RelativeTest::testSecondsUntilEndOfDay()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4286
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace HMLB\Date\Tests\Date;
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\Tests\AbstractTestCase;
16
17
class RelativeTest extends AbstractTestCase
18
{
19
    public function testSecondsSinceMidnight()
20
    {
21
        $d = Date::today()->addSeconds(30);
22
        $this->assertSame(30, $d->secondsSinceMidnight());
23
24
        $d = Date::today()->addDays(1);
25
        $this->assertSame(0, $d->secondsSinceMidnight());
26
27
        $d = Date::today()->addDays(1)->addSeconds(120);
28
        $this->assertSame(120, $d->secondsSinceMidnight());
29
30
        $d = Date::today()->addMonths(3)->addSeconds(42);
31
        $this->assertSame(42, $d->secondsSinceMidnight());
32
    }
33
34
    public function testSecondsUntilEndOfDay()
35
    {
36
        $d = Date::today()->endOfDay();
37
        $this->assertSame(0, $d->secondsUntilEndOfDay());
38
39
        $d = Date::today()->endOfDay()->subSeconds(60);
40
        $this->assertSame(60, $d->secondsUntilEndOfDay());
41
42
        $d = Date::create(2014, 10, 24, 12, 34, 56);
43
        $this->assertSame(41103, $d->secondsUntilEndOfDay());
44
45
        $d = Date::create(2014, 10, 24, 0, 0, 0);
46
        $this->assertSame(86399, $d->secondsUntilEndOfDay());
47
    }
48
}
49