Skip to content
This repository
Browse code

UPDATED: Improved get_all_versions test case to test versions in the …

…middle of version updates.
  • Loading branch information...
commit 89728acece2611574c39516994022bf478e17b1a 1 parent 56fe7f8
Damian Mooyman authored August 20, 2012

Showing 1 changed file with 17 additions and 3 deletions. Show diff stats Hide diff stats

  1. 20  tests/model/VersionedTest.php
20  tests/model/VersionedTest.php
@@ -333,6 +333,20 @@ public function testAllVersions()
333 333
 		$testPage->ExtraField = '2007';
334 334
 		$testPage->write();
335 335
 		
  336
+		// Check both versions are returned
  337
+		$versions = Versioned::get_all_versions('VersionedTest_Subclass', $testPage->ID);
  338
+		$content = array();
  339
+		$extraFields = array();
  340
+		foreach($versions as $version)
  341
+		{
  342
+			$content[] = $version->Content;
  343
+			$extraFields[] = $version->ExtraField;
  344
+		}
  345
+		
  346
+		$this->assertEquals($versions->Count(), 2, 'All versions returned');
  347
+		$this->assertEquals($content, array('This is the content from 2005', "It's 2007 already!"), 'Version fields returned');
  348
+		$this->assertEquals($extraFields, array('2005', '2007'), 'Version fields returned');
  349
+		
336 350
 		// In 2009 we updated it again
337 351
 		SS_Datetime::set_mock_now('2009-01-01 00:00:00');
338 352
 		$testPage->Content = "I'm enjoying 2009";
@@ -351,9 +365,9 @@ public function testAllVersions()
351 365
 			$extraFields[] = $version->ExtraField;
352 366
 		}
353 367
 		
354  
-		$this->assertEquals($versions->Count(), 3, 'All versions returned');
355  
-		$this->assertEquals($content, array('This is the content from 2005', "It's 2007 already!", "I'm enjoying 2009"), 'Version fields returned');
356  
-		$this->assertEquals($extraFields, array('2005', '2007', '2009'), 'Version fields returned');
  368
+		$this->assertEquals($versions->Count(), 3, 'Additional all versions returned');
  369
+		$this->assertEquals($content, array('This is the content from 2005', "It's 2007 already!", "I'm enjoying 2009"), 'Additional version fields returned');
  370
+		$this->assertEquals($extraFields, array('2005', '2007', '2009'), 'Additional version fields returned');
357 371
 	}
358 372
 }
359 373
 

0 notes on commit 89728ac

Please sign in to comment.
Something went wrong with that request. Please try again.