From e9fca71af23526dcaddadd16062706fe3650abca Mon Sep 17 00:00:00 2001 From: Andy Liu Date: Mon, 23 Sep 2024 15:00:55 -0400 Subject: [PATCH] initial commit: remove array filtering for params and add unit test --- src/Rest/Base.php | 1 - tests/Clients/BaseRestResourceTest.php | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Rest/Base.php b/src/Rest/Base.php index b30e4c37..755c01d4 100644 --- a/src/Rest/Base.php +++ b/src/Rest/Base.php @@ -178,7 +178,6 @@ protected static function request( $client = new Rest($session->getShop(), $session->getAccessToken()); - $params = array_filter($params); switch ($httpMethod) { case "get": $response = $client->get( diff --git a/tests/Clients/BaseRestResourceTest.php b/tests/Clients/BaseRestResourceTest.php index 435d8fac..4142477e 100644 --- a/tests/Clients/BaseRestResourceTest.php +++ b/tests/Clients/BaseRestResourceTest.php @@ -63,6 +63,24 @@ public function testFindsWithParam() $this->assertEquals([1, "attribute"], [$resource->id, $resource->attribute]); } + public function testCanUseFalseyParam() + { + $body = ["fake_resource" => ["id" => 1, "attribute" => "attribute"]]; + + $this->mockTransportRequests([ + new MockRequest( + $this->buildMockHttpResponse(200, $body), + "{$this->prefix}/fake_resources/1.json?param=0", + "GET", + null, + ["X-Shopify-Access-Token: access-token"], + ), + ]); + + $resource = FakeResource::find($this->session, 1, [ "param" => "0"]); + $this->assertEquals([1, "attribute"], [$resource->id, $resource->attribute]); + } + public function testFindsResourceAndChildrenById() { $body = ["fake_resource" => [