PHP Class Codeception\Module\WPDb

Inheritance: extends ExtendedDb
Show file Open project: lucatume/wp-browser

Protected Properties

Property Type Description
$blogId The id of the blog currently used.
$config array The module optional configuration parameters.
$handlebars Handlebars\Handlebars
$isSubdomainMultisiteInstall boolean
$menuItems array
$menus array
$numberPlaceholder string
$requiredFields array url - the site url
$stylesheet The theme stylesheet in use.
$tablePrefix string The table prefix to use.
$tables tad\WPBrowser\Generators\Tables
$templateData array
$termKeys array
$termTaxonomyKeys array
$uniqueTables A list of tables that WordPress will nor replicate in multisite installations.

Public Methods

Method Description
_cleanup ( )
_initialize ( Handlebars\Handlebars $handlebars = null, tad\WPBrowser\Generators\Tables $table = null ) Initializes the module.
dontHaveBlogInDatabase ( array $criteria ) Removes an entry from the blogs table.
dontHaveCommentInDatabase ( array $criteria ) Removes an entry from the comments table.
dontHaveCommentMetaInDatabase ( array $criteria ) Removes an entry from the commentmeta table.
dontHaveLinkInDatabase ( array $criteria ) Removes a link from the database.
dontHaveOptionInDatabase ( $key, null $value = null ) : integer Removes an entry from the options table.
dontHavePostInDatabase ( array $criteria ) Removes an entry from the posts table.
dontHavePostMetaInDatabase ( array $criteria ) Removes an entry from the postmeta table.
dontHaveSiteOptionInDatabase ( $key, null $value = null ) Removes a site option from the database.
dontHaveSiteTransientInDatabase ( string $key ) Removes a site transient from the database.
dontHaveTermInDatabase ( array $criteria ) Removes a term from the database.
dontHaveTermMetaInDatabase ( array $criteria ) Removes a term meta from the database.
dontHaveTermRelationshipInDatabase ( array $criteria ) Removes an entry from the term_relationships table.
dontHaveTermTaxonomyInDatabase ( array $criteria ) Removes an entry from the term_taxonomy table.
dontHaveTransientInDatabase ( $transient ) : integer Removes a transient from the database.
dontHaveUserInDatabase ( integer | string $userIdOrLogin ) Removes a user from the database.
dontHaveUserMetaInDatabase ( array $criteria ) Removes an entry from the usermeta table.
dontSeeBlogInDatabase ( array $criteria ) Checks that a row is not present in the blogs table.
dontSeeCommentInDatabase ( array $criteria ) : void Checks that a comment is not in the database.
dontSeeCommentMetaInDatabase ( array $criteria ) : void Checks that a comment meta value is not in the database.
dontSeeLinkInDatabase ( array $criteria ) Checks that a link is not in the database.
dontSeeOptionInDatabase ( array $criteria ) Checks that an option is not in the database for the current blog.
dontSeePageInDatabase ( array $criteria ) Checks that a page is not in the database.
dontSeePostInDatabase ( array $criteria ) Checks that a post is not in the database.
dontSeePostMetaInDatabase ( array $criteria ) Checks that a post meta value is not there.
dontSeeTermInDatabase ( array $criteria ) Makes sure a term is not in the database.
dontSeeTermMetaInDatabase ( array $criteria ) Checks that a term meta is not in the database.
dontSeeTermTaxonomyInDatabase ( array $criteria ) Checks that a term taxonomy is not in the database.
dontSeeUserInDatabase ( array $criteria ) Checks that a user is not in the database.
dontSeeUserMetaInDatabase ( array $criteria ) Check that a user meta value is not in the database.
getSiteDomain ( ) : string Returns the site domain inferred from the url set in the config.
grabAllFromDatabase ( string $table, string $column, array $criteria ) : array Returns all entries matching a criteria from the database.
grabBlogVersionsTableName ( ) : string Gets the prefixed blog_versions table name.
grabBlogsTableName ( ) : string Gets the prefixed blogs table name.
grabCommentmetaTableName ( ) : string Returns the prefixed comment meta table name.
grabCommentsTableName ( ) : string Gets the comments table name.
grabLatestEntryByFromDatabase ( string $tableName, string $idColumn = 'ID' ) : mixed Returns the id value of the last table entry.
grabLinksTableName ( ) : string Returns the prefixed links table name.
grabOptionFromDatabase ( string $option_name ) : mixed | string Gets an option from the database.
grabPostMetaTableName ( ) : string Returns the prefixed post meta table name.
grabPostsTableName ( ) : string Gets the posts table name.
grabPrefixedTableNameFor ( string $tableName = '' ) : string Returns a prefixed table name for the current blog.
grabRegistrationLogTableName ( ) : string Gets the prefixed registration_log table name.
grabSignupsTableName ( ) : string Gets the prefixed signups table name.
grabSiteMetaTableName ( ) : string Gets the prefixed sitemeta table name.
grabSiteOptionFromDatabase ( string $key ) : mixed | string Gets a site option from the database.
grabSiteTableName ( ) : string Gets the prefixed site table name.
grabSiteTransientFromDatabase ( string $key ) : mixed | string Gets a site transient from the database.
grabSiteUrl ( ) : string Returns the current site url as specified in the module configuration.
grabTablePrefix ( ) : string Returns the table prefix, namespaced for secondary blogs if selected.
grabTermIdFromDatabase ( array $criteria ) Gets a term from the database.
grabTermMetaTableName ( ) : string Gets the terms meta table prefixed name.
grabTermRelationshipsTableName ( ) : string Gets the prefixed term relationships table name, e.g. wp_term_relationships.
grabTermTaxonomyIdFromDatabase ( array $criteria ) Gets a term_taxonomy_id from the database.
grabTermTaxonomyTableName ( ) : string Gets the prefixed term and taxonomy table name, e.g. wp_term_taxonomy.
grabTermsTableName ( ) : string Gets the prefixed terms table name, e.g. wp_terms.
grabUserIdFromDatabase ( string $userLogin ) : integer Gets the a user ID from the database using the user login.
grabUserMetaFromDatabase ( integer $userId, string $meta_key ) : array Gets a user meta from the database.
grabUsermetaTableName ( ) : string Returns the prefixed usermeta table name, e.g. wp_usermeta.
haveBlogInDatabase ( string $domainOrPath, array $overrides = [] ) : integer Inserts a blog in the blogs table.
haveCommentInDatabase ( integer $comment_post_ID, array $data = [] ) : integer Inserts a comment in the database.
haveCommentMetaInDatabase ( integer $comment_id, string $meta_key, mixed $meta_value ) : integer Inserts a comment meta field in the database.
haveLinkInDatabase ( array $overrides = [] ) : integer Inserts a link in the database.
haveManyBlogsInDatabase ( integer $count, array $overrides = [] ) : array Inserts many blogs in the database.
haveManyCommentsInDatabase ( integer $count, integer $comment_post_ID, array $overrides = [] ) : int[] Inserts many comments in the database.
haveManyLinksInDatabase ( integer $count, array $overrides = [] ) : array Inserts many links in the database.
haveManyPostsInDatabase ( integer $count, array $overrides = [] ) : array Inserts many posts in the database returning their IDs.
haveManyTermsInDatabase ( integer $count, string $name, string $taxonomy, array $overrides = [] ) : array Inserts many terms in the database.
haveManyUsersInDatabase ( $count, $user_login, $role = 'subscriber', array $overrides = [] )
haveMenuInDatabase ( string $slug, string $location, array $overrides = [] ) : array Creates and adds a menu to a theme location in the database.
haveMenuItemInDatabase ( string $menuSlug, string $title, integer | null $menuOrder = null, array $meta = [] ) : integer Adds a menu element to a menu for the current theme.
haveOptionInDatabase ( string $option_name, mixed $option_value, string $autoload = 'yes' ) : integer Inserts an option in the database.
havePageInDatabase ( array $overrides = [] ) Inserts a page in the database.
havePostInDatabase ( array $data = [] ) : integer Inserts a post in the database.
havePostmetaInDatabase ( integer $post_id, string $meta_key, mixed $meta_value ) : integer Adds one or more meta key and value couples in the database for a post.
haveSiteOptionInDatabase ( string $key, mixed $value ) : integer Inserts a site option in the database.
haveSiteTransientInDatabase ( $key, $value ) Inserts a site transient in the database.
haveTermInDatabase ( string $name, string $taxonomy, array $overrides = [] ) : array Inserts a term in the database.
haveTermMetaInDatabase ( integer $term_id, string $meta_key, mixed $meta_value ) : integer Inserts a term meta row in the database.
haveTermRelationshipInDatabase ( integer $object_id, integer $term_taxonomy_id, integer $term_order ) Creates a term relationship in the database.
haveTransientInDatabase ( string $transient, mixed $value ) : integer Inserts a transient in the database.
haveUserCapabilitiesInDatabase ( integer $userId, string | array $role ) : array Sets a user capabilities.
haveUserInDatabase ( string $user_login, string $role = 'subscriber', array $overrides = [] ) : integer Inserts a user and appropriate meta in the database.
haveUserLevelsInDatabase ( integer $userId, string | array $role ) : array Sets the user level in the database for a user.
haveUserMetaInDatabase ( integer $userId, string $meta_key, mixed $meta_value ) : array Sets a user meta.
replaceSiteDomainInMultisiteSql ( $sql )
replaceSiteDomainInSql ( string $sql ) : string Replaces the WordPress domains in a SQL dump string.
seeBlogInDatabase ( array $criteria ) Checks for a blog in the database, looks up the blogs table.
seeCommentInDatabase ( array $criteria ) : void Checks for a comment in the database.
seeCommentMetaInDatabase ( array $criteria ) : void Checks that a comment meta value is in the database.
seeLinkInDatabase ( array $criteria ) Checks for a link in the database.
seeOptionInDatabase ( array $criteria ) Checks if an option is in the database for the current blog.
seePageInDatabase ( array $criteria ) Checks for a page in the database.
seePostInDatabase ( array $criteria ) Checks for a post in the database.
seePostMetaInDatabase ( array $criteria ) Checks for a post meta value in the database for the current blog.
seePostWithTermInDatabase ( integer $post_id, integer $term_id, integer $term_order ) : void Checks that a post to term relation exists in the database.
seeSiteOptionInDatabase ( string $key, mixed | null $value = null ) Checks that a site option is in the database.
seeSiteSiteTransientInDatabase ( string $key, mixed | null $value = null ) Checks that a site option is in the database.
seeTableInDatabase ( string $table ) Checks for a table in the database.
seeTermInDatabase ( array $criteria ) Checks for a term in the database.
seeTermMetaInDatabase ( array $criteria ) Checks for a term meta in the database.
seeTermRelationshipInDatabase ( array $criteria ) Checks for a term relationship in the database.
seeTermTaxonomyInDatabase ( array $criteria ) Checks for a term taxonomy in the database.
seeUserInDatabase ( array $criteria ) : void Checks that a user is in the database.
seeUserMetaInDatabase ( array $criteria ) Checks for a user meta value in the database.
useBlog ( integer $id ) Sets the blog to be used.
useMainBlog ( ) Sets the current blog to the main one (blog_id 1).
useTheme ( string $stylesheet, string | null $template = null, string | null $themeName = null ) Sets the current theme options.

