/** * @return void */ public function setUp() { $this->mockClient = $this->getMock('SimplyAdmire\\Zaaksysteem\\Object\\Client', [], [], '', false); $responseArray = json_decode(file_get_contents(__DIR__ . '/Fixtures/Responses/Object/products.json'), true); for ($page = 1; $page <= 19; $page++) { $this->mockClient->expects($this->any())->method('request')->will($this->returnCallback(function ($requestMethod, $page) use($responseArray) { preg_match('/[0-9]*$/', $page, $matches); $responseArray['next'] = (int) $matches[0] === 19 ? null : 'http://foo.bar/?zapi_page=' . ((int) $matches[0] + 1); return $responseArray; })); } $this->result = new PagedResult($this->mockClient, 'SimplyAdmire\\Zaaksysteem\\Tests\\Unit\\Fixtures\\DummyModel', '1'); }
/** * @param string $identifier * @return object * @throws RequestException * @throws ResponseException */ public function findOneByIdentifier($identifier) { $result = $this->client->request('GET', $this->apiPath . '/' . $identifier); return new $this->modelClassName($result['result'][0]); }