/** * Test uninstall() when error is triggered */ public function testUninstallWithError() { $this->model = $this->getModelMock(); $this->directoryMock->expects($this->exactly(2))->method('delete')->with($this->logicalOr($this->equalTo(TESTS_TEMP_DIR), $this->equalTo('local.xml')))->will($this->throwException(new \Magento\Framework\Filesystem\FilesystemException(sprintf('The file "%s" cannot be deleted %s', TESTS_TEMP_DIR, "Warning")))); $expectedString = str_repeat(sprintf('Please delete the file manually : "%s" ' . "\n", TESTS_TEMP_DIR), 2); $this->filesystemMock->expects($this->any())->method('getDirectoryWrite')->will($this->returnValue($this->directoryMock)); $this->expectOutputString($expectedString); $result = $this->model->uninstall(); $this->assertTrue($result); }
/** * Install/Uninstall application * * @param \Magento\Install\Model\Installer\Console $installer * @return void */ protected function _handleInstall(\Magento\Install\Model\Installer\Console $installer) { if (isset($this->_arguments['config']) && $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($this->_arguments['config']))) { $config = (array) (include $this->_arguments['config']); $this->_arguments = array_merge((array) $config, $this->_arguments); } $isUninstallMode = isset($this->_arguments['uninstall']); if ($isUninstallMode) { $result = $installer->uninstall(); } else { $result = $installer->install($this->_arguments); } if (!$installer->hasErrors()) { if ($isUninstallMode) { $msg = $result ? 'Uninstalled successfully' : 'Ignoring attempt to uninstall non-installed application'; } else { $msg = 'Installed successfully' . ($result ? ' (encryption key "' . $result . '")' : ''); } $this->_output->success($msg . PHP_EOL); } else { $this->_output->error(implode(PHP_EOL, $installer->getErrors()) . PHP_EOL); } }