In the previous post I’ve presented the addition of WP Loader to the WP Browser package and presented a simple end-to-end workflow example.
After creating the test case using Codeception CLI interface like
codecept generate:phpunit functional SomeClass
I’d go into the class and modify it to extend WP_UnitTestCase
in place of PHPUnit_Framework_TestCase
, that task would have to be carried out for each and every test case created to avoid database-related error during the tests making use of a wrapped WordPress automated testing suite.
To streamline test scaffolding I’ve added the wpcept
script to the package: the script is a drop-in replacement for the codecept
command with the added possibility to generate a ready to use WP_UnitTestCase
file using the usual format
wpcept generate:wpunit <suite> <class>
and have a test case like this one scaffolded
<?php
class SomeTest extends \WP_UnitTestCase
{
protected function setUp()
{
}
protected function tearDown()
{
}
// tests
public function testMe()
{
}
}