9 use \Magento\Setup\Controller\CustomizeYourStore;
21 private $sampleDataState;
31 private $objectManager;
40 $objectManagerProvider = $this->createMock(\
Magento\Setup\Model\ObjectManagerProvider::class);
41 $this->objectManager = $this->createMock(\
Magento\Framework\
App\ObjectManager::class);
42 $objectManagerProvider->expects($this->any())->method(
'get')->willReturn($this->objectManager);
43 $this->sampleDataState = $this->createMock(\
Magento\Framework\Setup\SampleData\State::class);
44 $this->lists = $this->createMock(\
Magento\Framework\Setup\Lists::class);
45 $this->moduleList = $this->createMock(\
Magento\Framework\
Module\FullModuleList::class);
46 $this->controller =
new CustomizeYourStore($this->moduleList, $this->lists, $objectManagerProvider);
57 if ($withSampleData) {
58 $this->moduleList->expects($this->once())->method(
'has')->willReturn(
true);
59 $this->objectManager->expects($this->once())->method(
'get')->willReturn($this->sampleDataState);
60 $this->sampleDataState->expects($this->once())->method(
'isInstalled')
61 ->willReturn($expected[
'isSampleDataInstalled']);
62 $this->sampleDataState->expects($this->once())->method(
'hasError')
63 ->willReturn($expected[
'isSampleDataErrorInstallation']);
65 $this->moduleList->expects($this->once())->method(
'has')->willReturn(
false);
66 $this->objectManager->expects($this->never())->method(
'get');
68 $this->lists->expects($this->once())->method(
'getTimezoneList')->willReturn($expected[
'timezone']);
69 $this->lists->expects($this->once())->method(
'getCurrencyList')->willReturn($expected[
'currency']);
70 $this->lists->expects($this->once())->method(
'getLocaleList')->willReturn($expected[
'language']);
74 $this->assertInstanceOf(\
Zend\View\Model\ViewModel::class,
$viewModel);
78 $this->assertArrayHasKey(
'timezone', $variables);
79 $this->assertArrayHasKey(
'currency', $variables);
80 $this->assertArrayHasKey(
'language', $variables);
81 $this->assertSame($expected, $variables);
89 $timezones = [
'timezone' => [
'America/New_York'=>
'EST',
'America/Chicago' =>
'CST']];
90 $currency = [
'currency' => [
'USD'=>
'US Dollar',
'EUR' =>
'Euro']];
91 $language = [
'language' => [
'en_US'=>
'English (USA)',
'en_UK' =>
'English (UK)']];
93 'isSampleDataInstalled' =>
false,
94 'isSampleDataErrorInstallation' =>
false 98 'with_all_data' => [array_merge($timezones, $currency, $language, $sampleData),
true],
99 'no_currency_data' => [array_merge($timezones, [
'currency' =>
null], $language, $sampleData),
true],
100 'no_timezone_data' => [array_merge([
'timezone' =>
null], $currency, $language, $sampleData),
true],
101 'no_language_data' => [array_merge($timezones, $currency, [
'language' =>
null], $sampleData),
true],
102 'empty_currency_data' => [array_merge($timezones, [
'currency' => []], $language, $sampleData),
true],
103 'empty_timezone_data' => [array_merge([
'timezone' => []], $currency, $language, $sampleData),
true],
104 'empty_language_data' => [array_merge($timezones, $currency, [
'language' => []], $sampleData),
true],
105 'no_sample_data' => [array_merge($timezones, $currency, $language, $sampleData),
false],
111 $jsonModel = $this->controller->defaultTimeZoneAction();
112 $this->assertInstanceOf(\
Zend\View\Model\JsonModel::class, $jsonModel);
113 $this->assertArrayHasKey(
'defaultTimeZone', $jsonModel->getVariables());
testIndexAction($expected, $withSampleData)
indexActionDataProvider()
testDefaultTimeZoneAction()