No Description

DayOfMonthFieldTest.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Cron\Tests;
  3. use Cron\DayOfMonthField;
  4. use DateTime;
  5. /**
  6. * @author Michael Dowling <mtdowling@gmail.com>
  7. */
  8. class DayOfMonthFieldTest extends \PHPUnit_Framework_TestCase
  9. {
  10. /**
  11. * @covers Cron\DayOfMonthField::validate
  12. */
  13. public function testValdatesField()
  14. {
  15. $f = new DayOfMonthField();
  16. $this->assertTrue($f->validate('1'));
  17. $this->assertTrue($f->validate('*'));
  18. $this->assertTrue($f->validate('*/3,1,1-12'));
  19. $this->assertTrue($f->validate('5W,L'));
  20. $this->assertFalse($f->validate('1.'));
  21. }
  22. /**
  23. * @covers Cron\DayOfMonthField::isSatisfiedBy
  24. */
  25. public function testChecksIfSatisfied()
  26. {
  27. $f = new DayOfMonthField();
  28. $this->assertTrue($f->isSatisfiedBy(new DateTime(), '?'));
  29. }
  30. /**
  31. * @covers Cron\DayOfMonthField::increment
  32. */
  33. public function testIncrementsDate()
  34. {
  35. $d = new DateTime('2011-03-15 11:15:00');
  36. $f = new DayOfMonthField();
  37. $f->increment($d);
  38. $this->assertEquals('2011-03-16 00:00:00', $d->format('Y-m-d H:i:s'));
  39. $d = new DateTime('2011-03-15 11:15:00');
  40. $f->increment($d, true);
  41. $this->assertEquals('2011-03-14 23:59:00', $d->format('Y-m-d H:i:s'));
  42. }
  43. }