Completed
Push — uv-index ( 4bbf1d...62e649 )
by Christian
02:11
created

TimeTest::testFromTo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 18
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 14
nc 1
nop 0
1
<?php
2
/**
3
 * Copyright Zikula Foundation 2014 - Zikula Application Framework
4
 *
5
 * This work is contributed to the Zikula Foundation under one or more
6
 * Contributor Agreements and licensed to You under the following license:
7
 *
8
 * @license GNU/LGPv3 (or at your option any later version).
9
 * @package OpenWeatherMap-PHP-Api
10
 *
11
 * Please see the NOTICE file distributed with this source code for further
12
 * information regarding copyright and licensing.
13
 */
14
15
namespace Cmfcmf\OpenWeatherMap\Tests\Util;
16
17
use Cmfcmf\OpenWeatherMap\Util\Time;
18
19
class TimeTest extends \PHPUnit_Framework_TestCase
20
{
21
    public function testFromTo()
22
    {
23
        $fromS = '2014-01-01 08:00:00';
24
        $toS = '2014-01-01 20:00:00';
25
        $from = new \DateTime($fromS);
26
        $to = new \DateTime($toS);
27
        $day = new \DateTime('2014-01-01');
28
29
        $time = new Time($from, $to);
30
        $this->assertSame($from->format('c'), $time->from->format('c'));
31
        $this->assertSame($to->format('c'), $time->to->format('c'));
32
        $this->assertSame($day->format('c'), $time->day->format('c'));
33
34
        $time = new Time($fromS, $toS);
35
        $this->assertSame($from->format('c'), $time->from->format('c'));
36
        $this->assertSame($to->format('c'), $time->to->format('c'));
37
        $this->assertSame($day->format('c'), $time->day->format('c'));
38
    }
39
    public function testFrom()
40
    {
41
        $fromS = '2014-01-01 00:00:00';
42
        $from = new \DateTime($fromS);
43
        $day = new \DateTime('2014-01-01');
44
        $to = new \DateTime('2014-01-01 23:59:59');
45
46
        $time = new Time($from);
47
        $this->assertSame($from->format('c'), $time->from->format('c'));
48
        $this->assertSame($to->format('c'), $time->to->format('c'));
49
        $this->assertSame($day->format('c'), $time->day->format('c'));
50
51
        $time = new Time($fromS);
52
        $this->assertSame($from->format('c'), $time->from->format('c'));
53
        $this->assertSame($to->format('c'), $time->to->format('c'));
54
        $this->assertSame($day->format('c'), $time->day->format('c'));
55
    }
56
}
57