Completed
Push — master ( f0c93a...888950 )
by Andrii
05:26
created

DateTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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\modifiers\addons\DateTestCase;
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()
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