Skip to content
This repository
Browse code

REMOVED: Unnecessary publish actions from test cases

ADDED: Test case for get_all_versions
  • Loading branch information...
commit 56fe7f881a71ad0d8582d16bdd116c408199700e 1 parent 0f09305
Damian Mooyman authored August 20, 2012

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

  1. 42  tests/model/VersionedTest.php
42  tests/model/VersionedTest.php
@@ -276,21 +276,18 @@ public function testArchiveVersion() {
276 276
 		$testPage->Content = 'This is the content from 2005';
277 277
 		$testPage->ExtraField = '2005';
278 278
 		$testPage->write();
279  
-		$testPage->publish('Stage', 'Live');
280 279
 		
281 280
 		// In 2007 we updated it
282 281
 		SS_Datetime::set_mock_now('2007-01-01 00:00:00');
283 282
 		$testPage->Content = "It's 2007 already!";
284 283
 		$testPage->ExtraField = '2007';
285 284
 		$testPage->write();
286  
-		$testPage->publish('Stage', 'Live');
287 285
 		
288 286
 		// In 2009 we updated it again
289 287
 		SS_Datetime::set_mock_now('2009-01-01 00:00:00');
290 288
 		$testPage->Content = "I'm enjoying 2009";
291 289
 		$testPage->ExtraField = '2009';
292 290
 		$testPage->write();
293  
-		$testPage->publish('Stage', 'Live');
294 291
 		
295 292
 		// End mock, back to the present day:)
296 293
 		SS_Datetime::clear_mock_now();
@@ -319,6 +316,45 @@ public function testArchiveVersion() {
319 316
 		$this->assertEquals("2009", $testPageCurrent->ExtraField);
320 317
 		$this->assertEquals("I'm enjoying 2009", $testPageCurrent->Content);
321 318
 	}
  319
+
  320
+	public function testAllVersions()
  321
+	{
  322
+		// In 2005 this file was created
  323
+		SS_Datetime::set_mock_now('2005-01-01 00:00:00');
  324
+		$testPage = new VersionedTest_Subclass();
  325
+		$testPage->Title = 'Archived page';
  326
+		$testPage->Content = 'This is the content from 2005';
  327
+		$testPage->ExtraField = '2005';
  328
+		$testPage->write();
  329
+		
  330
+		// In 2007 we updated it
  331
+		SS_Datetime::set_mock_now('2007-01-01 00:00:00');
  332
+		$testPage->Content = "It's 2007 already!";
  333
+		$testPage->ExtraField = '2007';
  334
+		$testPage->write();
  335
+		
  336
+		// In 2009 we updated it again
  337
+		SS_Datetime::set_mock_now('2009-01-01 00:00:00');
  338
+		$testPage->Content = "I'm enjoying 2009";
  339
+		$testPage->ExtraField = '2009';
  340
+		$testPage->write();
  341
+		
  342
+		// End mock, back to the present day:)
  343
+		SS_Datetime::clear_mock_now();
  344
+		
  345
+		$versions = Versioned::get_all_versions('VersionedTest_Subclass', $testPage->ID);
  346
+		$content = array();
  347
+		$extraFields = array();
  348
+		foreach($versions as $version)
  349
+		{
  350
+			$content[] = $version->Content;
  351
+			$extraFields[] = $version->ExtraField;
  352
+		}
  353
+		
  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');
  357
+	}
322 358
 }
323 359
 
324 360
 class VersionedTest_DataObject extends DataObject implements TestOnly {

0 notes on commit 56fe7f8

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