FieldFactoryTest.php 943B

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 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. );
  22. $f = new FieldFactory();
  23. foreach ($mappings as $position => $class) {
  24. $this->assertSame($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. }