Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions features/db-check.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Feature: Check the database
When I run `wp db check`
Then STDOUT should contain:
"""
wp_cli_test.wp_users
{DB_NAME}.wp_users
"""
And STDOUT should contain:
"""
Expand All @@ -28,7 +28,7 @@ Feature: Check the database
When I run `wp db check --silent`
Then STDOUT should not contain:
"""
wp_cli_test.wp_users
{DB_NAME}.wp_users
"""
And STDOUT should contain:
"""
Expand All @@ -42,7 +42,7 @@ Feature: Check the database
When I run `wp db check --defaults`
Then STDOUT should contain:
"""
wp_cli_test.wp_users
{DB_NAME}.wp_users
"""
And STDOUT should contain:
"""
Expand All @@ -56,7 +56,7 @@ Feature: Check the database
When I run `wp db check --no-defaults`
Then STDOUT should contain:
"""
wp_cli_test.wp_users
{DB_NAME}.wp_users
"""
And STDOUT should contain:
"""
Expand All @@ -67,7 +67,7 @@ Feature: Check the database
Scenario: Run db check with passed-in options
Given a WP install

When I run `wp db check --dbuser=wp_cli_test`
When I run `wp db check --dbuser={DB_USER}`
Then STDOUT should contain:
"""
Success: Database checked.
Expand All @@ -79,7 +79,7 @@ Feature: Check the database
Success: Database checked.
"""

When I run `wp db check --dbuser=wp_cli_test --dbpass=password1`
When I run `wp db check --dbuser={DB_USER} --dbpass=password1`
Then STDOUT should contain:
"""
Success: Database checked.
Expand All @@ -101,7 +101,7 @@ Feature: Check the database
"""
And STDOUT should be empty

When I try `wp db check --dbuser=wp_cli_test --verbose`
When I try `wp db check --dbuser={DB_USER} --verbose`
Then the return code should be 0
And STDOUT should contain:
"""
Expand Down
56 changes: 28 additions & 28 deletions features/db-export.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,59 @@ Feature: Export a WordPress database
When I run `wp db export --porcelain`
Then STDOUT should contain:
"""
wp_cli_test-
{DB_NAME}-
"""
And the wp_cli_test.sql file should not exist
And the {DB_NAME}.sql file should not exist

Scenario: Database export to a specified file path
Given a WP install

When I run `wp db export wp_cli_test.sql --porcelain`
When I run `wp db export {DB_NAME}.sql --porcelain`
Then STDOUT should contain:
"""
wp_cli_test.sql
{DB_NAME}.sql
"""
And the wp_cli_test.sql file should exist
And the {DB_NAME}.sql file should exist

@skip-sqlite
Scenario: Exclude tables when exporting the database
Given a WP install

When I try `wp db export wp_cli_test.sql --exclude_tables=wp_users --porcelain`
Then the wp_cli_test.sql file should exist
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE ["`]?wp_users["`]?/
And the contents of the wp_cli_test.sql file should match /CREATE TABLE ["`]?wp_options["`]?/
When I try `wp db export {DB_NAME}.sql --exclude_tables=wp_users --porcelain`
Then the {DB_NAME}.sql file should exist
And the contents of the {DB_NAME}.sql file should not match /CREATE TABLE ["`]?wp_users["`]?/
And the contents of the {DB_NAME}.sql file should match /CREATE TABLE ["`]?wp_options["`]?/

@skip-sqlite
Scenario: Include only specific tables when exporting the database
Given a WP install

When I try `wp db export wp_cli_test.sql --tables=wp_users --porcelain`
Then the wp_cli_test.sql file should exist
And the contents of the wp_cli_test.sql file should match /CREATE TABLE ["`]?wp_users["`]?/
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE ["`]?wp_posts["`]?/
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE ["`]?wp_options["`]?/
When I try `wp db export {DB_NAME}.sql --tables=wp_users --porcelain`
Then the {DB_NAME}.sql file should exist
And the contents of the {DB_NAME}.sql file should match /CREATE TABLE ["`]?wp_users["`]?/
And the contents of the {DB_NAME}.sql file should not match /CREATE TABLE ["`]?wp_posts["`]?/
And the contents of the {DB_NAME}.sql file should not match /CREATE TABLE ["`]?wp_options["`]?/

@require-sqlite
Scenario: Exclude tables when exporting the database
Given a WP install

When I try `wp db export wp_cli_test.sql --exclude_tables=wp_users --porcelain`
Then the wp_cli_test.sql file should exist
And the contents of the wp_cli_test.sql file should not match /_mysql_data_types_cache/
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE ["`]?wp_users["`]?/
And the contents of the wp_cli_test.sql file should match /CREATE TABLE ["`]?wp_options["`]?/
When I try `wp db export {DB_NAME}.sql --exclude_tables=wp_users --porcelain`
Then the {DB_NAME}.sql file should exist
And the contents of the {DB_NAME}.sql file should not match /_mysql_data_types_cache/
And the contents of the {DB_NAME}.sql file should not match /CREATE TABLE ["`]?wp_users["`]?/
And the contents of the {DB_NAME}.sql file should match /CREATE TABLE ["`]?wp_options["`]?/

@require-sqlite
Scenario: Include only specific tables when exporting the database
Given a WP install

When I try `wp db export wp_cli_test.sql --tables=wp_users --porcelain`
Then the wp_cli_test.sql file should exist
And the contents of the wp_cli_test.sql file should not match /_mysql_data_types_cache/
And the contents of the wp_cli_test.sql file should match /CREATE TABLE ["`]?wp_users["`]?/
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE ["`]?wp_posts["`]?/
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE ["`]?wp_options["`]?/
When I try `wp db export {DB_NAME}.sql --tables=wp_users --porcelain`
Then the {DB_NAME}.sql file should exist
And the contents of the {DB_NAME}.sql file should not match /_mysql_data_types_cache/
And the contents of the {DB_NAME}.sql file should match /CREATE TABLE ["`]?wp_users["`]?/
And the contents of the {DB_NAME}.sql file should not match /CREATE TABLE ["`]?wp_posts["`]?/
And the contents of the {DB_NAME}.sql file should not match /CREATE TABLE ["`]?wp_options["`]?/

@require-sqlite
Scenario: Export database to STDOUT
Expand Down Expand Up @@ -153,10 +153,10 @@ Feature: Export a WordPress database
Scenario: Export database when PHP exec() is disabled
Given a WP install

When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--ddisable_functions=exec} db export wp_cli_test.sql --porcelain`
When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--ddisable_functions=exec} db export {DB_NAME}.sql --porcelain`
Then the return code should be 0
And STDOUT should contain:
"""
wp_cli_test.sql
{DB_NAME}.sql
"""
And the wp_cli_test.sql file should exist
And the {DB_NAME}.sql file should exist
72 changes: 36 additions & 36 deletions features/db-import.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@ Feature: Import a WordPress database
Scenario: Import from database name path by default
Given a WP install

When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db export {DB_NAME}.sql`
Then the {DB_NAME}.sql file should exist

When I run `wp db import`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
Success: Imported from '{DB_NAME}.sql'.
"""

