59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature\Api\V1\IncoCompositions;
|
|
|
|
use Database\ArcadiaReplicate\Factories\Refp\IncoCompoFactory;
|
|
use Database\ArcadiaReplicate\Factories\Refp\IncoFactory;
|
|
|
|
describe('IncoCompositions Show Feature API', function (): void {
|
|
beforeEach(function (): void {
|
|
IncoFactory::truncate();
|
|
IncoCompoFactory::truncate();
|
|
});
|
|
|
|
it('returns 200 OK with inco composition details by inco sheet ID', function (): void {
|
|
// GIVEN
|
|
/** @var \Tests\TestCase $test */
|
|
$test = $this;
|
|
|
|
IncoFactory::new()->create([
|
|
'NO_ART' => 12345,
|
|
'REF_COMPO' => 67890,
|
|
]);
|
|
|
|
IncoCompoFactory::new()->create([
|
|
'ID' => 67890,
|
|
'ID_INCO' => 12345,
|
|
'NOM' => 'Poulet Rôti 1kg Test',
|
|
]);
|
|
|
|
// WHEN
|
|
$response = $test->getJson('/api/v1/inco-sheets/12345/composition');
|
|
|
|
// THEN
|
|
$response->assertStatus(200);
|
|
$response->assertJson([
|
|
'composition' => [
|
|
'incoCompoId' => '67890',
|
|
'incoId' => '12345',
|
|
'identification' => [
|
|
'name' => 'Poulet Rôti 1kg Test',
|
|
],
|
|
],
|
|
]);
|
|
});
|
|
|
|
it('returns 404 Not Found when composition does not exist', function (): void {
|
|
// GIVEN
|
|
/** @var \Tests\TestCase $test */
|
|
$test = $this;
|
|
|
|
// WHEN
|
|
$response = $test->getJson('/api/v1/inco-sheets/999999/composition');
|
|
|
|
// THEN
|
|
$response->assertStatus(404);
|
|
});
|
|
});
|