repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
lexxyungcarter/laravel-5-messenger | examples/MessagesController.php | MessagesController.read | public function read($id)
{
$thread = Thread::find($id);
if (!$thread) {
abort(404);
}
$thread->markAsRead(Auth::id());
} | php | public function read($id)
{
$thread = Thread::find($id);
if (!$thread) {
abort(404);
}
$thread->markAsRead(Auth::id());
} | [
"public",
"function",
"read",
"(",
"$",
"id",
")",
"{",
"$",
"thread",
"=",
"Thread",
"::",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"thread",
")",
"{",
"abort",
"(",
"404",
")",
";",
"}",
"$",
"thread",
"->",
"markAsRead",
"(",
... | Mark a specific thread as read, for ajax use.
@param $id | [
"Mark",
"a",
"specific",
"thread",
"as",
"read",
"for",
"ajax",
"use",
"."
] | train | https://github.com/lexxyungcarter/laravel-5-messenger/blob/d98d00b1e9e70b82748beb06f0470b6609ebc9ca/examples/MessagesController.php#L240-L248 |
lexxyungcarter/laravel-5-messenger | src/Models/Message.php | Message.scopeUnreadForUser | public function scopeUnreadForUser(Builder $query, $userId)
{
return $query->has('thread')
->where('user_id', '!=', $userId)
->whereHas('participants', function (Builder $query) use ($userId) {
$query->where('user_id', $userId)
->whereNull('deleted... | php | public function scopeUnreadForUser(Builder $query, $userId)
{
return $query->has('thread')
->where('user_id', '!=', $userId)
->whereHas('participants', function (Builder $query) use ($userId) {
$query->where('user_id', $userId)
->whereNull('deleted... | [
"public",
"function",
"scopeUnreadForUser",
"(",
"Builder",
"$",
"query",
",",
"$",
"userId",
")",
"{",
"return",
"$",
"query",
"->",
"has",
"(",
"'thread'",
")",
"->",
"where",
"(",
"'user_id'",
",",
"'!='",
",",
"$",
"userId",
")",
"->",
"whereHas",
... | Returns unread messages given the userId.
@param \Illuminate\Database\Eloquent\Builder $query
@param int $userId
@return \Illuminate\Database\Eloquent\Builder | [
"Returns",
"unread",
"messages",
"given",
"the",
"userId",
"."
] | train | https://github.com/lexxyungcarter/laravel-5-messenger/blob/d98d00b1e9e70b82748beb06f0470b6609ebc9ca/src/Models/Message.php#L104-L116 |
lexxyungcarter/laravel-5-messenger | src/Traits/Messagable.php | Messagable.threadsWithNewMessages | public function threadsWithNewMessages()
{
return $this->threads()
->where(function (Builder $q) {
$q->whereIn(Models::table('threads') . '.id', $this->unreadMessages()->pluck('thread_id'));
})
->get();
} | php | public function threadsWithNewMessages()
{
return $this->threads()
->where(function (Builder $q) {
$q->whereIn(Models::table('threads') . '.id', $this->unreadMessages()->pluck('thread_id'));
})
->get();
} | [
"public",
"function",
"threadsWithNewMessages",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"threads",
"(",
")",
"->",
"where",
"(",
"function",
"(",
"Builder",
"$",
"q",
")",
"{",
"$",
"q",
"->",
"whereIn",
"(",
"Models",
"::",
"table",
"(",
"'threads... | Returns all threads with new messages.
@return \Illuminate\Database\Eloquent\Collection | [
"Returns",
"all",
"threads",
"with",
"new",
"messages",
"."
] | train | https://github.com/lexxyungcarter/laravel-5-messenger/blob/d98d00b1e9e70b82748beb06f0470b6609ebc9ca/src/Traits/Messagable.php#L89-L96 |
paulgibbs/behat-wordpress-extension | src/Compiler/DriverElementPass.php | DriverElementPass.process | public function process(ContainerBuilder $container)
{
$wordpress = $container->getDefinition('wordpress.wordpress');
if (! $wordpress) {
return;
}
foreach ($container->findTaggedServiceIds('wordpress.element') as $id => $attributes) {
foreach ($attributes as... | php | public function process(ContainerBuilder $container)
{
$wordpress = $container->getDefinition('wordpress.wordpress');
if (! $wordpress) {
return;
}
foreach ($container->findTaggedServiceIds('wordpress.element') as $id => $attributes) {
foreach ($attributes as... | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"wordpress",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"'wordpress.wordpress'",
")",
";",
"if",
"(",
"!",
"$",
"wordpress",
")",
"{",
"return",
";",
"}",
"f... | Modify the container before Symfony compiles it.
@param ContainerBuilder $container | [
"Modify",
"the",
"container",
"before",
"Symfony",
"compiles",
"it",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Compiler/DriverElementPass.php#L19-L38 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpcli/ContentElement.php | ContentElement.create | public function create($args)
{
$meta_args = [];
$tax_args = [];
/*
* Array of taxonomy terms keyed by their taxonomy name, which WP-CLI can't handle.
*
* Values may be delimited by a comma.
*
* See https://github.com/wp-cli/entity-command/issue... | php | public function create($args)
{
$meta_args = [];
$tax_args = [];
/*
* Array of taxonomy terms keyed by their taxonomy name, which WP-CLI can't handle.
*
* Values may be delimited by a comma.
*
* See https://github.com/wp-cli/entity-command/issue... | [
"public",
"function",
"create",
"(",
"$",
"args",
")",
"{",
"$",
"meta_args",
"=",
"[",
"]",
";",
"$",
"tax_args",
"=",
"[",
"]",
";",
"/*\n * Array of taxonomy terms keyed by their taxonomy name, which WP-CLI can't handle.\n *\n * Values may be delimi... | Create an item for this element.
@param array $args Data used to create an object.
@return mixed The new item. | [
"Create",
"an",
"item",
"for",
"this",
"element",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpcli/ContentElement.php#L21-L92 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpcli/ContentElement.php | ContentElement.get | public function get($id, $args = [])
{
$url = '';
// Support fetching via arbitrary field.
if (! is_numeric($id)) {
$wpcli_args = ['--fields=ID,url', "--{$args['by']}=" . escapeshellarg($id), '--post_type=any', '--format=json', '--ignore_sticky_posts=true'];
$result ... | php | public function get($id, $args = [])
{
$url = '';
// Support fetching via arbitrary field.
if (! is_numeric($id)) {
$wpcli_args = ['--fields=ID,url', "--{$args['by']}=" . escapeshellarg($id), '--post_type=any', '--format=json', '--ignore_sticky_posts=true'];
$result ... | [
"public",
"function",
"get",
"(",
"$",
"id",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"''",
";",
"// Support fetching via arbitrary field.",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"id",
")",
")",
"{",
"$",
"wpcli_args",
"=",
"[",
... | Retrieve an item for this element.
@param int|string $id Object ID.
@param array $args Optional data used to fetch an object.
@throws \UnexpectedValueException
@return mixed The item. | [
"Retrieve",
"an",
"item",
"for",
"this",
"element",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpcli/ContentElement.php#L104-L147 |
paulgibbs/behat-wordpress-extension | src/Context/EditPostContext.php | EditPostContext.iGoToEditScreenForPostType | public function iGoToEditScreenForPostType(string $post_type, string $title)
{
$post = $this->getContentFromTitle($title, $post_type);
$this->edit_post_page->open(array(
'id' => $post['id'],
));
} | php | public function iGoToEditScreenForPostType(string $post_type, string $title)
{
$post = $this->getContentFromTitle($title, $post_type);
$this->edit_post_page->open(array(
'id' => $post['id'],
));
} | [
"public",
"function",
"iGoToEditScreenForPostType",
"(",
"string",
"$",
"post_type",
",",
"string",
"$",
"title",
")",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getContentFromTitle",
"(",
"$",
"title",
",",
"$",
"post_type",
")",
";",
"$",
"this",
"->",
... | Go to the edit post admin page for the referenced post.
This step allows you to specify the post type to consider.
Example: Given I am on the edit post screen for "Hello World"
Example: Given I am on the edit event screen for "Some Event"
@Given /^I am on the edit ([a-zA-z_-]+) screen for "([^"]*)"$/
@param string ... | [
"Go",
"to",
"the",
"edit",
"post",
"admin",
"page",
"for",
"the",
"referenced",
"post",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/EditPostContext.php#L50-L56 |
paulgibbs/behat-wordpress-extension | src/Context/EditPostContext.php | EditPostContext.iGoToEditScreenFor | public function iGoToEditScreenFor(string $title)
{
$post = $this->getContentFromTitle($title);
$this->edit_post_page->open(array(
'id' => $post['id'],
));
} | php | public function iGoToEditScreenFor(string $title)
{
$post = $this->getContentFromTitle($title);
$this->edit_post_page->open(array(
'id' => $post['id'],
));
} | [
"public",
"function",
"iGoToEditScreenFor",
"(",
"string",
"$",
"title",
")",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getContentFromTitle",
"(",
"$",
"title",
")",
";",
"$",
"this",
"->",
"edit_post_page",
"->",
"open",
"(",
"array",
"(",
"'id'",
"=>"... | Go to the edit post admin page for the referenced post.
This step works for all post types.
Example: Given I am on the edit screen for "Hello World"
Example: Given I am on the edit screen for "Some Event"
@Given /^I am on the edit screen for "(?P<title>[^"]*)"$/
@param string $title The name of the 'post' being edi... | [
"Go",
"to",
"the",
"edit",
"post",
"admin",
"page",
"for",
"the",
"referenced",
"post",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/EditPostContext.php#L70-L76 |
paulgibbs/behat-wordpress-extension | src/Context/EditPostContext.php | EditPostContext.iSelectPostContentEditorMode | public function iSelectPostContentEditorMode(string $mode)
{
$content_editor = $this->edit_post_page->getContentEditor();
$content_editor->setMode(strtoupper($mode));
} | php | public function iSelectPostContentEditorMode(string $mode)
{
$content_editor = $this->edit_post_page->getContentEditor();
$content_editor->setMode(strtoupper($mode));
} | [
"public",
"function",
"iSelectPostContentEditorMode",
"(",
"string",
"$",
"mode",
")",
"{",
"$",
"content_editor",
"=",
"$",
"this",
"->",
"edit_post_page",
"->",
"getContentEditor",
"(",
")",
";",
"$",
"content_editor",
"->",
"setMode",
"(",
"strtoupper",
"(",
... | Switch the mode of the post content editor.
Example: When I switch to the post content editor's Visual mode
Example: When I switch to the post content editor's Text mode
@When /^I switch to the post content editor's (visual|text) mode$/i
@param string $mode The mode (visual or text) to switch to in the editor. | [
"Switch",
"the",
"mode",
"of",
"the",
"post",
"content",
"editor",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/EditPostContext.php#L102-L106 |
paulgibbs/behat-wordpress-extension | src/Context/EditPostContext.php | EditPostContext.iEnterContentIntoPostContentEditor | public function iEnterContentIntoPostContentEditor(PyStringNode $content)
{
$content_editor = $this->edit_post_page->getContentEditor();
$content_editor->setContent($content->getRaw());
} | php | public function iEnterContentIntoPostContentEditor(PyStringNode $content)
{
$content_editor = $this->edit_post_page->getContentEditor();
$content_editor->setContent($content->getRaw());
} | [
"public",
"function",
"iEnterContentIntoPostContentEditor",
"(",
"PyStringNode",
"$",
"content",
")",
"{",
"$",
"content_editor",
"=",
"$",
"this",
"->",
"edit_post_page",
"->",
"getContentEditor",
"(",
")",
";",
"$",
"content_editor",
"->",
"setContent",
"(",
"$"... | Enter the content into the content editor.
Example: When I enter the following content into the post content editor:
"""
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
"""
@When I enter the following content into the post content editor:
@param PyStringNode $content The content... | [
"Enter",
"the",
"content",
"into",
"the",
"content",
"editor",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/EditPostContext.php#L120-L124 |
paulgibbs/behat-wordpress-extension | src/Context/EditPostContext.php | EditPostContext.postContentEditorIsInMode | public function postContentEditorIsInMode(string $mode)
{
$content_editor = $this->edit_post_page->getContentEditor();
if (strtoupper($mode) !== $content_editor->getMode()) {
throw new ExpectationException(
sprintf('[W808] Content editor is in "%1$s" mode. Expected "%2$s"... | php | public function postContentEditorIsInMode(string $mode)
{
$content_editor = $this->edit_post_page->getContentEditor();
if (strtoupper($mode) !== $content_editor->getMode()) {
throw new ExpectationException(
sprintf('[W808] Content editor is in "%1$s" mode. Expected "%2$s"... | [
"public",
"function",
"postContentEditorIsInMode",
"(",
"string",
"$",
"mode",
")",
"{",
"$",
"content_editor",
"=",
"$",
"this",
"->",
"edit_post_page",
"->",
"getContentEditor",
"(",
")",
";",
"if",
"(",
"strtoupper",
"(",
"$",
"mode",
")",
"!==",
"$",
"... | Assert the mode that the content editor is in.
Example: Then The post content editor is in Visual mode
Example: Then The post content editor is in Text mode
@Then /^the post content editor is in (visual|text) mode$/i
@param string $mode Assert that the editor is the specified mode (visual or text).
@throws Expectat... | [
"Assert",
"the",
"mode",
"that",
"the",
"content",
"editor",
"is",
"in",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/EditPostContext.php#L138-L147 |
paulgibbs/behat-wordpress-extension | src/Context/EditPostContext.php | EditPostContext.iAmOnEditScreenForPostType | public function iAmOnEditScreenForPostType(string $post_type, string $post_title)
{
$post = $this->getContentFromTitle($post_title, $post_type);
$this->edit_post_page->isOpen(array(
'id' => $post['id'],
));
} | php | public function iAmOnEditScreenForPostType(string $post_type, string $post_title)
{
$post = $this->getContentFromTitle($post_title, $post_type);
$this->edit_post_page->isOpen(array(
'id' => $post['id'],
));
} | [
"public",
"function",
"iAmOnEditScreenForPostType",
"(",
"string",
"$",
"post_type",
",",
"string",
"$",
"post_title",
")",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getContentFromTitle",
"(",
"$",
"post_title",
",",
"$",
"post_type",
")",
";",
"$",
"this",... | Assert that the edit screen for the given post and post type is displayed
Example: Then I should be on the edit event screen for "Some Event"
Example: Then I should be on the edit post screen for "Hello World"
@Then I should be on the edit :post_type screen for :post_title
@param string $post_type The post type of ... | [
"Assert",
"that",
"the",
"edit",
"screen",
"for",
"the",
"given",
"post",
"and",
"post",
"type",
"is",
"displayed"
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/EditPostContext.php#L174-L180 |
paulgibbs/behat-wordpress-extension | src/Context/EditPostContext.php | EditPostContext.iShouldNotSeeTheMetabox | public function iShouldNotSeeTheMetabox(string $title)
{
try {
$this->edit_post_page->getMetaBox($title);
} catch (ExpectationException $e) {
// Expectation fulfilled
return;
}
throw new ExpectationException(
sprintf(
'... | php | public function iShouldNotSeeTheMetabox(string $title)
{
try {
$this->edit_post_page->getMetaBox($title);
} catch (ExpectationException $e) {
// Expectation fulfilled
return;
}
throw new ExpectationException(
sprintf(
'... | [
"public",
"function",
"iShouldNotSeeTheMetabox",
"(",
"string",
"$",
"title",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"edit_post_page",
"->",
"getMetaBox",
"(",
"$",
"title",
")",
";",
"}",
"catch",
"(",
"ExpectationException",
"$",
"e",
")",
"{",
"// Exp... | Assert that the referenced metabox is not visible.
The metabox may still be collapsed.
Example: Then I should not see the "Featured Image" metabox
@Then I should not see the :title metabox
@param string $title The title of the metabox being checked
@throws ExpectationException | [
"Assert",
"that",
"the",
"referenced",
"metabox",
"is",
"not",
"visible",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/EditPostContext.php#L211-L227 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpphp/PluginElement.php | PluginElement.update | public function update($id, $args = [])
{
if ($args['status'] === 'activate') {
activate_plugin($id, '', false, true);
} elseif ($args['status'] === 'deactivate') {
deactivate_plugins($id, true, false);
}
} | php | public function update($id, $args = [])
{
if ($args['status'] === 'activate') {
activate_plugin($id, '', false, true);
} elseif ($args['status'] === 'deactivate') {
deactivate_plugins($id, true, false);
}
} | [
"public",
"function",
"update",
"(",
"$",
"id",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"args",
"[",
"'status'",
"]",
"===",
"'activate'",
")",
"{",
"activate_plugin",
"(",
"$",
"id",
",",
"''",
",",
"false",
",",
"true",
")",
... | Activate or deactivate specified plugin.
@param string $id Path to plugin.
@param array $args Optional data used to update an object. | [
"Activate",
"or",
"deactivate",
"specified",
"plugin",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpphp/PluginElement.php#L19-L26 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpphp/PluginElement.php | PluginElement.activate | public function activate($id, $args = [])
{
$plugin = $this->drivers->getDriver()->getPlugin($id);
if (! $plugin) {
throw new UnexpectedValueException("[W608] Cannot find the plugin: {$id}.");
}
$this->update($plugin, ['status' => 'activate']);
} | php | public function activate($id, $args = [])
{
$plugin = $this->drivers->getDriver()->getPlugin($id);
if (! $plugin) {
throw new UnexpectedValueException("[W608] Cannot find the plugin: {$id}.");
}
$this->update($plugin, ['status' => 'activate']);
} | [
"public",
"function",
"activate",
"(",
"$",
"id",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"plugin",
"=",
"$",
"this",
"->",
"drivers",
"->",
"getDriver",
"(",
")",
"->",
"getPlugin",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"plugi... | Alias of update().
@see update()
@param string $id Plugin name to activate.
@param array $args Optional. Not used.
@throws \UnexpectedValueException | [
"Alias",
"of",
"update",
"()",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpphp/PluginElement.php#L43-L52 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpcli/UserElement.php | UserElement.create | public function create($args)
{
$extra_roles = [];
// Store multiple roles; WP can only assign one on user creation.
if (! empty($args['role'])) {
if (! is_array($args['role'])) {
$args['role'] = array_map('trim', explode(',', $args['role']));
}
... | php | public function create($args)
{
$extra_roles = [];
// Store multiple roles; WP can only assign one on user creation.
if (! empty($args['role'])) {
if (! is_array($args['role'])) {
$args['role'] = array_map('trim', explode(',', $args['role']));
}
... | [
"public",
"function",
"create",
"(",
"$",
"args",
")",
"{",
"$",
"extra_roles",
"=",
"[",
"]",
";",
"// Store multiple roles; WP can only assign one on user creation.",
"if",
"(",
"!",
"empty",
"(",
"$",
"args",
"[",
"'role'",
"]",
")",
")",
"{",
"if",
"(",
... | Create an item for this element.
@param array $args Data used to create an object.
@return mixed The new item. | [
"Create",
"an",
"item",
"for",
"this",
"element",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpcli/UserElement.php#L21-L60 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpcli/UserElement.php | UserElement.get | public function get($id, $args = [])
{
// Fetch all the user properties by default, for convenience.
if (! isset($args['field']) && ! isset($args['fields'])) {
$args['fields'] = implode(
',',
array(
'ID',
'user_login... | php | public function get($id, $args = [])
{
// Fetch all the user properties by default, for convenience.
if (! isset($args['field']) && ! isset($args['fields'])) {
$args['fields'] = implode(
',',
array(
'ID',
'user_login... | [
"public",
"function",
"get",
"(",
"$",
"id",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"// Fetch all the user properties by default, for convenience.",
"if",
"(",
"!",
"isset",
"(",
"$",
"args",
"[",
"'field'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"a... | Retrieve an item for this element.
@param int|string $id Object ID.
@param array $args Optional data used to fetch an object.
@throws \UnexpectedValueException
@return mixed The item. | [
"Retrieve",
"an",
"item",
"for",
"this",
"element",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpcli/UserElement.php#L72-L117 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/PageObjectAwareContextTrait.php | PageObjectAwareContextTrait.getPage | public function getPage(string $name): Page
{
if ($this->page_object_factory === null) {
throw new RuntimeException('[W406] To create pages you need to pass a factory with setPageObjectFactory()');
}
return $this->page_object_factory->createPage($name);
} | php | public function getPage(string $name): Page
{
if ($this->page_object_factory === null) {
throw new RuntimeException('[W406] To create pages you need to pass a factory with setPageObjectFactory()');
}
return $this->page_object_factory->createPage($name);
} | [
"public",
"function",
"getPage",
"(",
"string",
"$",
"name",
")",
":",
"Page",
"{",
"if",
"(",
"$",
"this",
"->",
"page_object_factory",
"===",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'[W406] To create pages you need to pass a factory with setPag... | Creates a page object from its name.
@param string $name The name of the page object e.g 'Admin page'.
@throws \RuntimeException
@return Page | [
"Creates",
"a",
"page",
"object",
"from",
"its",
"name",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/PageObjectAwareContextTrait.php#L26-L33 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/PageObjectAwareContextTrait.php | PageObjectAwareContextTrait.getElement | public function getElement(string $name): Element
{
if ($this->page_object_factory === null) {
throw new RuntimeException('[W406] To create elements you need to pass a factory with setPageObjectFactory()');
}
return $this->page_object_factory->createElement($name);
} | php | public function getElement(string $name): Element
{
if ($this->page_object_factory === null) {
throw new RuntimeException('[W406] To create elements you need to pass a factory with setPageObjectFactory()');
}
return $this->page_object_factory->createElement($name);
} | [
"public",
"function",
"getElement",
"(",
"string",
"$",
"name",
")",
":",
"Element",
"{",
"if",
"(",
"$",
"this",
"->",
"page_object_factory",
"===",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'[W406] To create elements you need to pass a factory wi... | Creates a page object element from its name.
@param string $name The name of the page object element e.g 'Toolbar'
@throws \RuntimeException
@return Element | [
"Creates",
"a",
"page",
"object",
"element",
"from",
"its",
"name",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/PageObjectAwareContextTrait.php#L44-L51 |
paulgibbs/behat-wordpress-extension | src/Driver/WpcliDriver.php | WpcliDriver.bootstrap | public function bootstrap()
{
$version = '';
preg_match('#^WP-CLI (.*)$#', $this->wpcli('cli', 'version')['stdout'], $match);
if (! empty($match)) {
$version = array_pop($match);
}
if (! version_compare($version, '1.5.0', '>=')) {
throw new RuntimeEx... | php | public function bootstrap()
{
$version = '';
preg_match('#^WP-CLI (.*)$#', $this->wpcli('cli', 'version')['stdout'], $match);
if (! empty($match)) {
$version = array_pop($match);
}
if (! version_compare($version, '1.5.0', '>=')) {
throw new RuntimeEx... | [
"public",
"function",
"bootstrap",
"(",
")",
"{",
"$",
"version",
"=",
"''",
";",
"preg_match",
"(",
"'#^WP-CLI (.*)$#'",
",",
"$",
"this",
"->",
"wpcli",
"(",
"'cli'",
",",
"'version'",
")",
"[",
"'stdout'",
"]",
",",
"$",
"match",
")",
";",
"if",
"... | Set up anything required for the driver.
Called when the driver is used for the first time.
Checks `core is-installed`, and the version number.
@throws \RuntimeException | [
"Set",
"up",
"anything",
"required",
"for",
"the",
"driver",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/WpcliDriver.php#L67-L88 |
paulgibbs/behat-wordpress-extension | src/Driver/WpcliDriver.php | WpcliDriver.wpcli | public function wpcli(string $command, string $subcommand, array $raw_arguments = []): array
{
$arguments = implode(' ', $raw_arguments);
$config = sprintf('--url=%s', escapeshellarg($this->url));
if ($this->path) {
$config .= sprintf(' --path=%s', escapeshellarg($this->path)... | php | public function wpcli(string $command, string $subcommand, array $raw_arguments = []): array
{
$arguments = implode(' ', $raw_arguments);
$config = sprintf('--url=%s', escapeshellarg($this->url));
if ($this->path) {
$config .= sprintf(' --path=%s', escapeshellarg($this->path)... | [
"public",
"function",
"wpcli",
"(",
"string",
"$",
"command",
",",
"string",
"$",
"subcommand",
",",
"array",
"$",
"raw_arguments",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"arguments",
"=",
"implode",
"(",
"' '",
",",
"$",
"raw_arguments",
")",
";"... | Execute a WP-CLI command.
@param string $command Command name.
@param string $subcommand Subcommand name.
@param string[] $raw_arguments Optional. Associative array of arguments for the command.
@throws \UnexpectedValueException
@return array {
WP-CLI command results.
@type string $stdout Response t... | [
"Execute",
"a",
"WP",
"-",
"CLI",
"command",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/WpcliDriver.php#L106-L160 |
paulgibbs/behat-wordpress-extension | src/PageObject/DashboardPage.php | DashboardPage.verifyPage | protected function verifyPage()
{
$url = $this->getSession()->getCurrentUrl();
if (strrpos($url, $this->path) !== false) {
return;
}
throw new ExpectationException(
sprintf(
'[W401] Expected screen is the wp-admin dashboard, instead on "%1$s"... | php | protected function verifyPage()
{
$url = $this->getSession()->getCurrentUrl();
if (strrpos($url, $this->path) !== false) {
return;
}
throw new ExpectationException(
sprintf(
'[W401] Expected screen is the wp-admin dashboard, instead on "%1$s"... | [
"protected",
"function",
"verifyPage",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getCurrentUrl",
"(",
")",
";",
"if",
"(",
"strrpos",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"path",
")",
"!==",
"false",
")",... | Asserts the current screen is the Dashboard.
@throws ExpectationException | [
"Asserts",
"the",
"current",
"screen",
"is",
"the",
"Dashboard",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/DashboardPage.php#L22-L37 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpcli/WidgetElement.php | WidgetElement.addToSidebar | public function addToSidebar($widget_name, $sidebar_id, $args)
{
$widget_name = strtolower($widget_name);
$wpcli_args = array_merge([
$widget_name,
$sidebar_id
], buildCLIArgs(array_keys($args), $args));
$this->drivers->getDriver()->wpcli('widget... | php | public function addToSidebar($widget_name, $sidebar_id, $args)
{
$widget_name = strtolower($widget_name);
$wpcli_args = array_merge([
$widget_name,
$sidebar_id
], buildCLIArgs(array_keys($args), $args));
$this->drivers->getDriver()->wpcli('widget... | [
"public",
"function",
"addToSidebar",
"(",
"$",
"widget_name",
",",
"$",
"sidebar_id",
",",
"$",
"args",
")",
"{",
"$",
"widget_name",
"=",
"strtolower",
"(",
"$",
"widget_name",
")",
";",
"$",
"wpcli_args",
"=",
"array_merge",
"(",
"[",
"$",
"widget_name"... | Adds a widget to the sidebar with the specified arguments
@param string $widget_name The ID base of the widget (e.g. 'meta', 'calendar'). Case insensitive.
@param string $sidebar_id The ID of the sidebar to the add the widget to
@param array $args Associative array of widget settings for this widget | [
"Adds",
"a",
"widget",
"to",
"the",
"sidebar",
"with",
"the",
"specified",
"arguments"
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpcli/WidgetElement.php#L22-L32 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpcli/WidgetElement.php | WidgetElement.getSidebar | public function getSidebar($sidebar_name)
{
$registered_sidebars = json_decode($this->drivers->getDriver()->wpcli('sidebar', 'list', [
'--format=json',
])['stdout']);
$sidebar_id = null;
foreach ($registered_sidebars as $sidebar) {
if ($sidebar_name === $sid... | php | public function getSidebar($sidebar_name)
{
$registered_sidebars = json_decode($this->drivers->getDriver()->wpcli('sidebar', 'list', [
'--format=json',
])['stdout']);
$sidebar_id = null;
foreach ($registered_sidebars as $sidebar) {
if ($sidebar_name === $sid... | [
"public",
"function",
"getSidebar",
"(",
"$",
"sidebar_name",
")",
"{",
"$",
"registered_sidebars",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"drivers",
"->",
"getDriver",
"(",
")",
"->",
"wpcli",
"(",
"'sidebar'",
",",
"'list'",
",",
"[",
"'--format=json'... | Gets a sidebar ID from its human-readable name
@param string $sidebar_name The name of the sidebar (e.g. 'Footer', 'Widget Area', 'Right Sidebar')
@throws UnexpectedValueException If the sidebar is not registered
@return string The sidebar ID | [
"Gets",
"a",
"sidebar",
"ID",
"from",
"its",
"human",
"-",
"readable",
"name"
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpcli/WidgetElement.php#L43-L63 |
paulgibbs/behat-wordpress-extension | src/Driver/WpphpDriver.php | WpphpDriver.bootstrap | public function bootstrap()
{
if (! defined('ABSPATH')) {
define('ABSPATH', "{$this->path}/");
}
$_SERVER['DOCUMENT_ROOT'] = $this->path;
$_SERVER['HTTP_HOST'] = '';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/';
$... | php | public function bootstrap()
{
if (! defined('ABSPATH')) {
define('ABSPATH', "{$this->path}/");
}
$_SERVER['DOCUMENT_ROOT'] = $this->path;
$_SERVER['HTTP_HOST'] = '';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/';
$... | [
"public",
"function",
"bootstrap",
"(",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'ABSPATH'",
")",
")",
"{",
"define",
"(",
"'ABSPATH'",
",",
"\"{$this->path}/\"",
")",
";",
"}",
"$",
"_SERVER",
"[",
"'DOCUMENT_ROOT'",
"]",
"=",
"$",
"this",
"->",
"pa... | Set up anything required for the driver.
Called when the driver is used for the first time.
@throws \RuntimeException | [
"Set",
"up",
"anything",
"required",
"for",
"the",
"driver",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/WpphpDriver.php#L43-L70 |
paulgibbs/behat-wordpress-extension | src/Driver/WpphpDriver.php | WpphpDriver.getPlugin | public function getPlugin($name)
{
foreach (array_keys(get_plugins()) as $file) {
// Logic taken from WP-CLI.
if ($file === "{$name}.php" || ($name && $file === $name) || (dirname($file) === $name && $name !== '.')) {
return $file;
}
}
ret... | php | public function getPlugin($name)
{
foreach (array_keys(get_plugins()) as $file) {
// Logic taken from WP-CLI.
if ($file === "{$name}.php" || ($name && $file === $name) || (dirname($file) === $name && $name !== '.')) {
return $file;
}
}
ret... | [
"public",
"function",
"getPlugin",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"get_plugins",
"(",
")",
")",
"as",
"$",
"file",
")",
"{",
"// Logic taken from WP-CLI.",
"if",
"(",
"$",
"file",
"===",
"\"{$name}.php\"",
"||",
"(",
"$",
... | Get information about a plugin.
@param string $name
@return string Plugin filename and path. | [
"Get",
"information",
"about",
"a",
"plugin",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/WpphpDriver.php#L84-L94 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpphp/DatabaseElement.php | DatabaseElement.get | public function get($id, $args = [])
{
if (empty($args['path'])) {
$args['path'] = sys_get_temp_dir();
}
$bin = '';
$path = tempnam($args['path'], 'wordhat');
$command_args = sprintf(
'--no-defaults %1$s --add-drop-table --result-file... | php | public function get($id, $args = [])
{
if (empty($args['path'])) {
$args['path'] = sys_get_temp_dir();
}
$bin = '';
$path = tempnam($args['path'], 'wordhat');
$command_args = sprintf(
'--no-defaults %1$s --add-drop-table --result-file... | [
"public",
"function",
"get",
"(",
"$",
"id",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"args",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"args",
"[",
"'path'",
"]",
"=",
"sys_get_temp_dir",
"(",
")",
";",
"}",
"$"... | Export site database.
@param int $id Not used.
@param array $args
@return string Path to the database dump. | [
"Export",
"site",
"database",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpphp/DatabaseElement.php#L21-L79 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpphp/DatabaseElement.php | DatabaseElement.update | public function update($id, $args = [])
{
$bin = '';
$command_args = sprintf(
'--no-defaults --no-auto-rehash --host=%1$s --user=%2$s --database=%3$s --execute=%4$s',
DB_HOST,
DB_USER,
DB_NAME,
escapeshellarg(sprintf(
... | php | public function update($id, $args = [])
{
$bin = '';
$command_args = sprintf(
'--no-defaults --no-auto-rehash --host=%1$s --user=%2$s --database=%3$s --execute=%4$s',
DB_HOST,
DB_USER,
DB_NAME,
escapeshellarg(sprintf(
... | [
"public",
"function",
"update",
"(",
"$",
"id",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"bin",
"=",
"''",
";",
"$",
"command_args",
"=",
"sprintf",
"(",
"'--no-defaults --no-auto-rehash --host=%1$s --user=%2$s --database=%3$s --execute=%4$s'",
",",
"DB_HOS... | Import site database.
@param int $id Not used.
@param array $args | [
"Import",
"site",
"database",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpphp/DatabaseElement.php#L87-L150 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpphp/ThemeElement.php | ThemeElement.update | public function update($id, $args = [])
{
$theme = wp_get_theme($id);
if (! $theme->exists()) {
throw new UnexpectedValueException(sprintf('[W612] Could not find theme %s', $id));
}
switch_theme($theme->get_template());
} | php | public function update($id, $args = [])
{
$theme = wp_get_theme($id);
if (! $theme->exists()) {
throw new UnexpectedValueException(sprintf('[W612] Could not find theme %s', $id));
}
switch_theme($theme->get_template());
} | [
"public",
"function",
"update",
"(",
"$",
"id",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"theme",
"=",
"wp_get_theme",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"theme",
"->",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"Unexpecte... | Switch active theme.
@param string $id Theme name to switch to.
@param array $args Not used.
@throws \UnexpectedValueException | [
"Switch",
"active",
"theme",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpphp/ThemeElement.php#L21-L30 |
paulgibbs/behat-wordpress-extension | src/Context/RawWordpressContext.php | RawWordpressContext.locatePath | public function locatePath($path)
{
if (stripos($path, 'http') === 0) {
return $path;
}
$url = $this->getMinkParameter('base_url');
if (strpos($path, 'wp-admin') !== false || strpos($path, '.php') !== false) {
$url = $this->getWordpressParameter('site_url');... | php | public function locatePath($path)
{
if (stripos($path, 'http') === 0) {
return $path;
}
$url = $this->getMinkParameter('base_url');
if (strpos($path, 'wp-admin') !== false || strpos($path, '.php') !== false) {
$url = $this->getWordpressParameter('site_url');... | [
"public",
"function",
"locatePath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"path",
",",
"'http'",
")",
"===",
"0",
")",
"{",
"return",
"$",
"path",
";",
"}",
"$",
"url",
"=",
"$",
"this",
"->",
"getMinkParameter",
"(",
"'base_u... | Build URL, based on provided path.
@param string $path Relative or absolute URL.
@return string | [
"Build",
"URL",
"based",
"on",
"provided",
"path",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/RawWordpressContext.php#L48-L61 |
paulgibbs/behat-wordpress-extension | src/Context/RawWordpressContext.php | RawWordpressContext.getWordpressParameter | public function getWordpressParameter(string $name)
{
return ! empty($this->wordpress_parameters[$name]) ? $this->wordpress_parameters[$name] : null;
} | php | public function getWordpressParameter(string $name)
{
return ! empty($this->wordpress_parameters[$name]) ? $this->wordpress_parameters[$name] : null;
} | [
"public",
"function",
"getWordpressParameter",
"(",
"string",
"$",
"name",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"wordpress_parameters",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"wordpress_parameters",
"[",
"$",
"name",
"]",
... | Get a specific WordPress parameter.
IMPORTANT: this only sets the variable for the current Context!
Each Context exists independently.
@param string $name Parameter name.
@return mixed | [
"Get",
"a",
"specific",
"WordPress",
"parameter",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/RawWordpressContext.php#L106-L109 |
paulgibbs/behat-wordpress-extension | src/Context/RawWordpressContext.php | RawWordpressContext.getRandomString | public function getRandomString(int $length = 64): string
{
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()';
$random = '';
for ($i = 0; $i < $length; $i++) {
$random .= substr($chars, random_int(0, strlen($chars) - 1), 1);
}
... | php | public function getRandomString(int $length = 64): string
{
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()';
$random = '';
for ($i = 0; $i < $length; $i++) {
$random .= substr($chars, random_int(0, strlen($chars) - 1), 1);
}
... | [
"public",
"function",
"getRandomString",
"(",
"int",
"$",
"length",
"=",
"64",
")",
":",
"string",
"{",
"$",
"chars",
"=",
"'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()'",
";",
"$",
"random",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"="... | Get a random string.
@see https://developer.wordpress.org/reference/functions/wp_generate_password/ Implementation copied from WordPress.
@param int $length Optional. Length of string to return. Default is 64.
@return string | [
"Get",
"a",
"random",
"string",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/RawWordpressContext.php#L150-L160 |
paulgibbs/behat-wordpress-extension | src/PageObject/Element/Toolbar.php | Toolbar.clickToolbarLink | public function clickToolbarLink(string $link)
{
$link_parts = array_map('trim', preg_split('/(?<!\\\\)>/', $link));
$click_node = false;
$first_level_items = $this->findAll('css', '.ab-top-menu > li');
foreach ($first_level_items as $first_level_item) {
if (! $this->el... | php | public function clickToolbarLink(string $link)
{
$link_parts = array_map('trim', preg_split('/(?<!\\\\)>/', $link));
$click_node = false;
$first_level_items = $this->findAll('css', '.ab-top-menu > li');
foreach ($first_level_items as $first_level_item) {
if (! $this->el... | [
"public",
"function",
"clickToolbarLink",
"(",
"string",
"$",
"link",
")",
"{",
"$",
"link_parts",
"=",
"array_map",
"(",
"'trim'",
",",
"preg_split",
"(",
"'/(?<!\\\\\\\\)>/'",
",",
"$",
"link",
")",
")",
";",
"$",
"click_node",
"=",
"false",
";",
"$",
... | Click a specific item in the toolbar.
Top-level items are identified by their link text (e.g. 'Comments').
Second-level items are identified by their parent text and link text,
delimited by a right angle bracket. E.g. New > Post.
@param string $link The toolbar item to click.
@throws \Behat\Mink\Exception\Expectatio... | [
"Click",
"a",
"specific",
"item",
"in",
"the",
"toolbar",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/Element/Toolbar.php#L32-L62 |
paulgibbs/behat-wordpress-extension | src/PageObject/Element/Toolbar.php | Toolbar.elementIsTargetLink | protected function elementIsTargetLink(NodeElement $element, string $link_text): bool
{
$current_item_name = strtolower($element->find('css', '.ab-item')->getText());
switch (strtolower($link_text)) {
case 'wordpress':
$is_link = $element->getAttribute('id') === 'wp-admi... | php | protected function elementIsTargetLink(NodeElement $element, string $link_text): bool
{
$current_item_name = strtolower($element->find('css', '.ab-item')->getText());
switch (strtolower($link_text)) {
case 'wordpress':
$is_link = $element->getAttribute('id') === 'wp-admi... | [
"protected",
"function",
"elementIsTargetLink",
"(",
"NodeElement",
"$",
"element",
",",
"string",
"$",
"link_text",
")",
":",
"bool",
"{",
"$",
"current_item_name",
"=",
"strtolower",
"(",
"$",
"element",
"->",
"find",
"(",
"'css'",
",",
"'.ab-item'",
")",
... | Determines whether the link name refers to the given NodeElement.
Some toolbar links do not have any visible text, so we handle those
separately. Otherwise we compare the link text to the text of the
element.
@param \Behat\Mink\Element\NodeElement $element The element to check
@param string $link_text The link (text)... | [
"Determines",
"whether",
"the",
"link",
"name",
"refers",
"to",
"the",
"given",
"NodeElement",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/Element/Toolbar.php#L76-L95 |
paulgibbs/behat-wordpress-extension | src/PageObject/Element/Toolbar.php | Toolbar.getSubmenuLinkNode | protected function getSubmenuLinkNode(NodeElement $first_level_item, string $link_text)
{
$second_level_items = $first_level_item->findAll('css', 'ul li a');
$submenu_link_node = null;
foreach ($second_level_items as $second_level_item) {
$current_item_name = Util\stripTagsAndC... | php | protected function getSubmenuLinkNode(NodeElement $first_level_item, string $link_text)
{
$second_level_items = $first_level_item->findAll('css', 'ul li a');
$submenu_link_node = null;
foreach ($second_level_items as $second_level_item) {
$current_item_name = Util\stripTagsAndC... | [
"protected",
"function",
"getSubmenuLinkNode",
"(",
"NodeElement",
"$",
"first_level_item",
",",
"string",
"$",
"link_text",
")",
"{",
"$",
"second_level_items",
"=",
"$",
"first_level_item",
"->",
"findAll",
"(",
"'css'",
",",
"'ul li a'",
")",
";",
"$",
"subme... | Returns a second-level toolbar NodeElement corresponding to the link text
under the given first-level toolbar NodeElement.
@param \Behat\Mink\Element\NodeElement $first_level_item The element to check under.
@param string $link_text The link (text) to check for.
@return \Behat\Mink\Ele... | [
"Returns",
"a",
"second",
"-",
"level",
"toolbar",
"NodeElement",
"corresponding",
"to",
"the",
"link",
"text",
"under",
"the",
"given",
"first",
"-",
"level",
"toolbar",
"NodeElement",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/Element/Toolbar.php#L106-L140 |
paulgibbs/behat-wordpress-extension | src/PageObject/Element/Toolbar.php | Toolbar.search | public function search(string $text)
{
$search = $this->find('css', '#adminbarsearch');
if (! $search) {
throw new ExpectationException(
'[W404] Search field in the toolbar could not be found',
$this->getDriver()
);
}
try {
... | php | public function search(string $text)
{
$search = $this->find('css', '#adminbarsearch');
if (! $search) {
throw new ExpectationException(
'[W404] Search field in the toolbar could not be found',
$this->getDriver()
);
}
try {
... | [
"public",
"function",
"search",
"(",
"string",
"$",
"text",
")",
"{",
"$",
"search",
"=",
"$",
"this",
"->",
"find",
"(",
"'css'",
",",
"'#adminbarsearch'",
")",
";",
"if",
"(",
"!",
"$",
"search",
")",
"{",
"throw",
"new",
"ExpectationException",
"(",... | Searches for the given text using the toolbar search field.
@param string $text Text to enter into the search field
@throws \Behat\Mink\Exception\ExpectationException | [
"Searches",
"for",
"the",
"given",
"text",
"using",
"the",
"toolbar",
"search",
"field",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/Element/Toolbar.php#L149-L170 |
paulgibbs/behat-wordpress-extension | src/PageObject/Element/Toolbar.php | Toolbar.logOut | public function logOut()
{
/*
* Using NodeElement::mouseOver() won't work because WordPress is using hoverIndent.
* Instead we just manually add the hover class.
*
* See https://github.com/paulgibbs/behat-wordpress-extension/issues/65
*/
try {
... | php | public function logOut()
{
/*
* Using NodeElement::mouseOver() won't work because WordPress is using hoverIndent.
* Instead we just manually add the hover class.
*
* See https://github.com/paulgibbs/behat-wordpress-extension/issues/65
*/
try {
... | [
"public",
"function",
"logOut",
"(",
")",
"{",
"/*\n * Using NodeElement::mouseOver() won't work because WordPress is using hoverIndent.\n * Instead we just manually add the hover class.\n *\n * See https://github.com/paulgibbs/behat-wordpress-extension/issues/65\n ... | Logs-out using the toolbar log-out link. | [
"Logs",
"-",
"out",
"using",
"the",
"toolbar",
"log",
"-",
"out",
"link",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/Element/Toolbar.php#L185-L209 |
paulgibbs/behat-wordpress-extension | src/PageObject/LoginPage.php | LoginPage.verifyLoginPage | protected function verifyLoginPage()
{
// Get the session.
$session = $this->verifySession();
// Get the url.
$url = $session->getCurrentUrl();
// If the login path isn't in the current URL.
if (false === strrpos($url, $this->path)) {
// We aren't on th... | php | protected function verifyLoginPage()
{
// Get the session.
$session = $this->verifySession();
// Get the url.
$url = $session->getCurrentUrl();
// If the login path isn't in the current URL.
if (false === strrpos($url, $this->path)) {
// We aren't on th... | [
"protected",
"function",
"verifyLoginPage",
"(",
")",
"{",
"// Get the session.",
"$",
"session",
"=",
"$",
"this",
"->",
"verifySession",
"(",
")",
";",
"// Get the url.",
"$",
"url",
"=",
"$",
"session",
"->",
"getCurrentUrl",
"(",
")",
";",
"// If the login... | Asserts the current screen is the login page.
@throws ExpectationException | [
"Asserts",
"the",
"current",
"screen",
"is",
"the",
"login",
"page",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/LoginPage.php#L29-L71 |
paulgibbs/behat-wordpress-extension | src/PageObject/LoginPage.php | LoginPage.setUserName | public function setUserName(string $username)
{
// Get the session.
$session = $this->verifySession();
// Verify we are on the login page.
$this->verifyLoginPage();
// Get the page.
$page = $session->getPage();
// Find the user_login field.
$user_l... | php | public function setUserName(string $username)
{
// Get the session.
$session = $this->verifySession();
// Verify we are on the login page.
$this->verifyLoginPage();
// Get the page.
$page = $session->getPage();
// Find the user_login field.
$user_l... | [
"public",
"function",
"setUserName",
"(",
"string",
"$",
"username",
")",
"{",
"// Get the session.",
"$",
"session",
"=",
"$",
"this",
"->",
"verifySession",
"(",
")",
";",
"// Verify we are on the login page.",
"$",
"this",
"->",
"verifyLoginPage",
"(",
")",
"... | Fills the user_login field of the login form with a given username.
@param string $username the username to fill into the login form
@throws \Behat\Mink\Exception\ExpectationException | [
"Fills",
"the",
"user_login",
"field",
"of",
"the",
"login",
"form",
"with",
"a",
"given",
"username",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/LoginPage.php#L80-L130 |
paulgibbs/behat-wordpress-extension | src/PageObject/LoginPage.php | LoginPage.setUserPassword | public function setUserPassword(string $password)
{
// Get the session.
$session = $this->verifySession();
// Verify we are on the login page.
$this->verifyLoginPage();
// Get the page.
$page = $session->getPage();
// Find the user_pass field.
$use... | php | public function setUserPassword(string $password)
{
// Get the session.
$session = $this->verifySession();
// Verify we are on the login page.
$this->verifyLoginPage();
// Get the page.
$page = $session->getPage();
// Find the user_pass field.
$use... | [
"public",
"function",
"setUserPassword",
"(",
"string",
"$",
"password",
")",
"{",
"// Get the session.",
"$",
"session",
"=",
"$",
"this",
"->",
"verifySession",
"(",
")",
";",
"// Verify we are on the login page.",
"$",
"this",
"->",
"verifyLoginPage",
"(",
")",... | Fills the user_pass field of the login form with a given password.
@param string $password the password to fill into the login form
@throws \Behat\Mink\Exception\ExpectationException | [
"Fills",
"the",
"user_pass",
"field",
"of",
"the",
"login",
"form",
"with",
"a",
"given",
"password",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/LoginPage.php#L139-L189 |
paulgibbs/behat-wordpress-extension | src/PageObject/LoginPage.php | LoginPage.submitLoginForm | public function submitLoginForm()
{
// Get the session.
$session = $this->verifySession();
// Verify we are on the login page.
$this->verifyLoginPage();
// Get the page.
$page = $session->getPage();
// Find the submit button.
$submit_button = $page... | php | public function submitLoginForm()
{
// Get the session.
$session = $this->verifySession();
// Verify we are on the login page.
$this->verifyLoginPage();
// Get the page.
$page = $session->getPage();
// Find the submit button.
$submit_button = $page... | [
"public",
"function",
"submitLoginForm",
"(",
")",
"{",
"// Get the session.",
"$",
"session",
"=",
"$",
"this",
"->",
"verifySession",
"(",
")",
";",
"// Verify we are on the login page.",
"$",
"this",
"->",
"verifyLoginPage",
"(",
")",
";",
"// Get the page.",
"... | Submit the WordPress login form | [
"Submit",
"the",
"WordPress",
"login",
"form"
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/LoginPage.php#L194-L218 |
paulgibbs/behat-wordpress-extension | src/PageObject/LoginPage.php | LoginPage.verifySession | protected function verifySession()
{
// Get the session.
$session = $this->getSession();
// Start the session if needed.
if (! $session->isStarted()) {
$session->start();
}
// If we aren't on a valid page
if ('about:blank' === $session->getCurren... | php | protected function verifySession()
{
// Get the session.
$session = $this->getSession();
// Start the session if needed.
if (! $session->isStarted()) {
$session->start();
}
// If we aren't on a valid page
if ('about:blank' === $session->getCurren... | [
"protected",
"function",
"verifySession",
"(",
")",
"{",
"// Get the session.",
"$",
"session",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
";",
"// Start the session if needed.",
"if",
"(",
"!",
"$",
"session",
"->",
"isStarted",
"(",
")",
")",
"{",
"$"... | Verify and return a properly started Mink session
@return \Behat\Mink\Session Mink session. | [
"Verify",
"and",
"return",
"a",
"properly",
"started",
"Mink",
"session"
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/LoginPage.php#L225-L243 |
paulgibbs/behat-wordpress-extension | src/PageObject/Element/AdminMenu.php | AdminMenu.clickMenuItem | public function clickMenuItem(string $item)
{
$click_node = false;
$first_level_items = $this->findAll('css', 'li.menu-top');
$items = array_map('trim', preg_split('/(?<!\\\\)>/', $item));
foreach ($first_level_items as $first_level_item) {
/*
... | php | public function clickMenuItem(string $item)
{
$click_node = false;
$first_level_items = $this->findAll('css', 'li.menu-top');
$items = array_map('trim', preg_split('/(?<!\\\\)>/', $item));
foreach ($first_level_items as $first_level_item) {
/*
... | [
"public",
"function",
"clickMenuItem",
"(",
"string",
"$",
"item",
")",
"{",
"$",
"click_node",
"=",
"false",
";",
"$",
"first_level_items",
"=",
"$",
"this",
"->",
"findAll",
"(",
"'css'",
",",
"'li.menu-top'",
")",
";",
"$",
"items",
"=",
"array_map",
... | Click a specific item in the admin menu.
Top-level items are identified by their link text (e.g. 'Comments').
Second-level items are identified by their parent text and link text,
delimited by a right angle bracket. E.g. Posts > Add New.
@param string $item The menu item to click.
@throws \RuntimeException If the me... | [
"Click",
"a",
"specific",
"item",
"in",
"the",
"admin",
"menu",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/Element/AdminMenu.php#L31-L82 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpphp/ContentElement.php | ContentElement.create | public function create($args)
{
$args = wp_slash($args);
$id = wp_insert_post($args);
if (is_wp_error($id)) {
throw new UnexpectedValueException(sprintf('[W603] Failed creating new content: %s', $id->get_error_message()));
}
return $this->get($id);
} | php | public function create($args)
{
$args = wp_slash($args);
$id = wp_insert_post($args);
if (is_wp_error($id)) {
throw new UnexpectedValueException(sprintf('[W603] Failed creating new content: %s', $id->get_error_message()));
}
return $this->get($id);
} | [
"public",
"function",
"create",
"(",
"$",
"args",
")",
"{",
"$",
"args",
"=",
"wp_slash",
"(",
"$",
"args",
")",
";",
"$",
"id",
"=",
"wp_insert_post",
"(",
"$",
"args",
")",
";",
"if",
"(",
"is_wp_error",
"(",
"$",
"id",
")",
")",
"{",
"throw",
... | Create an item for this element.
@param array $args Data used to create an object.
@throws \UnexpectedValueException
@return \WP_Post The new item. | [
"Create",
"an",
"item",
"for",
"this",
"element",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpphp/ContentElement.php#L23-L33 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpphp/ContentElement.php | ContentElement.get | public function get($id, $args = [])
{
$post = false;
if (is_numeric($id) || (is_object($id) && $id instanceof \WP_Post)) {
$post = get_post($id);
} else {
$query = new WP_Query();
$query = $query->query(array(
"{$args['by']}" => ... | php | public function get($id, $args = [])
{
$post = false;
if (is_numeric($id) || (is_object($id) && $id instanceof \WP_Post)) {
$post = get_post($id);
} else {
$query = new WP_Query();
$query = $query->query(array(
"{$args['by']}" => ... | [
"public",
"function",
"get",
"(",
"$",
"id",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"post",
"=",
"false",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"id",
")",
"||",
"(",
"is_object",
"(",
"$",
"id",
")",
"&&",
"$",
"id",
"instanceof",
... | Retrieve an item for this element.
@param \WP_Post|string|int $id Object ID.
@param array $args Optional data used to fetch an object.
@throws \UnexpectedValueException
@return \WP_Post The item. | [
"Retrieve",
"an",
"item",
"for",
"this",
"element",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpphp/ContentElement.php#L45-L75 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpphp/ContentElement.php | ContentElement.delete | public function delete($id, $args = [])
{
$result = wp_delete_post($id, isset($args['force']));
if (! $result) {
throw new UnexpectedValueException('[W605] Failed deleting content.');
}
} | php | public function delete($id, $args = [])
{
$result = wp_delete_post($id, isset($args['force']));
if (! $result) {
throw new UnexpectedValueException('[W605] Failed deleting content.');
}
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"wp_delete_post",
"(",
"$",
"id",
",",
"isset",
"(",
"$",
"args",
"[",
"'force'",
"]",
")",
")",
";",
"if",
"(",
"!",
"$",
"result",
... | Delete an item for this element.
@param int $id Object ID.
@param array $args Optional data used to delete an object.
@throws \UnexpectedValueException | [
"Delete",
"an",
"item",
"for",
"this",
"element",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpphp/ContentElement.php#L85-L92 |
paulgibbs/behat-wordpress-extension | src/WordpressDriverManager.php | WordpressDriverManager.registerDriverElement | public function registerDriverElement(string $name, ElementInterface $element, string $driver_name)
{
$this->getDriver($driver_name, 'skip bootstrap')->registerElement($name, $element);
} | php | public function registerDriverElement(string $name, ElementInterface $element, string $driver_name)
{
$this->getDriver($driver_name, 'skip bootstrap')->registerElement($name, $element);
} | [
"public",
"function",
"registerDriverElement",
"(",
"string",
"$",
"name",
",",
"ElementInterface",
"$",
"element",
",",
"string",
"$",
"driver_name",
")",
"{",
"$",
"this",
"->",
"getDriver",
"(",
"$",
"driver_name",
",",
"'skip bootstrap'",
")",
"->",
"regis... | Register a new driver element.
@since 1.1.0 Added $driver_name parameter.
@param string $name Element name.
@param ElementInterface $element An instance of a ElementInterface.
@param string $driver_name Driver name. | [
"Register",
"a",
"new",
"driver",
"element",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/WordpressDriverManager.php#L73-L76 |
paulgibbs/behat-wordpress-extension | src/WordpressDriverManager.php | WordpressDriverManager.getDriver | public function getDriver(string $name = '', string $bootstrap = 'do bootstrap'): DriverInterface
{
$do_bootstrap = ($bootstrap === 'do bootstrap');
$name = $name ? strtolower($name) : $this->default_driver;
if (! isset($this->drivers[$name])) {
throw new InvalidArgument... | php | public function getDriver(string $name = '', string $bootstrap = 'do bootstrap'): DriverInterface
{
$do_bootstrap = ($bootstrap === 'do bootstrap');
$name = $name ? strtolower($name) : $this->default_driver;
if (! isset($this->drivers[$name])) {
throw new InvalidArgument... | [
"public",
"function",
"getDriver",
"(",
"string",
"$",
"name",
"=",
"''",
",",
"string",
"$",
"bootstrap",
"=",
"'do bootstrap'",
")",
":",
"DriverInterface",
"{",
"$",
"do_bootstrap",
"=",
"(",
"$",
"bootstrap",
"===",
"'do bootstrap'",
")",
";",
"$",
"na... | Return a registered driver by name (defaults to the default driver).
@since 1.1.0 Added $bootstrap parameter.
@param string $name Optional. The name of the driver to return. If omitted, the default driver is returned.
@param string $bootstrap Optional. If "skip bootstrap", driver bootstrap is skipped. Default: "... | [
"Return",
"a",
"registered",
"driver",
"by",
"name",
"(",
"defaults",
"to",
"the",
"default",
"driver",
")",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/WordpressDriverManager.php#L90-L107 |
paulgibbs/behat-wordpress-extension | src/WordpressDriverManager.php | WordpressDriverManager.setDefaultDriverName | public function setDefaultDriverName($name)
{
$name = strtolower($name);
if (! isset($this->drivers[$name])) {
throw new InvalidArgumentException("[W002] Driver '{$name}' is not registered.");
}
$this->default_driver = $name;
} | php | public function setDefaultDriverName($name)
{
$name = strtolower($name);
if (! isset($this->drivers[$name])) {
throw new InvalidArgumentException("[W002] Driver '{$name}' is not registered.");
}
$this->default_driver = $name;
} | [
"public",
"function",
"setDefaultDriverName",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"drivers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
... | Set the default driver name.
@param string $name Default driver name to set.
@throws \InvalidArgumentException | [
"Set",
"the",
"default",
"driver",
"name",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/WordpressDriverManager.php#L126-L135 |
paulgibbs/behat-wordpress-extension | src/WordpressDriverManager.php | WordpressDriverManager.getSetting | public function getSetting($name)
{
return ! empty($this->settings[$name]) ? $this->settings[$name] : null;
} | php | public function getSetting($name)
{
return ! empty($this->settings[$name]) ? $this->settings[$name] : null;
} | [
"public",
"function",
"getSetting",
"(",
"$",
"name",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"settings",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"settings",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] | Return the value of an internal setting.
Internal use only.
This value persists across Contexts, unlike getWordpressParameter().
@param string $name Setting name.
@return mixed | [
"Return",
"the",
"value",
"of",
"an",
"internal",
"setting",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/WordpressDriverManager.php#L147-L150 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/UserAwareContextTrait.php | UserAwareContextTrait.logIn | public function logIn(string $username, string $password, string $redirect_to = '/')
{
if ($this->loggedIn()) {
$this->logOut();
}
// Start a session.
$session = $this->getSession();
// Go to the login form.
$this->visitPath('wp-login.php?redirect_to=' .... | php | public function logIn(string $username, string $password, string $redirect_to = '/')
{
if ($this->loggedIn()) {
$this->logOut();
}
// Start a session.
$session = $this->getSession();
// Go to the login form.
$this->visitPath('wp-login.php?redirect_to=' .... | [
"public",
"function",
"logIn",
"(",
"string",
"$",
"username",
",",
"string",
"$",
"password",
",",
"string",
"$",
"redirect_to",
"=",
"'/'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"loggedIn",
"(",
")",
")",
"{",
"$",
"this",
"->",
"logOut",
"(",
... | Log in the user.
@param string $username
@param string $password
@param string $redirect_to Optional. After succesful log in, redirect browser to this path. Default = "/".
@throws ExpectationException | [
"Log",
"in",
"the",
"user",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/UserAwareContextTrait.php#L45-L69 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/UserAwareContextTrait.php | UserAwareContextTrait.loggedIn | public function loggedIn(): bool
{
$session = $this->getSession();
if (! $session->isStarted()) {
$session->start();
// If there isn't a session started the user can't be logged in.
return false;
}
$page = $session->getPage();
// Look for... | php | public function loggedIn(): bool
{
$session = $this->getSession();
if (! $session->isStarted()) {
$session->start();
// If there isn't a session started the user can't be logged in.
return false;
}
$page = $session->getPage();
// Look for... | [
"public",
"function",
"loggedIn",
"(",
")",
":",
"bool",
"{",
"$",
"session",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
";",
"if",
"(",
"!",
"$",
"session",
"->",
"isStarted",
"(",
")",
")",
"{",
"$",
"session",
"->",
"start",
"(",
")",
";"... | Determine if the current user is logged in or not.
@return bool | [
"Determine",
"if",
"the",
"current",
"user",
"is",
"logged",
"in",
"or",
"not",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/UserAwareContextTrait.php#L92-L126 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/UserAwareContextTrait.php | UserAwareContextTrait.createUser | public function createUser(string $user_login, string $user_email, array $args = []): array
{
$args['user_email'] = $user_email;
$args['user_login'] = $user_login;
try {
$user = $this->getDriver()->user->create($args);
} catch (UnexpectedValueException $exception) {
... | php | public function createUser(string $user_login, string $user_email, array $args = []): array
{
$args['user_email'] = $user_email;
$args['user_login'] = $user_login;
try {
$user = $this->getDriver()->user->create($args);
} catch (UnexpectedValueException $exception) {
... | [
"public",
"function",
"createUser",
"(",
"string",
"$",
"user_login",
",",
"string",
"$",
"user_email",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"args",
"[",
"'user_email'",
"]",
"=",
"$",
"user_email",
";",
"$",
"args",
... | Create a user.
If the user already exists, the existing user will be
compared with the user which was asked to be created. If all matches
no fault with be thrown. If it does not match then UnexpectedValueException
will be thrown.
@param string $user_login User login name.
@param string $user_email User email address.... | [
"Create",
"a",
"user",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/UserAwareContextTrait.php#L145-L162 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/UserAwareContextTrait.php | UserAwareContextTrait.getExistingMatchingUser | protected function getExistingMatchingUser(array $args)
{
$user_id = $this->getUserIdFromLogin($args['user_login']);
$user = $this->getDriver()->user->get($user_id);
/* users can have more than one role so needs to be a special case */
if (array_key_exists('role', $args)) {
... | php | protected function getExistingMatchingUser(array $args)
{
$user_id = $this->getUserIdFromLogin($args['user_login']);
$user = $this->getDriver()->user->get($user_id);
/* users can have more than one role so needs to be a special case */
if (array_key_exists('role', $args)) {
... | [
"protected",
"function",
"getExistingMatchingUser",
"(",
"array",
"$",
"args",
")",
"{",
"$",
"user_id",
"=",
"$",
"this",
"->",
"getUserIdFromLogin",
"(",
"$",
"args",
"[",
"'user_login'",
"]",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"getDriver",
... | Get a user which matches all parameters.
Fetches a user if all the passed parameters match
if none is found then UnexpectedValueException is thrown.
@param array $args Keyed array of parameters.
@throws \UnexpectedValueException
@return object $user | [
"Get",
"a",
"user",
"which",
"matches",
"all",
"parameters",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/UserAwareContextTrait.php#L176-L202 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/UserAwareContextTrait.php | UserAwareContextTrait.checkUserHasRole | protected function checkUserHasRole($user, string $role): bool
{
if (! in_array($role, $user->roles, true)) {
$message = sprintf(
'[W804] User with login: %s exists, but role %s is not in the list of applied roles: %s',
$user->user_login,
$role,
... | php | protected function checkUserHasRole($user, string $role): bool
{
if (! in_array($role, $user->roles, true)) {
$message = sprintf(
'[W804] User with login: %s exists, but role %s is not in the list of applied roles: %s',
$user->user_login,
$role,
... | [
"protected",
"function",
"checkUserHasRole",
"(",
"$",
"user",
",",
"string",
"$",
"role",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"role",
",",
"$",
"user",
"->",
"roles",
",",
"true",
")",
")",
"{",
"$",
"message",
"=",
"sprin... | Checks to see if the user has an assigned role or not.
@param object $user
@param string $role
@throws \UnexpectedValueException
@return boolean $retval True if the role does apply to the user. | [
"Checks",
"to",
"see",
"if",
"the",
"user",
"has",
"an",
"assigned",
"role",
"or",
"not",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/UserAwareContextTrait.php#L214-L227 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/UserAwareContextTrait.php | UserAwareContextTrait.isValidUserParameter | protected function isValidUserParameter(string $user_parameter): bool
{
$validUserParameters = array(
'id',
'user_login',
'display_name',
'user_email',
'user_registered',
'roles',
'user_nicename',
'user_url',
... | php | protected function isValidUserParameter(string $user_parameter): bool
{
$validUserParameters = array(
'id',
'user_login',
'display_name',
'user_email',
'user_registered',
'roles',
'user_nicename',
'user_url',
... | [
"protected",
"function",
"isValidUserParameter",
"(",
"string",
"$",
"user_parameter",
")",
":",
"bool",
"{",
"$",
"validUserParameters",
"=",
"array",
"(",
"'id'",
",",
"'user_login'",
",",
"'display_name'",
",",
"'user_email'",
",",
"'user_registered'",
",",
"'r... | Checks to see if the passed in parameter applies to a user or not.
@param string $user_parameter the parameter to be checked.
@return boolean $retval True if the parameter does apply to a user. | [
"Checks",
"to",
"see",
"if",
"the",
"passed",
"in",
"parameter",
"applies",
"to",
"a",
"user",
"or",
"not",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/UserAwareContextTrait.php#L236-L252 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/UserAwareContextTrait.php | UserAwareContextTrait.getUserIdFromLogin | public function getUserIdFromLogin(string $username): int
{
return (int) $this->getDriver()->user->get($username, ['by' => 'login'])->ID;
} | php | public function getUserIdFromLogin(string $username): int
{
return (int) $this->getDriver()->user->get($username, ['by' => 'login'])->ID;
} | [
"public",
"function",
"getUserIdFromLogin",
"(",
"string",
"$",
"username",
")",
":",
"int",
"{",
"return",
"(",
"int",
")",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"user",
"->",
"get",
"(",
"$",
"username",
",",
"[",
"'by'",
"=>",
"'login'",
... | Get a user's ID from their username.
@param string $username The username of the user to get the ID of.
@return int ID of the user. | [
"Get",
"a",
"user",
"s",
"ID",
"from",
"their",
"username",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/UserAwareContextTrait.php#L261-L264 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/UserAwareContextTrait.php | UserAwareContextTrait.deleteUser | public function deleteUser(int $user_id, array $args = [])
{
$this->getDriver()->user->delete($user_id, $args);
} | php | public function deleteUser(int $user_id, array $args = [])
{
$this->getDriver()->user->delete($user_id, $args);
} | [
"public",
"function",
"deleteUser",
"(",
"int",
"$",
"user_id",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"user",
"->",
"delete",
"(",
"$",
"user_id",
",",
"$",
"args",
")",
";",
"}"
] | Delete a user.
@param int $user_id ID of user to delete.
@param array $args Optional. Extra parameters to pass to WordPress. | [
"Delete",
"a",
"user",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/UserAwareContextTrait.php#L272-L275 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/UserAwareContextTrait.php | UserAwareContextTrait.getUserDataFromUsername | public function getUserDataFromUsername(string $data, string $username)
{
return $this->getDriver()->user->get($username, ['by' => 'login'])->{$data};
} | php | public function getUserDataFromUsername(string $data, string $username)
{
return $this->getDriver()->user->get($username, ['by' => 'login'])->{$data};
} | [
"public",
"function",
"getUserDataFromUsername",
"(",
"string",
"$",
"data",
",",
"string",
"$",
"username",
")",
"{",
"return",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"user",
"->",
"get",
"(",
"$",
"username",
",",
"[",
"'by'",
"=>",
"'login'",... | Get a piece of user data from their username.
@param string $data The user data to return (the name of a column from the WP_Users table).
@param string $username The username of the user to fetch a property from.
@return mixed The specified user data. | [
"Get",
"a",
"piece",
"of",
"user",
"data",
"from",
"their",
"username",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/UserAwareContextTrait.php#L285-L288 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpphp/TermElement.php | TermElement.create | public function create($args)
{
$args = wp_slash($args);
$term = wp_insert_term($args['term'], $args['taxonomy'], $args);
if (is_wordpress_error($term)) {
throw new UnexpectedValueException(sprintf('[W609] Failed creating a new term: %s', $term->get_error_message()));
}
... | php | public function create($args)
{
$args = wp_slash($args);
$term = wp_insert_term($args['term'], $args['taxonomy'], $args);
if (is_wordpress_error($term)) {
throw new UnexpectedValueException(sprintf('[W609] Failed creating a new term: %s', $term->get_error_message()));
}
... | [
"public",
"function",
"create",
"(",
"$",
"args",
")",
"{",
"$",
"args",
"=",
"wp_slash",
"(",
"$",
"args",
")",
";",
"$",
"term",
"=",
"wp_insert_term",
"(",
"$",
"args",
"[",
"'term'",
"]",
",",
"$",
"args",
"[",
"'taxonomy'",
"]",
",",
"$",
"a... | Create an item for this element.
@param array $args Data used to create an object.
@throws \UnexpectedValueException
@return \WP_Term The new item. | [
"Create",
"an",
"item",
"for",
"this",
"element",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpphp/TermElement.php#L22-L32 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpphp/TermElement.php | TermElement.get | public function get($id, $args = [])
{
$term = get_term($id, $args['taxonomy']);
if (! $term) {
throw new UnexpectedValueException(sprintf('[W610] Could not find term with ID %d', $id));
} elseif (is_wp_error($term)) {
throw new UnexpectedValueException(
... | php | public function get($id, $args = [])
{
$term = get_term($id, $args['taxonomy']);
if (! $term) {
throw new UnexpectedValueException(sprintf('[W610] Could not find term with ID %d', $id));
} elseif (is_wp_error($term)) {
throw new UnexpectedValueException(
... | [
"public",
"function",
"get",
"(",
"$",
"id",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"term",
"=",
"get_term",
"(",
"$",
"id",
",",
"$",
"args",
"[",
"'taxonomy'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"term",
")",
"{",
"throw",
"new",
... | Retrieve an item for this element.
@param int $id Object ID.
@param array $args Optional data used to fetch an object.
@throws \UnexpectedValueException
@return \WP_Term The item. | [
"Retrieve",
"an",
"item",
"for",
"this",
"element",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpphp/TermElement.php#L44-L57 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpphp/TermElement.php | TermElement.delete | public function delete($id, $args = [])
{
$result = wp_delete_term($id, $args['taxonomy']);
if (is_wordpress_error($result)) {
throw new UnexpectedValueException(
sprintf('[W611] Failed deleting a term: %s', $result->get_error_message())
);
}
} | php | public function delete($id, $args = [])
{
$result = wp_delete_term($id, $args['taxonomy']);
if (is_wordpress_error($result)) {
throw new UnexpectedValueException(
sprintf('[W611] Failed deleting a term: %s', $result->get_error_message())
);
}
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"wp_delete_term",
"(",
"$",
"id",
",",
"$",
"args",
"[",
"'taxonomy'",
"]",
")",
";",
"if",
"(",
"is_wordpress_error",
"(",
"$",
"result"... | Delete an item for this element.
@param int $id Object ID.
@param array $args Optional data used to delete an object.
@throws \UnexpectedValueException | [
"Delete",
"an",
"item",
"for",
"this",
"element",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpphp/TermElement.php#L67-L76 |
paulgibbs/behat-wordpress-extension | src/ServiceContainer/WordpressBehatExtension.php | WordpressBehatExtension.configure | public function configure(ArrayNodeDefinition $builder)
{
$builder
->children()
// Common settings.
->enumNode('default_driver')
// "wpapi" is for backwards compatibility; means "wpphp".
->values(['wpcli', 'wpapi', 'wpphp', ... | php | public function configure(ArrayNodeDefinition $builder)
{
$builder
->children()
// Common settings.
->enumNode('default_driver')
// "wpapi" is for backwards compatibility; means "wpphp".
->values(['wpcli', 'wpapi', 'wpphp', ... | [
"public",
"function",
"configure",
"(",
"ArrayNodeDefinition",
"$",
"builder",
")",
"{",
"$",
"builder",
"->",
"children",
"(",
")",
"// Common settings.",
"->",
"enumNode",
"(",
"'default_driver'",
")",
"// \"wpapi\" is for backwards compatibility; means \"wpphp\".",
"->... | Declare configuration options for the extension.
@param ArrayNodeDefinition $builder | [
"Declare",
"configuration",
"options",
"for",
"the",
"extension",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/ServiceContainer/WordpressBehatExtension.php#L73-L160 |
paulgibbs/behat-wordpress-extension | src/ServiceContainer/WordpressBehatExtension.php | WordpressBehatExtension.load | public function load(ContainerBuilder $container, array $config)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/config'));
$loader->load('services.yml');
// Backwards compatibility for pre-1.0. Will be removed in 2.0.
if ($config['default_driver'] === 'wpapi'... | php | public function load(ContainerBuilder $container, array $config)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/config'));
$loader->load('services.yml');
// Backwards compatibility for pre-1.0. Will be removed in 2.0.
if ($config['default_driver'] === 'wpapi'... | [
"public",
"function",
"load",
"(",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"config",
")",
"{",
"$",
"loader",
"=",
"new",
"YamlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"__DIR__",
".",
"'/config'",
")",
")",
";",
... | Load extension services into ServiceContainer.
@param ContainerBuilder $container
@param array $config | [
"Load",
"extension",
"services",
"into",
"ServiceContainer",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/ServiceContainer/WordpressBehatExtension.php#L168-L185 |
paulgibbs/behat-wordpress-extension | src/ServiceContainer/WordpressBehatExtension.php | WordpressBehatExtension.setupWpcliDriver | protected function setupWpcliDriver(FileLoader $loader, ContainerBuilder $container, array $config)
{
if (! isset($config['wpcli'])) {
return;
}
$loader->load('drivers/wpcli.yml');
$config['wpcli']['alias'] = isset($config['wpcli']['alias']) ? $config['wpcli']['alias'] ... | php | protected function setupWpcliDriver(FileLoader $loader, ContainerBuilder $container, array $config)
{
if (! isset($config['wpcli'])) {
return;
}
$loader->load('drivers/wpcli.yml');
$config['wpcli']['alias'] = isset($config['wpcli']['alias']) ? $config['wpcli']['alias'] ... | [
"protected",
"function",
"setupWpcliDriver",
"(",
"FileLoader",
"$",
"loader",
",",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'wpcli'",
"]",
")",
")",
"{",
"return",
";... | Load settings for the WP-CLI driver.
@param FileLoader $loader
@param ContainerBuilder $container
@param array $config | [
"Load",
"settings",
"for",
"the",
"WP",
"-",
"CLI",
"driver",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/ServiceContainer/WordpressBehatExtension.php#L194-L210 |
paulgibbs/behat-wordpress-extension | src/ServiceContainer/WordpressBehatExtension.php | WordpressBehatExtension.setupWpphpDriver | protected function setupWpphpDriver(FileLoader $loader, ContainerBuilder $container, array $config)
{
if (! isset($config['wpphp'])) {
return;
}
$loader->load('drivers/wpphp.yml');
$config['wpphp']['path'] = isset($config['path']) ? $config['path'] : '';
$contai... | php | protected function setupWpphpDriver(FileLoader $loader, ContainerBuilder $container, array $config)
{
if (! isset($config['wpphp'])) {
return;
}
$loader->load('drivers/wpphp.yml');
$config['wpphp']['path'] = isset($config['path']) ? $config['path'] : '';
$contai... | [
"protected",
"function",
"setupWpphpDriver",
"(",
"FileLoader",
"$",
"loader",
",",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'wpphp'",
"]",
")",
")",
"{",
"return",
";... | Load settings for the WordPress PHP driver.
@param FileLoader $loader
@param ContainerBuilder $container
@param array $config | [
"Load",
"settings",
"for",
"the",
"WordPress",
"PHP",
"driver",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/ServiceContainer/WordpressBehatExtension.php#L219-L229 |
paulgibbs/behat-wordpress-extension | src/ServiceContainer/WordpressBehatExtension.php | WordpressBehatExtension.setupBlackboxDriver | protected function setupBlackboxDriver(FileLoader $loader, ContainerBuilder $container, array $config)
{
if (! isset($config['blackbox'])) {
return;
}
$loader->load('drivers/blackbox.yml');
} | php | protected function setupBlackboxDriver(FileLoader $loader, ContainerBuilder $container, array $config)
{
if (! isset($config['blackbox'])) {
return;
}
$loader->load('drivers/blackbox.yml');
} | [
"protected",
"function",
"setupBlackboxDriver",
"(",
"FileLoader",
"$",
"loader",
",",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'blackbox'",
"]",
")",
")",
"{",
"return"... | Load settings for the blackbox driver.
@param FileLoader $loader
@param ContainerBuilder $container
@param array $config | [
"Load",
"settings",
"for",
"the",
"blackbox",
"driver",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/ServiceContainer/WordpressBehatExtension.php#L238-L245 |
paulgibbs/behat-wordpress-extension | src/ServiceContainer/WordpressBehatExtension.php | WordpressBehatExtension.process | public function process(ContainerBuilder $container)
{
$this->processDriverPass($container);
$this->processDriverElementPass($container);
$this->processEventSubscriberPass($container);
$this->processClassGenerator($container);
$this->setPageObjectNamespaces($container);
... | php | public function process(ContainerBuilder $container)
{
$this->processDriverPass($container);
$this->processDriverElementPass($container);
$this->processEventSubscriberPass($container);
$this->processClassGenerator($container);
$this->setPageObjectNamespaces($container);
... | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"this",
"->",
"processDriverPass",
"(",
"$",
"container",
")",
";",
"$",
"this",
"->",
"processDriverElementPass",
"(",
"$",
"container",
")",
";",
"$",
"this",
"->",
... | Modify the container before Symfony compiles it.
@param ContainerBuilder $container | [
"Modify",
"the",
"container",
"before",
"Symfony",
"compiles",
"it",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/ServiceContainer/WordpressBehatExtension.php#L252-L261 |
paulgibbs/behat-wordpress-extension | src/ServiceContainer/WordpressBehatExtension.php | WordpressBehatExtension.setPageObjectNamespaces | protected function setPageObjectNamespaces(ContainerBuilder $container)
{
// Append our namespaces as earlier namespaces take precedence.
$pages = $container->getParameter('sensio_labs.page_object_extension.namespaces.page');
$pages[] = 'PaulGibbs\WordpressBehatExtension\PageObject';
... | php | protected function setPageObjectNamespaces(ContainerBuilder $container)
{
// Append our namespaces as earlier namespaces take precedence.
$pages = $container->getParameter('sensio_labs.page_object_extension.namespaces.page');
$pages[] = 'PaulGibbs\WordpressBehatExtension\PageObject';
... | [
"protected",
"function",
"setPageObjectNamespaces",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"// Append our namespaces as earlier namespaces take precedence.",
"$",
"pages",
"=",
"$",
"container",
"->",
"getParameter",
"(",
"'sensio_labs.page_object_extension.namespac... | Tell Page Object Extension the namespace of our page objects
@param ContainerBuilder $container | [
"Tell",
"Page",
"Object",
"Extension",
"the",
"namespace",
"of",
"our",
"page",
"objects"
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/ServiceContainer/WordpressBehatExtension.php#L314-L325 |
paulgibbs/behat-wordpress-extension | src/ServiceContainer/WordpressBehatExtension.php | WordpressBehatExtension.injectSiteUrlIntoPageObjects | protected function injectSiteUrlIntoPageObjects(ContainerBuilder $container)
{
$page_parameters = $container->getParameter('sensio_labs.page_object_extension.page_factory.page_parameters');
$page_parameters = $container->getParameterBag()->resolveValue($page_parameters);
$page_parameters['si... | php | protected function injectSiteUrlIntoPageObjects(ContainerBuilder $container)
{
$page_parameters = $container->getParameter('sensio_labs.page_object_extension.page_factory.page_parameters');
$page_parameters = $container->getParameterBag()->resolveValue($page_parameters);
$page_parameters['si... | [
"protected",
"function",
"injectSiteUrlIntoPageObjects",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"page_parameters",
"=",
"$",
"container",
"->",
"getParameter",
"(",
"'sensio_labs.page_object_extension.page_factory.page_parameters'",
")",
";",
"$",
"page_p... | Adds the WordPress site url as a page parameter into page objects.
@param ContainerBuilder $container | [
"Adds",
"the",
"WordPress",
"site",
"url",
"as",
"a",
"page",
"parameter",
"into",
"page",
"objects",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/ServiceContainer/WordpressBehatExtension.php#L332-L338 |
paulgibbs/behat-wordpress-extension | src/Context/Initialiser/WordpressAwareInitialiser.php | WordpressAwareInitialiser.initializeContext | public function initializeContext(Context $context)
{
if (! $context instanceof WordpressAwareInterface) {
return;
}
$context->setWordpress($this->wordpress);
$context->setWordpressParameters($this->parameters);
} | php | public function initializeContext(Context $context)
{
if (! $context instanceof WordpressAwareInterface) {
return;
}
$context->setWordpress($this->wordpress);
$context->setWordpressParameters($this->parameters);
} | [
"public",
"function",
"initializeContext",
"(",
"Context",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"$",
"context",
"instanceof",
"WordpressAwareInterface",
")",
"{",
"return",
";",
"}",
"$",
"context",
"->",
"setWordpress",
"(",
"$",
"this",
"->",
"wordpre... | Prepare everything that the Context needs.
@param Context $context | [
"Prepare",
"everything",
"that",
"the",
"Context",
"needs",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Initialiser/WordpressAwareInitialiser.php#L47-L55 |
paulgibbs/behat-wordpress-extension | src/Context/WordpressContext.php | WordpressContext.maybeBackupDatabase | public function maybeBackupDatabase(BeforeScenarioScope $scope)
{
$db = $this->getWordpressParameter('database');
if (! $db['restore_after_test']) {
return;
}
/*
* We need the logic of this method to operate only once, and have access to the Context.
* ... | php | public function maybeBackupDatabase(BeforeScenarioScope $scope)
{
$db = $this->getWordpressParameter('database');
if (! $db['restore_after_test']) {
return;
}
/*
* We need the logic of this method to operate only once, and have access to the Context.
* ... | [
"public",
"function",
"maybeBackupDatabase",
"(",
"BeforeScenarioScope",
"$",
"scope",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"getWordpressParameter",
"(",
"'database'",
")",
";",
"if",
"(",
"!",
"$",
"db",
"[",
"'restore_after_test'",
"]",
")",
"{",
... | If database.restore_after_test is set, and a scenario is tagged "db", create a database backup.
The database will be restored from this backup via maybeRestoreDatabase().
@BeforeScenario @db
@param BeforeScenarioScope $scope | [
"If",
"database",
".",
"restore_after_test",
"is",
"set",
"and",
"a",
"scenario",
"is",
"tagged",
"db",
"create",
"a",
"database",
"backup",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/WordpressContext.php#L36-L62 |
paulgibbs/behat-wordpress-extension | src/Context/WordpressContext.php | WordpressContext.fixToolbar | public function fixToolbar()
{
$driver = $this->getSession()->getDriver();
if (! $driver instanceof Selenium2Driver || ! $driver->getWebDriverSession()) {
return;
}
try {
$this->getSession()->getDriver()->executeScript(
'if (document.getElemen... | php | public function fixToolbar()
{
$driver = $this->getSession()->getDriver();
if (! $driver instanceof Selenium2Driver || ! $driver->getWebDriverSession()) {
return;
}
try {
$this->getSession()->getDriver()->executeScript(
'if (document.getElemen... | [
"public",
"function",
"fixToolbar",
"(",
")",
"{",
"$",
"driver",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getDriver",
"(",
")",
";",
"if",
"(",
"!",
"$",
"driver",
"instanceof",
"Selenium2Driver",
"||",
"!",
"$",
"driver",
"->",
"getWebD... | When using the Selenium driver, position the admin bar to the top of the page, not fixed to the screen.
Otherwise the admin toolbar can hide clickable elements.
@BeforeStep | [
"When",
"using",
"the",
"Selenium",
"driver",
"position",
"the",
"admin",
"bar",
"to",
"the",
"top",
"of",
"the",
"page",
"not",
"fixed",
"to",
"the",
"screen",
".",
"Otherwise",
"the",
"admin",
"toolbar",
"can",
"hide",
"clickable",
"elements",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/WordpressContext.php#L70-L92 |
paulgibbs/behat-wordpress-extension | src/Context/WordpressContext.php | WordpressContext.maybeRestoreDatabase | public function maybeRestoreDatabase(AfterScenarioScope $scope)
{
$db = $this->getWordpressParameter('database');
if (! $db['restore_after_test']) {
return;
}
$file = $this->getWordpress()->getSetting('database_backup_file');
if (! $file) {
return;
... | php | public function maybeRestoreDatabase(AfterScenarioScope $scope)
{
$db = $this->getWordpressParameter('database');
if (! $db['restore_after_test']) {
return;
}
$file = $this->getWordpress()->getSetting('database_backup_file');
if (! $file) {
return;
... | [
"public",
"function",
"maybeRestoreDatabase",
"(",
"AfterScenarioScope",
"$",
"scope",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"getWordpressParameter",
"(",
"'database'",
")",
";",
"if",
"(",
"!",
"$",
"db",
"[",
"'restore_after_test'",
"]",
")",
"{",
... | If database.restore_after_test is set, and scenario is tagged "db", restore the database from a backup.
The database will be restored from a backup made via maybeBackupDatabase().
@AfterScenario @db
@param AfterScenarioScope $scope | [
"If",
"database",
".",
"restore_after_test",
"is",
"set",
"and",
"scenario",
"is",
"tagged",
"db",
"restore",
"the",
"database",
"from",
"a",
"backup",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/WordpressContext.php#L113-L126 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/TermAwareContextTrait.php | TermAwareContextTrait.createTerm | public function createTerm(string $term, string $taxonomy, array $args = []): array
{
$args['taxonomy'] = $taxonomy;
$args['term'] = $term;
$term = $this->getDriver()->term->create($args);
return array(
'id' => $term->term_id,
'slug' => $term->slug
... | php | public function createTerm(string $term, string $taxonomy, array $args = []): array
{
$args['taxonomy'] = $taxonomy;
$args['term'] = $term;
$term = $this->getDriver()->term->create($args);
return array(
'id' => $term->term_id,
'slug' => $term->slug
... | [
"public",
"function",
"createTerm",
"(",
"string",
"$",
"term",
",",
"string",
"$",
"taxonomy",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"args",
"[",
"'taxonomy'",
"]",
"=",
"$",
"taxonomy",
";",
"$",
"args",
"[",
"'te... | Create a term in a taxonomy.
@param string $term
@param string $taxonomy
@param array $args Optional. Set the values of the new term.
@return array {
@type int $id Term ID.
@type string $slug Term slug.
} | [
"Create",
"a",
"term",
"in",
"a",
"taxonomy",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/TermAwareContextTrait.php#L24-L35 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/TermAwareContextTrait.php | TermAwareContextTrait.deleteTerm | public function deleteTerm(int $term_id, string $taxonomy)
{
$this->getDriver()->term->delete($term_id, compact($taxonomy));
} | php | public function deleteTerm(int $term_id, string $taxonomy)
{
$this->getDriver()->term->delete($term_id, compact($taxonomy));
} | [
"public",
"function",
"deleteTerm",
"(",
"int",
"$",
"term_id",
",",
"string",
"$",
"taxonomy",
")",
"{",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"term",
"->",
"delete",
"(",
"$",
"term_id",
",",
"compact",
"(",
"$",
"taxonomy",
")",
")",
";"... | Delete a term from a taxonomy.
@param int $term_id
@param string $taxonomy | [
"Delete",
"a",
"term",
"from",
"a",
"taxonomy",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/TermAwareContextTrait.php#L43-L46 |
paulgibbs/behat-wordpress-extension | src/PageObject/AdminPage.php | AdminPage.getHeaderText | public function getHeaderText(): string
{
$header = $this->getHeaderElement();
$header_text = $header->getText();
$header_link = $header->find('css', 'a');
// The page headers can often include an 'add new link'. Strip that out of the header text.
if ($header_link) {
... | php | public function getHeaderText(): string
{
$header = $this->getHeaderElement();
$header_text = $header->getText();
$header_link = $header->find('css', 'a');
// The page headers can often include an 'add new link'. Strip that out of the header text.
if ($header_link) {
... | [
"public",
"function",
"getHeaderText",
"(",
")",
":",
"string",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"getHeaderElement",
"(",
")",
";",
"$",
"header_text",
"=",
"$",
"header",
"->",
"getText",
"(",
")",
";",
"$",
"header_link",
"=",
"$",
"header... | Returns the text in the header tag.
The first h1 element is used, or first h2 element if it is not present.
@return string The text in the header tag. | [
"Returns",
"the",
"text",
"in",
"the",
"header",
"tag",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/AdminPage.php#L24-L36 |
paulgibbs/behat-wordpress-extension | src/PageObject/AdminPage.php | AdminPage.assertHasHeader | public function assertHasHeader(string $expected)
{
$actual = $this->getHeaderText();
if ($expected === $actual) {
return;
}
throw new ExpectationException(
sprintf(
'[W402] Expected screen header "%1$s", found "%2$s".',
$expec... | php | public function assertHasHeader(string $expected)
{
$actual = $this->getHeaderText();
if ($expected === $actual) {
return;
}
throw new ExpectationException(
sprintf(
'[W402] Expected screen header "%1$s", found "%2$s".',
$expec... | [
"public",
"function",
"assertHasHeader",
"(",
"string",
"$",
"expected",
")",
"{",
"$",
"actual",
"=",
"$",
"this",
"->",
"getHeaderText",
"(",
")",
";",
"if",
"(",
"$",
"expected",
"===",
"$",
"actual",
")",
"{",
"return",
";",
"}",
"throw",
"new",
... | Asserts the text in the header tag matches the given text.
@param string $expected
@throws \Behat\Mink\Exception\ExpectationException | [
"Asserts",
"the",
"text",
"in",
"the",
"header",
"tag",
"matches",
"the",
"given",
"text",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/AdminPage.php#L45-L60 |
paulgibbs/behat-wordpress-extension | src/PageObject/AdminPage.php | AdminPage.getHeaderElement | protected function getHeaderElement()
{
/*
* h2s were used prior to WP v4.3/4 and h1s after.
* See https://make.wordpress.org/core/2015/10/28/headings-hierarchy-changes-in-the-admin-screens/
*/
$header2 = $this->find('css', '.wrap > h2');
$header1 = $this->find('cs... | php | protected function getHeaderElement()
{
/*
* h2s were used prior to WP v4.3/4 and h1s after.
* See https://make.wordpress.org/core/2015/10/28/headings-hierarchy-changes-in-the-admin-screens/
*/
$header2 = $this->find('css', '.wrap > h2');
$header1 = $this->find('cs... | [
"protected",
"function",
"getHeaderElement",
"(",
")",
"{",
"/*\n * h2s were used prior to WP v4.3/4 and h1s after.\n * See https://make.wordpress.org/core/2015/10/28/headings-hierarchy-changes-in-the-admin-screens/\n */",
"$",
"header2",
"=",
"$",
"this",
"->",
"fi... | Get the text in the header tag.
The first h1 element is used, or first h2 element if it is not present.
@throws \Behat\Mink\Exception\ExpectationException | [
"Get",
"the",
"text",
"in",
"the",
"header",
"tag",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/AdminPage.php#L69-L85 |
paulgibbs/behat-wordpress-extension | src/PageObject/AdminPage.php | AdminPage.clickLinkInHeader | public function clickLinkInHeader(string $link)
{
$header_link = $this->find('css', '.page-title-action');
if ($header_link->getText() === $link) {
$header_link->click();
} else {
$this->getHeaderElement()->clickLink($link);
}
} | php | public function clickLinkInHeader(string $link)
{
$header_link = $this->find('css', '.page-title-action');
if ($header_link->getText() === $link) {
$header_link->click();
} else {
$this->getHeaderElement()->clickLink($link);
}
} | [
"public",
"function",
"clickLinkInHeader",
"(",
"string",
"$",
"link",
")",
"{",
"$",
"header_link",
"=",
"$",
"this",
"->",
"find",
"(",
"'css'",
",",
"'.page-title-action'",
")",
";",
"if",
"(",
"$",
"header_link",
"->",
"getText",
"(",
")",
"===",
"$"... | Click a link within the page header tag.
@param string $link Link text. | [
"Click",
"a",
"link",
"within",
"the",
"page",
"header",
"tag",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/AdminPage.php#L92-L101 |
paulgibbs/behat-wordpress-extension | src/PageObject/AdminPage.php | AdminPage.makeSurePathIsAbsolute | protected function makeSurePathIsAbsolute($path): string
{
$site_url = rtrim($this->getParameter('site_url'), '/') . '/';
if (0 !== strpos($path, 'http')) {
return $site_url . ltrim($path, '/');
} else {
return $path;
}
} | php | protected function makeSurePathIsAbsolute($path): string
{
$site_url = rtrim($this->getParameter('site_url'), '/') . '/';
if (0 !== strpos($path, 'http')) {
return $site_url . ltrim($path, '/');
} else {
return $path;
}
} | [
"protected",
"function",
"makeSurePathIsAbsolute",
"(",
"$",
"path",
")",
":",
"string",
"{",
"$",
"site_url",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'site_url'",
")",
",",
"'/'",
")",
".",
"'/'",
";",
"if",
"(",
"0",
"!==",
"strpo... | We use WordHat's site_url property rather than Mink's base_url property
to get the correct URL to wp-admin, wp-login.php etc.
@param string $path Relative path of this page
@return string Absolute URL | [
"We",
"use",
"WordHat",
"s",
"site_url",
"property",
"rather",
"than",
"Mink",
"s",
"base_url",
"property",
"to",
"get",
"the",
"correct",
"URL",
"to",
"wp",
"-",
"admin",
"wp",
"-",
"login",
".",
"php",
"etc",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/AdminPage.php#L150-L159 |
paulgibbs/behat-wordpress-extension | src/PageObject/AdminPage.php | AdminPage.unmaskUrl | protected function unmaskUrl(array $url_parameters): string
{
$url = $this->getPath();
foreach ($url_parameters as $parameter => $value) {
$url = str_replace(sprintf('{%s}', $parameter), $value, $url);
}
return $url;
} | php | protected function unmaskUrl(array $url_parameters): string
{
$url = $this->getPath();
foreach ($url_parameters as $parameter => $value) {
$url = str_replace(sprintf('{%s}', $parameter), $value, $url);
}
return $url;
} | [
"protected",
"function",
"unmaskUrl",
"(",
"array",
"$",
"url_parameters",
")",
":",
"string",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"foreach",
"(",
"$",
"url_parameters",
"as",
"$",
"parameter",
"=>",
"$",
"value",
")",
"{... | Insert values for placeholders in the page's path.
@param array $url_parameters
@return string | [
"Insert",
"values",
"for",
"placeholders",
"in",
"the",
"page",
"s",
"path",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/AdminPage.php#L168-L177 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/CommentAwareContextTrait.php | CommentAwareContextTrait.createComment | public function createComment(array $args): array
{
$comment = $this->getDriver()->comment->create($args);
return array(
'id' => $comment->comment_ID
);
} | php | public function createComment(array $args): array
{
$comment = $this->getDriver()->comment->create($args);
return array(
'id' => $comment->comment_ID
);
} | [
"public",
"function",
"createComment",
"(",
"array",
"$",
"args",
")",
":",
"array",
"{",
"$",
"comment",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"comment",
"->",
"create",
"(",
"$",
"args",
")",
";",
"return",
"array",
"(",
"'id'",
"=>"... | Create a comment.
@param array $args Set the values of the new comment.
@return array {
@type int $id Content ID.
} | [
"Create",
"a",
"comment",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/CommentAwareContextTrait.php#L21-L28 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/CommentAwareContextTrait.php | CommentAwareContextTrait.deleteComment | public function deleteComment(int $comment_id, array $args = [])
{
$this->getDriver()->comment->delete($comment_id, $args);
} | php | public function deleteComment(int $comment_id, array $args = [])
{
$this->getDriver()->comment->delete($comment_id, $args);
} | [
"public",
"function",
"deleteComment",
"(",
"int",
"$",
"comment_id",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"comment",
"->",
"delete",
"(",
"$",
"comment_id",
",",
"$",
"args",
")",
";",
... | Delete specified comment.
@param int $comment_id ID of comment to delete.
@param array $args Optional. Extra parameters to pass to WordPress. | [
"Delete",
"specified",
"comment",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/CommentAwareContextTrait.php#L36-L39 |
paulgibbs/behat-wordpress-extension | src/Context/ToolbarContext.php | ToolbarContext.iShouldSeeTextInToolbar | public function iShouldSeeTextInToolbar(string $text)
{
$toolbar = $this->getElement('Toolbar');
$actual = $toolbar->getText();
$regex = '/' . preg_quote($text, '/') . '/ui';
if (! preg_match($regex, $actual)) {
$message = sprintf('[W806] The text "%s" was not found i... | php | public function iShouldSeeTextInToolbar(string $text)
{
$toolbar = $this->getElement('Toolbar');
$actual = $toolbar->getText();
$regex = '/' . preg_quote($text, '/') . '/ui';
if (! preg_match($regex, $actual)) {
$message = sprintf('[W806] The text "%s" was not found i... | [
"public",
"function",
"iShouldSeeTextInToolbar",
"(",
"string",
"$",
"text",
")",
"{",
"$",
"toolbar",
"=",
"$",
"this",
"->",
"getElement",
"(",
"'Toolbar'",
")",
";",
"$",
"actual",
"=",
"$",
"toolbar",
"->",
"getText",
"(",
")",
";",
"$",
"regex",
"... | Clicks the specified link in the toolbar.
Example: Then I should see "Howdy, admin" in the toolbar
@Then I should see :text in the toolbar
@param string $text
@throws ElementTextException | [
"Clicks",
"the",
"specified",
"link",
"in",
"the",
"toolbar",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/ToolbarContext.php#L37-L47 |
paulgibbs/behat-wordpress-extension | src/Context/ToolbarContext.php | ToolbarContext.theUsernameShouldBe | public function theUsernameShouldBe(string $username)
{
$toolbar = $this->getElement('Toolbar');
$actual = $toolbar->getAuthenticatedUserText();
if ($username !== $actual) {
$message = sprintf('[W807] Toolbar shows authenticated user is "%1$s", not "%2$s"', $actual, $username);... | php | public function theUsernameShouldBe(string $username)
{
$toolbar = $this->getElement('Toolbar');
$actual = $toolbar->getAuthenticatedUserText();
if ($username !== $actual) {
$message = sprintf('[W807] Toolbar shows authenticated user is "%1$s", not "%2$s"', $actual, $username);... | [
"public",
"function",
"theUsernameShouldBe",
"(",
"string",
"$",
"username",
")",
"{",
"$",
"toolbar",
"=",
"$",
"this",
"->",
"getElement",
"(",
"'Toolbar'",
")",
";",
"$",
"actual",
"=",
"$",
"toolbar",
"->",
"getAuthenticatedUserText",
"(",
")",
";",
"i... | Checks the authenticated user show in the toolbar.
Example: Then the toolbar should show I am authenticated as admin
@Then the toolbar should show I am authenticated as :username
@param string $username | [
"Checks",
"the",
"authenticated",
"user",
"show",
"in",
"the",
"toolbar",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/ToolbarContext.php#L58-L67 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/ContentAwareContextTrait.php | ContentAwareContextTrait.createContent | public function createContent(array $args): array
{
$post = $this->getDriver()->content->create($args);
return array(
'id' => (int) $post->ID,
'slug' => $post->post_name,
'url' => $post->url,
);
} | php | public function createContent(array $args): array
{
$post = $this->getDriver()->content->create($args);
return array(
'id' => (int) $post->ID,
'slug' => $post->post_name,
'url' => $post->url,
);
} | [
"public",
"function",
"createContent",
"(",
"array",
"$",
"args",
")",
":",
"array",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"content",
"->",
"create",
"(",
"$",
"args",
")",
";",
"return",
"array",
"(",
"'id'",
"=>",
... | Create content.
@param array $args Set the values of the new content item.
@return array {
@type int $id Content ID.
@type string $slug Content slug.
@type string $url Content permalink.
} | [
"Create",
"content",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/ContentAwareContextTrait.php#L23-L32 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/ContentAwareContextTrait.php | ContentAwareContextTrait.getContentFromTitle | public function getContentFromTitle(string $title, string $post_type = ''): array
{
$post = $this->getDriver()->content->get($title, ['by' => 'title', 'post_type' => $post_type]);
return array(
'id' => (int) $post->ID,
'slug' => $post->post_name,
'url' => $pos... | php | public function getContentFromTitle(string $title, string $post_type = ''): array
{
$post = $this->getDriver()->content->get($title, ['by' => 'title', 'post_type' => $post_type]);
return array(
'id' => (int) $post->ID,
'slug' => $post->post_name,
'url' => $pos... | [
"public",
"function",
"getContentFromTitle",
"(",
"string",
"$",
"title",
",",
"string",
"$",
"post_type",
"=",
"''",
")",
":",
"array",
"{",
"$",
"post",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"content",
"->",
"get",
"(",
"$",
"title",
... | Get content from its title.
@param string $title The title of the content to get.
@param string $post_type Post type(s) to consider when searching for the content.
@return array {
@type int $id Content ID.
@type string $slug Content slug.
@type string $url Content url.
} | [
"Get",
"content",
"from",
"its",
"title",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/ContentAwareContextTrait.php#L46-L55 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/ContentAwareContextTrait.php | ContentAwareContextTrait.deleteContent | public function deleteContent(int $content_id, array $args = [])
{
$this->getDriver()->content->delete($content_id, $args);
} | php | public function deleteContent(int $content_id, array $args = [])
{
$this->getDriver()->content->delete($content_id, $args);
} | [
"public",
"function",
"deleteContent",
"(",
"int",
"$",
"content_id",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"content",
"->",
"delete",
"(",
"$",
"content_id",
",",
"$",
"args",
")",
";",
... | Delete specified content.
@param int $content_id ID of content to delete.
@param array $args Optional. Extra parameters to pass to WordPress. | [
"Delete",
"specified",
"content",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/ContentAwareContextTrait.php#L63-L66 |
paulgibbs/behat-wordpress-extension | src/Context/DashboardContext.php | DashboardContext.iGoToMenuItem | public function iGoToMenuItem(string $item)
{
$adminMenu = $this->admin_page->getMenu();
$adminMenu->clickMenuItem($item);
} | php | public function iGoToMenuItem(string $item)
{
$adminMenu = $this->admin_page->getMenu();
$adminMenu->clickMenuItem($item);
} | [
"public",
"function",
"iGoToMenuItem",
"(",
"string",
"$",
"item",
")",
"{",
"$",
"adminMenu",
"=",
"$",
"this",
"->",
"admin_page",
"->",
"getMenu",
"(",
")",
";",
"$",
"adminMenu",
"->",
"clickMenuItem",
"(",
"$",
"item",
")",
";",
"}"
] | Go to a given screen on the admin menu.
Example: Given I go to the "Users" menu
Example: Given I go to the menu "Settings > Reading"
@Given I go to the menu :item
@Given I go to the :item menu
@param string $item | [
"Go",
"to",
"a",
"given",
"screen",
"on",
"the",
"admin",
"menu",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/DashboardContext.php#L88-L92 |
paulgibbs/behat-wordpress-extension | src/Context/DashboardContext.php | DashboardContext.iShouldSeeMessageThatSays | public function iShouldSeeMessageThatSays(string $type, string $message)
{
$selector = 'div.notice';
if ($type === 'error') {
$selector .= '.error';
} else {
$selector .= '.updated';
}
$this->assertSession()->elementTextContains('css', $selector, $me... | php | public function iShouldSeeMessageThatSays(string $type, string $message)
{
$selector = 'div.notice';
if ($type === 'error') {
$selector .= '.error';
} else {
$selector .= '.updated';
}
$this->assertSession()->elementTextContains('css', $selector, $me... | [
"public",
"function",
"iShouldSeeMessageThatSays",
"(",
"string",
"$",
"type",
",",
"string",
"$",
"message",
")",
"{",
"$",
"selector",
"=",
"'div.notice'",
";",
"if",
"(",
"$",
"type",
"===",
"'error'",
")",
"{",
"$",
"selector",
".=",
"'.error'",
";",
... | Check the specified notification is on-screen.
Example: Then I should see a status message that says "Post published"
@Then /^(?:I|they) should see an? (error|status) message that says "([^"]+)"$/
@param string $type Message type. Either "error" or "status".
@param string $message Text to search for. | [
"Check",
"the",
"specified",
"notification",
"is",
"on",
"-",
"screen",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/DashboardContext.php#L104-L115 |
paulgibbs/behat-wordpress-extension | src/Context/Traits/WidgetAwareContextTrait.php | WidgetAwareContextTrait.addWidgetToSidebar | public function addWidgetToSidebar(string $widget_name, string $sidebar_id, array $args)
{
$this->getDriver()->widget->addToSidebar($widget_name, $sidebar_id, $args);
} | php | public function addWidgetToSidebar(string $widget_name, string $sidebar_id, array $args)
{
$this->getDriver()->widget->addToSidebar($widget_name, $sidebar_id, $args);
} | [
"public",
"function",
"addWidgetToSidebar",
"(",
"string",
"$",
"widget_name",
",",
"string",
"$",
"sidebar_id",
",",
"array",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"widget",
"->",
"addToSidebar",
"(",
"$",
"widget_name",
"... | Adds a widget to the sidebar with the specified arguments.
@param string $widget_name The ID base of the widget (e.g. 'meta', 'calendar'). Case insensitive.
@param string $sidebar_id The ID of the sidebar to the add the widget to.
@param array $args Associative array of widget settings for this widget. | [
"Adds",
"a",
"widget",
"to",
"the",
"sidebar",
"with",
"the",
"specified",
"arguments",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/Traits/WidgetAwareContextTrait.php#L28-L31 |
paulgibbs/behat-wordpress-extension | src/Context/ContextClass/ClassGenerator.php | ClassGenerator.generateClass | public function generateClass(Suite $suite, $context_class)
{
$fqn = $context_class;
$namespace = '';
$pos = strrpos($fqn, '\\');
if ($pos) {
$context_class = substr($fqn, $pos + 1);
$namespace = sprintf('namespace %s;%s', substr($fqn, 0, $pos... | php | public function generateClass(Suite $suite, $context_class)
{
$fqn = $context_class;
$namespace = '';
$pos = strrpos($fqn, '\\');
if ($pos) {
$context_class = substr($fqn, $pos + 1);
$namespace = sprintf('namespace %s;%s', substr($fqn, 0, $pos... | [
"public",
"function",
"generateClass",
"(",
"Suite",
"$",
"suite",
",",
"$",
"context_class",
")",
"{",
"$",
"fqn",
"=",
"$",
"context_class",
";",
"$",
"namespace",
"=",
"''",
";",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"fqn",
",",
"'\\\\'",
")",
";"... | Generate context class code.
@param Suite $suite
@param string $context_class
@return string The context class source code. | [
"Generate",
"context",
"class",
"code",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/ContextClass/ClassGenerator.php#L61-L79 |
paulgibbs/behat-wordpress-extension | src/Driver/Element/Wpcli/TermElement.php | TermElement.get | public function get($id, $args = [])
{
$wpcli_args = buildCLIArgs(
array(
'field',
'fields',
),
$args
);
array_unshift($wpcli_args, $args['taxonomy'], $id, '--format=json');
$term = $this->drivers->getDriver()->wpcl... | php | public function get($id, $args = [])
{
$wpcli_args = buildCLIArgs(
array(
'field',
'fields',
),
$args
);
array_unshift($wpcli_args, $args['taxonomy'], $id, '--format=json');
$term = $this->drivers->getDriver()->wpcl... | [
"public",
"function",
"get",
"(",
"$",
"id",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"wpcli_args",
"=",
"buildCLIArgs",
"(",
"array",
"(",
"'field'",
",",
"'fields'",
",",
")",
",",
"$",
"args",
")",
";",
"array_unshift",
"(",
"$",
"wpcli_a... | Retrieve an item for this element.
@param int|string $id Object ID.
@param array $args Optional data used to fetch an object.
@throws \UnexpectedValueException
@return mixed The item. | [
"Retrieve",
"an",
"item",
"for",
"this",
"element",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Driver/Element/Wpcli/TermElement.php#L48-L67 |
paulgibbs/behat-wordpress-extension | src/Context/WidgetContext.php | WidgetContext.iHaveTheMetaWidgetIn | public function iHaveTheMetaWidgetIn(string $widget_name, string $sidebar_name, TableNode $widget_settings)
{
$sidebar = $this->getWidgetSidebar($sidebar_name);
$keys = array_map('strtolower', $widget_settings->getRow(0));
$values = $widget_settings->getRow(1); // We only support one wi... | php | public function iHaveTheMetaWidgetIn(string $widget_name, string $sidebar_name, TableNode $widget_settings)
{
$sidebar = $this->getWidgetSidebar($sidebar_name);
$keys = array_map('strtolower', $widget_settings->getRow(0));
$values = $widget_settings->getRow(1); // We only support one wi... | [
"public",
"function",
"iHaveTheMetaWidgetIn",
"(",
"string",
"$",
"widget_name",
",",
"string",
"$",
"sidebar_name",
",",
"TableNode",
"$",
"widget_settings",
")",
"{",
"$",
"sidebar",
"=",
"$",
"this",
"->",
"getWidgetSidebar",
"(",
"$",
"sidebar_name",
")",
... | Adds a widget (identified by its ID base) to the sidebar (identified by it's human-readable name, e.g. 'Widget
Area', 'Right Sidebar', or 'Footer') with the given arguments.
Example: Given I have the "Meta" widget in "Widget Area
Example: Given I have the "RSS" widget in "Widget Area"
| Title | Url ... | [
"Adds",
"a",
"widget",
"(",
"identified",
"by",
"its",
"ID",
"base",
")",
"to",
"the",
"sidebar",
"(",
"identified",
"by",
"it",
"s",
"human",
"-",
"readable",
"name",
"e",
".",
"g",
".",
"Widget",
"Area",
"Right",
"Sidebar",
"or",
"Footer",
")",
"wi... | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/WidgetContext.php#L30-L38 |
paulgibbs/behat-wordpress-extension | src/Context/ContentContext.php | ContentContext.thereArePosts | public function thereArePosts(TableNode $posts)
{
foreach ($posts->getHash() as $post) {
$this->createContent($this->parseArgs($post));
}
} | php | public function thereArePosts(TableNode $posts)
{
foreach ($posts->getHash() as $post) {
$this->createContent($this->parseArgs($post));
}
} | [
"public",
"function",
"thereArePosts",
"(",
"TableNode",
"$",
"posts",
")",
"{",
"foreach",
"(",
"$",
"posts",
"->",
"getHash",
"(",
")",
"as",
"$",
"post",
")",
"{",
"$",
"this",
"->",
"createContent",
"(",
"$",
"this",
"->",
"parseArgs",
"(",
"$",
... | Create content of the given type.
Example: Given there are posts:
| post_type | post_title | post_content | post_status |
| page | Test Post | Hello World | publish |
@Given /^(?:there are|there is a) posts?:/
@param TableNode $posts | [
"Create",
"content",
"of",
"the",
"given",
"type",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/ContentContext.php#L29-L34 |
paulgibbs/behat-wordpress-extension | src/Context/ContentContext.php | ContentContext.iAmViewingBlogPost | public function iAmViewingBlogPost($post_data_or_title)
{
// Retrieve the first row only.
if ($post_data_or_title instanceof TableNode) {
$post_data_hash = $post_data_or_title->getHash();
if (count($post_data_hash) > 1) {
throw new UnexpectedValueException('[... | php | public function iAmViewingBlogPost($post_data_or_title)
{
// Retrieve the first row only.
if ($post_data_or_title instanceof TableNode) {
$post_data_hash = $post_data_or_title->getHash();
if (count($post_data_hash) > 1) {
throw new UnexpectedValueException('[... | [
"public",
"function",
"iAmViewingBlogPost",
"(",
"$",
"post_data_or_title",
")",
"{",
"// Retrieve the first row only.",
"if",
"(",
"$",
"post_data_or_title",
"instanceof",
"TableNode",
")",
"{",
"$",
"post_data_hash",
"=",
"$",
"post_data_or_title",
"->",
"getHash",
... | Create content, and go to it in the browser.
Example: Given I am viewing a post:
| post_type | post_title | post_content | post_status |
| page | Test Post | Hello World | publish |
Example: Given I am viewing the post: "Test Post"
@Given /^(?:I am|they are) viewing (?:a|the)(?: blog)? post(?: "([^"]+)"|:... | [
"Create",
"content",
"and",
"go",
"to",
"it",
"in",
"the",
"browser",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/ContentContext.php#L50-L66 |
paulgibbs/behat-wordpress-extension | src/Context/ContentContext.php | ContentContext.iShouldNotBeAbleToViewThePost | public function iShouldNotBeAbleToViewThePost($post_title)
{
try {
$this->getContentFromTitle($post_title);
} catch (UnexpectedValueException $e) {
// This is expected to fail.
return;
}
throw new RuntimeException(sprintf('[W811] Content "%s" exis... | php | public function iShouldNotBeAbleToViewThePost($post_title)
{
try {
$this->getContentFromTitle($post_title);
} catch (UnexpectedValueException $e) {
// This is expected to fail.
return;
}
throw new RuntimeException(sprintf('[W811] Content "%s" exis... | [
"public",
"function",
"iShouldNotBeAbleToViewThePost",
"(",
"$",
"post_title",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getContentFromTitle",
"(",
"$",
"post_title",
")",
";",
"}",
"catch",
"(",
"UnexpectedValueException",
"$",
"e",
")",
"{",
"// This is expect... | @Then I should not be able to view the post :post_title
@throws RuntimeException | [
"@Then",
"I",
"should",
"not",
"be",
"able",
"to",
"view",
"the",
"post",
":",
"post_title"
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/Context/ContentContext.php#L100-L110 |
paulgibbs/behat-wordpress-extension | src/PageObject/Element/TinyMCEEditor.php | TinyMCEEditor.setMode | public function setMode(string $mode)
{
if (self::VISUAL === $mode) {
$this->find('css', '#content-tmce')->press();
} else {
$this->find('css', '#content-html')->press();
}
} | php | public function setMode(string $mode)
{
if (self::VISUAL === $mode) {
$this->find('css', '#content-tmce')->press();
} else {
$this->find('css', '#content-html')->press();
}
} | [
"public",
"function",
"setMode",
"(",
"string",
"$",
"mode",
")",
"{",
"if",
"(",
"self",
"::",
"VISUAL",
"===",
"$",
"mode",
")",
"{",
"$",
"this",
"->",
"find",
"(",
"'css'",
",",
"'#content-tmce'",
")",
"->",
"press",
"(",
")",
";",
"}",
"else",... | Sets the mode of the WYSIWYG editor.
@param string $mode VISUAL or TEXT. | [
"Sets",
"the",
"mode",
"of",
"the",
"WYSIWYG",
"editor",
"."
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/Element/TinyMCEEditor.php#L33-L40 |
paulgibbs/behat-wordpress-extension | src/PageObject/Element/TinyMCEEditor.php | TinyMCEEditor.setContent | public function setContent(string $content)
{
if (self::VISUAL === $this->getMode()) {
$this->getDriver()->switchToIFrame(self::$wysiwyg_iframe_id);
$this->getDriver()->executeScript(
';document.body.innerHTML = \'<p>' . addslashes(htmlspecialchars($content)) . '</p>\... | php | public function setContent(string $content)
{
if (self::VISUAL === $this->getMode()) {
$this->getDriver()->switchToIFrame(self::$wysiwyg_iframe_id);
$this->getDriver()->executeScript(
';document.body.innerHTML = \'<p>' . addslashes(htmlspecialchars($content)) . '</p>\... | [
"public",
"function",
"setContent",
"(",
"string",
"$",
"content",
")",
"{",
"if",
"(",
"self",
"::",
"VISUAL",
"===",
"$",
"this",
"->",
"getMode",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"switchToIFrame",
"(",
"self",
":... | Enter the given content into the WYSIWYG editor
@param string $content The content being entered | [
"Enter",
"the",
"given",
"content",
"into",
"the",
"WYSIWYG",
"editor"
] | train | https://github.com/paulgibbs/behat-wordpress-extension/blob/a5262e58510c8900ac165b91adb861adb8398774/src/PageObject/Element/TinyMCEEditor.php#L57-L68 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.