AddTest::testAddWithDiffInterval()   A
last analyzed

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.4286
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace HMLB\Date\Tests\Interval;
4
5
/*
6
 * This file is part of the Date package.
7
 *
8
 * (c) Hugues Maignol <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
use HMLB\Date\Date;
15
use HMLB\Date\Interval;
16
use HMLB\Date\Tests\AbstractTestCase;
17
18
class AddTest extends AbstractTestCase
19
{
20
    public function testAdd()
21
    {
22
        $ci = Interval::create(4, 3, 6, 7, 8, 10, 11)->add(Interval::createFromSpec('P2Y1M5DT22H33M44S'));
23
        $this->assertInterval($ci, 6, 4, 54, 30, 43, 55);
24
    }
25
26
    public function testAddWithDiffInterval()
27
    {
28
        $diff = Date::now()->diff(Date::now()->addWeeks(3));
29
        $ci = Interval::create(4, 3, 6, 7, 8, 10, 11)->add($diff);
30
        $this->assertInterval($ci, 4, 3, 70, 8, 10, 11);
31
    }
32
33
    public function testAddWithNegativeDiffInterval()
34
    {
35
        $diff = Date::now()->diff(Date::now()->subWeeks(3));
36
        $ci = Interval::create(4, 3, 6, 7, 8, 10, 11)->add($diff);
37
        $this->assertInterval($ci, 4, 3, 28, 8, 10, 11);
38
    }
39
}
40