Protected Methods

Method Description
_seeTableInDatabase ( $table ) : integer
getSiteSubfolder ( ) : string
getUsersTableName ( ) : string Returns the users table name, e.g. wp_users.
initialize_driver ( )
maybeCheckTermExistsInDatabase ( integer $term_id ) : void Conditionally checks that a term exists in the database.
maybeSerialize ( $value ) : string
replaceNumbersInArray ( $entry, $i )
replaceNumbersInString ( $value, $i ) : mixed
setTemplateData ( array $overrides = [] )

Private Methods

Method Description
importSqlDumpFile ( )
increaseTermCountBy ( $termTaxonomyId, $by = 1 )
maybeUnserialize ( $value )
prepareSqlDumpFile ( )

Method Details

_cleanup() public method

public _cleanup ( )

_initialize() public method

Initializes the module.
public _initialize ( Handlebars\Handlebars $handlebars = null, tad\WPBrowser\Generators\Tables $table = null )
$handlebars Handlebars\Handlebars
$table tad\WPBrowser\Generators\Tables

_seeTableInDatabase() protected method

protected _seeTableInDatabase ( $table ) : integer
$table
return integer

dontHaveBlogInDatabase() public method

Removes an entry from the blogs table.
public dontHaveBlogInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontHaveCommentInDatabase() public method

