src/Codeception/Module/WPDb.php
public function haveBlogInDatabase($domainOrPath, array $overrides = [], $subdomain = true)
    {
        $base = Blog::makeDefaults($subdomain);
        if ($subdomain) {
            $base['domain'] = false !== strpos($domainOrPath, $this->getSiteDomain())
                ? $domainOrPath
                : trim($domainOrPath, '/') . '.' . $this->getSiteDomain();
            $base['path'] = '/';
        } else {
            $base['domain'] = $this->getSiteDomain();
            $base['path'] = '/' . trim($domainOrPath, '/') . '/';
        }

        $data = array_merge($base, array_intersect_key($overrides, $base));

        // Make sure the path is in the `/path/` format.
        if (isset($data['path']) && $data['path'] !== '/') {
            $data['path'] = '/' . Utils::unleadslashit(Utils::untrailslashit($data['path'])) . '/';
        }

        $blogId = $this->haveInDatabase($this->grabBlogsTableName(), $data);
        $this->scaffoldBlogTables($blogId, $domainOrPath, (bool)$subdomain);

        if (($fs = $this->getWpFilesystemModule(false)) instanceof WPFilesystem) {
            $this->debug('Scaffolding blog uploads directories.');
            $fs->makeUploadsDir("sites/{$blogId}");
        }

        return $blogId;
    }
public function haveBlogInDatabase($domainOrPath, array $overrides = [], $subdomain = true)
    {
        $base = Blog::makeDefaults($subdomain);
        if ($subdomain) {
            $base['domain'] = false !== strpos($domainOrPath, $this->getSiteDomain())
                ? $domainOrPath
                : trim($domainOrPath, '/') . '.' . $this->getSiteDomain();
            $base['path'] = '/';
        } else {
            $base['domain'] = $this->getSiteDomain();
            $base['path'] = '/' . trim($domainOrPath, '/') . '/';
        }

        $data = array_merge($base, array_intersect_key($overrides, $base));

        // Make sure the path is in the `/path/` format.
        if (isset($data['path']) && $data['path'] !== '/') {
            $data['path'] = '/' . Utils::unleadslashit(Utils::untrailslashit($data['path'])) . '/';
        }

        $blogId = $this->haveInDatabase($this->grabBlogsTableName(), $data);
        $this->scaffoldBlogTables($blogId, $domainOrPath, (bool)$subdomain);

        if (($fs = $this->getWpFilesystemModule(false)) instanceof WPFilesystem) {
            $this->debug('Scaffolding blog uploads directories.');
            $fs->makeUploadsDir("sites/{$blogId}");
        }

        return $blogId;
    }
public function haveBlogInDatabase ( $ domainOrPath , array $ overrides = [ ] , $ subdomain = true ) { $ base = Blog :: makeDefaults ( $ subdomain ) ; if ( $ subdomain ) { $ base [ 'domain' ] = false !== strpos ( $ domainOrPath , $ this -> getSiteDomain ( ) ) ? $ domainOrPath : trim ( $ domainOrPath , '/' ) . '.' . $ this -> getSiteDomain ( ) ; $ base [ 'path' ] = '/' ; } else { $ base [ 'domain' ] = $ this -> getSiteDomain ( ) ; $ base [ 'path' ] = '/' . trim ( $ domainOrPath , '/' ) . '/' ; } $ data = array_merge ( $ base , array_intersect_key ( $ overrides , $ base ) ) ; // Make sure the path is in the `/path/` format. if ( isset ( $ data [ 'path' ] ) && $ data [ 'path' ] !== '/' ) { $ data [ 'path' ] = '/' . Utils :: unleadslashit ( Utils :: untrailslashit ( $ data [ 'path' ] ) ) . '/' ; } $ blogId = $ this -> haveInDatabase ( $ this -> grabBlogsTableName ( ) , $ data ) ; $ this -> scaffoldBlogTables ( $ blogId , $ domainOrPath , ( bool ) $ subdomain ) ; if ( ( $ fs = $ this -> getWpFilesystemModule ( false ) ) instanceof WPFilesystem ) { $ this -> debug ( 'Scaffolding blog uploads directories.' ) ; $ fs -> makeUploadsDir ( "sites/{$blogId}" ) ; } return $ blogId ; }
Inserts a blog in the `blogs` table.

@example
```php
// Create the `test` subdomain blog.
$blogId = $I->haveBlogInDatabase('test', ['administrator' => $userId]);
// Create the `/test` subfolder blog.
$blogId = $I->haveBlogInDatabase('test', ['administrator' => $userId], false);
```

@param  string $domainOrPath     The subdomain or the path to the be used for the blog.
@param array   $overrides        An array of values to override the defaults.
@param bool    $subdomain        Whether the new blog should be created as a subdomain (`true`)
or subfolder (`true`)

@return int The inserted blog `blog_id`.
Inserts a blog in the blogs table .