Passed
Push — master ( fe8c79...c4382a )
by Igor
04:34
created

LocationTest::testSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 9
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace SomeWork\Minjust\Tests\Unit\Entity;
4
5
use PHPUnit\Framework\TestCase;
6
use ReflectionObject;
7
use SomeWork\Minjust\Entity\Location;
8
9
class LocationTest extends TestCase
10
{
11
    public function testEmpty(): Location
12
    {
13
        $location = new Location();
14
        $this->assertIsString($this->getPropertyValue($location, 'id'));
15
        $this->assertIsString($this->getPropertyValue($location, 'name'));
16
17
        return $location;
18
    }
19
20
    protected function getPropertyValue(object $object, string $property)
21
    {
22
        $ref = new ReflectionObject($object);
23
        $property = $ref->getProperty($property);
24
        $property->setAccessible(true);
25
26
        return $property->getValue($object);
27
    }
28
29
    /**
30
     * @depends testEmpty
31
     *
32
     * @param Location $location
33
     *
34
     * @return Location
35
     */
36
    public function testSet(Location $location): Location
37
    {
38
        $location->setId('444555');
39
        $location->setName('666777');
40
41
        $this->assertEquals('444555', $this->getPropertyValue($location, 'id'));
42
        $this->assertEquals('666777', $this->getPropertyValue($location, 'name'));
43
44
        return $location;
45
    }
46
47
    /**
48
     * @depends testSet
49
     *
50
     * @param Location $location
51
     */
52
    public function testGet(Location $location): void
53
    {
54
        $this->assertEquals('444555', $location->getId());
55
        $this->assertEquals('666777', $location->getName());
56
    }
57
}
58