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