Files
FOSSBilling/tests/integration/bb-modules/mod_example/ServiceTest.php
T
Belle Aerni 50043e6211 Run Rector against our tests (#1761)
* Update rector config to include tests

* Run Rector against the tests

* Delete test-results

* Update .gitignore

* Correctly set the PHP min to 8.1, split the configs

* Corrected PHPDoc

* Deleted tests we can't really get to pass

PHPunit is hard-coded to fail when a class has a return type of `never`, which is the correct return type of our redirect function (and rightfully so).

No way to disable the exception as far as we can tell
2023-11-11 18:41:09 +00:00

58 lines
1.7 KiB
PHP

<?php
#[\PHPUnit\Framework\Attributes\Group('Core')]
class ServiceTest extends BBDbApiTestCase
{
protected $_initialSeedFile = 'example.xml';
public function testUninstall(){
$service = new Box\Mod\Example\Service();
$result = $service->uninstall();
$this->assertTrue($result);
}
public function testUpdate(){
$service = new Box\Mod\Example\Service();
$result = $service->update(array());
$this->assertTrue($result);
}
public function testGetSearchQuery()
{
$service = new Box\Mod\Example\Service();
$di = new \Pimple\Container();
$service->setDi($di);
$data = array(
'client_id' => 1
);
[$sql, $params] = $service->getSearchQuery($data);
$this->assertIsString($sql);
$this->assertIsArray($params);
$this->assertArrayHasKey(':client_id', $params);
$this->assertEquals($params[':client_id'], $data['client_id']);
}
public function testEvents()
{
$service = new Box\Mod\Example\Service();
$params = array(
'ip' => '123.123.123.123',
);
$event = new Box_Event(null, 'name', $params, $this->api_admin, $this->api_guest);
$event->setDi($this->di);
$result = $service->onEventClientLoginFailed($event);
$this->assertNull($result);
$params = array(
'client_id' => 1,
'id' => 1
);
$event = new Box_Event(null, 'name', $params, $this->api_admin, $this->api_guest);
$event->setDi($this->di);
$result = $service->onAfterClientOrderCreate($event);
$this->assertNull($result);
}
}