|
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
|
|
|
|