Scenario: Import from database name path by default with mysql defaults
Given a WP install

When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db export {DB_NAME}.sql`
Then the {DB_NAME}.sql file should exist

When I run `wp db import --defaults`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
Success: Imported from '{DB_NAME}.sql'.
"""

Scenario: Import from database name path by default with --no-defaults
Given a WP install

When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db export {DB_NAME}.sql`
Then the {DB_NAME}.sql file should exist

When I run `wp db import --no-defaults`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
Success: Imported from '{DB_NAME}.sql'.
"""

@require-mysql-or-mariadb
Expand All @@ -60,30 +60,30 @@ Feature: Import a WordPress database
Scenario: Import from database name path by default and skip speed optimization
Given a WP install

When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db export {DB_NAME}.sql`
Then the {DB_NAME}.sql file should exist

When I run `wp db import --skip-optimization`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
Success: Imported from '{DB_NAME}.sql'.
"""

# SQLite doesn't support the --dbuser flag.
@require-mysql-or-mariadb
Scenario: Import from database name path by default with passed-in dbuser/dbpass
Given a WP install

When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db export {DB_NAME}.sql`
Then the {DB_NAME}.sql file should exist

When I run `wp db import --dbuser=wp_cli_test --dbpass=password1`
When I run `wp db import --dbuser={DB_USER} --dbpass=password1`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
Success: Imported from '{DB_NAME}.sql'.
"""

When I try `wp db import --dbuser=wp_cli_test --dbpass=no_such_pass`
When I try `wp db import --dbuser={DB_USER} --dbpass=no_such_pass`
Then the return code should not be 0
And STDERR should contain:
"""
Expand Down Expand Up @@ -116,10 +116,10 @@ Feature: Import a WordPress database
Scenario: Import forwards the --ssl flag to the MySQL client
Given a WP install

When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db export {DB_NAME}.sql`
Then the {DB_NAME}.sql file should exist

