|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ByTIC\Models\SmartProperties\Tests\RecordsTraits\HasSmartProperties; |
|
4
|
|
|
|
|
5
|
|
|
use ByTIC\Models\SmartProperties\Definitions\Definition; |
|
6
|
|
|
use ByTIC\Models\SmartProperties\Tests\AbstractTest; |
|
7
|
|
|
use ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\HasSmartProperties\Records; |
|
8
|
|
|
use ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\HasSmartProperties\RegistrationStatuses\FreeConfirmed; |
|
9
|
|
|
use ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\HasSmartProperties\RegistrationStatuses\Unpaid; |
|
10
|
|
|
use ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\HasSmartProperties\Statuses\Allocated; |
|
11
|
|
|
use ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\HasSmartProperties\Statuses\Applicant; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class TraitsTest |
|
15
|
|
|
* @package ByTIC\Common\Tests\Payments\Methods |
|
16
|
|
|
*/ |
|
17
|
|
|
class RecordsTraitTest extends AbstractTest |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var Records |
|
21
|
|
|
*/ |
|
22
|
|
|
private $object; |
|
23
|
|
|
|
|
24
|
|
|
public function testGetSmartPropertiesDefinitions() |
|
25
|
|
|
{ |
|
26
|
|
|
$definitions = $this->object->getSmartPropertiesDefinitions(); |
|
27
|
|
|
self::assertCount(3, $definitions); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function testGetSmartPropertyDefinition() |
|
31
|
|
|
{ |
|
32
|
|
|
/** @var Definition $statusDefinition */ |
|
33
|
|
|
$statusDefinition = $this->object->getSmartPropertyDefinition('Status'); |
|
34
|
|
|
self::assertInstanceOf(Definition::class, $statusDefinition); |
|
35
|
|
|
self::assertSame('Status', $statusDefinition->getName()); |
|
36
|
|
|
self::assertSame('status', $statusDefinition->getField()); |
|
37
|
|
|
self::assertSame('Statuses', $statusDefinition->getLabel()); |
|
38
|
|
|
|
|
39
|
|
|
/** @var Definition $statusDefinition */ |
|
40
|
|
|
$statusDefinition = $this->object->getSmartPropertyDefinition('RegistrationStatus'); |
|
41
|
|
|
self::assertInstanceOf(Definition::class, $statusDefinition); |
|
42
|
|
|
self::assertSame('RegistrationStatus', $statusDefinition->getName()); |
|
43
|
|
|
self::assertSame('registration_status', $statusDefinition->getField()); |
|
44
|
|
|
self::assertSame('RegistrationStatuses', $statusDefinition->getLabel()); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function testGetSmartPropertyItems() |
|
48
|
|
|
{ |
|
49
|
|
|
$statuses = $this->object->getSmartPropertyItems('Status'); |
|
50
|
|
|
self::assertCount(2, $statuses); |
|
51
|
|
|
self::assertInstanceOf(Allocated::class, $statuses['allocated']); |
|
52
|
|
|
self::assertInstanceOf(Applicant::class, $statuses['applicant']); |
|
53
|
|
|
|
|
54
|
|
|
$statuses = $this->object->getSmartPropertyItems('RegistrationStatus'); |
|
55
|
|
|
self::assertCount(4, $statuses); |
|
56
|
|
|
self::assertInstanceOf(FreeConfirmed::class, $statuses['free_confirmed']); |
|
57
|
|
|
self::assertInstanceOf(Unpaid::class, $statuses['unpaid']); |
|
58
|
|
|
|
|
59
|
|
|
$statuses = $this->object->getSmartPropertyItems('MultiStatus'); |
|
60
|
|
|
self::assertCount(6, $statuses); |
|
61
|
|
|
self::assertInstanceOf(FreeConfirmed::class, $statuses['free_confirmed']); |
|
62
|
|
|
self::assertInstanceOf(Allocated::class, $statuses['allocated']); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function testGetSmartPropertyValues() |
|
66
|
|
|
{ |
|
67
|
|
|
$values = $this->object->getSmartPropertyValues('Status', 'name'); |
|
68
|
|
|
self::assertSame(['allocated', 'applicant'], $values); |
|
69
|
|
|
|
|
70
|
|
|
$values = $this->object->getSmartPropertyValues('RegistrationStatus', 'name'); |
|
71
|
|
|
self::assertEqualsCanonicalizing(['free_confirmed', 'paid_confirmed', 'unregistered', 'unpaid'], $values); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function testGetSmartPropertyItem() |
|
75
|
|
|
{ |
|
76
|
|
|
$status = $this->object->getSmartPropertyItem('Status', 'allocated'); |
|
77
|
|
|
self::assertInstanceOf(Allocated::class, $status); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function test_registerSmartProperty() |
|
81
|
|
|
{ |
|
82
|
|
|
$field = new \ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\PdfLetters\Record(); |
|
83
|
|
|
$field->field = 'relay'; |
|
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
self::assertInstanceOf( |
|
86
|
|
|
\ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\PdfLetters\Types\Relay::class, |
|
87
|
|
|
$field->getType() |
|
88
|
|
|
); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
protected function setUp(): void |
|
93
|
|
|
{ |
|
94
|
|
|
parent::setUp(); |
|
95
|
|
|
$this->object = new Records(); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|