5 class ThemeTest extends TestCase
7 protected $themeFolderName;
8 protected $themeFolderPath;
10 public function setUp(): void
14 // Create a folder and configure a theme
15 $this->themeFolderName = 'testing_theme_' . rtrim(base64_encode(time()), "=");
16 config()->set('view.theme', $this->themeFolderName);
17 $this->themeFolderPath = theme_path('');
18 File::makeDirectory($this->themeFolderPath);
21 public function tearDown(): void
23 // Cleanup the custom theme folder we created
24 File::deleteDirectory($this->themeFolderPath);
29 public function test_translation_text_can_be_overriden_via_theme()
31 $translationPath = theme_path('/lang/en');
32 File::makeDirectory($translationPath, 0777, true);
34 $customTranslations = '<?php
35 return [\'books\' => \'Sandwiches\'];
37 file_put_contents($translationPath . '/entities.php', $customTranslations);
39 $homeRequest = $this->actingAs($this->getViewer())->get('/');
40 $homeRequest->assertElementContains('header nav', 'Sandwiches');