Skip to content

Commit

Permalink
remove readonly property work for the moment, instead test generator …
Browse files Browse the repository at this point in the history
…value
  • Loading branch information
kenguest committed Apr 10, 2012
1 parent 5edc1e0 commit 2d8964c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 11 deletions.
37 changes: 26 additions & 11 deletions Services/OpenStreetMap/Config.php
Expand Up @@ -74,13 +74,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
*
Expand Down Expand Up @@ -113,6 +106,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.
Expand Down Expand Up @@ -375,6 +376,7 @@ private function _checkCapabilities($capabilities)
);
}
$this->timeout = (int) $this->getXmlValue($xml, 'timeout', 'seconds');

//changesets
$this->changesetMaximumElements = (int) $this->getXmlValue(
$xml,
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -516,6 +521,16 @@ public function getMaxElements()
return $this->changesetMaximumElements;
}

/**
* Name of what generated the Capabilities XML
*
* @return string
*/
public function getGenerator()
{
return $this->generator;
}

/**
* getXmlValue
*
Expand Down
28 changes: 28 additions & 0 deletions tests/ConfigTest.php
Expand Up @@ -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:
?>
14 changes: 14 additions & 0 deletions 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>

0 comments on commit 2d8964c

Please sign in to comment.