From 0a20a78b625d47d59bda8f39a834cb816458ae21 Mon Sep 17 00:00:00 2001 From: mscherer Date: Mon, 2 Nov 2020 23:06:09 +0100 Subject: [PATCH] Add test case. --- .../TestCase/View/Helper/SearchHelperTest.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/TestCase/View/Helper/SearchHelperTest.php b/tests/TestCase/View/Helper/SearchHelperTest.php index 7b017ae5..e08ef8d2 100644 --- a/tests/TestCase/View/Helper/SearchHelperTest.php +++ b/tests/TestCase/View/Helper/SearchHelperTest.php @@ -89,6 +89,37 @@ public function testResetUrl() $this->assertSame($expected, $result); } + /** + * @return void + */ + public function testResetUrlWithPassedParams() + { + $request = new ServerRequest([ + 'url' => '/controller/action/my-passed?limit=5&sort=x&direction=asc&foo=baz&bar=1', + ]); + $request = $request->withParam('pass', ['my-passed']); + + $this->view = new View($request); + $this->searchHelper = new SearchHelper($this->view, []); + + $params = [ + 'foo' => 'baz', + 'bar' => '1', + ]; + $this->view->set('_searchParams', $params); + + $result = $this->searchHelper->resetUrl(); + $expected = [ + 'my-passed', + '?' => [ + 'limit' => '5', + 'sort' => 'x', + 'direction' => 'asc', + ], + ]; + $this->assertSame($expected, $result); + } + /** * @return void */