Example #1
0
 /**
  * Test for SunFunc
  */
 public function testSunFunc()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(1010101010, $locale);
     $date->setTimezone(date_default_timezone_get());
     $result = Zend_Date_Cities::City('vienna');
     $this->assertTrue(is_array($result));
     $result = $date->getSunset($result);
     $this->assertSame('2002-01-04T20:09:59+05:00', $result->get(Zend_Date::W3C));
     unset($result);
     $result = Zend_Date_Cities::City('vienna', 'civil');
     $this->assertTrue(is_array($result));
     $result = $date->getSunset($result);
     $this->assertSame('2002-01-04T20:09:20+05:00', $result->get(Zend_Date::W3C));
     unset($result);
     $result = Zend_Date_Cities::City('vienna', 'nautic');
     $this->assertTrue(is_array($result));
     $result = $date->getSunset($result);
     $this->assertSame('2002-01-04T20:08:34+05:00', $result->get(Zend_Date::W3C));
     unset($result);
     $result = Zend_Date_Cities::City('vienna', 'astronomic');
     $this->assertTrue(is_array($result));
     $result = $date->getSunset($result);
     $this->assertSame('2002-01-04T20:07:49+05:00', $result->get(Zend_Date::W3C));
     unset($result);
     $result = Zend_Date_Cities::City('BERLIN');
     $this->assertTrue(is_array($result));
     $result = $date->getSunrise($result);
     $this->assertSame('2002-01-04T12:21:21+05:00', $result->get(Zend_Date::W3C));
     unset($result);
     $result = Zend_Date_Cities::City('London');
     $this->assertTrue(is_array($result));
     $result = $date->getSunInfo($result);
     $this->assertSame('2002-01-04T13:10:10+05:00', $result['sunrise']['effective']->get(Zend_Date::W3C));
     $this->assertSame('2002-01-04T13:10:54+05:00', $result['sunrise']['civil']->get(Zend_Date::W3C));
     $this->assertSame('2002-01-04T13:11:45+05:00', $result['sunrise']['nautic']->get(Zend_Date::W3C));
     $this->assertSame('2002-01-04T13:12:35+05:00', $result['sunrise']['astronomic']->get(Zend_Date::W3C));
     $this->assertSame('2002-01-04T21:00:52+05:00', $result['sunset']['effective']->get(Zend_Date::W3C));
     $this->assertSame('2002-01-04T21:00:08+05:00', $result['sunset']['civil']->get(Zend_Date::W3C));
     $this->assertSame('2002-01-04T20:59:18+05:00', $result['sunset']['nautic']->get(Zend_Date::W3C));
     $this->assertSame('2002-01-04T20:58:28+05:00', $result['sunset']['astronomic']->get(Zend_Date::W3C));
     unset($result);
     $result = array('longitude' => 0);
     try {
         $result = $date->getSunrise($result);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     unset($result);
     $result = array('latitude' => 0);
     try {
         $result = $date->getSunrise($result);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     unset($result);
     $result = array('longitude' => 180.1, 'latitude' => 0);
     try {
         $result = $date->getSunrise($result);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     unset($result);
     $result = array('longitude' => -180.1, 'latitude' => 0);
     try {
         $result = $date->getSunrise($result);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     unset($result);
     $result = array('longitude' => 0, 'latitude' => 90.09999999999999);
     try {
         $result = $date->getSunrise($result);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     unset($result);
     $result = array('longitude' => 0, 'latitude' => -90.09999999999999);
     try {
         $result = $date->getSunrise($result);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     unset($result);
     $result = array('latitude' => 0, 'longitude' => 0);
     $result = $date->getSunInfo($result);
     $this->assertTrue(is_array($result));
     unset($result);
     $result = array('latitude' => 0, 'longitude' => 0);
     $result = $date->getSunrise($result);
     $this->assertTrue($result instanceof Zend_Date);
 }
Example #2
0
 /**
  * Test for SunFunc
  */
 public function testSunFunc()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(1010101010, $locale);
     $date->setTimezone(date_default_timezone_get());
     $result = Zend_Date_Cities::City('vienna');
     $this->assertTrue(is_array($result));
     $result = $date->getSunSet($result);
     $this->assertSame($result->get(Zend_Date::W3C), '2002-01-04T16:10:10+01:00');
     unset($result);
     $result = Zend_Date_Cities::City('vienna', 'civil');
     $this->assertTrue(is_array($result));
     $result = $date->getSunSet($result);
     $this->assertSame($result->get(Zend_Date::W3C), '2002-01-04T16:09:31+01:00');
     unset($result);
     $result = Zend_Date_Cities::City('vienna', 'nautic');
     $this->assertTrue(is_array($result));
     $result = $date->getSunSet($result);
     $this->assertSame($result->get(Zend_Date::W3C), '2002-01-04T16:08:45+01:00');
     unset($result);
     $result = Zend_Date_Cities::City('vienna', 'astronomic');
     $this->assertTrue(is_array($result));
     $result = $date->getSunSet($result);
     $this->assertSame($result->get(Zend_Date::W3C), '2002-01-04T16:08:00+01:00');
     unset($result);
     $result = Zend_Date_Cities::City('BERLIN');
     $this->assertTrue(is_array($result));
     $result = $date->getSunRise($result);
     $this->assertSame($result->get(Zend_Date::W3C), '2002-01-04T08:21:17+01:00');
     unset($result);
     $result = Zend_Date_Cities::City('London');
     $this->assertTrue(is_array($result));
     $result = $date->getSunInfo($result);
     $this->assertSame($result['sunrise']['effective']->get(Zend_Date::W3C), '2002-01-04T09:10:07+01:00');
     $this->assertSame($result['sunrise']['civil']->get(Zend_Date::W3C), '2002-01-04T09:10:51+01:00');
     $this->assertSame($result['sunrise']['nautic']->get(Zend_Date::W3C), '2002-01-04T09:11:42+01:00');
     $this->assertSame($result['sunrise']['astronomic']->get(Zend_Date::W3C), '2002-01-04T09:12:31+01:00');
     $this->assertSame($result['sunset']['effective']->get(Zend_Date::W3C), '2002-01-04T17:01:04+01:00');
     $this->assertSame($result['sunset']['civil']->get(Zend_Date::W3C), '2002-01-04T17:00:20+01:00');
     $this->assertSame($result['sunset']['nautic']->get(Zend_Date::W3C), '2002-01-04T16:59:30+01:00');
     $this->assertSame($result['sunset']['astronomic']->get(Zend_Date::W3C), '2002-01-04T16:58:40+01:00');
 }