Hard and fast does not apply to a WordPress functional tests module.
I admit that the being able to assemble a first working version of a WordPress functional testing module gave me a thrill.
Delving deeper into the needs such a module could satisfy I’ve found out how resilient to multiple request handling WordPress can be.
The extensive use of
include_once instructions, globals and constants makes juggling different and successive request types a pain.
While I’ve been able to handle successive requests hitting the same kind of endpoints in the case of, say, both front end and back end endpoints like the one below the code would fall apart:
// hitting admin $I->amOnAdminPage('post-new.php'); // create a new post $I->submitForm(...); // now move to homepage $I->amOnPage('/'); // and fail badly...
I could list a number of reasons; to pick one think of administration area constants set during the first request now colliding with the the ones set or checked during the front end request.
I tend to walk into software enterprises with little thought especially when dealing with a side project like WP Browser and can hear the chorus in my head saying “Told you! WordPress is/is not /was meant/was never meant to do/not do X”.
I’m fine with this initial failure and am willing to back pedal and restart from scratch.
Taking a look around Codeception code I’ve seen modules for modern frameworks will rely on well structured and compartmentalized components to handle multiple successive requests.
Not going to happen in WordPress.
I’ve not taken nearly enough time to read Codeception framework modules code but can say that framework modules will end up relying on the Symfony Browser Kit Client class to handle requests and that same class allows for requests to be handled in separate processes.
That’s the next path I will try and exploit.
I sincerely had 5 minutes where I thought that building a real functional tests Codeception module for WordPress would have been a matter of days.
That’s not the case but I’m not willing to let it drop without some more attempts.