/** * @test */ public function should_update_existing_article_and_respond_without_instance() { $responseMock = $this->createResponseMock(200, null); $apiClient = $this->createTestApiClient($responseMock); $article = new Article(); $article->setId(uniqid()); $article->setCollectionId(uniqid()); $article->setName(uniqid("New Article Name ")); $article->setText("New Article text"); $updated = $apiClient->updateArticle($article, false); $this->assertSame($article, $updated); }
/** * @param Article $article * @param bool $reload * @return bool|Article * @throws ApiException */ public function createArticle(Article $article, $reload = false) { $url = "articles"; $requestBody = $article->toArray(); if ($reload) { $requestBody['reload'] = true; } list($id, $response) = $this->doPost($url, $requestBody); if ($reload) { $articleData = (array) $response; $articleData = reset($articleData); return new Article($articleData); } else { $article->setId($id); return $article; } }