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