@@ -11,7 +11,11 @@ class CreateVuetifyThemeTest extends CommandTestCase {
1111 public function test00 () {
1212 $ ns = 'TestTheme \\My ' ;
1313 $ name = 'MyCoolVuetifyTheme ' ;
14- $ path = ROOT_PATH .DS .$ ns ;
14+ $ path = ROOT_PATH . DS . str_replace ('\\' , DS , $ ns );
15+
16+ // Clean up before test
17+ $ this ->cleanupTestResources ($ path );
18+
1519 $ output = $ this ->executeSingleCommand (new CreateVuetifyThemeCommand (), [], [
1620 '0 ' ,
1721 $ name ,
@@ -29,11 +33,47 @@ public function test00() {
2933 "Creating new vuetify theme based on 'Base' wireframe... \n" ,
3034 "Your theme was successfully created. \n"
3135 ], $ output );
32- $ this ->assertTrue (file_exists ($ path .DS .$ name .'.php ' ), "File not found: " .$ path .DS .$ name .'.php ' );
33- $ this ->assertTrue (class_exists ($ ns .'\\' .$ name ), "Class not found: " .$ ns .'\\' .$ name );
34- $ this ->assertTrue (class_exists ($ ns .'\\AsideSection ' , "Class not found: " .$ ns .'\\AsideSection ' ));
35- $ this ->assertTrue (class_exists ($ ns .'\\FooterSection ' , "Class not found: " .$ ns .'\\FooterSection ' ));
36- $ this ->assertTrue (class_exists ($ ns .'\\HeaderSection ' , "Class not found: " .$ ns .'\\HeaderSection ' ));
37- $ this ->assertTrue (class_exists ($ ns .'\\HeadSection ' , "Class not found: " .$ ns .'\\HeadSection ' ));
36+
37+ // Check that all expected files were created
38+ $ expectedFiles = [
39+ $ name . '.php ' ,
40+ 'AsideSection.php ' ,
41+ 'FooterSection.php ' ,
42+ 'HeaderSection.php ' ,
43+ 'HeadSection.php '
44+ ];
45+
46+ foreach ($ expectedFiles as $ fileName ) {
47+ $ filePath = $ path . DS . $ fileName ;
48+ $ this ->assertTrue (file_exists ($ filePath ), "File not found: " . $ filePath );
49+ require_once $ filePath ;
50+ $ this ->assertTrue (class_exists ($ ns .'\\' .explode ('. ' , $ fileName )[0 ]), "Class not found: " . $ ns .'\\' .explode ('. ' , $ fileName )[0 ]);
51+ }
52+
53+ // Clean up after test
54+ $ this ->cleanupTestResources ($ path );
55+ }
56+
57+ /**
58+ * Deletes all resources created by a test in the specified path
59+ *
60+ * @param string $path The path to clean up
61+ */
62+ public function cleanupTestResources ($ path ) {
63+ if (is_dir ($ path )) {
64+ $ files = glob ($ path . DS . '* ' );
65+ foreach ($ files as $ file ) {
66+ if (is_file ($ file )) {
67+ unlink ($ file );
68+ }
69+ }
70+ rmdir ($ path );
71+ }
72+
73+ // Also remove parent directory if empty
74+ $ parentPath = dirname ($ path );
75+ if (is_dir ($ parentPath ) && count (glob ($ parentPath . DS . '* ' )) === 0 ) {
76+ rmdir ($ parentPath );
77+ }
3878 }
39- }
79+ }
0 commit comments