Completed
Push — master ( a17b9a...3a4c95 )
by Andrii
01:54
created

ModifierTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * PHP Billing Library
4
 *
5
 * @link      https://github.com/hiqdev/php-billing
6
 * @package   php-billing
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\tests\unit\charge\FixedDiscountTest;
12
13
use hiqdev\php\billing\charge\modifiers\Modifier;
14
use hiqdev\php\billing\charge\modifiers\addons\Reason;
15
use hiqdev\php\billing\charge\modifiers\addons\Since;
16
use hiqdev\php\billing\charge\modifiers\addons\Till;
17
use DateTimeImmutable;
18
19
/**
20
 * @author Andrii Vasyliev <[email protected]>
21
 */
22
class ModifierTest extends \PHPUnit\Framework\TestCase
23
{
24
    protected $modifier;
25
26
    const SOME_TEXT = 'some text';
27
28
    protected function setUp()
29
    {
30
        parent::setUp();
31
        $this->now = new DateTimeImmutable();
32
        $this->modifier = new Modifier();
33
    }
34
35
    public function testAddons()
36
    {
37
        $this->modifier->reason(self::SOME_TEXT);
38
        $this->modifier->since($this->now);
39
        $this->modifier->till($this->now);
40
        $reason = $this->modifier->getReason();
41
        $since = $this->modifier->getSince();
42
        $till = $this->modifier->getTill();
43
        $this->assertInstanceOf(Reason::class, $reason);
44
        $this->assertInstanceOf(Since::class, $since);
45
        $this->assertInstanceOf(Till::class, $till);
46
        $this->assertSame(self::SOME_TEXT, $reason->getValue());
47
        $this->assertSame($this->now, $since->getValue());
48
        $this->assertSame($this->now, $till->getValue());
49
    }
50
}
51