]> git.mxchange.org Git - friendica-addons.git/blob - curweather/vendor/cmfcmf/openweathermap-php-api/tests/Util/SunTest.php
added composer.json and needed libs
[friendica-addons.git] / curweather / vendor / cmfcmf / openweathermap-php-api / tests / Util / SunTest.php
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\Sun;
18
19 class SunTest extends \PHPUnit_Framework_TestCase
20 {
21     /**
22      * @var Sun
23      */
24     private $sun;
25
26     public function testSunRise()
27     {
28         $rise = new \DateTime('2014-01-01 08:00:00');
29         $set = new \DateTime('2014-01-01 20:00:00');
30
31         $this->givenThereIsASunObject($rise, $set);
32
33         $this->assertSame($rise, $this->sun->rise);
34     }
35
36     public function testSunSet()
37     {
38         $rise = new \DateTime('2014-01-01 08:00:00');
39         $set = new \DateTime('2014-01-01 20:00:00');
40
41         $this->givenThereIsASunObject($rise, $set);
42
43         $this->assertSame($set, $this->sun->set);
44     }
45
46
47     private function givenThereIsASunObject($rise, $set)
48     {
49         $this->sun = new Sun($rise, $set);
50     }
51
52     /**
53      * @expectedException \LogicException
54      */
55     public function testSunSetBeforeSunRiseException()
56     {
57         $rise = new \DateTime('2014-01-01 08:00:00');
58         $set = new \DateTime('2014-01-01 7:00:00');
59
60         $this->givenThereIsASunObject($rise, $set);
61     }
62 }