-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a concrete class to test AbstractSearcher
Although testing abstract classes is good, using mocks makes the code too complicated. Signed-off-by: Henrique Moody <[email protected]>
- Loading branch information
1 parent
0c7f269
commit 57b4c06
Showing
2 changed files
with
40 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (c) Alexandre Gomes Gaigalas <[email protected]> | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Respect\Validation\Test\Rules; | ||
|
||
use Respect\Validation\Rules\AbstractSearcher; | ||
|
||
use function call_user_func; | ||
|
||
final class SearcherStub extends AbstractSearcher | ||
{ | ||
/** | ||
* @var callable | ||
*/ | ||
private $dataSourceCallable; | ||
|
||
public function __construct(callable $dataSourceCallable) | ||
{ | ||
$this->dataSourceCallable = $dataSourceCallable; | ||
} | ||
|
||
/** | ||
* @return array<mixed, array<mixed>> | ||
*/ | ||
protected function getDataSource(mixed $input = null): array | ||
{ | ||
return call_user_func($this->dataSourceCallable, $input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters