Files
FOSSBilling/tests-legacy/integration/bb-modules/mod_activity/Api_AdminTest.php
T
Belle Aerni 8f4d0d4cac More tests and CI improvements (#2078)
* 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
2024-01-17 18:11:45 -08:00

75 lines
2.4 KiB
PHP

<?php
#[PHPUnit\Framework\Attributes\Group('Core')]
class Api_AdminTest extends BBDbApiTestCase
{
protected $_initialSeedFile = 'settings.xml';
public function testActivity()
{
$bool = $this->api_admin->activity_log_delete(['id' => 1]);
$this->assertTrue($bool);
$bool = $this->api_admin->activity_log();
$this->assertFalse($bool);
$bool = $this->api_admin->activity_log(['m' => 'this is test message to log']);
$this->assertTrue($bool);
$bool = $this->api_admin->activity_log_email(['subject' => 'This is an email subject']);
$this->assertTrue($bool);
}
public function testLogDeleteIdNotSetException()
{
$this->expectException(FOSSBilling\Exception::class);
$this->api_admin->activity_log_delete([]);
}
public function testLogNotFoundException()
{
$this->expectException(FOSSBilling\Exception::class);
$this->api_admin->activity_log_delete(['id' => 100]);
}
public function testActivityLogGetList()
{
$array = $this->api_admin->activity_log_get_list();
$this->assertIsArray($array);
$this->assertArrayHasKey('list', $array);
$this->assertArrayHasKey('pages', $array);
$this->assertArrayHasKey('page', $array);
$this->assertArrayHasKey('per_page', $array);
$this->assertArrayHasKey('total', $array);
$this->assertArrayHasKey('list', $array);
$list = $array['list'];
$this->assertIsArray($list);
if (count($list)) {
$item = $list[0];
$this->assertArrayHasKey('id', $item);
$this->assertArrayHasKey('priority', $item);
$this->assertArrayHasKey('admin_id', $item);
$this->assertArrayHasKey('client_id', $item);
$this->assertArrayHasKey('message', $item);
$this->assertArrayHasKey('ip', $item);
$this->assertArrayHasKey('created_at', $item);
$this->assertArrayHasKey('updated_at', $item);
}
}
public function testBatchDelete()
{
$array = $this->api_admin->activity_log_get_list([]);
foreach ($array['list'] as $value) {
$ids[] = $value['id'];
}
$result = $this->api_admin->activity_batch_delete(['ids' => $ids]);
$array = $this->api_admin->activity_log_get_list([]);
$this->assertEquals(0, count($array['list']));
$this->assertTrue($result);
}
}