Skip to content

Commit

Permalink
Merge pull request #28 from ppaulis/1.6.x
Browse files Browse the repository at this point in the history
Allow `Laminas\Stdlib\Parameters` as parameter type for for `AbstractResourceListener#fetchAll()`
  • Loading branch information
Ocramius authored Apr 19, 2022
2 parents 36583a7 + 2174bc9 commit c6c4e16
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/AbstractResourceListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Laminas\EventManager\ListenerAggregateInterface;
use Laminas\EventManager\ListenerAggregateTrait;
use Laminas\InputFilter\InputFilterInterface;
use Laminas\Stdlib\Parameters;

use function sprintf;

Expand Down Expand Up @@ -252,7 +253,7 @@ public function fetch($id)
/**
* Fetch all or a subset of resources
*
* @param array $params
* @param array|Parameters $params
* @return ApiProblem|mixed
*/
public function fetchAll($params = [])
Expand Down
13 changes: 13 additions & 0 deletions test/AbstractResourceListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,17 @@ public function testDispatchShouldPassWhitelistedQueryParamsToFetchAllMethod()

$this->assertEquals($queryParams, $this->listener->testCase->paramsPassedToListener);
}

/**
* @group 7
*/
public function testDispatchShouldPassEmptyArrayToFetchAllMethodIfNoQueryParamsArePresent()
{
$event = new ResourceEvent();
$event->setName('fetchAll');

$this->listener->dispatch($event);

$this->assertEquals([], $this->listener->testCase->paramsPassedToListener);
}
}

0 comments on commit c6c4e16

Please sign in to comment.