No Description

YearFieldTest.php 883B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Cron\Tests;
  3. use Cron\YearField;
  4. use DateTime;
  5. /**
  6. * @author Michael Dowling <mtdowling@gmail.com>
  7. */
  8. class YearFieldTest extends \PHPUnit_Framework_TestCase
  9. {
  10. /**
  11. * @covers Cron\YearField::validate
  12. */
  13. public function testValdatesField()
  14. {
  15. $f = new YearField();
  16. $this->assertTrue($f->validate('2011'));
  17. $this->assertTrue($f->validate('*'));
  18. $this->assertTrue($f->validate('*/10,2012,1-12'));
  19. }
  20. /**
  21. * @covers Cron\YearField::increment
  22. */
  23. public function testIncrementsDate()
  24. {
  25. $d = new DateTime('2011-03-15 11:15:00');
  26. $f = new YearField();
  27. $f->increment($d);
  28. $this->assertEquals('2012-01-01 00:00:00', $d->format('Y-m-d H:i:s'));
  29. $f->increment($d, true);
  30. $this->assertEquals('2011-12-31 23:59:00', $d->format('Y-m-d H:i:s'));
  31. }
  32. }