예제 #1
0
 /**
  * @depends testGetCollection
  */
 public function testSearchOnCollection()
 {
     $this->initContext();
     $collection = new RestoCollection('Landsat', $this->context, $this->admin, array('autoload' => true));
     $this->context->query = array('q' => 'summer');
     $searchResult = $collection->search();
     $searchResult = $searchResult->toArray();
     $errors = $searchResult['properties']['query']['analysis']['analyze']['Errors'];
     $features = $searchResult['features'];
     $this->assertEquals(0, count($errors));
     $this->assertEquals(0, count($features));
     /*
      * Test error - request not understood
      */
     $this->context->query = array('q' => 'nawak');
     $searchResult = $collection->search();
     $searchResult = $searchResult->toArray();
     $errors = $searchResult['properties']['query']['analysis']['analyze']['Errors'];
     $features = $searchResult['features'];
     $this->assertEquals(1, count($errors));
     $this->assertEquals(0, count($features));
     /*
      * Test year selection
      */
     $this->context->query = array('q' => '2011');
     $searchResult = $collection->search();
     $searchResult = $searchResult->toArray();
     $errors = $searchResult['properties']['query']['analysis']['analyze']['Errors'];
     $features = $searchResult['features'];
     $this->assertEquals(0, count($errors));
     $this->assertEquals(1, count($features));
     $this->assertEquals('c5dc1f32-002d-5ee9-bd4a-c690461eb734', $features[0]['id']);
     /*
      * Test empty results on year selection
      */
     $this->context->query = array('q' => '2012');
     $searchResult = $collection->search();
     $searchResult = $searchResult->toArray();
     $errors = $searchResult['properties']['query']['analysis']['analyze']['Errors'];
     $features = $searchResult['features'];
     $this->assertEquals(0, count($errors));
     $this->assertEquals(0, count($features));
     /*
      * Test model
      */
     $this->context->query = array('identifier' => 'LANDSAT5_TM_XS_20110520_N2A_France-MetropoleD0005H0003');
     $searchResult = $collection->search();
     $searchResult = $searchResult->toArray();
     $features = $searchResult['features'];
     $this->assertEquals(1, count($features));
     $this->assertEquals('c5dc1f32-002d-5ee9-bd4a-c690461eb734', $features[0]['id']);
     $this->assertEquals('Landsat', $features[0]['properties']['collection']);
     $this->assertEquals('Example', $features[0]['properties']['license']['licenseId']);
     $this->assertEquals('once', $features[0]['properties']['license']['hasToBeSigned']);
     $this->assertEquals('LANDSAT5_TM_XS_20110520_N2A_France-MetropoleD0005H0003', $features[0]['properties']['productIdentifier']);
     $this->assertEquals('urn:ogc:def:EOP:CNES::Landsat:', $features[0]['properties']['parentIdentifier']);
     $this->assertEquals('http:///resto/collections/Landsat/c5dc1f32-002d-5ee9-bd4a-c690461eb734/wms?map=/mount/landsat/wms/map.map&file=LANDSAT5_TM_XS_20110520_N2A_France-MetropoleD0005H0003&LAYERS=landsat&FORMAT=image%2Fpng&TRANSITIONEFFECT=resize&TRANSPARENT=true&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&STYLES=&SRS=EPSG%3A3857&BBOX={:bbox3857:}&WIDTH=256&HEIGHT=256', $features[0]['properties']['services']['browse']['layer']['url']);
     $this->assertEquals('http:///resto/collections/Landsat/c5dc1f32-002d-5ee9-bd4a-c690461eb734/download', $features[0]['properties']['services']['download']['url']);
     $this->assertEquals('http://spirit.cnes.fr/cgi-bin/mapserv?map=/mount/landsat/wms/map.map&file=LANDSAT5_TM_XS_20110520_N2A_France-MetropoleD0005H0003&LAYERS=landsat&FORMAT=image%2Fpng&TRANSITIONEFFECT=resize&TRANSPARENT=true&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&STYLES=&SRS=EPSG%3A3857&BBOX={:bbox3857:}&WIDTH=256&HEIGHT=256', $features[0]['properties']['wmsInfos']);
     $this->assertEquals('/mount/landsat/archives/LANDSAT5_TM_XS_20110520_N2A_France-MetropoleD0005H0003.tgz', $features[0]['properties']['resourceInfos']['path']);
     /*
      * Test identifier
      */
     $this->context->query = array('identifier' => 'XX');
     $searchResult = $collection->search();
     $searchResult = $searchResult->toArray();
     $features = $searchResult['features'];
     $this->assertEquals(0, count($features));
     $this->context->query = array('identifier' => 'c5dc1f32-002d-5ee9-bd4a-c690461eb734');
     $searchResult = $collection->search();
     $searchResult = $searchResult->toArray();
     $features = $searchResult['features'];
     $this->assertEquals(1, count($features));
     $this->assertEquals('c5dc1f32-002d-5ee9-bd4a-c690461eb734', $features[0]['id']);
     /*
      * Test startDate
      */
     $this->context->query = array('startDate' => '2011-01-01');
     $searchResult = $collection->search();
     $searchResult = $searchResult->toArray();
     $features = $searchResult['features'];
     $this->assertEquals(1, count($features));
     $this->assertEquals('c5dc1f32-002d-5ee9-bd4a-c690461eb734', $features[0]['id']);
     $this->context->query = array('startDate' => '2014-01-01');
     $searchResult = $collection->search();
     $searchResult = $searchResult->toArray();
     $features = $searchResult['features'];
     $this->assertEquals(0, count($features));
     /*
      * Test updated
      */
     $this->context->query = array('updated' => '2015-01-01');
     $searchResult = $collection->search();
     $searchResult = $searchResult->toArray();
     $features = $searchResult['features'];
     $this->assertEquals(1, count($features));
     $this->assertEquals('c5dc1f32-002d-5ee9-bd4a-c690461eb734', $features[0]['id']);
     $this->context->query = array('updated' => '2016-01-01');
     $searchResult = $collection->search();
     $searchResult = $searchResult->toArray();
     $features = $searchResult['features'];
     $this->assertEquals(0, count($features));
 }