Scaffolding WordPress multisite installation tables in WPDb.
New tables
As explained in an earlier post I’m trying to give the WPDb module, part of wp-browser, the capability to deal with more complex fixtures set up.
I’ve covered posts, users, comments, terms and the like (taking term meta into account) and am missing the elephant in the room that is multisite.
Multisite in WordPress means, from a database perspective, new tables.
This first step of table creation and alteration (the users
table) I’ve covered in the last code update I’ve tagged version 1.8.7a
and it all comes down to the haveMultisite
method.
Small and powerful
Moving by increments the haveMultisite
method still does not allow to specify the type of multisite installation (sub-domain based or sub-folder based) required but is already taking charge of creating the missing multisite tables if missing and of altering the users
one.
Since this is happening, presumably, in a Cest
test class _before
method a use scenario for the method might be this one presuming the WPDb
and WPWebDriver
modules are used together:
use tad\WPBrowser\Generators\Tables;
class MultisiteTestCest {
public function _before( FunctionalTester $I ) {
$I->haveMultisite();
$blog1 = $I->haveBlog(['domain'=> 'blog1']);
$blog2 = $I->haveBlog(['domain'=> 'blog2']);
$I->useBlog($blog1);
$blog1posts = $I->haveManyPosts(10, ['post_title' => 'Blog 1 Post {{n}}']);
$I->useBlog($blog2);
$blog2posts = $I->haveManyPosts(10, ['post_title' => 'Blog 2 Post {{n}}']);
}
public function _after( FunctionalTester $I ) {
}
/**
* @test
* it should show different blog posts for different blogs
*/
public function it_should_show_different_blog_for_different_blog_posts( FunctionalTester $I ) {
$I->amOnBlog('blog1');
$I->amOnPage('/');
$I->see('Blog 1 Post 0');
$I->amOnBlog('blog2');
$I->amOnPage('/');
$I->see('Blog 2 Post 0');
}
}
the methods haveBlog
and amOnBlog
will be part of the next iteration on the code.