|
|
|
|
@ -45,4 +45,39 @@ class ResolutionStrategyFactoryTest extends TestCase
|
|
|
|
|
// Then
|
|
|
|
|
$this->assertInstanceOf($strategyClass, $function);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function userDefinedPrecedenceProvider(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
['R', 'save', 'UPDATE', '', null, [], UserDefinedQuery::class],
|
|
|
|
|
['R', 'delete', 'DELETE', '', null, [], UserDefinedQuery::class],
|
|
|
|
|
['R', 'findById', 'SELECT', '', null, [], UserDefinedQuery::class],
|
|
|
|
|
['R', 'findAll', 'SELECT', '', null, [], UserDefinedQuery::class],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[DataProvider('userDefinedPrecedenceProvider')]
|
|
|
|
|
public function testUserDefinedQueryHasAlwaysPrecedence(
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|