Passed
Push — master ( 4f7192...bd6c0b )
by Gabriel
03:33
created

RecordTraitTest::testGetStatusWithValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 12
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ByTIC\Models\SmartProperties\Tests\RecordsTraits\HasSmartProperties;
4
5
use ByTIC\Models\SmartProperties\Properties\AbstractProperty\Generic;
6
use ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\HasSmartProperties\Record;
7
use ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\HasSmartProperties\Records;
8
use ByTIC\Models\SmartProperties\Tests\AbstractTest;
9
use ByTIC\Models\SmartProperties\Tests\Fixtures\RecordsTraits\HasSmartProperties\RegistrationStatuses\Unregistered;
10
11
/**
12
 * Class TraitsTest
13
 * @package ByTIC\Common\Tests\Payments\Methods
14
 */
15
class RecordTraitTest extends AbstractTest
16
{
17
    /**
18
     * @var Record
19
     */
20
    private $object;
21
22
    public function testGetPropertyWithoutValue()
23
    {
24
        $status = $this->object->getSmartProperty('Status');
25
        self::assertInstanceOf(Generic::class, $status);
26
        self::assertSame('allocated', $status->getName());
27
28
        $registrationStatus = $this->object->getSmartProperty('RegistrationStatus');
29
        self::assertInstanceOf(Generic::class, $registrationStatus);
30
        self::assertSame('unregistered', $registrationStatus->getName());
31
    }
32
33
    public function test_getProperty_EmptyValue()
34
    {
35
        $this->object->registration_status = '';
36
        $registrationStatus = $this->object->getSmartProperty('RegistrationStatus');
37
        self::assertInstanceOf(Unregistered::class, $registrationStatus);
38
    }
39
40
    public function testGetStatusWithValue()
41
    {
42
        $this->object->status = 'applicant';
43
        $this->object->registration_status = 'unpaid';
44
45
        $status = $this->object->getSmartProperty('Status');
46
        self::assertInstanceOf(Generic::class, $status);
47
        self::assertSame('applicant', $status->getName());
48
49
        $registrationStatus = $this->object->getSmartProperty('RegistrationStatus');
50
        self::assertInstanceOf(Generic::class, $registrationStatus);
51
        self::assertSame('unpaid', $registrationStatus->getName());
52
    }
53
54
    public function testUpdateSmartProperty()
55
    {
56
        $this->object->status = 'applicant';
57
58
        self::assertSame('applicant', $this->object->getSmartProperty('Status')->getName());
59
        $this->object->updateSmartProperty('Status', 'allocated');
60
        self::assertSame('allocated', $this->object->status);
61
        self::assertSame('allocated', $this->object->getSmartProperty('Status')->getName());
62
    }
63
64
    protected function setUp(): void
65
    {
66
        parent::setUp();
67
        $this->object = new Record();
68
69
        $manager = new Records();
70
        $this->object->setManager($manager);
71
    }
72
}
73