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\LawFormation; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @covers \SomeWork\Minjust\Entity\LawFormation |
13
|
|
|
* @coversDefaultClass LawFormation |
14
|
|
|
*/ |
15
|
|
|
class LawFormationTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
public function testEmpty(): LawFormation |
18
|
|
|
{ |
19
|
|
|
$lawFormation = new LawFormation(); |
20
|
|
|
|
21
|
|
|
$this->assertIsString($this->getPropertyValue($lawFormation, 'organizationalForm')); |
22
|
|
|
$this->assertIsString($this->getPropertyValue($lawFormation, 'name')); |
23
|
|
|
$this->assertIsString($this->getPropertyValue($lawFormation, 'address')); |
24
|
|
|
$this->assertIsString($this->getPropertyValue($lawFormation, 'phone')); |
25
|
|
|
$this->assertIsString($this->getPropertyValue($lawFormation, 'email')); |
26
|
|
|
|
27
|
|
|
return $lawFormation; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
protected function getPropertyValue(object $object, string $property) |
31
|
|
|
{ |
32
|
|
|
$ref = new ReflectionObject($object); |
33
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */ |
34
|
|
|
$property = $ref->getProperty($property); |
35
|
|
|
$property->setAccessible(true); |
36
|
|
|
|
37
|
|
|
return $property->getValue($object); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @depends testEmpty |
42
|
|
|
* |
43
|
|
|
* @param LawFormation $lawFormation |
44
|
|
|
* |
45
|
|
|
* @return LawFormation |
46
|
|
|
*/ |
47
|
|
|
public function testSet(LawFormation $lawFormation): LawFormation |
48
|
|
|
{ |
49
|
|
|
$lawFormation |
50
|
|
|
->setName('testName') |
51
|
|
|
->setEmail('testEmail') |
52
|
|
|
->setAddress('testAddress') |
53
|
|
|
->setPhone('testPhone') |
54
|
|
|
->setOrganizationalForm('testOrganizationalForm'); |
55
|
|
|
|
56
|
|
|
$this->assertEquals('testName', $this->getPropertyValue($lawFormation, 'name')); |
57
|
|
|
$this->assertEquals('testEmail', $this->getPropertyValue($lawFormation, 'email')); |
58
|
|
|
$this->assertEquals('testAddress', $this->getPropertyValue($lawFormation, 'address')); |
59
|
|
|
$this->assertEquals('testPhone', $this->getPropertyValue($lawFormation, 'phone')); |
60
|
|
|
$this->assertEquals('testOrganizationalForm', $this->getPropertyValue($lawFormation, 'organizationalForm')); |
61
|
|
|
|
62
|
|
|
return $lawFormation; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @depends testSet |
67
|
|
|
* |
68
|
|
|
* @param LawFormation $lawFormation |
69
|
|
|
*/ |
70
|
|
|
public function testGet(LawFormation $lawFormation): void |
71
|
|
|
{ |
72
|
|
|
$this->assertEquals('testName', $lawFormation->getName()); |
73
|
|
|
$this->assertEquals('testEmail', $lawFormation->getEmail()); |
74
|
|
|
$this->assertEquals('testAddress', $lawFormation->getAddress()); |
75
|
|
|
$this->assertEquals('testPhone', $lawFormation->getPhone()); |
76
|
|
|
$this->assertEquals('testOrganizationalForm', $lawFormation->getOrganizationalForm()); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|