Test Failed
Push — master ( 0e13f3...6d8a3f )
by Vítězslav
06:17
created

FlexiBeeROTest::testRawXmlToArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 0
dl 0
loc 22
rs 9.2
c 0
b 0
f 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 testSetupProperty()
110
    {
111
        $this->object->setupProperty(['test' => 'test'], 'test');
112
        $properties = ['debug' => true];
113
        $this->object->setupProperty($properties, 'debug');
114
        $this->assertTrue($this->object->debug);
115
        $this->object->setupProperty($properties, 'url', 'FLEXIBEE_URL');
116
    }
117
118
    /**
119
     * @covers FlexiPeeHP\FlexiBeeRO::curlInit
120
     */
121
    public function testCurlInit()
122
    {
123
        $this->object->timeout = 120;
124
        $this->object->curlInit();
125
        $this->assertTrue(is_resource($this->object->curl));
126
    }
127
128
    /**
129
     * @covers FlexiPeeHP\FlexiBeeRO::processInit
130
     */
131
    public function testProcessInit()
132
    {
133
        $this->object->processInit(1);
134
        $this->object->processInit(['id' => 1]);
135
        $this->assertEquals(1, $this->object->getDataValue('id'));
136
137
        if (!is_null($this->object->evidence) && $this->object->evidence != 'test') {
138
139
140
            $firstID = $this->object->getColumnsFromFlexibee(['id', 'kod'],
141
                ['limit' => 1]);
142
143
            if (count($firstID) && isset($firstID[0]['id'])) {
144
145
                $this->object->processInit((int) current($firstID));
146
                $this->assertNotEmpty($this->object->__toString());
147
148
                if (isset($firstID[0]['kod'])) {
149
                    $this->object->processInit('code:'.$firstID[0]['kod']);
150
                    $this->assertNotEmpty($this->object->__toString());
151
                }
152
153
                $this->object->processInit($this->object->getEvidenceURL().'/'.$firstID[0]['id'].'.xml');
154
            } else {
155
                $this->markTestSkipped(sprintf('Evidence %s doed not contain first record',
156
                        $this->object->getEvidence()));
157
            }
158
        }
159
    }
160
161
    /**
162
     * @covers FlexiPeeHP\FlexiBeeRO::setUp
163
     */
164
    public function testSetUp()
165
    {
166
        $this->object->authSessionId = 'XXXtestXXX';
167
        $this->object->setUp(
168
            [
169
                'company' => 'cmp',
170
                'url' => 'url',
171
                'user' => 'usr',
172
                'password' => 'pwd',
173
                'prefix' => 'c',
174
                'debug' => true,
175
                'defaultUrlParams' => ['limit' => 10],
176
                'evidence' => 'smlouva',
177
                'detail' => 'summary',
178
                'filter' => 'testfilter',
179
                'ignore404' => true,
180
                'offline' => true
181
            ]
182
        );
183
        $this->assertEquals('cmp', $this->object->company);
184
        $this->assertEquals('url', $this->object->url);
185
        $this->assertEquals('usr', $this->object->user);
186
        $this->assertEquals('/c/', $this->object->prefix);
187
        $this->assertEquals('pwd', $this->object->password);
188
    }
189
190
    /**
191
     * @covers FlexiPeeHP\FlexiBeeRO::getConnectionOptions
192
     */
193
    public function testGetConnectionOptions()
194
    {
195
        $options                     = $this->object->getConnectionOptions();
196
        $this->assertArrayHasKey('url', $options);
197
        $this->object->timeout       = 120;
198
        $this->object->authSessionId = 'sessid';
199
        $this->object->setCompany('test');
200
        $this->object->getConnectionOptions();
201
    }
202
203
    /**
204
     * @covers FlexiPeeHP\FlexiBeeRO::setPrefix
205
     * @expectedException \Exception
206
     */
207
    public function testSetPrefix()
208
    {
209
        $this->object->setPrefix('c');
210
        $this->assertEquals('/c/', $this->object->prefix);
211
        $this->object->setPrefix(null);
212
        $this->assertEquals('', $this->object->prefix);
213
        $this->object->setPrefix('fail');
214
    }
215
216
    /**
217
     * @covers FlexiPeeHP\FlexiBeeRO::setFormat
218
     */
219
    public function testSetFormat()
220
    {
221
        $this->object->setFormat('xml');
222
        $this->assertEquals('xml', $this->object->format);
223
    }
224
225
    /**
226
     * We can set only evidence defined in EvidenceList class
227
     *
228
     * @covers FlexiPeeHP\FlexiBeeRO::setEvidence
229
     * @expectedException \Exception
230
     */
231
    public function testSetEvidence()
232
    {
233
        $this->object->setEvidence('adresar');
234
        $this->assertEquals('adresar', $this->object->evidence);
235
        $this->object->setPrefix('c');
236
        $this->object->debug = true;
237
        $this->object->setEvidence('fail');
238
    }
239
240
    /**
241
     * @covers FlexiPeeHP\FlexiBeeRO::setCompany
242
     */
243
    public function testSetCompany()
244
    {
245
        $this->object->setCompany('test_s_r_o_');
246
        $this->assertEquals('test_s_r_o_', $this->object->company);
247
    }
248
249
    /**
250
     * @covers FlexiPeeHP\FlexiBeeRO::object2array
251
     */
252
    public function testObject2array()
253
    {
254
        $this->assertNull($this->object->object2array(new \stdClass()));
255
        $this->assertEquals(
256
            [
257
                'item' => 1,
258
                'arrItem' => ['a', 'b' => 'c']
259
            ]
260
            , $this->object->object2array(new \Test\ObjectForTesting()));
261
    }
262
263
    /**
264
     * @covers FlexiPeeHP\FlexiBeeRO::objectToID
265
     */
266
    public function testObjectToID()
