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 string |
||||||
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)) { |
||||||
41 | if (array_key_exists('typDokl', $structure)) { |
||||||
42 | if ($structure['typDokl']['type'] == 'relation') { |
||||||
43 | $relatedEvidence = basename($structure['typDokl']['url']); |
||||||
44 | $loader = new \FlexiPeeHP\FlexiBeeRO(null, |
||||||
45 | ['evidence' => $relatedEvidence]); |
||||||
46 | $typDoklRaw = $loader->getColumnsFromFlexibee([ |
||||||
47 | 'kod'], ['limit' => 1]); |
||||||
48 | $dataForInsert['typDokl'] = \FlexiPeeHP\FlexiBeeRO::code($typDoklRaw[0]['kod']); |
||||||
49 | } |
||||||
50 | } |
||||||
51 | if (array_key_exists('poznam', $structure)) { |
||||||
52 | $dataForInsert['poznam'] = $this->poznam.' '.$code; |
||||||
53 | } |
||||||
54 | |||||||
55 | if (array_key_exists('nazev', $structure)) { |
||||||
56 | $dataForInsert['nazev'] = $code.' '.$this->poznam.' '; |
||||||
57 | } |
||||||
58 | |||||||
59 | if (array_key_exists('kod', $structure)) { |
||||||
60 | $dataForInsert['kod'] = \FlexiPeeHP\FlexiBeeRO::uncode($this->object->getKod($code)); |
||||||
61 | } |
||||||
62 | } |
||||||
63 | return $dataForInsert; |
||||||
64 | } |
||||||
65 | |||||||
66 | /** |
||||||
67 | * Sets up the fixture, for example, opens a network connection. |
||||||
68 | * This method is called before a test is executed. |
||||||
69 | * @covers FlexiPeeHP\FlexiBeeRW::__construct |
||||||
70 | */ |
||||||
71 | protected function setUp(): void |
||||||
72 | { |
||||||
73 | $this->object = new FlexiBeeRW(null, |
||||||
74 | ['atomic' => false, 'debug' => false]); |
||||||
75 | } |
||||||
76 | |||||||
77 | /** |
||||||
78 | * Tears down the fixture, for example, closes a network connection. |
||||||
79 | * This method is called after a test is executed. |
||||||
80 | */ |
||||||
81 | protected function tearDown(): void |
||||||
82 | { |
||||||
83 | |||||||
84 | } |
||||||
85 | |||||||
86 | /** |
||||||
87 | * @covers FlexiPeeHP\FlexiBeeRW::performAction |
||||||
88 | * @expectedException \Exception |
||||||
89 | */ |
||||||
90 | public function testPerformAction() |
||||||
91 | { |
||||||
92 | $actions = $this->object->getActionsInfo(); |
||||||
93 | |||||||
94 | if (!empty($actions) && count($actions)) { |
||||||
95 | if (array_key_exists('new', $actions)) { |
||||||
96 | $this->object->performAction('new', 'ext'); |
||||||
97 | } |
||||||
98 | |||||||
99 | if (array_key_exists('storno', $actions)) { |
||||||
100 | $this->object->insertToFlexiBee($this->getDataForInsert('StornoTest_'.time())); |
||||||
101 | $this->object->performAction('storno', 'int'); |
||||||
102 | } |
||||||
103 | } |
||||||
104 | $this->object->performAction('nonexitst'); |
||||||
105 | } |
||||||
106 | |||||||
107 | /** |
||||||
108 | * @covers FlexiPeeHP\FlexiBeeRW::timestampToFlexiDate |
||||||
109 | */ |
||||||
110 | public function testTimestampToFlexiDate() |
||||||
111 | { |
||||||
112 | $this->assertNull($this->object->timestampToFlexiDate()); |
||||||
0 ignored issues
–
show
|
|||||||
113 | $this->assertEquals('2016-09-16', |
||||||
0 ignored issues
–
show
The method
assertEquals() does not exist on Test\FlexiPeeHP\FlexiBeeRWTest .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
114 | $this->object->timestampToFlexiDate('1474040506')); |
||||||
115 | } |
||||||
116 | |||||||
117 | /** |
||||||
118 | * @covers FlexiPeeHP\FlexiBeeRW::timestampToFlexiDateTime |
||||||
119 | */ |
||||||
120 | public function testTimestampToFlexiDateTime() |
||||||
121 | { |
||||||
122 | $this->assertNull($this->object->timestampToFlexiDateTime()); |
||||||
123 | $flexiDateTime = $this->object->timestampToFlexiDateTime('1474040506'); |
||||||
124 | $this->assertEquals('2016-09-16', substr($flexiDateTime, 0, 10)); |
||||||
125 | $this->assertEquals(':41:46', substr($flexiDateTime, -6)); |
||||||
126 | } |
||||||
127 | |||||||
128 | /** |
||||||
129 | * @covers FlexiPeeHP\FlexiBeeRW::objectToID |
||||||
130 | */ |
||||||
131 | public function testObjectToID() |
||||||
132 | { |
||||||
133 | $id = \Ease\Sand::randomNumber(1, 9999); |
||||||
134 | $this->object->setMyKey($id); |
||||||
135 | $this->assertEquals([$id], $this->object->objectToID([$this->object])); |
||||||
136 | parent::testObjectToID(); |
||||||
137 | } |
||||||
138 | |||||||
139 | /** |
||||||
140 | * @covers FlexiPeeHP\FlexiBeeRW::getRecordID |
||||||
141 | */ |
||||||
142 | public function testGetRecordID() |
||||||
143 | { |
||||||
144 | parent::testGetRecordID(); |
||||||
145 | $structure = $this->object->getEvidenceInfo(); |
||||||
146 | if (!empty($structure) && count($structure) && array_key_exists('kod', $structure)) { |
||||||
147 | $this->object->setData(['kod' => 'KOD']); |
||||||
148 | $this->assertEquals('code:KOD', $this->object->getRecordID()); |
||||||
149 | } |
||||||
150 | } |
||||||
151 | |||||||
152 | /** |
||||||
153 | * @covers FlexiPeeHP\FlexiBeeRW::controlMandatoryColumns |
||||||
154 | */ |
||||||
155 | public function testControlMandatoryColumns() |
||||||
156 | { |
||||||
157 | $this->object->controlMandatoryColumns(); |
||||||
0 ignored issues
–
show
The function
FlexiPeeHP\FlexiBeeRW::controlMandatoryColumns() has been deprecated: since version 1.8.7
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||||
158 | } |
||||||
159 | |||||||
160 | /** |
||||||
161 | * @covers FlexiPeeHP\FlexiBeeRW::controlReadOnlyColumns |
||||||
162 | */ |
||||||
163 | public function testControlReadOnlyColumns() |
||||||
164 | { |
||||||
165 | $this->object->controlReadOnlyColumns(['id' => 1]); |
||||||
166 | } |
||||||
167 | |||||||
168 | /** |
||||||
169 | * @covers FlexiPeeHP\FlexiBeeRW::addArrayToBranch |
||||||
170 | */ |
||||||
171 | public function testAddArrayToBranch() |
||||||
172 | { |
||||||
173 | $this->object->addArrayToBranch(['nazev' => 'test'], 'podEvidence'); |
||||||
174 | } |
||||||
175 | |||||||
176 | /** |
||||||
177 | * @covers FlexiPeeHP\FlexiBeeRW::addObjectToBranch |
||||||
178 | */ |
||||||
179 | public function testAddObjectToBranch() |
||||||
180 | { |
||||||
181 | $this->object->addObjectToBranch(new \FlexiPeeHP\FakturaVydanaPolozka(['nazev' => 'test'])); |
||||||
182 | } |
||||||
183 | |||||||
184 | /** |
||||||
185 | * @covers FlexiPeeHP\FlexiBeeRW::vazbaAdd |
||||||
186 | */ |
||||||
187 | public function testVazbaAdd() |
||||||
188 | { |
||||||
189 | $this->object->vazbaAdd(\Ease\Sand::randomNumber()); |
||||||
190 | } |
||||||
191 | |||||||
192 | /** |
||||||
193 | * @covers FlexiPeeHP\FlexiBeeRW::vazbaDel |
||||||
194 | */ |
||||||
195 | public function testVazbaDel() |
||||||
196 | { |
||||||
197 | $this->object->vazbaDel(\Ease\Sand::randomNumber()); |
||||||
198 | } |
||||||
199 | |||||||
200 | /** |
||||||
201 | * @covers FlexiPeeHP\FlexiBeeRW::getJsonizedData |
||||||
202 | */ |
||||||
203 | public function testGetJsonizedData() |
||||||
204 | { |
||||||
205 | $this->object->setData(['id' => time(), 'nazev' => \Ease\Sand::randomString(), |
||||||
206 | 'stitky' => ['TEST', 'TESTING']]); |
||||||
207 | $this->object->getJsonizedData(); |
||||||
208 | } |
||||||
209 | |||||||
210 | |||||||
211 | |||||||
212 | /** |
||||||
213 | * @covers FlexiPeeHP\FlexiBeeRW::insertToFlexiBee |
||||||
214 | */ |
||||||
215 | public function testInsertToFlexiBee() |
||||||
216 | { |
||||||
217 | $this->object->insertToFlexiBee(['id' => 'ext:test:'.time()]); |
||||||
218 | $this->object->setData(['id' => 'ext:test:'.time()], true); |
||||||
219 | $this->object->insertToFlexiBee(); |
||||||
220 | } |
||||||
221 | |||||||
222 | /** |
||||||
223 | * @covers FlexiPeeHP\FlexiBeeRW::parseResponse |
||||||
224 | */ |
||||||
225 | public function testParseResponse() |
||||||
226 | { |
||||||
227 | $responseDecoded = array( |
||||||
228 | '@version' => '1.0', |
||||||
229 | 'success' => 'true', |
||||||
230 | 'stats' => |
||||||
231 | array( |
||||||
232 | 'created' => '1', |
||||||
233 | 'updated' => '5', |
||||||
234 | 'deleted' => '0', |
||||||
235 | 'skipped' => '0', |
||||||
236 | 'failed' => '0', |
||||||
237 | ), |
||||||
238 | 'results' => |
||||||
239 | array( |
||||||
240 | 0 => |
||||||
241 | array( |
||||||
242 | 'id' => '792', |
||||||
243 | 'request-id' => 'EXT:APP:100', |
||||||
244 | 'ref' => '/c/flexipeehp/adresar/792', |
||||||
245 | ), |
||||||
246 | 1 => |
||||||
247 | array( |
||||||
248 | 'id' => '793', |
||||||
249 | 'request-id' => 'EXT:APP:200', |
||||||
250 | 'ref' => '/c/flexipeehp/adresar/793', |
||||||
251 | ), |
||||||
252 | 2 => |
||||||
253 | array( |
||||||
254 | 'id' => '794', |
||||||
255 | 'request-id' => 'EXT:APP:300', |
||||||
256 | 'ref' => '/c/flexipeehp/adresar/794', |
||||||
257 | ), |
||||||
258 | 3 => |
||||||
259 | array( |
||||||
260 | 'id' => '795', |
||||||
261 | 'request-id' => 'EXT:APP:400', |
||||||
262 | 'ref' => '/c/flexipeehp/adresar/795', |
||||||
263 | ), |
||||||
264 | 4 => |
||||||
265 | array( |
||||||
266 | 'id' => '830', |
||||||
267 | 'request-id' => 'EXT:APP:500', |
||||||
268 | 'ref' => '/c/flexipeehp/banka/830', |
||||||
269 | ), |
||||||
270 | 5 => |
||||||
271 | array( |
||||||
272 | 'id' => '28', |
||||||
273 | 'ref' => '/c/flexipeehp/adresar-bankovni-ucet/28', |
||||||
274 | ), |
||||||
275 | ), |
||||||
276 | ) |
||||||
277 | ; |
||||||
278 | $this->object->parseResponse($responseDecoded, 201); |
||||||
279 | } |
||||||
280 | |||||||
281 | /** |
||||||
282 | * @covers FlexiPeeHP\FlexiBeeRW::assignResultIDs |
||||||
283 | */ |
||||||
284 | public function testAssignResultIDs() |
||||||
285 | { |
||||||
286 | $ids = array( |
||||||
287 | 'adresar' => |
||||||
288 | array( |
||||||
289 | 'EXT:APP:100' => '792', |
||||||
290 | 'EXT:APP:200' => '793', |
||||||
291 | 'EXT:APP:300' => '794', |
||||||
292 | 'EXT:APP:400' => '795', |
||||||
293 | ), |
||||||
294 | 'banka' => |
||||||
295 | array( |
||||||
296 | 'EXT:APP:500' => '830', |
||||||
297 | ), |
||||||
298 | 'adresar-bankovni-ucet' => |
||||||
299 | array( |
||||||
300 | '' => '27', |
||||||
301 | ), |
||||||
302 | ); |
||||||
303 | $this->object->assignResultIDs($ids); |
||||||
304 | } |
||||||
305 | |||||||
306 | /** |
||||||
307 | * @covers FlexiPeeHP\FlexiBeeRW::extractResultIDs |
||||||
308 | */ |
||||||
309 | public function testExtractResultIDs() |
||||||
310 | { |
||||||
311 | $resultInfo = array( |
||||||
312 | 0 => |
||||||
313 | array( |
||||||
314 | 'id' => '792', |
||||||
315 | 'request-id' => 'EXT:APP:100', |
||||||
316 | 'ref' => '/c/flexipeehp/adresar/792', |
||||||
317 | ), |
||||||
318 | 1 => |
||||||
319 | array( |
||||||
320 | 'id' => '793', |
||||||
321 | 'request-id' => 'EXT:APP:200', |
||||||
322 | 'ref' => '/c/flexipeehp/adresar/793', |
||||||
323 | ), |
||||||
324 | 2 => |
||||||
325 | array( |
||||||
326 | 'id' => '794', |
||||||
327 | 'request-id' => 'EXT:APP:300', |
||||||
328 | 'ref' => '/c/flexipeehp/adresar/794', |
||||||
329 | ), |
||||||
330 | 3 => |
||||||
331 | array( |
||||||
332 | 'id' => '795', |
||||||
333 | 'request-id' => 'EXT:APP:400', |
||||||
334 | 'ref' => '/c/flexipeehp/adresar/795', |
||||||
335 | ), |
||||||
336 | 4 => |
||||||
337 | array( |
||||||
338 | 'id' => '830', |
||||||
339 | 'request-id' => 'EXT:APP:500', |
||||||
340 | 'ref' => '/c/flexipeehp/banka/830', |
||||||
341 | ), |
||||||
342 | 5 => |
||||||
343 | array( |
||||||
344 | 'id' => '26', |
||||||
345 | 'ref' => '/c/flexipeehp/adresar-bankovni-ucet/26', |
||||||
346 | ), |
||||||
347 | ); |
||||||
348 | $this->object->extractResultIDs($resultInfo); |
||||||
349 | } |
||||||
350 | |||||||
351 | /** |
||||||
352 | * @covers FlexiPeeHP\FlexiBeeRW::getLastInsertedId |
||||||
353 | */ |
||||||
354 | public function testGetLastInsertedId() |
||||||
355 | { |
||||||
356 | $this->object->getLastInsertedId(); |
||||||
357 | } |
||||||
358 | |||||||
359 | /** |
||||||
360 | * @covers FlexiPeeHP\FlexiBeeRW::deleteFromFlexiBee |
||||||
361 | */ |
||||||
362 | public function testDeleteFromFlexiBee() |
||||||
363 | { |
||||||
364 | $this->object->deleteFromFlexiBee(); |
||||||
365 | } |
||||||
366 | |||||||
367 | /** |
||||||
368 | * @covers FlexiPeeHP\FlexiBeeRW::takeData |
||||||
369 | */ |
||||||
370 | public function testTakeData() |
||||||
371 | { |
||||||
372 | $this->object->takeData(['id' => \Ease\Sand::randomNumber()]); |
||||||
373 | } |
||||||
374 | |||||||
375 | /** |
||||||
376 | * @after |
||||||
377 | * @covers FlexiPeeHP\FlexiBeeRW::getDataForJSON |
||||||
378 | */ |
||||||
379 | public function testGetDataForJSON() |
||||||
380 | { |
||||||
381 | $this->object->setData(['name' => 'test']); |
||||||
382 | $this->object->getDataForJSON(); |
||||||
383 | } |
||||||
384 | |||||||
385 | /** |
||||||
386 | * @covers FlexiPeeHP\FlexiBeeRW::addExternalID |
||||||
387 | */ |
||||||
388 | public function testAddExternalID() |
||||||
389 | { |
||||||
390 | if (empty($this->object->getEvidence())) { |
||||||
391 | $this->object->setEvidence('banka'); |
||||||
392 | } |
||||||
393 | $this->object->addExternalID('ext:test:'.\Ease\Sand::randomNumber()); |
||||||
394 | } |
||||||
395 | |||||||
396 | /** |
||||||
397 | * @covers FlexiPeeHP\FlexiBeeRW::changeExternalID |
||||||
398 | */ |
||||||
399 | public function testChangeExternalID() |
||||||
400 | { |
||||||
401 | $this->object->changeExternalID('test', \Ease\Sand::randomNumber(), |
||||||
402 | \Ease\Sand::randomNumber()); |
||||||
403 | } |
||||||
404 | |||||||
405 | /** |
||||||
406 | * @covers FlexiPeeHP\FlexiBeeRW::sync |
||||||
407 | */ |
||||||
408 | public function testSync() |
||||||
409 | { |
||||||
410 | $code = \Ease\Sand::randomString(); |
||||||
411 | $this->assertFalse($this->object->sync(['kod' => $code.'X'])); |
||||||
0 ignored issues
–
show
The method
assertFalse() does not exist on Test\FlexiPeeHP\FlexiBeeRWTest .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
412 | if ($this->object->getEvidence()) { |
||||||
413 | $syncResult = $this->object->sync($this->getDataForInsert($code)); |
||||||
414 | $this->assertTrue($syncResult); |
||||||
0 ignored issues
–
show
The method
assertTrue() does not exist on Test\FlexiPeeHP\FlexiBeeRWTest .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
415 | } |
||||||
416 | } |
||||||
417 | } |
||||||
418 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.