Passed
Push — master ( 20f309...c1f576 )
by Vítězslav
01:56
created

FlexiBeeROTest::testPerformRequest()   B

Complexity

Conditions 8
Paths 14

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 8.4444
c 0
b 0
f 0
cc 8
nc 14
nop 0
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\SandTest
11
{
12
    /**
13
     * @var FlexiBeeRO
14
     */
15
    protected $object;
16
17
    /**
18
     * Example JSON 
19
     * @var string json 
20
     */
21
    public $json = '{"winstrom":{"@version":"1.0","adresar":[{"id":"2574","kontakty":[{"id":"299"}]}]}}';
22
23
    /**
24
     * Example XML
25
     * @var string xml 
26
     */
27
    public $xml = '<?xml version="1.0" encoding="utf-8"?>
28
29
<winstrom version="1.0">
30
  <!-- Adresář -->
31
  <adresar>
32
    <!-- ID (celé číslo) - -->
33
    <id>2574</id>
34
    <kontakty>
35
      <!-- Kontakty -->
36
      <kontakt>
37
        <!-- ID (celé číslo) - -->
38
        <id>299</id>
39
      </kontakt>
40
    </kontakty>
41
  </adresar>
42
</winstrom>';
43
44
    /**
45
     * Sets up the fixture, for example, opens a network connection.
46
     * This method is called before a test is executed.
47
     * @covers FlexiPeeHP\FlexiBeeRO::__construct
48
     */
49
    protected function setUp()
50
    {
51
        $this->object                  = new FlexiBeeRO();
52
        $this->object->prefix          = '/';
53
        $this->object->debug           = true;
54
        $this->object->reportRecipient = '[email protected]';
55
    }
56
57
    /**
58
     * Tears down the fixture, for example, closes a network connection.
59
     * This method is called after a test is executed.
60
     */
61
    protected function tearDown()
62
    {
63
        
64
    }
65
66
    /**
67
     * @covers FlexiPeeHP\FlexiBeeRO::logBanner
68
     */
69
    public function testLogBanner()
70
    {
71
        $this->object->logBanner(addslashes(get_class($this)));
72
    }
73
74
    /**
75
     * Test Constructor
76
     *
77
     * @depends testLogBanner
78
     * @covers FlexiPeeHP\FlexiBeeRO::__construct
79
     */
80
    public function testConstructor()
81
    {
82
        $classname = get_class($this->object);
83
        $evidence  = $this->object->getEvidence();
84
85
        // Get mock, without the constructor being called
86
        $mock = $this->getMockBuilder($classname)
87
            ->disableOriginalConstructor()
88
            ->getMockForAbstractClass();
89
        $mock->__construct(1, ['debug' => false]);
90
91
        if (!isset(\FlexiPeeHP\EvidenceList::$name[$evidence])) {
92
            $evidence = 'adresar';
93
        }
94
95
        $mock->__construct('',
96
            [
97
                'company' => constant('FLEXIBEE_COMPANY'),
98
                'url' => constant('FLEXIBEE_URL'),
99
                'user' => constant('FLEXIBEE_LOGIN'),
100
                'password' => constant('FLEXIBEE_PASSWORD'),
101
                'debug' => true,
102
                'prefix' => 'c',
103
                'evidence' => $evidence]);
104
    }
105
106
    /**
107
     * @covers FlexiPeeHP\FlexiBeeRO::curlInit
108
     */
109
    public function testCurlInit()
110
    {
111
        $this->object->timeout = 120;
112
        $this->object->curlInit();
113
        $this->assertTrue(is_resource($this->object->curl));
114
    }
115
116
    /**
117
     * @covers FlexiPeeHP\FlexiBeeRO::processInit
118
     */
119
    public function testProcessInit()
120
    {
121
        $this->object->processInit(1);
122
        $this->object->processInit(['id' => 1]);
123
        $this->assertEquals(1, $this->object->getDataValue('id'));
124
125
        if (!is_null($this->object->evidence) && $this->object->evidence != 'test') {
0 ignored issues
show
introduced by
The condition is_null($this->object->evidence) is always false.
Loading history...
126
127
128
            $firstID = $this->object->getColumnsFromFlexibee(['id', 'kod'],
129
                ['limit' => 1]);
130
131
            if (count($firstID) && isset($firstID[0]['id'])) {
132
133
                $this->object->processInit((int) current($firstID));
134
                $this->assertNotEmpty($this->object->__toString());
135
136
                if (isset($firstID[0]['kod'])) {
137
                    $this->object->processInit('code:'.$firstID[0]['kod']);
138
                    $this->assertNotEmpty($this->object->__toString());
139
                }
140
141
                $this->object->processInit($this->object->getEvidenceURL().'/'.$firstID[0]['id'].'.xml');
142
            } else {
143
                $this->markTestSkipped(sprintf('Evidence %s does not contain first record',
144
                        $this->object->getEvidence()));
145
            }
146
        }
147
    }
148
149
    /**
150
     * @covers FlexiPeeHP\FlexiBeeRO::setUp
151
     */
152
    public function testSetUp()
153
    {
154
        $this->object->authSessionId = 'XXXtestXXX';
155
        $this->object->setUp(
156
            [
157
                'company' => 'cmp',
158
                'url' => 'url',
159
                'user' => 'usr',
160
                'password' => 'pwd',
161
                'prefix' => 'c',
162
                'debug' => true,
163
                'defaultUrlParams' => ['limit' => 10],
164
                'evidence' => 'smlouva',
165
                'detail' => 'summary',
166
                'filter' => 'testfilter',
167
                'ignore404' => true,
168
                'offline' => true
169
            ]
170
        );
171
        $this->assertEquals('cmp', $this->object->company);
172
        $this->assertEquals('url', $this->object->url);
173
        $this->assertEquals('usr', $this->object->user);
174
        $this->assertEquals('/c/', $this->object->prefix);
175
        $this->assertEquals('pwd', $this->object->password);
176
    }
177
178
    /**
179
     * @covers FlexiPeeHP\FlexiBeeRO::getConnectionOptions
180
     */
181
    public function testGetConnectionOptions()
182
    {
183
        $options                     = $this->object->getConnectionOptions();
184
        $this->assertArrayHasKey('url', $options);
185
        $this->object->timeout       = 120;
186
        $this->object->authSessionId = 'sessid';
187
        $this->object->setCompany('test');
188
        $this->object->getConnectionOptions();
189
    }
190
191
    /**
192
     * @covers FlexiPeeHP\FlexiBeeRO::setPrefix
193
     * @expectedException \Exception
194
     */
195
    public function testSetPrefix()
196
    {
197
        $this->object->setPrefix('c');
198
        $this->assertEquals('/c/', $this->object->prefix);
199
        $this->object->setPrefix(null);
200
        $this->assertEquals('', $this->object->prefix);
201
        $this->object->setPrefix('fail');
202
    }
203
204
    /**
205
     * @covers FlexiPeeHP\FlexiBeeRO::setFormat
206
     */
207
    public function testSetFormat()
208
    {
209
        $this->object->setFormat('xml');
210
        $this->assertEquals('xml', $this->object->format);
211
    }
212
213
    /**
214
     * We can set only evidence defined in EvidenceList class
215
     *
216
     * @covers FlexiPeeHP\FlexiBeeRO::setEvidence
217
     * @expectedException \Exception
218
     */
219
    public function testSetEvidence()
220
    {
221
        $this->object->setEvidence('adresar');
222
        $this->assertEquals('adresar', $this->object->evidence);
223
        $this->object->setPrefix('c');
224
        $this->object->debug = true;
225
        $this->object->setEvidence('fail');
226
    }
227
228
    /**
229
     * @covers FlexiPeeHP\FlexiBeeRO::setCompany
230
     */
231
    public function testSetCompany()
232
    {
233
        $this->object->setCompany('test_s_r_o_');
234
        $this->assertEquals('test_s_r_o_', $this->object->company);
235
    }
236
237
    /**
238
     * @covers FlexiPeeHP\FlexiBeeRO::object2array
239
     */
240
    public function testObject2array()
241
    {
242
        $this->assertNull($this->object->object2array(new \stdClass()));
243
        $this->assertEquals(
244
            [
245
                'item' => 1,
246
                'arrItem' => ['a', 'b' => 'c']
247
            ]
248
            , $this->object->object2array(new \Test\ObjectForTesting()));
249
    }
250
251
    /**
252
     * @covers FlexiPeeHP\FlexiBeeRO::objectToID
253
     */
254
    public function testObjectToID()
255
    {
256
        $this->object->setDataValue('kod', 'TEST');
257
        $this->assertEquals('code:TEST',
258
            $this->object->objectToID($this->object));
259
260
        $this->assertEquals('TEST', $this->object->objectToID('TEST'));
0 ignored issues
show
Bug introduced by
'TEST' of type string is incompatible with the type object|array expected by parameter $object of FlexiPeeHP\FlexiBeeRO::objectToID(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

260
        $this->assertEquals('TEST', $this->object->objectToID(/** @scrutinizer ignore-type */ 'TEST'));
Loading history...
261
    }
262
263
    /**
264
     * @covers FlexiPeeHP\FlexiBeeRO::performRequest
265
     */
266
    public function testPerformRequest()
267
    {
268
        $evidence = $this->object->getEvidence();
269
        switch ($evidence) {
270
            case null:
271
            case '':
272
            case 'c':
273
            case 'test':
274
            case 'status':
275
            case 'nastaveni':
276
                $this->object->performRequest(null, 'GET', 'xml');
277
                break;
278
279
            default:
280
                $this->object->performRequest(null, 'GET', 'json');
281
                $this->object->performRequest(null, 'GET', 'xml');
282
                break;
283
        }
284
285
        //404 Test
286
287
        $notFound = $this->object->performRequest('error404.json');
288
        if (array_key_exists('message', $notFound)) {
289
            $this->assertEquals('false', $notFound['success']);
290
        } else {
291
            echo '';
292
        }
293
    }
294
295
    /**
296
     * @covers FlexiPeeHP\FlexiBeeRO::rawResponseToArray
297
     */
298
    public function testRawResponseToArray()
299
    {
300
301
        $this->assertTrue(is_array(
302
                $this->object->rawResponseToArray($this->json, 'json')));
303
        $this->assertTrue(is_array(
304
                $this->object->rawResponseToArray($this->xml, 'xml')));
305
        $this->assertTrue(is_array(
306
                $this->object->rawResponseToArray('simpletext', 'txt')));
307
        $this->assertTrue(is_array(
308
                $this->object->rawResponseToArray('othertext', 'other')));
309
    }
310
311
    /**
312
     * @covers FlexiPeeHP\FlexiBeeRO::rawJsonToArray
313
     */
314
    public function testRawJsonToArray()
315
    {
316
        $this->assertNull($this->object->rawJsonToArray($this->json.'XXX'));
317
        $evidence    = $this->object->getResponseEvidence() ? $this->object->getResponseEvidence()
318
                : 'adresar';
319
        $arrayWeWant = [
320
            '@version' => '1.0',
321
            $evidence =>
322
            [
323
                [
324
                    'id' => '2574',
325
                    'kontakty' =>
326
                    [
327
                        ['id' => '299']
328
                    ]
329
                ]
330
            ]
331
        ];
332
        $this->assertEquals($arrayWeWant,
333
            $this->object->rawJsonToArray($this->json));
334
    }
335
336
    /**
337
     * @covers FlexiPeeHP\FlexiBeeRO::rawXmlToArray
338
     */
339
    public function testRawXmlToArray()
340
    {
341
        $evidence    = $this->object->getResponseEvidence() ? $this->object->getResponseEvidence()
342
                : 'adresar';
343
        $arrayWeWant = [
344
            '@version' => '1.0',
345
            $evidence =>
346
            [
347
                [
348
                    'id' => '2574',
349
                    'kontakty' =>
350
                    [
351
                        ['kontakt' => [
352
                                ['id' => '299']
353
                            ]
354
                        ]
355
                    ]
356
                ]
357
            ]
358
        ];
359
        $this->assertEquals($arrayWeWant,
360
            $this->object->rawXmlToArray($this->xml));
361
    }
362
363
    /**
364
     * @covers FlexiPeeHP\FlexiBeeRO::parseResponse
365
     */
366
    public function testParseResponse()
367
    {
368
        $this->object->parseResponse($this->object->rawJsonToArray($this->json),
369
            200);
370
    }
371
372
    /**
373
     * @covers FlexiPeeHP\FlexiBeeRO::doCurlRequest
374
     */
375
    public function testDoCurlRequest()
376
    {
377
        $this->object->doCurlRequest(constant('FLEXIBEE_URL'), 'GET');
378
    }
379
380
    /**
381
     * @covers FlexiPeeHP\FlexiBeeRO::setAction
382
     */
383
    public function testSetAction()
384
    {
385
        switch ($this->object->getEvidence()) {
386
            case '':
387
            case 'c':
388
            case 'hooks':
389
            case 'status':
390
            case 'changes':
391
            case 'nastaveni':
392
            case 'evidence-list':
393
                $this->object->setAction('none');
394
                break;
395
            default:
396
                $this->assertTrue($this->object->setAction('new'));
397
                $this->object->actionsAvailable = [];
398
                $this->assertFalse($this->object->setAction('none'));
399
                $this->object->actionsAvailable = ['copy'];
400
                $this->assertFalse($this->object->setAction('none'));
401
                break;
402
        }
403
    }
404
405
    /**
406
     * @covers FlexiPeeHP\FlexiBeeRO::getEvidence
407
     */
408
    public function testGetEvidence()
409
    {
410
        $this->assertEquals($this->object->evidence,
411
            $this->object->getEvidence());
412
    }
413
414
    /**
415
     * @covers FlexiPeeHP\FlexiBeeRO::getCompany
416
     */
417
    public function testGetCompany()
418
    {
419
        $this->assertEquals($this->object->company, $this->object->getCompany());
420
    }
421
422
    /**
423
     * @covers FlexiPeeHP\FlexiBeeRO::getResponseEvidence
424
     */
425
    public function testGetResponseEvidence()
426
    {
427
        $responseEvidence = $this->object->getResponseEvidence();
428
        switch ($this->object->getEvidence()) {
429
            case '':
430
            case 'c':
431
            case 'hooks':
432
            case 'status':
433
            case 'changes':
434
            case 'nastaveni':
435
            case 'evidence-list':
436
                break;
437
            default:
438
                $this->assertEquals($this->object->getEvidence(),
439
                    $responseEvidence);
440
                break;
441
        }
442
    }
443
444
    /**
445
     * @covers FlexiPeeHP\FlexiBeeRO::getLastInsertedId
446
     * @depends testInsertToFlexiBee
447
     */
448
    public function testGetLastInsertedId()
449
    {
450
        $this->assertNotEmpty($this->object->getLastInsertedId());
0 ignored issues
show
Bug introduced by
The method getLastInsertedId() does not exist on FlexiPeeHP\FlexiBeeRO. It seems like you code against a sub-type of FlexiPeeHP\FlexiBeeRO such as FlexiPeeHP\FlexiBeeRW. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

450
        $this->assertNotEmpty($this->object->/** @scrutinizer ignore-call */ getLastInsertedId());
Loading history...
451
    }
452
453
    /**
454
     * @covers FlexiPeeHP\FlexiBeeRO::xml2array
455
     */
456
    public function testXml2array()
457
    {
458
        $arrayWeWant = [
459
            '@version' => '1.0',
460
            'adresar' =>
461
            [
462
                [
463
                    'id' => '2574',
464
                    'kontakty' =>
465
                    [
466
                        ['kontakt' => [
467
                                ['id' => '299']
468
                            ]
469
                        ]
470
                    ]
471
                ]
472
            ]
473
        ];
474
475
        $this->assertEquals($arrayWeWant, $this->object->xml2array($this->xml));
476
    }
477
478
    /**
479
     * @covers FlexiPeeHP\FlexiBeeRO::extractUrlParams
480
     */
481
    public function testExtractUrlParams()
482
    {
483
        $conditions = ['id' => 23, 'limit' => 10];
484
        $this->object->extractUrlParams($conditions, $urlParams);
485
        $this->assertEquals(['id' => 23], $conditions);
486
        $this->assertEquals(['limit' => 10], $urlParams);
487
    }
488
489
    /**
490
     * @covers FlexiPeeHP\FlexiBeeRO::urlEncode
491
     */
492
    public function testUrlEncode()
493
    {
494
        $this->assertEquals("stitky%3D'code:VIP'%20or%20stitky%3D'code:DULEZITE'",
495
            FlexiBeeRO::urlEncode("stitky='code:VIP' or stitky='code:DULEZITE'"));
496
    }
497
498
    /**
499
     * @covers FlexiPeeHP\FlexiBeeRO::getAllFromFlexibee
500
     */
501
    public function testGetAllFromFlexibee()
502
    {
503
        $this->object->getAllFromFlexibee();
504
    }
505
506
    /**
507
     * @covers FlexiPeeHP\FlexiBeeRO::disconnect
508
     *
509
     * @depends testPerformRequest
510
     * @depends testLoadFlexiData
511
     * @depends testGetFlexiRow
512
     * @depends testGetFlexiData
513
     * @depends testLoadFromFlexiBee
514
     * @depends testInsertToFlexiBee
515
     * @depends testIdExists
516
     * @depends testRecordExists
517
     * @depends testGetColumnsFromFlexibee
518
     * @depends testSearchString
519
     */
520
    public function testDisconnect()
521
    {
522
        $this->object->disconnect();
523
        $this->assertNull($this->object->curl);
524
    }
525
526
    /**
527
     * @covers FlexiPeeHP\FlexiBeeRO::__destruct
528
     * @depends testDisconnect
529
     */
530
    public function testdestruct()
531
    {
532
        $this->markTestSkipped();
533
    }
534
535
    /**
536
     * @covers FlexiPeeHP\FlexiBeeRO::getFlexiRow
537
     */
538
    public function testGetFlexiRow()
539
    {
540
        $this->object->getFlexiRow(0);
541
        $this->object->getFlexiRow(1);
542
    }
543
544
    /**
545
     * @covers FlexiPeeHP\FlexiBeeRO::getFlexiData
546
     */
547
    public function testGetFlexiData()
548
    {
549
        $evidence = $this->object->getEvidence();
550
        switch ($evidence) {
551
            case null:
552
                $this->object->getFlexiData();
553
                break;
554
            case 'c':
555
                $this->object->evidence  = 'c';
556
                $this->object->prefix    = '';
557
                $this->object->company   = '';
558
                $this->object->nameSpace = 'companies';
559
                $flexidata               = $this->object->getFlexiData();
560
                $this->assertArrayHasKey('company', $flexidata);
561
                break;
562
            case 'evidence-list':
563
                $flexidata               = $this->object->getFlexiData(null,
564
                    ['detail' => 'id']);
565
                $this->assertArrayHasKey('evidenceType', $flexidata[0]);
566
                break;
567
568
            default:
569
                $flexidata = $this->object->getFlexiData(null,
570
                    ['detail' => 'id']);
571
572
                if (is_array($flexidata)) {
0 ignored issues
show
introduced by
The condition is_array($flexidata) is always true.
Loading history...
573
                    if (count($flexidata)) {
574
                        $this->markTestSkipped('Empty evidence');
575
                    } else {
576
                        $this->assertArrayHasKey(0, $flexidata);
577
578
                        $this->assertArrayHasKey('id', $flexidata[0]);
579
                        $filtrered = $this->object->getFlexiData(null,
580
                            ["id = ".$flexidata[0]['id'], 'detail' => 'full']);
581
                        $this->assertArrayHasKey(0, $filtrered);
582
                        $this->assertArrayHasKey('id', $filtrered[0]);
583
                    }
584
                }
585
                break;
586
        }
587
    }
588
589
    /**
590
     * @covers FlexiPeeHP\FlexiBeeRO::loadFromFlexiBee
591
     */
592
    public function testLoadFromFlexiBee()
593
    {
594
        $this->object->loadFromFlexiBee();
595
        $this->object->loadFromFlexiBee(222);
596
    }
597
598
    /**
599
     * @covers FlexiPeeHP\FlexiBeeRO::getJsonizedData
600
     */
601
    public function testGetJsonizedData()
602
    {
603
        $this->assertEquals('{"'.$this->object->nameSpace.'":{"@version":"1.0","'.$this->object->evidence.'":{"key":"value"}}}',
604
            $this->object->getJsonizedData(['key' => 'value']));
605
606
        switch ($this->object->getEvidence()) {
607
            case '':
608
            case 'c':
609
            case 'hooks':
610
            case 'status':
611
            case 'changes':
612
            case 'nastaveni':
613
            case 'evidence-list':
614
                $this->object->getJsonizedData(['key' => 'value']);
615
                break;
616
            default:
617
                $this->object->setAction('copy');
618
                $this->assertEquals('{"'.$this->object->nameSpace.'":{"@version":"1.0","'.$this->object->evidence.'":{"key":"value"},"'.$this->object->evidence.'@action":"copy"}}',
619
                    $this->object->getJsonizedData(['key' => 'value']));
620
621
                $this->object->action = 'storno';
0 ignored issues
show
Bug introduced by
The property action is declared protected in FlexiPeeHP\FlexiBeeRO and cannot be accessed from this context.
Loading history...
622
                $this->object->filter = "stavUhrK = 'stavUhr.uhrazeno'";
623
                $this->object->getJsonizedData([]);
624
                break;
625
        }
626
    }
627
628
    /**
629
     * @covers FlexiPeeHP\FlexiBeeRO::getDataForJSON
630
     */
631
    public function testGetDataForJson()
632
    {
633
        $this->object->getDataForJSON();
634
    }
635
636
    /**
637
     * @covers FlexiPeeHP\FlexiBeeRO::idExists
638
     */
639
    public function testIdExists()
640
    {
641
        $this->assertFalse($this->object->idExists('nonexistent'));
642
        switch ($this->object->getEvidence()) {
643
            case '':
644
            case 'c':
645
            case 'hooks':
646
            case 'status':
647
            case 'changes':
648
            case 'nastaveni':
649
            case 'evidence-list':
650
                break;
651
            default:
652
                $first = $this->object->getColumnsFromFlexibee(['id'],
653
                    ['limit' => 1], 'id');
654
                if (empty($first)) {
655
                    $this->markTestSkipped('empty evidence ?');
656
                } else {
657
                    $this->object->setData($first);
658
                    $this->assertTrue($this->object->idExists());
659
                }
660
                break;
661
        }
662
    }
663
664
    /**
665
     * @covers FlexiPeeHP\FlexiBeeRO::getRecordID
666
     */
667
    public function testGetRecordID()
668
    {
669
        $this->object->setData([$this->object->getKeyColumn() => 10]);
670
        $this->assertEquals(10, $this->object->getRecordID());
671
    }
672
673
    
674
    /**
675
     * @covers FlexiPeeHP\FlexiBeeRO::getRecordIdent
676
     */
677
    public function testGetRecordIdent(){
678
        $this->object->dataReset();
679
        $this->assertNull($this->object->getRecordIdent());
680
681
        $this->object->setMyKey(20);
682
        $this->assertEquals(20,  $this->object->getRecordIdent());
683
684
        $this->object->setDataValue('kod','test');
685
        $this->assertEquals('code:TEST',  $this->object->getRecordIdent());
686
        
687
        $this->object->setDataValue('external-ids',['ext:test:10']);
688
        $this->assertEquals('ext:test:10',  $this->object->getRecordIdent());
689
        
690
    }
691
    
692
693
    /**
694
     * @covers FlexiPeeHP\FlexiBeeRO::recordExists
695
     */
696
    public function testRecordExists()
697
    {
698
        $evidence = $this->object->getEvidence();
699
700
        switch ($evidence) {
701
            case null:
702
            case 'c':
703
            case 'status':
704
            case 'evidence-list':
705
                $this->object->recordExists();
706
                break;
707
708
            default:
709
                $flexidata = $this->object->getFlexiData(null,
710
                    ['limit' => 1, 'detail' => 'id']);
711
                if (is_array($flexidata) && !count($flexidata)) {
712
                    $this->assertFalse($this->object->recordExists(['id' => 1]),
713
                        'Record ID 1 exists in empty evidence ?');
714
                } else {
715
                    if (!is_null($flexidata)) {
716
                        $this->object->setData(['id' => (int) $flexidata[0]['id']]);
717
                        $this->assertTrue($this->object->recordExists(),
718
                            'First record exists test failed');
719
                        $this->assertFalse($this->object->recordExists(['id' => 0]),
720
                            'Record ID 0 exists');
721
                        $this->assertFalse($this->object->recordExists(['unexistent' => 1]),
722
                            'Unexistent Record exist ?');
723
                    }
724
                }
725
                break;
726
        }
727
    }
728
729
    /**
730
     * @covers FlexiPeeHP\FlexiBeeRO::getColumnsFromFlexibee
731
     */
732
    public function testGetColumnsFromFlexibee()
733
    {
734
735
        switch ($this->object->getEvidence()) {
736
            case '':
737
            case 'c':
738
            case 'hooks':
739
            case 'status':
740
            case 'changes':
741
            case 'nastaveni':
742
            case 'evidence-list':
743
                break;
744
            default:
745
                $this->object->getColumnsFromFlexibee(['id', 'kod'],
746
                    ['limit' => 1], 'id');
747
                $this->object->getColumnsFromFlexibee('summary', ['limit' => 1],
0 ignored issues
show
Bug introduced by
'summary' of type string is incompatible with the type string[] expected by parameter $columnsList of FlexiPeeHP\FlexiBeeRO::getColumnsFromFlexibee(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

747
                $this->object->getColumnsFromFlexibee(/** @scrutinizer ignore-type */ 'summary', ['limit' => 1],
Loading history...
748
                    'id');
749
750
                break;
751
        }
752
    }
753
754
    /**
755
     * @covers FlexiPeeHP\FlexiBeeRO::getExternalID
756
     */
757
    public function testGetExternalID()
758
    {
759
        $this->assertTrue(empty($this->object->getExternalID('ext:test:10'))); //ext: does not exist
760
761
        $this->object->setDataValue('external-ids',
762
            ['ext:doe:22', 'ext:test:10']);
763
764
        $this->assertEquals('ext:doe:22', $this->object->getExternalID());
765
        $this->assertEquals('10', $this->object->getExternalID('test'));
766
    }
767
768
    /**
769
     * @covers FlexiPeeHP\FlexiBeeRO::getGlobalVersion
770
     */
771
    public function testGetGlobalVersion()
772
    {
773
        switch ($this->object->getEvidence()) {
774
            case '':
775
            case 'c':
776
            case 'hooks':
777
            case 'status':
778
            case 'changes':
779
            case 'nastaveni':
780
            case 'evidence-list':
781
                $this->object->getGlobalVersion();
782
                break;
783
            default:
784
                $this->assertInternalType("int",
785
                    $this->object->getGlobalVersion(),
786
                    'error obtaining of GlobalVersion');
787
                break;
788
        }
789
    }
790
791
    /**
792
     * @covers FlexiPeeHP\FlexiBeeRO::getApiURL
793
     */
794
    public function testGetApiUrl()
795
    {
796
        $evidence = $this->object->getEvidence();
797
        if ($evidence) {
798
            $url = $this->object->url.'/c/'.constant('FLEXIBEE_COMPANY').'/'.$evidence;
799
        } else {
800
            $url = $this->object->url.'/c/'.constant('FLEXIBEE_COMPANY');
801
        }
802
803
        $this->assertEquals($url, $this->object->getApiURL());
804
        $this->assertEquals($url.'.html', $this->object->getApiURL('html'));
805
        $this->assertEquals($url.'.xml', $this->object->getApiURL('xml'));
806
    }
807
808
    /**
809
     * @covers FlexiPeeHP\FlexiBeeRO::getResponseFormat
810
     */
811
    public function testGetResponseFormat()
812
    {
813
        $this->object->performRequest(null, 'GET', 'json');
814
        $this->assertEquals('application/json',
815
            $this->object->getResponseFormat());
816
        $this->object->performRequest(null, 'GET', 'xml');
817
        $this->assertEquals('application/xml',
818
            $this->object->getResponseFormat());
819
        unset($this->object->curlInfo['content_type']);
820
        $this->assertNull($this->object->getResponseFormat());
821
    }
822
823
    /**
824
     * @covers FlexiPeeHP\FlexiBeeRO::getKod
825
     */
826
    public function testGetKod()
827
    {
828
        $testString = [];
829
        $this->assertEquals('code:CODE',
830
            $this->object->getKod([$this->object->keyColumn => 'code']));
831
832
        $testString[$this->object->nameColumn] = 'Fish clamp -  Úchytka pro instalaci samonosných kabelů '
833
            .'(3.5 mm)';
834
        $code0                                 = $this->object->getKod($testString);
835
        $this->assertEquals('code:FISHCLAMPUCHYTKAPR', $code0);
836
        $code1                                 = $this->object->getKod($testString,
837
            false);
838
        $this->assertEquals('code:FISHCLAMPUCHYTKAPR', $code1);
839
        $code2                                 = $this->object->getKod($testString);
840
        $this->assertEquals('code:FISHCLAMPUCHYTKAPR1', $code2);
841
        $this->object->setData($testString);
842
        $code3                                 = $this->object->getKod();
843
        $this->assertEquals('code:FISHCLAMPUCHYTKAPR2', $code3);
844
845
        $this->assertEquals('code:TEST',
846
            $this->object->getKod([$this->object->nameColumn => 'test']));
847
848
        $this->assertEquals('code:TEST1', $this->object->getKod('test'));
849
850
        $this->assertEquals('code:TEST2',
851
            $this->object->getKod(['kod' => 'test']));
852
        $this->assertEquals('code:NOTSET', $this->object->getKod(['kod' => '']));
853
    }
854
855
    /**
856
     * @covers FlexiPeeHP\FlexiBeeRO::logResult
857
     */
858
    public function testLogResult()
859
    {
860
        $this->object->cleanMessages();
861
        $success = json_decode('{"winstrom":{"@version":"1.0","success":"true",'
862
            .'"stats":{"created":"0","updated":"1","deleted":"0","skipped":"0"'
863
            .',"failed":"0"},"results":[{"id":"1","request-id":"ext:SōkoMan.item'
864
            .':5271","ref":"/c/spoje_net_s_r_o_1/skladovy-pohyb/1.json"}]}}');
865
        $this->object->logResult(current($this->object->object2array($success)),
866
            'http://test');
867
868
        $this->assertArrayHasKey('info', $this->object->getStatusMessages(true));
869
870
        $error                          = json_decode('{"winstrom":{"@version":"1.0","success":"false",'
871
            .'"stats":{"created":"0","updated":"0","deleted":"0","skipped":"0"'
872
            .',"failed":"0"},"results":[{"errors":[{"message":"cz.winstrom.'
873
            .'service.WSBusinessException: Zadaný kód není unikátní.\nZadaný'
874
            .' kód není unikátní."}]}]}}');
875
        $this->object->lastResponseCode = 500;
876
        $this->object->logResult(current($this->object->object2array($error)));
877
        $this->assertArrayHasKey('error', $this->object->getStatusMessages(true));
878
    }
879
880
    /**
881
     * @covers FlexiPeeHP\FlexiBeeRO::flexiUrl
882
     */
883
    public function testFlexiUrl()
884
    {
885
        $this->assertEquals("a eq '1' and b eq 'foo'",
886
            $this->object->flexiUrl(['a' => 1, 'b' => 'foo'], 'and'));
887
        $this->assertEquals("a eq '1' or b eq 'bar'",
888
            $this->object->flexiUrl(['a' => 1, 'b' => 'bar'], 'or'));
889
        $this->assertEquals("a eq true or b eq false",
890
            $this->object->flexiUrl(['a' => true, 'b' => false], 'or'));
891
        $this->assertEquals("a is null and b is not null",
892
            $this->object->flexiUrl(['a' => null, 'b' => '!null'], 'and'));
893
    }
894
895
    /**
896
     * @covers FlexiPeeHP\FlexiBeeRO::unifyResponseFormat
897
     */
898
    public function testunifyResponseFormat()
899
    {
900
        $this->assertNull($this->object->unifyResponseFormat(null));
901
        //One Row Test
902
903
        $responseEvidence = $this->object->getResponseEvidence();
904
        if (empty($responseEvidence)) {
905
            $responseEvidence       = $this->object->evidence = 'test';
906
        }
907
908
        $test1raw = [$responseEvidence =>
909
            ['id' => 1, 'name' => 'value']
910
        ];
911
912
        $test1expected = [$responseEvidence =>
913
            [
914
                ['id' => 1, 'name' => 'value']
915
            ]
916
        ];
917
918
        $this->assertEquals($test1expected,
919
            $this->object->unifyResponseFormat($test1raw));
920
921
        //Two Row Test
922
        $test2Raw = [$this->object->getResponseEvidence() =>
923
            [
924
                ['id' => 1, 'name' => 'value'],
925
                ['id' => 2, 'name' => 'value2']
926
            ]
927
        ];
928
929
        $test2expected = [$this->object->getResponseEvidence() =>
930
            [
931
                ['id' => 1, 'name' => 'value'],
932
                ['id' => 2, 'name' => 'value2']
933
            ]
934
        ];
935
936
        $this->assertEquals($test2expected,
937
            $this->object->unifyResponseFormat($test2Raw));
938
    }
939
940
    /**
941
     * @covers FlexiPeeHP\FlexiBeeRO::__toString
942
     */
943
    public function testtoString()
944
    {
945
        $id = '123';
946
        $this->object->setMyKey($id);
947
        $this->assertEquals($id, (string) $this->object);
948
949
        $this->object->setDataValue('kod', 'test');
950
        $this->assertEquals('code:TEST', (string) $this->object);
951
952
        $identifer = 'ext:test:123';
953
        $this->object->setMyKey($identifer);
954
        $this->assertEquals($identifer, (string) $this->object);
955
956
        $this->object->dataReset();
957
        $this->assertEquals('', $this->object->__toString());
958
    }
959
960
    /**
961
     * @covers FlexiPeeHP\FlexiBeeRO::draw
962
     */
963
    public function testDraw($whatWant = NULL)
964
    {
965
        $this->object->setDataValue('kod', 'test');
966
        $this->assertEquals('code:TEST', $this->object->draw());
967
    }
968
969
    /**
970
     * @covers FlexiPeeHP\FlexiBeeRO::getColumnsInfo
971
     */
972
    public function testgetColumnsInfo()
973
    {
974
        switch ($this->object->getEvidence()) {
975
            case '':
976
            case 'c':
977
            case 'hooks':
978
            case 'status':
979
            case 'changes':
980
            case 'evidence-list':
981
                $this->assertNull($this->object->getColumnsInfo());
982
                break;
983
            default:
984
                $this->assertNotEmpty($this->object->getColumnsInfo(),
985
                    'Cannot obtain structure for '.$this->object->getEvidence());
986
                break;
987
        }
988
    }
989
990
    /**
991
     * @covers FlexiPeeHP\FlexiBeeRO::getActionsInfo
992
     */
993
    public function testgetActionsInfo()
994
    {
995
        switch ($this->object->getEvidence()) {
996
            case '':
997
            case 'c':
998
            case 'hooks':
999
            case 'status':
1000
            case 'changes':
1001
            case 'nastaveni':
1002
            case 'evidence-list':
1003
                $this->assertNull($this->object->getActionsInfo());
1004
                $this->assertNotEmpty($this->object->getActionsInfo('faktura-vydana'),
1005
                    'Cannot obtain actions for na evidence');
1006
                break;
1007
            default:
1008
                $this->assertNotEmpty($this->object->getActionsInfo(),
1009
                    'Cannot obtain actions for '.$this->object->getEvidence());
1010
                break;
1011
        }
1012
    }
1013
1014
    /**
1015
     * @covers FlexiPeeHP\FlexiBeeRO::getRelationsInfo
1016
     */
1017
    public function testgetRelationsInfo()
1018
    {
1019
        switch ($this->object->getEvidence()) {
1020
            case '':
1021
            case 'c':
1022
            case 'hooks':
1023
            case 'status':
1024
            case 'changes':
1025
            case 'nastaveni':
1026
            case 'strom-cenik':
1027
            case 'ucetni-obdobi':
1028
            case 'evidence-list':
1029
                $this->assertNull($this->object->getRelationsInfo());
1030
                break;
1031
            default:
1032
                $this->assertNotEmpty($this->object->getRelationsInfo(),
1033
                    'Cannot obtain relations for '.$this->object->getEvidence());
1034
                break;
1035
        }
1036
    }
1037
1038
    /**
1039
     * @covers FlexiPeeHP\FlexiBeeRO::getEvidenceUrl
1040
     */
1041
    public function testgetEvidenceUrl()
1042
    {
1043
        $this->assertNotEmpty($this->object->getEvidenceUrl());
1044
        $this->assertNotEmpty($this->object->getEvidenceUrl('/properties'));
0 ignored issues
show
Unused Code introduced by
The call to FlexiPeeHP\FlexiBeeRO::getEvidenceURL() has too many arguments starting with '/properties'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1044
        $this->assertNotEmpty($this->object->/** @scrutinizer ignore-call */ getEvidenceUrl('/properties'));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
1045
    }
1046
1047
    /**
1048
     * @covers FlexiPeeHP\FlexiBeeRO::evidenceToClassName
1049
     */
1050
    public function testevidenceToClassName()
1051
    {
1052
        $this->assertEquals('FakturaVydana',
1053
            $this->object->evidenceToClassName('faktura-vydana'));
1054
    }
1055
1056
    /**
1057
     * @covers FlexiPeeHP\FlexiBeeRO::getEvidenceInfo
1058
     */
1059
    public function testGetEvidenceInfo()
1060
    {
1061
        $eInfo = $this->object->getEvidenceInfo();
1062
        switch ($this->object->getEvidence()) {
1063
            case '':
1064
            case 'c':
1065
            case 'hooks':
1066
            case 'status':
1067
            case 'changes':
1068
            case 'nastaveni':
1069
            case 'evidence-list':
1070
                break;
1071
            default:
1072
                $this->assertArrayHasKey('evidencePath', $eInfo);
1073
                break;
1074
        }
1075
    }
1076
1077
    /**
1078
     * @covers FlexiPeeHP\FlexiBeeRO::getEvidenceName
1079
     */
1080
    public function testGetEvidenceName()
1081
    {
1082
        $evidenceName = $this->object->getEvidenceName();
1083
        switch ($this->object->getEvidence()) {
1084
            case '':
1085
            case 'c':
1086
            case 'hooks':
1087
            case 'status':
1088
            case 'changes':
1089
            case 'nastaveni':
1090
            case 'evidence-list':
1091
                break;
1092
            default:
1093
                $this->assertNotEmpty($evidenceName);
1094
                break;
1095
        }
1096
    }
1097
1098
    /**
1099
     * @covers FlexiPeeHP\FlexiBeeRO::saveResponseToFile
1100
     */
1101
    public function testSaveResponseToFile()
1102
    {
1103
        $tmp = sys_get_temp_dir().'/'.tmpfile();
0 ignored issues
show
Bug introduced by
Are you sure tmpfile() of type resource|false can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1103
        $tmp = sys_get_temp_dir().'/'./** @scrutinizer ignore-type */ tmpfile();
Loading history...
1104
        $this->object->saveResponseToFile($tmp);
1105
        $this->assertFileExists($tmp);
1106
    }
1107
1108
    /**
1109
     * @covers FlexiPeeHP\FlexiBeeRO::getFirstRecordID()
1110
     */
1111
    public function testgetFirstRecordID()
1112
    {
1113
        $this->object->getFirstRecordID();
1114
        switch ($this->object->getEvidence()) {
1115
            case '':
1116
            case 'c':
1117
            case 'hooks':
1118
            case 'status':
1119
            case 'changes':
1120
            case 'nastaveni':
1121
            case 'evidence-list':
1122
                break;
1123
            default:
1124
                break;
1125
        }
1126
    }
1127
1128
    /**
1129
     * @covers FlexiPeeHP\FlexiBeeRO::getVazby
1130
     * @expectedException \Exception
1131
     */
1132
    public function testGetVazby()
1133
    {
1134
        switch ($this->object->getEvidence()) {
1135
            case '':
1136
            case 'c':
1137
            case 'hooks':
1138
            case 'status':
1139
            case 'changes':
1140
            case 'nastaveni':
1141
            case 'evidence-list':
1142
                break;
1143
            default:
1144
                $this->object->getVazby($this->object->getMyKey());
1145
                break;
1146
        }
1147
        $this->object->getVazby();
1148
    }
1149
1150
    /**
1151
     * @covers FlexiPeeHP\FlexiBeeRO::evidenceUrlWithSuffix
1152
     */
1153
    public function testEvidenceUrlWithSuffix()
1154
    {
1155
        $urlraw = $this->object->getEvidenceURL();
1156
        $lala   = $this->object->evidenceUrlWithSuffix('lala');
1157
        $this->assertEquals($urlraw.'/lala', $lala);
1158
        $lolo   = $this->object->evidenceUrlWithSuffix('?lele');
1159
        $this->assertEquals($urlraw.'?lele', $lolo);
1160
        $lulu   = $this->object->evidenceUrlWithSuffix(';lulu');
1161
        $this->assertEquals($urlraw.';lulu', $lulu);
1162
    }
1163
1164
    /**
1165
     * @covers FlexiPeeHP\FlexiBeeRO::join
1166
     * @expectedException \Ease\Exception
1167
     */
1168
    public function testJoin()
1169
    {
1170
        $ada = new FlexiBeeRO(['id' => 'A'], ['evidence' => 'adresar']);
1171
        $adb = new FlexiBeeRO(['id' => 'B'], ['evidence' => 'adresar']);
1172
        $this->assertTrue($this->object->join($ada));
1173
        $this->assertTrue($this->object->join($adb));
1174
        $ads = new \stdClass();
1175
        $this->object->join($ads);
0 ignored issues
show
Bug introduced by
$ads of type stdClass is incompatible with the type FlexiPeeHP\FlexiBeeRO expected by parameter $object of FlexiPeeHP\FlexiBeeRO::join(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1175
        $this->object->join(/** @scrutinizer ignore-type */ $ads);
Loading history...
1176
    }
1177
1178
    /**
1179
     * @covers FlexiPeeHP\FlexiBeeRO::addDefaultUrlParams
1180
     */
1181
    public function testAddDefaultUrlParams()
1182
    {
1183
        $this->object->defaultUrlParams       = [];
1184
        $this->assertEquals('http://vitexsoftware.cz?a=b',
1185
            $this->object->addDefaultUrlParams('http://vitexsoftware.cz?a=b'));
1186
        $this->object->defaultUrlParams['id'] = 1;
1187
        $this->assertEquals('http://vitexsoftware.cz/path?id=1&a=b',
1188
            $this->object->addDefaultUrlParams('http://vitexsoftware.cz/path?a=b'));
1189
    }
1190
1191
    public function testFlexiDateToDateTime()
1192
    {
1193
        $this->assertEquals(1495749600,
1194
            FlexiBeeRO::flexiDateToDateTime('2017-05-26+02:00')->getTimestamp());
1195
    }
1196
1197
    public function testFlexiDateTimeToDateTime()
1198
    {
1199
        $this->assertEquals(1506412853,
1200
            FlexiBeeRO::flexiDateTimeToDateTime('2017-09-26T10:00:53.755+02:00')->getTimestamp());
1201
    }
1202
1203
    /**
1204
     * @covers FlexiPeeHP\FlexiBeeRO::takeData
1205
     */
1206
    public function testTakeData()
1207
    {
1208
        $this->object->takeData(['id'=>1]);
1209
        $this->assertEquals( constant('FLEXIBEE_URL') .'/'.constant('FLEXIBEE_COMPANY') .  '/1', $this->object->getApiURL());
1210
        
1211
        $this->object->dataReset();
1212
        $this->object->takeData(['kod'=>'test']);
1213
        $this->assertEquals(constant('FLEXIBEE_URL') .'/'.constant('FLEXIBEE_COMPANY') . '/code:TEST', $this->object->getApiURL());
1214
    }
1215
    
1216
    
1217
    /**
1218
     * @covers FlexiPeeHP\FlexiBeeRO::setDataValue
1219
     */
1220
    public function testSetDataValue()
1221
    {
1222
        if (!empty($this->object->getColumnsInfo())) {
1223
            $this->object->setDataValue('datVyst', new \DateTime());
1224
        }
1225
        $this->object->setDataValue('test', 'test');
1226
        $this->object->setDataValue('kod', 'code:testKOD');
1227
        $this->assertEquals('testKOD', $this->object->getDataValue('kod'));
1228
    }
1229
1230
    /**
1231
     * @covers FlexiPeeHP\FlexiBeeRO::saveDebugFiles
1232
     */
1233
    public function testSaveDebugFiles()
1234
    {
1235
        $this->object->saveDebugFiles();
1236
    }
1237
1238
    /**
1239
     * @covers FlexiPeeHP\FlexiBeeRO::setPostFields
1240
     * @covers FlexiPeeHP\FlexiBeeRO::getPostFields
1241
     */
1242
    public function testSetPostFields()
1243
    {
1244
        $this->object->setPostFields('test');
1245
        $this->assertEquals($this->object->getPostFields(), 'test');
1246
    }
1247
1248
    /**
1249
     * PHP Date object to FlexiBee date format test
1250
     * 
1251
     * @covers FlexiPeeHP\FlexiBeeRO::dateToFlexiDate
1252
     */
1253
    public function testDateToFlexiDate()
1254
    {
1255
        $dater = new \DateTime();
1256
        $this->assertEquals($dater->format(FlexiBeeRO::$DateFormat),
1257
            FlexiBeeRO::dateToFlexiDate($dater));
1258
    }
1259
1260
    /**
1261
     * PHP Date object to FlexiBee dateTime format test
1262
     * 
1263
     * @covers FlexiPeeHP\FlexiBeeRO::dateToFlexiDateTime
1264
     */
1265
    public function testDateToFlexiDateTime()
1266
    {
1267
        $dater = new \DateTime();
1268
        $this->assertEquals($dater->format(FlexiBeeRO::$DateTimeFormat),
1269
            FlexiBeeRO::dateToFlexiDateTime($dater));
1270
    }
1271
1272
    public function testSetFilter()
1273
    {
1274
        $this->object->setFilter('X');
1275
        $this->object->setFilter(['a' => 'b']);
1276
    }
1277
1278
    /**
1279
     * @covers FlexiPeeHP\FlexiBeeRO::getColumnInfo
1280
     */
1281
    public function testGetColumnInfo()
1282
    {
1283
        $this->object->getColumnInfo('id');
1284
    }
1285
1286
    /**
1287
     * @covers FlexiPeeHP\FlexiBeeRO::getFlexiBeeURL
1288
     */
1289
    public function testGetFlexiBeeURL()
1290
    {
1291
        $this->object->getFlexiBeeURL();
1292
    }
1293
1294
    /**
1295
     * @covers FlexiPeeHP\FlexiBeeRO::error500Reporter
1296
     */
1297
    public function testError500Reporter()
1298
    {
1299
        $this->object->reportRecipient = '[email protected]';
1300
        $this->object->error500Reporter(['success' => 'false', 'message' => 'test']);
1301
    }
1302
1303
    /**
1304
     * @covers FlexiPeeHP\FlexiBeeRO::setMyKey
1305
     */
1306
    public function testSetMyKey()
1307
    {
1308
        $this->object->setMyKey(1);
1309
    }
1310
1311
    /**
1312
     * @covers FlexiPeeHP\FlexiBeeRO::ignore404
1313
     */
1314
    public function testIgnore404()
1315
    {
1316
        $this->object->ignore404(true);
1317
        $this->assertTrue($this->object->ignore404());
1318
    }
1319
1320
    /**
1321
     * @covers FlexiPeeHP\FlexiBeeRO::sendByMail
1322
     */
1323
    public function testSendByMail()
1324
    {
1325
        $this->object->sendByMail($this->object->reportRecipient, 'test',
1326
            'test body');
1327
    }
1328
1329
    /**
1330
     * @covers FlexiPeeHP\FlexiBeeRO::sendUnsent
1331
     */
1332
    public function testSendUnsent()
1333
    {
1334
        $this->object->sendUnsent();
1335
    }
1336
1337
    /**
1338
     * @expectedException        Ease\Exception
1339
     * @expectedExceptionMessage Unknown language ua for PDF export
1340
     * @covers FlexiPeeHP\FlexiBeeRO::getInFormat
1341
     */
1342
    public function testGetInFormat()
1343
    {
1344
        $this->object->evidence = 'test';
1345
        $this->object->getInFormat('html', 'test');
1346
        $this->object->getInFormat('pdf', 'test');
1347
        $this->object->getInFormat('pdf', 'test','cs',true);
1348
        $this->object->getInFormat('pdf', 'error','ua',false);
1349
    }
1350
1351
    /**
1352
     * @covers FlexiPeeHP\FlexiBeeRO::downloadInFormat
1353
     */
1354
    public function testDownloadInFormat()
1355
    {
1356
        $this->object->downloadInFormat('pdf', sys_get_temp_dir().'/');
1357
    }
1358
1359
    /**
1360
     * @covers FlexiPeeHP\FlexiBeeRO::code
1361
     */
1362
    public function testCode()
1363
    {
1364
        $this->assertEquals('code:TEST', FlexiBeeRO::code('test'));
1365
    }
1366
1367
    /**
1368
     * @covers FlexiPeeHP\FlexiBeeRO::uncode
1369
     */
1370
    public function testUncode()
1371
    {
1372
        $this->assertEquals('test', FlexiBeeRO::uncode('code:test'));
1373
    }
1374
1375
    /**
1376
     * @covers FlexiPeeHP\FlexiBeeRO::arrayCleanUP
1377
     */
1378
    public function testArrayCleanUP()
1379
    {
1380
        $this->assertEquals(['a' => 'b'],
1381
            FlexiBeeRO::arrayCleanUP(['a' => 'b', '@a' => 'aaa']));
1382
    }
1383
1384
    /**
1385
     * @covers FlexiPeeHP\FlexiBeeRO::__wakeup
1386
     */
1387
    public function test__wakeup()
1388
    {
1389
        $this->object->__wakeup();
1390
    }
1391
1392
    /**
1393
     * @covers FlexiPeeHP\FlexiBeeRO::__destruct
1394
     */
1395
    public function test_destruct()
1396
    {
1397
        $this->object->__destruct();
1398
    }
1399
}
1400