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
|
|
|
|