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

DateTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testEnsureValidValue() 0 9 1
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