/** * @param Collection $collection * @param bool $reload * @return Collection * @throws ApiException */ public function updateCollection(Collection $collection, $reload = false) { $url = sprintf("collections/%s", $collection->getId()); $requestBody = $collection->toArray(); if ($reload) { $requestBody['reload'] = true; } $response = $this->doPut($url, $requestBody); if ($reload) { $collectionData = (array) $response; $collectionData = reset($collectionData); return new Collection($collectionData); } else { return $collection; } }
/** * @test */ public function should_update_collection_and_respond_without_entity() { $responseMock = $this->createResponseMock(200, null); $apiClient = $this->createTestApiClient($responseMock); $collection = new Collection(); $collection->setName(uniqid("Updated collection ")); $updated = $apiClient->updateCollection($collection, false); $this->assertInstanceOf(Collection::class, $updated); $this->assertSame($collection, $updated); }