public function testArchive() { if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $this->markTestSkipped(); } $jobName = 'Backup'; $jobStatus = new \Magento\Update\Status(); $jobStatus->clear(); $backupInfo = $this->getMockBuilder('Magento\\Update\\Backup\\BackupInfo')->disableOriginalConstructor()->getMock(); $backupInfo->expects($this->any())->method('generateBackupFilename')->willReturn($this->backupFilename); $backupInfo->expects($this->any())->method('getArchivedDirectory')->willReturn(UPDATER_BP); $backupInfo->expects($this->any())->method('getBlacklist')->willReturn(['var/backup', 'vendor', 'app/code']); $backupInfo->expects($this->any())->method('getBackupPath')->willReturn($this->backupPath); $maintenanceMode = new MaintenanceMode(TESTS_TEMP_DIR . '/maintenanceMode.flag', TESTS_TEMP_DIR . '/maintenanceAddress.flag'); $jobBackup = new \Magento\Update\Queue\JobBackup($jobName, [], $jobStatus, $maintenanceMode, $backupInfo); $this->dirList = scandir($this->backupPath); $jobBackup->execute(); $tmpFiles = array_diff(scandir($this->backupPath), $this->dirList); $actualBackupFile = array_pop($tmpFiles); $this->assertEquals($this->backupFilename, $actualBackupFile); $actualJobStatus = $jobStatus->get(); $fullBackupFileName = $this->backupPath . $this->backupFilename; $this->assertContains(sprintf('Creating backup archive "%s" ...', $fullBackupFileName), $actualJobStatus); $this->assertContains(sprintf('Backup archive "%s" has been created.', $fullBackupFileName), $actualJobStatus); if (file_exists($this->backupPath . $actualBackupFile)) { unlink($this->backupPath . $actualBackupFile); } }
public function testClearNotExistingFile() { unlink($this->tmpStatusFilePath); $this->assertFalse(file_exists($this->tmpStatusFilePath), "Precondition failed."); $status = new \Magento\Update\Status($this->tmpStatusFilePath); $this->assertInstanceOf('Magento\\Update\\Status', $status->clear()); $this->assertFalse(file_exists($this->tmpStatusFilePath)); }
$status->add($error, \Psr\Log\LogLevel::WARNING); } unset($backupPaths['error']); } foreach (array_values($backupPaths) as $backupPath) { $queue->addJobs(['jobs' => ['name' => $backupPath['type'], 'params' => ['backup_file_name' => $backupPath['filename']]]]); } $status->setUpdateError(false); } catch (\Exception $e) { $status->setUpdateError(true); $status->add('Error in Rollback:' . $e->getMessage(), \Psr\Log\LogLevel::ERROR); } } elseif ($_SERVER['PATH_INFO'] === '/status') { $complete = !$status->isUpdateInProgress() && $queue->isEmpty() && !$status->isUpdateError(); if ($complete) { $status->clear(); } echo json_encode(['statusMessage' => $statusMessage, 'isUpdateInProgress' => $isUpdateInProgress, 'complete' => $complete, 'error' => $status->isUpdateError(), 'pending' => $pending]); } } else { if (!file_exists(MAGENTO_BP . '/app/etc/config.php') || !file_exists(MAGENTO_BP . '/app/etc/env.php')) { header('Location: ../setup'); die; } $type = 'default'; $titles = []; $defaultHeaderTitle = 'Magento Updater'; if (file_exists(MAGENTO_BP . '/var/.type.json')) { $typeFlag = json_decode(file_get_contents(MAGENTO_BP . '/var/.type.json'), true); $headerTitle = isset($typeFlag['headerTitle']) ? $typeFlag['headerTitle'] : $defaultHeaderTitle; $titles = $typeFlag['titles'];