2015-02-08 07:00:15 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace DavidBadura\Taskwarrior\Test;
|
|
|
|
|
|
|
|
use DavidBadura\Taskwarrior\Recurring;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author David Badura <badura@simplethings.de>
|
|
|
|
*/
|
|
|
|
class RecurringTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
/**
|
2015-05-15 06:38:38 -05:00
|
|
|
* @see http://taskwarrior.org/docs/durations.html
|
2015-02-08 07:00:15 -06:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function validData()
|
|
|
|
{
|
|
|
|
return [
|
2015-05-15 06:38:38 -05:00
|
|
|
['5 seconds'],
|
|
|
|
['5 second'],
|
|
|
|
['5 secs'],
|
|
|
|
['5 sec'],
|
|
|
|
['5 s'],
|
|
|
|
['5seconds'],
|
|
|
|
['5second'],
|
|
|
|
['5secs'],
|
|
|
|
['5sec'],
|
|
|
|
['5s'],
|
|
|
|
['second'],
|
|
|
|
['sec'],
|
|
|
|
['5 minutes'],
|
|
|
|
['5 minute'],
|
|
|
|
['5 mins'],
|
|
|
|
['5 min'],
|
|
|
|
['5minutes'],
|
|
|
|
['5minute'],
|
|
|
|
['5mins'],
|
|
|
|
['5min'],
|
|
|
|
['minute'],
|
|
|
|
['min'],
|
|
|
|
['3 hours'],
|
|
|
|
['3 hour'],
|
|
|
|
['3 hrs'],
|
|
|
|
['3 hr'],
|
|
|
|
['3 h'],
|
|
|
|
['3hours'],
|
|
|
|
['3hour'],
|
|
|
|
['3hrs'],
|
|
|
|
['3hr'],
|
|
|
|
['3h'],
|
|
|
|
['hour'],
|
|
|
|
['hr'],
|
|
|
|
['2 days'],
|
|
|
|
['2 day'],
|
|
|
|
['2 d'],
|
|
|
|
['2days'],
|
|
|
|
['2day'],
|
|
|
|
['2d'],
|
2015-02-08 07:00:15 -06:00
|
|
|
['daily'],
|
2015-05-15 06:38:38 -05:00
|
|
|
['day'],
|
|
|
|
['3 weeks'],
|
|
|
|
['3 week'],
|
|
|
|
['3 wks'],
|
|
|
|
['3 wk'],
|
|
|
|
['3 w'],
|
|
|
|
['3weeks'],
|
|
|
|
['3week'],
|
|
|
|
['3wks'],
|
|
|
|
['3wk'],
|
|
|
|
['3w'],
|
2015-02-08 07:00:15 -06:00
|
|
|
['weekly'],
|
2015-05-15 06:38:38 -05:00
|
|
|
['week'],
|
|
|
|
['wk'],
|
|
|
|
['weekdays'],
|
|
|
|
['2 fortnight'],
|
|
|
|
['2 sennight'],
|
|
|
|
['2fortnight'],
|
|
|
|
['2sennight'],
|
2015-02-08 07:00:15 -06:00
|
|
|
['biweekly'],
|
2015-05-15 06:38:38 -05:00
|
|
|
['fortnight'],
|
|
|
|
['sennight'],
|
|
|
|
['5 months'],
|
|
|
|
['5 month'],
|
|
|
|
['5 mnths'],
|
|
|
|
['5 mths'],
|
|
|
|
['5 mth'],
|
|
|
|
['5 mo'],
|
|
|
|
['5 m'],
|
|
|
|
['5months'],
|
|
|
|
['5month'],
|
|
|
|
['5mnths'],
|
|
|
|
['5mths'],
|
|
|
|
['5mth'],
|
|
|
|
['5mo'],
|
|
|
|
['5m'],
|
|
|
|
['monthly'],
|
|
|
|
['month'],
|
|
|
|
['mth'],
|
|
|
|
['mo'],
|
|
|
|
['bimonthly'],
|
|
|
|
['1 quarterly'],
|
|
|
|
['1 quarters'],
|
|
|
|
['1 quarter'],
|
|
|
|
['1 qrtrs'],
|
|
|
|
['1 qrtr'],
|
|
|
|
['1 qtr'],
|
|
|
|
['1 q'],
|
|
|
|
['1quarterly'],
|
|
|
|
['1quarters'],
|
|
|
|
['1quarter'],
|
|
|
|
['1qrtrs'],
|
|
|
|
['1qrtr'],
|
|
|
|
['1qtr'],
|
|
|
|
['1q'],
|
2015-02-08 07:00:15 -06:00
|
|
|
['quarterly'],
|
2015-05-15 06:38:38 -05:00
|
|
|
['quarter'],
|
|
|
|
['qrtr'],
|
|
|
|
['qtr'],
|
2015-02-08 07:00:15 -06:00
|
|
|
['semiannual'],
|
2015-05-15 06:38:38 -05:00
|
|
|
['1 years'],
|
|
|
|
['1 year'],
|
|
|
|
['1 yrs'],
|
|
|
|
['1 yr'],
|
|
|
|
['1 y'],
|
|
|
|
['1years'],
|
|
|
|
['1year'],
|
|
|
|
['1yrs'],
|
|
|
|
['1yr'],
|
|
|
|
['1y'],
|
2015-02-08 07:00:15 -06:00
|
|
|
['annual'],
|
|
|
|
['yearly'],
|
2015-05-15 06:38:38 -05:00
|
|
|
['year'],
|
|
|
|
['yr'],
|
2015-02-08 07:00:15 -06:00
|
|
|
['biannual'],
|
2015-05-15 06:38:38 -05:00
|
|
|
['biyearly']
|
2015-02-08 07:00:15 -06:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider validData
|
|
|
|
* @param $recur
|
|
|
|
*/
|
|
|
|
public function testValid($recur)
|
|
|
|
{
|
|
|
|
$this->assertEquals($recur, (string)new Recurring($recur));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function invalidData()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
['dailya'],
|
|
|
|
['asdasd'],
|
|
|
|
['foo'],
|
|
|
|
['weekday'],
|
|
|
|
['2x'],
|
2015-05-15 06:38:38 -05:00
|
|
|
['a2w']
|
2015-02-08 07:00:15 -06:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider invalidData
|
|
|
|
* @param $recur
|
|
|
|
*/
|
|
|
|
public function testInvalid($recur)
|
|
|
|
{
|
2015-04-06 16:13:02 -05:00
|
|
|
$this->setExpectedException('DavidBadura\Taskwarrior\Exception\RecurringParseException');
|
2015-02-08 07:00:15 -06:00
|
|
|
|
2015-05-15 06:38:38 -05:00
|
|
|
new Recurring($recur);
|
2015-02-08 07:00:15 -06:00
|
|
|
}
|
|
|
|
}
|