From 08b1026721c288eab42303093c5d52326fdf8656 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Mar 2026 10:32:08 +0000 Subject: [PATCH 1/4] Initial plan From 91c4f5813ee28aed603384da6a5c3546a6f9ba34 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Mar 2026 10:57:08 +0000 Subject: [PATCH 2/4] Initial plan for adding test coverage Co-authored-by: tehwave <4569897+tehwave@users.noreply.github.com> --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d08aeaa..3594dc9 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "brianium/paratest": "^7.4", "laravel/pint": "^1.21", "orchestra/testbench": "^9.0|^10.0", - "phpunit/phpunit": "^10.5|^11.5.3" + "phpunit/phpunit": "^11.5" }, "autoload": { "psr-4": { From 0887fbd4706aa83267a56c6278125b596890ae33 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Mar 2026 10:58:59 +0000 Subject: [PATCH 3/4] Add meaningful test coverage for getNamespacedClasses and getInstantiatedClasses Co-authored-by: tehwave <4569897+tehwave@users.noreply.github.com> --- tests/ShortcodeTest.php | 45 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/tests/ShortcodeTest.php b/tests/ShortcodeTest.php index 624afcd..9b32b9d 100644 --- a/tests/ShortcodeTest.php +++ b/tests/ShortcodeTest.php @@ -201,9 +201,26 @@ public function test_get_classes(): void */ public function test_get_namespaced_classes(): void { - $namespacedClasses = Shortcode::getNamespacedClasses(); + $name = 'TestGetNamespacedClasses'; + $path = $this->app->path('Shortcodes').'/'.$name.'.php'; - $this->assertInstanceOf(Collection::class, $namespacedClasses); + $this->artisan('make:shortcode', ['name' => $name])->assertExitCode(0); + + try { + Shortcode::clearCache(); + + $namespacedClasses = Shortcode::getNamespacedClasses(); + + $this->assertInstanceOf(Collection::class, $namespacedClasses); + + $expectedClass = app()->getNamespace().'Shortcodes\\'.$name; + + $this->assertContains($expectedClass, $namespacedClasses->toArray()); + } finally { + unlink($path); + + Shortcode::clearCache(); + } } /** @@ -211,9 +228,29 @@ public function test_get_namespaced_classes(): void */ public function test_get_instantiated_classes(): void { - $instances = Shortcode::getInstantiatedClasses(); + $name = 'TestGetInstantiatedClasses'; + $path = $this->app->path('Shortcodes').'/'.$name.'.php'; - $this->assertInstanceOf(Collection::class, $instances); + $this->artisan('make:shortcode', ['name' => $name])->assertExitCode(0); + + require_once $path; + + try { + Shortcode::clearCache(); + + $instances = Shortcode::getInstantiatedClasses(); + + $this->assertInstanceOf(Collection::class, $instances); + $this->assertNotEmpty($instances); + + $instances->each(function ($instance) { + $this->assertInstanceOf(Shortcode::class, $instance); + }); + } finally { + unlink($path); + + Shortcode::clearCache(); + } } /** From 784d32b6b3fa0be2e9ab845dce7e76101008b0df Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Mar 2026 14:24:58 +0000 Subject: [PATCH 4/4] Address review feedback: fix try-finally scope, guard unlink, restore composer constraint Co-authored-by: tehwave <4569897+tehwave@users.noreply.github.com> --- composer.json | 2 +- tests/ShortcodeTest.php | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 3594dc9..d08aeaa 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "brianium/paratest": "^7.4", "laravel/pint": "^1.21", "orchestra/testbench": "^9.0|^10.0", - "phpunit/phpunit": "^11.5" + "phpunit/phpunit": "^10.5|^11.5.3" }, "autoload": { "psr-4": { diff --git a/tests/ShortcodeTest.php b/tests/ShortcodeTest.php index 9b32b9d..5164fca 100644 --- a/tests/ShortcodeTest.php +++ b/tests/ShortcodeTest.php @@ -204,9 +204,9 @@ public function test_get_namespaced_classes(): void $name = 'TestGetNamespacedClasses'; $path = $this->app->path('Shortcodes').'/'.$name.'.php'; - $this->artisan('make:shortcode', ['name' => $name])->assertExitCode(0); - try { + $this->artisan('make:shortcode', ['name' => $name])->assertExitCode(0); + Shortcode::clearCache(); $namespacedClasses = Shortcode::getNamespacedClasses(); @@ -217,7 +217,9 @@ public function test_get_namespaced_classes(): void $this->assertContains($expectedClass, $namespacedClasses->toArray()); } finally { - unlink($path); + if (file_exists($path)) { + unlink($path); + } Shortcode::clearCache(); } @@ -231,11 +233,11 @@ public function test_get_instantiated_classes(): void $name = 'TestGetInstantiatedClasses'; $path = $this->app->path('Shortcodes').'/'.$name.'.php'; - $this->artisan('make:shortcode', ['name' => $name])->assertExitCode(0); + try { + $this->artisan('make:shortcode', ['name' => $name])->assertExitCode(0); - require_once $path; + require_once $path; - try { Shortcode::clearCache(); $instances = Shortcode::getInstantiatedClasses(); @@ -247,7 +249,9 @@ public function test_get_instantiated_classes(): void $this->assertInstanceOf(Shortcode::class, $instance); }); } finally { - unlink($path); + if (file_exists($path)) { + unlink($path); + } Shortcode::clearCache(); }