Browse files

VersionTest: make tests run against bugtrackers with existing versions

  • Loading branch information...
1 parent 6cd4123 commit f5c2fb4f970a1de42731fe0104f9298da8902526 @rombert rombert committed Nov 11, 2011
Showing with 18 additions and 4 deletions.
  1. +18 −4 tests/soap/VersionTest.php
View
22 tests/soap/VersionTest.php
@@ -44,6 +44,8 @@ private function getTestVersion() {
* Tests creating a new version
*/
public function testAddVersion() {
+
+ $initialVersions = $this->countVersions();
$versionId = $this->client->mc_project_version_add($this->userName, $this->password, $this->getTestVersion() );
@@ -53,7 +55,7 @@ public function testAddVersion() {
$versions = $this->client->mc_project_get_versions( $this->userName, $this->password, $this->getProjectId() );
- $this->assertEquals(1, count($versions));
+ $this->assertEquals(1, count($versions) - $initialVersions);
$version = $versions[0];
@@ -70,6 +72,8 @@ public function testAddVersion() {
* Tests updating a version
*/
public function testUpdateVersion() {
+
+ $initialVersions = $this->countVersions();
$versionId = $this->client->mc_project_version_add($this->userName, $this->password, $this->getTestVersion() );
@@ -84,10 +88,20 @@ public function testUpdateVersion() {
$versions = $this->client->mc_project_get_versions( $this->userName, $this->password, $this->getProjectId() );
- $this->assertEquals(1, count($versions));
+ $this->assertEquals(1, count($versions) - $initialVersions);
- $version = $versions[0];
+ foreach ( $versions as $version ) {
+ if ( $version->id == $versionId ) {
+ $this->assertEquals('1.1', $version->name);
+ return;
+ }
+ }
- $this->assertEquals('1.1', $version->name);
+ self::fail('Did not find version with id ' . $versionId . ' in the reply');
+ }
+
+ private function countVersions() {
+
+ return count ( $this->client->mc_project_get_versions( $this->userName, $this->password, $this->getProjectId() ) );
}
}

0 comments on commit f5c2fb4

Please sign in to comment.