1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ByTIC\Models\SmartProperties\Tests\RecordsTraits\HasStatus; |
4
|
|
|
|
5
|
|
|
use ByTIC\Models\SmartProperties\Properties\AbstractProperty\Generic; |
6
|
|
|
use ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\HasStatus\Record; |
7
|
|
|
use ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\HasStatus\Records; |
8
|
|
|
use ByTIC\Models\SmartProperties\Tests\AbstractTest; |
9
|
|
|
use ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\HasStatus\Statuses\Allocated; |
10
|
|
|
use ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\HasStatus\Statuses\Applicant; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class TraitsTest |
14
|
|
|
* @package ByTIC\Models\SmartProperties\Tests\RecordsTraits\HasStatus |
15
|
|
|
*/ |
16
|
|
|
class RecordTraitTest extends AbstractTest |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var Record |
20
|
|
|
*/ |
21
|
|
|
private $object; |
22
|
|
|
|
23
|
|
|
public function testGetStatusWithoutValue() |
24
|
|
|
{ |
25
|
|
|
$status = $this->object->getStatus(); |
26
|
|
|
self::assertInstanceOf(Generic::class, $status); |
27
|
|
|
self::assertSame('allocated', $status->getName()); |
28
|
|
|
|
29
|
|
|
$data = $this->object->toArray(); |
30
|
|
|
self::assertSame('allocated', $data['status']); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testGetStatusWithValue() |
34
|
|
|
{ |
35
|
|
|
$this->object->status = 'applicant'; |
36
|
|
|
|
37
|
|
|
$status = $this->object->getStatus(); |
38
|
|
|
self::assertInstanceOf(Generic::class, $status); |
39
|
|
|
self::assertSame('applicant', $status->getName()); |
40
|
|
|
|
41
|
|
|
$data = $this->object->toArray(); |
42
|
|
|
self::assertSame('applicant', $data['status']); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param $status |
47
|
|
|
* @param $check |
48
|
|
|
* @param $result |
49
|
|
|
* @dataProvider data_isInStatus |
50
|
|
|
*/ |
51
|
|
|
public function test_isInStatus($status, $check, $result) |
52
|
|
|
{ |
53
|
|
|
$this->object->status = $status; |
54
|
|
|
self::assertSame($result, $this->object->isInStatus($check)); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function data_isInStatus() |
58
|
|
|
{ |
59
|
|
|
return [ |
60
|
|
|
['applicant', 'applicant', true], |
61
|
|
|
[Allocated::NAME, Allocated::class, true], |
62
|
|
|
[Applicant::NAME, Allocated::class, false], |
63
|
|
|
[Allocated::NAME, [Applicant::class, Allocated::NAME], true], |
64
|
|
|
]; |
65
|
|
|
} |
66
|
|
|
protected function setUp(): void |
67
|
|
|
{ |
68
|
|
|
parent::setUp(); |
69
|
|
|
|
70
|
|
|
$this->object = \Mockery::mock(Record::class)->makePartial(); |
|
|
|
|
71
|
|
|
|
72
|
|
|
$manager = new Records(); |
73
|
|
|
$this->object->shouldReceive('getManager')->andReturn($manager); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..