Removes an entry from the comments table.
public dontHaveCommentInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontHaveCommentMetaInDatabase() public method

Removes an entry from the commentmeta table.
public dontHaveCommentMetaInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontHaveLinkInDatabase() public method

Removes a link from the database.
public dontHaveLinkInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontHaveOptionInDatabase() public method

Removes an entry from the options table.
public dontHaveOptionInDatabase ( $key, null $value = null ) : integer
$key
$value null
return integer The removed option `option_id`.

dontHavePostInDatabase() public method

Removes an entry from the posts table.
public dontHavePostInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontHavePostMetaInDatabase() public method

Removes an entry from the postmeta table.
public dontHavePostMetaInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontHaveSiteOptionInDatabase() public method

Removes a site option from the database.
public dontHaveSiteOptionInDatabase ( $key, null $value = null )
$key
$value null

dontHaveSiteTransientInDatabase() public method

Removes a site transient from the database.

dontHaveTermInDatabase() public method

Removes a term from the database.
public dontHaveTermInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontHaveTermMetaInDatabase() public method

Removes a term meta from the database.
public dontHaveTermMetaInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontHaveTermRelationshipInDatabase() public method

Removes an entry from the term_relationships table.
public dontHaveTermRelationshipInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontHaveTermTaxonomyInDatabase() public method

