MaterielsTableTest.php 4.13 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.SurCategories',
        'app.Categories',
        'app.SousCategories',
        
        'app.GroupesThematiques',
        'app.GroupesMetiers',
        
        'app.Projets',
        
        'app.Fakeldapusers',
        'app.Users',
        'app.Organismes',
        'app.Sites',
        'app.Documents',
        'app.Suivis',
        'app.Emprunts',
		'app.Fournisseurs',
		'app.Unites',
        
        // 14/1/19 bake autogenerated:
        'app.TypeSuivis',
        'app.TypeDocuments',
        'app.Fichemetrologiques',
        //'app.mesures',
    ];
    

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




}