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