Пример #1
0
 /**
  * Test for setTimezone()
  */
 public function testSetTimezone()
 {
     $date = new Zend_Date_DateObjectTestHelper(0);
     date_default_timezone_set('Europe/Vienna');
     $this->assertTrue($date->setTimezone('Indian/Maldives'));
     $this->assertSame($date->getTimezone(), 'Indian/Maldives');
     try {
         $this->assertFalse($date->setTimezone('Unknown'));
         $this->fail("exception expected");
     } catch (Zend_Date_Exception $e) {
         $this->assertRegexp('/not a known timezone/i', $e->getMessage());
         $this->assertSame($e->getOperand(), 'Unknown');
     }
     $this->assertSame($date->getTimezone(), 'Indian/Maldives');
     $this->assertTrue($date->setTimezone());
     $this->assertSame($date->getTimezone(), 'Europe/Vienna');
 }
Пример #2
0
 /**
  * Test for setTimezone()
  */
 public function testSetTimezone()
 {
     $date = new Zend_Date_DateObjectTestHelper(0);
     date_default_timezone_set('Europe/Vienna');
     $date->setTimezone('Indian/Maldives');
     $this->assertSame('Indian/Maldives', $date->getTimezone());
     try {
         $date->setTimezone('Unknown');
         // without new phpdate false timezones do not throw an exception !
         // known and expected behaviour
         if (function_exists('timezone_open')) {
             $this->fail("exception expected");
         }
     } catch (Zend_Date_Exception $e) {
         $this->assertRegexp('/not a known timezone/i', $e->getMessage());
         $this->assertSame('Unknown', $e->getOperand());
     }
     $this->assertSame('Indian/Maldives', $date->getTimezone());
     $date->setTimezone();
     $this->assertSame('Europe/Vienna', $date->getTimezone());
 }
Пример #3
0
 /**
  * Test for setTimezone()
  */
 public function testSetTimezone()
 {
     $date = new Zend_Date_DateObjectTestHelper(0);
     date_default_timezone_set('Europe/Vienna');
     $this->assertTrue($date->setTimezone('Indian/Maldives'));
     $this->assertSame($date->getTimezone(), 'Indian/Maldives');
     $this->assertFalse($date->setTimezone('Unknown'));
     $this->assertSame($date->getTimezone(), 'Indian/Maldives');
     $this->assertTrue($date->setTimezone());
     $this->assertSame($date->getTimezone(), 'Europe/Vienna');
 }