No Description

HoursFieldTest.php 916B

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