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 testGetEmptyFile() { file_put_contents($this->tmpStatusFilePath, ''); $status = new \Magento\Update\Status($this->tmpStatusFilePath); $this->assertEquals('', $status->get()); }
<?php /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ require_once __DIR__ . '/app/bootstrap.php'; $status = new \Magento\Update\Status(); $statusMessage = $status->get(10); $isUpdateInProgress = $status->isUpdateInProgress(); /** TODO: Section below is added for demo purposes */ $status->add("Message #" . rand(1, 1000)); if (!$statusMessage) { $statusMessage = 'Please wait for job processing to start.'; } $statusMessage = str_replace("\n", "<br />", $statusMessage); //$isUpdateInProgress = (bool)rand(0, 1); /** TODO: End of section added for demo */ if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { /* Ajax request processing */ echo json_encode(['statusMessage' => $statusMessage, 'isUpdateInProgress' => $isUpdateInProgress]); } else { include __DIR__ . '/app/code/Magento/Update/view/templates/status.phtml'; }
* Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ require_once __DIR__ . '/app/bootstrap.php'; header('X-Frame-Options: SAMEORIGIN'); header('X-Content-Type-Options: nosniff'); if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8') === false) { $xssHeaderValue = '1; mode=block'; } else { $xssHeaderValue = '0'; } header('X-XSS-Protection: ' . $xssHeaderValue); $status = new \Magento\Update\Status(); $isUpdateInProgress = $status->isUpdateInProgress(); $statusMessage = ''; $statusMessage .= $status->get(); $statusMessage = str_replace("\n", "<br />", $statusMessage); $queue = new \Magento\Update\Queue(); $pending = !$status->isUpdateInProgress() && !$queue->isEmpty() && !$status->isUpdateError(); if (isset($_SERVER['PATH_INFO']) && !empty($_SERVER['PATH_INFO'])) { if ($_SERVER['PATH_INFO'] === '/rollback' && file_exists(MAGENTO_BP . '/var/.update_error.flag')) { try { $queue->clear(); $backupInfo = new \Magento\Update\Backup\BackupInfo(); $backupPaths = $backupInfo->getBackupFilePaths(); if (isset($backupPaths['error'])) { $status->add('WARNING: There is a problem with backup files! Performing rollback from these' . ' files may cause the Magento application to be unstable', \Psr\Log\LogLevel::WARNING); foreach ($backupPaths['error'] as $error) { $status->add($error, \Psr\Log\LogLevel::WARNING); } unset($backupPaths['error']);