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