Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove readonly property work for the moment, instead test generator …

…value
  • Loading branch information...
commit 2d8964ca8ae2525d303fe1bbe15dabf5c60d854a 1 parent 5edc1e0
@kenguest authored
View
37 Services/OpenStreetMap/Config.php
@@ -75,13 +75,6 @@ class Services_OpenStreetMap_Config
protected $areaMaximum = null;
/**
- * State of server - can updates be accepted? (experimental)
- * @var boolean
- * @internal
- */
- protected $readOnly = null;
-
- /**
* Default config settings
*
* @var array
@@ -114,6 +107,14 @@ class Services_OpenStreetMap_Config
protected $server = 'http://api.openstreetmap.org/';
/**
+ * Capabilities XML generated by...
+ *
+ * @var string
+ * @internal
+ */
+ protected $generator = 'Generator';
+
+ /**
* Get the value of a configuration setting - if none is set all are
* returned.
*
@@ -375,6 +376,7 @@ private function _checkCapabilities($capabilities)
);
}
$this->timeout = (int) $this->getXmlValue($xml, 'timeout', 'seconds');
+
//changesets
$this->changesetMaximumElements = (int) $this->getXmlValue(
$xml,
@@ -402,12 +404,15 @@ private function _checkCapabilities($capabilities)
'area',
'maximum'
);
- $this->readOnly = (bool) $this->getXmlValue(
+
+ // What generated the XML.
+ $this->generator = '' . $this->getXmlValue(
$xml,
- 'status',
- 'readonly',
- false
+ 'osm',
+ 'generator',
+ 'OpenStreetMap server'
);
+
return true;
}
@@ -517,6 +522,16 @@ public function getMaxElements()
}
/**
+ * Name of what generated the Capabilities XML
+ *
+ * @return string
+ */
+ public function getGenerator()
+ {
+ return $this->generator;
+ }
+
+ /**
* getXmlValue
*
* @param SimpleXMLElement $xml Object
View
28 tests/ConfigTest.php
@@ -398,6 +398,34 @@ public function testMultiLinedPasswordFileExplicitMethod()
$config = $osm->getConfig();
$this->assertEquals($config->getValue('password'), 'Wilma4evah');
}
+
+ public function testGenerator()
+ {
+ $mock = new HTTP_Request2_Adapter_Mock();
+ $mock->addResponse(fopen(__DIR__ . '/responses/capabilities.xml', 'rb'));
+
+ $config = array(
+ 'api_version' => '0.6',
+ 'adapter' => $mock,
+ 'password' => null,
+ 'passwordfile' => null,
+ 'user' => null,
+ 'verbose' => false,
+ 'User-Agent' => 'Services_OpenStreetMap',
+ 'server' => 'http://api06.dev.openstreetmap.org/'
+ );
+ $osm = new Services_OpenStreetMap($config);
+ $generator = $osm->getConfig()->getGenerator();
+ $this->assertEquals($generator, 'OpenStreetMap server');
+
+ $mock2 = new HTTP_Request2_Adapter_Mock();
+ $mock2->addResponse(fopen(__DIR__ . '/responses/capabilities_jxapi.xml', 'rb'));
+
+ $config['adapter'] = $mock2;
+ $osm = new Services_OpenStreetMap($config);
+ $generator = $osm->getConfig()->getGenerator();
+ $this->assertEquals($generator, 'Java XAPI Server');
+ }
}
// vim:set et ts=4 sw=4:
?>
View
14 tests/responses/capabilities_jxapi.xml
@@ -0,0 +1,14 @@
+HTTP/1.1 200 OK
+
+<osm version="0.6" generator="Java XAPI Server" xmlns:xapi="http://jxapi.openstreetmap.org/" xapi:planetDate="Mon, 10 Apr 2012 13:58:17 GMT">
+ <!-- Note that since this server only supports XAPI, only the area maximum is real. -->
+ <api>
+ <version minimum="0.6" maximum="0.6"/>
+ <area maximum="0.12"/>
+ <tracepoints per_page="5000"/>
+ <waynodes maximum="2000"/>
+ <changesets maximum_elements="50000"/>
+ <timeout seconds="300"/>
+ </api>
+</osm>
+
Please sign in to comment.
Something went wrong with that request. Please try again.