You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Kartierung\Repository\ResolutionStrategy;
|
|
|
|
use Kartierung\FullEntity;
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ResolutionStrategyFactoryTest extends TestCase
|
|
{
|
|
public static function validFunctionsProvider(): array
|
|
{
|
|
return [
|
|
['R', 'save', null, '', null, [1], SaveEntity::class],
|
|
['R', 'delete', null, 'int', null, [1], DeleteEntity::class],
|
|
['R', 'findById', null, '?int', null, [1], FindById::class],
|
|
['R', 'findAll', null, 'array', FullEntity::class, [], FindAll::class],
|
|
['R', 'something', 'SELECT', 'int', null, [], UserDefinedQuery::class]
|
|
];
|
|
}
|
|
|
|
#[DataProvider('validFunctionsProvider')]
|
|
public function testValidFunctions(
|
|
string $repName,
|
|
string $name,
|
|
?string $query,
|
|
string $returnType,
|
|
?string $listType,
|
|
array $params,
|
|
string $strategyClass
|
|
): void
|
|
{
|
|
// When
|
|
$function = (new ResolutionStrategyFactory())->forRepositoryMethod(
|
|
$repName,
|
|
$name,
|
|
$query,
|
|
$returnType,
|
|
$listType,
|
|
$params
|
|
);
|
|
|
|
// Then
|
|
$this->assertInstanceOf($strategyClass, $function);
|
|
}
|
|
}
|