Files
gorilla/tests/Feature/ServiceTest.php
2026-01-12 12:37:16 +01:00

72 lines
1.9 KiB
PHP

<?php
namespace Tests\Feature;
use App\Service\Service;
use Tests\TestCase;
class ServiceTest extends TestCase
{
public function testEntriesAreClassifiedCorrectly()
{
$data = $this->getTestData();
$service = new Service();
foreach ($data as $entry) {
$service->processEntry($entry);
}
$this->assertEquals(2, $service->getInspectionsCount());
$this->assertEquals(2, $service->getFailureReportsCount());
}
public function testDuplicatedEntryThrowsException()
{
$data = $this->getTestData();
$service = new Service();
$this->expectException(\InvalidArgumentException::class);
$service->processEntry($data[0]);
$service->processEntry($data[0]);
}
public function testDuplicatedEntryIsAddedToUnprocessableList()
{
$data = $this->getTestData();
$service = new Service();
$service->processEntry($data[0]);
try {
$service->processEntry($data[0]);
} catch (\Exception $e) {}
$this->assertCount(1, $service->getUnprocessable());
}
private function getTestData()
{
return [
[
'number' => 1,
'description' => 'Test przegląd',
'dueDate' => '',
'phone' => '',
],
[
'number' => 2,
'description' => 'Awaria systemu',
'dueDate' => '',
'phone' => '',
],
[
'number' => 3,
'description' => 'Test przegląd 2',
'dueDate' => '',
'phone' => '',
],
[
'number' => 4,
'description' => 'Awaria systemu 2',
'dueDate' => '',
'phone' => '',
],
];
}
}