| 1 | <?php |
||
| 17 | * Class AbstractScheduledTest. |
||
| 18 | */ |
||
| 19 | class AbstractScheduledTest extends \PHPUnit_Framework_TestCase |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var AbstractScheduled |
||
| 23 | */ |
||
| 24 | protected $watcher; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * {@inheritdoc} |
||
| 28 | */ |
||
| 29 | public function setUp() |
||
| 30 | { |
||
| 31 | $this->watcher = $this->getMockForAbstractClass(AbstractScheduled::class); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @expectedException \InvalidArgumentException |
||
| 36 | */ |
||
| 37 | public function testBadTimeZoneName() |
||
| 38 | { |
||
| 39 | $this->watcher->setTimeZone('World/Unknown'); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @expectedException \InvalidArgumentException |
||
| 44 | */ |
||
| 45 | public function testBadTimeZoneOffset() |
||
| 46 | { |
||
| 47 | $this->watcher->setTimeZone(158622); |
||
| 48 | } |
||
| 49 | |||
| 50 | public function testTimeZone() |
||
| 51 | { |
||
| 52 | self::assertEquals( |
||
| 53 | (new \DateTimeZone(date_default_timezone_get()))->getName(), |
||
| 54 | $this->watcher->getTimeZone()->getName() |
||
| 55 | ); |
||
| 56 | |||
| 57 | $this->watcher->setTimeZone(1); |
||
| 58 | self::assertEquals('Europe/London', $this->watcher->getTimeZone()->getName()); |
||
| 59 | |||
| 60 | $this->watcher->setTimeZone('Europe/Madrid'); |
||
| 61 | self::assertEquals('Europe/Madrid', $this->watcher->getTimeZone()->getName()); |
||
| 62 | } |
||
| 64 |