267
    {
268
        $this->object->setDataValue('kod', 'TEST');
269
        $this->assertEquals('code:TEST',
270
            $this->object->objectToID($this->object));
271
272
        $this->assertEquals('TEST', $this->object->objectToID('TEST'));
0 ignored issues
show
Documentation introduced by
'TEST' is of type string, but the function expects a object|array.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
273
    }
274
275
    /**
276
     * @covers FlexiPeeHP\FlexiBeeRO::performRequest
277
     */
278
    public function testPerformRequest()
279
    {
280
        $evidence = $this->object->getEvidence();
281
        switch ($evidence) {
282
            case null:
283
            case '':
284
            case 'c':
285
            case 'test':
286
            case 'status':
287
            case 'nastaveni':
288
                $this->object->performRequest(null, 'GET', 'xml');
289
                break;
290
291
            default:
292
                $this->object->performRequest(null, 'GET', 'json');
293
                $this->object->performRequest(null, 'GET', 'xml');
294
                break;
295
        }
296
297
        //404 Test
298
299
        $notFound = $this->object->performRequest('error404.json');
300
        if(array_key_exists('message', $notFound)){
301
            $this->assertEquals('false', $notFound['success']);
302
        } else {
303
            echo '';
304
        }
305
    }
306
307
    /**
308
     * @covers FlexiPeeHP\FlexiBeeRO::rawResponseToArray
309
     */
310
    public function testRawResponseToArray()
311
    {
312
313
        $this->assertTrue(is_array(
314
                $this->object->rawResponseToArray($this->json, 'json')));
315
        $this->assertTrue(is_array(
316
                $this->object->rawResponseToArray($this->xml, 'xml')));
317
        $this->assertTrue(is_array(
318
                $this->object->rawResponseToArray('simpletext', 'txt')));
319
        $this->assertTrue(is_array(
320
                $this->object->rawResponseToArray('othertext', 'other')));
321
    }
322
323
    /**
324
     * @covers FlexiPeeHP\FlexiBeeRO::rawJsonToArray
325
     */
326
    public function testRawJsonToArray()
327
    {
328
        $this->assertNull($this->object->rawJsonToArray($this->json.'XXX'));
329
        $evidence = $this->object->getResponseEvidence() ? $this->object->getResponseEvidence() : 'adresar';
330
        $arrayWeWant = [
331
            '@version' => '1.0',
332
            $evidence  =>
333
            [
334
                [
335
                    'id' => '2574',
336
                    'kontakty' =>
337
                    [
338
                        ['id' => '299']
339
                    ]
340
                ]
341
            ]
342
        ];
343
        $this->assertEquals($arrayWeWant,
344
            $this->object->rawJsonToArray($this->json));
345
    }
346
347
    /**
348
     * @covers FlexiPeeHP\FlexiBeeRO::rawXmlToArray
349
     */
350
    public function testRawXmlToArray()
351
    {
352
        $evidence = $this->object->getResponseEvidence() ? $this->object->getResponseEvidence() : 'adresar';
353
        $arrayWeWant = [
354
            '@version' => '1.0',
355
            $evidence =>
356
            [
357
                [
358
                    'id' => '2574',
359
                    'kontakty' =>
360
                    [
361
                        ['kontakt' => [
362
                                ['id' => '299']
363
                            ]
364
                        ]
365
                    ]
366
                ]
367
            ]
368
        ];
369
        $this->assertEquals($arrayWeWant,
370
            $this->object->rawXmlToArray($this->xml));
371
    }
372
373
    /**
374
     * @covers FlexiPeeHP\FlexiBeeRO::parseResponse
375
     */
376
    public function testParseResponse()
377
    {
378
        $this->object->parseResponse($this->object->rawJsonToArray($this->json),
379
            200);
380
    }
381
382
    /**
383
     * @covers FlexiPeeHP\FlexiBeeRO::doCurlRequest
384
     */
385
    public function testDoCurlRequest()
386
    {
387
        $this->object->doCurlRequest(constant('FLEXIBEE_URL'), 'GET');
388
    }
389
390
    /**
391
     * @covers FlexiPeeHP\FlexiBeeRO::setAction
392
     */
393
    public function testSetAction()
394
    {
395
        switch ($this->object->getEvidence()) {
396
            case '':
397
            case 'c':
398
            case 'hooks':
399
            case 'status':
400
            case 'changes':
401
            case 'nastaveni':
402
            case 'evidence-list':
403
                $this->object->setAction('none');
404
                break;
405
            default:
406
                $this->assertTrue($this->object->setAction('new'));
407
                $this->object->actionsAvailable = [];
408
                $this->assertFalse($this->object->setAction('none'));
409
                $this->object->actionsAvailable = ['copy'];
410
                $this->assertFalse($this->object->setAction('none'));
411
                break;
412
        }
413
    }
414
415
    /**
416
     * @covers FlexiPeeHP\FlexiBeeRO::getEvidence
417
     */
418
    public function testGetEvidence()
419
    {
420
        $this->assertEquals($this->object->evidence,
421
            $this->object->getEvidence());
422
    }
423
424
    /**
425
     * @covers FlexiPeeHP\FlexiBeeRO::getCompany
426
     */
427
    public function testGetCompany()
428
    {
429
        $this->assertEquals($this->object->company, $this->object->getCompany());
430
    }
431
432
    /**
433
     * @covers FlexiPeeHP\FlexiBeeRO::getResponseEvidence
434
     */
435 View Code Duplication
    public function testGetResponseEvidence()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
436
    {
437
        $responseEvidence = $this->object->getResponseEvidence();
438
        switch ($this->object->getEvidence()) {
439
            case '':
440
            case 'c':
441
            case 'hooks':
442
            case 'status':
443
            case 'changes':
444
            case 'nastaveni':
445
            case 'evidence-list':
446
                break;
447
            default:
448
                $this->assertEquals($this->object->getEvidence(),
449
                    $responseEvidence);
450
                break;
451
        }
452
    }
