Skip to content

Commit 2d66f75

Browse files
author
Bohdan Korablov
committed
MAGETWO-58523: CLI Rollback doesn't work
1 parent fd12fa9 commit 2d66f75

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\Backup;
7+
8+
class FilesystemTest extends \PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @var \Magento\Framework\ObjectManagerInterface
12+
*/
13+
private $objectManager;
14+
15+
/**
16+
* @var \Magento\Framework\Backup\Filesystem
17+
*/
18+
private $filesystem;
19+
20+
protected function setUp()
21+
{
22+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
23+
$this->filesystem = $this->objectManager->create(\Magento\Framework\Backup\Filesystem::class);
24+
}
25+
26+
public function testRollback()
27+
{
28+
$rootDir = __DIR__ . '/_files';
29+
$backupsDir = $rootDir . '/var/backups';
30+
$fileName = 'test.txt';
31+
32+
$this->filesystem->setRootDir($rootDir)
33+
->setBackupsDir($backupsDir)
34+
->setTime(1474538269)
35+
->setName('code')
36+
->setBackupExtension('tgz');
37+
38+
$this->assertTrue($this->filesystem->rollback());
39+
$this->assertTrue(file_exists($rootDir . '/' . $fileName));
40+
$this->assertTrue(unlink($rootDir . '/' . $fileName));
41+
}
42+
}

lib/internal/Magento/Framework/Backup/Filesystem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ protected function getRollBackFtp()
316316
if (!$this->rollBackFtp) {
317317
$this->rollBackFtp = ObjectManager::getInstance()->create(
318318
\Magento\Framework\Backup\Filesystem\Rollback\Ftp::class,
319-
[$this]
319+
['snapshotObject' => $this]
320320
);
321321
}
322322

@@ -332,7 +332,7 @@ protected function getRollBackFs()
332332
if (!$this->rollBackFs) {
333333
$this->rollBackFs = ObjectManager::getInstance()->create(
334334
\Magento\Framework\Backup\Filesystem\Rollback\Fs::class,
335-
[$this]
335+
['snapshotObject' => $this]
336336
);
337337
}
338338

0 commit comments

Comments
 (0)