Removes an entry from the term_taxonomy table.
public dontHaveTermTaxonomyInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontHaveTransientInDatabase() public method

Removes a transient from the database.
public dontHaveTransientInDatabase ( $transient ) : integer
$transient
return integer The removed option `option_id`.

dontHaveUserInDatabase() public method

Removes a user from the database.
public dontHaveUserInDatabase ( integer | string $userIdOrLogin )
$userIdOrLogin integer | string

dontHaveUserMetaInDatabase() public method

Removes an entry from the usermeta table.
public dontHaveUserMetaInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontSeeBlogInDatabase() public method

Checks that a row is not present in the blogs table.
public dontSeeBlogInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontSeeCommentInDatabase() public method

Will look up the "comments" table.
public dontSeeCommentInDatabase ( array $criteria ) : void
$criteria array
return void

dontSeeCommentMetaInDatabase() public method

Will look up the "commentmeta" table.
public dontSeeCommentMetaInDatabase ( array $criteria ) : void
$criteria array
return void

dontSeeLinkInDatabase() public method

Will look up the "links" table.
public dontSeeLinkInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontSeeOptionInDatabase() public method

If the value is an object or an array then the serialized option will be checked for.
public dontSeeOptionInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontSeePageInDatabase() public method

Checks that a page is not in the database.
public dontSeePageInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontSeePostInDatabase() public method

Checks that a post is not in the database.
public dontSeePostInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontSeePostMetaInDatabase() public method

If the meta value is an object or an array then the serialized version will be checked for.
public dontSeePostMetaInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontSeeTermInDatabase() public method

Looks up both the terms table and the term_taxonomy tables.
public dontSeeTermInDatabase ( array $criteria )
$criteria array An array of criteria to search for the term, can be columns from the `terms` and the `term_taxonomy` tables.

dontSeeTermMetaInDatabase() public method

Checks that a term meta is not in the database.
public dontSeeTermMetaInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontSeeTermTaxonomyInDatabase() public method

Will look up the prefixed term_taxonomy table, e.g. wp_term_taxonomy.
public dontSeeTermTaxonomyInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontSeeUserInDatabase() public method

Checks that a user is not in the database.
public dontSeeUserInDatabase ( array $criteria )
$criteria array An array of search criteria.

dontSeeUserMetaInDatabase() public method

Check that a user meta value is not in the database.
public dontSeeUserMetaInDatabase ( array $criteria )
$criteria array An array of search criteria.

getSiteDomain() public method

Returns the site domain inferred from the url set in the config.
public getSiteDomain ( ) : string
return string

getSiteSubfolder() protected method

protected getSiteSubfolder ( ) : string
return string

getUsersTableName() protected method

Returns the users table name, e.g. wp_users.
protected getUsersTableName ( ) : string
return string

grabAllFromDatabase() public method

Returns all entries matching a criteria from the database.
public grabAllFromDatabase ( string $table, string $column, array $criteria ) : array
$table string
$column string
$criteria array
return array An array of results.

grabBlogVersionsTableName() public method

Gets the prefixed blog_versions table name.

grabBlogsTableName() public method

Gets the prefixed blogs table name.
public grabBlogsTableName ( ) : string
return string

grabCommentmetaTableName() public method

E.g. wp_commentmeta.
public grabCommentmetaTableName ( ) : string
return string

grabCommentsTableName() public method

Gets the comments table name.
public grabCommentsTableName ( ) : string
return string The prefixed table name, e.g. `wp_comments`.

