22 private $themeFactory;
24 protected function setUp()
29 \
Magento\Theme\Model\Theme\Registration::class
31 $registration->register();
34 ->get(\
Magento\Framework\View\Design\Theme\FlyweightFactory::class);
48 AppBootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => [
50 'path' =>
__DIR__ .
'/../../_files/fallback/lib/web',
64 public function testGetTemplateFile($file, $themePath, $module, $expectedFilename)
69 ->create(\
Magento\Framework\View\Design\FileResolution\Fallback\TemplateFile::class);
70 $themeModel = $this->themeFactory->create($themePath);
72 $actualFilename =
$model->getFile(
'frontend', $themeModel, $file, $module);
73 if ($expectedFilename) {
74 $this->assertInternalType(
'string', $actualFilename);
75 $this->assertStringMatchesFormat($expectedFilename, $actualFilename);
76 $this->assertFileExists($actualFilename);
78 $this->assertFalse($actualFilename);
88 'non-modular: no default inheritance' => [
89 'fixture_template.phtml',
'Vendor_ViewTest/standalone_theme',
null,
92 'non-modular: inherit parent theme' => [
93 'fixture_template.phtml',
'Vendor_ViewTest/custom_theme',
null,
94 '%s/frontend/Vendor/default/templates/fixture_template.phtml',
96 'non-modular: inherit grandparent theme' => [
97 'fixture_template.phtml',
'Vendor_ViewTest/custom_theme2',
null,
98 '%s/frontend/Vendor/default/templates/fixture_template.phtml',
100 'modular: no default inheritance' => [
101 'fixture_template.phtml',
'Vendor_ViewTest/standalone_theme',
'ViewTest_Module',
104 'modular: no fallback to non-modular file' => [
105 'nonexistent_fixture_script.phtml',
'Vendor_ViewTest/default',
'ViewTest_Module',
108 'modular: inherit parent theme' => [
109 'fixture_template.phtml',
'Vendor_ViewTest/custom_theme',
'ViewTest_Module',
110 '%s/frontend/Vendor/default/ViewTest_Module/templates/fixture_template.phtml',
112 'modular: inherit grandparent theme' => [
113 'fixture_template.phtml',
'Vendor_ViewTest/custom_theme2',
'ViewTest_Module',
114 '%s/frontend/Vendor/default/ViewTest_Module/templates/fixture_template.phtml',
126 public function testGetI18nCsvFile($themePath, $locale, $expectedFilename)
131 \
Magento\Framework\View\Design\FileResolution\Fallback\File::class
133 $themeModel = $this->themeFactory->create($themePath);
135 $actualFilename =
$model->getFile(
'frontend', $themeModel,
'i18n/' . $locale .
'.csv');
137 if ($expectedFilename) {
138 $this->assertInternalType(
'string', $actualFilename);
139 $this->assertStringMatchesFormat($expectedFilename, $actualFilename);
140 $this->assertFileExists($actualFilename);
142 $this->assertFalse($actualFilename);
149 'no default inheritance' => [
150 'Vendor_ViewTest/standalone_theme',
'en_US',
153 'inherit parent theme' => [
154 'Vendor_ViewTest/custom_theme',
'en_US',
155 '%s/frontend/Vendor/custom_theme/i18n/en_US.csv',
157 'inherit grandparent theme' => [
158 'Vendor_ViewTest/custom_theme2',
'en_US',
159 '%s/frontend/Vendor/custom_theme/i18n/en_US.csv',
175 public function testGetViewFile($file, $themePath, $locale, $module, $expectedFilename)
180 ->create(\
Magento\Framework\View\Design\FileResolution\Fallback\StaticFile::class);
181 $themeModel = $this->themeFactory->create($themePath);
183 $actualFilename =
$model->getFile(
'frontend', $themeModel, $locale, $file, $module);
184 if ($expectedFilename) {
185 $this->assertInternalType(
'string', $actualFilename);
186 $this->assertStringMatchesFormat($expectedFilename, $actualFilename);
187 $this->assertFileExists($actualFilename);
189 $this->assertFalse($actualFilename);
196 'non-modular: no default inheritance' => [
197 'fixture_script.js',
'Vendor_ViewTest/standalone_theme',
null,
null,
200 'non-modular: inherit same package & parent theme' => [
201 'fixture_script.js',
'Vendor_ViewTest/custom_theme',
null,
null,
202 '%s/frontend/Vendor/default/web/fixture_script.js',
204 'non-modular: inherit same package & grandparent theme' => [
205 'fixture_script.js',
'Vendor_ViewTest/custom_theme2',
null,
null,
206 '%s/frontend/Vendor/default/web/fixture_script.js',
208 'non-modular: fallback to non-localized file' => [
209 'fixture_script.js',
'Vendor_ViewTest/default',
'en_US',
null,
210 '%s/frontend/Vendor/default/web/fixture_script.js',
212 'non-modular: localized file' => [
213 'fixture_script.js',
'Vendor_ViewTest/default',
'ru_RU',
null,
214 '%s/frontend/Vendor/default/web/i18n/ru_RU/fixture_script.js',
216 'non-modular: override js lib file' => [
217 'mage/script.js',
'Vendor_ViewTest/custom_theme',
null,
null,
218 '%s/frontend/Vendor/custom_theme/web/mage/script.js',
220 'non-modular: inherit js lib file' => [
221 'mage/script.js',
'Vendor_ViewTest/default',
null,
null,
222 '%s/lib/web/mage/script.js',
224 'modular: no default inheritance' => [
225 'fixture_script.js',
'Vendor_ViewTest/standalone_theme',
null,
'ViewTest_Module',
228 'modular: no fallback to non-modular file' => [
229 'nonexistent_fixture_script.js',
'Vendor_ViewTest/default',
null,
'ViewTest_Module',
232 'modular: no fallback to js lib file' => [
233 'mage/script.js',
'Vendor_ViewTest/default',
null,
'ViewTest_Module',
236 'modular: no fallback to non-modular localized file' => [
237 'nonexistent_fixture_script.js',
'Vendor_ViewTest/default',
'ru_RU',
'ViewTest_Module',
240 'modular: inherit same package & parent theme' => [
241 'fixture_script.js',
'Vendor_ViewTest/custom_theme',
null,
'ViewTest_Module',
242 '%s/frontend/Vendor/default/ViewTest_Module/web/fixture_script.js',
244 'modular: inherit same package & grandparent theme' => [
245 'fixture_script.js',
'Vendor_ViewTest/custom_theme2',
null,
'ViewTest_Module',
246 '%s/frontend/Vendor/default/ViewTest_Module/web/fixture_script.js',
248 'modular: fallback to non-localized file' => [
249 'fixture_script.js',
'Vendor_ViewTest/default',
'en_US',
'ViewTest_Module',
250 '%s/frontend/Vendor/default/ViewTest_Module/web/fixture_script.js',
252 'modular: localized file' => [
253 'fixture_script.js',
'Vendor_ViewTest/custom_theme2',
'ru_RU',
'ViewTest_Module',
254 '%s/frontend/Vendor/default/ViewTest_Module/web/i18n/ru_RU/fixture_script.js',
272 public function testGetEmailTemplateFile($file, $themePath, $module, $expectedFilename)
278 ->create(\
Magento\Framework\View\Design\FileResolution\Fallback\EmailTemplateFile::class);
280 $themeModel = $this->themeFactory->create($themePath);
281 $locale = \Magento\Setup\Module\I18n\Locale::DEFAULT_SYSTEM_LOCALE;
283 $actualFilename =
$model->getFile($area, $themeModel, $locale, $file, $module);
284 if ($expectedFilename) {
285 $this->assertInternalType(
'string', $actualFilename);
286 $this->assertStringMatchesFormat($expectedFilename, $actualFilename);
287 $this->assertFileExists($actualFilename);
289 $this->assertFalse($actualFilename);
301 'Vendor_EmailTest/custom_theme',
303 '%s/frontend/Vendor/custom_theme/Magento_Customer/email/account_new.html',
305 'inherit same package & parent theme' => [
306 'account_new_confirmation.html',
307 'Vendor_EmailTest/custom_theme',
309 '%s/frontend/Vendor/default/Magento_Customer/email/account_new_confirmation.html',
311 'inherit parent package & grandparent theme' => [
312 'account_new_confirmed.html',
313 'Vendor_EmailTest/custom_theme',
315 '%s/frontend/Magento/default/Magento_Customer/email/account_new_confirmed.html',
getViewFileDataProvider()
defined('TESTS_BP')||define('TESTS_BP' __DIR__
reinitializeEnvironment()
getEmailTemplateFileDataProvider()
getTemplateFileDataProvider()
static getObjectManager()
getLocaleFileDataProvider()