Files
FOSSBilling/tests/modules/Api/ServiceTest.php
T
Belle Aerni 32d011225b Rector & PHP-CS-Fixer Improvements (#2047)
* Added the rector cache to the action

* Enabled PHP-CS fixer for the tests & library folder

* Use the PHP-CS-Fixer Cache

* Fix the tests

* Ensure the Sentry placeholder isn't messed up from CS changes

* Typo..
2024-01-08 00:10:00 +00:00

47 lines
1.0 KiB
PHP

<?php
namespace Box\Mod\Api;
class ServiceTest extends \BBTestCase
{
/**
* @var Service
*/
protected $service;
public function setup(): void
{
$this->service = new Service();
}
public function testgetDi()
{
$di = new \Pimple\Container();
$this->service->setDi($di);
$getDi = $this->service->getDi();
$this->assertEquals($di, $getDi);
}
public function testgetRequestCount()
{
$since = 674_690_401; // timestamp == '1991-05-20 00:00:01';
$ip = '1.2.3.4';
$requestNumber = 11;
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
$dbMock->expects($this->atLeastOnce())
->method('getCell')
->willReturn($requestNumber);
$di = new \Pimple\Container();
$di['db'] = $dbMock;
$this->service->setDi($di);
$result = $this->service->getRequestCount($since, $ip);
$this->assertIsInt($result);
$this->assertEquals($requestNumber, $result);
}
}