refactor(service): remove redundant short methods from IncoService
This commit is contained in:
parent
7c51b7c710
commit
c24991bd7d
3 changed files with 0 additions and 142 deletions
|
|
@ -73,18 +73,6 @@ final class ArcadiaIncoService implements IncoService
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BrandCode[]|BrandCode $brands
|
||||
* @return StreamOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>
|
||||
*/
|
||||
public function streamAllShortOfBrands(
|
||||
array | BrandCode $brands,
|
||||
PageSize $pageSize = new PageSize(),
|
||||
?IncoSorter $sorter = null,
|
||||
): StreamOf {
|
||||
return $this->streamAllOfBrands($brands, $pageSize, $sorter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BrandCode[]|BrandCode $brands
|
||||
* @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>|ApiError
|
||||
|
|
@ -119,18 +107,6 @@ final class ArcadiaIncoService implements IncoService
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BrandCode[]|BrandCode $brands
|
||||
* @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>|ApiError
|
||||
*/
|
||||
public function getAllShortOfBrands(
|
||||
Pagination $pagination,
|
||||
array | BrandCode $brands,
|
||||
?IncoSorter $sorter = null
|
||||
): PageOf | ApiError {
|
||||
return $this->getAllOfBrands($pagination, $brands, $sorter);
|
||||
}
|
||||
|
||||
/** @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>|ApiError */
|
||||
public function getAll(
|
||||
Pagination $pagination,
|
||||
|
|
@ -154,14 +130,6 @@ final class ArcadiaIncoService implements IncoService
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>|ApiError
|
||||
*/
|
||||
public function findShortByIncoIdLike(string $incoIdLike, BrandCode ...$onBrands): PageOf | ApiError
|
||||
{
|
||||
return $this->findByIncoIdLike($incoIdLike, ...$onBrands);
|
||||
}
|
||||
|
||||
public function findBy(IncoId $id): Inco | null | ApiError
|
||||
{
|
||||
return $this->incoRepository->find($id);
|
||||
|
|
|
|||
|
|
@ -45,16 +45,6 @@ interface IncoService
|
|||
\SortDirection $sortDirection = \SortDirection::Descending,
|
||||
): StreamOf;
|
||||
|
||||
/**
|
||||
* @param BrandCode[]|BrandCode $brands
|
||||
* @return StreamOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>
|
||||
*/
|
||||
public function streamAllShortOfBrands(
|
||||
array | BrandCode $brands,
|
||||
PageSize $pageSize = new PageSize(),
|
||||
?IncoSorter $sorter = null,
|
||||
): StreamOf;
|
||||
|
||||
/**
|
||||
* @param BrandCode[]|BrandCode $brands
|
||||
* @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>|ApiError
|
||||
|
|
@ -76,16 +66,6 @@ interface IncoService
|
|||
?IncoSorter $sorter = null
|
||||
): PageOf | ApiError;
|
||||
|
||||
/**
|
||||
* @param BrandCode[]|BrandCode $brands
|
||||
* @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>|ApiError
|
||||
*/
|
||||
public function getAllShortOfBrands(
|
||||
Pagination $pagination,
|
||||
array | BrandCode $brands,
|
||||
?IncoSorter $sorter = null
|
||||
): PageOf | ApiError;
|
||||
|
||||
/** @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>|ApiError */
|
||||
public function getAll(
|
||||
Pagination $pagination,
|
||||
|
|
@ -97,11 +77,6 @@ interface IncoService
|
|||
*/
|
||||
public function findByIncoIdLike(string $incoIdLike, BrandCode ...$onBrands): PageOf | ApiError;
|
||||
|
||||
/**
|
||||
* @return PageOf<\Uwil\ArcadiaApiPhpClient\Lib\ApiDto\Dto\IncoShort>|ApiError
|
||||
*/
|
||||
public function findShortByIncoIdLike(string $incoIdLike, BrandCode ...$onBrands): PageOf | ApiError;
|
||||
|
||||
public function findBy(IncoId $id): Inco | null | ApiError;
|
||||
|
||||
public function findCompo(IncoId | IncoCompoId $id): IncoCompo | null | ApiError;
|
||||
|
|
|
|||
|
|
@ -208,32 +208,6 @@ describe('ArcadiaIncoService', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('getAllShortOfBrands', function () {
|
||||
it('returns PageOf of IncoShort when repository succeeds', function () {
|
||||
// GIVEN
|
||||
$pagination = Pagination::firstPage();
|
||||
$brand = new BrandCode('LGL39');
|
||||
$expectedPage = new PageOf(
|
||||
new PaginationDto(page: 1, pageSize: 50, totalItems: 1, totalPages: 1),
|
||||
[dummyIncoShortForService()]
|
||||
);
|
||||
|
||||
[$incoRepo, $shortRepo, $compoRepo] = serviceIncoMocks();
|
||||
$shortRepo->shouldReceive('selectAllHavingBrands')
|
||||
->once()
|
||||
->with($pagination, [$brand], null)
|
||||
->andReturn($expectedPage);
|
||||
|
||||
$service = new ArcadiaIncoService($incoRepo, $shortRepo, $compoRepo);
|
||||
|
||||
// WHEN
|
||||
$result = $service->getAllShortOfBrands($pagination, $brand);
|
||||
|
||||
// THEN
|
||||
expect($result)->toBe($expectedPage);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findByIncoIdLike', function () {
|
||||
it('returns PageOf when search succeeds', function () {
|
||||
// GIVEN
|
||||
|
|
@ -268,40 +242,6 @@ describe('ArcadiaIncoService', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('findShortByIncoIdLike', function () {
|
||||
it('returns PageOf of IncoShort when search succeeds', function () {
|
||||
// GIVEN
|
||||
$brand = new BrandCode('LGL39');
|
||||
$expectedPage = new PageOf(
|
||||
new PaginationDto(page: 1, pageSize: 50, totalItems: 1, totalPages: 1),
|
||||
[dummyIncoShortForService()]
|
||||
);
|
||||
|
||||
[$incoRepo, $shortRepo, $compoRepo] = serviceIncoMocks();
|
||||
$shortRepo->shouldReceive('findWhere')
|
||||
->once()
|
||||
->andReturn($expectedPage);
|
||||
|
||||
$service = new ArcadiaIncoService($incoRepo, $shortRepo, $compoRepo);
|
||||
|
||||
// WHEN
|
||||
$result = $service->findShortByIncoIdLike('poulet', $brand);
|
||||
|
||||
// THEN
|
||||
expect($result)->toBe($expectedPage);
|
||||
});
|
||||
|
||||
it('throws InvalidArgumentException when no brands are passed', function () {
|
||||
// GIVEN
|
||||
[$incoRepo, $shortRepo, $compoRepo] = serviceIncoMocks();
|
||||
$service = new ArcadiaIncoService($incoRepo, $shortRepo, $compoRepo);
|
||||
|
||||
// WHEN / THEN
|
||||
expect(fn () => $service->findShortByIncoIdLike('poulet'))
|
||||
->toThrow(\InvalidArgumentException::class, 'At least 1 brand code is required');
|
||||
});
|
||||
});
|
||||
|
||||
describe('findBy', function () {
|
||||
it('returns Inco when found', function () {
|
||||
// GIVEN
|
||||
|
|
@ -500,30 +440,5 @@ describe('ArcadiaIncoService', function () {
|
|||
expect($items)->toHaveCount(1);
|
||||
expect($items[0])->toBe($incoShort);
|
||||
});
|
||||
|
||||
it('streamAllShortOfBrands returns StreamOf yielding inco shorts', function () {
|
||||
// GIVEN
|
||||
$incoShort = dummyIncoShortForService();
|
||||
$expectedPage = new PageOf(
|
||||
new PaginationDto(page: 1, pageSize: 50, totalItems: 1, totalPages: 1),
|
||||
[$incoShort]
|
||||
);
|
||||
|
||||
[$incoRepo, $shortRepo, $compoRepo] = serviceIncoMocks();
|
||||
$shortRepo->shouldReceive('selectAllHavingBrands')
|
||||
->once()
|
||||
->andReturn($expectedPage);
|
||||
|
||||
$service = new ArcadiaIncoService($incoRepo, $shortRepo, $compoRepo);
|
||||
|
||||
// WHEN
|
||||
$stream = $service->streamAllShortOfBrands(new BrandCode('LGL39'));
|
||||
$items = iterator_to_array($stream);
|
||||
|
||||
// THEN
|
||||
expect($stream)->toBeInstanceOf(StreamOf::class);
|
||||
expect($items)->toHaveCount(1);
|
||||
expect($items[0])->toBe($incoShort);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue