init
This commit is contained in:
71
tests/Feature/ServiceTest.php
Normal file
71
tests/Feature/ServiceTest.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?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' => '',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user