Testing your frameworks
SVRUnit can also be used to test your framework.
Let's imagine you are building a PHP framework, that is published as a composer dependency, as well as a PHAR binary.
You would usually start it with one of these 2 commands:
SVRUnit helps you with 2 things.
You can create your custom "E2E" setups where you start your framework and verify the expected output using SVRUnit
You can use SVRUnit placeholders to test both, the script as well as the PHAR file with the same tests.
Let's get started.
Because SVRUnit allows you to install it with Composer, it is recommended to install it directly as dependency. You can of course also use the PHAR file for this.
Now create a XML configuration file that specifies 2 test suites.
Both test suites use the same test directory, but use different executable placeholders. With this approach, we can then use a placeholder inside the real tests later, so that we either use the script version of our file, or the PHAR binary, when running the tests.
Please keep in mind, this is totally optional...you don't need to use placeholders.
Last but not least, we need the specification of our tests in the YAML file.
If you use placeholders for your executable, just use (($EXEC)) instead of the real path to your executable. If not, just use your real path.
That's it!
You can now manually run your tests, or even use your CI/CD pipeline for this.
Last updated