/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $table = $this->getHelperSet()->get('table'); $table->setHeaders(['Currency', 'Code']); foreach ($this->lists->getCurrencyList() as $key => $currency) { $table->addRow([$currency, $key]); } $table->render($output); }
/** * Validate currency code * * @param string $currencyCode * @return bool * @api */ public function isValid($currencyCode) { $isValid = true; $allowedCurrencyCodes = array_keys($this->lists->getCurrencyList()); if (!$currencyCode || !in_array($currencyCode, $allowedCurrencyCodes)) { $isValid = false; } return $isValid; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $table = $this->getHelperSet()->get('table'); $table->setHeaders(['Language', 'Code']); foreach ($this->lists->getLocaleList() as $key => $locale) { $table->addRow([$locale, $key]); } $table->render($output); }
/** * Validate locale code. Code must be in the list of allowed locales. * * @param string $localeCode * @return bool * * @api */ public function isValid($localeCode) { $isValid = true; $allowedLocaleCodes = array_keys($this->lists->getLocaleList()); if (!$localeCode || !in_array($localeCode, $allowedLocaleCodes)) { $isValid = false; } return $isValid; }
/** * @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; }
/** * @return ViewModel */ public function indexAction() { $sampleDataDeployed = $this->moduleList->has('Magento_SampleData'); if ($sampleDataDeployed) { /** @var \Magento\Framework\Setup\SampleData\State $sampleData */ $sampleData = $this->objectManagerProvider->get()->get('Magento\\Framework\\Setup\\SampleData\\State'); $isSampleDataInstalled = $sampleData->isInstalled(); $isSampleDataErrorInstallation = $sampleData->hasError(); } else { $isSampleDataInstalled = false; $isSampleDataErrorInstallation = false; } $view = new ViewModel(['timezone' => $this->list->getTimezoneList(), 'currency' => $this->list->getCurrencyList(), 'language' => $this->list->getLocaleList(), 'isSampleDataInstalled' => $isSampleDataInstalled, 'isSampleDataErrorInstallation' => $isSampleDataErrorInstallation]); $view->setTerminal(true); return $view; }
/** * @param array $expected * @param $withSampleData * * @dataProvider indexActionDataProvider */ public function testIndexAction($expected, $withSampleData) { if ($withSampleData) { $this->moduleList->expects($this->once())->method('has')->willReturn(true); $this->objectManager->expects($this->once())->method('get')->willReturn($this->sampleDataState); $this->sampleDataState->expects($this->once())->method('isInstalled')->willReturn($expected['isSampleDataInstalled']); $this->sampleDataState->expects($this->once())->method('hasError')->willReturn($expected['isSampleDataErrorInstallation']); } else { $this->moduleList->expects($this->once())->method('has')->willReturn(false); $this->objectManager->expects($this->never())->method('get'); } $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); }
public function testGetLocaleList() { $locales = array_intersect($this->expectedLocales, array_keys($this->lists->getLocaleList())); $this->assertEquals($this->expectedLocales, $locales); }