-
-
Notifications
You must be signed in to change notification settings - Fork 540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.x] Scaffold PHPUnit test suite with make:addon
command
#9593
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The composer install step failed for me. Not sure how it passed for you. It was complaining about a plugin not being allowed.
Adding this to the composer.json.stub fixes it:
"config": {
"allow-plugins": {
"pixelfear/composer-dist-plugin": true
}
}
Also, the tests don't want to run for me. Did they work for you?
sandbox/addons/pixelfear/charlie on master [!?]
→ ./vendor/bin/phpunit
Fatal error: Uncaught Error: Class "Statamic\Extend\AddonTestCase" not found in /Users/jason/Code/statamic/sandbox/addons/pixelfear/charlie/tests/TestCase.php:8
Stack trace:
#0 /Users/jason/Code/statamic/sandbox/addons/pixelfear/charlie/vendor/composer/ClassLoader.php(576): include()
#1 /Users/jason/Code/statamic/sandbox/addons/pixelfear/charlie/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}('/Users/jason/Co...')
#2 /Users/jason/Code/statamic/sandbox/addons/pixelfear/charlie/tests/ExampleTest.php(5): Composer\Autoload\ClassLoader->loadClass('Pixelfear\\Charl...')
#3 /Users/jason/Code/statamic/sandbox/addons/pixelfear/charlie/vendor/phpunit/phpunit/src/Util/FileLoader.php(66): include_once('/Users/jason/Co...')
Funnily, using VSCode's "Better PHPUnit" extension to run the test from the file itself does work:
Executing task: valet php ./vendor/bin/phpunit /Users/jason/Code/statamic/sandbox/addons/pixelfear/charlie/tests/ExampleTest.php --configuration /Users/jason/Code/statamic/sandbox/addons/pixelfear/charlie/phpunit.xml
PHPUnit 9.6.17 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 00:00.180, Memory: 34.00 MB
OK (1 test, 0 assertions)
Weird, it was definitely working for me. 🤔 Anyways, I've added that plugin to the
It'll be because the You probably need to symlink your local |
You're right! I changed the stub to Since it works, I've bumped the constraint to |
This pull request improves the
php please make:addon
command by automatically scaffolding a PHPUnit test suite alongside new addons.This PR, combined with #9573, will streamline the process of setting up addon tests suites, ultimately saving time for addon developers. ✨