1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Update\Queue;
class JobRollbackTest extends \PHPUnit\Framework\TestCase
{
/** @var string */
protected $maintenanceFlagFilePath;
/** @var string */
protected $updateErrorFlagFilePath;
protected function setUp()
{
parent::setUp();
$this->maintenanceFlagFilePath = TESTS_TEMP_DIR . '/.maintenance.flag';
$this->updateErrorFlagFilePath = TESTS_TEMP_DIR . '/.update_error.flag';
}
protected function tearDown()
{
parent::tearDown();
if (file_exists($this->maintenanceFlagFilePath)) {
unlink($this->maintenanceFlagFilePath);
}
if (file_exists($this->updateErrorFlagFilePath)) {
unlink($this->updateErrorFlagFilePath);
}
}
public function testManualRollbackBackupFileUnavailable()
{
$backupFileName = UPDATER_BP . '/dev/tests/integration/testsuite/Magento/Update/_files/backup/' . 'fake.zip';
$maintenanceMode = new \Magento\Update\MaintenanceMode(
$this->maintenanceFlagFilePath,
$this->updateErrorFlagFilePath
);
$jobRollback = new \Magento\Update\Queue\JobRollback(
'rollback',
['backup_file_name' => $backupFileName],
new \Magento\Update\Status(),
$maintenanceMode
);
$this->expectException('RuntimeException');
$this->expectExceptionMessage(sprintf(
'Cannot create phar \'%s\', file extension (or combination) not recognised' .
' or the directory does not exist',
$backupFileName
));
$jobRollback->execute();
}
}