Completed
Push — master ( bf19e6...50ec2e )
by Vítězslav
09:51
created

FlexiBeeROTest   B

Complexity

Total Complexity 46

Size/Duplication

Total Lines 498
Duplicated Lines 2.01 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 12
Bugs 1 Features 3
Metric Value
wmc 46
c 12
b 1
f 3
lcom 1
cbo 4
dl 10
loc 498
rs 8.3999

29 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A tearDown() 0 4 1
A testCurlInit() 0 5 1
A testProcessInit() 0 11 3
A testSetUp() 0 15 1
A testSetEvidence() 0 5 1
A testObject2array() 0 10 1
A testObjectToID() 0 12 1
B testPerformRequest() 0 34 6
A testSetAction() 0 8 1
A testGetEvidence() 0 5 1
A testGetResponseEvidence() 0 5 1
A testGetLastInsertedId() 0 4 1
A testXml2array() 0 17 1
A testDisconnect() 0 5 1
A testdestruct() 0 4 1
A testGetFlexiRow() 0 5 1
B testGetFlexiData() 10 32 5
A testLoadFromFlexiBee() 0 5 1
A testJsonizeData() 0 8 1
A testIdExists() 0 7 1
C testRecordExists() 0 27 7
A testGetColumnsFromFlexibee() 0 7 1
B testGetKod() 0 27 1
A testLogResult() 0 21 1
A testFlexiUrl() 0 11 1
B testunifyResponseFormat() 0 38 1
A testtoString() 0 14 1
A testDraw() 0 5 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like FlexiBeeROTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use FlexiBeeROTest, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace Test\FlexiPeeHP;
4
5
use FlexiPeeHP\FlexiBeeRO;
6
7
/**
8
 * Generated by PHPUnit_SkeletonGenerator on 2016-05-04 at 10:08:36.
9
 */
