public function testPayloadValidation() { $payload = new SearchPayload(); try { $payload->setRows('abc'); } catch (EuropeanaException $e) { $previous = $e->getPrevious(); $this->assertInstanceOf('\\InvalidArgumentException', $previous); $this->assertEquals('Expected argument to be of type "integer", got "string"', $previous->getMessage()); } try { $payload->setStart('abc'); } catch (EuropeanaException $e) { $previous = $e->getPrevious(); $this->assertInstanceOf('\\InvalidArgumentException', $previous); $this->assertEquals('Expected argument to be of type "integer", got "string"', $previous->getMessage()); return; } $this->markTestIncomplete('This test should have thrown an exception'); }
protected function createPayload() { $payload = new SearchPayload(); $payload->setQuery('foo bar'); $refinement = new Refinement('TYPE', 'IMAGE'); $payload->addRefinement($refinement); $refinement = new Refinement('where', 'france'); $payload->addRefinement($refinement); $facet = new Facet('PROVIDER', 10, 20); $payload->addFacet($facet); $facet = new Facet('proxy_dc_coverage', 10, 20); $payload->addFacet($facet); $facet = new Facet('proxy_dc_contributor', 10, 20); $payload->addFacet($facet); return $payload; }
/** * Lists all the records asociated with a single dataset id. * * We use SearchPayload instead of DatasetPayload because this call will * return data directly from the Lucene index used on the Europeana server * side. * * @return SearchPayload The SearchPayload which will retrieve the data. */ public function listRecords() { $payload = new SearchPayload(); $payload->setQuery('*:*'); $refinement = new Refinement('europeana_collectionName', $this->collectionName); $payload->addRefinement($refinement); $rows = 20; $this->page = isset($this->page) ? $this->page : 1; $offset = $this->page * $rows; $payload->setStart($offset); $payload->setRows($rows); return $payload; }