453
454
    /**
455
     * @covers FlexiPeeHP\FlexiBeeRO::getLastInsertedId
456
     * @depends testInsertToFlexiBee
457
     */
458
    public function testGetLastInsertedId()
459
    {
460
        $this->assertNotEmpty($this->object->getLastInsertedId());
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class FlexiPeeHP\FlexiBeeRO as the method getLastInsertedId() does only exist in the following sub-classes of FlexiPeeHP\FlexiBeeRO: FlexiPeeHP\Adresar, FlexiPeeHP\Banka, FlexiPeeHP\Cenik, FlexiPeeHP\Company, FlexiPeeHP\DodavatelskaSmlouva, FlexiPeeHP\FakturaPrijata, FlexiPeeHP\FakturaVydana, FlexiPeeHP\FakturaVydanaPolozka, FlexiPeeHP\FlexiBeeRW, FlexiPeeHP\Hooks, FlexiPeeHP\Kontakt, FlexiPeeHP\Pokladna, FlexiPeeHP\PokladniPohyb, FlexiPeeHP\Priloha, FlexiPeeHP\RadaPokladniPohyb, FlexiPeeHP\SkladovaKarta, FlexiPeeHP\SkladovyPohyb, FlexiPeeHP\SkladovyPohybPolozka, FlexiPeeHP\SkupinaFirem, FlexiPeeHP\Stitek, FlexiPeeHP\Strom, FlexiPeeHP\StromCenik, FlexiPeeHP\UcetniObdobi, FlexiPeeHP\VyrobniCislo. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
461
    }
462
463
    /**
464
     * @covers FlexiPeeHP\FlexiBeeRO::xml2array
465
     */
466
    public function testXml2array()
467
    {
468
        $arrayWeWant = [
469
            '@version' => '1.0',
470
            'adresar' =>
471
            [
472
                [
473
                    'id' => '2574',
474
                    'kontakty' =>
475
                    [
476
                        ['kontakt' => [
477
                                ['id' => '299']
478
                            ]
479
                        ]
480
                    ]
481
                ]
482
            ]
483
        ];
484
485
        $this->assertEquals($arrayWeWant, $this->object->xml2array($this->xml));
486
    }
487
488
    /**
489
     * @covers FlexiPeeHP\FlexiBeeRO::extractUrlParams
490
     */
491
    public function testExtractUrlParams()
492
    {
493
        $conditions = ['id' => 23, 'limit' => 10];
494
        $this->object->extractUrlParams($conditions, $urlParams);
495
        $this->assertEquals(['id' => 23], $conditions);
496
        $this->assertEquals(['limit' => 10], $urlParams);
497
    }
498
499
    /**
500
     * @covers FlexiPeeHP\FlexiBeeRO::urlEncode
501
     */
502
    public function testUrlEncode()
503
    {
504
        $this->assertEquals("stitky%3D'code:VIP'%20or%20stitky%3D'code:DULEZITE'",
505
            FlexiBeeRO::urlEncode("stitky='code:VIP' or stitky='code:DULEZITE'"));
506
    }
507
508
    /**
509
     * @covers FlexiPeeHP\FlexiBeeRO::getAllFromFlexibee
510
     */
511
    public function testGetAllFromFlexibee()
512
    {
513
        $this->object->getAllFromFlexibee();
514
    }
515
516
    /**
517
     * @covers FlexiPeeHP\FlexiBeeRO::disconnect
518
     *
519
     * @depends testPerformRequest
520
     * @depends testLoadFlexiData
521
     * @depends testGetFlexiRow
522
     * @depends testGetFlexiData
523
     * @depends testLoadFromFlexiBee
524
     * @depends testInsertToFlexiBee
525
     * @depends testIdExists
526
     * @depends testRecordExists
527
     * @depends testGetColumnsFromFlexibee
528
     * @depends testSearchString
529
     */
530
    public function testDisconnect()
531
    {
532
        $this->object->disconnect();
533
        $this->assertNull($this->object->curl);
534
    }
535
536
    /**
537
     * @covers FlexiPeeHP\FlexiBeeRO::__destruct
538
     * @depends testDisconnect
539
     */
540
    public function testdestruct()
541
    {
542
        $this->markTestSkipped();
543
    }
544
545
    /**
546
     * @covers FlexiPeeHP\FlexiBeeRO::getFlexiRow
547
     */
548
    public function testGetFlexiRow()
549
    {
550
        $this->object->getFlexiRow(0);
551
        $this->object->getFlexiRow(1);
552
    }
553
554
    /**
555
     * @covers FlexiPeeHP\FlexiBeeRO::getFlexiData
556
     */
557
    public function testGetFlexiData()
558
    {
559
        $evidence = $this->object->getEvidence();
560
        switch ($evidence) {
561
            case null:
562
                $this->object->getFlexiData();
563
                break;
564
            case 'c':
565
                $this->object->evidence  = 'c';
566
                $this->object->prefix    = '';
567
                $this->object->company   = '';
568
                $this->object->nameSpace = 'companies';
569
                $flexidata               = $this->object->getFlexiData();
570
                $this->assertArrayHasKey('company', $flexidata);
571
                break;
572
            case 'evidence-list':
573
                $flexidata               = $this->object->getFlexiData(null,
574
                    ['detail' => 'id']);
575
                $this->assertArrayHasKey('evidenceType', $flexidata[0]);
576
                break;
577
578
            default:
579
                $flexidata = $this->object->getFlexiData(null,
580
                    ['detail' => 'id']);
581
582
                if (is_array($flexidata)) {
583
                    if (count($flexidata)) {
584
                        $this->markTestSkipped('Empty evidence');
585
                    } else {
586
                        $this->assertArrayHasKey(0, $flexidata);
587
588
                        $this->assertArrayHasKey('id', $flexidata[0]);
589
                        $filtrered = $this->object->getFlexiData(null,
590
                            ["id = ".$flexidata[0]['id'], 'detail' => 'full']);
591
                        $this->assertArrayHasKey(0, $filtrered);
592
                        $this->assertArrayHasKey('id', $filtrered[0]);
593
                    }
594
                }
595
                break;
596
        }
597
    }
