protected function getSerializedQuery(Query $query) { $selectionRequests = array(); foreach ($query->getSelectionRequests() as $selectionRequest) { $selectionRequests[] = $this->componentSerializer->serialize($selectionRequest); } return array('objectType' => 'query', 'description' => $this->componentSerializer->serialize($query->getDescription()), 'options' => $this->componentSerializer->serialize($query->getOptions()), 'selectionRequests' => $selectionRequests); }
/** * @dataProvider selectionRequestsProvider * * @param array $selectionRequests */ public function testGetSelectionRequests(array $selectionRequests) { $query = new Query(new AnyValue(), $selectionRequests, new QueryOptions(100, 0)); $obtainedRequests = $query->getSelectionRequests(); $this->assertInternalType('array', $obtainedRequests); $this->assertContainsOnlyInstancesOf('\\Ask\\Language\\Selection\\SelectionRequest', $obtainedRequests); $this->assertEquals($selectionRequests, $obtainedRequests); }