/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $adminUserName = $input->getArgument(AdminAccount::KEY_USER); $modules = []; if ($input->getOption(self::INPUT_KEY_MODULES)) { $modules = $this->getRequestedModules($input->getOption(self::INPUT_KEY_MODULES)); } $logger = new ConsoleLogger($output); $this->sampleData->install($this->objectManager, $logger, $adminUserName, $modules); $output->writeln('<info>' . 'Successfully installed sample data.' . '</info>'); }
/** * @return ViewModel */ public function indexAction() { $view = new ViewModel([ 'timezone' => $this->list->getTimezoneList(), 'currency' => $this->list->getCurrencyList(), 'language' => $this->list->getLocaleList(), 'isSampledataEnabled' => $this->sampleData->isDeployed(), 'isSampleDataInstalled' => $this->sampleData->isInstalledSuccessfully(), 'isSampleDataErrorInstallation' => $this->sampleData->isInstallationError() ]); $view->setTerminal(true); return $view; }
/** * @param array $expected * * @dataProvider indexActionDataProvider */ public function testIndexAction($expected) { $this->sampleData->expects($this->once())->method('isDeployed')->willReturn($expected['isSampledataEnabled']); $this->sampleData->expects($this->once())->method('isInstalledSuccessfully') ->willReturn($expected['isSampleDataInstalled']); $this->sampleData->expects($this->once())->method('isInstallationError') ->willReturn($expected['isSampleDataErrorInstallation']); $this->lists->expects($this->once())->method('getTimezoneList')->willReturn($expected['timezone']); $this->lists->expects($this->once())->method('getCurrencyList')->willReturn($expected['currency']); $this->lists->expects($this->once())->method('getLocaleList')->willReturn($expected['language']); $viewModel = $this->controller->indexAction(); $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); $this->assertTrue($viewModel->terminate()); $variables = $viewModel->getVariables(); $this->assertArrayHasKey('timezone', $variables); $this->assertArrayHasKey('currency', $variables); $this->assertArrayHasKey('language', $variables); $this->assertSame($expected, $variables); }
/** * Run installation process for Sample Data * * @param array $request * @return void * * @SuppressWarnings(PHPMD.UnusedPrivateMethod) Called by install() via callback. */ private function installSampleData($request) { $userName = isset($request[AdminAccount::KEY_USERNAME]) ? $request[AdminAccount::KEY_USERNAME] : ''; $this->sampleData->install($this->objectManagerProvider->get(), $this->log, $userName); }
/** * Run installation process for Sample Data * * @param array $request * @return void * @throws \Magento\Setup\SampleDataException * * @SuppressWarnings(PHPMD.UnusedPrivateMethod) Called by install() via callback. */ private function installSampleData($request) { try { $userName = isset($request[AdminAccount::KEY_USER]) ? $request[AdminAccount::KEY_USER] : ''; $this->objectManagerProvider->reset(); $this->sampleData->install($this->objectManagerProvider->get(), $this->log, $userName); } catch (\Exception $e) { throw new \Magento\Setup\SampleDataException( "Error during sample data installation: {$e->getMessage()}", $e->getCode() ); } }
/** * Test SampleData installation check method. * Can be tested only negative case because file_exists method used in the tested class */ public function testIsInstalledSuccessfully() { $this->assertFalse($this->sampleDataInstall->isInstalledSuccessfully()); }