Blame view

tests/TestCase/Model/Table/MaterielsTableTest.php 3.84 KB
6c4edfa3   Alexandre   First Commit LabI...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?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',
9212589e   Alexandre   Ajout tests (débu...
33
        'app.users',
6c4edfa3   Alexandre   First Commit LabI...
34
35
36
37
        'app.organismes',
        'app.sites',
        'app.documents',
        'app.suivis',
32b504ee   Alexis Proust   mise a jour test
38
39
        'app.emprunts',
		'app.fournisseurs',
ed60c45e   Etienne Pallier   Nouveau script in...
40
41
42
43
44
45
		'app.unites',
        // 14/1/19 bake autogenerated:
        'app.type_suivis',
        'app.type_documents',
        'app.fichemetrologiques',
        //'app.mesures',
6c4edfa3   Alexandre   First Commit LabI...
46
    ];
ed60c45e   Etienne Pallier   Nouveau script in...
47
    
6c4edfa3   Alexandre   First Commit LabI...
48
49
50
51
52
53
54
55
56

    /**
     * setUp method
     *
     * @return void
     */
    public function setUp()
    {
        parent::setUp();
ed60c45e   Etienne Pallier   Nouveau script in...
57
58
59
        // 14/1/19 bake autogenerated:
        $config = TableRegistry::exists('Materiels') ? [] : ['className' => MaterielsTable::class];
        //$config = TableRegistry::exists('Materiels') ? [] : ['className' => 'App\Model\Table\MaterielsTable'];
6c4edfa3   Alexandre   First Commit LabI...
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
        $this->Materiels = TableRegistry::get('Materiels', $config);
    }

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

        parent::tearDown();
    }

    /**
ed60c45e   Etienne Pallier   Nouveau script in...
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
     * 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.');
    }
     */

    
    /**
183ce554   Alexandre   Ajout de test, su...
117
     * Test check_string method
6c4edfa3   Alexandre   First Commit LabI...
118
119
120
     *
     * @return void
     */
183ce554   Alexandre   Ajout de test, su...
121
    public function testCheck_string()
6c4edfa3   Alexandre   First Commit LabI...
122
    {
183ce554   Alexandre   Ajout de test, su...
123
124
125
126
127
		$result = $this->Materiels->check_string("& materiel");
		$this->assertTextEquals(false, $result);
		
		$result = $this->Materiels->check_string("materiel");
		$this->assertTextEquals(true, $result);
6c4edfa3   Alexandre   First Commit LabI...
128
    }
183ce554   Alexandre   Ajout de test, su...
129
    
6c4edfa3   Alexandre   First Commit LabI...
130
    /**
183ce554   Alexandre   Ajout de test, su...
131
     * Test check_string_with_some_special_cars method
6c4edfa3   Alexandre   First Commit LabI...
132
133
134
     *
     * @return void
     */
183ce554   Alexandre   Ajout de test, su...
135
    public function testCheck_string_with_some_special_cars()
6c4edfa3   Alexandre   First Commit LabI...
136
    {
183ce554   Alexandre   Ajout de test, su...
137
138
139
140
141
    	$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);
6c4edfa3   Alexandre   First Commit LabI...
142
143
144
    }

    /**
9212589e   Alexandre   Ajout tests (débu...
145
146
147
148
149
150
     * Test checkStatus method
     *
     * @return void
     */
    public function testCheckStatus()
    {
183ce554   Alexandre   Ajout de test, su...
151
152
        $result = $this->Materiels->checkStatus("pas un status");
        $this->assertTextEquals(false, $result);     
9212589e   Alexandre   Ajout tests (débu...
153

183ce554   Alexandre   Ajout de test, su...
154
155
        $result = $this->Materiels->checkStatus("CREATE");
        $this->assertTextEquals(false, $result);
9212589e   Alexandre   Ajout tests (débu...
156

183ce554   Alexandre   Ajout de test, su...
157
158
159
160
161
162
163
164
165
166
167
        $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);
9212589e   Alexandre   Ajout tests (débu...
168
    }
183ce554   Alexandre   Ajout de test, su...
169
170
171
172




6c4edfa3   Alexandre   First Commit LabI...
173
}