mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-01 12:48:08 +09:00
* Various additional tests * Fixes * More fixes * Fixed my other mistakes * Final fix
36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use APIHelper\Request;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class CronAdminTest extends TestCase
|
|
{
|
|
public function testDoesCronWork(): void
|
|
{
|
|
// Get when cron was last run
|
|
$response = Request::makeRequest('admin/cron/info');
|
|
$this->assertTrue($response->wasSuccessful(), $response->generatePHPUnitMessage());
|
|
if (!empty($response->getResult()['last_cron_exec'])) {
|
|
$firstDate = new DateTime($response->getResult()['last_cron_exec']);
|
|
} else {
|
|
// Cron didn't have a last execution set, so let's just make up that it was an hour ago
|
|
$firstDate = new DateTime();
|
|
$firstDate->modify('-1 hour');
|
|
}
|
|
|
|
// Then run it
|
|
$response = Request::makeRequest('admin/cron/run');
|
|
$this->assertTrue($response->wasSuccessful(), $response->generatePHPUnitMessage());
|
|
|
|
// Validate the last run date was moved up
|
|
$response = Request::makeRequest('admin/cron/info');
|
|
$this->assertTrue($response->wasSuccessful(), $response->generatePHPUnitMessage());
|
|
$this->assertNotEmpty($response->getResult()['last_cron_exec']);
|
|
|
|
$newDate = new DateTime($response->getResult()['last_cron_exec']);
|
|
$this->assertGreaterThan($firstDate, $newDate, "Cron's last execution time was not incremented");
|
|
}
|
|
}
|