HasAttributesTraitTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_setAttribute_with_internal_property() 0 9 1
A test_setAttribute() 0 8 1
A test_getAttributes_empty_array() 0 4 1
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