1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Test\FlexiPeeHP; |
4
|
|
|
|
5
|
|
|
use FlexiPeeHP\FlexiBeeRW; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Generated by PHPUnit_SkeletonGenerator on 2016-05-04 at 10:08:36. |
9
|
|
|
*/ |
10
|
|
|
class FlexiBeeRWTest extends FlexiBeeROTest |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Poznámka vkládaná do záznamů vytvářených během testů |
14
|
|
|
* @var strig |
15
|
|
|
*/ |
16
|
|
|
public $poznam = 'Generováno UnitTestem PHP Knihovny https://github.com/Spoje-NET/FlexiPeeHP'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* |
20
|
|
|
* @var array |
21
|
|
|
*/ |
22
|
|
|
public $insertableData = []; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var FlexiBeeRW |
26
|
|
|
*/ |
27
|
|
|
protected $object; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Gives You data able to insert into current evidence |
31
|
|
|
* |
32
|
|
|
* @param string $code custom record code |
33
|
|
|
* |
34
|
|
|
* @return array |
35
|
|
|
*/ |
36
|
|
|
public function getDataForInsert($code = 'UnitTest') |
37
|
|
|
{ |
38
|
|
|
$dataForInsert = []; |
39
|
|
|
$structure = $this->object->getColumnsInfo(); |
40
|
|
|
if (count($structure) && array_key_exists('typDokl', $structure)) { |
41
|
|
|
if ($structure['typDokl']['type'] == 'relation') { |
42
|
|
|
$relatedEvidence = basename($structure['typDokl']['url']); |
43
|
|
|
$loader = new \FlexiPeeHP\FlexiBeeRO(null, |
44
|
|
|
['evidence' => $relatedEvidence]); |
45
|
|
|
$typDoklRaw = $loader->getColumnsFromFlexibee([ |
46
|
|
|
'kod'], ['limit' => 1]); |
47
|
|
|
$dataForInsert['typDokl'] = \FlexiPeeHP\FlexiBeeRO::code($typDoklRaw[0]['kod']); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
if (array_key_exists('poznam', $structure)) { |
51
|
|
|
$dataForInsert['poznam'] = $this->poznam; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
if (array_key_exists('kod', $structure)) { |
55
|
|
|
$dataForInsert['kod'] = \FlexiPeeHP\FlexiBeeRO::uncode($this->object->getKod($code)); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
return $dataForInsert; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Sets up the fixture, for example, opens a network connection. |
63
|
|
|
* This method is called before a test is executed. |
64
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::__construct |
65
|
|
|
*/ |
66
|
|
|
protected function setUp() |
67
|
|
|
{ |
68
|
|
|
$this->object = new FlexiBeeRW(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Tears down the fixture, for example, closes a network connection. |
73
|
|
|
* This method is called after a test is executed. |
74
|
|
|
*/ |
75
|
|
|
protected function tearDown() |
76
|
|
|
{ |
77
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::getLastInsertedId |
82
|
|
|
* @depends testInsertToFlexiBee |
83
|
|
|
*/ |
84
|
|
|
public function testGetLastInsertedId() |
85
|
|
|
{ |
86
|
|
|
$this->assertNotEmpty($this->object->getLastInsertedId()); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::insertToFlexiBee |
91
|
|
|
*/ |
92
|
|
|
public function testInsertToFlexiBee() |
93
|
|
|
{ |
94
|
|
|
if (empty($this->insertableData)) { |
95
|
|
|
$this->insertableData = $this->getDataForInsert('INSERTTEST'.time()); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
$this->object->insertToFlexiBee($this->insertableData); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::performAction |
103
|
|
|
* @expectedException \Exception |
104
|
|
|
*/ |
105
|
|
|
public function testPerformAction() |
106
|
|
|
{ |
107
|
|
|
$actions = $this->object->getActionsInfo(); |
108
|
|
|
|
109
|
|
|
if (count($actions)) { |
110
|
|
|
if (array_key_exists('new', $actions)) { |
111
|
|
|
$this->object->performAction('new', 'ext'); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
if (array_key_exists('storno', $actions)) { |
115
|
|
|
$this->object->insertToFlexiBee($this->getDataForInsert('StornoTest_'.time())); |
116
|
|
|
$this->object->performAction('storno', 'int'); |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
$this->object->performAction('nonexitst'); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @covers FlexiPeeHP\FlexiBeeRWRW::deleteFromFlexiBee |
124
|
|
|
*/ |
125
|
|
|
public function testDeleteFromFlexiBee() |
126
|
|
|
{ |
127
|
|
|
// Remove the following lines when you implement this test. |
128
|
|
|
$this->markTestIncomplete( |
129
|
|
|
'This test has not been implemented yet.' |
130
|
|
|
); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::timestampToFlexiDate |
135
|
|
|
*/ |
136
|
|
|
public function testTimestampToFlexiDate() |
137
|
|
|
{ |
138
|
|
|
$this->assertNull($this->object->timestampToFlexiDate()); |
139
|
|
|
$this->assertEquals('2016-09-16', |
140
|
|
|
$this->object->timestampToFlexiDate('1474040506')); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::timestampToFlexiDateTime |
145
|
|
|
*/ |
146
|
|
|
public function testTimestampToFlexiDateTime() |
147
|
|
|
{ |
148
|
|
|
$this->assertNull($this->object->timestampToFlexiDateTime()); |
149
|
|
|
$flexiDateTime = $this->object->timestampToFlexiDateTime('1474040506'); |
150
|
|
|
$this->assertEquals('2016-09-16', substr($flexiDateTime, 0, 10)); |
151
|
|
|
$this->assertEquals(':41:46', substr($flexiDateTime, -6)); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::objectToID |
156
|
|
|
*/ |
157
|
|
|
public function testObjectToID() |
158
|
|
|
{ |
159
|
|
|
$id = \Ease\Sand::randomNumber(1, 9999); |
160
|
|
|
$this->object->setMyKey($id); |
|
|
|
|
161
|
|
|
$this->assertEquals([$id], $this->object->objectToID([$this->object])); |
162
|
|
|
parent::testObjectToID(); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::getRecordID |
167
|
|
|
*/ |
168
|
|
|
public function testGetRecordID() |
169
|
|
|
{ |
170
|
|
|
parent::testGetRecordID(); |
171
|
|
|
$structure = $this->object->getEvidenceInfo(); |
172
|
|
|
if (count($structure) && array_key_exists('kod', $structure)) { |
173
|
|
|
$this->object->setData(['kod' => 'KOD']); |
174
|
|
|
$this->assertEquals('code:KOD', $this->object->getRecordID()); |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::takeData |
180
|
|
|
* @todo Implement testTakeData(). |
181
|
|
|
*/ |
182
|
|
|
public function testTakeData() |
183
|
|
|
{ |
184
|
|
|
// Remove the following lines when you implement this test. |
185
|
|
|
$this->markTestIncomplete( |
186
|
|
|
'This test has not been implemented yet.' |
187
|
|
|
); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::controlMandatoryColumns |
192
|
|
|
* @todo Implement testControlMandatoryColumns(). |
193
|
|
|
*/ |
194
|
|
|
public function testControlMandatoryColumns() |
195
|
|
|
{ |
196
|
|
|
// Remove the following lines when you implement this test. |
197
|
|
|
$this->markTestIncomplete( |
198
|
|
|
'This test has not been implemented yet.' |
199
|
|
|
); |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::controlReadOnlyColumns |
204
|
|
|
* @todo Implement testControlReadOnlyColumns(). |
205
|
|
|
*/ |
206
|
|
|
public function testControlReadOnlyColumns() |
207
|
|
|
{ |
208
|
|
|
// Remove the following lines when you implement this test. |
209
|
|
|
$this->markTestIncomplete( |
210
|
|
|
'This test has not been implemented yet.' |
211
|
|
|
); |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::addArrayToBranch |
216
|
|
|
* @todo Implement testAddArrayToBranch(). |
217
|
|
|
*/ |
218
|
|
|
public function testAddArrayToBranch() |
219
|
|
|
{ |
220
|
|
|
// Remove the following lines when you implement this test. |
221
|
|
|
$this->markTestIncomplete( |
222
|
|
|
'This test has not been implemented yet.' |
223
|
|
|
); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::addObjectToBranch |
228
|
|
|
* @todo Implement testAddObjectToBranch(). |
229
|
|
|
*/ |
230
|
|
|
public function testAddObjectToBranch() |
231
|
|
|
{ |
232
|
|
|
// Remove the following lines when you implement this test. |
233
|
|
|
$this->markTestIncomplete( |
234
|
|
|
'This test has not been implemented yet.' |
235
|
|
|
); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::vazbaAdd |
240
|
|
|
* @todo Implement testVazbaAdd(). |
241
|
|
|
*/ |
242
|
|
|
public function testVazbaAdd() |
243
|
|
|
{ |
244
|
|
|
// Remove the following lines when you implement this test. |
245
|
|
|
$this->markTestIncomplete( |
246
|
|
|
'This test has not been implemented yet.' |
247
|
|
|
); |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::vazbaDel |
252
|
|
|
* @todo Implement testVazbaDel(). |
253
|
|
|
*/ |
254
|
|
|
public function testVazbaDel() |
255
|
|
|
{ |
256
|
|
|
// Remove the following lines when you implement this test. |
257
|
|
|
$this->markTestIncomplete( |
258
|
|
|
'This test has not been implemented yet.' |
259
|
|
|
); |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::getJsonizedData |
264
|
|
|
* @todo Implement testGetJsonizedData(). |
265
|
|
|
*/ |
266
|
|
|
public function testGetJsonizedData() |
267
|
|
|
{ |
268
|
|
|
// Remove the following lines when you implement this test. |
269
|
|
|
$this->markTestIncomplete( |
270
|
|
|
'This test has not been implemented yet.' |
271
|
|
|
); |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* @covers FlexiPeeHP\FlexiBeeRW::refresh |
276
|
|
|
* @todo Implement testRefresh(). |
277
|
|
|
*/ |
278
|
|
|
public function testRefresh() |
279
|
|
|
{ |
280
|
|
|
// Remove the following lines when you implement this test. |
281
|
|
|
$this->markTestIncomplete( |
282
|
|
|
'This test has not been implemented yet.' |
283
|
|
|
); |
284
|
|
|
} |
285
|
|
|
} |
286
|
|
|
|
This check looks for type mismatches where the missing type is
false
. This is usually indicative of an error condtion.Consider the follow example
This function either returns a new
DateTime
object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returnedfalse
before passing on the value to another function or method that may not be able to handle afalse
.