mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-30 20:27:07 +09:00
* 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
66 lines
2.1 KiB
PHP
66 lines
2.1 KiB
PHP
<?php
|
|
|
|
#[\PHPUnit\Framework\Attributes\Group('Core')]
|
|
class LogTest extends BBDbApiTestCase
|
|
{
|
|
public static function logWithoutParamsProvider()
|
|
{
|
|
return array(
|
|
array('Test message'),
|
|
array('Test message with param %s, but param not passed'),
|
|
);
|
|
}
|
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider('logWithoutParamsProvider')]
|
|
public function testLogWithoutParams($msg)
|
|
{
|
|
$msg = 'Test message';
|
|
$this->di['logger']->info($msg);
|
|
|
|
$array = $this->api_admin->activity_log_get_list();
|
|
$log = $array['list'][0]; //by default sorting by ID descending order so newest will always be first array item
|
|
$message = $log['message'];
|
|
|
|
$this->assertEquals($msg, $message);
|
|
}
|
|
|
|
|
|
public function testLogProvider()
|
|
{
|
|
$rand = random_int(1, 100);
|
|
$msg1 = 'No params in message, param passed';
|
|
$msg2 = 'Test message with param %s';
|
|
|
|
$this->assertTrue(($rand <= 100 && $rand > 0));
|
|
|
|
return array(
|
|
array($msg1, $rand, $msg1),
|
|
array($msg2, $rand, 'Test message with param ' . $rand),
|
|
);
|
|
}
|
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider('testLogProvider')]
|
|
public function testLogWithSingleParam($msg, $param, $expected)
|
|
{
|
|
$this->di['logger']->info($msg, $param);
|
|
|
|
$array = $this->api_admin->activity_log_get_list();
|
|
$log = $array['list'][0]; //by default sorting by ID descending order so newest will always be first array item
|
|
$message = $log['message'];
|
|
|
|
$this->assertEquals($expected, $message);
|
|
}
|
|
|
|
public function testLogMultipleVariables()
|
|
{
|
|
$msg = '%sMultiple params in message, one param passed%s';
|
|
$rand = random_int(1, 100);
|
|
$this->di['logger']->info($msg, $rand, $rand);
|
|
$array = $this->api_admin->activity_log_get_list();
|
|
$log = $array['list'][0]; //by default sorting by ID descending order so newest will always be first array item
|
|
$message = $log['message'];
|
|
|
|
$this->assertEquals(sprintf($msg, $rand, $rand), $message);
|
|
}
|
|
|
|
} |