grabLatestEntryByFromDatabase() public method

Returns the id value of the last table entry.
public grabLatestEntryByFromDatabase ( string $tableName, string $idColumn = 'ID' ) : mixed
$tableName string
$idColumn string
return mixed

grabLinksTableName() public method

E.g. wp_links.
public grabLinksTableName ( ) : string
return string

grabOptionFromDatabase() public method

Gets an option from the database.
public grabOptionFromDatabase ( string $option_name ) : mixed | string
$option_name string
return mixed | string

grabPostMetaTableName() public method

Returns the prefixed post meta table name.
public grabPostMetaTableName ( ) : string
return string The prefixed `postmeta` table name, e.g. `wp_postmeta`.

grabPostsTableName() public method

Gets the posts table name.
public grabPostsTableName ( ) : string
return string The prefixed table name, e.g. `wp_posts`

grabPrefixedTableNameFor() public method

If the table is not one to be prefixed (e.g. users) then the proper table name will be returned.
public grabPrefixedTableNameFor ( string $tableName = '' ) : string
$tableName string The table name, e.g. `options`.
return string The prefixed table name, e.g. `wp_options` or `wp_2_options`.

grabRegistrationLogTableName() public method

Gets the prefixed registration_log table name.

grabSignupsTableName() public method

Gets the prefixed signups table name.
public grabSignupsTableName ( ) : string
return string

grabSiteMetaTableName() public method

Gets the prefixed sitemeta table name.
public grabSiteMetaTableName ( ) : string
return string

grabSiteOptionFromDatabase() public method

Gets a site option from the database.
public grabSiteOptionFromDatabase ( string $key ) : mixed | string
$key string
return mixed | string

grabSiteTableName() public method

Gets the prefixed site table name.
public grabSiteTableName ( ) : string
return string

grabSiteTransientFromDatabase() public method

Gets a site transient from the database.
public grabSiteTransientFromDatabase ( string $key ) : mixed | string
$key string
return mixed | string

grabSiteUrl() public method

Returns the current site url as specified in the module configuration.
public grabSiteUrl ( ) : string
return string The current site URL

grabTablePrefix() public method

Returns the table prefix, namespaced for secondary blogs if selected.
public grabTablePrefix ( ) : string
return string The blog aware table prefix.

grabTermIdFromDatabase() public method

Looks up the prefixed terms table, e.g. wp_terms.
public grabTermIdFromDatabase ( array $criteria )
$criteria array An array of search criteria.

grabTermMetaTableName() public method

E.g.: wp_termmeta.
public grabTermMetaTableName ( ) : string
return string

grabTermRelationshipsTableName() public method

Gets the prefixed term relationships table name, e.g. wp_term_relationships.

grabTermTaxonomyIdFromDatabase() public method

Looks up the prefixed terms_relationships table, e.g. wp_term_relationships.
public grabTermTaxonomyIdFromDatabase ( array $criteria )
$criteria array An array of search criteria.

grabTermTaxonomyTableName() public method

Gets the prefixed term and taxonomy table name, e.g. wp_term_taxonomy.

grabTermsTableName() public method

Gets the prefixed terms table name, e.g. wp_terms.
public grabTermsTableName ( ) : string
return string

grabUserIdFromDatabase() public method

Gets the a user ID from the database using the user login.
public grabUserIdFromDatabase ( string $userLogin ) : integer
$userLogin string
return integer The user ID

grabUserMetaFromDatabase() public method

Gets a user meta from the database.
public grabUserMetaFromDatabase ( integer $userId, string $meta_key ) : array
$userId integer
$meta_key string
return array An associative array of meta key/values.

grabUsermetaTableName() public method

Returns the prefixed usermeta table name, e.g. wp_usermeta.
public grabUsermetaTableName ( ) : string
return string

haveBlogInDatabase() public method

Inserts a blog in the blogs table.
public haveBlogInDatabase ( string $domainOrPath, array $overrides = [] ) : integer
$domainOrPath string The subdomain or the path to the be used for the blog.
$overrides array An array of values to override the defaults.
return integer The inserted blog `blog_id`.

haveCommentInDatabase() public method

Inserts a comment in the database.
public haveCommentInDatabase ( integer $comment_post_ID, array $data = [] ) : integer
$comment_post_ID integer The id of the post the comment refers to.
$data array The comment data overriding default and random generated values.
return integer The inserted comment `comment_id`

