WordPress Db Codeception module – 02

I’ve decided to work on the WPDb Codeception module to complete a fully working first iteration of it to use in my imminent test writing and am slowly getting my head around Codeception modules mechanics and how much “sugar” I want to trade with customization possibility.
As a first more meaningful step I’ve tackled the users table and added two small methods to add and check for a user at database level; in an acceptance test loading the WPDb module

<?php $I = new AcceptanceTester($scenario); $I->wantTo('create and check for a user'); // create a subscriber user with user login and id as bare minimum parameters $I->haveUserInDatabase('someUser', 100); // check for created user $I->seeUserInDatabase(array('user_login' => 'someUser', 'ID' => 100)); 

the haveUserInDatabase method will take care of a lot of default values and will add queries, using Codeception Db module methods, to insert user meta as well. The full signature for the method is

public function haveUserInDatabase($user_login, $user_id, $role = 'subscriber', Array $userData = []); 

while the checking methods is way simpler.
While led by immediate needs for a quicker way to write WordPress specific acceptance and functional tests I’m also trying to develop something that will suite my, and maybe someone else’s, needs in the future.

Share

The updated-as-I-work-on-it module is on Packagist and source is on GitHub.

I appreciate your input