Skip to content

Commit

Permalink
Fix for info() failing with the new HTTP API format. Added test. (#65)
Browse files Browse the repository at this point in the history
Co-authored-by: Steve Therrien <stherrien@onlineschool.ca>
  • Loading branch information
SteveTherrien and Steve Therrien authored Jun 27, 2024
1 parent 463e991 commit 88747d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ private function request($method, $params)
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, \json_encode($params));
curl_setopt($ch, CURLOPT_POSTFIELDS, \json_encode((object)$params));
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->getHeaders());
curl_setopt($ch, CURLOPT_URL, $this->getUrl($method));
$data = curl_exec($ch);
Expand Down
7 changes: 7 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,11 @@ public function testPublishNetworkError()
$client = new \phpcent\Client("http://localhost:9000/api");
$res = $client->publish('channel', ["message" => "Hello World"]);
}

public function testInfo()
{
$res = $this->client->info();
$this->assertNotNull($res);
$this->assertTrue(is_array($res->result->nodes));
}
}

0 comments on commit 88747d2

Please sign in to comment.