FieldFactoryTest.php 995 B

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