Added unit test for cron validator
This commit is contained in:
parent
3d44665484
commit
efe703abda
|
@ -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
|
||||
|
|
37
tests/unit/Task/Validator/CronTest.php
Normal file
37
tests/unit/Task/Validator/CronTest.php
Normal 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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue