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

LocationTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 47
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmpty() 0 7 1
A testSet() 0 9 1
A getPropertyValue() 0 7 1
A testGet() 0 4 1
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