When I try `wp db import wp_cli_test.sql --ssl --debug`
When I try `wp db import {DB_NAME}.sql --ssl --debug`
Then STDERR should contain:
"""
--ssl
Expand Down Expand Up @@ -170,8 +170,8 @@ Feature: Import a WordPress database
Scenario: MySQL defaults are available as appropriate with --defaults flag
Given a WP install

When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db export {DB_NAME}.sql`
Then the {DB_NAME}.sql file should exist

When I try `wp db import --defaults --debug`
Then STDERR should match #Debug \(db\): Running shell command: /([^/]+/)+(mysql|mariadb) --no-auto-rehash#
Expand All @@ -194,9 +194,9 @@ Feature: Import a WordPress database
🍣
"""

When I try `wp db export wp_cli_test.sql --debug`
When I try `wp db export {DB_NAME}.sql --debug`
Then the return code should be 0
And the wp_cli_test.sql file should exist
And the {DB_NAME}.sql file should exist
And STDERR should contain:
"""
Detected character set of the posts table: utf8mb4
Expand All @@ -206,10 +206,10 @@ Feature: Import a WordPress database
Setting missing default character set to utf8mb4
"""

When I run `wp db import --dbuser=wp_cli_test --dbpass=password1`
When I run `wp db import --dbuser={DB_USER} --dbpass=password1`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
Success: Imported from '{DB_NAME}.sql'.
"""

When I run `wp post list`
Expand All @@ -231,14 +231,14 @@ Feature: Import a WordPress database
🍣
"""

When I try `wp db export wp_cli_test.sql --debug`
When I try `wp db export {DB_NAME}.sql --debug`
Then the return code should be 0
And the wp_cli_test.sql file should exist
And the {DB_NAME}.sql file should exist

When I run `wp db import --dbuser=wp_cli_test --dbpass=password1`
When I run `wp db import --dbuser={DB_USER} --dbpass=password1`
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
Success: Imported from '{DB_NAME}.sql'.
"""

When I run `wp post list`
Expand Down Expand Up @@ -316,14 +316,14 @@ Feature: Import a WordPress database
Scenario: `wp db import` adapts the SQL mode via --init-command by default
Given a WP install

When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db export {DB_NAME}.sql`
Then the {DB_NAME}.sql file should exist

# The WordPress-compatibility mode adaptation runs on the same import
# connection via --init-command, so it is visible in the debug output and no
# separate mode probe runs (which is what used to break with custom connection
# options).
When I try `wp db import wp_cli_test.sql --debug`
When I try `wp db import {DB_NAME}.sql --debug`
Then the return code should be 0
And STDERR should contain:
"""
Expand All @@ -338,10 +338,10 @@ Feature: Import a WordPress database
Scenario: `wp db import --skip-sql-mode-compat` imports under the server's own SQL modes
Given a WP install

When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist
When I run `wp db export {DB_NAME}.sql`
Then the {DB_NAME}.sql file should exist

When I try `wp db import wp_cli_test.sql --skip-sql-mode-compat --debug`
When I try `wp db import {DB_NAME}.sql --skip-sql-mode-compat --debug`
Then the return code should be 0
And STDERR should not contain:
"""
Expand Down
6 changes: 3 additions & 3 deletions features/db-query.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Feature: Query the database with WordPress' MySQL config
Scenario: Database querying with passed-in options
Given a WP install

When I run `wp db query "SELECT COUNT(ID) FROM wp_posts;" --dbuser=wp_cli_test --html`
When I run `wp db query "SELECT COUNT(ID) FROM wp_posts;" --dbuser={DB_USER} --html`
Then STDOUT should contain:
"""
<TABLE
Expand All @@ -45,7 +45,7 @@ Feature: Query the database with WordPress' MySQL config
Scenario: Database querying with MySQL defaults and passed-in options
Given a WP install

When I run `wp db query --defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser=wp_cli_test --html`
When I run `wp db query --defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser={DB_USER} --html`
Then STDOUT should contain:
"""
<TABLE
Expand All @@ -64,7 +64,7 @@ Feature: Query the database with WordPress' MySQL config
Scenario: Database querying with --nodefaults and passed-in options
Given a WP install

When I run `wp db query --no-defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser=wp_cli_test --html`
When I run `wp db query --no-defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser={DB_USER} --html`
Then STDOUT should contain:
"""
<TABLE
Expand Down
Loading
Loading