598
599
    /**
600
     * @covers FlexiPeeHP\FlexiBeeRO::loadFromFlexiBee
601
     */
602
    public function testLoadFromFlexiBee()
603
    {
604
        $this->object->loadFromFlexiBee();
605
        $this->object->loadFromFlexiBee(222);
606
    }
607
608
    /**
609
     * @covers FlexiPeeHP\FlexiBeeRO::getJsonizedData
610
     */
611
    public function testGetJsonizedData()
612
    {
613
        $this->assertEquals('{"'.$this->object->nameSpace.'":{"@version":"1.0","'.$this->object->evidence.'":{"key":"value"}}}',
614
            $this->object->getJsonizedData(['key' => 'value']));
615
616
        switch ($this->object->getEvidence()) {
617
            case '':
618
            case 'c':
619
            case 'hooks':
620
            case 'status':
621
            case 'changes':
622
            case 'nastaveni':
623
            case 'evidence-list':
624
                $this->object->getJsonizedData(['key' => 'value']);
625
                break;
626
            default:
627
                $this->object->setAction('copy');
628
                $this->assertEquals('{"'.$this->object->nameSpace.'":{"@version":"1.0","'.$this->object->evidence.'":{"key":"value"},"'.$this->object->evidence.'@action":"copy"}}',
629
                    $this->object->getJsonizedData(['key' => 'value']));
630
631
                $this->object->action = 'storno';
0 ignored issues
show
Bug introduced by
The property action cannot be accessed from this context as it is declared protected in class FlexiPeeHP\FlexiBeeRO.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
632
                $this->object->filter = "stavUhrK = 'stavUhr.uhrazeno'";
633
                $this->object->getJsonizedData([]);
634
                break;
635
        }
636
    }
637
638
    /**
639
     * @covers FlexiPeeHP\FlexiBeeRO::getDataForJSON
640
     */
641
    public function testGetDataForJson()
642
    {
643
        $this->object->getDataForJSON();
644
    }
645
646
    /**
647
     * @covers FlexiPeeHP\FlexiBeeRO::idExists
648
     */
649
    public function testIdExists()
650
    {
651
        $this->assertFalse($this->object->idExists('nonexistent'));
652
        switch ($this->object->getEvidence()) {
653
            case '':
654
            case 'c':
655
            case 'hooks':
656
            case 'status':
657
            case 'changes':
658
            case 'nastaveni':
659
            case 'evidence-list':
660
                break;
661
            default:
662
                $first = $this->object->getColumnsFromFlexibee(['id'],
663
                    ['limit' => 1], 'id');
664
                if (empty($first)) {
665
                    $this->markTestSkipped('empty evidence ?');
666
                } else {
667
                    $this->object->setData($first);
668
                    $this->assertTrue($this->object->idExists());
669
                }
670
                break;
671
        }
672
    }
673
674
    /**
675
     * @covers FlexiPeeHP\FlexiBeeRO::getRecordID
676
     */
677
    public function testGetRecordID()
678
    {
679
        $this->object->setData([$this->object->getKeyColumn() => 10]);
680
        $this->assertEquals(10, $this->object->getRecordID());
681
    }
682
683
    /**
684
     * @covers FlexiPeeHP\FlexiBeeRO::recordExists
685
     */
686
    public function testRecordExists()
687
    {
688
        $evidence = $this->object->getEvidence();
689
690
        switch ($evidence) {
691
            case null:
692
            case 'c':
693
            case 'status':
694
            case 'evidence-list':
695
                $this->object->recordExists();
696
                break;
697
698
            default:
699
                $flexidata = $this->object->getFlexiData(null,
700
                    ['limit' => 1, 'detail' => 'id']);
701
                if (is_array($flexidata) && !count($flexidata)) {
702
                    $this->assertFalse($this->object->recordExists(['id' => 1]),
703
                        'Record ID 1 exists in empty evidence ?');
704
                } else {
705
                    if (!is_null($flexidata)) {
706
                        $this->object->setData(['id' => (int) $flexidata[0]['id']]);
707
                        $this->assertTrue($this->object->recordExists(),
708
                            'First record exists test failed');
709
                        $this->assertFalse($this->object->recordExists(['id' => 0]),
710
                            'Record ID 0 exists');
711
                        $this->assertFalse($this->object->recordExists(['unexistent' => 1]),
712
                            'Unexistent Record exist ?');
713
                    }
714
                }
715
                break;
716
        }
717
    }
718
719
    /**
720
     * @covers FlexiPeeHP\FlexiBeeRO::getColumnsFromFlexibee
721
     */
722
    public function testGetColumnsFromFlexibee()
723
    {
724
725
        switch ($this->object->getEvidence()) {
726
            case '':
727
            case 'c':
728
            case 'hooks':
729
            case 'status':
730
            case 'changes':
731
            case 'nastaveni':
732
            case 'evidence-list':
733
                break;
734
            default:
735
                $this->object->getColumnsFromFlexibee(['id', 'kod'],
736
                    ['limit' => 1], 'id');
737
                $this->object->getColumnsFromFlexibee('summary', ['limit' => 1],
0 ignored issues
show
Documentation introduced by
'summary' is of type string, but the function expects a array<integer,string>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
738
                    'id');
739
740
                break;
741
        }
742
    }
