Pantheon\Terminus\UnitTests\Models\BackupTest::testRestore PHP Method

testRestore() public method

public testRestore ( )
    public function testRestore()
    {
        $workflow = $this->getMockBuilder(Workflow::class)->disableOriginalConstructor()->getMock();
        $backup = $this->_getBackup(['id' => 'scheduledfor_archivetype_code', 'filename' => 'def.tgz']);
        $this->workflows->expects($this->once())->method('create')->with('restore_code', ['params' => ['key' => "abc/dev/def.tgz", 'bucket' => 'pantheon-backups']])->willReturn($workflow);
        $this->assertEquals($workflow, $backup->restore());
        $backup = $this->_getBackup(['id' => 'scheduledfor_archivetype_files', 'filename' => 'def.tgz']);
        $this->workflows->expects($this->once())->method('create')->with('restore_files', ['params' => ['key' => "abc/dev/def.tgz", 'bucket' => 'pantheon-backups']])->willReturn($workflow);
        $this->assertEquals($workflow, $backup->restore());
        $backup = $this->_getBackup(['id' => 'scheduledfor_archivetype_database', 'filename' => 'def.tgz']);
        $this->workflows->expects($this->once())->method('create')->with('restore_database', ['params' => ['key' => "abc/dev/def.tgz", 'bucket' => 'pantheon-backups']])->willReturn($workflow);
        $this->assertEquals($workflow, $backup->restore());
        $backup = $this->_getBackup(['id' => 'scheduledfor_archivetype_xyz', 'filename' => 'def.tgz']);
        $this->setExpectedException(TerminusException::class, 'This backup has no archive to restore.');
        $this->assertNull($backup->restore());
    }