themesPath = base_path('themes'); if (! File::exists($this->themesPath)) { File::makeDirectory($this->themesPath); } File::deleteDirectory($this->themesPath . '/parent-theme'); File::deleteDirectory($this->themesPath . '/child-theme'); File::makeDirectory($this->themesPath . '/parent-theme'); File::makeDirectory($this->themesPath . '/child-theme'); File::put($this->themesPath . '/parent-theme/theme.md', "title: Parent Theme\nauthor: SiteWeaver\ndescription: A base theme."); File::put($this->themesPath . '/child-theme/theme.md', "title: Child Theme\nauthor: SiteWeaver\ndescription: A child theme.\nparent: parent-theme"); File::makeDirectory($this->themesPath . '/parent-theme/css'); File::makeDirectory($this->themesPath . '/child-theme/css'); File::put($this->themesPath . '/parent-theme/css/style.css', 'parent-css'); File::put($this->themesPath . '/child-theme/css/custom.css', 'child-css'); File::put($this->themesPath . '/parent-theme/css/shared.css', 'shared-css'); } protected function tearDown(): void { File::deleteDirectory($this->themesPath . '/parent-theme'); File::deleteDirectory($this->themesPath . '/child-theme'); parent::tearDown(); } public function test_it_can_list_themes(): void { $themeManager = new ThemeManager(); $themes = $themeManager->getThemes(); $this->assertArrayHasKey('parent-theme', $themes); $this->assertArrayHasKey('child-theme', $themes); $this->assertEquals('Parent Theme', $themes['parent-theme']['title']); $this->assertEquals('Child Theme', $themes['child-theme']['title']); } public function test_it_can_parse_metadata(): void { $themeManager = new ThemeManager(); $metadata = $themeManager->getMetadata('child-theme'); $this->assertEquals('child-theme', $metadata['slug']); $this->assertEquals('Child Theme', $metadata['title']); $this->assertEquals('parent-theme', $metadata['parent']); } public function test_it_discovers_assets_with_inheritance(): void { $themeManager = new ThemeManager(); $this->assertEquals('themes/child-theme/css/custom.css', $themeManager->getAssetPath('css/custom.css', 'child-theme')); $this->assertEquals('themes/parent-theme/css/shared.css', $themeManager->getAssetPath('css/shared.css', 'child-theme')); $this->assertNull($themeManager->getAssetPath('css/not-found.css', 'child-theme')); } }