1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

Added unit test for cron validator

This commit is contained in:
Eldad Fux 2019-12-26 12:20:09 +02:00
parent 3d44665484
commit efe703abda
2 changed files with 38 additions and 2 deletions

View file

@ -2,12 +2,11 @@
namespace Appwrite\Tests;
use Exception;
use Utopia\Request;
use Event\Event;
use PHPUnit\Framework\TestCase;
class LocaleTest extends TestCase
class EventTest extends TestCase
{
/**
* @var Event

View file

@ -0,0 +1,37 @@
<?php
namespace Appwrite\Tests;
use Task\Validator\Cron;
use PHPUnit\Framework\TestCase;
class CronTest extends TestCase
{
/**
* @var Cron
*/
protected $object = null;
public function setUp()
{
$this->object = new Cron();
}
public function tearDown()
{
}
public function testValues()
{
$this->assertEquals($this->object->isValid('0 2 * * *'), true); // execute at 2am daily
$this->assertEquals($this->object->isValid('0 5,17 * * *'), true); // execute twice a day
$this->assertEquals($this->object->isValid('* * * * *'), true); // execute on every minutes
// $this->assertEquals($this->object->isValid('0 17 * * sun'), true); // execute on every Sunday at 5 PM
$this->assertEquals($this->object->isValid('*/10 * * * *'), true); // execute on every 10 minutes
// $this->assertEquals($this->object->isValid('* * * jan,may,aug *'), true); // execute on selected months
// $this->assertEquals($this->object->isValid('0 17 * * sun,fri'), true); // execute on selected days
// $this->assertEquals($this->object->isValid('0 2 * * sun'), true); // execute on first sunday of every month
$this->assertEquals($this->object->isValid('0 */4 * * *'), true); // execute on every four hours
// $this->assertEquals($this->object->isValid('0 4,17 * * sun,mon'), true); // execute twice on every Sunday and Monday
}
}