17 use PHPUnit_Framework_MockObject_MockObject as MockObject;
18 use Symfony\Component\Console\Output\OutputInterface;
50 private $directoryWrite;
55 private $userCollection;
60 private $objectManager;
65 private $deployFilesystem;
76 $this->storeView = $this->getMockBuilder(StoreView::class)
77 ->disableOriginalConstructor()
79 $this->shell = $this->getMockBuilder(ShellInterface::class)
80 ->disableOriginalConstructor()
82 $this->
output = $this->getMockBuilder(OutputInterface::class)
83 ->disableOriginalConstructor()
85 $this->objectManager = $this->getMockBuilder(ObjectManagerInterface::class)
86 ->disableOriginalConstructor()
88 $this->filesystem = $this->getMockBuilder(Filesystem::class)
89 ->disableOriginalConstructor()
91 $this->directoryWrite = $this->getMockBuilder(WriteInterface::class)
92 ->disableOriginalConstructor()
94 $this->filesystem->method(
'getDirectoryWrite')
95 ->willReturn($this->directoryWrite);
97 $this->userCollection = $this->getMockBuilder(Collection::class)
98 ->disableOriginalConstructor()
100 $lists = $this->getMockBuilder(Lists::class)
101 ->disableOriginalConstructor()
104 $lists->method(
'getLocaleList')
107 'de_DE' =>
'Germany',
108 'nl_NL' =>
'Netherlands',
111 $locale = $objectManager->getObject(Locale::class, [
'lists' => $lists]);
113 $this->deployFilesystem = $objectManager->getObject(
114 DeployFilesystem::class,
116 'storeView' => $this->storeView,
117 'shell' => $this->shell,
118 'filesystem' => $this->filesystem,
119 'userCollection' => $this->userCollection,
124 $this->cmdPrefix = PHP_BINARY .
' -f ' .
BP . DIRECTORY_SEPARATOR .
'bin' . DIRECTORY_SEPARATOR .
'magento ';
129 $storeLocales = [
'fr_FR',
'de_DE',
'nl_NL'];
130 $this->storeView->method(
'retrieveLocales')
131 ->willReturn($storeLocales);
133 $setupDiCompileCmd = $this->cmdPrefix .
'setup:di:compile';
134 $this->shell->expects(self::at(0))
136 ->with($setupDiCompileCmd);
138 $this->initAdminLocaleMock(
'en_US');
140 $usedLocales = [
'fr_FR',
'de_DE',
'nl_NL',
'en_US'];
141 $staticContentDeployCmd = $this->cmdPrefix .
'setup:static-content:deploy -f ' 142 . implode(
' ', $usedLocales);
143 $this->shell->expects(self::at(1))
145 ->with($staticContentDeployCmd);
147 $this->
output->expects(self::at(0))
149 ->with(
'Starting compilation');
150 $this->
output->expects(self::at(2))
152 ->with(
'Compilation complete');
153 $this->
output->expects(self::at(3))
155 ->with(
'Starting deployment of static content');
156 $this->
output->expects(self::at(5))
158 ->with(
'Deployment of static content complete');
160 $this->deployFilesystem->regenerateStatic($this->
output);
172 $storeLocales = [
'fr_FR',
'de_DE',
';echo'];
173 $this->storeView->method(
'retrieveLocales')
174 ->willReturn($storeLocales);
176 $this->initAdminLocaleMock(
'en_US');
178 $this->deployFilesystem->regenerateStatic($this->
output);
190 $storeLocales = [
'fr_FR',
'de_DE',
'en_US'];
191 $this->storeView->method(
'retrieveLocales')
192 ->willReturn($storeLocales);
194 $this->initAdminLocaleMock(
';echo');
196 $this->deployFilesystem->regenerateStatic($this->
output);
205 private function initAdminLocaleMock($locale)
208 $user = $this->getMockBuilder(User::class)
209 ->disableOriginalConstructor()
211 $user->method(
'getInterfaceLocale')
212 ->willReturn($locale);
213 $this->userCollection->method(
'getIterator')
214 ->willReturn(
new \ArrayIterator([
$user]));
output($string, $level=INFO, $label='')
testGenerateStaticForNotAllowedStoreViewLocale()
testGenerateStaticForNotAllowedAdminLocale()