10
class FlexiBeeROTest extends \Test\Ease\BrickTest
11
{
12
    /**
13
     * @var FlexiBeeRO
14
     */
15
    protected $object;
16
17
    /**
18
     * Sets up the fixture, for example, opens a network connection.
19
     * This method is called before a test is executed.
20
     * @covers FlexiPeeHP\FlexiBeeRO::__construct
21
     */
22
    protected function setUp()
23
    {
24
        $this->object            = new FlexiBeeRO();
25
        $this->object->evidence  = 'c';
26
        $this->object->prefix    = '';
27
        $this->object->company   = '';
28
        $this->object->nameSpace = 'companies';
29
    }
30
31
    /**
32
     * Tears down the fixture, for example, closes a network connection.
33
     * This method is called after a test is executed.
34
     */
35
    protected function tearDown()
36
    {
37
        
38
    }
39
40
    /**
41
     * @covers FlexiPeeHP\FlexiBeeRO::curlInit
42
     */
43
    public function testCurlInit()
44
    {
45
        $this->object->curlInit();
46
        $this->assertTrue(is_resource($this->object->curl));
47
    }
48
49
    /**
50
     * @covers FlexiPeeHP\FlexiBeeRO::processInit
51
     */
52
    public function testProcessInit()
53
    {
54
        $this->object->processInit(['id' => 1]);
55
        $this->assertEquals(1, $this->object->getDataValue('id'));
56
        if (!is_null($this->object->evidence) && $this->object->evidence != 'test') {
57
            $firstID = $this->object->getColumnsFromFlexibee('id',
0 ignored issues
show
Documentation introduced by
'id' 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...
58
                ['limit' => 1]);
59
            $this->object->processInit((int) current($firstID));
60
            $this->assertNotEmpty($this->object->__toString());
61
        }
62
    }
63
64
    /**
65
     * @covers FlexiPeeHP\FlexiBeeRO::setUp
66
     */
67
    public function testSetUp()
68
    {
69
        $this->object->setUp(
70
            [
71
                'company' => 'cmp',
72
                'url' => 'url',
73
                'user' => 'usr',
74
                'password' => 'pwd'
75
            ]
76
        );
77
        $this->assertEquals('cmp', $this->object->company);
78
        $this->assertEquals('url', $this->object->url);
79
        $this->assertEquals('usr', $this->object->user);
80
        $this->assertEquals('pwd', $this->object->password);
81
    }
82
83
    /**
84
     * @covers FlexiPeeHP\FlexiBeeRO::setEvidence
85
     */
86
    public function testSetEvidence()
87
    {
88
        $this->object->setEvidence('nastaveni');
89
        $this->assertEquals('nastaveni', $this->object->evidence);
90
    }
91
92
    /**
93
     * @covers FlexiPeeHP\FlexiBeeRO::object2array
94
     */
95
    public function testObject2array()
96
    {
97
        $this->assertNull($this->object->object2array(new \stdClass()));
98
        $this->assertEquals(
99
            [
100
            'item' => 1,
101
            'arrItem' => ['a', 'b' => 'c']
102
            ]
103
            , $this->object->object2array(new \Test\ObjectForTesting()));
104
    }
105
106
    /**
107
     * @covers FlexiPeeHP\FlexiBeeRO::objectToID
108
     */
109
    public function testObjectToID()
110
    {
111
        $id = \Ease\Sand::randomNumber(1, 9999);
112
        $this->object->setMyKey($id);
0 ignored issues
show
Security Bug introduced by
It seems like $id defined by \Ease\Sand::randomNumber(1, 9999) on line 111 can also be of type false; however, Ease\Brick::setMyKey() does only seem to accept integer|string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
113
        $this->assertEquals([$id], $this->object->objectToID([$this->object]));
114
115
        $this->object->setDataValue('kod', 'TEST');
116
        $this->assertEquals('code:TEST',
117
            $this->object->objectToID($this->object));
118
119
        $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...
120
    }
121
122
    /**
123
     * @covers FlexiPeeHP\FlexiBeeRO::performRequest
124
     */
125
    public function testPerformRequest()
126
    {
127
        $evidence = $this->object->getEvidence();
128
        switch ($evidence) {
129
            case null:
130
            case '':
131
            case 'test':
132
            case 'c':
133
                $this->object->evidence  = 'c';
134
                $this->object->prefix    = '';
135
                $this->object->company   = '';
136
                $this->object->nameSpace = 'companies';
137
                $json                    = $this->object->performRequest();
138
                $this->assertArrayHasKey('company', $json);
139
140
                $xml = $this->object->performRequest(null, 'GET', 'xml');
141
                $this->assertArrayHasKey('company', $xml);
142
                break;
143
144
            default:
145
                $json = $this->object->performRequest($evidence.'.json');
146
                if (array_key_exists('message', $json)) {
147
                    $this->assertArrayHasKey('@version', $json);
148
                } else {
149
                    $this->assertArrayHasKey($evidence, $json);
150
                }
151
                break;
152
        }
153
154
155
        $err = $this->object->performRequest('error.json');
156
        $this->assertArrayHasKey('success', $err);
157
        $this->assertEquals('false', $err['success']);
158
    }
159
160
    /**
161
     * @covers FlexiPeeHP\FlexiBeeRO::setAction
162
     */
163
    public function testSetAction()
164
    {
165
        $this->assertTrue($this->object->setAction('none'));
166
        $this->object->actionsAvailable = [];
167
        $this->assertFalse($this->object->setAction('none'));
168
        $this->object->actionsAvailable = ['copy'];
169
        $this->assertFalse($this->object->setAction('none'));
170
    }
171
172
    /**
173
     * @covers FlexiPeeHP\FlexiBeeRO::getEvidence
174
     */
175
    public function testGetEvidence()
176
    {
177
        $this->assertEquals($this->object->evidence,
178
            $this->object->getEvidence());
179
    }
180
181
    /**
182
     * @covers FlexiPeeHP\FlexiBeeRO::getResponseEvidence
183
     */
184
    public function testGetResponseEvidence()
185
    {
186
        $this->assertEquals($this->object->getEvidence(),
187
            $this->object->getResponseEvidence());
188
    }
189
190
    /**
191
     * @covers FlexiPeeHP\FlexiBeeRO::getLastInsertedId
192
     * @depends testInsertToFlexiBee
193
     */
194
    public function testGetLastInsertedId()
195
    {
196
        $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\FakturaVydana, FlexiPeeHP\FakturaVydanaPolozka, FlexiPeeHP\FlexiBeeRW, FlexiPeeHP\Hooks, FlexiPeeHP\Kontakt, FlexiPeeHP\Pokladna, FlexiPeeHP\PokladniPohyb, FlexiPeeHP\RadaPokladniPohyb, 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...
197
    }
198
199
    /**
200
     * @covers FlexiPeeHP\FlexiBeeRO::xml2array
201
     */
202
    public function testXml2array()
203
    {
204
        $xml = '<card xmlns="http://businesscard.org">
205
   <name>John Doe</name>
206
   <title>CEO, Widget Inc.</title>
207
   <email>[email protected]</email>
208
   <phone>(202) 456-1414</phone>
209
   <logo url="widget.gif"/>
210
   <a><b>c</b></a>
211
 </card>';
212
213
        $data = ['name' => 'John Doe', 'title' => 'CEO, Widget Inc.', 'email' => '[email protected]',
214
            'phone' => '(202) 456-1414', 'logo' => '', 'a' => [['b' => 'c']]];
215
216
217
        $this->assertEquals($data, $this->object->xml2array($xml));
218
    }
219
220
    /**
221
     * @covers FlexiPeeHP\FlexiBeeRO::disconnect
222
     *
223
     * @depends testPerformRequest
224
     * @depends testLoadFlexiData
225
     * @depends testGetFlexiRow
226
     * @depends testGetFlexiData
227
     * @depends testLoadFromFlexiBee
228
     * @depends testInsertToFlexiBee
229
     * @depends testIdExists
230
     * @depends testRecordExists
231
     * @depends testGetColumnsFromFlexibee
232
     * @depends testSearchString
233
     */
234
    public function testDisconnect()
235
    {
236
        $this->object->disconnect();
237
        $this->assertNull($this->object->curl);
238
    }
239
240
    /**
241
     * @covers FlexiPeeHP\FlexiBeeRO::__destruct
242
     * @depends testDisconnect
243
     */
244
    public function testdestruct()
245
    {
246
        $this->markTestSkipped();
247
    }
248
249
    /**
250
     * @covers FlexiPeeHP\FlexiBeeRO::getFlexiRow
251
     */
252
    public function testGetFlexiRow()
253
    {
254
        $this->object->getFlexiRow(0);
255
        $this->object->getFlexiRow(1);
256
    }
257
258
    /**
259
     * @covers FlexiPeeHP\FlexiBeeRO::getFlexiData
260
     */
261
    public function testGetFlexiData()
262
    {
263
        $evidence = $this->object->getEvidence();
264
265
        switch ($evidence) {
266
            case null:
267
                $this->markTestSkipped('Unsupported evidence');
268
                break;
269
            case 'c':
270
                $this->object->evidence  = 'c';
271
                $this->object->prefix    = '';
272
                $this->object->company   = '';
273
                $this->object->nameSpace = 'companies';
274
                $flexidata               = $this->object->getFlexiData();
275
                $this->assertArrayHasKey('company', $flexidata);
276
                break;
277
278
            default:
279
                $flexidata = $this->object->getFlexiData();
280 View Code Duplication
                if (is_array($flexidata) && !count($flexidata)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
281
                    $this->markTestSkipped('Empty evidence');
282
                } else {
283
                    $this->assertArrayHasKey(0, $flexidata);
284
                    $this->assertArrayHasKey('id', $flexidata[0]);
285
                    $filtrered = $this->object->getFlexiData(null,
286
                        "id = ".$flexidata[0]['id']);
287
                    $this->assertArrayHasKey(0, $filtrered);
288
                    $this->assertArrayHasKey('id', $filtrered[0]);
289
                }
290
                break;
291
        }
292
    }
293
294
    /**
295
     * @covers FlexiPeeHP\FlexiBeeRO::loadFromFlexiBee
296
     */
297
    public function testLoadFromFlexiBee()
298
    {
299
        $this->object->loadFromFlexiBee();
300
        $this->object->loadFromFlexiBee(222);
301
    }
302
303
    /**
304
     * @covers FlexiPeeHP\FlexiBeeRO::jsonizeData
305
     */
306
    public function testJsonizeData()
307
    {
308
        $this->assertEquals('{"'.$this->object->nameSpace.'":{"@version":"1.0","'.$this->object->evidence.'":{"key":"value"}}}',
309
            $this->object->jsonizeData(['key' => 'value']));
310
        $this->object->setAction('copy');
311
        $this->assertEquals('{"'.$this->object->nameSpace.'":{"@version":"1.0","'.$this->object->evidence.'":{"key":"value"},"'.$this->object->evidence.'@action":"copy"}}',
312
            $this->object->jsonizeData(['key' => 'value']));
313
    }
314
315
    /**
316
     * @covers FlexiPeeHP\FlexiBeeRO::idExists
317
     */
318
    public function testIdExists()
319
    {
320
        // Remove the following lines when you implement this test.
321
        $this->markTestIncomplete(
322
            'This test has not been implemented yet.'
323
        );
324
    }
325
326
    /**
327
     * @covers FlexiPeeHP\FlexiBeeRO::recordExists
328
     */
329
    public function testRecordExists()
330
    {
331
        $evidence = $this->object->getEvidence();
332
333
        switch ($evidence) {
334
            case null:
335
            case 'c':
336
                $this->markTestSkipped('Unsupported evidence');
337
                break;
338
339
            default:
340
                $flexidata = $this->object->getFlexiData(null, ['limit' => 1]);
341
                if (is_array($flexidata) && !count($flexidata)) {
342
                    $this->markTestSkipped('Empty evidence');
343
                } else {
344
                    if (isset($flexidata['success']) && ($flexidata['success'] == 'false')) {
345
                        $this->markTestSkipped($flexidata['message']);
346
                    } else {
347
                        $this->object->setData(['id' => (int) $flexidata[0]['id']]);
348
                        $this->assertTrue($this->object->recordExists());
349
                        $this->assertFalse($this->object->recordExists(['id' => 0]));
350
                        $this->assertFalse($this->object->recordExists(['unexistent' => 1]));
351
                    }
352
                }
353
                break;
354
        }
355
    }
356
357
    /**
358
     * @covers FlexiPeeHP\FlexiBeeRO::getColumnsFromFlexibee
359
     */
360
    public function testGetColumnsFromFlexibee()
361
    {
362
        // Remove the following lines when you implement this test.
363
        $this->markTestIncomplete(
364
            'This test has not been implemented yet.'
365
        );
366
    }
367
368
    /**
369
     * @covers FlexiPeeHP\FlexiBeeRO::getKod
370
     */
371
    public function testGetKod()
372
    {
373
374
        $this->assertEquals('CODE',
375
            $this->object->getKod([$this->object->myKeyColumn => 'code']));
376
377
        $testString[$this->object->nameColumn] = 'Fish clamp -  Úchytka pro instalaci samonosných kabelů '
0 ignored issues
show
Coding Style Comprehensibility introduced by
$testString was never initialized. Although not strictly required by PHP, it is generally a good practice to add $testString = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
378
            .'(3.5 mm)';
379
        $code0                                 = $this->object->getKod($testString);
380
        $this->assertEquals('FISHCLAMPUCHYTKAPR', $code0);
381
        $code1                                 = $this->object->getKod($testString,
382
            false);
383
        $this->assertEquals('FISHCLAMPUCHYTKAPR', $code1);
384
        $code2                                 = $this->object->getKod($testString);
385
        $this->assertEquals('FISHCLAMPUCHYTKAPR1', $code2);
386
        $this->object->setData($testString);
387
        $code3                                 = $this->object->getKod();
388
        $this->assertEquals('FISHCLAMPUCHYTKAPR2', $code3);
389
390
        $this->assertEquals('TEST',
391
            $this->object->getKod([$this->object->nameColumn => 'test']));
392
393
        $this->assertEquals('TEST1', $this->object->getKod('test'));
394
395
        $this->assertEquals('TEST2', $this->object->getKod(['kod' => 'test']));
396
        $this->assertEquals('NOTSET', $this->object->getKod(['kod' => '']));
397
    }
398
399
    /**
400
     * @covers FlexiPeeHP\FlexiBeeRO::logResult
401
     */
402
    public function testLogResult()
403
    {
404
        $this->object->cleanMessages();
405
        $success = json_decode('{"winstrom":{"@version":"1.0","success":"true",'
406
            .'"stats":{"created":"0","updated":"1","deleted":"0","skipped":"0"'
407
            .',"failed":"0"},"results":[{"id":"1","request-id":"ext:SōkoMan.item'
408
            .':5271","ref":"/c/spoje_net_s_r_o_1/skladovy-pohyb/1.json"}]}}');
409
        $this->object->logResult(current($this->object->object2array($success)),
410
            'http://test');
411
412
        $this->assertArrayHasKey('info', $this->object->getStatusMessages(true));
413
414
        $error                          = json_decode('{"winstrom":{"@version":"1.0","success":"false",'
415
            .'"stats":{"created":"0","updated":"0","deleted":"0","skipped":"0"'
416
            .',"failed":"0"},"results":[{"errors":[{"message":"cz.winstrom.'
417
            .'service.WSBusinessException: Zadaný kód není unikátní.\nZadaný'
418
            .' kód není unikátní."}]}]}}');
419
        $this->object->lastResponseCode = 500;
420
        $this->object->logResult(current($this->object->object2array($error)));
421
        $this->assertArrayHasKey('error', $this->object->getStatusMessages(true));
422
    }
423
424
    /**
425
     * @covers FlexiPeeHP\FlexiBeeRO::flexiUrl
426
     */
427
    public function testFlexiUrl()
428
    {
429
        $this->assertEquals("a eq 1 and b eq 'foo'",
430
            $this->object->flexiUrl(['a' => 1, 'b' => 'foo'], 'and'));
431
        $this->assertEquals("a eq 1 or b eq 'bar'",
432
            $this->object->flexiUrl(['a' => 1, 'b' => 'bar'], 'or'));
433
        $this->assertEquals("a eq true or b eq false",
434
            $this->object->flexiUrl(['a' => true, 'b' => false], 'or'));
435
        $this->assertEquals("a is null and b is not null",
436
            $this->object->flexiUrl(['a' => null, 'b' => '!null'], 'and'));
437
    }
438
439
    /**
440
     * @covers FlexiPeeHP\FlexiBeeRO::unifyResponseFormat
441
     */
442
    public function testunifyResponseFormat()
443
    {
444
        $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...
445
        //One Row Test
446
        $test1raw = [$this->object->nameSpace =>
447
            [$this->object->getResponseEvidence() =>
448
                ['id' => 1, 'name' => 'value']
449
            ]
450
        ];
451
452
        $test1expected = [$this->object->getResponseEvidence() =>
453
            [
454
                ['id' => 1, 'name' => 'value']
455
            ]
456
        ];
457
458
        $this->assertEquals($test1expected,
459
            $this->object->unifyResponseFormat($test1raw));
460
461
        //Two Row Test
462
        $test2Raw      = [$this->object->nameSpace =>
463
            [$this->object->getResponseEvidence() =>
464
                [
465
                    ['id' => 1, 'name' => 'value'],
466
                    ['id' => 2, 'name' => 'value2']
467
                ]
468
            ]
469
        ];
470
        $test2expected = [$this->object->getResponseEvidence() =>
471
            [
472
                ['id' => 1, 'name' => 'value'],
473
                ['id' => 2, 'name' => 'value2']
474
            ]
475
        ];
476
477
        $this->assertEquals($test2expected,
478
            $this->object->unifyResponseFormat($test2Raw));
479
    }
480
481
    /**
482
     * @covers FlexiPeeHP\FlexiBeeRO::__toString
483
     */
484
    public function testtoString()
485
    {
486
487
        $identifer = 'ext:test:123';
488
        $this->object->setDataValue('id', $identifer);
489
        $this->assertEquals($identifer, (string) $this->object);
490
491
        $code = 'test';
492
        $this->object->setDataValue('kod', $code);
493
        $this->assertEquals('code:'.$code, (string) $this->object);
494
495
        $this->object->dataReset();
496
        $this->assertNull($this->object->__toString());
497
    }
498
499
    /**
500
     * @covers FlexiPeeHP\FlexiBeeRO::draw
501
     */
502
    public function testDraw($whatWant = NULL)
503
    {
504
        $this->object->setDataValue('kod', 'test');
505
        $this->assertEquals('code:test', $this->object->draw());
506
    }
507
}