743
744
    /**
745
     * @covers FlexiPeeHP\FlexiBeeRO::getExternalID
746
     */
747
    public function testGetExternalID()
748
    {
749
        $this->assertTrue(empty($this->object->getExternalID('ext:test:10'))); //ext: does not exist
750
751
        $this->object->setDataValue('external-ids',
752
            ['ext:doe:22', 'ext:test:10']);
753
754
        $this->assertEquals('ext:doe:22', $this->object->getExternalID());
755
        $this->assertEquals('10', $this->object->getExternalID('test'));
756
    }
757
758
    /**
759
     * @covers FlexiPeeHP\FlexiBeeRO::getGlobalVersion
760
     */
761 View Code Duplication
    public function testGetGlobalVersion()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
762
    {
763
        switch ($this->object->getEvidence()) {
764
            case '':
765
            case 'c':
766
            case 'hooks':
767
            case 'status':
768
            case 'changes':
769
            case 'nastaveni':
770
            case 'evidence-list':
771
                $this->object->getGlobalVersion();
772
                break;
773
            default:
774
                $this->assertInternalType("int",
775
                    $this->object->getGlobalVersion(),
776
                    'error obtaining of GlobalVersion');
777
                break;
778
        }
779
    }
780
781
    /**
782
     * @covers FlexiPeeHP\FlexiBeeRO::getApiURL
783
     */
784
    public function testGetApiUrl()
785
    {
786
        $evidence = $this->object->getEvidence();
787
        if ($evidence) {
788
            $url = $this->object->url.'/c/'.constant('FLEXIBEE_COMPANY').'/'.$evidence;
789
        } else {
790
            $url = $this->object->url.'/c/'.constant('FLEXIBEE_COMPANY');
791
        }
792
793
        $this->assertEquals($url, $this->object->getApiURL());
794
        $this->assertEquals($url.'.html', $this->object->getApiURL('html'));
795
        $this->assertEquals($url.'.xml', $this->object->getApiURL('xml'));
796
    }
797
798
    /**
799
     * @covers FlexiPeeHP\FlexiBeeRO::getResponseFormat
800
     */
801
    public function testGetResponseFormat()
802
    {
803
        $this->object->performRequest(null, 'GET', 'json');
804
        $this->assertEquals('application/json',
805
            $this->object->getResponseFormat());
806
        $this->object->performRequest(null, 'GET', 'xml');
807
        $this->assertEquals('application/xml',
808
            $this->object->getResponseFormat());
809
        unset($this->object->curlInfo['content_type']);
810
        $this->assertNull($this->object->getResponseFormat());
811
    }
812
813
    /**
814
     * @covers FlexiPeeHP\FlexiBeeRO::getKod
815
     */
816
    public function testGetKod()
817
    {
818
        $testString = [];
819
        $this->assertEquals('code:CODE',
820
            $this->object->getKod([$this->object->keyColumn => 'code']));
821
822
        $testString[$this->object->nameColumn] = 'Fish clamp -  Úchytka pro instalaci samonosných kabelů '
823
            .'(3.5 mm)';
824
        $code0                                 = $this->object->getKod($testString);
825
        $this->assertEquals('code:FISHCLAMPUCHYTKAPR', $code0);
826
        $code1                                 = $this->object->getKod($testString,
827
            false);
828
        $this->assertEquals('code:FISHCLAMPUCHYTKAPR', $code1);
829
        $code2                                 = $this->object->getKod($testString);
830
        $this->assertEquals('code:FISHCLAMPUCHYTKAPR1', $code2);
831
        $this->object->setData($testString);
832
        $code3                                 = $this->object->getKod();
833
        $this->assertEquals('code:FISHCLAMPUCHYTKAPR2', $code3);
834
835
        $this->assertEquals('code:TEST',
836
            $this->object->getKod([$this->object->nameColumn => 'test']));
837
838
        $this->assertEquals('code:TEST1', $this->object->getKod('test'));
839
840
        $this->assertEquals('code:TEST2',
841
            $this->object->getKod(['kod' => 'test']));
842
        $this->assertEquals('code:NOTSET', $this->object->getKod(['kod' => '']));
843
    }
844
845
    /**
846
     * @covers FlexiPeeHP\FlexiBeeRO::logResult
847
     */
848
    public function testLogResult()
849
    {
850
        $this->object->cleanMessages();
851
        $success = json_decode('{"winstrom":{"@version":"1.0","success":"true",'
852
            .'"stats":{"created":"0","updated":"1","deleted":"0","skipped":"0"'
853
            .',"failed":"0"},"results":[{"id":"1","request-id":"ext:SōkoMan.item'
854
            .':5271","ref":"/c/spoje_net_s_r_o_1/skladovy-pohyb/1.json"}]}}');
855
        $this->object->logResult(current($this->object->object2array($success)),
856
            'http://test');
857
858
        $this->assertArrayHasKey('info', $this->object->getStatusMessages(true));
859
860
        $error                          = json_decode('{"winstrom":{"@version":"1.0","success":"false",'
861
            .'"stats":{"created":"0","updated":"0","deleted":"0","skipped":"0"'
862
            .',"failed":"0"},"results":[{"errors":[{"message":"cz.winstrom.'
863
            .'service.WSBusinessException: Zadaný kód není unikátní.\nZadaný'
864
            .' kód není unikátní."}]}]}}');
865
        $this->object->lastResponseCode = 500;
866
        $this->object->logResult(current($this->object->object2array($error)));
867
        $this->assertArrayHasKey('error', $this->object->getStatusMessages(true));
868
    }
869
870
    /**
871
     * @covers FlexiPeeHP\FlexiBeeRO::flexiUrl
872
     */
873
    public function testFlexiUrl()