haveCommentMetaInDatabase() public method

Array and object meta values will be serialized.
public haveCommentMetaInDatabase ( integer $comment_id, string $meta_key, mixed $meta_value ) : integer
$comment_id integer
$meta_key string
$meta_value mixed
return integer The inserted comment meta ID

haveLinkInDatabase() public method

Inserts a link in the database.
public haveLinkInDatabase ( array $overrides = [] ) : integer
$overrides array The data to insert.
return integer The inserted link `link_id`.

haveManyBlogsInDatabase() public method

Inserts many blogs in the database.
public haveManyBlogsInDatabase ( integer $count, array $overrides = [] ) : array
$count integer
$overrides array
return array An array of inserted blogs `blog_id`s.

haveManyCommentsInDatabase() public method

Inserts many comments in the database.
public haveManyCommentsInDatabase ( integer $count, integer $comment_post_ID, array $overrides = [] ) : int[]
$count integer The number of comments to insert.
$comment_post_ID integer The comment parent post ID.
$overrides array An associative array to override the defaults.
return int[] An array containing the inserted comments IDs.

haveManyLinksInDatabase() public method

Inserts many links in the database.
public haveManyLinksInDatabase ( integer $count, array $overrides = [] ) : array
$count integer
$overrides array
return array An array of inserted `link_id`s.

haveManyPostsInDatabase() public method

