MaterielsTableTest.php 3.84 KB
<?php
namespace App\Test\TestCase\Model\Table;

use App\Model\Table\MaterielsTable;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;

/**
 * App\Model\Table\MaterielsTable Test Case
 */
class MaterielsTableTest extends TestCase
{

    /**
     * Test subject
     *
     * @var \App\Model\Table\MaterielsTable
     */
    public $Materiels;

    /**
     * Fixtures
     *
     * @var array
     */
    public $fixtures = [
        'app.materiels',
        'app.sur_categories',
        'app.categories',
        'app.sous_categories',
        'app.groupes_thematiques',
        'app.groupes_metiers',
        'app.users',
        'app.organismes',
        'app.sites',
        'app.documents',
        'app.suivis',
        'app.emprunts',
		'app.fournisseurs',
		'app.unites',
        // 14/1/19 bake autogenerated:
        'app.type_suivis',
        'app.type_documents',
        'app.fichemetrologiques',
        //'app.mesures',
    ];
    

    /**
     * setUp method
     *
     * @return void
     */
    public function setUp()
    {
        parent::setUp();
        // 14/1/19 bake autogenerated:
        $config = TableRegistry::exists('Materiels') ? [] : ['className' => MaterielsTable::class];
        //$config = TableRegistry::exists('Materiels') ? [] : ['className' => 'App\Model\Table\MaterielsTable'];
        $this->Materiels = TableRegistry::get('Materiels', $config);
    }

    /**
     * tearDown method
     *
     * @return void
     */
    public function tearDown()
    {
        unset($this->Materiels);

        parent::tearDown();
    }

    /**
     * Test initialize method
     *
     * @return void
    public function testInitialize()
    {
        $this->markTestIncomplete('Not implemented yet.');
    }
     */
    
    /**
     * Test validationDefault method
     *
     * @return void
    public function testValidationDefault()
    {
        $this->markTestIncomplete('Not implemented yet.');
    }
     */

    /**
     * Test buildRules method
     *
     * @return void
    public function testBuildRules()
    {
        $this->markTestIncomplete('Not implemented yet.');
    }
     */
    
    /**
     * Test beforeSave method
     *
     * @return void
    public function testBeforeSave()
    {
        $this->markTestIncomplete('Not implemented yet.');
    }
     */

    
    /**
     * Test check_string method
     *
     * @return void
     */
    public function testCheck_string()
    {
		$result = $this->Materiels->check_string("& materiel");
		$this->assertTextEquals(false, $result);
		
		$result = $this->Materiels->check_string("materiel");
		$this->assertTextEquals(true, $result);
    }
    
    /**
     * Test check_string_with_some_special_cars method
     *
     * @return void
     */
    public function testCheck_string_with_some_special_cars()
    {
    	$result = $this->Materiels->check_string_with_some_special_cars("$$ materiel");
    	$this->assertTextEquals(false, $result);
    	
    	$result = $this->Materiels->check_string_with_some_special_cars("& materiel");
    	$this->assertTextEquals(true, $result);
    }

    /**
     * Test checkStatus method
     *
     * @return void
     */
    public function testCheckStatus()
    {
        $result = $this->Materiels->checkStatus("pas un status");
        $this->assertTextEquals(false, $result);     

        $result = $this->Materiels->checkStatus("CREATE");
        $this->assertTextEquals(false, $result);

        $result = $this->Materiels->checkStatus("CREATED");
        $this->assertTextEquals(true, $result);
        
        $result = $this->Materiels->checkStatus("VALIDATED");
        $this->assertTextEquals(true, $result);
        
        $result = $this->Materiels->checkStatus("TOBEARCHIVED");
        $this->assertTextEquals(true, $result);
        
        $result = $this->Materiels->checkStatus("ARCHIVED");
        $this->assertTextEquals(true, $result);
    }




}