mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 10:49:00 +02:00
Use a enum for level in LogEntries
This commit is contained in:
parent
4a644d8712
commit
2da7463edf
18 changed files with 322 additions and 149 deletions
|
@ -60,22 +60,6 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class AbstractLogEntryTest extends TestCase
|
||||
{
|
||||
public function levelDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[0, 'emergency'],
|
||||
[1, 'alert'],
|
||||
[2, 'critical'],
|
||||
[3, 'error'],
|
||||
[4, 'warning'],
|
||||
[5, 'notice'],
|
||||
[6, 'info'],
|
||||
[7, 'debug'],
|
||||
[8, 'blabla', true],
|
||||
[-1, 'test', true],
|
||||
];
|
||||
}
|
||||
|
||||
public function targetTypeDataProvider(): array
|
||||
{
|
||||
return [
|
||||
|
@ -95,28 +79,6 @@ class AbstractLogEntryTest extends TestCase
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider levelDataProvider
|
||||
*/
|
||||
public function testLevelIntToString(int $int, string $expected_string, bool $expect_exception = false): void
|
||||
{
|
||||
if ($expect_exception) {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
}
|
||||
$this->assertSame($expected_string, AbstractLogEntry::levelIntToString($int));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider levelDataProvider
|
||||
*/
|
||||
public function testLevelStringToInt(int $expected_int, string $string, bool $expect_exception = false): void
|
||||
{
|
||||
if ($expect_exception) {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
}
|
||||
$this->assertSame($expected_int, AbstractLogEntry::levelStringToInt($string));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider targetTypeDataProvider
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue