Functional test scaffolding for CMB2 Pipes

Setting up to test CMB2 Pipes.

A different approach

The dependency the CMB2 Pipes plugin has with the Custom Meta Boxes 2 plugins are such that I’d have to mock globals and side effects to test it efficiently.
While I’m not excluding unit testing from the possibilities I’ve begun testing it on a service level; that’s the middle level of testing where simple chains of components are tested together to test their behaviour and the expectations made on that.
To do so I’ve used WP Browser database and WordPress loader modules.

Setting up for the service tests

After the quick requirement of Codeception and the WP Browser module via Composer


composer require --dev lucatume/wp-browser

and the “wait while Composer works its magic” phase I’ve bootstrapped wp-browser to have an almost ready to run test suite configured


wpcept bootstrap

after some configuration setting in the codeception.yml file I’ve run the test suite once to make sure everything work. Codeception test dry run

Test scaffolding

What I want to do is create a functional test to the ones that used by the WordPress core team to test the code and WP Browser offers a quick scaffolding possibility


wpcept generate:wpunit functional PostPiping

to end up with the base structure of a functional test


class PostPipingTest extends \WP_UnitTestCase
    {
        public function setUp()
        {
            // before
            parent::setUp();

            // your set up methods here
        }

        public function tearDown()
        {
            // your tear down methods here

            // then
            parent::tearDown();
        }

        // tests
        public function testMe()
        {
        }

    }


and running it yields a green light that lets me know everything is ready to test code. First stupid green light