Default tables and many users in WPDb

All WordPress default tables covered and many users.


WordPress defines a number of tables by default and WPDb was not covering all of them properly.
The latest version of the WPDb module, part of wp-browser 1.8.4, closes the cycle covering all of them with the Codeception familiar database syntax:

  • haveSomethingInDatabase to insert a new row in a table
  • dontHaveSomethingInDatabase to remove a row from a table
  • seeSomethingInDatabase to check for a row in a table
  • dontSeeSometingInDatabase to check that a row is not in a table

Users, posts, comments, terms and links are all taken into account.

Many users

A method missing from earlier versions was one to insert many users in the database similarly to what haveManyPostsInDatabase allows and I took care to add that, this code is now possible in a test case implementing the WPDb module:

public function test_many_users(FunctionalTester $I){
    $I->haveManyUsersInDatabase(5, 'Luca', 'editor');

    for($i = 0; $i < 5, $i++){
        $I->seeUserInDatabase(['user_login'=> 'Luca_' . $i]);

adding many users holds the same power found in the haveUserInDatabase method like multisite support and the like.


While I’m at it I will add the possibility to add user meta fields along with the user insertion, terms meta (a feature of WordPress 4.4) and will work on easier multisite installation handling.