mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-10 02:14:31 +02:00
Made the magic strings of EventCommentHelper into an array
This commit is contained in:
parent
a0a7ca3c9c
commit
6df7bc5f2a
6 changed files with 62 additions and 33 deletions
|
@ -23,23 +23,17 @@ declare(strict_types=1);
|
|||
namespace App\Tests\Services\LogSystem;
|
||||
|
||||
use App\Services\LogSystem\EventCommentNeededHelper;
|
||||
use App\Services\LogSystem\EventCommentType;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class EventCommentNeededHelperTest extends TestCase
|
||||
{
|
||||
public function testIsCommentNeeded(): void
|
||||
{
|
||||
$service = new EventCommentNeededHelper(['part_edit', 'part_create']);
|
||||
$this->assertTrue($service->isCommentNeeded('part_edit'));
|
||||
$this->assertTrue($service->isCommentNeeded('part_create'));
|
||||
$this->assertFalse($service->isCommentNeeded('part_delete'));
|
||||
$this->assertFalse($service->isCommentNeeded('part_stock_operation'));
|
||||
}
|
||||
|
||||
public function testIsCommentNeededInvalidTypeException(): void
|
||||
{
|
||||
$service = new EventCommentNeededHelper(['part_edit', 'part_create']);
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$service->isCommentNeeded('this_is_not_valid');
|
||||
$service = new EventCommentNeededHelper([EventCommentType::PART_CREATE, EventCommentType::PART_EDIT]);
|
||||
$this->assertTrue($service->isCommentNeeded(EventCommentType::PART_CREATE));
|
||||
$this->assertTrue($service->isCommentNeeded(EventCommentType::PART_EDIT));
|
||||
$this->assertFalse($service->isCommentNeeded(EventCommentType::DATASTRUCTURE_EDIT));
|
||||
$this->assertFalse($service->isCommentNeeded(EventCommentType::PART_STOCK_OPERATION));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue