MaterielsTableTest.php
2.77 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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
117
118
119
120
121
122
<?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'
];
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$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 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);
}
}