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

RecordTraitTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 5
eloc 28
c 2
b 1
f 1
dl 0
loc 56
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetPropertyWithoutValue() 0 9 1
A setUp() 0 7 1
A testUpdateSmartProperty() 0 8 1
A test_getProperty_EmptyValue() 0 5 1
A testGetStatusWithValue() 0 12 1
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