Inserts many posts in the database returning their IDs.
public haveManyPostsInDatabase ( integer $count, array $overrides = [] ) : array
$count integer The number of posts to insert.
$overrides array { An array of values to override the defaults. The `{{n}}` placeholder can be used to have the post count inserted in its place; e.g. `Post Title - {{n}}` will be set to `Post Title - 0` for the first post, `Post Title - 1` for the second one and so on. The same applies to meta values as well.
return array

haveManyTermsInDatabase() public method

Inserts many terms in the database.
public haveManyTermsInDatabase ( integer $count, string $name, string $taxonomy, array $overrides = [] ) : array
$count integer
$name string The term name.
$taxonomy string The taxonomy name.
$overrides array An associative array of default overrides.
return array An array of inserted terms `term_id`s.

haveManyUsersInDatabase() public method

public haveManyUsersInDatabase ( $count, $user_login, $role = 'subscriber', array $overrides = [] )
$overrides array

haveMenuInDatabase() public method

Creates and adds a menu to a theme location in the database.
public haveMenuInDatabase ( string $slug, string $location, array $overrides = [] ) : array
$slug string The menu slug.
$location string The theme menu location the menu will be assigned to.
$overrides array An array of values to override the defaults.
return array An array containing the created menu `term_id` and `term_taxonomy_id`.

haveMenuItemInDatabase() public method

Adds a menu element to a menu for the current theme.
public haveMenuItemInDatabase ( string $menuSlug, string $title, integer | null $menuOrder = null, array $meta = [] ) : integer
$menuSlug string The menu slug the item should be added to.
$title string The menu item title.
$menuOrder integer | null An optional menu order, `1` based.
$meta array An associative array that will be prefixed with `_menu_item_` for the item post meta.
return integer The menu item post `ID`

haveOptionInDatabase() public method

If the option value is an object or an array then the value will be serialized.
public haveOptionInDatabase ( string $option_name, mixed $option_value, string $autoload = 'yes' ) : integer
$option_name string
$option_value mixed
$autoload string
return integer The inserted `option_id`

havePageInDatabase() public method

Inserts a page in the database.
public havePageInDatabase ( array $overrides = [] )
$overrides array An array of values to override the default ones.

havePostInDatabase() public method

Inserts a post in the database.
public havePostInDatabase ( array $data = [] ) : integer
$data array An associative array of post data to override default and random generated values.
return integer post_id The inserted post ID.

havePostmetaInDatabase() public method

Adds one or more meta key and value couples in the database for a post.
public havePostmetaInDatabase ( integer $post_id, string $meta_key, mixed $meta_value ) : integer
$post_id integer
$meta_key string
$meta_value mixed The value to insert in the database, objects and arrays will be serialized.
return integer The inserted meta `meta_id`.

haveSiteOptionInDatabase() public method

If the value is an array or an object then the value will be serialized.
public haveSiteOptionInDatabase ( string $key, mixed $value ) : integer
$key string
$value mixed
return integer The inserted option `option_id`.

haveSiteTransientInDatabase() public method

If the value is an array or an object then the value will be serialized.
public haveSiteTransientInDatabase ( $key, $value )
$key
$value

haveTermInDatabase() public method

Inserts a term in the database.
public haveTermInDatabase ( string $name, string $taxonomy, array $overrides = [] ) : array
$name string The term name, e.g. "Fuzzy".
$taxonomy string The term taxonomy
$overrides array An array of values to override the default ones.
return array An array containing `term_id` and `term_taxonomy_id` of the inserted term.

haveTermMetaInDatabase() public method

Objects and array meta values will be serialized.
public haveTermMetaInDatabase ( integer $term_id, string $meta_key, mixed $meta_value ) : integer
$term_id integer
$meta_key string
$meta_value mixed
return integer The inserted term meta `meta_id`

haveTermRelationshipInDatabase() public method

Please mind that no check about the consistency of the insertion is made. E.g. a post could be assigned a term from a taxonomy that's not registered for that post type.
public haveTermRelationshipInDatabase ( integer $object_id, integer $term_taxonomy_id, integer $term_order )
$object_id integer A post ID, a user ID or anything that can be assigned a taxonomy term.
$term_taxonomy_id integer
$term_order integer Defaults to `0`.

haveTransientInDatabase() public method

If the value is an array or an object then the value will be serialized.
public haveTransientInDatabase ( string $transient, mixed $value ) : integer
$transient string
$value mixed
return integer The inserted option `option_id`.

haveUserCapabilitiesInDatabase() public method

Sets a user capabilities.
public haveUserCapabilitiesInDatabase ( integer $userId, string | array $role ) : array
$userId integer
$role string | array Either a role string (e.g. `administrator`) or an associative array of blog IDs/roles for a multisite installation; e.g. `[1 => 'administrator`, 2 => 'subscriber']`.
return array An array of inserted `meta_id`.

haveUserInDatabase() public method

Inserts a user and appropriate meta in the database.
public haveUserInDatabase ( string $user_login, string $role = 'subscriber', array $overrides = [] ) : integer
$user_login string The user login slug
$role string The user role slug, e.g. "administrator"; defaults to "subscriber".
$overrides array An associative array of column names and values overridind defaults in the "users" and "usermeta" table.
return integer The inserted user `ID`

haveUserLevelsInDatabase() public method

Sets the user level in the database for a user.
public haveUserLevelsInDatabase ( integer $userId, string | array $role ) : array
$userId integer
$role string | array Either a role string (e.g. `administrator`) or an array of blog IDs/roles for a multisite installation.
return array An array of inserted `meta_id`.

haveUserMetaInDatabase() public method

Sets a user meta.
public haveUserMetaInDatabase ( integer $userId, string $meta_key, mixed $meta_value ) : array
$userId integer
$meta_key string
$meta_value mixed Either a single value or an array of values; objects will be serialized while array of values will trigger the insertion of multiple rows.
return array An array of inserted `user_id`.

initialize_driver() protected method

protected initialize_driver ( )

maybeCheckTermExistsInDatabase() protected method

Will look up the "terms" table, will throw if not found.
protected maybeCheckTermExistsInDatabase ( integer $term_id ) : void
$term_id integer The term ID.
return void

maybeSerialize() protected method

protected maybeSerialize ( $value ) : string
$value
return string

replaceNumbersInArray() protected method

protected replaceNumbersInArray ( $entry, $i )

replaceNumbersInString() protected method

protected replaceNumbersInString ( $value, $i ) : mixed
$value
$i
return mixed

replaceSiteDomainInMultisiteSql() public method

replaceSiteDomainInSql() public method

Replaces the WordPress domains in a SQL dump string.
public replaceSiteDomainInSql ( string $sql ) : string
$sql string The input SQL dump string.
return string The modified SQL string.

seeBlogInDatabase() public method

Checks for a blog in the database, looks up the blogs table.
public seeBlogInDatabase ( array $criteria )
$criteria array An array of search criteria.

seeCommentInDatabase() public method

Will look up the "comments" table.
public seeCommentInDatabase ( array $criteria ) : void
$criteria array
return void

seeCommentMetaInDatabase() public method

Will look up the "commentmeta" table.
public seeCommentMetaInDatabase ( array $criteria ) : void
$criteria array
return void

seeLinkInDatabase() public method

Will look up the "links" table.
public seeLinkInDatabase ( array $criteria )
$criteria array An array of search criteria.

seeOptionInDatabase() public method

If checking for an array or an object then the serialized version will be checked for.
public seeOptionInDatabase ( array $criteria )
$criteria array An array of search criteria.

seePageInDatabase() public method

Checks for a page in the database.
public seePageInDatabase ( array $criteria )
$criteria array An array of search criteria.

seePostInDatabase() public method

Checks for a post in the database.
public seePostInDatabase ( array $criteria )
$criteria array An array of search criteria.

seePostMetaInDatabase() public method

If the meta_value is an object or an array then the serialized value will be checked for.
public seePostMetaInDatabase ( array $criteria )
$criteria array An array of search criteria.

seePostWithTermInDatabase() public method

Will look up the "term_relationships" table.
public seePostWithTermInDatabase ( integer $post_id, integer $term_id, integer $term_order ) : void
$post_id integer The post ID.
$term_id integer The term ID.
$term_order integer The order the term applies to the post, defaults to 0.
return void

seeSiteOptionInDatabase() public method

Checks that a site option is in the database.
public seeSiteOptionInDatabase ( string $key, mixed | null $value = null )
$key string
$value mixed | null

seeSiteSiteTransientInDatabase() public method

Checks that a site option is in the database.
public seeSiteSiteTransientInDatabase ( string $key, mixed | null $value = null )
$key string
$value mixed | null

seeTableInDatabase() public method

Checks for a table in the database.
public seeTableInDatabase ( string $table )
$table string

seeTermInDatabase() public method

Looks up the terms and term_taxonomy prefixed tables.
public seeTermInDatabase ( array $criteria )
$criteria array An array of criteria to search for the term, can be columns from the `terms` and the `term_taxonomy` tables.

seeTermMetaInDatabase() public method

Checks for a term meta in the database.
public seeTermMetaInDatabase ( array $criteria )
$criteria array An array of search criteria.

seeTermRelationshipInDatabase() public method

Checks for a term relationship in the database.
public seeTermRelationshipInDatabase ( array $criteria )
$criteria array An array of search criteria.

seeTermTaxonomyInDatabase() public method

Will look up the prefixed term_taxonomy table, e.g. wp_term_taxonomy.
public seeTermTaxonomyInDatabase ( array $criteria )
$criteria array An array of search criteria.

seeUserInDatabase() public method

Will look up the "users" table.
public seeUserInDatabase ( array $criteria ) : void
$criteria array
return void

seeUserMetaInDatabase() public method

Checks for a user meta value in the database.
public seeUserMetaInDatabase ( array $criteria )
$criteria array An array of search criteria.

setTemplateData() protected method

protected setTemplateData ( array $overrides = [] )
$overrides array

useBlog() public method

Sets the blog to be used.
public useBlog ( integer $id )
$id integer

useMainBlog() public method

Sets the current blog to the main one (blog_id 1).
public useMainBlog ( )

useTheme() public method

Sets the current theme options.
public useTheme ( string $stylesheet, string | null $template = null, string | null $themeName = null )
$stylesheet string The theme stylesheet slug, e.g. `twentysixteen`.
$template string | null The theme template slug, e.g. `twentysixteen`, defaults to `$stylesheet`.
$themeName string | null The theme name, e.g. `Twentysixteen`, defaults to title version of `$stylesheet`.

Property Details

$blogId protected property

The id of the blog currently used.
protected $blogId

$config protected property

The module optional configuration parameters.
protected array $config
return array

$handlebars protected property

protected Handlebars,Handlebars $handlebars
return Handlebars\Handlebars

$isSubdomainMultisiteInstall protected property

protected bool $isSubdomainMultisiteInstall
return boolean

$menuItems protected property

protected array $menuItems
return array

$menus protected property

protected array $menus
return array

$numberPlaceholder protected property

protected string $numberPlaceholder
return string

$requiredFields protected property

url - the site url
protected array $requiredFields
return array

$stylesheet protected property

The theme stylesheet in use.
protected $stylesheet

$tablePrefix protected property

The table prefix to use.
protected string $tablePrefix
return string

$tables protected property

protected Tables,tad\WPBrowser\Generators $tables
return tad\WPBrowser\Generators\Tables

$templateData protected property

protected array $templateData
return array

$termKeys protected property

protected array $termKeys
return array

$termTaxonomyKeys protected property

protected array $termTaxonomyKeys
return array

$uniqueTables protected property

A list of tables that WordPress will nor replicate in multisite installations.
protected $uniqueTables