/**
  * Test that an object can not be added to a closed changeset.
  * A changeset is closed after it has been committed.
  *
  * @expectedException        Services_OpenStreetMap_RuntimeException
  * @expectedExceptionMessage Object added to closed changeset
  *
  * @return void
  */
 public function testObjectAddedToChangesetAfterCommit()
 {
     if (!file_exists($this->credentialsFile)) {
         $this->markTestSkipped('Credentials file does not exist.');
     }
     $wayId = 30357328;
     $way2Id = 30357329;
     $mock = new HTTP_Request2_Adapter_Mock();
     $mock->addResponse(fopen(__DIR__ . '/responses/capabilities.xml', 'rb'));
     $mock->addResponse(fopen(__DIR__ . '/responses/changeset_id', 'rb'));
     $mock->addResponse(fopen(__DIR__ . '/responses/way_30357328_30357329.xml', 'rb'));
     $mock->addResponse(fopen(__DIR__ . '/responses/diff_30357328_30357329.xml', 'rb'));
     $mock->addResponse(fopen(__DIR__ . '/responses/changeset_closed', 'rb'));
     $config = array('adapter' => $mock, 'server' => 'http://api06.dev.openstreetmap.org/', 'passwordfile' => $this->credentialsFile);
     $osm = new Services_OpenStreetMap($config);
     try {
         $changeset = $osm->createChangeset();
     } catch (Services_OpenStreetMap_Exception $e) {
     }
     $this->assertEquals(false, $changeset->isOpen());
     $ways = $osm->getWays($wayId, $way2Id);
     $changeset->begin('Undo accidental highway change from residential to service');
     foreach ($ways as $way) {
         $way->setTag('highway', 'residential');
         $way->setTag('lit', 'yes');
         $changeset->add($way);
     }
     $this->assertEquals(true, $changeset->isOpen());
     $changeset->commit();
     $lat = 52.8638729;
     $lon = -8.1983611;
     $tags = array('building' => 'yes', 'amenity' => 'vet');
     $node = $osm->createNode($lat, $lon, $tags);
     $changeset->add($node);
 }
예제 #2
0
 /**
  * Retrieve multiple (2) ways.
  *
  * @return void
  */
 public function testGetWays()
 {
     $wayId = 30357328;
     $way2Id = 30357329;
     $mock = new HTTP_Request2_Adapter_Mock();
     $mock->addResponse(fopen(__DIR__ . '/responses/capabilities.xml', 'rb'));
     $mock->addResponse(fopen(__DIR__ . '/responses/way_30357328_30357329.xml', 'rb'));
     $config = array('adapter' => $mock, 'server' => 'http://api06.dev.openstreetmap.org/');
     $osm = new Services_OpenStreetMap($config);
     $ways = $osm->getWays($wayId, $way2Id);
     foreach ($ways as $key => $way) {
         $this->assertEquals($way, $ways[$key]);
     }
 }