1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SomeWork\Minjust\Tests\Unit\Entity; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use ReflectionObject; |
9
|
|
|
use SomeWork\Minjust\Entity\Lawyer; |
10
|
|
|
use SomeWork\Minjust\Entity\Location; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @covers \SomeWork\Minjust\Entity\Lawyer |
14
|
|
|
*/ |
15
|
|
|
class LawyerTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
public function testEmpty(): Lawyer |
18
|
|
|
{ |
19
|
|
|
$lawyer = new Lawyer(); |
20
|
|
|
$this->assertIsString($this->getPropertyValue($lawyer, 'fullName')); |
21
|
|
|
$this->assertIsString($this->getPropertyValue($lawyer, 'registerNumber')); |
22
|
|
|
$this->assertIsString($this->getPropertyValue($lawyer, 'certificateNumber')); |
23
|
|
|
$this->assertIsString($this->getPropertyValue($lawyer, 'status')); |
24
|
|
|
$this->assertIsString($this->getPropertyValue($lawyer, 'url')); |
25
|
|
|
$this->assertNull($this->getPropertyValue($lawyer, 'location')); |
26
|
|
|
|
27
|
|
|
return $lawyer; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
protected function getPropertyValue(object $object, string $property) |
31
|
|
|
{ |
32
|
|
|
$ref = new ReflectionObject($object); |
33
|
|
|
$property = $ref->getProperty($property); |
34
|
|
|
$property->setAccessible(true); |
35
|
|
|
|
36
|
|
|
return $property->getValue($object); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @depends testEmpty |
41
|
|
|
* |
42
|
|
|
* @param Lawyer $lawyer |
43
|
|
|
* |
44
|
|
|
* @return Lawyer |
45
|
|
|
*/ |
46
|
|
|
public function testSet(Lawyer $lawyer): Lawyer |
47
|
|
|
{ |
48
|
|
|
$location = (new Location()) |
49
|
|
|
->setId('testLocationId') |
50
|
|
|
->setName('testLocation'); |
51
|
|
|
|
52
|
|
|
$lawyer |
53
|
|
|
->setUrl('testUrl') |
54
|
|
|
->setFullName('testFullName') |
55
|
|
|
->setStatus('testStatus') |
56
|
|
|
->setRegisterNumber('testRegisterNumber') |
57
|
|
|
->setCertificateNumber('testCertificateNumber') |
58
|
|
|
->setLocation($location); |
59
|
|
|
|
60
|
|
|
$this->assertEquals('testUrl', $this->getPropertyValue($lawyer, 'url')); |
61
|
|
|
$this->assertEquals('testFullName', $this->getPropertyValue($lawyer, 'fullName')); |
62
|
|
|
$this->assertEquals('testStatus', $this->getPropertyValue($lawyer, 'status')); |
63
|
|
|
$this->assertEquals('testRegisterNumber', $this->getPropertyValue($lawyer, 'registerNumber')); |
64
|
|
|
$this->assertEquals('testCertificateNumber', $this->getPropertyValue($lawyer, 'certificateNumber')); |
65
|
|
|
$this->assertEquals($location, $this->getPropertyValue($lawyer, 'location')); |
66
|
|
|
|
67
|
|
|
return $lawyer; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @depends testSet |
72
|
|
|
* |
73
|
|
|
* @param Lawyer $lawyer |
74
|
|
|
*/ |
75
|
|
|
public function testGet(Lawyer $lawyer): void |
76
|
|
|
{ |
77
|
|
|
$this->assertEquals('testUrl', $lawyer->getUrl()); |
78
|
|
|
$this->assertEquals('testFullName', $lawyer->getFullName()); |
79
|
|
|
$this->assertEquals('testStatus', $lawyer->getStatus()); |
80
|
|
|
$this->assertEquals('testRegisterNumber', $lawyer->getRegisterNumber()); |
81
|
|
|
$this->assertEquals('testCertificateNumber', $lawyer->getCertificateNumber()); |
82
|
|
|
$this->assertEquals('testLocationId', $lawyer->getLocation()->getId()); |
83
|
|
|
$this->assertEquals('testLocation', $lawyer->getLocation()->getName()); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|