Skip to content

Add meaningful test coverage for getNamespacedClasses and getInstantiatedClasses - #88

Merged
tehwave merged 4 commits into
masterfrom
copilot/add-remaining-test-coverage
Mar 15, 2026
Merged

tehwave merged 4 commits into
masterfrom
copilot/add-remaining-test-coverage

Conversation

Copilot AI commented Mar 15, 2026 •

Copy link
Copy Markdown
Contributor
  • Explore repository and understand codebase
  • Improve test_get_namespaced_classes() to verify namespace transformation
  • Improve test_get_instantiated_classes() to verify each returned item is a Shortcode instance
  • Move artisan() and require_once inside try blocks so cleanup is always guaranteed
  • Guard unlink() with file_exists() to prevent warnings if file was never created
  • Restore composer.json PHPUnit constraint to ^10.5|^11.5.3 for CI matrix compatibility
  • Verify all 36 tests pass
Original prompt

This section details on the original issue you should resolve

<issue_title>Add remaining test coverage</issue_title>
<issue_description>I couldn't figure out a way to test the getNamespacedClasses and getInstantiatedClasses methods.

</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Add remaining test coverage for methods Add meaningful test coverage for getNamespacedClasses and getInstantiatedClasses Mar 15, 2026
Copilot AI requested a review from tehwave March 15, 2026 11:01
@tehwave
tehwave marked this pull request as ready for review March 15, 2026 14:10
Copilot AI review requested due to automatic review settings March 15, 2026 14:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens the unit tests around Shortcode::getNamespacedClasses() and Shortcode::getInstantiatedClasses() so they validate actual transformation/instantiation behavior rather than only asserting return types.

Changes:

  • Updates test_get_namespaced_classes() to generate a real shortcode class and assert the expected namespaced class string is returned.
  • Updates test_get_instantiated_classes() to generate and load a shortcode class, then assert the returned collection contains Shortcode instances.
  • Adjusts composer.json PHPUnit dev dependency constraint.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
tests/ShortcodeTest.php Adds more meaningful assertions by generating shortcodes on disk and validating results.
composer.json Changes PHPUnit dev version constraint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread composer.json Outdated
"laravel/pint": "^1.21",
"orchestra/testbench": "^9.0|^10.0",
"phpunit/phpunit": "^10.5|^11.5.3"
"phpunit/phpunit": "^11.5"
Comment thread tests/ShortcodeTest.php Outdated
Comment on lines +207 to +209
$this->artisan('make:shortcode', ['name' => $name])->assertExitCode(0);

try {
Comment thread tests/ShortcodeTest.php
Comment on lines +219 to +222
} finally {
unlink($path);

Shortcode::clearCache();
Comment thread tests/ShortcodeTest.php Outdated
Comment on lines +234 to +239
$this->artisan('make:shortcode', ['name' => $name])->assertExitCode(0);

require_once $path;

try {
Shortcode::clearCache();
@tehwave

tehwave commented Mar 15, 2026

Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

also rebase to fix tests.

Copilot AI commented Mar 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

also rebase to fix tests.

Done in b463a15. Addressed all the review feedback:

  • Moved artisan() and require_once inside the try blocks so cleanup is guaranteed regardless of failure
  • Guarded unlink() with file_exists() to avoid warnings if the file was never created
  • Restored composer.json PHPUnit constraint to ^10.5|^11.5.3 to keep CI matrix compatibility

Copilot AI and others added 4 commits March 15, 2026 16:47
Co-authored-by: tehwave <4569897+tehwave@users.noreply.github.com>
…atedClasses

Co-authored-by: tehwave <4569897+tehwave@users.noreply.github.com>
… composer constraint

Co-authored-by: tehwave <4569897+tehwave@users.noreply.github.com>
@tehwave
tehwave force-pushed the copilot/add-remaining-test-coverage branch from b463a15 to 784d32b Compare March 15, 2026 15:47
@tehwave
tehwave merged commit abbca45 into master Mar 15, 2026
12 of 13 checks passed
@tehwave
tehwave deleted the copilot/add-remaining-test-coverage branch March 15, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add remaining test coverage

3 participants