themesPath = storage_path('framework/testing/stylist-installed-'.uniqid()); $this->workspace = storage_path('framework/testing/stylist-package-'.uniqid()); mkdir($this->themesPath, 0777, true); mkdir($this->workspace, 0777, true); config(['stylist.themes_path' => $this->themesPath]); app(Loader::class)->flush(); } protected function tearDown(): void { app(Filesystem::class)->deleteDirectory($this->themesPath); app(Filesystem::class)->deleteDirectory($this->workspace); app(Loader::class)->flush(); parent::tearDown(); } public function test_generated_theme_zip_installs_discovers_and_renders(): void { $source = $this->workspace.'/design-gallery'; mkdir($source.'/css', 0777, true); mkdir($source.'/js', 0777, true); mkdir($source.'/views', 0777, true); file_put_contents($source.'/theme.json', json_encode([ 'manifest_version' => 1, 'key' => 'design-gallery', 'name' => 'Design Gallery', 'stylesheet' => 'css/app.css', 'script' => 'js/app.js', 'entry_view' => 'home', 'appearances' => ['light', 'dark', 'system'], 'accents' => ['blue', 'neutral'], 'default_appearance' => 'system', 'default_accent' => 'neutral', ])); file_put_contents($source.'/css/app.css', 'body{}'); file_put_contents($source.'/js/app.js', ''); file_put_contents($source.'/views/home.blade.php', '
Design Gallery works
'); $zipPath = $this->workspace.'/design-gallery.zip'; $zip = new ZipArchive; $this->assertTrue($zip->open($zipPath, ZipArchive::CREATE | ZipArchive::OVERWRITE)); foreach (app(Filesystem::class)->allFiles($source) as $file) { $zip->addFile($file->getPathname(), 'design-gallery/'.$file->getRelativePathname()); } $zip->close(); $upload = new UploadedFile($zipPath, 'design-gallery.zip', 'application/zip', null, true); $theme = app(ThemePackageManager::class)->install($upload); $this->assertSame('design-gallery', $theme->key()); $this->assertTrue(app(Loader::class)->all()->has('design-gallery')); $this->assertStringContainsString( 'Design Gallery works', stylist_theme_view('design-gallery', 'home')->render(), ); } }