874
    {
875
        $this->assertEquals("a eq '1' and b eq 'foo'",
876
            $this->object->flexiUrl(['a' => 1, 'b' => 'foo'], 'and'));
877
        $this->assertEquals("a eq '1' or b eq 'bar'",
878
            $this->object->flexiUrl(['a' => 1, 'b' => 'bar'], 'or'));
879
        $this->assertEquals("a eq true or b eq false",
880
            $this->object->flexiUrl(['a' => true, 'b' => false], 'or'));
881
        $this->assertEquals("a is null and b is not null",
882
            $this->object->flexiUrl(['a' => null, 'b' => '!null'], 'and'));
883
    }
884
885
    /**
886
     * @covers FlexiPeeHP\FlexiBeeRO::unifyResponseFormat
887
     */
888
    public function testunifyResponseFormat()
889
    {
890
        $this->assertNull($this->object->unifyResponseFormat(null));
0 ignored issues
show
Documentation introduced by
null is of type null, but the function expects a array.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
891
        //One Row Test
892
893
        $responseEvidence = $this->object->getResponseEvidence();
894
        if (empty($responseEvidence)) {
895
            $responseEvidence       = $this->object->evidence = 'test';
896
        }
897
898
        $test1raw = [$responseEvidence =>
899
            ['id' => 1, 'name' => 'value']
900
        ];
901
902
        $test1expected = [$responseEvidence =>
903
            [
904
                ['id' => 1, 'name' => 'value']
905
            ]
906
        ];
907
908
        $this->assertEquals($test1expected,
909
            $this->object->unifyResponseFormat($test1raw));
910
911
        //Two Row Test
912
        $test2Raw = [$this->object->getResponseEvidence() =>
913
            [
914
                ['id' => 1, 'name' => 'value'],
915
                ['id' => 2, 'name' => 'value2']
916
            ]
917
        ];
918
919
        $test2expected = [$this->object->getResponseEvidence() =>
920
            [
921
                ['id' => 1, 'name' => 'value'],
922
                ['id' => 2, 'name' => 'value2']
923
            ]
924
        ];
925
926
        $this->assertEquals($test2expected,
927
            $this->object->unifyResponseFormat($test2Raw));
928
    }
929
930
    /**
931
     * @covers FlexiPeeHP\FlexiBeeRO::__toString
932
     */
933
    public function testtoString()
934
    {
935
        $id = '123';
936
        $this->object->setMyKey($id);
937
        $this->assertEquals($id, (string) $this->object);
938
939
        $this->object->setDataValue('kod', 'test');
940
        $this->assertEquals('code:TEST', (string) $this->object);
941
942
        $identifer = 'ext:test:123';
943
        $this->object->setMyKey($identifer);
944
        $this->assertEquals($identifer, (string) $this->object);
945
946
        $this->object->dataReset();
947
        $this->assertEquals('', $this->object->__toString());
948
    }
949
950
    /**
951
     * @covers FlexiPeeHP\FlexiBeeRO::draw
952
     */
953
    public function testDraw($whatWant = NULL)
954
    {
955
        $this->object->setDataValue('kod', 'test');
956
        $this->assertEquals('code:TEST', $this->object->draw());
957
    }
958
959
    /**
960
     * @covers FlexiPeeHP\FlexiBeeRO::getColumnsInfo
961
     */
962
    public function testgetColumnsInfo()
963
    {
964
        switch ($this->object->getEvidence()) {
965
            case '':
966
            case 'c':
967
            case 'hooks':
968
            case 'status':
969
            case 'changes':
970
            case 'evidence-list':
971
                $this->assertNull($this->object->getColumnsInfo());
972
                break;
973
            default:
974
                $this->assertNotEmpty($this->object->getColumnsInfo(),
975
                    'Cannot obtain structure for '.$this->object->getEvidence());
976
                break;
977
        }
978
    }
979
980
    /**
981
     * @covers FlexiPeeHP\FlexiBeeRO::getActionsInfo
982
     */
983
    public function testgetActionsInfo()
984
    {
985
        switch ($this->object->getEvidence()) {
986
            case '':
987
            case 'c':
988
            case 'hooks':
989
            case 'status':
990
            case 'changes':
991
            case 'nastaveni':
992
            case 'evidence-list':
993
                $this->assertNull($this->object->getActionsInfo());
994
                $this->assertNotEmpty($this->object->getActionsInfo('faktura-vydana'),
995
                    'Cannot obtain actions for na evidence');
996
                break;
997
            default:
998
                $this->assertNotEmpty($this->object->getActionsInfo(),
999
                    'Cannot obtain actions for '.$this->object->getEvidence());
1000
                break;
1001
        }
1002
    }
1003
1004
    /**
1005
     * @covers FlexiPeeHP\FlexiBeeRO::getRelationsInfo
1006
     */
1007
    public function testgetRelationsInfo()
1008
    {
1009
        switch ($this->object->getEvidence()) {
1010
            case '':
1011
            case 'c':
1012
            case 'hooks':
1013
            case 'status':
1014
            case 'changes':
1015
            case 'nastaveni':
1016
            case 'strom-cenik':
1017
            case 'ucetni-obdobi':
1018
            case 'evidence-list':
1019
                $this->assertNull($this->object->getRelationsInfo());
1020
                break;
1021
            default:
1022
                $this->assertNotEmpty($this->object->getRelationsInfo(),
1023
                    'Cannot obtain relations for '.$this->object->getEvidence());
1024
                break;
1025
        }
1026
    }
1027
1028
    /**
1029
     * @covers FlexiPeeHP\FlexiBeeRO::getEvidenceUrl
1030
     */
1031
    public function testgetEvidenceUrl()
1032
    {
1033
        $this->assertNotEmpty($this->object->getEvidenceUrl());
1034
        $this->assertNotEmpty($this->object->getEvidenceUrl('/properties'));
0 ignored issues
show
Unused Code introduced by
The call to FlexiBeeRO::getEvidenceURL() has too many arguments starting with '/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.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
1035
    }
