Passed
Pull Request — master (#99)
by
unknown
02:46
created

DateTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2
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-2020, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\tests\unit\charge\modifiers\addons;
12
13
use DateTimeImmutable;
14
use hiqdev\php\billing\charge\modifiers\addons\Date;
15
16
/**
17
 * @author Andrii Vasyliev <[email protected]>
18
 */
19
class DateTest extends \PHPUnit\Framework\TestCase
20
{
21
    protected $date;
22
    protected $year = '2018';
23
    protected $month = '11';
24
25
    protected function setUp(): void
26
    {
27
        $this->date = new DateTimeImmutable($this->year . '-' . $this->month . '-01');
28
    }
29
30
    public function testEnsureValidValue()
31
    {
32
        $year = $this->year;
33
        $month = $this->month;
34
        $this->assertEquals($this->date, Date::ensureValidValue("$year-$month"));
35
        $this->assertEquals($this->date, Date::ensureValidValue("$year-$month-01"));
36
        $this->assertEquals($this->date, Date::ensureValidValue("$month.$year"));
37
        $this->assertEquals($this->date, Date::ensureValidValue("1.$month.$year"));
38
    }
39
}
40