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