/**
  *
  */
 public function testWriteToStages_ManyPages_WritesObjectsToStage()
 {
     $sizes = array(10, 30, 100, 300);
     foreach ($sizes as $size) {
         $writer = new \BatchedWriter($size);
         $pages = array();
         for ($i = 0; $i < 100; $i++) {
             $page = new DogPage();
             $page->Title = 'Wonder Pup  ' . $i;
             $pages[] = $page;
         }
         $writer->writeToStage($pages, 'Stage');
         $writer->finish();
         $currentStage = \Versioned::current_stage();
         \Versioned::reading_stage('Stage');
         $this->assertEquals(100, DogPage::get()->Count());
         \Versioned::reading_stage('Live');
         $this->assertEquals(0, DogPage::get()->Count());
         $writer->writeToStage($pages, 'Live');
         $writer->finish();
         \Versioned::reading_stage('Live');
         $this->assertEquals(100, DogPage::get()->Count());
         \Versioned::reading_stage($currentStage);
         $writer->deleteFromStage($pages, 'Stage', 'Live');
         $writer->finish();
         $this->assertEquals(0, DogPage::get()->Count());
     }
 }
 /**
  *
  */
 public function testBatchDelete_VersionedObject_ObjectsDeleted()
 {
     $pages = array();
     for ($i = 0; $i < 100; $i++) {
         $page = new DogPage();
         $page->Title = 'Hero Dog ' . $i;
         $page->writeToStage('Stage');
         $page->publish('Stage', 'Live');
         $pages[] = $page;
     }
     $batch = new \Batch();
     $currentStage = \Versioned::current_stage();
     \Versioned::reading_stage('Live');
     $this->assertEquals(100, DogPage::get()->Count());
     $batch->deleteFromStage($pages, 'Live');
     $this->assertEquals(0, DogPage::get()->Count());
     \Versioned::reading_stage('Stage');
     $this->assertEquals(100, DogPage::get()->Count());
     $batch->deleteFromStage($pages, 'Stage');
     $this->assertEquals(0, DogPage::get()->Count());
     \Versioned::reading_stage($currentStage);
 }
 /**
  *
  */
 public function testBatchWrite_WriteObjectToStageAndLive_WritesStageAndLive()
 {
     $page = new DogPage();
     $page->Title = 'WOOF';
     $page->Author = 'Woof Woof';
     $batch = new \Batch();
     $batch->writeToStage(array($page), 'Stage', 'Live');
     $this->assertEquals(1, $page->ID);
     $currentStage = \Versioned::current_stage();
     \Versioned::reading_stage('Stage');
     $page = DogPage::get()->first();
     $this->assertNotNull($page);
     $this->assertEquals('WOOF', $page->Title);
     $this->assertEquals('Woof Woof', $page->Author);
     \Versioned::reading_stage('Live');
     $page = DogPage::get()->first();
     $this->assertNotNull($page);
     $this->assertEquals('WOOF', $page->Title);
     $this->assertEquals('Woof Woof', $page->Author);
     \Versioned::reading_stage($currentStage);
 }