1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Test\FlexiPeeHP; |
4
|
|
|
|
5
|
|
|
use FlexiPeeHP\FlexiBeeRO; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Generated by PHPUnit_SkeletonGenerator on 2016-05-04 at 10:08:36. |
9
|
|
|
*/ |
10
|
|
|
class FlexiBeeROTest extends \Test\Ease\BrickTest |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var FlexiBeeRO |
14
|
|
|
*/ |
15
|
|
|
protected $object; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Sets up the fixture, for example, opens a network connection. |
19
|
|
|
* This method is called before a test is executed. |
20
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::__construct |
21
|
|
|
*/ |
22
|
|
|
protected function setUp() |
23
|
|
|
{ |
24
|
|
|
$this->object = new FlexiBeeRO(); |
25
|
|
|
$this->object->evidence = 'c'; |
26
|
|
|
$this->object->prefix = ''; |
27
|
|
|
$this->object->company = ''; |
28
|
|
|
$this->object->nameSpace = 'companies'; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Tears down the fixture, for example, closes a network connection. |
33
|
|
|
* This method is called after a test is executed. |
34
|
|
|
*/ |
35
|
|
|
protected function tearDown() |
36
|
|
|
{ |
37
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testConstructor() |
41
|
|
|
{ |
42
|
|
|
$classname = get_class($this->object); |
43
|
|
|
$evidence = $this->object->getEvidence(); |
44
|
|
|
|
45
|
|
|
// Get mock, without the constructor being called |
46
|
|
|
$mock = $this->getMockBuilder($classname) |
47
|
|
|
->disableOriginalConstructor() |
48
|
|
|
->getMockForAbstractClass(); |
49
|
|
|
$mock->__construct(''); |
50
|
|
|
|
51
|
|
|
$mock->__construct('', |
52
|
|
|
[ |
53
|
|
|
'company' => 'Firma_s_r_o_', |
54
|
|
|
'url' => 'https://flexibee.firma.cz/', |
55
|
|
|
'user' => 'rest', |
56
|
|
|
'password' => '-dj3x21xaA_', 'evidence' => $evidence]); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::curlInit |
61
|
|
|
*/ |
62
|
|
|
public function testCurlInit() |
63
|
|
|
{ |
64
|
|
|
$this->object->curlInit(); |
65
|
|
|
$this->assertTrue(is_resource($this->object->curl)); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::processInit |
70
|
|
|
*/ |
71
|
|
|
public function testProcessInit() |
72
|
|
|
{ |
73
|
|
|
$this->object->processInit(['id' => 1]); |
74
|
|
|
$this->assertEquals(1, $this->object->getDataValue('id')); |
75
|
|
|
if (!is_null($this->object->evidence) && $this->object->evidence != 'test') { |
76
|
|
|
$firstID = $this->object->getColumnsFromFlexibee('id', |
|
|
|
|
77
|
|
|
['limit' => 1]); |
78
|
|
|
$this->object->processInit((int) current($firstID)); |
79
|
|
|
$this->assertNotEmpty($this->object->__toString()); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::setUp |
85
|
|
|
*/ |
86
|
|
|
public function testSetUp() |
87
|
|
|
{ |
88
|
|
|
$this->object->setUp( |
89
|
|
|
[ |
90
|
|
|
'company' => 'cmp', |
91
|
|
|
'url' => 'url', |
92
|
|
|
'user' => 'usr', |
93
|
|
|
'password' => 'pwd', |
94
|
|
|
'evidence' => 'smlouva' |
95
|
|
|
] |
96
|
|
|
); |
97
|
|
|
$this->assertEquals('cmp', $this->object->company); |
98
|
|
|
$this->assertEquals('url', $this->object->url); |
99
|
|
|
$this->assertEquals('usr', $this->object->user); |
100
|
|
|
$this->assertEquals('pwd', $this->object->password); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::setEvidence |
105
|
|
|
*/ |
106
|
|
|
public function testSetEvidence() |
107
|
|
|
{ |
108
|
|
|
$this->object->setEvidence('nastaveni'); |
109
|
|
|
$this->assertEquals('nastaveni', $this->object->evidence); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::setCompany |
114
|
|
|
*/ |
115
|
|
|
public function testSetCompany() |
116
|
|
|
{ |
117
|
|
|
$this->object->setCompany('test_s_r_o_'); |
118
|
|
|
$this->assertEquals('test_s_r_o_', $this->object->company); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::object2array |
123
|
|
|
*/ |
124
|
|
|
public function testObject2array() |
125
|
|
|
{ |
126
|
|
|
$this->assertNull($this->object->object2array(new \stdClass())); |
127
|
|
|
$this->assertEquals( |
128
|
|
|
[ |
129
|
|
|
'item' => 1, |
130
|
|
|
'arrItem' => ['a', 'b' => 'c'] |
131
|
|
|
] |
132
|
|
|
, $this->object->object2array(new \Test\ObjectForTesting())); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::objectToID |
137
|
|
|
*/ |
138
|
|
|
public function testObjectToID() |
139
|
|
|
{ |
140
|
|
|
$id = \Ease\Sand::randomNumber(1, 9999); |
141
|
|
|
$this->object->setMyKey($id); |
|
|
|
|
142
|
|
|
$this->assertEquals([$id], $this->object->objectToID([$this->object])); |
143
|
|
|
|
144
|
|
|
$this->object->setDataValue('kod', 'TEST'); |
145
|
|
|
$this->assertEquals('code:TEST', |
146
|
|
|
$this->object->objectToID($this->object)); |
147
|
|
|
|
148
|
|
|
$this->assertEquals('TEST', $this->object->objectToID('TEST')); |
|
|
|
|
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::performRequest |
153
|
|
|
*/ |
154
|
|
|
public function testPerformRequest() |
155
|
|
|
{ |
156
|
|
|
$evidence = $this->object->getEvidence(); |
157
|
|
|
switch ($evidence) { |
158
|
|
|
case null: |
159
|
|
|
case '': |
160
|
|
|
case 'test': |
161
|
|
|
case 'c': |
162
|
|
|
$this->object->evidence = 'c'; |
163
|
|
|
$this->object->prefix = ''; |
164
|
|
|
$this->object->company = ''; |
165
|
|
|
$this->object->nameSpace = 'companies'; |
166
|
|
|
$json = $this->object->performRequest(); |
167
|
|
|
$this->assertArrayHasKey('company', $json); |
168
|
|
|
|
169
|
|
|
$xml = $this->object->performRequest(null, 'GET', 'xml'); |
170
|
|
|
$this->assertArrayHasKey('company', $xml); |
171
|
|
|
break; |
172
|
|
|
|
173
|
|
|
default: |
174
|
|
|
$json = $this->object->performRequest($evidence.'.json'); |
175
|
|
|
if (array_key_exists('message', $json)) { |
176
|
|
|
$this->assertArrayHasKey('@version', $json); |
177
|
|
|
} else { |
178
|
|
|
$this->assertArrayHasKey($evidence, $json); |
179
|
|
|
} |
180
|
|
|
break; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
|
184
|
|
|
$err = $this->object->performRequest('error.json'); |
185
|
|
|
$this->assertArrayHasKey('success', $err); |
186
|
|
|
$this->assertEquals('false', $err['success']); |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::setAction |
191
|
|
|
*/ |
192
|
|
|
public function testSetAction() |
193
|
|
|
{ |
194
|
|
|
$this->assertTrue($this->object->setAction('none')); |
195
|
|
|
$this->object->actionsAvailable = []; |
196
|
|
|
$this->assertFalse($this->object->setAction('none')); |
197
|
|
|
$this->object->actionsAvailable = ['copy']; |
198
|
|
|
$this->assertFalse($this->object->setAction('none')); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::getEvidence |
203
|
|
|
*/ |
204
|
|
|
public function testGetEvidence() |
205
|
|
|
{ |
206
|
|
|
$this->assertEquals($this->object->evidence, |
207
|
|
|
$this->object->getEvidence()); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::getCompany |
212
|
|
|
*/ |
213
|
|
|
public function testGetCompany() |
214
|
|
|
{ |
215
|
|
|
$this->assertEquals($this->object->company, $this->object->getCompany()); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::getResponseEvidence |
220
|
|
|
*/ |
221
|
|
|
public function testGetResponseEvidence() |
222
|
|
|
{ |
223
|
|
|
switch ($this->object->getEvidence()) { |
224
|
|
|
case 'c': |
225
|
|
|
$this->assertEquals('companies', |
226
|
|
|
$this->object->getResponseEvidence()); |
227
|
|
|
break; |
228
|
|
|
|
229
|
|
|
default: |
230
|
|
|
$this->assertEquals($this->object->getEvidence(), |
231
|
|
|
$this->object->getResponseEvidence()); |
232
|
|
|
break; |
233
|
|
|
} |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::getLastInsertedId |
238
|
|
|
* @depends testInsertToFlexiBee |
239
|
|
|
*/ |
240
|
|
|
public function testGetLastInsertedId() |
241
|
|
|
{ |
242
|
|
|
$this->assertNotEmpty($this->object->getLastInsertedId()); |
|
|
|
|
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::xml2array |
247
|
|
|
*/ |
248
|
|
|
public function testXml2array() |
249
|
|
|
{ |
250
|
|
|
$xml = '<card xmlns="http://businesscard.org"> |
251
|
|
|
<name>John Doe</name> |
252
|
|
|
<title>CEO, Widget Inc.</title> |
253
|
|
|
<email>[email protected]</email> |
254
|
|
|
<phone>(202) 456-1414</phone> |
255
|
|
|
<logo url="widget.gif"/> |
256
|
|
|
<a><b>c</b></a> |
257
|
|
|
</card>'; |
258
|
|
|
|
259
|
|
|
$data = ['name' => 'John Doe', 'title' => 'CEO, Widget Inc.', 'email' => '[email protected]', |
260
|
|
|
'phone' => '(202) 456-1414', 'logo' => '', 'a' => [['b' => 'c']]]; |
261
|
|
|
|
262
|
|
|
|
263
|
|
|
$this->assertEquals($data, $this->object->xml2array($xml)); |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::disconnect |
268
|
|
|
* |
269
|
|
|
* @depends testPerformRequest |
270
|
|
|
* @depends testLoadFlexiData |
271
|
|
|
* @depends testGetFlexiRow |
272
|
|
|
* @depends testGetFlexiData |
273
|
|
|
* @depends testLoadFromFlexiBee |
274
|
|
|
* @depends testInsertToFlexiBee |
275
|
|
|
* @depends testIdExists |
276
|
|
|
* @depends testRecordExists |
277
|
|
|
* @depends testGetColumnsFromFlexibee |
278
|
|
|
* @depends testSearchString |
279
|
|
|
*/ |
280
|
|
|
public function testDisconnect() |
281
|
|
|
{ |
282
|
|
|
$this->object->disconnect(); |
283
|
|
|
$this->assertNull($this->object->curl); |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::__destruct |
288
|
|
|
* @depends testDisconnect |
289
|
|
|
*/ |
290
|
|
|
public function testdestruct() |
291
|
|
|
{ |
292
|
|
|
$this->markTestSkipped(); |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::getFlexiRow |
297
|
|
|
*/ |
298
|
|
|
public function testGetFlexiRow() |
299
|
|
|
{ |
300
|
|
|
$this->object->getFlexiRow(0); |
301
|
|
|
$this->object->getFlexiRow(1); |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/** |
305
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::getFlexiData |
306
|
|
|
*/ |
307
|
|
|
public function testGetFlexiData() |
308
|
|
|
{ |
309
|
|
|
$evidence = $this->object->getEvidence(); |
310
|
|
|
|
311
|
|
|
switch ($evidence) { |
312
|
|
|
case null: |
313
|
|
|
$this->markTestSkipped('Unsupported evidence'); |
314
|
|
|
break; |
315
|
|
|
case 'c': |
316
|
|
|
$this->object->evidence = 'c'; |
317
|
|
|
$this->object->prefix = ''; |
318
|
|
|
$this->object->company = ''; |
319
|
|
|
$this->object->nameSpace = 'companies'; |
320
|
|
|
$flexidata = $this->object->getFlexiData(); |
321
|
|
|
$this->assertArrayHasKey('company', $flexidata); |
322
|
|
|
break; |
323
|
|
|
|
324
|
|
|
default: |
325
|
|
|
$flexidata = $this->object->getFlexiData(); |
326
|
|
View Code Duplication |
if (is_array($flexidata) && !count($flexidata)) { |
|
|
|
|
327
|
|
|
$this->markTestSkipped('Empty evidence'); |
328
|
|
|
} else { |
329
|
|
|
$this->assertArrayHasKey(0, $flexidata); |
330
|
|
|
$this->assertArrayHasKey('id', $flexidata[0]); |
331
|
|
|
$filtrered = $this->object->getFlexiData(null, |
332
|
|
|
"id = ".$flexidata[0]['id']); |
333
|
|
|
$this->assertArrayHasKey(0, $filtrered); |
334
|
|
|
$this->assertArrayHasKey('id', $filtrered[0]); |
335
|
|
|
} |
336
|
|
|
break; |
337
|
|
|
} |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::loadFromFlexiBee |
342
|
|
|
*/ |
343
|
|
|
public function testLoadFromFlexiBee() |
344
|
|
|
{ |
345
|
|
|
$this->object->loadFromFlexiBee(); |
346
|
|
|
$this->object->loadFromFlexiBee(222); |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::jsonizeData |
351
|
|
|
*/ |
352
|
|
|
public function testJsonizeData() |
353
|
|
|
{ |
354
|
|
|
$this->assertEquals('{"'.$this->object->nameSpace.'":{"@version":"1.0","'.$this->object->evidence.'":{"key":"value"}}}', |
355
|
|
|
$this->object->jsonizeData(['key' => 'value'])); |
356
|
|
|
$this->object->setAction('copy'); |
357
|
|
|
$this->assertEquals('{"'.$this->object->nameSpace.'":{"@version":"1.0","'.$this->object->evidence.'":{"key":"value"},"'.$this->object->evidence.'@action":"copy"}}', |
358
|
|
|
$this->object->jsonizeData(['key' => 'value'])); |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::idExists |
363
|
|
|
*/ |
364
|
|
|
public function testIdExists() |
365
|
|
|
{ |
366
|
|
|
// Remove the following lines when you implement this test. |
367
|
|
|
$this->markTestIncomplete( |
368
|
|
|
'This test has not been implemented yet.' |
369
|
|
|
); |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::recordExists |
374
|
|
|
*/ |
375
|
|
|
public function testRecordExists() |
376
|
|
|
{ |
377
|
|
|
$evidence = $this->object->getEvidence(); |
378
|
|
|
|
379
|
|
|
switch ($evidence) { |
380
|
|
|
case null: |
381
|
|
|
case 'c': |
382
|
|
|
$this->markTestSkipped('Unsupported evidence'); |
383
|
|
|
break; |
384
|
|
|
|
385
|
|
|
default: |
386
|
|
|
$flexidata = $this->object->getFlexiData(null, ['limit' => 1]); |
387
|
|
|
if (is_array($flexidata) && !count($flexidata)) { |
388
|
|
|
$this->markTestSkipped('Empty evidence'); |
389
|
|
|
} else { |
390
|
|
|
if (isset($flexidata['success']) && ($flexidata['success'] == 'false')) { |
391
|
|
|
$this->markTestSkipped($flexidata['message']); |
392
|
|
|
} else { |
393
|
|
|
$this->object->setData(['id' => (int) $flexidata[0]['id']]); |
394
|
|
|
$this->assertTrue($this->object->recordExists()); |
395
|
|
|
$this->assertFalse($this->object->recordExists(['id' => 0])); |
396
|
|
|
$this->assertFalse($this->object->recordExists(['unexistent' => 1])); |
397
|
|
|
} |
398
|
|
|
} |
399
|
|
|
break; |
400
|
|
|
} |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
/** |
404
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::getColumnsFromFlexibee |
405
|
|
|
*/ |
406
|
|
|
public function testGetColumnsFromFlexibee() |
407
|
|
|
{ |
408
|
|
|
// Remove the following lines when you implement this test. |
409
|
|
|
$this->markTestIncomplete( |
410
|
|
|
'This test has not been implemented yet.' |
411
|
|
|
); |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::getKod |
416
|
|
|
*/ |
417
|
|
|
public function testGetKod() |
418
|
|
|
{ |
419
|
|
|
|
420
|
|
|
$this->assertEquals('CODE', |
421
|
|
|
$this->object->getKod([$this->object->myKeyColumn => 'code'])); |
422
|
|
|
|
423
|
|
|
$testString[$this->object->nameColumn] = 'Fish clamp - Úchytka pro instalaci samonosných kabelů ' |
|
|
|
|
424
|
|
|
.'(3.5 mm)'; |
425
|
|
|
$code0 = $this->object->getKod($testString); |
426
|
|
|
$this->assertEquals('FISHCLAMPUCHYTKAPR', $code0); |
427
|
|
|
$code1 = $this->object->getKod($testString, |
428
|
|
|
false); |
429
|
|
|
$this->assertEquals('FISHCLAMPUCHYTKAPR', $code1); |
430
|
|
|
$code2 = $this->object->getKod($testString); |
431
|
|
|
$this->assertEquals('FISHCLAMPUCHYTKAPR1', $code2); |
432
|
|
|
$this->object->setData($testString); |
433
|
|
|
$code3 = $this->object->getKod(); |
434
|
|
|
$this->assertEquals('FISHCLAMPUCHYTKAPR2', $code3); |
435
|
|
|
|
436
|
|
|
$this->assertEquals('TEST', |
437
|
|
|
$this->object->getKod([$this->object->nameColumn => 'test'])); |
438
|
|
|
|
439
|
|
|
$this->assertEquals('TEST1', $this->object->getKod('test')); |
440
|
|
|
|
441
|
|
|
$this->assertEquals('TEST2', $this->object->getKod(['kod' => 'test'])); |
442
|
|
|
$this->assertEquals('NOTSET', $this->object->getKod(['kod' => ''])); |
443
|
|
|
} |
444
|
|
|
|
445
|
|
|
/** |
446
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::logResult |
447
|
|
|
*/ |
448
|
|
|
public function testLogResult() |
449
|
|
|
{ |
450
|
|
|
$this->object->cleanMessages(); |
451
|
|
|
$success = json_decode('{"winstrom":{"@version":"1.0","success":"true",' |
452
|
|
|
.'"stats":{"created":"0","updated":"1","deleted":"0","skipped":"0"' |
453
|
|
|
.',"failed":"0"},"results":[{"id":"1","request-id":"ext:SōkoMan.item' |
454
|
|
|
.':5271","ref":"/c/spoje_net_s_r_o_1/skladovy-pohyb/1.json"}]}}'); |
455
|
|
|
$this->object->logResult(current($this->object->object2array($success)), |
456
|
|
|
'http://test'); |
457
|
|
|
|
458
|
|
|
$this->assertArrayHasKey('info', $this->object->getStatusMessages(true)); |
459
|
|
|
|
460
|
|
|
$error = json_decode('{"winstrom":{"@version":"1.0","success":"false",' |
461
|
|
|
.'"stats":{"created":"0","updated":"0","deleted":"0","skipped":"0"' |
462
|
|
|
.',"failed":"0"},"results":[{"errors":[{"message":"cz.winstrom.' |
463
|
|
|
.'service.WSBusinessException: Zadaný kód není unikátní.\nZadaný' |
464
|
|
|
.' kód není unikátní."}]}]}}'); |
465
|
|
|
$this->object->lastResponseCode = 500; |
466
|
|
|
$this->object->logResult(current($this->object->object2array($error))); |
467
|
|
|
$this->assertArrayHasKey('error', $this->object->getStatusMessages(true)); |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
/** |
471
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::flexiUrl |
472
|
|
|
*/ |
473
|
|
|
public function testFlexiUrl() |
474
|
|
|
{ |
475
|
|
|
$this->assertEquals("a eq '1' and b eq 'foo'", |
476
|
|
|
$this->object->flexiUrl(['a' => 1, 'b' => 'foo'], 'and')); |
477
|
|
|
$this->assertEquals("a eq '1' or b eq 'bar'", |
478
|
|
|
$this->object->flexiUrl(['a' => 1, 'b' => 'bar'], 'or')); |
479
|
|
|
$this->assertEquals("a eq true or b eq false", |
480
|
|
|
$this->object->flexiUrl(['a' => true, 'b' => false], 'or')); |
481
|
|
|
$this->assertEquals("a is null and b is not null", |
482
|
|
|
$this->object->flexiUrl(['a' => null, 'b' => '!null'], 'and')); |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
/** |
486
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::unifyResponseFormat |
487
|
|
|
*/ |
488
|
|
|
public function testunifyResponseFormat() |
489
|
|
|
{ |
490
|
|
|
$this->assertNull($this->object->unifyResponseFormat(null)); |
|
|
|
|
491
|
|
|
//One Row Test |
492
|
|
|
$test1raw = [$this->object->nameSpace => |
493
|
|
|
[$this->object->getResponseEvidence() => |
494
|
|
|
['id' => 1, 'name' => 'value'] |
495
|
|
|
] |
496
|
|
|
]; |
497
|
|
|
|
498
|
|
|
$test1expected = [$this->object->getResponseEvidence() => |
499
|
|
|
[ |
500
|
|
|
['id' => 1, 'name' => 'value'] |
501
|
|
|
] |
502
|
|
|
]; |
503
|
|
|
|
504
|
|
|
$this->assertEquals($test1expected, |
505
|
|
|
$this->object->unifyResponseFormat($test1raw)); |
506
|
|
|
|
507
|
|
|
//Two Row Test |
508
|
|
|
$test2Raw = [$this->object->nameSpace => |
509
|
|
|
[$this->object->getResponseEvidence() => |
510
|
|
|
[ |
511
|
|
|
['id' => 1, 'name' => 'value'], |
512
|
|
|
['id' => 2, 'name' => 'value2'] |
513
|
|
|
] |
514
|
|
|
] |
515
|
|
|
]; |
516
|
|
|
$test2expected = [$this->object->getResponseEvidence() => |
517
|
|
|
[ |
518
|
|
|
['id' => 1, 'name' => 'value'], |
519
|
|
|
['id' => 2, 'name' => 'value2'] |
520
|
|
|
] |
521
|
|
|
]; |
522
|
|
|
|
523
|
|
|
$this->assertEquals($test2expected, |
524
|
|
|
$this->object->unifyResponseFormat($test2Raw)); |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
/** |
528
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::__toString |
529
|
|
|
*/ |
530
|
|
|
public function testtoString() |
531
|
|
|
{ |
532
|
|
|
|
533
|
|
|
$identifer = 'ext:test:123'; |
534
|
|
|
$this->object->setDataValue('id', $identifer); |
535
|
|
|
$this->assertEquals($identifer, (string) $this->object); |
536
|
|
|
|
537
|
|
|
$code = 'test'; |
538
|
|
|
$this->object->setDataValue('kod', $code); |
539
|
|
|
$this->assertEquals('code:'.$code, (string) $this->object); |
540
|
|
|
|
541
|
|
|
$this->object->dataReset(); |
542
|
|
|
$this->assertNull($this->object->__toString()); |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
/** |
546
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::draw |
547
|
|
|
*/ |
548
|
|
|
public function testDraw($whatWant = NULL) |
549
|
|
|
{ |
550
|
|
|
$this->object->setDataValue('kod', 'test'); |
551
|
|
|
$this->assertEquals('code:test', $this->object->draw()); |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
/** |
555
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::getColumnsInfo |
556
|
|
|
*/ |
557
|
|
|
public function testgetColumnsInfo() |
558
|
|
|
{ |
559
|
|
|
switch ($this->object->getEvidence()) { |
560
|
|
|
case '': |
561
|
|
|
case 'c': |
562
|
|
|
case 'hooks': |
563
|
|
|
case 'changes': |
564
|
|
|
case 'nastaveni': |
565
|
|
|
$this->assertNull($this->object->getColumnsInfo()); |
566
|
|
|
$this->assertNotEmpty($this->object->getColumnsInfo('faktura-vydana'), |
567
|
|
|
'Cannot obtain structure for na evidence'); |
568
|
|
|
break; |
569
|
|
|
default: |
570
|
|
|
$this->assertNotEmpty($this->object->getColumnsInfo(), |
571
|
|
|
'Cannot obtain structure for '.$this->object->getEvidence()); |
572
|
|
|
break; |
573
|
|
|
} |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
/** |
577
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::getEvidenceUrl |
578
|
|
|
*/ |
579
|
|
|
public function testgetEvidenceUrl() |
580
|
|
|
{ |
581
|
|
|
$this->assertNotEmpty($this->object->getEvidenceUrl()); |
582
|
|
|
$this->assertNotEmpty($this->object->getEvidenceUrl('/properties')); |
583
|
|
|
} |
584
|
|
|
|
585
|
|
|
/** |
586
|
|
|
* @covers FlexiPeeHP\FlexiBeeRO::evidenceToClassName |
587
|
|
|
*/ |
588
|
|
|
public function testevidenceToClassName() |
589
|
|
|
{ |
590
|
|
|
$this->assertEquals('FakturaVydana', |
591
|
|
|
$this->object->evidenceToClassName('faktura-vydana')); |
592
|
|
|
} |
593
|
|
|
|
594
|
|
|
} |
595
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: