repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
lucatume/wp-browser | src/Codeception/Module/WPQueries.php | WPQueries.assertQueriesCountByAction | public function assertQueriesCountByAction($n, $action, $message = '')
{
$this->readQueries();
$message = $message ?: 'Failed asserting that ' . $n . ' queries were triggered by action [' . $action . ']';
$iterator = new ActionsQueriesFilter(new \ArrayIterator($this->filteredQueries), $action);
Assert::assertCount($n, iterator_to_array($iterator), $message);
} | php | public function assertQueriesCountByAction($n, $action, $message = '')
{
$this->readQueries();
$message = $message ?: 'Failed asserting that ' . $n . ' queries were triggered by action [' . $action . ']';
$iterator = new ActionsQueriesFilter(new \ArrayIterator($this->filteredQueries), $action);
Assert::assertCount($n, iterator_to_array($iterator), $message);
} | [
"public",
"function",
"assertQueriesCountByAction",
"(",
"$",
"n",
",",
"$",
"action",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"readQueries",
"(",
")",
";",
"$",
"message",
"=",
"$",
"message",
"?",
":",
"'Failed asserting that '",
"... | Asserts that n queries were made as a consequence of the specified action.
Queries generated by `setUp`, `tearDown` and `factory` methods are excluded by default.
@example
```php
add_action( 'edit_post', function($postId){
$count = get_option('acme_title_updates_count');
update_option('acme_title_updates_count', ++$count);
} );
wp_update_post(['ID' => $bookOneId, 'post_title' => 'One']);
wp_update_post(['ID' => $bookTwoId, 'post_title' => 'Two']);
wp_update_post(['ID' => $bookThreeId, 'post_title' => 'Three']);
$this->assertQueriesCountByAction(3, 'edit_post');
```
@param int $n The expected number of queries.
@param string $action The action name, e.g. 'init'.
@param string $message An optional message to override the default one. | [
"Asserts",
"that",
"n",
"queries",
"were",
"made",
"as",
"a",
"consequence",
"of",
"the",
"specified",
"action",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPQueries.php#L659-L665 | train |
lucatume/wp-browser | src/Codeception/Module/WPQueries.php | WPQueries.assertQueriesByStatementAndAction | public function assertQueriesByStatementAndAction($statement, $action, $message = '')
{
$this->readQueries();
$message = $message ?: 'Failed asserting that queries were triggered by action ['
. $action . '] containing statement [' . $statement . ']';
$iterator = new MainStatementQueriesFilter(new ActionsQueriesFilter(
new \ArrayIterator($this->filteredQueries),
$action
), $statement);
Assert::assertNotEmpty(iterator_to_array($iterator), $message);
} | php | public function assertQueriesByStatementAndAction($statement, $action, $message = '')
{
$this->readQueries();
$message = $message ?: 'Failed asserting that queries were triggered by action ['
. $action . '] containing statement [' . $statement . ']';
$iterator = new MainStatementQueriesFilter(new ActionsQueriesFilter(
new \ArrayIterator($this->filteredQueries),
$action
), $statement);
Assert::assertNotEmpty(iterator_to_array($iterator), $message);
} | [
"public",
"function",
"assertQueriesByStatementAndAction",
"(",
"$",
"statement",
",",
"$",
"action",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"readQueries",
"(",
")",
";",
"$",
"message",
"=",
"$",
"message",
"?",
":",
"'Failed asserti... | Asserts that at least one query was made as a consequence of the specified action containing the SQL query.
Queries generated by `setUp`, `tearDown` and `factory` methods are excluded by default.
@example
```php
add_action( 'edit_post', function($postId){
$count = get_option('acme_title_updates_count');
update_option('acme_title_updates_count', ++$count);
} );
wp_update_post(['ID' => $bookId, 'post_title' => 'New']);
$this->assertQueriesByStatementAndAction('UPDATE', 'edit_post');
```
@param string $statement A simple string the statement should start with or a valid regular expression.
Regular expressions must contain delimiters.
@param string $action The action name, e.g. 'init'.
@param string $message An optional message to override the default one. | [
"Asserts",
"that",
"at",
"least",
"one",
"query",
"was",
"made",
"as",
"a",
"consequence",
"of",
"the",
"specified",
"action",
"containing",
"the",
"SQL",
"query",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPQueries.php#L687-L697 | train |
lucatume/wp-browser | src/Codeception/Module/WPQueries.php | WPQueries.assertNotQueriesByStatementAndAction | public function assertNotQueriesByStatementAndAction($statement, $action, $message = '')
{
$message = $message ?: 'Failed asserting that no queries were triggered by action ['
. $action . '] containing statement [' . $statement . ']';
$this->assertQueriesCountByStatementAndAction(0, $statement, $action, $message);
} | php | public function assertNotQueriesByStatementAndAction($statement, $action, $message = '')
{
$message = $message ?: 'Failed asserting that no queries were triggered by action ['
. $action . '] containing statement [' . $statement . ']';
$this->assertQueriesCountByStatementAndAction(0, $statement, $action, $message);
} | [
"public",
"function",
"assertNotQueriesByStatementAndAction",
"(",
"$",
"statement",
",",
"$",
"action",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"message",
"=",
"$",
"message",
"?",
":",
"'Failed asserting that no queries were triggered by action ['",
".",
"... | Asserts that no queries were made as a consequence of the specified action containing the SQL query.
Queries generated by `setUp`, `tearDown` and `factory` methods are excluded by default.
@example
```php
add_action( 'edit_post', function($postId){
$count = get_option('acme_title_updates_count');
update_option('acme_title_updates_count', ++$count);
} );
wp_delete_post($bookId);
$this->assertNotQueriesByStatementAndAction('DELETE', 'delete_post');
```
@param string $statement A simple string the statement should start with or a valid regular expression.
Regular expressions must contain delimiters.
@param string $action The action name, e.g. 'init'.
@param string $message An optional message to override the default one. | [
"Asserts",
"that",
"no",
"queries",
"were",
"made",
"as",
"a",
"consequence",
"of",
"the",
"specified",
"action",
"containing",
"the",
"SQL",
"query",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPQueries.php#L719-L724 | train |
lucatume/wp-browser | src/Codeception/Module/WPQueries.php | WPQueries.assertQueriesCountByStatementAndAction | public function assertQueriesCountByStatementAndAction($n, $statement, $action, $message = '')
{
$this->readQueries();
$message = $message ?: 'Failed asserting that ' . $n . ' queries were triggered by action ['
. $action . '] containing statement [' . $statement . ']';
$iterator = new MainStatementQueriesFilter(new ActionsQueriesFilter(
new \ArrayIterator($this->filteredQueries),
$action
), $statement);
Assert::assertCount($n, iterator_to_array($iterator), $message);
} | php | public function assertQueriesCountByStatementAndAction($n, $statement, $action, $message = '')
{
$this->readQueries();
$message = $message ?: 'Failed asserting that ' . $n . ' queries were triggered by action ['
. $action . '] containing statement [' . $statement . ']';
$iterator = new MainStatementQueriesFilter(new ActionsQueriesFilter(
new \ArrayIterator($this->filteredQueries),
$action
), $statement);
Assert::assertCount($n, iterator_to_array($iterator), $message);
} | [
"public",
"function",
"assertQueriesCountByStatementAndAction",
"(",
"$",
"n",
",",
"$",
"statement",
",",
"$",
"action",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"readQueries",
"(",
")",
";",
"$",
"message",
"=",
"$",
"message",
"?",... | Asserts that n queries were made as a consequence of the specified action containing the specified SQL statement.
Queries generated by `setUp`, `tearDown` and `factory` methods are excluded by default.
@example
```php
add_action( 'edit_post', function($postId){
$count = get_option('acme_title_updates_count');
update_option('acme_title_updates_count', ++$count);
} );
wp_delete_post($bookOneId);
wp_delete_post($bookTwoId);
wp_update_post(['ID' => $bookThreeId, 'post_title' => 'New']);
$this->assertQueriesCountByStatementAndAction(2, 'DELETE', 'delete_post');
$this->assertQueriesCountByStatementAndAction(1, 'INSERT', 'edit_post');
```
@param int $n The expected number of queries.
@param string $statement A simple string the statement should start with or a valid regular expression.
Regular expressions must contain delimiters.
@param string $action The action name, e.g. 'init'.
@param string $message An optional message to override the default one. | [
"Asserts",
"that",
"n",
"queries",
"were",
"made",
"as",
"a",
"consequence",
"of",
"the",
"specified",
"action",
"containing",
"the",
"specified",
"SQL",
"statement",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPQueries.php#L750-L760 | train |
lucatume/wp-browser | src/Codeception/Module/WPQueries.php | WPQueries.assertQueriesByFilter | public function assertQueriesByFilter($filter, $message = '')
{
$this->readQueries();
$message = $message ? $message : 'Failed asserting that queries were triggered by filter [' . $filter . ']';
$iterator = new FiltersQueriesFilter(new \ArrayIterator($this->filteredQueries), $filter);
Assert::assertNotEmpty(iterator_to_array($iterator), $message);
} | php | public function assertQueriesByFilter($filter, $message = '')
{
$this->readQueries();
$message = $message ? $message : 'Failed asserting that queries were triggered by filter [' . $filter . ']';
$iterator = new FiltersQueriesFilter(new \ArrayIterator($this->filteredQueries), $filter);
Assert::assertNotEmpty(iterator_to_array($iterator), $message);
} | [
"public",
"function",
"assertQueriesByFilter",
"(",
"$",
"filter",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"readQueries",
"(",
")",
";",
"$",
"message",
"=",
"$",
"message",
"?",
"$",
"message",
":",
"'Failed asserting that queries were ... | Asserts that at least one query was made as a consequence of the specified filter.
Queries generated by `setUp`, `tearDown` and `factory` methods are excluded by default.
@example
```php
add_filter('the_title', function($title, $postId){
$post = get_post($postId);
if($post->post_type !== 'book'){
return $title;
}
$new = get_option('acme_new_prefix');
return "{$new} - " . $title;
});
$title = apply_filters('the_title', get_post($bookId)->post_title, $bookId);
$this->assertQueriesByFilter('the_title');
```
@param string $filter The filter name, e.g. 'posts_where'.
@param string $message An optional message to override the default one. | [
"Asserts",
"that",
"at",
"least",
"one",
"query",
"was",
"made",
"as",
"a",
"consequence",
"of",
"the",
"specified",
"filter",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPQueries.php#L784-L790 | train |
lucatume/wp-browser | src/Codeception/Module/WPQueries.php | WPQueries.assertNotQueriesByFilter | public function assertNotQueriesByFilter($filter, $message = '')
{
$message = $message ? $message : 'Failed asserting that no queries were triggered by filter [' . $filter . ']';
$this->assertQueriesCountByFilter(0, $filter, $message);
} | php | public function assertNotQueriesByFilter($filter, $message = '')
{
$message = $message ? $message : 'Failed asserting that no queries were triggered by filter [' . $filter . ']';
$this->assertQueriesCountByFilter(0, $filter, $message);
} | [
"public",
"function",
"assertNotQueriesByFilter",
"(",
"$",
"filter",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"message",
"=",
"$",
"message",
"?",
"$",
"message",
":",
"'Failed asserting that no queries were triggered by filter ['",
".",
"$",
"filter",
".",... | Asserts that no queries were made as a consequence of the specified filter.
Queries generated by `setUp`, `tearDown` and `factory` methods are excluded by default.
@example
```php
add_filter('the_title', function($title, $postId){
$post = get_post($postId);
if($post->post_type !== 'book'){
return $title;
}
$new = get_option('acme_new_prefix');
return "{$new} - " . $title;
});
$title = apply_filters('the_title', get_post($notABookId)->post_title, $notABookId);
$this->assertNotQueriesByFilter('the_title');
```
@param string $filter The filter name, e.g. 'posts_where'.
@param string $message An optional message to override the default one. | [
"Asserts",
"that",
"no",
"queries",
"were",
"made",
"as",
"a",
"consequence",
"of",
"the",
"specified",
"filter",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPQueries.php#L814-L818 | train |
lucatume/wp-browser | src/Codeception/Module/WPQueries.php | WPQueries.assertQueriesCountByFilter | public function assertQueriesCountByFilter($n, $filter, $message = '')
{
$this->readQueries();
$message = $message ?: 'Failed asserting that ' . $n . ' queries were triggered by filter [' . $filter . ']';
$iterator = new FiltersQueriesFilter(new \ArrayIterator($this->filteredQueries), $filter);
Assert::assertCount($n, iterator_to_array($iterator), $message);
} | php | public function assertQueriesCountByFilter($n, $filter, $message = '')
{
$this->readQueries();
$message = $message ?: 'Failed asserting that ' . $n . ' queries were triggered by filter [' . $filter . ']';
$iterator = new FiltersQueriesFilter(new \ArrayIterator($this->filteredQueries), $filter);
Assert::assertCount($n, iterator_to_array($iterator), $message);
} | [
"public",
"function",
"assertQueriesCountByFilter",
"(",
"$",
"n",
",",
"$",
"filter",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"readQueries",
"(",
")",
";",
"$",
"message",
"=",
"$",
"message",
"?",
":",
"'Failed asserting that '",
"... | Asserts that n queries were made as a consequence of the specified filter.
Queries generated by `setUp`, `tearDown` and `factory` methods are excluded by default.
@example
```php
add_filter('the_title', function($title, $postId){
$post = get_post($postId);
if($post->post_type !== 'book'){
return $title;
}
$new = get_option('acme_new_prefix');
return "{$new} - " . $title;
});
$title = apply_filters('the_title', get_post($bookOneId)->post_title, $bookOneId);
$title = apply_filters('the_title', get_post($notABookId)->post_title, $notABookId);
$title = apply_filters('the_title', get_post($bookTwoId)->post_title, $bookTwoId);
$this->assertQueriesCountByFilter(2, 'the_title');
```
@param int $n The expected number of queries.
@param string $filter The filter name, e.g. 'posts_where'.
@param string $message An optional message to override the default one. | [
"Asserts",
"that",
"n",
"queries",
"were",
"made",
"as",
"a",
"consequence",
"of",
"the",
"specified",
"filter",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPQueries.php#L845-L851 | train |
lucatume/wp-browser | src/Codeception/Module/WPQueries.php | WPQueries.assertQueriesByStatementAndFilter | public function assertQueriesByStatementAndFilter($statement, $filter, $message = '')
{
$this->readQueries();
$message = $message ?: 'Failed asserting that queries were triggered by filter ['
. $filter . '] containing statement [' . $statement . ']';
$iterator = new MainStatementQueriesFilter(new FiltersQueriesFilter(
new \ArrayIterator($this->filteredQueries),
$filter
), $statement);
Assert::assertNotEmpty(iterator_to_array($iterator), $message);
} | php | public function assertQueriesByStatementAndFilter($statement, $filter, $message = '')
{
$this->readQueries();
$message = $message ?: 'Failed asserting that queries were triggered by filter ['
. $filter . '] containing statement [' . $statement . ']';
$iterator = new MainStatementQueriesFilter(new FiltersQueriesFilter(
new \ArrayIterator($this->filteredQueries),
$filter
), $statement);
Assert::assertNotEmpty(iterator_to_array($iterator), $message);
} | [
"public",
"function",
"assertQueriesByStatementAndFilter",
"(",
"$",
"statement",
",",
"$",
"filter",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"readQueries",
"(",
")",
";",
"$",
"message",
"=",
"$",
"message",
"?",
":",
"'Failed asserti... | Asserts that at least one query was made as a consequence of the specified filter containing the SQL query.
Queries generated by `setUp`, `tearDown` and `factory` methods are excluded by default.
@example
```php
add_filter('the_title', function($title, $postId){
$post = get_post($postId);
if($post->post_type !== 'book'){
return $title;
}
$new = get_option('acme_new_prefix');
return "{$new} - " . $title;
});
$title = apply_filters('the_title', get_post($bookId)->post_title, $bookId);
$this->assertQueriesByStatementAndFilter('SELECT', 'the_title');
```
@param string $statement A simple string the statement should start with or a valid regular expression.
Regular expressions must contain delimiters.
@param string $filter The filter name, e.g. 'posts_where'.
@param string $message An optional message to override the default one. | [
"Asserts",
"that",
"at",
"least",
"one",
"query",
"was",
"made",
"as",
"a",
"consequence",
"of",
"the",
"specified",
"filter",
"containing",
"the",
"SQL",
"query",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPQueries.php#L877-L887 | train |
lucatume/wp-browser | src/Codeception/Module/WPQueries.php | WPQueries.assertNotQueriesByStatementAndFilter | public function assertNotQueriesByStatementAndFilter($statement, $filter, $message = '')
{
$message = $message ?: 'Failed asserting that no queries were triggered by filter ['
. $filter . '] containing statement [' . $statement . ']';
$this->assertQueriesCountByStatementAndFilter(0, $statement, $filter, $message);
} | php | public function assertNotQueriesByStatementAndFilter($statement, $filter, $message = '')
{
$message = $message ?: 'Failed asserting that no queries were triggered by filter ['
. $filter . '] containing statement [' . $statement . ']';
$this->assertQueriesCountByStatementAndFilter(0, $statement, $filter, $message);
} | [
"public",
"function",
"assertNotQueriesByStatementAndFilter",
"(",
"$",
"statement",
",",
"$",
"filter",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"message",
"=",
"$",
"message",
"?",
":",
"'Failed asserting that no queries were triggered by filter ['",
".",
"... | Asserts that no queries were made as a consequence of the specified filter containing the specified SQL query.
Queries generated by `setUp`, `tearDown` and `factory` methods are excluded by default.
@example
```php
add_filter('the_title', function($title, $postId){
$post = get_post($postId);
if($post->post_type !== 'book'){
return $title;
}
$new = get_option('acme_new_prefix');
return "{$new} - " . $title;
});
$title = apply_filters('the_title', get_post($notABookId)->post_title, $notABookId);
$this->assertNotQueriesByStatementAndFilter('SELECT', 'the_title');
```
@param string $statement A simple string the statement should start with or a valid regular expression.
Regular expressions must contain delimiters.
@param string $filter The filter name, e.g. 'posts_where'.
@param string $message An optional message to override the default one. | [
"Asserts",
"that",
"no",
"queries",
"were",
"made",
"as",
"a",
"consequence",
"of",
"the",
"specified",
"filter",
"containing",
"the",
"specified",
"SQL",
"query",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPQueries.php#L913-L918 | train |
lucatume/wp-browser | src/Codeception/Module/WPQueries.php | WPQueries.assertQueriesCountByStatementAndFilter | public function assertQueriesCountByStatementAndFilter($n, $statement, $filter, $message = '')
{
$this->readQueries();
$message = $message ?: 'Failed asserting that ' . $n . ' queries were triggered by filter ['
. $filter . '] containing statement [' . $statement . ']';
$iterator = new MainStatementQueriesFilter(new FiltersQueriesFilter(
new \ArrayIterator($this->filteredQueries),
$filter
), $statement);
Assert::assertCount($n, iterator_to_array($iterator), $message);
} | php | public function assertQueriesCountByStatementAndFilter($n, $statement, $filter, $message = '')
{
$this->readQueries();
$message = $message ?: 'Failed asserting that ' . $n . ' queries were triggered by filter ['
. $filter . '] containing statement [' . $statement . ']';
$iterator = new MainStatementQueriesFilter(new FiltersQueriesFilter(
new \ArrayIterator($this->filteredQueries),
$filter
), $statement);
Assert::assertCount($n, iterator_to_array($iterator), $message);
} | [
"public",
"function",
"assertQueriesCountByStatementAndFilter",
"(",
"$",
"n",
",",
"$",
"statement",
",",
"$",
"filter",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"readQueries",
"(",
")",
";",
"$",
"message",
"=",
"$",
"message",
"?",... | Asserts that n queries were made as a consequence of the specified filter containing the specified SQL statement.
Queries generated by `setUp`, `tearDown` and `factory` methods are excluded by default.
@example
```php
add_filter('the_title', function($title, $postId){
$post = get_post($postId);
if($post->post_type !== 'book'){
return $title;
}
$new = get_option('acme_new_prefix');
return "{$new} - " . $title;
});
// Warm up the cache.
$title = apply_filters('the_title', get_post($bookOneId)->post_title, $bookOneId);
// Cache is warmed up now.
$title = apply_filters('the_title', get_post($bookTwoId)->post_title, $bookTwoId);
$title = apply_filters('the_title', get_post($bookThreeId)->post_title, $bookThreeId);
$this->assertQueriesCountByStatementAndFilter(1, 'SELECT', 'the_title');
```
@param int $n The expected number of queries.
@param string $statement A simple string the statement should start with or a valid regular expression.
Regular expressions must contain delimiters.
@param string $filter The filter name, e.g. 'posts_where'.
@param string $message An optional message to override the default one. | [
"Asserts",
"that",
"n",
"queries",
"were",
"made",
"as",
"a",
"consequence",
"of",
"the",
"specified",
"filter",
"containing",
"the",
"specified",
"SQL",
"statement",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPQueries.php#L949-L959 | train |
lucatume/wp-browser | src/includes/mock-fs.php | WP_Filesystem_MockFS.abspath | function abspath( $path = false ) {
if ( ! $path )
$path = ABSPATH;
$folder = $this->find_folder( $path );
// Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
if ( ! $folder && $this->is_dir('/wp-includes') )
$folder = '/';
return $folder;
} | php | function abspath( $path = false ) {
if ( ! $path )
$path = ABSPATH;
$folder = $this->find_folder( $path );
// Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
if ( ! $folder && $this->is_dir('/wp-includes') )
$folder = '/';
return $folder;
} | [
"function",
"abspath",
"(",
"$",
"path",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"path",
")",
"$",
"path",
"=",
"ABSPATH",
";",
"$",
"folder",
"=",
"$",
"this",
"->",
"find_folder",
"(",
"$",
"path",
")",
";",
"// Perhaps the FTP folder is rooted ... | Copy of core's function, but accepts a path. | [
"Copy",
"of",
"core",
"s",
"function",
"but",
"accepts",
"a",
"path",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/includes/mock-fs.php#L23-L32 | train |
lucatume/wp-browser | src/includes/mock-fs.php | WP_Filesystem_MockFS.setfs | function setfs( $paths ) {
if ( ! is_array($paths) )
$paths = explode( "\n", $paths );
$paths = array_filter( array_map( 'trim', $paths ) );
foreach ( $paths as $path ) {
// Allow for comments
if ( '#' == $path[0] )
continue;
// Directories
if ( '/' == $path[ strlen($path) -1 ] )
$this->mkdir( $path );
else // Files (with dummy content for now)
$this->put_contents( $path, 'This is a test file' );
}
} | php | function setfs( $paths ) {
if ( ! is_array($paths) )
$paths = explode( "\n", $paths );
$paths = array_filter( array_map( 'trim', $paths ) );
foreach ( $paths as $path ) {
// Allow for comments
if ( '#' == $path[0] )
continue;
// Directories
if ( '/' == $path[ strlen($path) -1 ] )
$this->mkdir( $path );
else // Files (with dummy content for now)
$this->put_contents( $path, 'This is a test file' );
}
} | [
"function",
"setfs",
"(",
"$",
"paths",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"paths",
")",
")",
"$",
"paths",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"paths",
")",
";",
"$",
"paths",
"=",
"array_filter",
"(",
"array_map",
"(",
"'trim'"... | "Bulk Loads" a filesystem into the internal virtual filesystem | [
"Bulk",
"Loads",
"a",
"filesystem",
"into",
"the",
"internal",
"virtual",
"filesystem"
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/includes/mock-fs.php#L53-L71 | train |
lucatume/wp-browser | src/includes/mock-fs.php | WP_Filesystem_MockFS.locate_node | private function locate_node( $path ) {
return isset( $this->fs_map[ $path ] ) ? $this->fs_map[ $path ] : false;
} | php | private function locate_node( $path ) {
return isset( $this->fs_map[ $path ] ) ? $this->fs_map[ $path ] : false;
} | [
"private",
"function",
"locate_node",
"(",
"$",
"path",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"fs_map",
"[",
"$",
"path",
"]",
")",
"?",
"$",
"this",
"->",
"fs_map",
"[",
"$",
"path",
"]",
":",
"false",
";",
"}"
] | Locates a filesystem "node" | [
"Locates",
"a",
"filesystem",
"node"
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/includes/mock-fs.php#L76-L78 | train |
lucatume/wp-browser | src/includes/mock-fs.php | WP_Filesystem_MockFS.locate_parent_node | private function locate_parent_node( $path ) {
$dirname = str_replace( '\\', '/', dirname( $path ) );
return $this->locate_node( trailingslashit( $dirname ) );
} | php | private function locate_parent_node( $path ) {
$dirname = str_replace( '\\', '/', dirname( $path ) );
return $this->locate_node( trailingslashit( $dirname ) );
} | [
"private",
"function",
"locate_parent_node",
"(",
"$",
"path",
")",
"{",
"$",
"dirname",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"dirname",
"(",
"$",
"path",
")",
")",
";",
"return",
"$",
"this",
"->",
"locate_node",
"(",
"trailingslashit",
"... | Locates a filesystem node for the parent of the given item | [
"Locates",
"a",
"filesystem",
"node",
"for",
"the",
"parent",
"of",
"the",
"given",
"item"
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/includes/mock-fs.php#L83-L86 | train |
lucatume/wp-browser | src/includes/mock-fs.php | WP_Filesystem_MockFS.mkdir | function mkdir( $path, /* Optional args are ignored */ $chmod = false, $chown = false, $chgrp = false ) {
$path = trailingslashit( $path );
$parent_node = $this->locate_parent_node( $path );
if ( ! $parent_node ) {
$dirname = str_replace( '\\', '/', dirname( $path ) );
$this->mkdir( $dirname );
$parent_node = $this->locate_parent_node( $path );
if ( ! $parent_node )
return false;
}
$node = new MockFS_Directory_Node( $path );
$parent_node->children[ $node->name ] = $node;
$this->fs_map[ $path ] = $node;
return true;
} | php | function mkdir( $path, /* Optional args are ignored */ $chmod = false, $chown = false, $chgrp = false ) {
$path = trailingslashit( $path );
$parent_node = $this->locate_parent_node( $path );
if ( ! $parent_node ) {
$dirname = str_replace( '\\', '/', dirname( $path ) );
$this->mkdir( $dirname );
$parent_node = $this->locate_parent_node( $path );
if ( ! $parent_node )
return false;
}
$node = new MockFS_Directory_Node( $path );
$parent_node->children[ $node->name ] = $node;
$this->fs_map[ $path ] = $node;
return true;
} | [
"function",
"mkdir",
"(",
"$",
"path",
",",
"/* Optional args are ignored */",
"$",
"chmod",
"=",
"false",
",",
"$",
"chown",
"=",
"false",
",",
"$",
"chgrp",
"=",
"false",
")",
"{",
"$",
"path",
"=",
"trailingslashit",
"(",
"$",
"path",
")",
";",
"$",... | Here starteth the WP_Filesystem functions. | [
"Here",
"starteth",
"the",
"WP_Filesystem",
"functions",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/includes/mock-fs.php#L90-L108 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.ensureOptionalPaths | protected function ensureOptionalPaths($check = true)
{
$optionalPaths = [
'themes' => [
'mustExist' => true,
'default' => '/wp-content/themes',
],
'plugins' => [
'mustExist' => true,
'default' => '/wp-content/plugins',
],
'mu-plugins' => [
'mustExist' => false,
'default' => '/wp-content/mu-plugins',
],
'uploads' => [
'mustExist' => true,
'default' => '/wp-content/uploads',
],
];
$wpRoot = Utils::untrailslashit($this->config['wpRootFolder']);
foreach ($optionalPaths as $configKey => $info) {
if (empty($this->config[$configKey])) {
$path = $info['default'];
} else {
$path = $this->config[$configKey];
}
if (!is_dir($path) || ($configKey === 'mu-plugins' && !is_dir(dirname($path)))) {
$path = Utils::unleadslashit(str_replace($wpRoot, '', $path));
$absolutePath = $wpRoot . DIRECTORY_SEPARATOR . $path;
} else {
$absolutePath = $path;
}
if ($check) {
$mustExistAndIsNotDir = $info['mustExist'] && !is_dir($absolutePath);
if ($mustExistAndIsNotDir) {
if (!mkdir($absolutePath, 0777, true) && !is_dir($absolutePath)) {
throw new ModuleConfigException(
__CLASS__,
"The {$configKey} config path [{$path}] does not exist."
);
}
}
}
$this->config[$configKey] = Utils::untrailslashit($absolutePath) . DIRECTORY_SEPARATOR;
}
} | php | protected function ensureOptionalPaths($check = true)
{
$optionalPaths = [
'themes' => [
'mustExist' => true,
'default' => '/wp-content/themes',
],
'plugins' => [
'mustExist' => true,
'default' => '/wp-content/plugins',
],
'mu-plugins' => [
'mustExist' => false,
'default' => '/wp-content/mu-plugins',
],
'uploads' => [
'mustExist' => true,
'default' => '/wp-content/uploads',
],
];
$wpRoot = Utils::untrailslashit($this->config['wpRootFolder']);
foreach ($optionalPaths as $configKey => $info) {
if (empty($this->config[$configKey])) {
$path = $info['default'];
} else {
$path = $this->config[$configKey];
}
if (!is_dir($path) || ($configKey === 'mu-plugins' && !is_dir(dirname($path)))) {
$path = Utils::unleadslashit(str_replace($wpRoot, '', $path));
$absolutePath = $wpRoot . DIRECTORY_SEPARATOR . $path;
} else {
$absolutePath = $path;
}
if ($check) {
$mustExistAndIsNotDir = $info['mustExist'] && !is_dir($absolutePath);
if ($mustExistAndIsNotDir) {
if (!mkdir($absolutePath, 0777, true) && !is_dir($absolutePath)) {
throw new ModuleConfigException(
__CLASS__,
"The {$configKey} config path [{$path}] does not exist."
);
}
}
}
$this->config[$configKey] = Utils::untrailslashit($absolutePath) . DIRECTORY_SEPARATOR;
}
} | [
"protected",
"function",
"ensureOptionalPaths",
"(",
"$",
"check",
"=",
"true",
")",
"{",
"$",
"optionalPaths",
"=",
"[",
"'themes'",
"=>",
"[",
"'mustExist'",
"=>",
"true",
",",
"'default'",
"=>",
"'/wp-content/themes'",
",",
"]",
",",
"'plugins'",
"=>",
"[... | Sets and checks that the optional paths, if set, are actually valid.
@param bool $check Whether to check the paths for existence or not.
@throws \Codeception\Exception\ModuleConfigException If one of the paths does not exist. | [
"Sets",
"and",
"checks",
"that",
"the",
"optional",
"paths",
"if",
"set",
"are",
"actually",
"valid",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L59-L108 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.ensureWpRootFolder | protected function ensureWpRootFolder()
{
$wpRoot = $this->config['wpRootFolder'];
if (!is_dir($wpRoot)) {
$wpRoot = codecept_root_dir(Utils::unleadslashit($wpRoot));
}
$message = "[{$wpRoot}] is not a valid WordPress root folder.\n\nThe WordPress root folder is the one that "
. "contains the 'wp-load.php' file.";
if (!(is_dir($wpRoot) && is_readable($wpRoot) && is_writable($wpRoot))) {
throw new ModuleConfigException(__CLASS__, $message);
}
if (!file_exists($wpRoot . '/wp-load.php')) {
throw new ModuleConfigException(__CLASS__, $message);
}
$this->config['wpRootFolder'] = Utils::untrailslashit($wpRoot) . DIRECTORY_SEPARATOR;
} | php | protected function ensureWpRootFolder()
{
$wpRoot = $this->config['wpRootFolder'];
if (!is_dir($wpRoot)) {
$wpRoot = codecept_root_dir(Utils::unleadslashit($wpRoot));
}
$message = "[{$wpRoot}] is not a valid WordPress root folder.\n\nThe WordPress root folder is the one that "
. "contains the 'wp-load.php' file.";
if (!(is_dir($wpRoot) && is_readable($wpRoot) && is_writable($wpRoot))) {
throw new ModuleConfigException(__CLASS__, $message);
}
if (!file_exists($wpRoot . '/wp-load.php')) {
throw new ModuleConfigException(__CLASS__, $message);
}
$this->config['wpRootFolder'] = Utils::untrailslashit($wpRoot) . DIRECTORY_SEPARATOR;
} | [
"protected",
"function",
"ensureWpRootFolder",
"(",
")",
"{",
"$",
"wpRoot",
"=",
"$",
"this",
"->",
"config",
"[",
"'wpRootFolder'",
"]",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"wpRoot",
")",
")",
"{",
"$",
"wpRoot",
"=",
"codecept_root_dir",
"(",
"... | Checks the WordPress root folder exists and is a WordPress root folder.
@throws \Codeception\Exception\ModuleConfigException if the WordPress root folder does not exist
or is not a valid WordPress root folder. | [
"Checks",
"the",
"WordPress",
"root",
"folder",
"exists",
"and",
"is",
"a",
"WordPress",
"root",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L122-L142 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.amInUploadsPath | public function amInUploadsPath($path = null)
{
if (null === $path) {
$path = $this->config['uploads'];
} else {
$path = (string)$path;
if (is_dir($this->config['uploads'] . DIRECTORY_SEPARATOR . Utils::unleadslashit($path))) {
$path = $this->config['uploads'] . DIRECTORY_SEPARATOR . Utils::unleadslashit($path);
} else {
// time based?
$timestamp = is_numeric($path) ? $path : strtotime($path);
$path = implode(
DIRECTORY_SEPARATOR,
[
$this->config['uploads'],
date('Y', $timestamp),
date('m', $timestamp),
]
);
}
}
$this->amInPath($path);
} | php | public function amInUploadsPath($path = null)
{
if (null === $path) {
$path = $this->config['uploads'];
} else {
$path = (string)$path;
if (is_dir($this->config['uploads'] . DIRECTORY_SEPARATOR . Utils::unleadslashit($path))) {
$path = $this->config['uploads'] . DIRECTORY_SEPARATOR . Utils::unleadslashit($path);
} else {
// time based?
$timestamp = is_numeric($path) ? $path : strtotime($path);
$path = implode(
DIRECTORY_SEPARATOR,
[
$this->config['uploads'],
date('Y', $timestamp),
date('m', $timestamp),
]
);
}
}
$this->amInPath($path);
} | [
"public",
"function",
"amInUploadsPath",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"config",
"[",
"'uploads'",
"]",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"(",... | Enters, changing directory, to the uploads folder in the local filesystem.
@example
```php
$I->amInUploadsPath('/logs');
$I->seeFileFound('shop.log');
```
@param string $path The path, relative to the site uploads folder. | [
"Enters",
"changing",
"directory",
"to",
"the",
"uploads",
"folder",
"in",
"the",
"local",
"filesystem",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L176-L198 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.seeUploadedFileFound | public function seeUploadedFileFound($filename, $date = null)
{
$path = $this->getUploadsPath($filename, $date);
Assert::assertFileExists($path);
} | php | public function seeUploadedFileFound($filename, $date = null)
{
$path = $this->getUploadsPath($filename, $date);
Assert::assertFileExists($path);
} | [
"public",
"function",
"seeUploadedFileFound",
"(",
"$",
"filename",
",",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getUploadsPath",
"(",
"$",
"filename",
",",
"$",
"date",
")",
";",
"Assert",
"::",
"assertFileExists",
"(",... | Checks if file exists in the uploads folder.
The date argument can be a string compatible with `strtotime` or a Unix
timestamp that will be used to build the `Y/m` uploads subfolder path.
@example
```php
$I->seeUploadedFileFound('some-file.txt');
$I->seeUploadedFileFound('some-file.txt','today');
?>
```
@param string $filename The file path, relative to the uploads folder or the current folder.
@param string|int $date A string compatible with `strtotime` or a Unix timestamp. | [
"Checks",
"if",
"file",
"exists",
"in",
"the",
"uploads",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L216-L220 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.getUploadsPath | public function getUploadsPath($file = '', $date = null)
{
$dateFrag = $date !== null ?
$this->buildDateFrag($date)
: '';
$uploads = Utils::untrailslashit($this->config['uploads']);
$path = $file;
if (false === strpos($file, $uploads)) {
$path = implode(DIRECTORY_SEPARATOR, array_filter([
$uploads,
$dateFrag,
Utils::unleadslashit($file),
]));
}
return $path;
} | php | public function getUploadsPath($file = '', $date = null)
{
$dateFrag = $date !== null ?
$this->buildDateFrag($date)
: '';
$uploads = Utils::untrailslashit($this->config['uploads']);
$path = $file;
if (false === strpos($file, $uploads)) {
$path = implode(DIRECTORY_SEPARATOR, array_filter([
$uploads,
$dateFrag,
Utils::unleadslashit($file),
]));
}
return $path;
} | [
"public",
"function",
"getUploadsPath",
"(",
"$",
"file",
"=",
"''",
",",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"dateFrag",
"=",
"$",
"date",
"!==",
"null",
"?",
"$",
"this",
"->",
"buildDateFrag",
"(",
"$",
"date",
")",
":",
"''",
";",
"$",
"... | Returns the path to the specified uploads file of folder.
Not providing a value for `$file` and `$date` will return the uploads folder path.
@example
```php
$todaysPath = $I->getUploadsPath();
$lastWeek = $I->getUploadsPath('', '-1 week');
```
@param string $file The file path, relative to the uploads folder.
@param string|int $date A string compatible with `strtotime` or a Unix timestamp.
@return string The absolute path to an uploaded file. | [
"Returns",
"the",
"path",
"to",
"the",
"specified",
"uploads",
"file",
"of",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L238-L255 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.buildDateFrag | protected function buildDateFrag($date)
{
$timestamp = is_numeric($date) ? $date : strtotime($date);
$Y = date('Y', $timestamp);
$m = date('m', $timestamp);
$dateFrag = $Y . DIRECTORY_SEPARATOR . $m;
return $dateFrag;
} | php | protected function buildDateFrag($date)
{
$timestamp = is_numeric($date) ? $date : strtotime($date);
$Y = date('Y', $timestamp);
$m = date('m', $timestamp);
$dateFrag = $Y . DIRECTORY_SEPARATOR . $m;
return $dateFrag;
} | [
"protected",
"function",
"buildDateFrag",
"(",
"$",
"date",
")",
"{",
"$",
"timestamp",
"=",
"is_numeric",
"(",
"$",
"date",
")",
"?",
"$",
"date",
":",
"strtotime",
"(",
"$",
"date",
")",
";",
"$",
"Y",
"=",
"date",
"(",
"'Y'",
",",
"$",
"timestam... | Builds the additional path fragment depending on the date.
@param string|int $date A string compatible with `strtotime` or a Unix timestamp.
@return string The relative path with the date path appended, if needed. | [
"Builds",
"the",
"additional",
"path",
"fragment",
"depending",
"on",
"the",
"date",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L264-L272 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.dontSeeUploadedFileFound | public function dontSeeUploadedFileFound($file, $date = null)
{
Assert::assertFileNotExists($this->getUploadsPath($file, $date));
} | php | public function dontSeeUploadedFileFound($file, $date = null)
{
Assert::assertFileNotExists($this->getUploadsPath($file, $date));
} | [
"public",
"function",
"dontSeeUploadedFileFound",
"(",
"$",
"file",
",",
"$",
"date",
"=",
"null",
")",
"{",
"Assert",
"::",
"assertFileNotExists",
"(",
"$",
"this",
"->",
"getUploadsPath",
"(",
"$",
"file",
",",
"$",
"date",
")",
")",
";",
"}"
] | Checks thata a file does not exist in the uploads folder.
The date argument can be a string compatible with `strtotime` or a Unix
timestamp that will be used to build the `Y/m` uploads subfolder path.
@example
``` php
$I->dontSeeUploadedFileFound('some-file.txt');
$I->dontSeeUploadedFileFound('some-file.txt','today');
```
@param string $file The file path, relative to the uploads folder or the current folder.
@param string|int $date A string compatible with `strtotime` or a Unix timestamp. | [
"Checks",
"thata",
"a",
"file",
"does",
"not",
"exist",
"in",
"the",
"uploads",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L289-L292 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.seeInUploadedFile | public function seeInUploadedFile($file, $contents, $date = null)
{
Assert::assertStringEqualsFile(
$this->getUploadsPath(
$file,
$date
),
$contents
);
} | php | public function seeInUploadedFile($file, $contents, $date = null)
{
Assert::assertStringEqualsFile(
$this->getUploadsPath(
$file,
$date
),
$contents
);
} | [
"public",
"function",
"seeInUploadedFile",
"(",
"$",
"file",
",",
"$",
"contents",
",",
"$",
"date",
"=",
"null",
")",
"{",
"Assert",
"::",
"assertStringEqualsFile",
"(",
"$",
"this",
"->",
"getUploadsPath",
"(",
"$",
"file",
",",
"$",
"date",
")",
",",
... | Checks that a file in the uploads folder contains a string.
The date argument can be a string compatible with `strtotime` or a Unix
timestamp that will be used to build the `Y/m` uploads subfolder path.
@example
```php
$I->seeInUploadedFile('some-file.txt', 'foo');
$I->seeInUploadedFile('some-file.txt','foo', 'today');
```
@param string $file The file path, relative to the uploads folder or the current folder.
@param string $contents The expected file contents or part of them.
@param string|int $date A string compatible with `strtotime` or a Unix timestamp. | [
"Checks",
"that",
"a",
"file",
"in",
"the",
"uploads",
"folder",
"contains",
"a",
"string",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L310-L319 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.dontSeeInUploadedFile | public function dontSeeInUploadedFile($file, $contents, $date = null)
{
Assert::assertStringNotEqualsFile(
$this->getUploadsPath(
$file,
$date
),
$contents
);
} | php | public function dontSeeInUploadedFile($file, $contents, $date = null)
{
Assert::assertStringNotEqualsFile(
$this->getUploadsPath(
$file,
$date
),
$contents
);
} | [
"public",
"function",
"dontSeeInUploadedFile",
"(",
"$",
"file",
",",
"$",
"contents",
",",
"$",
"date",
"=",
"null",
")",
"{",
"Assert",
"::",
"assertStringNotEqualsFile",
"(",
"$",
"this",
"->",
"getUploadsPath",
"(",
"$",
"file",
",",
"$",
"date",
")",
... | Checks that a file in the uploads folder does contain a string.
The date argument can be a string compatible with `strtotime` or a Unix
timestamp that will be used to build the `Y/m` uploads subfolder path.
@example
```php
$I->dontSeeInUploadedFile('some-file.txt', 'foo');
$I->dontSeeInUploadedFile('some-file.txt','foo', 'today');
```
@param string $file The file path, relative to the uploads folder or the current folder.
@param string $contents The not expected file contents or part of them.
@param string|int $date A string compatible with `strtotime` or a Unix timestamp. | [
"Checks",
"that",
"a",
"file",
"in",
"the",
"uploads",
"folder",
"does",
"contain",
"a",
"string",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L337-L346 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.deleteUploadedDir | public function deleteUploadedDir($dir, $date = null)
{
$dir = $this->getUploadsPath($dir, $date);
$this->debug('Deleting folder ' . $dir);
$this->deleteDir($dir);
} | php | public function deleteUploadedDir($dir, $date = null)
{
$dir = $this->getUploadsPath($dir, $date);
$this->debug('Deleting folder ' . $dir);
$this->deleteDir($dir);
} | [
"public",
"function",
"deleteUploadedDir",
"(",
"$",
"dir",
",",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"getUploadsPath",
"(",
"$",
"dir",
",",
"$",
"date",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"'Deleting folder... | Deletes a dir in the uploads folder.
The date argument can be a string compatible with `strtotime` or a Unix
timestamp that will be used to build the `Y/m` uploads subfolder path.
@example
``` php
$I->deleteUploadedDir('folder');
$I->deleteUploadedDir('folder', 'today');
```
@param string $dir The path to the directory to delete, relative to the uploads folder.
@param string|int|\DateTime $date The date of the uploads to delete, will default to `now`. | [
"Deletes",
"a",
"dir",
"in",
"the",
"uploads",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L363-L368 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.deleteUploadedFile | public function deleteUploadedFile($file, $date = null)
{
$file = $this->getUploadsPath($file, $date);
$this->deleteFile($file);
} | php | public function deleteUploadedFile($file, $date = null)
{
$file = $this->getUploadsPath($file, $date);
$this->deleteFile($file);
} | [
"public",
"function",
"deleteUploadedFile",
"(",
"$",
"file",
",",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getUploadsPath",
"(",
"$",
"file",
",",
"$",
"date",
")",
";",
"$",
"this",
"->",
"deleteFile",
"(",
"$",
"... | Deletes a file in the uploads folder.
The date argument can be a string compatible with `strtotime` or a Unix
timestamp that will be used to build the `Y/m` uploads subfolder path.
@example
``` php
$I->deleteUploadedFile('some-file.txt');
$I->deleteUploadedFile('some-file.txt', 'today');
```
@param string $file The file path, relative to the uploads folder or the current folder.
@param string|int $date A string compatible with `strtotime` or a Unix timestamp. | [
"Deletes",
"a",
"file",
"in",
"the",
"uploads",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L385-L389 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.cleanUploadsDir | public function cleanUploadsDir($dir = null, $date = null)
{
$dir = null === $dir ? $this->config['uploads'] : $this->getUploadsPath(
$dir,
$date
);
$this->cleanDir($dir);
} | php | public function cleanUploadsDir($dir = null, $date = null)
{
$dir = null === $dir ? $this->config['uploads'] : $this->getUploadsPath(
$dir,
$date
);
$this->cleanDir($dir);
} | [
"public",
"function",
"cleanUploadsDir",
"(",
"$",
"dir",
"=",
"null",
",",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"dir",
"=",
"null",
"===",
"$",
"dir",
"?",
"$",
"this",
"->",
"config",
"[",
"'uploads'",
"]",
":",
"$",
"this",
"->",
"getUploads... | Clears a folder in the uploads folder.
The date argument can be a string compatible with `strtotime` or a Unix
timestamp that will be used to build the `Y/m` uploads subfolder path.
@example
``` php
$I->cleanUploadsDir('some/folder');
$I->cleanUploadsDir('some/folder', 'today');
```
@param string $dir The path to the directory to delete, relative to the uploads folder.
@param string|int|\DateTime $date The date of the uploads to delete, will default to `now`. | [
"Clears",
"a",
"folder",
"in",
"the",
"uploads",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L406-L413 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.copyDirToUploads | public function copyDirToUploads($src, $dst, $date = null)
{
$this->copyDir($src, $this->getUploadsPath($dst, $date));
} | php | public function copyDirToUploads($src, $dst, $date = null)
{
$this->copyDir($src, $this->getUploadsPath($dst, $date));
} | [
"public",
"function",
"copyDirToUploads",
"(",
"$",
"src",
",",
"$",
"dst",
",",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"copyDir",
"(",
"$",
"src",
",",
"$",
"this",
"->",
"getUploadsPath",
"(",
"$",
"dst",
",",
"$",
"date",
")",
... | Copies a folder to the uploads folder.
The date argument can be a string compatible with `strtotime` or a Unix
timestamp that will be used to build the `Y/m` uploads subfolder path.
@example
``` php
$I->copyDirToUploads(codecept_data_dir('foo'), 'uploadsFoo');
$I->copyDirToUploads(codecept_data_dir('foo'), 'uploadsFoo', 'today');
```
@param string $src The path to the source file, relative to the current uploads folder.
@param string $dst The path to the destination file, relative to the current uploads folder.
@param string|int|\DateTime $date The date of the uploads to delete, will default to `now`. | [
"Copies",
"a",
"folder",
"to",
"the",
"uploads",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L431-L434 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.writeToUploadedFile | public function writeToUploadedFile($filename, $data, $date = null)
{
$filename = $this->getUploadsPath($filename, $date);
$dir = dirname($filename);
if (!is_dir($dir)) {
if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new ModuleException(__CLASS__, "Could not create the [{$dir}] folder.");
}
$this->toClean[] = $dir;
}
if (file_put_contents($filename, $data) === false) {
throw new ModuleException(__CLASS__, "Could not write data to file[{$filename}].");
}
return $filename;
} | php | public function writeToUploadedFile($filename, $data, $date = null)
{
$filename = $this->getUploadsPath($filename, $date);
$dir = dirname($filename);
if (!is_dir($dir)) {
if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new ModuleException(__CLASS__, "Could not create the [{$dir}] folder.");
}
$this->toClean[] = $dir;
}
if (file_put_contents($filename, $data) === false) {
throw new ModuleException(__CLASS__, "Could not write data to file[{$filename}].");
}
return $filename;
} | [
"public",
"function",
"writeToUploadedFile",
"(",
"$",
"filename",
",",
"$",
"data",
",",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getUploadsPath",
"(",
"$",
"filename",
",",
"$",
"date",
")",
";",
"$",
"dir",
"="... | Writes a string to a file in the the uploads folder.
The date argument can be a string compatible with `strtotime` or a Unix
timestamp that will be used to build the `Y/m` uploads subfolder path.
@example
``` php
$I->writeToUploadedFile('some-file.txt', 'foo bar');
$I->writeToUploadedFile('some-file.txt', 'foo bar', 'today');
```
@param string $filename The path to the destination file, relative to the current uploads folder.
@param string $data The data to write to the file.
@param string|int|\DateTime $date The date of the uploads to delete, will default to `now`.
@return string The absolute path to the destination file.
@throws \Codeception\Exception\ModuleException If the destination folder could not be created or the destination
file could not be written. | [
"Writes",
"a",
"string",
"to",
"a",
"file",
"in",
"the",
"the",
"uploads",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L457-L474 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.openUploadedFile | public function openUploadedFile($filename, $date = null)
{
$this->openFile($this->getUploadsPath($filename, $date));
} | php | public function openUploadedFile($filename, $date = null)
{
$this->openFile($this->getUploadsPath($filename, $date));
} | [
"public",
"function",
"openUploadedFile",
"(",
"$",
"filename",
",",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"openFile",
"(",
"$",
"this",
"->",
"getUploadsPath",
"(",
"$",
"filename",
",",
"$",
"date",
")",
")",
";",
"}"
] | Opens a file in the the uploads folder.
The date argument can be a string compatible with `strtotime` or a Unix
timestamp that will be used to build the `Y/m` uploads subfolder path.
@example
``` php
$I->openUploadedFile('some-file.txt');
$I->openUploadedFile('some-file.txt', 'time');
```
@param string $filename The path to the file, relative to the current uploads folder.
@param string|int|\DateTime $date The date of the uploads to delete, will default to `now`. | [
"Opens",
"a",
"file",
"in",
"the",
"the",
"uploads",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L491-L494 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.amInPluginPath | public function amInPluginPath($path)
{
$this->amInPath($this->config['plugins'] . DIRECTORY_SEPARATOR . Utils::unleadslashit($path));
} | php | public function amInPluginPath($path)
{
$this->amInPath($this->config['plugins'] . DIRECTORY_SEPARATOR . Utils::unleadslashit($path));
} | [
"public",
"function",
"amInPluginPath",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"amInPath",
"(",
"$",
"this",
"->",
"config",
"[",
"'plugins'",
"]",
".",
"DIRECTORY_SEPARATOR",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"path",
")",
")",
";",
... | Sets the current working folder to a folder in a plugin.
@example
``` php
$I->amInPluginPath('my-plugin');
```
@param string $path The folder path, relative to the root uploads folder, to change to. | [
"Sets",
"the",
"current",
"working",
"folder",
"to",
"a",
"folder",
"in",
"a",
"plugin",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L506-L509 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.copyDirToPlugin | public function copyDirToPlugin($src, $pluginDst)
{
$this->copyDir(
$src,
$this->config['plugins'] . Utils::unleadslashit($pluginDst)
);
} | php | public function copyDirToPlugin($src, $pluginDst)
{
$this->copyDir(
$src,
$this->config['plugins'] . Utils::unleadslashit($pluginDst)
);
} | [
"public",
"function",
"copyDirToPlugin",
"(",
"$",
"src",
",",
"$",
"pluginDst",
")",
"{",
"$",
"this",
"->",
"copyDir",
"(",
"$",
"src",
",",
"$",
"this",
"->",
"config",
"[",
"'plugins'",
"]",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"pluginDst... | Copies a folder to a folder in a plugin.
@example
``` php
// Copy the 'foo' folder to the 'foo' folder in the plugin.
$I->copyDirToPlugin(codecept_data_dir('foo'), 'my-plugin/foo');
```
@param string $src The path to the source directory to copy.
@param string $pluginDst The destination path, relative to the plugins root folder. | [
"Copies",
"a",
"folder",
"to",
"a",
"folder",
"in",
"a",
"plugin",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L523-L529 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.writeToPluginFile | public function writeToPluginFile($file, $data)
{
$this->writeToFile(
$this->config['plugins'] . Utils::unleadslashit($file),
$data
);
} | php | public function writeToPluginFile($file, $data)
{
$this->writeToFile(
$this->config['plugins'] . Utils::unleadslashit($file),
$data
);
} | [
"public",
"function",
"writeToPluginFile",
"(",
"$",
"file",
",",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"writeToFile",
"(",
"$",
"this",
"->",
"config",
"[",
"'plugins'",
"]",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"file",
")",
",",
"$",
... | Writes a file in a plugin folder.
@example
``` php
$I->writeToPluginFile('my-plugin/some-file.txt', 'foo');
```
@param string $file The path to the file, relative to the plugins root folder.
@param string $data The data to write in the file. | [
"Writes",
"a",
"file",
"in",
"a",
"plugin",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L557-L563 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.seeInPluginFile | public function seeInPluginFile($file, $contents)
{
Assert::assertStringEqualsFile(
$this->config['plugins'] . Utils::unleadslashit($file),
$contents
);
} | php | public function seeInPluginFile($file, $contents)
{
Assert::assertStringEqualsFile(
$this->config['plugins'] . Utils::unleadslashit($file),
$contents
);
} | [
"public",
"function",
"seeInPluginFile",
"(",
"$",
"file",
",",
"$",
"contents",
")",
"{",
"Assert",
"::",
"assertStringEqualsFile",
"(",
"$",
"this",
"->",
"config",
"[",
"'plugins'",
"]",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"file",
")",
",",
... | Checks that a file in a plugin folder contains a string.
@example
``` php
$I->seeInPluginFile('my-plugin/some-file.txt', 'foo');
```
@param string $file The path to the file, relative to the plugins root folder.
@param string $contents The contents to check the file for. | [
"Checks",
"that",
"a",
"file",
"in",
"a",
"plugin",
"folder",
"contains",
"a",
"string",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L606-L612 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.dontSeeInPluginFile | public function dontSeeInPluginFile($file, $contents)
{
Assert::assertStringNotEqualsFile(
$this->config['plugins'] . Utils::unleadslashit($file),
$contents
);
} | php | public function dontSeeInPluginFile($file, $contents)
{
Assert::assertStringNotEqualsFile(
$this->config['plugins'] . Utils::unleadslashit($file),
$contents
);
} | [
"public",
"function",
"dontSeeInPluginFile",
"(",
"$",
"file",
",",
"$",
"contents",
")",
"{",
"Assert",
"::",
"assertStringNotEqualsFile",
"(",
"$",
"this",
"->",
"config",
"[",
"'plugins'",
"]",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"file",
")",
... | Checks that a file in a plugin folder does not contain a string.
@example
``` php
$I->dontSeeInPluginFile('my-plugin/some-file.txt', 'foo');
```
@param string $file The path to the file, relative to the plugins root folder.
@param string $contents The contents to check the file for. | [
"Checks",
"that",
"a",
"file",
"in",
"a",
"plugin",
"folder",
"does",
"not",
"contain",
"a",
"string",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L625-L631 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.amInThemePath | public function amInThemePath($path)
{
$this->amInPath($this->config['themes'] . DIRECTORY_SEPARATOR . Utils::unleadslashit($path));
} | php | public function amInThemePath($path)
{
$this->amInPath($this->config['themes'] . DIRECTORY_SEPARATOR . Utils::unleadslashit($path));
} | [
"public",
"function",
"amInThemePath",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"amInPath",
"(",
"$",
"this",
"->",
"config",
"[",
"'themes'",
"]",
".",
"DIRECTORY_SEPARATOR",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"path",
")",
")",
";",
... | Sets the current working folder to a folder in a theme.
@example
``` php
$I->amInThemePath('my-theme');
```
@param string $path The path to the theme folder, relative to themes root folder. | [
"Sets",
"the",
"current",
"working",
"folder",
"to",
"a",
"folder",
"in",
"a",
"theme",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L658-L661 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.copyDirToTheme | public function copyDirToTheme($src, $themeDst)
{
$this->copyDir(
$src,
$this->config['themes'] . Utils::unleadslashit($themeDst)
);
} | php | public function copyDirToTheme($src, $themeDst)
{
$this->copyDir(
$src,
$this->config['themes'] . Utils::unleadslashit($themeDst)
);
} | [
"public",
"function",
"copyDirToTheme",
"(",
"$",
"src",
",",
"$",
"themeDst",
")",
"{",
"$",
"this",
"->",
"copyDir",
"(",
"$",
"src",
",",
"$",
"this",
"->",
"config",
"[",
"'themes'",
"]",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"themeDst",
... | Copies a folder in a theme folder.
@example
``` php
$I->copyDirToTheme(codecept_data_dir('foo'), 'my-theme');
```
@param string $src The path to the source file.
@param string $themeDst The path to the destination folder, relative to the themes root folder. | [
"Copies",
"a",
"folder",
"in",
"a",
"theme",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L674-L680 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.writeToThemeFile | public function writeToThemeFile($file, $data)
{
$this->writeToFile(
$this->config['themes'] . Utils::unleadslashit($file),
$data
);
} | php | public function writeToThemeFile($file, $data)
{
$this->writeToFile(
$this->config['themes'] . Utils::unleadslashit($file),
$data
);
} | [
"public",
"function",
"writeToThemeFile",
"(",
"$",
"file",
",",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"writeToFile",
"(",
"$",
"this",
"->",
"config",
"[",
"'themes'",
"]",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"file",
")",
",",
"$",
"d... | Writes a string to a file in a theme folder.
@example
``` php
$I->writeToThemeFile('my-theme/some-file.txt', 'foo');
```
@param string $file The path to the file, relative to the themese root folder.
@param string $data The data to write to the file. | [
"Writes",
"a",
"string",
"to",
"a",
"file",
"in",
"a",
"theme",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L708-L714 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.amInMuPluginPath | public function amInMuPluginPath($path)
{
$this->amInPath($this->config['mu-plugins'] . DIRECTORY_SEPARATOR . Utils::unleadslashit($path));
} | php | public function amInMuPluginPath($path)
{
$this->amInPath($this->config['mu-plugins'] . DIRECTORY_SEPARATOR . Utils::unleadslashit($path));
} | [
"public",
"function",
"amInMuPluginPath",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"amInPath",
"(",
"$",
"this",
"->",
"config",
"[",
"'mu-plugins'",
"]",
".",
"DIRECTORY_SEPARATOR",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"path",
")",
")",
... | Sets the current working folder to a folder in a mu-plugin.
@example
``` php
$I->amInMuPluginPath('mu-plugin');
```
@param string $path The path to the folder, relative to the mu-plugins root folder. | [
"Sets",
"the",
"current",
"working",
"folder",
"to",
"a",
"folder",
"in",
"a",
"mu",
"-",
"plugin",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L811-L814 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.copyDirToMuPlugin | public function copyDirToMuPlugin($src, $pluginDst)
{
$this->copyDir(
$src,
$this->config['mu-plugins'] . Utils::unleadslashit($pluginDst)
);
} | php | public function copyDirToMuPlugin($src, $pluginDst)
{
$this->copyDir(
$src,
$this->config['mu-plugins'] . Utils::unleadslashit($pluginDst)
);
} | [
"public",
"function",
"copyDirToMuPlugin",
"(",
"$",
"src",
",",
"$",
"pluginDst",
")",
"{",
"$",
"this",
"->",
"copyDir",
"(",
"$",
"src",
",",
"$",
"this",
"->",
"config",
"[",
"'mu-plugins'",
"]",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"plug... | Copies a folder to a folder in a mu-plugin.
@example
``` php
$I->copyDirToMuPlugin(codecept_data_dir('foo'), 'mu-plugin/foo');
```
@param string $src The path to the source file to copy.
@param string $pluginDst The path to the destination folder, relative to the mu-plugins root folder. | [
"Copies",
"a",
"folder",
"to",
"a",
"folder",
"in",
"a",
"mu",
"-",
"plugin",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L827-L833 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.writeToMuPluginFile | public function writeToMuPluginFile($file, $data)
{
$this->writeToFile(
$this->config['mu-plugins'] . Utils::unleadslashit($file),
$data
);
} | php | public function writeToMuPluginFile($file, $data)
{
$this->writeToFile(
$this->config['mu-plugins'] . Utils::unleadslashit($file),
$data
);
} | [
"public",
"function",
"writeToMuPluginFile",
"(",
"$",
"file",
",",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"writeToFile",
"(",
"$",
"this",
"->",
"config",
"[",
"'mu-plugins'",
"]",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"file",
")",
",",
"$... | Writes a file in a mu-plugin folder.
@example
``` php
$I->writeToMuPluginFile('mu-plugin1/some-file.txt', 'foo');
```
@param string $file The path to the destination file, relative to the mu-plugins root folder.
@param string $data The data to write to the file. | [
"Writes",
"a",
"file",
"in",
"a",
"mu",
"-",
"plugin",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L861-L867 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.havePlugin | public function havePlugin($path, $code)
{
$fullPath = $this->config['plugins'] . Utils::unleadslashit($path);
$dir = dirname($fullPath);
if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new ModuleException(
__CLASS__,
"Could not create [{$dir}] plugin folder."
);
}
$slug = basename(dirname($path));
$code = $this->removeOpeningPhpTag($code);
$name = $slug;
$contents = <<<PHP
<?php
/*
Plugin Name: $name
Description: $name
*/
$code
PHP;
$put = file_put_contents($fullPath, $contents);
if (!$put) {
throw new ModuleException(
__CLASS__,
"Could not create [{$fullPath}] plugin file."
);
}
$this->toClean[] = $dir;
} | php | public function havePlugin($path, $code)
{
$fullPath = $this->config['plugins'] . Utils::unleadslashit($path);
$dir = dirname($fullPath);
if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new ModuleException(
__CLASS__,
"Could not create [{$dir}] plugin folder."
);
}
$slug = basename(dirname($path));
$code = $this->removeOpeningPhpTag($code);
$name = $slug;
$contents = <<<PHP
<?php
/*
Plugin Name: $name
Description: $name
*/
$code
PHP;
$put = file_put_contents($fullPath, $contents);
if (!$put) {
throw new ModuleException(
__CLASS__,
"Could not create [{$fullPath}] plugin file."
);
}
$this->toClean[] = $dir;
} | [
"public",
"function",
"havePlugin",
"(",
"$",
"path",
",",
"$",
"code",
")",
"{",
"$",
"fullPath",
"=",
"$",
"this",
"->",
"config",
"[",
"'plugins'",
"]",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"path",
")",
";",
"$",
"dir",
"=",
"dirname",
... | Creates a plugin file, including plugin header, in the plugins folder.
The plugin is just created and not activated; the code can not contain the opening '<?php' tag.
@example
``` php
$code = 'echo "Hello world!"';
$I->havePlugin('foo/plugin.php', $code);
// Load the code from a file.
$code = file_get_contents(codecept_data_dir('code/plugin.php'));
$I->havePlugin('foo/plugin.php', $code);
```
@param string $path The path to the file to create, relative to the plugins folder.
@param string $code The content of the plugin file with or without the opening PHP tag.
@throws \Codeception\Exception\ModuleException If the plugin folder and/or files could not be created. | [
"Creates",
"a",
"plugin",
"file",
"including",
"plugin",
"header",
"in",
"the",
"plugins",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L972-L1005 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.haveMuPlugin | public function haveMuPlugin($filename, $code)
{
$fullPath = $this->config['mu-plugins'] . Utils::unleadslashit($filename);
$dir = dirname($fullPath);
if (!file_exists($dir)) {
if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new ModuleException(
__CLASS__,
"Could not create [{$dir}] mu-plugin folder."
);
}
$this->toClean[] = $dir;
}
$code = $this->removeOpeningPhpTag($code);
$name = 'Test mu-plugin ' . ++$this->testPluginCount;
$contents = <<<PHP
<?php
/*
Plugin Name: $name
Description: $name
*/
$code
PHP;
$put = file_put_contents($fullPath, $contents);
if (!$put) {
throw new ModuleException(
__CLASS__,
"Could not create [{$fullPath}] mu-plugin file."
);
}
$this->toClean[] = $fullPath;
} | php | public function haveMuPlugin($filename, $code)
{
$fullPath = $this->config['mu-plugins'] . Utils::unleadslashit($filename);
$dir = dirname($fullPath);
if (!file_exists($dir)) {
if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new ModuleException(
__CLASS__,
"Could not create [{$dir}] mu-plugin folder."
);
}
$this->toClean[] = $dir;
}
$code = $this->removeOpeningPhpTag($code);
$name = 'Test mu-plugin ' . ++$this->testPluginCount;
$contents = <<<PHP
<?php
/*
Plugin Name: $name
Description: $name
*/
$code
PHP;
$put = file_put_contents($fullPath, $contents);
if (!$put) {
throw new ModuleException(
__CLASS__,
"Could not create [{$fullPath}] mu-plugin file."
);
}
$this->toClean[] = $fullPath;
} | [
"public",
"function",
"haveMuPlugin",
"(",
"$",
"filename",
",",
"$",
"code",
")",
"{",
"$",
"fullPath",
"=",
"$",
"this",
"->",
"config",
"[",
"'mu-plugins'",
"]",
".",
"Utils",
"::",
"unleadslashit",
"(",
"$",
"filename",
")",
";",
"$",
"dir",
"=",
... | Creates a mu-plugin file, including plugin header, in the mu-plugins folder.
The code can not contain the opening '<?php' tag.
@example
``` php
$code = 'echo "Hello world!"';
$I->haveMuPlugin('foo-mu-plugin.php', $code);
// Load the code from a file.
$code = file_get_contents(codecept_data_dir('code/mu-plugin.php'));
$I->haveMuPlugin('foo-mu-plugin.php', $code);
```
@param string $filename The path to the file to create, relative to the plugins root folder.
@param string $code The content of the plugin file with or without the opening PHP tag.
@throws \Codeception\Exception\ModuleException If the mu-plugin folder and/or files could not be created. | [
"Creates",
"a",
"mu",
"-",
"plugin",
"file",
"including",
"plugin",
"header",
"in",
"the",
"mu",
"-",
"plugins",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L1026-L1064 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.haveTheme | public function haveTheme(
$folder,
$indexFileCode,
$functionsFileCode = null
) {
$dir = $this->config['themes'] . Utils::untrailslashit(Utils::unleadslashit($folder));
$styleFile = $dir . DIRECTORY_SEPARATOR . 'style.css';
$indexFile = $dir . DIRECTORY_SEPARATOR . 'index.php';
$functionsFile = $dir . DIRECTORY_SEPARATOR . 'functions.php';
if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new ModuleException(
__CLASS__,
"Could not create [{$dir}] theme folder."
);
}
$indexFileCode = $this->removeOpeningPhpTag($indexFileCode);
$functionsFileCode = $this->removeOpeningPhpTag($functionsFileCode);
$name = $folder;
$style = <<<CSS
/*
Theme Name: $name
Author: wp-browser
Description: $name
Version: 1.0
*/
CSS;
$stylePut = file_put_contents($styleFile, $style);
if (!$stylePut) {
throw new ModuleException(
__CLASS__,
"Could not create [{$styleFile}] theme file."
);
}
$this->toClean[] = $dir;
$index = '<?php ' . $indexFileCode;
$indexPut = file_put_contents($indexFile, $index);
if (!$indexPut) {
throw new ModuleException(
__CLASS__,
"Could not create [{$indexFile}] theme file."
);
}
if (null !== $functionsFileCode) {
$functions = '<?php ' . $functionsFileCode;
$functionsPut = file_put_contents($functionsFile, $functions);
if (!$functionsPut) {
throw new ModuleException(
__CLASS__,
"Could not create [{$indexFile}] theme file."
);
}
}
} | php | public function haveTheme(
$folder,
$indexFileCode,
$functionsFileCode = null
) {
$dir = $this->config['themes'] . Utils::untrailslashit(Utils::unleadslashit($folder));
$styleFile = $dir . DIRECTORY_SEPARATOR . 'style.css';
$indexFile = $dir . DIRECTORY_SEPARATOR . 'index.php';
$functionsFile = $dir . DIRECTORY_SEPARATOR . 'functions.php';
if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new ModuleException(
__CLASS__,
"Could not create [{$dir}] theme folder."
);
}
$indexFileCode = $this->removeOpeningPhpTag($indexFileCode);
$functionsFileCode = $this->removeOpeningPhpTag($functionsFileCode);
$name = $folder;
$style = <<<CSS
/*
Theme Name: $name
Author: wp-browser
Description: $name
Version: 1.0
*/
CSS;
$stylePut = file_put_contents($styleFile, $style);
if (!$stylePut) {
throw new ModuleException(
__CLASS__,
"Could not create [{$styleFile}] theme file."
);
}
$this->toClean[] = $dir;
$index = '<?php ' . $indexFileCode;
$indexPut = file_put_contents($indexFile, $index);
if (!$indexPut) {
throw new ModuleException(
__CLASS__,
"Could not create [{$indexFile}] theme file."
);
}
if (null !== $functionsFileCode) {
$functions = '<?php ' . $functionsFileCode;
$functionsPut = file_put_contents($functionsFile, $functions);
if (!$functionsPut) {
throw new ModuleException(
__CLASS__,
"Could not create [{$indexFile}] theme file."
);
}
}
} | [
"public",
"function",
"haveTheme",
"(",
"$",
"folder",
",",
"$",
"indexFileCode",
",",
"$",
"functionsFileCode",
"=",
"null",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"config",
"[",
"'themes'",
"]",
".",
"Utils",
"::",
"untrailslashit",
"(",
"Utils"... | Creates a theme file structure, including theme style file and index, in the themes folder.
The theme is just created and not activated; the code can not contain the opening '<?php' tag.
@example
``` php
$code = 'sayHi();';
$functionsCode = 'function sayHi(){echo "Hello world";};';
$I->haveTheme('foo', $indexCode, $functionsCode);
// Load the code from a file.
$indexCode = file_get_contents(codecept_data_dir('code/index.php'));
$functionsCode = file_get_contents(codecept_data_dir('code/functions.php'));
$I->haveTheme('foo', $indexCode, $functionsCode);
```
@param string $folder The path to the theme to create, relative to the themes root folder.
@param string $indexFileCode The content of the theme index.php file with or without the opening PHP tag.
@param string $functionsFileCode The content of the theme functions.php file with or without the opening PHP tag.
@throws \Codeception\Exception\ModuleException If the mu-plugin folder and/or files could not be created. | [
"Creates",
"a",
"theme",
"file",
"structure",
"including",
"theme",
"style",
"file",
"and",
"index",
"in",
"the",
"themes",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L1088-L1149 | train |
lucatume/wp-browser | src/Codeception/Module/WPFilesystem.php | WPFilesystem.makeUploadsDir | public function makeUploadsDir($path)
{
$path = $this->getUploadsPath($path);
if (is_dir($path)) {
$this->debug("Uploads folder '{$path}' already exists.");
return $path;
}
try {
if (!mkdir($path, 0777, true) && !is_dir($path)) {
throw new ModuleException($this, sprintf('Could not create uploads folder "%s"', $path));
}
} catch (ModuleException $e) {
throw $e;
} catch (\Exception $e) {
throw new ModuleException($this, sprintf(
"Could not create uploads folder '%s'\nreason: %s\nuser: %s",
$path,
$e->getMessage(),
get_current_user()
));
}
$this->debug("Created uploads folder '{$path}'");
$this->toClean[] = $path;
return $path;
} | php | public function makeUploadsDir($path)
{
$path = $this->getUploadsPath($path);
if (is_dir($path)) {
$this->debug("Uploads folder '{$path}' already exists.");
return $path;
}
try {
if (!mkdir($path, 0777, true) && !is_dir($path)) {
throw new ModuleException($this, sprintf('Could not create uploads folder "%s"', $path));
}
} catch (ModuleException $e) {
throw $e;
} catch (\Exception $e) {
throw new ModuleException($this, sprintf(
"Could not create uploads folder '%s'\nreason: %s\nuser: %s",
$path,
$e->getMessage(),
get_current_user()
));
}
$this->debug("Created uploads folder '{$path}'");
$this->toClean[] = $path;
return $path;
} | [
"public",
"function",
"makeUploadsDir",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getUploadsPath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"Uploads... | Creates an empty folder in the WordPress installation uploads folder.
@example
```php
$logsDir = $I->makeUploadsDir('logs/acme');
```
@param string $path The path, relative to the WordPress installation uploads folder, of the folder
to create.
@return string The absolute path to the created folder.
@throws \Codeception\Exception\ModuleException | [
"Creates",
"an",
"empty",
"folder",
"in",
"the",
"WordPress",
"installation",
"uploads",
"folder",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPFilesystem.php#L1220-L1248 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.importSqlDumpFile | public function importSqlDumpFile($dumpFile = null)
{
if ($dumpFile !== null) {
if (!file_exists($dumpFile) || !is_readable($dumpFile)) {
throw new \InvalidArgumentException("Dump file [{$dumpFile}] does not exist or is not readable.");
}
$this->driver->load($dumpFile);
return;
}
if ($this->config['populate']) {
$this->_cleanup();
$this->_loadDump();
$this->populated = true;
}
} | php | public function importSqlDumpFile($dumpFile = null)
{
if ($dumpFile !== null) {
if (!file_exists($dumpFile) || !is_readable($dumpFile)) {
throw new \InvalidArgumentException("Dump file [{$dumpFile}] does not exist or is not readable.");
}
$this->driver->load($dumpFile);
return;
}
if ($this->config['populate']) {
$this->_cleanup();
$this->_loadDump();
$this->populated = true;
}
} | [
"public",
"function",
"importSqlDumpFile",
"(",
"$",
"dumpFile",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"dumpFile",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dumpFile",
")",
"||",
"!",
"is_readable",
"(",
"$",
"dumpFile",
")",
... | Import the SQL dump file if populate is enabled.
@example
```php
// Import a dump file passing the absolute path.
$I->importSqlDumpFile(codecept_data_dir('dumps/start.sql'));
```
Specifying a dump file that file will be imported.
@param null|string $dumpFile The dump file that should be imported in place of the default one.
@throws \InvalidArgumentException If the specified file does not exist. | [
"Import",
"the",
"SQL",
"dump",
"file",
"if",
"populate",
"is",
"enabled",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L189-L206 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.dontSeeOptionInDatabase | public function dontSeeOptionInDatabase(array $criteria)
{
$tableName = $this->grabPrefixedTableNameFor('options');
if (!empty($criteria['option_value'])) {
$criteria['option_value'] = $this->maybeSerialize($criteria['option_value']);
}
$this->dontSeeInDatabase($tableName, $criteria);
} | php | public function dontSeeOptionInDatabase(array $criteria)
{
$tableName = $this->grabPrefixedTableNameFor('options');
if (!empty($criteria['option_value'])) {
$criteria['option_value'] = $this->maybeSerialize($criteria['option_value']);
}
$this->dontSeeInDatabase($tableName, $criteria);
} | [
"public",
"function",
"dontSeeOptionInDatabase",
"(",
"array",
"$",
"criteria",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
"'options'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"criteria",
"[",
"'option_value'",
... | Checks that an option is not in the database for the current blog.
If the value is an object or an array then the serialized option will be checked.
@example
```php
$I->dontHaveOptionInDatabase('posts_per_page');
$I->dontSeeOptionInDatabase('posts_per_page');
```
@param array $criteria An array of search criteria. | [
"Checks",
"that",
"an",
"option",
"is",
"not",
"in",
"the",
"database",
"for",
"the",
"current",
"blog",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L227-L234 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.grabPrefixedTableNameFor | public function grabPrefixedTableNameFor($tableName = '')
{
$idFrag = '';
if (!(in_array($tableName, $this->uniqueTables) || $this->blogId == 1)) {
$idFrag = empty($this->blogId) ? '' : "{$this->blogId}_";
}
$tableName = $this->config['tablePrefix'] . $idFrag . $tableName;
return $tableName;
} | php | public function grabPrefixedTableNameFor($tableName = '')
{
$idFrag = '';
if (!(in_array($tableName, $this->uniqueTables) || $this->blogId == 1)) {
$idFrag = empty($this->blogId) ? '' : "{$this->blogId}_";
}
$tableName = $this->config['tablePrefix'] . $idFrag . $tableName;
return $tableName;
} | [
"public",
"function",
"grabPrefixedTableNameFor",
"(",
"$",
"tableName",
"=",
"''",
")",
"{",
"$",
"idFrag",
"=",
"''",
";",
"if",
"(",
"!",
"(",
"in_array",
"(",
"$",
"tableName",
",",
"$",
"this",
"->",
"uniqueTables",
")",
"||",
"$",
"this",
"->",
... | Returns a prefixed table name for the current blog.
If the table is not one to be prefixed (e.g. `users`) then the proper table name will be returned.
@example
```php
// Will return wp_users.
$usersTable = $I->grabPrefixedTableNameFor('users');
// Will return wp_options.
$optionsTable = $I->grabPrefixedTableNameFor('options');
// Use a different blog and get its options table.
$I->useBlog(2);
$blogOptionsTable = $I->grabPrefixedTableNameFor('options');
```
@param string $tableName The table name, e.g. `options`.
@return string The prefixed table name, e.g. `wp_options` or `wp_2_options`. | [
"Returns",
"a",
"prefixed",
"table",
"name",
"for",
"the",
"current",
"blog",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L256-L266 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.seePostMetaInDatabase | public function seePostMetaInDatabase(array $criteria)
{
$tableName = $this->grabPrefixedTableNameFor('postmeta');
if (!empty($criteria['meta_value'])) {
$criteria['meta_value'] = $this->maybeSerialize($criteria['meta_value']);
}
$this->seeInDatabase($tableName, $criteria);
} | php | public function seePostMetaInDatabase(array $criteria)
{
$tableName = $this->grabPrefixedTableNameFor('postmeta');
if (!empty($criteria['meta_value'])) {
$criteria['meta_value'] = $this->maybeSerialize($criteria['meta_value']);
}
$this->seeInDatabase($tableName, $criteria);
} | [
"public",
"function",
"seePostMetaInDatabase",
"(",
"array",
"$",
"criteria",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
"'postmeta'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"criteria",
"[",
"'meta_value'",
"]"... | Checks for a post meta value in the database for the current blog.
If the `meta_value` is an object or an array then the check will be made for serialized values.
@example
```php
$postId = $I->havePostInDatabase(['meta_input' => ['foo' => 'bar']];
$I->seePostMetaInDatabase(['post_id' => '$postId', 'meta_key' => 'foo']);
```
@param array $criteria An array of search criteria. | [
"Checks",
"for",
"a",
"post",
"meta",
"value",
"in",
"the",
"database",
"for",
"the",
"current",
"blog",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L293-L300 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.dontSeePostMetaInDatabase | public function dontSeePostMetaInDatabase(array $criteria)
{
$tableName = $this->grabPrefixedTableNameFor('postmeta');
if (!empty($criteria['meta_value'])) {
$criteria['meta_value'] = $this->maybeSerialize($criteria['meta_value']);
}
$this->dontSeeInDatabase($tableName, $criteria);
} | php | public function dontSeePostMetaInDatabase(array $criteria)
{
$tableName = $this->grabPrefixedTableNameFor('postmeta');
if (!empty($criteria['meta_value'])) {
$criteria['meta_value'] = $this->maybeSerialize($criteria['meta_value']);
}
$this->dontSeeInDatabase($tableName, $criteria);
} | [
"public",
"function",
"dontSeePostMetaInDatabase",
"(",
"array",
"$",
"criteria",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
"'postmeta'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"criteria",
"[",
"'meta_value'",
... | Checks that a post meta value does not exist.
If the meta value is an object or an array then the check will be made on its serialized version.
@example
```php
$postId = $I->havePostInDatabase(['meta_input' => ['foo' => 'bar']]);
$I->dontSeePostMetaInDatabase(['post_id' => $postId, 'meta_key' => 'woot']);
```
@param array $criteria An array of search criteria. | [
"Checks",
"that",
"a",
"post",
"meta",
"value",
"does",
"not",
"exist",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L351-L358 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.seePostWithTermInDatabase | public function seePostWithTermInDatabase($post_id, $term_id, $term_order = 0)
{
$tableName = $this->grabPrefixedTableNameFor('term_relationships');
$this->dontSeeInDatabase($tableName, [
'object_id' => $post_id,
'term_id' => $term_id,
'term_order' => $term_order,
]);
} | php | public function seePostWithTermInDatabase($post_id, $term_id, $term_order = 0)
{
$tableName = $this->grabPrefixedTableNameFor('term_relationships');
$this->dontSeeInDatabase($tableName, [
'object_id' => $post_id,
'term_id' => $term_id,
'term_order' => $term_order,
]);
} | [
"public",
"function",
"seePostWithTermInDatabase",
"(",
"$",
"post_id",
",",
"$",
"term_id",
",",
"$",
"term_order",
"=",
"0",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
"'term_relationships'",
")",
";",
"$",
"this",
... | Checks that a post to term relation exists in the database.
The method will check the "term_relationships" table.
@example
```php
list($fiction) = $I->haveTermInDatabase('fiction', 'genre');
$postId = $I->havePostInDatabase(['tax_input' => ['genre' => [$fiction]]]);
$I->seePostWithTermInDatabase($postId, $fiction);
```
@param int $post_id The post ID.
@param int $term_id The term ID.
@param integer $term_order The order the term applies to the post, defaults to 0. | [
"Checks",
"that",
"a",
"post",
"to",
"term",
"relation",
"exists",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L376-L384 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.seeUserInDatabase | public function seeUserInDatabase(array $criteria)
{
$tableName = $this->grabPrefixedTableNameFor('users');
$allCriteria = $criteria;
if (!empty($criteria['user_pass'])) {
$userPass = $criteria['user_pass'];
unset($criteria['user_pass']);
$hashedPass = $this->grabFromDatabase($tableName, 'user_pass', $criteria);
$passwordOk = WpPassword::instance()->check($userPass, $hashedPass);
$this->assertTrue(
$passwordOk,
'No matching records found for criteria ' . json_encode($allCriteria) . ' in table ' . $tableName
);
}
$this->seeInDatabase($tableName, $criteria);
} | php | public function seeUserInDatabase(array $criteria)
{
$tableName = $this->grabPrefixedTableNameFor('users');
$allCriteria = $criteria;
if (!empty($criteria['user_pass'])) {
$userPass = $criteria['user_pass'];
unset($criteria['user_pass']);
$hashedPass = $this->grabFromDatabase($tableName, 'user_pass', $criteria);
$passwordOk = WpPassword::instance()->check($userPass, $hashedPass);
$this->assertTrue(
$passwordOk,
'No matching records found for criteria ' . json_encode($allCriteria) . ' in table ' . $tableName
);
}
$this->seeInDatabase($tableName, $criteria);
} | [
"public",
"function",
"seeUserInDatabase",
"(",
"array",
"$",
"criteria",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
"'users'",
")",
";",
"$",
"allCriteria",
"=",
"$",
"criteria",
";",
"if",
"(",
"!",
"empty",
"(",... | Checks that a user is in the database.
The method will check the "users" table.
@example
```php
$userId = $I->haveUserInDatabase(['])
```
@param array $criteria An array of search criteria. | [
"Checks",
"that",
"a",
"user",
"is",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L398-L413 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.dontSeeUserInDatabase | public function dontSeeUserInDatabase(array $criteria)
{
$tableName = $this->grabPrefixedTableNameFor('users');
$allCriteria = $criteria;
$passwordOk = false;
if (!empty($criteria['user_pass'])) {
$userPass = $criteria['user_pass'];
unset($criteria['user_pass']);
$hashedPass = $this->grabFromDatabase($tableName, 'user_pass', [$criteria]);
$passwordOk = WpPassword::instance()->check($userPass, $hashedPass);
}
$count = $this->countInDatabase($tableName, $criteria);
$this->assertTrue(
!$passwordOk && $count < 1,
'Unexpectedly found matching records for criteria ' . json_encode($allCriteria) . ' in table ' . $tableName
);
} | php | public function dontSeeUserInDatabase(array $criteria)
{
$tableName = $this->grabPrefixedTableNameFor('users');
$allCriteria = $criteria;
$passwordOk = false;
if (!empty($criteria['user_pass'])) {
$userPass = $criteria['user_pass'];
unset($criteria['user_pass']);
$hashedPass = $this->grabFromDatabase($tableName, 'user_pass', [$criteria]);
$passwordOk = WpPassword::instance()->check($userPass, $hashedPass);
}
$count = $this->countInDatabase($tableName, $criteria);
$this->assertTrue(
!$passwordOk && $count < 1,
'Unexpectedly found matching records for criteria ' . json_encode($allCriteria) . ' in table ' . $tableName
);
} | [
"public",
"function",
"dontSeeUserInDatabase",
"(",
"array",
"$",
"criteria",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
"'users'",
")",
";",
"$",
"allCriteria",
"=",
"$",
"criteria",
";",
"$",
"passwordOk",
"=",
"fa... | Checks that a user is not in the database.
@example
```php
// Asserts a user does not exist in the database.
$I->dontSeeUserInDatabase(['user_login' => 'luca']);
// Asserts a user with email and login is not in the database.
$I->dontSeeUserInDatabase(['user_login' => 'luca', 'user_email' => 'luca@theaveragedev.com']);
```
@param array $criteria An array of search criteria. | [
"Checks",
"that",
"a",
"user",
"is",
"not",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L428-L445 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.havePostInDatabase | public function havePostInDatabase(array $data = [])
{
$postTableName = $this->grabPostsTableName();
$idColumn = 'ID';
$id = $this->grabLatestEntryByFromDatabase($postTableName, $idColumn) + 1;
$post = Post::makePost($id, $this->config['url'], $data);
$hasMeta = !empty($data['meta']) || !empty($data['meta_input']);
$hasTerms = !empty($data['terms']) || !empty($data['tax_input']);
$meta = [];
if ($hasMeta) {
$meta = !empty($data['meta']) ? $data['meta'] : $data['meta_input'];
unset($post['meta']);
unset($post['meta_input']);
}
$terms = [];
if ($hasTerms) {
$terms = !empty($data['terms']) ? $data['terms'] : $data['tax_input'];
unset($post['terms']);
unset($post['tax_input']);
}
$postId = $this->haveInDatabase($postTableName, $post);
if ($hasMeta) {
foreach ($meta as $meta_key => $meta_value) {
$this->havePostmetaInDatabase($postId, $meta_key, $meta_value);
}
}
if ($hasTerms) {
foreach ($terms as $taxonomy => $termNames) {
foreach ($termNames as $termName) {
$termId = $this->grabTermIdFromDatabase(['name' => $termName]);
if (empty($termId)) {
$termId = $this->grabTermIdFromDatabase(['slug' => $termName]);
}
if (empty($termId)) {
$termIds = $this->haveTermInDatabase($termName, $taxonomy);
$termId = reset($termIds);
}
$termTaxonomyId = $this->grabTermTaxonomyIdFromDatabase([
'term_id' => $termId,
'taxonomy' => $taxonomy,
]);
$this->haveTermRelationshipInDatabase($postId, $termTaxonomyId);
$this->increaseTermCountBy($termTaxonomyId, 1);
}
}
}
return $postId;
} | php | public function havePostInDatabase(array $data = [])
{
$postTableName = $this->grabPostsTableName();
$idColumn = 'ID';
$id = $this->grabLatestEntryByFromDatabase($postTableName, $idColumn) + 1;
$post = Post::makePost($id, $this->config['url'], $data);
$hasMeta = !empty($data['meta']) || !empty($data['meta_input']);
$hasTerms = !empty($data['terms']) || !empty($data['tax_input']);
$meta = [];
if ($hasMeta) {
$meta = !empty($data['meta']) ? $data['meta'] : $data['meta_input'];
unset($post['meta']);
unset($post['meta_input']);
}
$terms = [];
if ($hasTerms) {
$terms = !empty($data['terms']) ? $data['terms'] : $data['tax_input'];
unset($post['terms']);
unset($post['tax_input']);
}
$postId = $this->haveInDatabase($postTableName, $post);
if ($hasMeta) {
foreach ($meta as $meta_key => $meta_value) {
$this->havePostmetaInDatabase($postId, $meta_key, $meta_value);
}
}
if ($hasTerms) {
foreach ($terms as $taxonomy => $termNames) {
foreach ($termNames as $termName) {
$termId = $this->grabTermIdFromDatabase(['name' => $termName]);
if (empty($termId)) {
$termId = $this->grabTermIdFromDatabase(['slug' => $termName]);
}
if (empty($termId)) {
$termIds = $this->haveTermInDatabase($termName, $taxonomy);
$termId = reset($termIds);
}
$termTaxonomyId = $this->grabTermTaxonomyIdFromDatabase([
'term_id' => $termId,
'taxonomy' => $taxonomy,
]);
$this->haveTermRelationshipInDatabase($postId, $termTaxonomyId);
$this->increaseTermCountBy($termTaxonomyId, 1);
}
}
}
return $postId;
} | [
"public",
"function",
"havePostInDatabase",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"postTableName",
"=",
"$",
"this",
"->",
"grabPostsTableName",
"(",
")",
";",
"$",
"idColumn",
"=",
"'ID'",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"... | Inserts a post in the database.
@example
```php
// Insert a post with random values in the database.
$randomPostId = $I->havePostInDatabase();
// Insert a post with specific values in the database.
$I->dontSeeOptionInDatabase([
'post_type' => 'book',
'post_title' => 'Alice in Wonderland',
'meta_input' => [
'readers_count' => 23
],
'tax_input' => [
'genre' => 'fiction'
]
]);
```
@param array $data An associative array of post data to override default and random generated values.
@return int post_id The inserted post ID. | [
"Inserts",
"a",
"post",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L495-L552 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.havePostmetaInDatabase | public function havePostmetaInDatabase($postId, $meta_key, $meta_value)
{
if (!is_int($postId)) {
throw new \BadMethodCallException('Post id must be an int', 1);
}
if (!is_string($meta_key)) {
throw new \BadMethodCallException('Meta key must be an string', 3);
}
$tableName = $this->grabPostMetaTableName();
return $this->haveInDatabase($tableName, [
'post_id' => $postId,
'meta_key' => $meta_key,
'meta_value' => $this->maybeSerialize($meta_value),
]);
} | php | public function havePostmetaInDatabase($postId, $meta_key, $meta_value)
{
if (!is_int($postId)) {
throw new \BadMethodCallException('Post id must be an int', 1);
}
if (!is_string($meta_key)) {
throw new \BadMethodCallException('Meta key must be an string', 3);
}
$tableName = $this->grabPostMetaTableName();
return $this->haveInDatabase($tableName, [
'post_id' => $postId,
'meta_key' => $meta_key,
'meta_value' => $this->maybeSerialize($meta_value),
]);
} | [
"public",
"function",
"havePostmetaInDatabase",
"(",
"$",
"postId",
",",
"$",
"meta_key",
",",
"$",
"meta_value",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"postId",
")",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'Post id must be an... | Adds one or more meta key and value couples in the database for a post.
@example
```php
// Set the post-meta for a post.
$I->havePostmetaInDatabase($postId, 'karma', 23);
// Set an array post-meta for a post, it will be serialized in the db.
$I->havePostmetaInDatabase($postId, 'data', ['one', 'two']);
// Use a loop to insert one meta per row.
foreach( ['one', 'two'] as $value){
$I->havePostmetaInDatabase($postId, 'data', $value);
}
```
@param int $postId The post ID.
@param string $meta_key The meta key.
@param mixed $meta_value The value to insert in the database, objects and arrays will be serialized.
@return int The inserted meta `meta_id`. | [
"Adds",
"one",
"or",
"more",
"meta",
"key",
"and",
"value",
"couples",
"in",
"the",
"database",
"for",
"a",
"post",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L619-L634 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveTermInDatabase | public function haveTermInDatabase($name, $taxonomy, array $overrides = [])
{
$termDefaults = ['slug' => (new Slugifier())->slugify($name), 'term_group' => 0];
$hasMeta = !empty($overrides['meta']);
$meta = [];
if ($hasMeta) {
$meta = $overrides['meta'];
unset($overrides['meta']);
}
$termData = array_merge($termDefaults, array_intersect_key($overrides, $termDefaults));
$termData['name'] = $name;
$term_id = $this->haveInDatabase($this->grabTermsTableName(), $termData);
$termTaxonomyDefaults = ['description' => '', 'parent' => 0, 'count' => 0];
$termTaxonomyData = array_merge($termTaxonomyDefaults, array_intersect_key($overrides, $termTaxonomyDefaults));
$termTaxonomyData['taxonomy'] = $taxonomy;
$termTaxonomyData['term_id'] = $term_id;
$term_taxonomy_id = $this->haveInDatabase($this->grabTermTaxonomyTableName(), $termTaxonomyData);
if ($hasMeta) {
foreach ($meta as $key => $value) {
$this->haveTermMetaInDatabase($term_id, $key, $value);
}
}
return [$term_id, $term_taxonomy_id];
} | php | public function haveTermInDatabase($name, $taxonomy, array $overrides = [])
{
$termDefaults = ['slug' => (new Slugifier())->slugify($name), 'term_group' => 0];
$hasMeta = !empty($overrides['meta']);
$meta = [];
if ($hasMeta) {
$meta = $overrides['meta'];
unset($overrides['meta']);
}
$termData = array_merge($termDefaults, array_intersect_key($overrides, $termDefaults));
$termData['name'] = $name;
$term_id = $this->haveInDatabase($this->grabTermsTableName(), $termData);
$termTaxonomyDefaults = ['description' => '', 'parent' => 0, 'count' => 0];
$termTaxonomyData = array_merge($termTaxonomyDefaults, array_intersect_key($overrides, $termTaxonomyDefaults));
$termTaxonomyData['taxonomy'] = $taxonomy;
$termTaxonomyData['term_id'] = $term_id;
$term_taxonomy_id = $this->haveInDatabase($this->grabTermTaxonomyTableName(), $termTaxonomyData);
if ($hasMeta) {
foreach ($meta as $key => $value) {
$this->haveTermMetaInDatabase($term_id, $key, $value);
}
}
return [$term_id, $term_taxonomy_id];
} | [
"public",
"function",
"haveTermInDatabase",
"(",
"$",
"name",
",",
"$",
"taxonomy",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
"{",
"$",
"termDefaults",
"=",
"[",
"'slug'",
"=>",
"(",
"new",
"Slugifier",
"(",
")",
")",
"->",
"slugify",
"(",
... | Inserts a term in the database.
@example
```php
// Insert a random 'genre' term in the database.
$I->haveTermInDatabase('non-fiction', 'genre');
// Insert a term in the database with term meta.
$I->haveTermInDatabase('fiction', 'genre', [
'slug' => 'genre--fiction',
'meta' => [
'readers_count' => 23
]
]);
```
@param string $name The term name, e.g. "Fuzzy".
@param string $taxonomy The term taxonomy
@param array $overrides An array of values to override the default ones.
@return array An array containing `term_id` and `term_taxonomy_id` of the inserted term. | [
"Inserts",
"a",
"term",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L719-L747 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveTermMetaInDatabase | public function haveTermMetaInDatabase($term_id, $meta_key, $meta_value)
{
if (!is_int($term_id)) {
throw new \BadMethodCallException('Term id must be an int');
}
if (!is_string($meta_key)) {
throw new \BadMethodCallException('Meta key must be an string');
}
$tableName = $this->grabTermMetaTableName();
return $this->haveInDatabase($tableName, [
'term_id' => $term_id,
'meta_key' => $meta_key,
'meta_value' => $this->maybeSerialize($meta_value),
]);
} | php | public function haveTermMetaInDatabase($term_id, $meta_key, $meta_value)
{
if (!is_int($term_id)) {
throw new \BadMethodCallException('Term id must be an int');
}
if (!is_string($meta_key)) {
throw new \BadMethodCallException('Meta key must be an string');
}
$tableName = $this->grabTermMetaTableName();
return $this->haveInDatabase($tableName, [
'term_id' => $term_id,
'meta_key' => $meta_key,
'meta_value' => $this->maybeSerialize($meta_value),
]);
} | [
"public",
"function",
"haveTermMetaInDatabase",
"(",
"$",
"term_id",
",",
"$",
"meta_key",
",",
"$",
"meta_value",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"term_id",
")",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'Term id must be ... | Inserts a term meta row in the database.
Objects and array meta values will be serialized.
@example
```php
$I->haveTermMetaInDatabase($fictionId, 'readers_count', 23);
// Insert some meta that will be serialized.
$I->haveTermMetaInDatabase($fictionId, 'flags', [3, 4, 89]);
// Use a loop to insert one meta per row.
foreach([3, 4, 89] as $value) {
$I->haveTermMetaInDatabase($fictionId, 'flag', $value);
}
```
@param int $term_id The ID of the term to insert the meta for.
@param string $meta_key The key of the meta to insert.
@param mixed $meta_value The value of the meta to insert, if serializable it will be serialized.
@return int The inserted term meta `meta_id`. | [
"Inserts",
"a",
"term",
"meta",
"row",
"in",
"the",
"database",
".",
"Objects",
"and",
"array",
"meta",
"values",
"will",
"be",
"serialized",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L789-L804 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveTermRelationshipInDatabase | public function haveTermRelationshipInDatabase($object_id, $term_taxonomy_id, $term_order = 0)
{
$this->haveInDatabase($this->grabTermRelationshipsTableName(), [
'object_id' => $object_id,
'term_taxonomy_id' => $term_taxonomy_id,
'term_order' => $term_order,
]);
} | php | public function haveTermRelationshipInDatabase($object_id, $term_taxonomy_id, $term_order = 0)
{
$this->haveInDatabase($this->grabTermRelationshipsTableName(), [
'object_id' => $object_id,
'term_taxonomy_id' => $term_taxonomy_id,
'term_order' => $term_order,
]);
} | [
"public",
"function",
"haveTermRelationshipInDatabase",
"(",
"$",
"object_id",
",",
"$",
"term_taxonomy_id",
",",
"$",
"term_order",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"haveInDatabase",
"(",
"$",
"this",
"->",
"grabTermRelationshipsTableName",
"(",
")",
",",... | Creates a term relationship in the database.
No check about the consistency of the insertion is made. E.g. a post could be assigned a term from
a taxonomy that's not registered for that post type.
@example
```php
// Assign the `fiction` term to a book.
$I->haveTermRelationshipInDatabase($bookId, $fictionId);
```
@param int $object_id A post ID, a user ID or anything that can be assigned a taxonomy term.
@param int $term_taxonomy_id The `term_taxonomy_id` of the term and taxonomy to create a relation with.
@param int $term_order Defaults to `0`. | [
"Creates",
"a",
"term",
"relationship",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L863-L870 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.dontHaveInDatabase | public function dontHaveInDatabase($table, array $criteria)
{
try {
$this->_getDriver()->deleteQueryByCriteria($table, $criteria);
} catch (\Exception $e) {
$this->debug("Couldn't delete record(s) from {$table} with criteria " . json_encode($criteria));
}
} | php | public function dontHaveInDatabase($table, array $criteria)
{
try {
$this->_getDriver()->deleteQueryByCriteria($table, $criteria);
} catch (\Exception $e) {
$this->debug("Couldn't delete record(s) from {$table} with criteria " . json_encode($criteria));
}
} | [
"public",
"function",
"dontHaveInDatabase",
"(",
"$",
"table",
",",
"array",
"$",
"criteria",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"_getDriver",
"(",
")",
"->",
"deleteQueryByCriteria",
"(",
"$",
"table",
",",
"$",
"criteria",
")",
";",
"}",
"catch",... | Deletes a database entry.
@example
```php
$I->dontHaveInDatabase('custom_table', ['book_ID' => 23, 'book_genre' => 'fiction']);
```
@param string $table The table name.
@param array $criteria An associative array of the column names and values to use as deletion criteria. | [
"Deletes",
"a",
"database",
"entry",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1116-L1123 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.grabUserMetaFromDatabase | public function grabUserMetaFromDatabase($userId, $meta_key)
{
$table = $this->grabPrefixedTableNameFor('usermeta');
$meta = $this->grabAllFromDatabase($table, 'meta_value', ['user_id' => $userId, 'meta_key' => $meta_key]);
if (empty($meta)) {
return [];
}
return array_column($meta, 'meta_value');
} | php | public function grabUserMetaFromDatabase($userId, $meta_key)
{
$table = $this->grabPrefixedTableNameFor('usermeta');
$meta = $this->grabAllFromDatabase($table, 'meta_value', ['user_id' => $userId, 'meta_key' => $meta_key]);
if (empty($meta)) {
return [];
}
return array_column($meta, 'meta_value');
} | [
"public",
"function",
"grabUserMetaFromDatabase",
"(",
"$",
"userId",
",",
"$",
"meta_key",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
"'usermeta'",
")",
";",
"$",
"meta",
"=",
"$",
"this",
"->",
"grabAllFromDatabase",
"... | Gets a user meta from the database.
@example
```php
// Returns a user 'karma' value.
$I->grabUserMetaFromDatabase($userId, 'karma');
// Returns an array, the unserialized version of the value stored in the database.
$I->grabUserMetaFromDatabase($userId, 'api_data');
```
@param int $userId The ID of th user to get the meta for.
@param string $meta_key The meta key to fetch the value for.
@return array An associative array of meta key/values.
@throws \Exception If the search criteria is incoherent. | [
"Gets",
"a",
"user",
"meta",
"from",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1200-L1209 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.grabAllFromDatabase | public function grabAllFromDatabase($table, $column, $criteria)
{
$query = $this->_getDriver()->select($column, $table, $criteria);
$sth = $this->_getDriver()->executeQuery($query, array_values($criteria));
return $sth->fetchAll(PDO::FETCH_ASSOC);
} | php | public function grabAllFromDatabase($table, $column, $criteria)
{
$query = $this->_getDriver()->select($column, $table, $criteria);
$sth = $this->_getDriver()->executeQuery($query, array_values($criteria));
return $sth->fetchAll(PDO::FETCH_ASSOC);
} | [
"public",
"function",
"grabAllFromDatabase",
"(",
"$",
"table",
",",
"$",
"column",
",",
"$",
"criteria",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"_getDriver",
"(",
")",
"->",
"select",
"(",
"$",
"column",
",",
"$",
"table",
",",
"$",
"criter... | Returns all entries matching a criteria from the database.
@example
```php
// Asserts a user does not exist in the database.
$I->dontSeeUserInDatabase(['user_login' => 'luca']);
// Asserts a user with email and login is not in the database.
$books = $I->grabPrefixedTableNameFor('books');
$I->grabAllFromDatabase($books, 'title', ['genre' => 'fiction']);
```
@param string $table The table to grab the values from.
@param string $column The column to fetch.
@param array $criteria The search criteria.
@return array An array of results.
@throws \Exception If the criteria is inconsistent. | [
"Returns",
"all",
"entries",
"matching",
"a",
"criteria",
"from",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1231-L1238 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveOptionInDatabase | public function haveOptionInDatabase($option_name, $option_value, $autoload = 'yes')
{
$table = $this->grabPrefixedTableNameFor('options');
$this->dontHaveInDatabase($table, ['option_name' => $option_name]);
$option_value = $this->maybeSerialize($option_value);
return $this->haveInDatabase($table, [
'option_name' => $option_name,
'option_value' => $option_value,
'autoload' => $autoload,
]);
} | php | public function haveOptionInDatabase($option_name, $option_value, $autoload = 'yes')
{
$table = $this->grabPrefixedTableNameFor('options');
$this->dontHaveInDatabase($table, ['option_name' => $option_name]);
$option_value = $this->maybeSerialize($option_value);
return $this->haveInDatabase($table, [
'option_name' => $option_name,
'option_value' => $option_value,
'autoload' => $autoload,
]);
} | [
"public",
"function",
"haveOptionInDatabase",
"(",
"$",
"option_name",
",",
"$",
"option_value",
",",
"$",
"autoload",
"=",
"'yes'",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
"'options'",
")",
";",
"$",
"this",
"->",
... | Inserts an option in the database.
@example
```php
$I->haveOptionInDatabase('posts_per_page, 23);
$I->haveOptionInDatabase('my_plugin_options', ['key_one' => 'value_one', 'key_two' => 89]);
```
If the option value is an object or an array then the value will be serialized.
@param string $option_name The option name.
@param mixed $option_value The option value; if an array or object it will be serialized.
@param string $autoload Wether the option should be autoloaded by WordPress or not.
@return int The inserted option `option_id` | [
"Inserts",
"an",
"option",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1280-L1291 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.dontHaveOptionInDatabase | public function dontHaveOptionInDatabase($key, $value = null)
{
$tableName = $this->grabPrefixedTableNameFor('options');
$criteria['option_name'] = $key;
if (!empty($value)) {
$criteria['option_value'] = $this->maybeUnserialize($value);
}
$this->dontHaveInDatabase($tableName, $criteria);
} | php | public function dontHaveOptionInDatabase($key, $value = null)
{
$tableName = $this->grabPrefixedTableNameFor('options');
$criteria['option_name'] = $key;
if (!empty($value)) {
$criteria['option_value'] = $this->maybeUnserialize($value);
}
$this->dontHaveInDatabase($tableName, $criteria);
} | [
"public",
"function",
"dontHaveOptionInDatabase",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
"'options'",
")",
";",
"$",
"criteria",
"[",
"'option_name'",
"]",
"=",
... | Removes an entry from the options table.
@example
```php
// Remove the `foo` option.
$I->dontHaveOptionInDatabase('foo');
// Remove the 'bar' option only if it has the `baz` value.
$I->dontHaveOptionInDatabase('bar', 'baz');
```
@param string $key The option name.
@param null|mixed $value If set the option will only be removed if its value matches the passed one. | [
"Removes",
"an",
"entry",
"from",
"the",
"options",
"table",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1323-L1332 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveSiteOptionInDatabase | public function haveSiteOptionInDatabase($key, $value)
{
$currentBlogId = $this->blogId;
$this->useMainBlog();
$option_id = $this->haveOptionInDatabase('_site_option_' . $key, $value);
$this->useBlog($currentBlogId);
return $option_id;
} | php | public function haveSiteOptionInDatabase($key, $value)
{
$currentBlogId = $this->blogId;
$this->useMainBlog();
$option_id = $this->haveOptionInDatabase('_site_option_' . $key, $value);
$this->useBlog($currentBlogId);
return $option_id;
} | [
"public",
"function",
"haveSiteOptionInDatabase",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"currentBlogId",
"=",
"$",
"this",
"->",
"blogId",
";",
"$",
"this",
"->",
"useMainBlog",
"(",
")",
";",
"$",
"option_id",
"=",
"$",
"this",
"->",
"hav... | Inserts a site option in the database.
If the value is an array or an object then the value will be serialized.
@example
```php
$fooCountOptionId = $I->haveSiteOptionInDatabase('foo_count','23');
```
@param string $key The name of the option to insert.
@param mixed $value The value ot insert for the option.
@return int The inserted option `option_id`. | [
"Inserts",
"a",
"site",
"option",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1349-L1357 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.useBlog | public function useBlog($blogId = 0)
{
if (!(is_numeric($blogId) && intval($blogId) === $blogId && intval($blogId) >= 0)) {
throw new \InvalidArgumentException('Id must be an integer greater than or equal to 0');
}
$this->blogId = intval($blogId);
} | php | public function useBlog($blogId = 0)
{
if (!(is_numeric($blogId) && intval($blogId) === $blogId && intval($blogId) >= 0)) {
throw new \InvalidArgumentException('Id must be an integer greater than or equal to 0');
}
$this->blogId = intval($blogId);
} | [
"public",
"function",
"useBlog",
"(",
"$",
"blogId",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"(",
"is_numeric",
"(",
"$",
"blogId",
")",
"&&",
"intval",
"(",
"$",
"blogId",
")",
"===",
"$",
"blogId",
"&&",
"intval",
"(",
"$",
"blogId",
")",
">=",
"0"... | Sets the blog to be used.
This has nothing to do with WordPress `switch_to_blog` function, this code will affect the table prefixes used.
@example
```php
// Switch to the blog with ID 23.
$I->useBlog(23);
// Switch back to the main blog.
$I->useMainBlog();
```
@param int $blogId The ID of the blog to use. | [
"Sets",
"the",
"blog",
"to",
"be",
"used",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1390-L1396 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.dontHaveSiteOptionInDatabase | public function dontHaveSiteOptionInDatabase($key, $value = null)
{
$currentBlogId = $this->blogId;
$this->useMainBlog();
$this->dontHaveOptionInDatabase('_site_option_' . $key, $value);
$this->useBlog($currentBlogId);
} | php | public function dontHaveSiteOptionInDatabase($key, $value = null)
{
$currentBlogId = $this->blogId;
$this->useMainBlog();
$this->dontHaveOptionInDatabase('_site_option_' . $key, $value);
$this->useBlog($currentBlogId);
} | [
"public",
"function",
"dontHaveSiteOptionInDatabase",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"currentBlogId",
"=",
"$",
"this",
"->",
"blogId",
";",
"$",
"this",
"->",
"useMainBlog",
"(",
")",
";",
"$",
"this",
"->",
"dontHaveOpt... | Removes a site option from the database.
@example
```php
// Remove the `foo_count` option.
$I->dontHaveSiteOptionInDatabase('foo_count');
// Remove the `foo_count` option only if its value is `23`.
$I->dontHaveSiteOptionInDatabase('foo_count', 23);
```
@param string $key The option name.
@param null|mixed $value If set the option will only be removed it its value matches the specified one. | [
"Removes",
"a",
"site",
"option",
"from",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1412-L1418 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.dontHaveSiteTransientInDatabase | public function dontHaveSiteTransientInDatabase($key)
{
$currentBlogId = $this->blogId;
$this->useMainBlog();
$this->dontHaveOptionInDatabase('_site_transient_' . $key);
$this->useBlog($currentBlogId);
} | php | public function dontHaveSiteTransientInDatabase($key)
{
$currentBlogId = $this->blogId;
$this->useMainBlog();
$this->dontHaveOptionInDatabase('_site_transient_' . $key);
$this->useBlog($currentBlogId);
} | [
"public",
"function",
"dontHaveSiteTransientInDatabase",
"(",
"$",
"key",
")",
"{",
"$",
"currentBlogId",
"=",
"$",
"this",
"->",
"blogId",
";",
"$",
"this",
"->",
"useMainBlog",
"(",
")",
";",
"$",
"this",
"->",
"dontHaveOptionInDatabase",
"(",
"'_site_transi... | Removes a site transient from the database.
@example
```php
$I->dontHaveSiteTransientInDatabase(['my_plugin_site_buffer']);
```
@param string $key The name of the transient to delete. | [
"Removes",
"a",
"site",
"transient",
"from",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1456-L1462 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.grabSiteOptionFromDatabase | public function grabSiteOptionFromDatabase($key)
{
$currentBlogId = $this->blogId;
$this->useMainBlog();
$value = $this->grabOptionFromDatabase('_site_option_' . $key);
$this->useBlog($currentBlogId);
return $value;
} | php | public function grabSiteOptionFromDatabase($key)
{
$currentBlogId = $this->blogId;
$this->useMainBlog();
$value = $this->grabOptionFromDatabase('_site_option_' . $key);
$this->useBlog($currentBlogId);
return $value;
} | [
"public",
"function",
"grabSiteOptionFromDatabase",
"(",
"$",
"key",
")",
"{",
"$",
"currentBlogId",
"=",
"$",
"this",
"->",
"blogId",
";",
"$",
"this",
"->",
"useMainBlog",
"(",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"grabOptionFromDatabase",
"("... | Gets a site option from the database.
@example
```php
$fooCountOptionId = $I->haveSiteOptionInDatabase('foo_count','23');
```
@param string $key The name of the option to read from the database.
@return mixed|string The value of the option stored in the database, if unserializable the value will be unserialized. | [
"Gets",
"a",
"site",
"option",
"from",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1476-L1484 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.grabOptionFromDatabase | public function grabOptionFromDatabase($option_name)
{
$table = $this->grabPrefixedTableNameFor('options');
$option_value = $this->grabFromDatabase($table, 'option_value', ['option_name' => $option_name]);
return empty($option_value) ? '' : $this->maybeUnserialize($option_value);
} | php | public function grabOptionFromDatabase($option_name)
{
$table = $this->grabPrefixedTableNameFor('options');
$option_value = $this->grabFromDatabase($table, 'option_value', ['option_name' => $option_name]);
return empty($option_value) ? '' : $this->maybeUnserialize($option_value);
} | [
"public",
"function",
"grabOptionFromDatabase",
"(",
"$",
"option_name",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
"'options'",
")",
";",
"$",
"option_value",
"=",
"$",
"this",
"->",
"grabFromDatabase",
"(",
"$",
"table",... | Gets an option value from the database.
@example
```php
$count = $I->grabOptionFromDatabase('foo_count');
```
@param string $option_name The name of the option to grab from the database.
@return mixed|string The option value. If the value is serialized it will be unserialized. | [
"Gets",
"an",
"option",
"value",
"from",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1498-L1504 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.seeOptionInDatabase | public function seeOptionInDatabase(array $criteria)
{
$tableName = $this->grabPrefixedTableNameFor('options');
if (!empty($criteria['option_value'])) {
$criteria['option_value'] = $this->maybeSerialize($criteria['option_value']);
}
$this->seeInDatabase($tableName, $criteria);
} | php | public function seeOptionInDatabase(array $criteria)
{
$tableName = $this->grabPrefixedTableNameFor('options');
if (!empty($criteria['option_value'])) {
$criteria['option_value'] = $this->maybeSerialize($criteria['option_value']);
}
$this->seeInDatabase($tableName, $criteria);
} | [
"public",
"function",
"seeOptionInDatabase",
"(",
"array",
"$",
"criteria",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
"'options'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"criteria",
"[",
"'option_value'",
"]",... | Checks if an option is in the database for the current blog.
If checking for an array or an object then the serialized version will be checked for.
@example
```php
// Checks an option is in the database.
$I->seeOptionInDatabase('tables_version');
// Checks an option is in the database and has a specific value.
$I->seeOptionInDatabase('tables_version', '1.0');
```
@param array $criteria An array of search criteria. | [
"Checks",
"if",
"an",
"option",
"is",
"in",
"the",
"database",
"for",
"the",
"current",
"blog",
".",
"If",
"checking",
"for",
"an",
"array",
"or",
"an",
"object",
"then",
"the",
"serialized",
"version",
"will",
"be",
"checked",
"for",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1575-L1582 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveManyPostsInDatabase | public function haveManyPostsInDatabase($count, array $overrides = [])
{
if (!is_int($count)) {
throw new \InvalidArgumentException('Count must be an integer value');
}
$overrides = $this->setTemplateData($overrides);
$ids = [];
for ($i = 0; $i < $count; $i++) {
$thisOverrides = $this->replaceNumbersInArray($overrides, $i);
$ids[] = $this->havePostInDatabase($thisOverrides);
}
return $ids;
} | php | public function haveManyPostsInDatabase($count, array $overrides = [])
{
if (!is_int($count)) {
throw new \InvalidArgumentException('Count must be an integer value');
}
$overrides = $this->setTemplateData($overrides);
$ids = [];
for ($i = 0; $i < $count; $i++) {
$thisOverrides = $this->replaceNumbersInArray($overrides, $i);
$ids[] = $this->havePostInDatabase($thisOverrides);
}
return $ids;
} | [
"public",
"function",
"haveManyPostsInDatabase",
"(",
"$",
"count",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"count",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Count must be ... | Inserts many posts in the database returning their IDs.
@param int $count The number of posts to insert.
@param array $overrides {
An array of values to override the defaults.
The `{{n}}` placeholder can be used to have the post count inserted in its place;
e.g. `Post Title - {{n}}` will be set to `Post Title - 0` for the first post,
`Post Title - 1` for the second one and so on.
The same applies to meta values as well.
@type array $meta An associative array of meta key/values to be set for the post, shorthand for the
`havePostmetaInDatabase` method. e.g. `['one' => 'foo', 'two' => 'bar']`; to have an array value inserted
in a single row serialize it e.g.
`['serialized_field` => serialize(['one','two','three'])]` otherwise a distinct row will be
added for each entry. See `havePostmetaInDatabase` method.
}
@example
```php
// Insert 3 random posts.
$I->haveManyPostsInDatabase(3);
// Insert 3 posts with generated titles.
$I->haveManyPostsInDatabase(3, ['post_title' => 'Test post {{n}}']);
```
@return array An array of the inserted post IDs. | [
"Inserts",
"many",
"posts",
"in",
"the",
"database",
"returning",
"their",
"IDs",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1638-L1651 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.setTemplateData | protected function setTemplateData(array $overrides = [])
{
if (empty($overrides['template_data'])) {
$this->templateData = [];
} else {
$this->templateData = $overrides['template_data'];
$overrides = array_diff_key($overrides, ['template_data' => []]);
}
return $overrides;
} | php | protected function setTemplateData(array $overrides = [])
{
if (empty($overrides['template_data'])) {
$this->templateData = [];
} else {
$this->templateData = $overrides['template_data'];
$overrides = array_diff_key($overrides, ['template_data' => []]);
}
return $overrides;
} | [
"protected",
"function",
"setTemplateData",
"(",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"overrides",
"[",
"'template_data'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"templateData",
"=",
"[",
"]",
";",
"}",
"e... | Sets the template data in the overrides array.
@param array $overrides An array of overrides to apply the template data to.
@return array The array of overrides with the template data replaced. | [
"Sets",
"the",
"template",
"data",
"in",
"the",
"overrides",
"array",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1660-L1670 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.seeTermInDatabase | public function seeTermInDatabase(array $criteria)
{
$termsCriteria = array_intersect_key($criteria, array_flip($this->termKeys));
$termTaxonomyCriteria = array_intersect_key($criteria, array_flip($this->termTaxonomyKeys));
if (!empty($termsCriteria)) {
// this one fails... go to...
$this->seeInDatabase($this->grabTermsTableName(), $termsCriteria);
}
if (!empty($termTaxonomyCriteria)) {
$this->seeInDatabase($this->grabTermTaxonomyTableName(), $termTaxonomyCriteria);
}
} | php | public function seeTermInDatabase(array $criteria)
{
$termsCriteria = array_intersect_key($criteria, array_flip($this->termKeys));
$termTaxonomyCriteria = array_intersect_key($criteria, array_flip($this->termTaxonomyKeys));
if (!empty($termsCriteria)) {
// this one fails... go to...
$this->seeInDatabase($this->grabTermsTableName(), $termsCriteria);
}
if (!empty($termTaxonomyCriteria)) {
$this->seeInDatabase($this->grabTermTaxonomyTableName(), $termTaxonomyCriteria);
}
} | [
"public",
"function",
"seeTermInDatabase",
"(",
"array",
"$",
"criteria",
")",
"{",
"$",
"termsCriteria",
"=",
"array_intersect_key",
"(",
"$",
"criteria",
",",
"array_flip",
"(",
"$",
"this",
"->",
"termKeys",
")",
")",
";",
"$",
"termTaxonomyCriteria",
"=",
... | Checks for a term in the database.
Looks up the `terms` and `term_taxonomy` prefixed tables.
@example
```php
$I->seeTermInDatabase(['slug' => 'genre--fiction']);
$I->seeTermInDatabase(['name' => 'Fiction', 'slug' => 'genre--fiction']);
```
@param array $criteria An array of criteria to search for the term, can be columns from the `terms` and the
`term_taxonomy` tables. | [
"Checks",
"for",
"a",
"term",
"in",
"the",
"database",
".",
"Looks",
"up",
"the",
"terms",
"and",
"term_taxonomy",
"prefixed",
"tables",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1728-L1740 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.dontHaveTermInDatabase | public function dontHaveTermInDatabase(array $criteria, $purgeMeta = true)
{
$termRelationshipsKeys = ['term_taxonomy_id'];
$termTableCriteria = array_intersect_key($criteria, array_flip($this->termKeys));
$termTaxonomyTableCriteria = array_intersect_key($criteria, array_flip($this->termTaxonomyKeys));
if ($purgeMeta) {
$ids = false;
if (!empty($termTableCriteria)) {
$ids = $this->grabAllFromDatabase($this->grabTermsTableName(), 'term_id', $criteria);
} elseif (!empty($termTaxonomyTableCriteria)) {
$ids = $this->grabAllFromDatabase($this->grabTermTaxonomyTableName(), 'term_id', $criteria);
}
if (!empty($ids)) {
foreach ($ids as $id) {
$this->dontHaveTermMetaInDatabase($id);
}
}
}
$this->dontHaveInDatabase($this->grabTermsTableName(), $termTableCriteria);
$this->dontHaveInDatabase($this->grabTermTaxonomyTableName(), $termTaxonomyTableCriteria);
$this->dontHaveInDatabase(
$this->grabTermRelationshipsTableName(),
array_intersect_key($criteria, array_flip($termRelationshipsKeys))
);
} | php | public function dontHaveTermInDatabase(array $criteria, $purgeMeta = true)
{
$termRelationshipsKeys = ['term_taxonomy_id'];
$termTableCriteria = array_intersect_key($criteria, array_flip($this->termKeys));
$termTaxonomyTableCriteria = array_intersect_key($criteria, array_flip($this->termTaxonomyKeys));
if ($purgeMeta) {
$ids = false;
if (!empty($termTableCriteria)) {
$ids = $this->grabAllFromDatabase($this->grabTermsTableName(), 'term_id', $criteria);
} elseif (!empty($termTaxonomyTableCriteria)) {
$ids = $this->grabAllFromDatabase($this->grabTermTaxonomyTableName(), 'term_id', $criteria);
}
if (!empty($ids)) {
foreach ($ids as $id) {
$this->dontHaveTermMetaInDatabase($id);
}
}
}
$this->dontHaveInDatabase($this->grabTermsTableName(), $termTableCriteria);
$this->dontHaveInDatabase($this->grabTermTaxonomyTableName(), $termTaxonomyTableCriteria);
$this->dontHaveInDatabase(
$this->grabTermRelationshipsTableName(),
array_intersect_key($criteria, array_flip($termRelationshipsKeys))
);
} | [
"public",
"function",
"dontHaveTermInDatabase",
"(",
"array",
"$",
"criteria",
",",
"$",
"purgeMeta",
"=",
"true",
")",
"{",
"$",
"termRelationshipsKeys",
"=",
"[",
"'term_taxonomy_id'",
"]",
";",
"$",
"termTableCriteria",
"=",
"array_intersect_key",
"(",
"$",
"... | Removes a term from the database.
@example
```php
$I->dontHaveTermInDatabase(['name' => 'romance']);
$I->dontHaveTermInDatabase(['slug' => 'genre--romance']);
```
@param array $criteria An array of search criteria.
@param bool $purgeMeta Whether the terms meta should be purged along side with the meta or not. | [
"Removes",
"a",
"term",
"from",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1754-L1783 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.dontSeeTermInDatabase | public function dontSeeTermInDatabase(array $criteria)
{
$termsCriteria = array_intersect_key($criteria, array_flip($this->termKeys));
$termTaxonomyCriteria = array_intersect_key($criteria, array_flip($this->termTaxonomyKeys));
if (!empty($termsCriteria)) {
// this one fails... go to...
$this->dontSeeInDatabase($this->grabTermsTableName(), $termsCriteria);
}
if (!empty($termTaxonomyCriteria)) {
$this->dontSeeInDatabase($this->grabTermTaxonomyTableName(), $termTaxonomyCriteria);
}
} | php | public function dontSeeTermInDatabase(array $criteria)
{
$termsCriteria = array_intersect_key($criteria, array_flip($this->termKeys));
$termTaxonomyCriteria = array_intersect_key($criteria, array_flip($this->termTaxonomyKeys));
if (!empty($termsCriteria)) {
// this one fails... go to...
$this->dontSeeInDatabase($this->grabTermsTableName(), $termsCriteria);
}
if (!empty($termTaxonomyCriteria)) {
$this->dontSeeInDatabase($this->grabTermTaxonomyTableName(), $termTaxonomyCriteria);
}
} | [
"public",
"function",
"dontSeeTermInDatabase",
"(",
"array",
"$",
"criteria",
")",
"{",
"$",
"termsCriteria",
"=",
"array_intersect_key",
"(",
"$",
"criteria",
",",
"array_flip",
"(",
"$",
"this",
"->",
"termKeys",
")",
")",
";",
"$",
"termTaxonomyCriteria",
"... | Makes sure a term is not in the database.
Looks up both the `terms` table and the `term_taxonomy` tables.
@example
```php
// Asserts a 'fiction' term is not in the database.
$I->dontSeeTermInDatabase(['name' => 'fiction']);
// Asserts a 'fiction' term with slug 'genre--fiction' is not in the database.
$I->dontSeeTermInDatabase(['name' => 'fiction', 'slug' => 'genre--fiction']);
```
@param array $criteria An array of criteria to search for the term, can be columns from the `terms` and the
`term_taxonomy` tables. | [
"Makes",
"sure",
"a",
"term",
"is",
"not",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1819-L1831 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveManyCommentsInDatabase | public function haveManyCommentsInDatabase($count, $comment_post_ID, array $overrides = [])
{
if (!is_int($count)) {
throw new \InvalidArgumentException('Count must be an integer value');
}
$overrides = $this->setTemplateData($overrides);
$ids = [];
for ($i = 0; $i < $count; $i++) {
$thisOverrides = $this->replaceNumbersInArray($overrides, $i);
$ids[] = $this->haveCommentInDatabase($comment_post_ID, $thisOverrides);
}
return $ids;
} | php | public function haveManyCommentsInDatabase($count, $comment_post_ID, array $overrides = [])
{
if (!is_int($count)) {
throw new \InvalidArgumentException('Count must be an integer value');
}
$overrides = $this->setTemplateData($overrides);
$ids = [];
for ($i = 0; $i < $count; $i++) {
$thisOverrides = $this->replaceNumbersInArray($overrides, $i);
$ids[] = $this->haveCommentInDatabase($comment_post_ID, $thisOverrides);
}
return $ids;
} | [
"public",
"function",
"haveManyCommentsInDatabase",
"(",
"$",
"count",
",",
"$",
"comment_post_ID",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"count",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumen... | Inserts many comments in the database.
@example
```php
// Insert 3 random comments for a post.
$I->haveManyCommentsInDatabase(3, $postId);
// Insert 3 random comments for a post.
$I->haveManyCommentsInDatabase(3, $postId, ['comment_content' => 'Comment {{n}}']);
```
@param int $count The number of comments to insert.
@param int $comment_post_ID The comment parent post ID.
@param array $overrides An associative array to override the defaults.
@return int[] An array containing the inserted comments IDs. | [
"Inserts",
"many",
"comments",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1851-L1864 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveCommentInDatabase | public function haveCommentInDatabase($comment_post_ID, array $data = [])
{
if (!is_int($comment_post_ID)) {
throw new \BadMethodCallException('Comment post ID must be int');
}
$has_meta = !empty($data['meta']);
$meta = [];
if ($has_meta) {
$meta = $data['meta'];
unset($data['meta']);
}
$comment = Comment::makeComment($comment_post_ID, $data);
$commentsTableName = $this->grabPrefixedTableNameFor('comments');
$commentId = $this->haveInDatabase($commentsTableName, $comment);
if ($has_meta) {
foreach ($meta as $key => $value) {
$this->haveCommentMetaInDatabase($commentId, $key, $value);
}
}
if ($comment['comment_approved']) {
$commentCount = $this->countInDatabase(
$commentsTableName,
[
'comment_approved' => '1',
'comment_post_ID' => $comment_post_ID,
]
);
$postsTableName = $this->grabPostsTableName();
$this->updateInDatabase(
$postsTableName,
['comment_count' => $commentCount],
['ID' => $comment_post_ID]
);
}
return $commentId;
} | php | public function haveCommentInDatabase($comment_post_ID, array $data = [])
{
if (!is_int($comment_post_ID)) {
throw new \BadMethodCallException('Comment post ID must be int');
}
$has_meta = !empty($data['meta']);
$meta = [];
if ($has_meta) {
$meta = $data['meta'];
unset($data['meta']);
}
$comment = Comment::makeComment($comment_post_ID, $data);
$commentsTableName = $this->grabPrefixedTableNameFor('comments');
$commentId = $this->haveInDatabase($commentsTableName, $comment);
if ($has_meta) {
foreach ($meta as $key => $value) {
$this->haveCommentMetaInDatabase($commentId, $key, $value);
}
}
if ($comment['comment_approved']) {
$commentCount = $this->countInDatabase(
$commentsTableName,
[
'comment_approved' => '1',
'comment_post_ID' => $comment_post_ID,
]
);
$postsTableName = $this->grabPostsTableName();
$this->updateInDatabase(
$postsTableName,
['comment_count' => $commentCount],
['ID' => $comment_post_ID]
);
}
return $commentId;
} | [
"public",
"function",
"haveCommentInDatabase",
"(",
"$",
"comment_post_ID",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"comment_post_ID",
")",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'Com... | Inserts a comment in the database.
@example
```php
$I->haveCommentInDatabase($postId, ['comment_content' => 'Test Comment', 'comment_karma' => 23]);
```
@param int $comment_post_ID The id of the post the comment refers to.
@param array $data The comment data overriding default and random generated values.
@return int The inserted comment `comment_id`. | [
"Inserts",
"a",
"comment",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1879-L1921 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveCommentMetaInDatabase | public function haveCommentMetaInDatabase($comment_id, $meta_key, $meta_value)
{
if (!is_int($comment_id)) {
throw new \BadMethodCallException('Comment id must be an int');
}
if (!is_string($meta_key)) {
throw new \BadMethodCallException('Meta key must be an string');
}
return $this->haveInDatabase($this->grabCommentmetaTableName(), [
'comment_id' => $comment_id,
'meta_key' => $meta_key,
'meta_value' => $this->maybeSerialize($meta_value),
]);
} | php | public function haveCommentMetaInDatabase($comment_id, $meta_key, $meta_value)
{
if (!is_int($comment_id)) {
throw new \BadMethodCallException('Comment id must be an int');
}
if (!is_string($meta_key)) {
throw new \BadMethodCallException('Meta key must be an string');
}
return $this->haveInDatabase($this->grabCommentmetaTableName(), [
'comment_id' => $comment_id,
'meta_key' => $meta_key,
'meta_value' => $this->maybeSerialize($meta_value),
]);
} | [
"public",
"function",
"haveCommentMetaInDatabase",
"(",
"$",
"comment_id",
",",
"$",
"meta_key",
",",
"$",
"meta_value",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"comment_id",
")",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'Comment... | Inserts a comment meta field in the database.
Array and object meta values will be serialized.
@example
```php
$I->haveCommentMetaInDatabase($commentId, 'api_ID', 23);
// The value will be serialized.
$apiData = ['ID' => 23, 'user' => 89, 'origin' => 'twitter'];
$I->haveCommentMetaInDatabase($commentId, 'api_data', $apiData);
```
@param int $comment_id The ID of the comment to insert the meta for.
@param string $meta_key The key of the comment meta to insert.
@param mixed $meta_value The value of the meta to insert, if serializable it will be serialized.
@return int The inserted comment meta ID. | [
"Inserts",
"a",
"comment",
"meta",
"field",
"in",
"the",
"database",
".",
"Array",
"and",
"object",
"meta",
"values",
"will",
"be",
"serialized",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L1941-L1955 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.dontHaveCommentInDatabase | public function dontHaveCommentInDatabase(array $criteria, $purgeMeta = true)
{
$table = $this->grabCommentsTableName();
if ($purgeMeta) {
$ids = $this->grabAllFromDatabase($table, 'comment_id', $criteria);
if (!empty($ids)) {
foreach ($ids as $id) {
$this->dontHaveCommentMetaInDatabase($id);
}
}
}
$this->dontHaveInDatabase($table, $criteria);
} | php | public function dontHaveCommentInDatabase(array $criteria, $purgeMeta = true)
{
$table = $this->grabCommentsTableName();
if ($purgeMeta) {
$ids = $this->grabAllFromDatabase($table, 'comment_id', $criteria);
if (!empty($ids)) {
foreach ($ids as $id) {
$this->dontHaveCommentMetaInDatabase($id);
}
}
}
$this->dontHaveInDatabase($table, $criteria);
} | [
"public",
"function",
"dontHaveCommentInDatabase",
"(",
"array",
"$",
"criteria",
",",
"$",
"purgeMeta",
"=",
"true",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"grabCommentsTableName",
"(",
")",
";",
"if",
"(",
"$",
"purgeMeta",
")",
"{",
"$",
"ids... | Removes an entry from the comments table.
@example
```php
$I->dontHaveCommentInDatabase(['comment_post_ID' => 23, 'comment_url' => 'http://example.copm']);
```
@param array $criteria An array of search criteria.
@param bool $purgeMeta If set to `true` then the meta for the comment will be purged too.
@throws \Exception In case of incoherent query criteria. | [
"Removes",
"an",
"entry",
"from",
"the",
"comments",
"table",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2009-L2022 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveManyLinksInDatabase | public function haveManyLinksInDatabase($count, array $overrides = [])
{
if (!is_int($count)) {
throw new \InvalidArgumentException('Count must be an integer value');
}
$overrides = $this->setTemplateData($overrides);
$ids = [];
for ($i = 0; $i < $count; $i++) {
$thisOverrides = $this->replaceNumbersInArray($overrides, $i);
$ids[] = $this->haveLinkInDatabase($thisOverrides);
}
return $ids;
} | php | public function haveManyLinksInDatabase($count, array $overrides = [])
{
if (!is_int($count)) {
throw new \InvalidArgumentException('Count must be an integer value');
}
$overrides = $this->setTemplateData($overrides);
$ids = [];
for ($i = 0; $i < $count; $i++) {
$thisOverrides = $this->replaceNumbersInArray($overrides, $i);
$ids[] = $this->haveLinkInDatabase($thisOverrides);
}
return $ids;
} | [
"public",
"function",
"haveManyLinksInDatabase",
"(",
"$",
"count",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"count",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Count must be ... | Inserts many links in the database `links` table.
@example
```php
// Insert 3 randomly generated links in the database.
$linkIds = $I->haveManyLinksInDatabase(3);
// Inserts links in the database replacing the `n` placeholder.
$linkIds = $I->haveManyLinksInDatabase(3, ['link_url' => 'http://example.org/test-{{n}}']);
```
@param int $count The number of links to insert.
@param array|null $overrides Overrides for the default arguments.
@return array An array of inserted `link_id`s. | [
"Inserts",
"many",
"links",
"in",
"the",
"database",
"links",
"table",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2078-L2091 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveLinkInDatabase | public function haveLinkInDatabase(array $overrides = [])
{
$tableName = $this->grabLinksTableName();
$defaults = Links::getDefaults();
$overrides = array_merge($defaults, array_intersect_key($overrides, $defaults));
return $this->haveInDatabase($tableName, $overrides);
} | php | public function haveLinkInDatabase(array $overrides = [])
{
$tableName = $this->grabLinksTableName();
$defaults = Links::getDefaults();
$overrides = array_merge($defaults, array_intersect_key($overrides, $defaults));
return $this->haveInDatabase($tableName, $overrides);
} | [
"public",
"function",
"haveLinkInDatabase",
"(",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"grabLinksTableName",
"(",
")",
";",
"$",
"defaults",
"=",
"Links",
"::",
"getDefaults",
"(",
")",
";",
"$",
... | Inserts a link in the database.
@example
```php
$linkId = $I->haveLinkInDatabase(['link_url' => 'http://example.org']);
```
@param array $overrides The data to insert.
@return int The inserted link `link_id`. | [
"Inserts",
"a",
"link",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2105-L2112 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveManyUsersInDatabase | public function haveManyUsersInDatabase($count, $user_login, $role = 'subscriber', array $overrides = [])
{
if (!is_int($count)) {
throw new \InvalidArgumentException('Count must be an integer value');
}
$ids = [];
$overrides = $this->setTemplateData($overrides);
for ($i = 0; $i < $count; $i++) {
$thisOverrides = $this->replaceNumbersInArray($overrides, $i);
$thisUserLogin = false === strpos(
$user_login,
$this->numberPlaceholder
) ? $user_login . '_' . $i : $this->replaceNumbersInString($user_login, $i);
$ids[] = $this->haveUserInDatabase($thisUserLogin, $role, $thisOverrides);
}
return $ids;
} | php | public function haveManyUsersInDatabase($count, $user_login, $role = 'subscriber', array $overrides = [])
{
if (!is_int($count)) {
throw new \InvalidArgumentException('Count must be an integer value');
}
$ids = [];
$overrides = $this->setTemplateData($overrides);
for ($i = 0; $i < $count; $i++) {
$thisOverrides = $this->replaceNumbersInArray($overrides, $i);
$thisUserLogin = false === strpos(
$user_login,
$this->numberPlaceholder
) ? $user_login . '_' . $i : $this->replaceNumbersInString($user_login, $i);
$ids[] = $this->haveUserInDatabase($thisUserLogin, $role, $thisOverrides);
}
return $ids;
} | [
"public",
"function",
"haveManyUsersInDatabase",
"(",
"$",
"count",
",",
"$",
"user_login",
",",
"$",
"role",
"=",
"'subscriber'",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"count",
")",
")",
"{",
"t... | Inserts many users in the database.
@example
```php
$subscribers = $I->haveManyUsersInDatabase(5, 'user-{{n}}');
$editors = $I->haveManyUsersInDatabase(
5,
'user-{{n}}',
'editor',
['user_email' => 'user-{{n}}@example.org']
);
```
@param int $count The number of users to insert.
@param string $user_login The user login name.
@param string $role The user role.
@param array $overrides An array of values to override the default ones.
@return array An array of user IDs. | [
"Inserts",
"many",
"users",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2154-L2171 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveUserInDatabase | public function haveUserInDatabase($user_login, $role = 'subscriber', array $overrides = [])
{
$hasMeta = !empty($overrides['meta']);
$meta = [];
if ($hasMeta) {
$meta = $overrides['meta'];
unset($overrides['meta']);
}
$userTableData = User::generateUserTableDataFrom($user_login, $overrides);
$this->debugSection('Generated users table data', json_encode($userTableData));
$userId = $this->haveInDatabase($this->grabUsersTableName(), $userTableData);
$this->haveUserCapabilitiesInDatabase($userId, $role);
$this->haveUserLevelsInDatabase($userId, $role);
if ($hasMeta) {
foreach ($meta as $key => $value) {
$this->haveUserMetaInDatabase($userId, $key, $value);
}
}
return $userId;
} | php | public function haveUserInDatabase($user_login, $role = 'subscriber', array $overrides = [])
{
$hasMeta = !empty($overrides['meta']);
$meta = [];
if ($hasMeta) {
$meta = $overrides['meta'];
unset($overrides['meta']);
}
$userTableData = User::generateUserTableDataFrom($user_login, $overrides);
$this->debugSection('Generated users table data', json_encode($userTableData));
$userId = $this->haveInDatabase($this->grabUsersTableName(), $userTableData);
$this->haveUserCapabilitiesInDatabase($userId, $role);
$this->haveUserLevelsInDatabase($userId, $role);
if ($hasMeta) {
foreach ($meta as $key => $value) {
$this->haveUserMetaInDatabase($userId, $key, $value);
}
}
return $userId;
} | [
"public",
"function",
"haveUserInDatabase",
"(",
"$",
"user_login",
",",
"$",
"role",
"=",
"'subscriber'",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
"{",
"$",
"hasMeta",
"=",
"!",
"empty",
"(",
"$",
"overrides",
"[",
"'meta'",
"]",
")",
";",
... | Inserts a user and its meta in the database.
@example
```php
$userId = $I->haveUserInDatabase('luca', 'editor', ['user_email' => 'luca@example.org']);
$subscriberId = $I->haveUserInDatabase('test');
```
@param string $user_login The user login name.
@param string $role The user role slug, e.g. "administrator"; defaults to "subscriber".
@param array $overrides An associative array of column names and values overridind defaults in the "users"
and "usermeta" table.
@return int The inserted user ID. | [
"Inserts",
"a",
"user",
"and",
"its",
"meta",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2189-L2212 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveUserCapabilitiesInDatabase | public function haveUserCapabilitiesInDatabase($userId, $role)
{
if (!is_array($role)) {
$meta_key = $this->grabPrefixedTableNameFor() . 'capabilities';
$meta_value = serialize([$role => 1]);
return $this->haveUserMetaInDatabase($userId, $meta_key, $meta_value);
}
$ids = [];
foreach ($role as $blogId => $_role) {
$blogIdAndPrefix = $blogId == 0 ? '' : $blogId . '_';
$meta_key = $this->grabPrefixedTableNameFor() . $blogIdAndPrefix . 'capabilities';
$meta_value = serialize([$_role => 1]);
$ids[] = array_merge($ids, $this->haveUserMetaInDatabase($userId, $meta_key, $meta_value));
}
return $ids;
} | php | public function haveUserCapabilitiesInDatabase($userId, $role)
{
if (!is_array($role)) {
$meta_key = $this->grabPrefixedTableNameFor() . 'capabilities';
$meta_value = serialize([$role => 1]);
return $this->haveUserMetaInDatabase($userId, $meta_key, $meta_value);
}
$ids = [];
foreach ($role as $blogId => $_role) {
$blogIdAndPrefix = $blogId == 0 ? '' : $blogId . '_';
$meta_key = $this->grabPrefixedTableNameFor() . $blogIdAndPrefix . 'capabilities';
$meta_value = serialize([$_role => 1]);
$ids[] = array_merge($ids, $this->haveUserMetaInDatabase($userId, $meta_key, $meta_value));
}
return $ids;
} | [
"public",
"function",
"haveUserCapabilitiesInDatabase",
"(",
"$",
"userId",
",",
"$",
"role",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"role",
")",
")",
"{",
"$",
"meta_key",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
")",
".",
"'cap... | Sets a user capabilities in the database.
@example
```php
$blogId = $this->haveBlogInDatabase('test');
$editor = $I->haveUserInDatabase('luca', 'editor');
$capsIds = $I->haveUserCapabilitiesInDatabase($editor, [$blogId => 'editor']);
```
@param int $userId The ID of the user to set the capabilities of.
@param string|array $role Either a role string (e.g. `administrator`) or an associative array of blog IDs/roles
for a multisite installation (e.g. `[1 => 'administrator`, 2 => 'subscriber']`).
@return array An array of inserted `meta_id`. | [
"Sets",
"a",
"user",
"capabilities",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2269-L2286 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveUserMetaInDatabase | public function haveUserMetaInDatabase($userId, $meta_key, $meta_value)
{
$ids = [];
$meta_values = is_array($meta_value) ? $meta_value : [$meta_value];
foreach ($meta_values as $meta_value) {
$data = [
'user_id' => $userId,
'meta_key' => $meta_key,
'meta_value' => $this->maybeSerialize($meta_value),
];
$ids[] = $this->haveInDatabase($this->grabUsermetaTableName(), $data);
}
return $ids;
} | php | public function haveUserMetaInDatabase($userId, $meta_key, $meta_value)
{
$ids = [];
$meta_values = is_array($meta_value) ? $meta_value : [$meta_value];
foreach ($meta_values as $meta_value) {
$data = [
'user_id' => $userId,
'meta_key' => $meta_key,
'meta_value' => $this->maybeSerialize($meta_value),
];
$ids[] = $this->haveInDatabase($this->grabUsermetaTableName(), $data);
}
return $ids;
} | [
"public",
"function",
"haveUserMetaInDatabase",
"(",
"$",
"userId",
",",
"$",
"meta_key",
",",
"$",
"meta_value",
")",
"{",
"$",
"ids",
"=",
"[",
"]",
";",
"$",
"meta_values",
"=",
"is_array",
"(",
"$",
"meta_value",
")",
"?",
"$",
"meta_value",
":",
"... | Sets a user meta in the database.
@example
```php
$userId = $I->haveUserInDatabase('luca', 'editor');
$I->haveUserMetaInDatabase($userId, 'karma', 23);
```
@param int $userId The user ID.
@param string $meta_key The meta key to set the value for.
@param mixed $meta_value Either a single value or an array of values; objects will be serialized while array of
values will trigger the insertion of multiple rows.
@return array An array of inserted `umeta_id`s. | [
"Sets",
"a",
"user",
"meta",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2304-L2318 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveUserLevelsInDatabase | public function haveUserLevelsInDatabase($userId, $role)
{
if (!is_array($role)) {
$meta_key = $this->grabPrefixedTableNameFor() . 'user_level';
$meta_value = User\Roles::getLevelForRole($role);
return $this->haveUserMetaInDatabase($userId, $meta_key, $meta_value);
}
$ids = [];
foreach ($role as $blogId => $_role) {
$blogIdAndPrefix = $blogId == 0 ? '' : $blogId . '_';
$meta_key = $this->grabPrefixedTableNameFor() . $blogIdAndPrefix . 'user_level';
$meta_value = User\Roles::getLevelForRole($_role);
$ids[] = $this->haveUserMetaInDatabase($userId, $meta_key, $meta_value);
}
return $ids;
} | php | public function haveUserLevelsInDatabase($userId, $role)
{
if (!is_array($role)) {
$meta_key = $this->grabPrefixedTableNameFor() . 'user_level';
$meta_value = User\Roles::getLevelForRole($role);
return $this->haveUserMetaInDatabase($userId, $meta_key, $meta_value);
}
$ids = [];
foreach ($role as $blogId => $_role) {
$blogIdAndPrefix = $blogId == 0 ? '' : $blogId . '_';
$meta_key = $this->grabPrefixedTableNameFor() . $blogIdAndPrefix . 'user_level';
$meta_value = User\Roles::getLevelForRole($_role);
$ids[] = $this->haveUserMetaInDatabase($userId, $meta_key, $meta_value);
}
return $ids;
} | [
"public",
"function",
"haveUserLevelsInDatabase",
"(",
"$",
"userId",
",",
"$",
"role",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"role",
")",
")",
"{",
"$",
"meta_key",
"=",
"$",
"this",
"->",
"grabPrefixedTableNameFor",
"(",
")",
".",
"'user_leve... | Sets the user access level meta in the database for a user.
@example
```php
$userId = $I->haveUserInDatabase('luca', 'editor');
$moreThanAnEditorLessThanAnAdmin = 8;
$I->haveUserLevelsInDatabase($userId, $moreThanAnEditorLessThanAnAdmin);
```
@param int $userId The ID of the user to set the level for.
@param string|array $role Either a role string (e.g. `administrator`) or an array of blog IDs/roles for a
multisite installation (e.g. `[1 => 'administrator`, 2 => 'subscriber']`).
@return array An array of inserted `meta_id`. | [
"Sets",
"the",
"user",
"access",
"level",
"meta",
"in",
"the",
"database",
"for",
"a",
"user",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2357-L2374 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveManyTermsInDatabase | public function haveManyTermsInDatabase($count, $name, $taxonomy, array $overrides = [])
{
if (!is_int($count)) {
throw new \InvalidArgumentException('Count must be an integer value');
}
$ids = [];
$overrides = $this->setTemplateData($overrides);
for ($i = 0; $i < $count; $i++) {
$thisName = false === strpos(
$name,
$this->numberPlaceholder
) ? $name . ' ' . $i : $this->replaceNumbersInString($name, $i);
$thisTaxonomy = $this->replaceNumbersInString($taxonomy, $i);
$thisOverrides = $this->replaceNumbersInArray($overrides, $i);
$ids[] = $this->haveTermInDatabase($thisName, $thisTaxonomy, $thisOverrides);
}
return $ids;
} | php | public function haveManyTermsInDatabase($count, $name, $taxonomy, array $overrides = [])
{
if (!is_int($count)) {
throw new \InvalidArgumentException('Count must be an integer value');
}
$ids = [];
$overrides = $this->setTemplateData($overrides);
for ($i = 0; $i < $count; $i++) {
$thisName = false === strpos(
$name,
$this->numberPlaceholder
) ? $name . ' ' . $i : $this->replaceNumbersInString($name, $i);
$thisTaxonomy = $this->replaceNumbersInString($taxonomy, $i);
$thisOverrides = $this->replaceNumbersInArray($overrides, $i);
$ids[] = $this->haveTermInDatabase($thisName, $thisTaxonomy, $thisOverrides);
}
return $ids;
} | [
"public",
"function",
"haveManyTermsInDatabase",
"(",
"$",
"count",
",",
"$",
"name",
",",
"$",
"taxonomy",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"count",
")",
")",
"{",
"throw",
"new",
"\\",
"... | Inserts many terms in the database.
@example
```php
$terms = $I->haveManyTermsInDatabase(3, 'genre-{{n}}', 'genre');
$termIds = array_column($terms, 0);
$termTaxonomyIds = array_column($terms, 1);
```
@param int $count The number of terms to insert.
@param string $name The term name template, can include the `{{n}}` placeholder.
@param string $taxonomy The taxonomy to insert the terms for.
@param array $overrides An associative array of default overrides.
@return array An array of arrays containing `term_id` and `term_taxonomy_id` of the inserted terms. | [
"Inserts",
"many",
"terms",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2393-L2411 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.seeTableInDatabase | public function seeTableInDatabase($table)
{
$count = $this->_seeTableInDatabase($table);
$this->assertTrue($count > 0, "No matching tables found for table '" . $table . "' in database.");
} | php | public function seeTableInDatabase($table)
{
$count = $this->_seeTableInDatabase($table);
$this->assertTrue($count > 0, "No matching tables found for table '" . $table . "' in database.");
} | [
"public",
"function",
"seeTableInDatabase",
"(",
"$",
"table",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"_seeTableInDatabase",
"(",
"$",
"table",
")",
";",
"$",
"this",
"->",
"assertTrue",
"(",
"$",
"count",
">",
"0",
",",
"\"No matching tables foun... | Checks that a table is in the database.
@example
```php
$options = $I->grabPrefixedTableNameFor('options');
$I->seeTableInDatabase($options);
```
@param string $table The full table name, including the table prefix. | [
"Checks",
"that",
"a",
"table",
"is",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2490-L2495 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb._seeTableInDatabase | protected function _seeTableInDatabase($table)
{
$dbh = $this->_getDbh();
$sth = $dbh->prepare('SHOW TABLES LIKE :table');
$this->debugSection('Query', $sth->queryString);
$sth->execute(['table' => $table]);
$count = $sth->rowCount();
return $count == 1;
} | php | protected function _seeTableInDatabase($table)
{
$dbh = $this->_getDbh();
$sth = $dbh->prepare('SHOW TABLES LIKE :table');
$this->debugSection('Query', $sth->queryString);
$sth->execute(['table' => $table]);
$count = $sth->rowCount();
return $count == 1;
} | [
"protected",
"function",
"_seeTableInDatabase",
"(",
"$",
"table",
")",
"{",
"$",
"dbh",
"=",
"$",
"this",
"->",
"_getDbh",
"(",
")",
";",
"$",
"sth",
"=",
"$",
"dbh",
"->",
"prepare",
"(",
"'SHOW TABLES LIKE :table'",
")",
";",
"$",
"this",
"->",
"deb... | Asserts a table exists in the database.
@param string $table The table to look for.
@return bool Whether the table exists in the database or not. | [
"Asserts",
"a",
"table",
"exists",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2504-L2513 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveManyBlogsInDatabase | public function haveManyBlogsInDatabase($count, array $overrides = [], $subdomain = true)
{
$blogIds = [];
$overrides = $this->setTemplateData($overrides);
for ($i = 0; $i < $count; $i++) {
$blogOverrides = $this->replaceNumbersInArray($overrides, $i);
$domainOrPath = 'blog-' . $i;
if (isset($blogOverrides['slug'])) {
$domainOrPath = $blogOverrides['slug'];
unset($blogOverrides['slug']);
}
$blogIds[] = $this->haveBlogInDatabase($domainOrPath, $blogOverrides, $subdomain);
}
return $blogIds;
} | php | public function haveManyBlogsInDatabase($count, array $overrides = [], $subdomain = true)
{
$blogIds = [];
$overrides = $this->setTemplateData($overrides);
for ($i = 0; $i < $count; $i++) {
$blogOverrides = $this->replaceNumbersInArray($overrides, $i);
$domainOrPath = 'blog-' . $i;
if (isset($blogOverrides['slug'])) {
$domainOrPath = $blogOverrides['slug'];
unset($blogOverrides['slug']);
}
$blogIds[] = $this->haveBlogInDatabase($domainOrPath, $blogOverrides, $subdomain);
}
return $blogIds;
} | [
"public",
"function",
"haveManyBlogsInDatabase",
"(",
"$",
"count",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
",",
"$",
"subdomain",
"=",
"true",
")",
"{",
"$",
"blogIds",
"=",
"[",
"]",
";",
"$",
"overrides",
"=",
"$",
"this",
"->",
"setTemplateD... | Inserts many blogs in the database.
@example
```php
$blogIds = $I->haveManyBlogsInDatabase(3, ['domain' =>'test-{{n}}']);
foreach($blogIds as $blogId){
$I->useBlog($blogId);
$I->haveManuPostsInDatabase(3);
}
```
@param int $count The number of blogs to create.
@param array $overrides An array of values to override the default ones; `{{n}}` will be replaced by the count.
@param bool $subdomain Whether the new blogs should be created as a subdomain or subfolder.
@return array An array of inserted blogs `blog_id`s. | [
"Inserts",
"many",
"blogs",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2681-L2698 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveBlogInDatabase | public function haveBlogInDatabase($domainOrPath, array $overrides = [], $subdomain = true)
{
$base = Blog::makeDefaults($subdomain);
if ($subdomain) {
$base['domain'] = false !== strpos($domainOrPath, $this->getSiteDomain())
? $domainOrPath
: trim($domainOrPath, '/') . '.' . $this->getSiteDomain();
$base['path'] = '/';
} else {
$base['domain'] = $this->getSiteDomain();
$base['path'] = '/' . trim($domainOrPath, '/') . '/';
}
$data = array_merge($base, array_intersect_key($overrides, $base));
// Make sure the path is in the `/path/` format.
if (isset($data['path']) && $data['path'] !== '/') {
$data['path'] = '/' . Utils::unleadslashit(Utils::untrailslashit($data['path'])) . '/';
}
$blogId = $this->haveInDatabase($this->grabBlogsTableName(), $data);
$this->scaffoldBlogTables($blogId, $domainOrPath, (bool)$subdomain);
if (($fs = $this->getWpFilesystemModule(false)) instanceof WPFilesystem) {
$this->debug('Scaffolding blog uploads directories.');
$fs->makeUploadsDir("sites/{$blogId}");
}
return $blogId;
} | php | public function haveBlogInDatabase($domainOrPath, array $overrides = [], $subdomain = true)
{
$base = Blog::makeDefaults($subdomain);
if ($subdomain) {
$base['domain'] = false !== strpos($domainOrPath, $this->getSiteDomain())
? $domainOrPath
: trim($domainOrPath, '/') . '.' . $this->getSiteDomain();
$base['path'] = '/';
} else {
$base['domain'] = $this->getSiteDomain();
$base['path'] = '/' . trim($domainOrPath, '/') . '/';
}
$data = array_merge($base, array_intersect_key($overrides, $base));
// Make sure the path is in the `/path/` format.
if (isset($data['path']) && $data['path'] !== '/') {
$data['path'] = '/' . Utils::unleadslashit(Utils::untrailslashit($data['path'])) . '/';
}
$blogId = $this->haveInDatabase($this->grabBlogsTableName(), $data);
$this->scaffoldBlogTables($blogId, $domainOrPath, (bool)$subdomain);
if (($fs = $this->getWpFilesystemModule(false)) instanceof WPFilesystem) {
$this->debug('Scaffolding blog uploads directories.');
$fs->makeUploadsDir("sites/{$blogId}");
}
return $blogId;
} | [
"public",
"function",
"haveBlogInDatabase",
"(",
"$",
"domainOrPath",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
",",
"$",
"subdomain",
"=",
"true",
")",
"{",
"$",
"base",
"=",
"Blog",
"::",
"makeDefaults",
"(",
"$",
"subdomain",
")",
";",
"if",
"(... | Inserts a blog in the `blogs` table.
@example
```php
// Create the `test` subdomain blog.
$blogId = $I->haveBlogInDatabase('test', ['administrator' => $userId]);
// Create the `/test` subfolder blog.
$blogId = $I->haveBlogInDatabase('test', ['administrator' => $userId], false);
```
@param string $domainOrPath The subdomain or the path to the be used for the blog.
@param array $overrides An array of values to override the defaults.
@param bool $subdomain Whether the new blog should be created as a subdomain (`true`)
or subfolder (`true`)
@return int The inserted blog `blog_id`. | [
"Inserts",
"a",
"blog",
"in",
"the",
"blogs",
"table",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2718-L2747 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.scaffoldBlogTables | protected function scaffoldBlogTables($blogId, $domainOrPath, $isSubdomain = true)
{
$stylesheet = $this->grabOptionFromDatabase('stylesheet');
$subdomain = $isSubdomain ?
trim($domainOrPath, '.')
: '';
$subFolder = !$isSubdomain ?
trim($domainOrPath, '/')
: '';
$data = [
'subdomain' => $subdomain,
'domain' => $this->getSiteDomain(),
'subfolder' => $subFolder,
'stylesheet' => $stylesheet,
];
$dbh = $this->_getDbh();
$dropQuery = $this->tables->getBlogDropQuery($this->config['tablePrefix'], $blogId);
$sth = $dbh->prepare($dropQuery);
$this->debugSection('Query', $sth->queryString);
$dropped = $sth->execute();
$scaffoldQuery = $this->tables->getBlogScaffoldQuery($this->config['tablePrefix'], $blogId, $data);
$sth = $dbh->prepare($scaffoldQuery);
$this->debugSection('Query', $sth->queryString);
$created = $sth->execute();
$this->scaffoldedBlogIds[] = $blogId;
} | php | protected function scaffoldBlogTables($blogId, $domainOrPath, $isSubdomain = true)
{
$stylesheet = $this->grabOptionFromDatabase('stylesheet');
$subdomain = $isSubdomain ?
trim($domainOrPath, '.')
: '';
$subFolder = !$isSubdomain ?
trim($domainOrPath, '/')
: '';
$data = [
'subdomain' => $subdomain,
'domain' => $this->getSiteDomain(),
'subfolder' => $subFolder,
'stylesheet' => $stylesheet,
];
$dbh = $this->_getDbh();
$dropQuery = $this->tables->getBlogDropQuery($this->config['tablePrefix'], $blogId);
$sth = $dbh->prepare($dropQuery);
$this->debugSection('Query', $sth->queryString);
$dropped = $sth->execute();
$scaffoldQuery = $this->tables->getBlogScaffoldQuery($this->config['tablePrefix'], $blogId, $data);
$sth = $dbh->prepare($scaffoldQuery);
$this->debugSection('Query', $sth->queryString);
$created = $sth->execute();
$this->scaffoldedBlogIds[] = $blogId;
} | [
"protected",
"function",
"scaffoldBlogTables",
"(",
"$",
"blogId",
",",
"$",
"domainOrPath",
",",
"$",
"isSubdomain",
"=",
"true",
")",
"{",
"$",
"stylesheet",
"=",
"$",
"this",
"->",
"grabOptionFromDatabase",
"(",
"'stylesheet'",
")",
";",
"$",
"subdomain",
... | Scaffolds the blog tables to support and create a blog.
@param int $blogId The blog ID.
@param string $domainOrPath Either the path or the sub-domain of the blog to create.
@param bool $isSubdomain Whether to create a sub-folder or a sub-domain blog. | [
"Scaffolds",
"the",
"blog",
"tables",
"to",
"support",
"and",
"create",
"a",
"blog",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2776-L2805 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.getWpFilesystemModule | protected function getWpFilesystemModule($throw = true)
{
try {
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $this->getModule('WPFilesystem');
} catch (ModuleException $e) {
if (!$throw) {
return null;
}
$message = 'This method requires the WPFilesystem module.';
throw new ModuleException(__CLASS__, $message);
}
} | php | protected function getWpFilesystemModule($throw = true)
{
try {
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $this->getModule('WPFilesystem');
} catch (ModuleException $e) {
if (!$throw) {
return null;
}
$message = 'This method requires the WPFilesystem module.';
throw new ModuleException(__CLASS__, $message);
}
} | [
"protected",
"function",
"getWpFilesystemModule",
"(",
"$",
"throw",
"=",
"true",
")",
"{",
"try",
"{",
"/** @noinspection PhpIncompatibleReturnTypeInspection */",
"return",
"$",
"this",
"->",
"getModule",
"(",
"'WPFilesystem'",
")",
";",
"}",
"catch",
"(",
"ModuleE... | Gets the WPFilesystem module.
@param bool $throw Whether to throw an exception if the WPFilesystem module is not loaded in
the suite or just return `false`.
@return \Codeception\Module\WPFilesystem The filesytem module instance if loaded in the suite.
@throws \Codeception\Exception\ModuleException If the WPFilesystem module is not loaded in the suite. | [
"Gets",
"the",
"WPFilesystem",
"module",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2817-L2830 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.dontHaveBlogInDatabase | public function dontHaveBlogInDatabase(array $criteria, $removeTables = true, $removeUploads = true)
{
$criteria = $this->prepareBlogCriteria($criteria);
$blogIds = $this->grabAllFromDatabase($this->grabBlogsTableName(), 'blog_id', $criteria);
foreach (array_column($blogIds, 'blog_id') as $blogId) {
if (empty($blogId)) {
$this->debug('No blog found matching criteria ' . json_encode($criteria, JSON_PRETTY_PRINT));
return;
}
if ($removeTables) {
foreach ($this->grabBlogTableNames($blogId) as $tableName) {
$this->dontHaveTableInDatabase($tableName);
}
}
if ($removeUploads && ($fs = $this->getWpFilesystemModule(false))) {
$fs->deleteUploadedDir($fs->getBlogUploadsPath($blogId));
}
$this->dontHaveInDatabase($this->grabBlogsTableName(), $criteria);
}
} | php | public function dontHaveBlogInDatabase(array $criteria, $removeTables = true, $removeUploads = true)
{
$criteria = $this->prepareBlogCriteria($criteria);
$blogIds = $this->grabAllFromDatabase($this->grabBlogsTableName(), 'blog_id', $criteria);
foreach (array_column($blogIds, 'blog_id') as $blogId) {
if (empty($blogId)) {
$this->debug('No blog found matching criteria ' . json_encode($criteria, JSON_PRETTY_PRINT));
return;
}
if ($removeTables) {
foreach ($this->grabBlogTableNames($blogId) as $tableName) {
$this->dontHaveTableInDatabase($tableName);
}
}
if ($removeUploads && ($fs = $this->getWpFilesystemModule(false))) {
$fs->deleteUploadedDir($fs->getBlogUploadsPath($blogId));
}
$this->dontHaveInDatabase($this->grabBlogsTableName(), $criteria);
}
} | [
"public",
"function",
"dontHaveBlogInDatabase",
"(",
"array",
"$",
"criteria",
",",
"$",
"removeTables",
"=",
"true",
",",
"$",
"removeUploads",
"=",
"true",
")",
"{",
"$",
"criteria",
"=",
"$",
"this",
"->",
"prepareBlogCriteria",
"(",
"$",
"criteria",
")",... | Removes one ore more blogs frome the database.
@example
```php
// Remove the blog, all its tables and files.
$I->dontHaveBlogInDatabase(['path' => 'test/one']);
// Remove the blog entry, not the tables though.
$I->dontHaveBlogInDatabase(['blog_id' => $blogId]);
// Remove multiple blogs.
$I->dontHaveBlogInDatabase(['domain' => 'test']);
```
@param array $criteria An array of search criteria to find the blog rows in the blogs table.
@param bool $removeTables Remove the blog tables.
@param bool $removeUploads Remove the blog uploads; requires the `WPFilesystem` module. | [
"Removes",
"one",
"ore",
"more",
"blogs",
"frome",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2849-L2873 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.grabBlogTableNames | public function grabBlogTableNames($blogId)
{
$table_prefix = "{$this->tablePrefix}{$blogId}_";
$query = 'SELECT table_name '
. 'FROM information_schema.tables '
. "WHERE table_schema = ? and table_name like '{$table_prefix}%'";
$databaseName = $this->_getDriver()->executeQuery('select database()', [])->fetchColumn();
return $this->_getDriver()->executeQuery($query, [$databaseName])->fetchAll(PDO::FETCH_COLUMN);
} | php | public function grabBlogTableNames($blogId)
{
$table_prefix = "{$this->tablePrefix}{$blogId}_";
$query = 'SELECT table_name '
. 'FROM information_schema.tables '
. "WHERE table_schema = ? and table_name like '{$table_prefix}%'";
$databaseName = $this->_getDriver()->executeQuery('select database()', [])->fetchColumn();
return $this->_getDriver()->executeQuery($query, [$databaseName])->fetchAll(PDO::FETCH_COLUMN);
} | [
"public",
"function",
"grabBlogTableNames",
"(",
"$",
"blogId",
")",
"{",
"$",
"table_prefix",
"=",
"\"{$this->tablePrefix}{$blogId}_\"",
";",
"$",
"query",
"=",
"'SELECT table_name '",
".",
"'FROM information_schema.tables '",
".",
"\"WHERE table_schema = ? and table_name li... | Returns a list of tables for a blog ID.
@example
```php
$blogId = $I->haveBlogInDatabase('test');
$tables = $I->grabBlogTableNames($blogId);
$options = array_filter($tables, function($tableName){
return str_pos($tableName, 'options') !== false;
});
```
@param int $blogId The ID of the blog to fetch the tables for.
@return array An array of tables for the blog, it does not include the tables common to all blogs; an empty array
if the tables for the blog do not exist.
@throws \Exception If there is any error while preparing the query. | [
"Returns",
"a",
"list",
"of",
"tables",
"for",
"a",
"blog",
"ID",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2894-L2902 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.dontHaveTableInDatabase | public function dontHaveTableInDatabase($fullTableName)
{
$drop = "DROP TABLE {$fullTableName}";
try {
$this->_getDriver()->executeQuery($drop, []);
} catch (\PDOException $e) {
if (false === strpos($e->getMessage(), 'table or view not found')) {
throw $e;
}
$this->debug("Table {$fullTableName} not removed from database: it did not exist.");
return;
}
$this->debug("Table {$fullTableName} removed from database.");
} | php | public function dontHaveTableInDatabase($fullTableName)
{
$drop = "DROP TABLE {$fullTableName}";
try {
$this->_getDriver()->executeQuery($drop, []);
} catch (\PDOException $e) {
if (false === strpos($e->getMessage(), 'table or view not found')) {
throw $e;
}
$this->debug("Table {$fullTableName} not removed from database: it did not exist.");
return;
}
$this->debug("Table {$fullTableName} removed from database.");
} | [
"public",
"function",
"dontHaveTableInDatabase",
"(",
"$",
"fullTableName",
")",
"{",
"$",
"drop",
"=",
"\"DROP TABLE {$fullTableName}\"",
";",
"try",
"{",
"$",
"this",
"->",
"_getDriver",
"(",
")",
"->",
"executeQuery",
"(",
"$",
"drop",
",",
"[",
"]",
")",... | Removes a table from the database.
The case where a table does not exist is handled without raising an error.
@example
```php
$ordersTable = $I->grabPrefixedTableNameFor('orders');
$I->dontHaveTableInDatabase($ordersTable);
```
@param string $fullTableName The full table name, including the table prefix.
@throws \Exception If there is an error while dropping the table. | [
"Removes",
"a",
"table",
"from",
"the",
"database",
".",
"The",
"case",
"where",
"a",
"table",
"does",
"not",
"exist",
"is",
"handled",
"without",
"raising",
"an",
"error",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2918-L2933 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.useTheme | public function useTheme($stylesheet, $template = null, $themeName = null)
{
if (!(is_string($stylesheet))) {
throw new \InvalidArgumentException('Stylesheet must be a string');
}
if (!(is_string($template) || $template === null)) {
throw new \InvalidArgumentException('Template must either be a string or be null.');
}
if (!(is_string($themeName) || $themeName === null)) {
throw new \InvalidArgumentException('Current Theme must either be a string or be null.');
}
$template = $template ?: $stylesheet;
$themeName = $themeName ?: ucwords($stylesheet, " _");
$this->haveOptionInDatabase('stylesheet', $stylesheet);
$this->haveOptionInDatabase('template', $template);
$this->haveOptionInDatabase('current_theme', $themeName);
$this->stylesheet = $stylesheet;
$this->menus[$stylesheet] = empty($this->menus[$stylesheet]) ? [] : $this->menus[$stylesheet];
} | php | public function useTheme($stylesheet, $template = null, $themeName = null)
{
if (!(is_string($stylesheet))) {
throw new \InvalidArgumentException('Stylesheet must be a string');
}
if (!(is_string($template) || $template === null)) {
throw new \InvalidArgumentException('Template must either be a string or be null.');
}
if (!(is_string($themeName) || $themeName === null)) {
throw new \InvalidArgumentException('Current Theme must either be a string or be null.');
}
$template = $template ?: $stylesheet;
$themeName = $themeName ?: ucwords($stylesheet, " _");
$this->haveOptionInDatabase('stylesheet', $stylesheet);
$this->haveOptionInDatabase('template', $template);
$this->haveOptionInDatabase('current_theme', $themeName);
$this->stylesheet = $stylesheet;
$this->menus[$stylesheet] = empty($this->menus[$stylesheet]) ? [] : $this->menus[$stylesheet];
} | [
"public",
"function",
"useTheme",
"(",
"$",
"stylesheet",
",",
"$",
"template",
"=",
"null",
",",
"$",
"themeName",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"(",
"is_string",
"(",
"$",
"stylesheet",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArg... | Sets the current theme options.
@example
```php
$I->useTheme('twentyseventeen');
$I->useTheme('child-of-twentyseventeen', 'twentyseventeen');
$I->useTheme('acme', 'acme', 'Acme Theme');
```
@param string $stylesheet The theme stylesheet slug, e.g. `twentysixteen`.
@param string|null $template The theme template slug, e.g. `twentysixteen`, defaults to `$stylesheet`.
@param string|null $themeName The theme name, e.g. `Acme`, defaults to the "title" version of `$stylesheet`. | [
"Sets",
"the",
"current",
"theme",
"options",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L2966-L2987 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveMenuInDatabase | public function haveMenuInDatabase($slug, $location, array $overrides = [])
{
if (!is_string($slug)) {
throw new \InvalidArgumentException('Menu slug must be a string.');
}
if (!is_string($location)) {
throw new \InvalidArgumentException('Menu location must be a string.');
}
if (empty($this->stylesheet)) {
throw new \RuntimeException('Stylesheet must be set to add menus, use `useTheme` first.');
}
$title = empty($overrides['title']) ? ucwords($slug, ' -_') : $overrides['title'];
$menuIds = $this->haveTermInDatabase($title, 'nav_menu', ['slug' => $slug]);
$menuTermTaxonomyIds = reset($menuIds);
// set theme options to use the `primary` location
$this->haveOptionInDatabase(
'theme_mods_' . $this->stylesheet,
['nav_menu_locations' => [$location => $menuTermTaxonomyIds]]
);
$this->menus[$this->stylesheet][$slug] = $menuIds;
$this->menuItems[$this->stylesheet][$slug] = [];
return $menuIds;
} | php | public function haveMenuInDatabase($slug, $location, array $overrides = [])
{
if (!is_string($slug)) {
throw new \InvalidArgumentException('Menu slug must be a string.');
}
if (!is_string($location)) {
throw new \InvalidArgumentException('Menu location must be a string.');
}
if (empty($this->stylesheet)) {
throw new \RuntimeException('Stylesheet must be set to add menus, use `useTheme` first.');
}
$title = empty($overrides['title']) ? ucwords($slug, ' -_') : $overrides['title'];
$menuIds = $this->haveTermInDatabase($title, 'nav_menu', ['slug' => $slug]);
$menuTermTaxonomyIds = reset($menuIds);
// set theme options to use the `primary` location
$this->haveOptionInDatabase(
'theme_mods_' . $this->stylesheet,
['nav_menu_locations' => [$location => $menuTermTaxonomyIds]]
);
$this->menus[$this->stylesheet][$slug] = $menuIds;
$this->menuItems[$this->stylesheet][$slug] = [];
return $menuIds;
} | [
"public",
"function",
"haveMenuInDatabase",
"(",
"$",
"slug",
",",
"$",
"location",
",",
"array",
"$",
"overrides",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"slug",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
... | Creates and adds a menu to a theme location in the database.
@example
```php
list($termId, $termTaxId) = $I->haveMenuInDatabase('test', 'sidebar');
```
@param string $slug The menu slug.
@param string $location The theme menu location the menu will be assigned to.
@param array $overrides An array of values to override the defaults.
@return array An array containing the created menu `term_id` and `term_taxonomy_id`. | [
"Creates",
"and",
"adds",
"a",
"menu",
"to",
"a",
"theme",
"location",
"in",
"the",
"database",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L3003-L3031 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.haveMenuItemInDatabase | public function haveMenuItemInDatabase($menuSlug, $title, $menuOrder = null, array $meta = [])
{
if (!is_string($menuSlug)) {
throw new \InvalidArgumentException('Menu slug must be a string.');
}
if (empty($this->stylesheet)) {
throw new \RuntimeException('Stylesheet must be set to add menus, use `useTheme` first.');
}
if (!array_key_exists($menuSlug, $this->menus[$this->stylesheet])) {
throw new \RuntimeException("Menu $menuSlug is not a registered menu for the current theme.");
}
$menuOrder = $menuOrder ?: count($this->menuItems[$this->stylesheet][$menuSlug]) + 1;
$menuItemId = $this->havePostInDatabase([
'post_title' => $title,
'menu_order' => $menuOrder,
'post_type' => 'nav_menu_item',
]);
$defaults = [
'type' => 'custom',
'object' => 'custom',
'url' => 'http://example.com',
];
$meta = array_merge($defaults, $meta);
array_walk($meta, function ($value, $key) use ($menuItemId) {
$this->havePostmetaInDatabase($menuItemId, '_menu_item_' . $key, $value);
});
$this->haveTermRelationshipInDatabase($menuItemId, $this->menus[$this->stylesheet][$menuSlug][1]);
$this->menuItems[$this->stylesheet][$menuSlug][] = $menuItemId;
return $menuItemId;
} | php | public function haveMenuItemInDatabase($menuSlug, $title, $menuOrder = null, array $meta = [])
{
if (!is_string($menuSlug)) {
throw new \InvalidArgumentException('Menu slug must be a string.');
}
if (empty($this->stylesheet)) {
throw new \RuntimeException('Stylesheet must be set to add menus, use `useTheme` first.');
}
if (!array_key_exists($menuSlug, $this->menus[$this->stylesheet])) {
throw new \RuntimeException("Menu $menuSlug is not a registered menu for the current theme.");
}
$menuOrder = $menuOrder ?: count($this->menuItems[$this->stylesheet][$menuSlug]) + 1;
$menuItemId = $this->havePostInDatabase([
'post_title' => $title,
'menu_order' => $menuOrder,
'post_type' => 'nav_menu_item',
]);
$defaults = [
'type' => 'custom',
'object' => 'custom',
'url' => 'http://example.com',
];
$meta = array_merge($defaults, $meta);
array_walk($meta, function ($value, $key) use ($menuItemId) {
$this->havePostmetaInDatabase($menuItemId, '_menu_item_' . $key, $value);
});
$this->haveTermRelationshipInDatabase($menuItemId, $this->menus[$this->stylesheet][$menuSlug][1]);
$this->menuItems[$this->stylesheet][$menuSlug][] = $menuItemId;
return $menuItemId;
} | [
"public",
"function",
"haveMenuItemInDatabase",
"(",
"$",
"menuSlug",
",",
"$",
"title",
",",
"$",
"menuOrder",
"=",
"null",
",",
"array",
"$",
"meta",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"menuSlug",
")",
")",
"{",
"throw"... | Adds a menu element to a menu for the current theme.
@example
```php
$I->haveMenuInDatabase('test', 'sidebar');
$I->haveMenuItemInDatabase('test', 'Test one', 0);
$I->haveMenuItemInDatabase('test', 'Test two', 1);
```
@param string $menuSlug The menu slug the item should be added to.
@param string $title The menu item title.
@param int|null $menuOrder An optional menu order, `1` based.
@param array|null $meta An associative array that will be prefixed with `_menu_item_` for the item post
meta.
@return int The menu item post `ID` | [
"Adds",
"a",
"menu",
"element",
"to",
"a",
"menu",
"for",
"the",
"current",
"theme",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L3051-L3082 | train |
lucatume/wp-browser | src/Codeception/Module/WPDb.php | WPDb.grabSiteUrl | public function grabSiteUrl($path = null)
{
$url = $this->config['url'];
if ($path !== null) {
return Utils::untrailslashit($this->config['url']) . DIRECTORY_SEPARATOR . Utils::unleadslashit($path);
}
return $url;
} | php | public function grabSiteUrl($path = null)
{
$url = $this->config['url'];
if ($path !== null) {
return Utils::untrailslashit($this->config['url']) . DIRECTORY_SEPARATOR . Utils::unleadslashit($path);
}
return $url;
} | [
"public",
"function",
"grabSiteUrl",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"config",
"[",
"'url'",
"]",
";",
"if",
"(",
"$",
"path",
"!==",
"null",
")",
"{",
"return",
"Utils",
"::",
"untrailslashit",
"(",
"$"... | Returns the current site URL as specified in the module configuration.
@example
```php
$shopPath = $I->grabSiteUrl('/shop');
```
@param string $path A path that should be appended to the site URL.
@return string The current site URL | [
"Returns",
"the",
"current",
"site",
"URL",
"as",
"specified",
"in",
"the",
"module",
"configuration",
"."
] | 1bf32090a0ab97385a6cf654643967c4abf30c7d | https://github.com/lucatume/wp-browser/blob/1bf32090a0ab97385a6cf654643967c4abf30c7d/src/Codeception/Module/WPDb.php#L3262-L3271 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.