Skip to content

Commit

Permalink
initial commit: remove array filtering for params and add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-liuu committed Sep 23, 2024
1 parent 18d1d3f commit e9fca71
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/Rest/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 18 additions & 0 deletions tests/Clients/BaseRestResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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" => [
Expand Down

0 comments on commit e9fca71

Please sign in to comment.