No Description

FieldFactoryTest.php 964B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Cron\Tests;
  3. use Cron\FieldFactory;
  4. /**
  5. * @author Michael Dowling <mtdowling@gmail.com>
  6. */
  7. class FieldFactoryTest extends \PHPUnit_Framework_TestCase
  8. {
  9. /**
  10. * @covers Cron\FieldFactory::getField
  11. */
  12. public function testRetrievesFieldInstances()
  13. {
  14. $mappings = array(
  15. 0 => 'Cron\MinutesField',
  16. 1 => 'Cron\HoursField',
  17. 2 => 'Cron\DayOfMonthField',
  18. 3 => 'Cron\MonthField',
  19. 4 => 'Cron\DayOfWeekField',
  20. 5 => 'Cron\YearField'
  21. );
  22. $f = new FieldFactory();
  23. foreach ($mappings as $position => $class) {
  24. $this->assertEquals($class, get_class($f->getField($position)));
  25. }
  26. }
  27. /**
  28. * @covers Cron\FieldFactory::getField
  29. * @expectedException InvalidArgumentException
  30. */
  31. public function testValidatesFieldPosition()
  32. {
  33. $f = new FieldFactory();
  34. $f->getField(-1);
  35. }
  36. }