1036
1037
    /**
1038
     * @covers FlexiPeeHP\FlexiBeeRO::evidenceToClassName
1039
     */
1040
    public function testevidenceToClassName()
1041
    {
1042
        $this->assertEquals('FakturaVydana',
1043
            $this->object->evidenceToClassName('faktura-vydana'));
1044
    }
1045
1046
    /**
1047
     * @covers FlexiPeeHP\FlexiBeeRO::getEvidenceInfo
1048
     */
1049 View Code Duplication
    public function testGetEvidenceInfo()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1050
    {
1051
        $eInfo = $this->object->getEvidenceInfo();
1052
        switch ($this->object->getEvidence()) {
1053
            case '':
1054
            case 'c':
1055
            case 'hooks':
1056
            case 'status':
1057
            case 'changes':
1058
            case 'nastaveni':
1059
            case 'evidence-list':
1060
                break;
1061
            default:
1062
                $this->assertArrayHasKey('evidencePath', $eInfo);
1063
                break;
1064
        }
1065
    }
1066
1067
    /**
1068
     * @covers FlexiPeeHP\FlexiBeeRO::getEvidenceName
1069
     */
1070 View Code Duplication
    public function testGetEvidenceName()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1071
    {
1072
        $evidenceName = $this->object->getEvidenceName();
1073
        switch ($this->object->getEvidence()) {
1074
            case '':
1075
            case 'c':
1076
            case 'hooks':
1077
            case 'status':
1078
            case 'changes':
1079
            case 'nastaveni':
1080
            case 'evidence-list':
1081
                break;
1082
            default:
1083
                $this->assertNotEmpty($evidenceName);
1084
                break;
1085
        }
1086
    }
1087
1088
    /**
1089
     * @covers FlexiPeeHP\FlexiBeeRO::saveResponseToFile
1090
     */
1091
    public function testSaveResponseToFile()
1092
    {
1093
        $tmp = sys_get_temp_dir().'/'.tmpfile();
1094
        $this->object->saveResponseToFile($tmp);
1095
        $this->assertFileExists($tmp);
1096
    }
1097
1098
    /**
1099
     * @covers FlexiPeeHP\FlexiBeeRO::getFirstRecordID()
1100
     */
1101 View Code Duplication
    public function testgetFirstRecordID()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1102
    {
1103
        $this->object->getFirstRecordID();
1104
        switch ($this->object->getEvidence()) {
1105
            case '':
1106
            case 'c':
1107
            case 'hooks':
1108
            case 'status':
1109
            case 'changes':
1110
            case 'nastaveni':
1111
            case 'evidence-list':
1112
                break;
1113
            default:
1114
                break;
1115
        }
1116
    }
1117
1118
    /**
1119
     * @covers FlexiPeeHP\FlexiBeeRO::getVazby
1120
     * @expectedException \Exception
1121
     */
1122 View Code Duplication
    public function testGetVazby()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1123
    {
1124
        switch ($this->object->getEvidence()) {
1125
            case '':
1126
            case 'c':
1127
            case 'hooks':
1128
            case 'status':
1129
            case 'changes':
1130
            case 'nastaveni':
1131
            case 'evidence-list':
1132
                break;
1133
            default:
1134
                $this->object->getVazby($this->object->getMyKey());
1135
                break;
1136
        }
1137
        $this->object->getVazby();
1138
    }
1139
1140
    /**
1141
     * @covers FlexiPeeHP\FlexiBeeRO::evidenceUrlWithSuffix
1142
     */
1143
    public function testEvidenceUrlWithSuffix()
1144
    {
1145
        $urlraw = $this->object->getEvidenceURL();
1146
        $lala   = $this->object->evidenceUrlWithSuffix('lala');
1147
        $this->assertEquals($urlraw.'/lala', $lala);
1148
        $lolo   = $this->object->evidenceUrlWithSuffix('?lele');
1149
        $this->assertEquals($urlraw.'?lele', $lolo);
1150
        $lulu   = $this->object->evidenceUrlWithSuffix(';lulu');
1151
        $this->assertEquals($urlraw.';lulu', $lulu);
1152
    }
1153
1154
    /**
1155
     * @covers FlexiPeeHP\FlexiBeeRO::join
1156
     * @expectedException \Ease\Exception
1157
     */
1158
    public function testJoin()
1159
    {
1160
        $ada = new FlexiBeeRO(['id' => 'A'], ['evidence' => 'adresar']);
1161
        $adb = new FlexiBeeRO(['id' => 'B'], ['evidence' => 'adresar']);
1162
        $this->assertTrue($this->object->join($ada));
1163
        $this->assertTrue($this->object->join($adb));
1164
        $ads = new \stdClass();
1165
        $this->object->join($ads);
0 ignored issues
show
Documentation introduced by
$ads is of type object<stdClass>, but the function expects a object<FlexiPeeHP\FlexiBeeRO>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1166
    }
1167
1168
    /**
1169
     * @covers FlexiPeeHP\FlexiBeeRO::addUrlParams
1170
     */
1171
    public function testAddUrlParams()
