Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

if file 'credentials' doesn't exist, attempt to use 'credentials.dist…

…' instead.
  • Loading branch information...
commit d1e52c9e80f78d020ebd8892aef47b7e97dabc7b 1 parent 1afa58d
@kenguest authored
Showing with 33 additions and 16 deletions.
  1. +33 −16 tests/ChangesetTest.php
View
49 tests/ChangesetTest.php
@@ -37,6 +37,23 @@
*/
class ChangesetTest extends PHPUnit_Framework_TestCase
{
+ protected $credentialsFile = '/credentials';
+
+ /**
+ * Setup - if there is a 'credentials' file, use it. Otherwise fall back to
+ * using the credentials.dist file.
+ *
+ * @return void
+ */
+ public function setup()
+ {
+ if (file_exists(__DIR__ . $this->credentialsFile)) {
+ $this->credentialsFile = __DIR__ . $this->credentialsFile;
+ } else {
+ $this->credentialsFile = __DIR__ . '/credentials.dist';
+ }
+ }
+
/**
* Retrieve a changeset and check its attributes are as expected.
*
@@ -133,7 +150,7 @@ public function testChange()
$wayId = 30357328;
$way2Id = 30357329;
- if (!file_exists(__DIR__ . '/credentials')) {
+ if (!file_exists($this->credentialsFile)) {
$this->markTestSkipped('Credentials file does not exist.');
}
@@ -153,7 +170,7 @@ public function testChange()
$config = array(
'adapter' => $mock,
'server' => 'http://api06.dev.openstreetmap.org/',
- 'passwordfile' => __DIR__ . '/credentials'
+ 'passwordfile' => $this->credentialsFile
);
$osm = new Services_OpenStreetMap($config);
try {
@@ -192,7 +209,7 @@ public function testChange()
*/
public function testObjectAddedToChangesetAfterCommit()
{
- if (!file_exists(__DIR__ . '/credentials')) {
+ if (!file_exists($this->credentialsFile)) {
$this->markTestSkipped('Credentials file does not exist.');
}
@@ -213,7 +230,7 @@ public function testObjectAddedToChangesetAfterCommit()
$config = array(
'adapter' => $mock,
'server' => 'http://api06.dev.openstreetmap.org/',
- 'passwordfile' => __DIR__ . '/credentials'
+ 'passwordfile' => $this->credentialsFile
);
$osm = new Services_OpenStreetMap($config);
try {
@@ -249,7 +266,7 @@ public function testObjectAddedToChangesetAfterCommit()
*/
public function testSameObjectAddedToChangeset()
{
- if (!file_exists(__DIR__ . '/credentials')) {
+ if (!file_exists($this->credentialsFile)) {
$this->markTestSkipped('Credentials file does not exist.');
}
@@ -268,7 +285,7 @@ public function testSameObjectAddedToChangeset()
$config = array(
'adapter' => $mock,
'server' => 'http://api06.dev.openstreetmap.org/',
- 'passwordfile' => __DIR__ . '/credentials'
+ 'passwordfile' => $this->credentialsFile
);
$osm = new Services_OpenStreetMap($config);
try {
@@ -301,7 +318,7 @@ public function testSameObjectAddedToChangeset()
*/
public function testDeleteNode()
{
- if (!file_exists(__DIR__ . '/credentials')) {
+ if (!file_exists($this->credentialsFile)) {
$this->markTestSkipped('Credentials file does not exist.');
}
@@ -320,7 +337,7 @@ public function testDeleteNode()
$config = array(
'adapter' => $mock,
'server' => 'http://api06.dev.openstreetmap.org/',
- 'passwordfile' => __DIR__ . '/credentials'
+ 'passwordfile' => $this->credentialsFile
);
$osm = new Services_OpenStreetMap($config);
try {
@@ -351,7 +368,7 @@ public function testDeleteNode()
*/
public function testDeleteNodeClosingError404()
{
- if (!file_exists(__DIR__ . '/credentials')) {
+ if (!file_exists($this->credentialsFile)) {
$this->markTestSkipped('Credentials file does not exist.');
}
@@ -369,7 +386,7 @@ public function testDeleteNodeClosingError404()
$config = array(
'adapter' => $mock,
'server' => 'http://api06.dev.openstreetmap.org/',
- 'passwordfile' => __DIR__ . '/credentials'
+ 'passwordfile' => $this->credentialsFile
);
$osm = new Services_OpenStreetMap($config);
try {
@@ -397,7 +414,7 @@ public function testDeleteNodeClosingError404()
*/
public function testDeleteNodeClosingError400()
{
- if (!file_exists(__DIR__ . '/credentials')) {
+ if (!file_exists($this->credentialsFile)) {
$this->markTestSkipped('Credentials file does not exist.');
}
@@ -423,7 +440,7 @@ public function testDeleteNodeClosingError400()
$config = array(
'adapter' => $mock,
'server' => 'http://api06.dev.openstreetmap.org/',
- 'passwordfile' => __DIR__ . '/credentials'
+ 'passwordfile' => $this->credentialsFile
);
$osm = new Services_OpenStreetMap($config);
try {
@@ -451,7 +468,7 @@ public function testDeleteNodeClosingError400()
*/
public function testDeleteNodeDiffError400()
{
- if (!file_exists(__DIR__ . '/credentials')) {
+ if (!file_exists($this->credentialsFile)) {
$this->markTestSkipped('Credentials file does not exist.');
}
@@ -466,7 +483,7 @@ public function testDeleteNodeDiffError400()
$config = array(
'adapter' => $mock,
'server' => 'http://api06.dev.openstreetmap.org/',
- 'passwordfile' => __DIR__ . '/credentials'
+ 'passwordfile' => $this->credentialsFile
);
$osm = new Services_OpenStreetMap($config);
try {
@@ -492,7 +509,7 @@ public function testDeleteNodeDiffError400()
*/
public function testSaveNode()
{
- if (!file_exists(__DIR__ . '/credentials')) {
+ if (!file_exists($this->credentialsFile)) {
$this->markTestSkipped('Credentials file does not exist.');
}
@@ -504,7 +521,7 @@ public function testSaveNode()
$config = array(
'adapter' => $mock,
'server' => 'http://api06.dev.openstreetmap.org/',
- 'passwordfile' => __DIR__ . '/credentials',
+ 'passwordfile' => $this->credentialsFile
);
$osm = new Services_OpenStreetMap($config);
$lat = 52.8638729;
Please sign in to comment.
Something went wrong with that request. Please try again.