RelativeTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSecondsSinceMidnight() 0 14 1
A testSecondsUntilEndOfDay() 0 14 1
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