public function testSuccessful()
 {
     $pipeline = $this->getDummyPipeline();
     // Start failure
     $pipeline->markFailed();
     $step = $pipeline->RollbackStep1();
     // Assert not error at startup
     $this->assertEquals('Started', $step->Status);
     $this->assertEquals('Deployment', $step->Doing);
     $this->assertNotLogged('Maintenance page disabled');
     // Shouldn't be disabled yet
     // Mark the service as completed and check result
     $deployment = $step->RollbackDeployment();
     $deployment->markFinished();
     // Re-enter step as if called from checkPipelineStatus
     PipelineTest_MockLog::clear();
     $step->start();
     $this->assertEquals('Started', $step->Status);
     $this->assertEquals('Snapshot', $step->Doing);
     $this->assertNotLogged('Maintenance page disabled');
     // Shouldn't be disabled yet
     // Mark the snapshot as completed and check result
     $snapshot = $step->RollbackDatabase();
     $snapshot->markFinished();
     // Re-enter step as if called from checkPipelineStatus
     PipelineTest_MockLog::clear();
     $step->start();
     $this->assertEquals('Finished', $step->Status);
     // confirm the maintenace page has been left up for a failed rollback
     $this->assertFalse(PipelineTest_MockLog::has_message('Enabling maintenance page for failed rollback'));
 }
 public function testTimeout()
 {
     $step = $this->getDummyDeployment();
     $step->start();
     // Assert not error at startup
     $this->assertEquals('Started', $step->Status);
     $this->assertTrue(PipelineTest_MockLog::has_message('TestDeployStep:Snapshot creating snapshot of database'));
     // Go to two hours into the future
     SS_Datetime::set_mock_now(date('Y-m-d H:i:s', strtotime('+2 hours')));
     // Retry step
     PipelineTest_MockLog::clear();
     $step->start();
     $this->assertEquals('Failed', $step->Status);
     $this->assertTrue($step->isTimedOut());
     $this->assertTrue(PipelineTest_MockLog::has_message('Checking status of TestDeployStep:Snapshot...'));
     $this->assertTrue(PipelineTest_MockLog::has_message('TestDeployStep:Snapshot took longer than 3600 seconds to run and has timed out'));
 }
 protected function assertNotLogged($message)
 {
     $this->assertFalse(PipelineTest_MockLog::has_message($message), "Assert not logged \"{$message}\"");
 }