mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-01 21:02:54 +09:00
* Wrote a few more tests, improvements * Ran Rector & PHP-CS-Fixer * Append a capital letter to the test client passwords * Minor tweaks * Display more info after the tests run * Oops, I forgot to set the dir * Fix cron behavior for test env, dropped legacy tests * Rename the empty test suite so PHPUnit ignores it * Update cspell.json * Minor tweaks to the tests * Fixes
61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Box\Mod\Cron;
|
|
|
|
class ServiceTest extends \BBTestCase
|
|
{
|
|
public function testgetDi()
|
|
{
|
|
$di = new \Pimple\Container();
|
|
$service = new Service();
|
|
$service->setDi($di);
|
|
$getDi = $service->getDi();
|
|
$this->assertEquals($di, $getDi);
|
|
}
|
|
|
|
public function testgetCronInfo()
|
|
{
|
|
$systemServiceMock = $this->getMockBuilder('\\' . \Box\Mod\System\Service::class)->getMock();
|
|
$systemServiceMock->expects($this->atLeastOnce())->method('getParamValue');
|
|
|
|
$di = new \Pimple\Container();
|
|
$di['mod_service'] = $di->protect(fn ($name) => $systemServiceMock);
|
|
$service = new Service();
|
|
$service->setDi($di);
|
|
|
|
$result = $service->getCronInfo();
|
|
$this->assertIsArray($result);
|
|
}
|
|
|
|
public function testgetLastExecutionTime()
|
|
{
|
|
$systemServiceMock = $this->getMockBuilder('\\' . \Box\Mod\System\Service::class)->getMock();
|
|
$systemServiceMock->expects($this->atLeastOnce())
|
|
->method('getParamValue')
|
|
->willReturn('2012-12-12 12:12:12');
|
|
|
|
$di = new \Pimple\Container();
|
|
$di['mod_service'] = $di->protect(fn ($name) => $systemServiceMock);
|
|
$service = new Service();
|
|
$service->setDi($di);
|
|
|
|
$result = $service->getLastExecutionTime();
|
|
$this->assertIsString($result);
|
|
}
|
|
|
|
public function testisLate()
|
|
{
|
|
$serviceMock = $this->getMockBuilder('\\' . Service::class)
|
|
->onlyMethods(['getLastExecutionTime'])
|
|
->getMock();
|
|
|
|
$serviceMock->expects($this->atLeastOnce())
|
|
->method('getLastExecutionTime')
|
|
->willReturn(date('Y-m-d H:i:s'));
|
|
|
|
$result = $serviceMock->isLate();
|
|
$this->assertIsBool($result);
|
|
$this->assertFalse($result);
|
|
}
|
|
}
|