Skip to content

Conversation

@mpdude
Copy link
Member

@mpdude mpdude commented May 25, 2022

The class Webfactory\ShortcodeBundle\Test\ShortcodeTest is intended to be used as a base class for users of this bundle.

It should thus not only be available through autoload-dev, but the regular autoload configuration.

My suggestion is to follow conventions as e. g. in symfony/symfony and use a Test sub-namespace for testing-related classes that are intended to be used by clients, i. e. are part of the bundle's API.

@mpdude
Copy link
Member Author

mpdude commented May 25, 2022

Strictly speaking, we'd need to declare the PHPUnit version we're compatible with. However, since this test base class is only an add-on, I would not want to make it a regular require dependency.

On the other hand, a conflicts entry might also get in the way for people who do not intend to use the ShortcodeTest base class.

We might also simply ignore the problem, since we only inherit from WebTestCase, so let FrameworkBundle be responsible for making the right declarations and 🤞🏻 that it will work in the long run.

@mpdude
Copy link
Member Author

mpdude commented May 25, 2022

Still an issue, since the test base class uses Symfony DomCrawler and BrowserKit, but we don't want to declare those as regular (prod) dependencies.

@mpdude mpdude closed this in #23 May 31, 2022
mpdude added a commit that referenced this pull request May 31, 2022
This PR addresses the shortcomings outlined in #12 and #13, and probably replaces #10 and #18 as well.

1. Deprecate the `\Webfactory\ShortcodeBundle\Tests\Functional\ShortcodeTest` class. 

* It was not available through the regular autoload mechanism (required extra trickery), 
* depended on undeclared dependencies (BrowserKit and DomCrawler), 
* came without tests, 
* suggested users to do/prefer full-scale Application Testing (using `WebTestCase`) and 
* worked only through the means of (ab-)using the Shortcode Guide.

2. Provide alternate means of testing shortcode processing

* Encourage users to do plain/direct unit testing (or integration testing, when necessary) of their shortcode handlers and/or shortcode handling controllers through new sections in the README. This gives best (most direct) control of input parameters.
* Add the public `\Webfactory\ShortcodeBundle\Test\ShortcodeDefinitionTestHelper` service that can be used in Kernel-based (functional) tests to verify a given shortcode name is known, the controller can be resolved etc.
* Add a `\Webfactory\ShortcodeBundle\Test\EndToEndTestHelper` class that simplifies full end-to-end (from content to processed content) functional testing, including round-trips through Symfony's FragmentHandler for controller-based shortcodes.

Fixes #12, fixes #13, closes #10, closes #18, closes #24.

Co-authored-by: Malte Wunsch <mw@webfactory.de>
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.

2 participants