You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

38 lines
915 B

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