1172
    {
1173
        $this->assertEquals('http://vitexsoftware.cz/path?a=b&id=1',
1174
            $this->object->addUrlParams('http://vitexsoftware.cz/path?a=b',
1175
                ['id' => 1], TRUE));
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::setDataValue
1205
     */
1206
    public function testSetDataValue()
1207
    {
1208
        if (!empty($this->object->getColumnsInfo())) {
1209
            $this->object->setDataValue('datVyst', new \DateTime());
1210
        }
1211
        $this->object->setDataValue('test', 'test');
1212
        $this->object->setDataValue('kod', 'code:testKOD');
1213
        $this->assertEquals('testKOD', $this->object->getDataValue('kod'));
1214
    }
1215
1216
    /**
1217
     * @covers FlexiPeeHP\FlexiBeeRO::saveDebugFiles
1218
     */
1219
    public function testSaveDebugFiles()
1220
    {
1221
        $this->object->saveDebugFiles();
1222
    }
1223
1224
    /**
1225
     * @covers FlexiPeeHP\FlexiBeeRO::setPostFields
1226
     * @covers FlexiPeeHP\FlexiBeeRO::getPostFields
1227
     */
1228
    public function testSetPostFields()
1229
    {
1230
        $this->object->setPostFields('test');
1231
        $this->assertEquals($this->object->getPostFields(), 'test');
1232
    }
1233
1234
    /**
1235
     * PHP Date object to FlexiBee date format test
1236
     * 
1237
     * @covers FlexiPeeHP\FlexiBeeRO::dateToFlexiDate
1238
     */
1239
    public function testDateToFlexiDate()
1240
    {
1241
        $dater = new \DateTime();
1242
        $this->assertEquals($dater->format(FlexiBeeRO::$DateFormat),
1243
            FlexiBeeRO::dateToFlexiDate($dater));
1244
    }
1245
1246
    /**
1247
     * PHP Date object to FlexiBee dateTime format test
1248
     * 
1249
     * @covers FlexiPeeHP\FlexiBeeRO::dateToFlexiDateTime
1250
     */
1251
    public function testDateToFlexiDateTime()
1252
    {
1253
        $dater = new \DateTime();
1254
        $this->assertEquals($dater->format(FlexiBeeRO::$DateTimeFormat),
1255
            FlexiBeeRO::dateToFlexiDateTime($dater));
1256
    }
1257
1258
    public function testSetFilter()
1259
    {
1260
        $this->object->setFilter('X');
1261
        $this->object->setFilter(['a' => 'b']);
1262
    }
1263
1264
    /**
1265
     * @covers FlexiPeeHP\FlexiBeeRO::getColumnInfo
1266
     */
1267
    public function testGetColumnInfo()
1268
    {
1269
        $this->object->getColumnInfo('id');
1270
    }
1271
1272
    /**
1273
     * @covers FlexiPeeHP\FlexiBeeRO::getFlexiBeeURL
1274
     */
1275
    public function testGetFlexiBeeURL()
1276
    {
1277
        $this->object->getFlexiBeeURL();
1278
    }
1279
1280
    /**
1281
     * @covers FlexiPeeHP\FlexiBeeRO::error500Reporter
1282
     */
1283
    public function testError500Reporter()
1284
    {
1285
        $this->object->reportRecipient = '[email protected]';
1286
        $this->object->error500Reporter(['success' => 'false', 'message' => 'test']);
1287
    }
1288
1289
    /**
1290
     * @covers FlexiPeeHP\FlexiBeeRO::setMyKey
1291
     */
1292
    public function testSetMyKey()
1293
    {
1294
        $this->object->setMyKey(1);
1295
    }
1296
1297
    /**
1298
     * @covers FlexiPeeHP\FlexiBeeRO::ignore404
1299
     */
1300
    public function testIgnore404()
1301
    {
1302
        $this->object->ignore404(true);
1303
        $this->assertTrue($this->object->ignore404());
1304
    }
1305
1306
    /**
1307
     * @covers FlexiPeeHP\FlexiBeeRO::sendByMail
1308
     */
1309
    public function testSendByMail()
1310
    {
1311
        $this->object->sendByMail($this->object->reportRecipient, 'test',
1312
            'test body');
1313
    }
1314
1315
    /**
1316
     * @covers FlexiPeeHP\FlexiBeeRO::sendUnsent
1317
     */
1318
    public function testSendUnsent()
1319
    {
1320
        $this->object->sendUnsent();
1321
    }
1322
1323
    /**
1324
     * @covers FlexiPeeHP\FlexiBeeRO::getInFormat
1325
     */
1326
    public function testGetInFormat()
1327
    {
1328
        $this->object->evidence = 'test';
1329
        $this->object->getInFormat('html', 'test');
1330
    }
1331
1332
    /**
1333
     * @covers FlexiPeeHP\FlexiBeeRO::downloadInFormat
1334
     */
1335
    public function testDownloadInFormat()
1336
    {
1337
        $this->object->downloadInFormat('pdf', sys_get_temp_dir().'/');
1338
    }
1339
1340
    /**
1341
     * @covers FlexiPeeHP\FlexiBeeRO::code
1342
     */
1343
    public function testCode()
1344
    {
1345
        $this->assertEquals('code:TEST', FlexiBeeRO::code('test'));
1346
    }
1347
1348
    /**
1349
     * @covers FlexiPeeHP\FlexiBeeRO::uncode
1350
     */
1351
    public function testUncode()
1352
    {
1353
        $this->assertEquals('test', FlexiBeeRO::uncode('code:test'));
1354
    }
1355
1356
    /**
1357
     * @covers FlexiPeeHP\FlexiBeeRO::arrayCleanUP
1358
     */
1359
    public function testArrayCleanUP()
1360
    {
1361
        $this->assertEquals(['a' => 'b'],
1362
            FlexiBeeRO::arrayCleanUP(['a' => 'b', '@a' => 'aaa']));
1363
    }
1364
1365
    /**
1366
     * @covers FlexiPeeHP\FlexiBeeRO::__wakeup
1367
     */
1368
    public function test__wakeup()
1369
    {
1370
        $this->object->__wakeup();
1371
    }
1372
1373
    /**
1374
     * @covers FlexiPeeHP\FlexiBeeRO::__destruct
1375
     */
1376
    public function test_destruct()
1377
    {
1378
        $this->object->__destruct();
1379
    }
1380
}
1381