test_getAttributes_empty_array()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace ByTIC\DataObjects\Tests\Behaviors\WithAttributes;
4
5
use ByTIC\DataObjects\BaseDto;
6
use ByTIC\DataObjects\Tests\AbstractTest;
7
use ByTIC\DataObjects\Tests\Fixtures\Models\Books\Book;
8
9
/**
10
 * Class HasAttributesTraitTest
11
 * @package ByTIC\DataObjects\Tests\Behaviors\WithAttributes
12
 */
13
class HasAttributesTraitTest extends AbstractTest
14
{
15
    public function test_getAttributes_empty_array()
16
    {
17
        $object = new BaseDto();
18
        self::assertIsArray($object->getAttributes());
19
    }
20
21
    public function test_setAttribute()
22
    {
23
        $object = new BaseDto();
24
        self::assertFalse($object->hasAttribute('test'));
25
26
        $object->setAttribute('test', 'value');
27
        self::assertTrue($object->hasAttribute('test'));
28
        self::assertSame('value', $object->getAttribute('test'));
29
    }
30
31
    public function test_setAttribute_with_internal_property()
32
    {
33
        $object = new Book();
34
        self::assertFalse($object->hasAttribute('name'));
35
36
        $object->name = 'test';
37
        self::assertSame('Test', $object->getAttribute('name'));
38
        self::assertSame('Test', $object->name);
39
        self::assertSame('Test', $object->getName());
40
    }
41
}
42