Skip to content
Draft
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
28 changes: 28 additions & 0 deletions features/db-import.feature
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,34 @@ Feature: Import a WordPress database
Success: Imported from 'wp_cli_test.sql'.
"""

@require-mysql-or-mariadb
Scenario: Database import falls back to wpdb when mysql binary is unavailable
Given a WP install
And a fake-bin/mysql file:
"""
#!/bin/sh
exit 127
"""
And a fake-bin/mariadb file:
"""
#!/bin/sh
exit 127
"""

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

When I run `chmod +x fake-bin/mysql fake-bin/mariadb`
And I run `env PATH={RUN_DIR}/fake-bin:$PATH wp db import wp_cli_test.sql --debug`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
"""
And STDERR should contain:
"""
MySQL/MariaDB binary not available, falling back to wpdb for import.
"""

# SQLite doesn't support the --dbuser flag.
@require-mysql-or-mariadb
Scenario: Import from database name path by default with passed-in dbuser/dbpass
Expand Down
26 changes: 26 additions & 0 deletions features/db-query.feature
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,29 @@ Feature: Query the database with WordPress' MySQL config
"""
ANSI
"""

@require-mysql-or-mariadb
Scenario: Database querying falls back to wpdb when mysql binary is unavailable
Given a WP install
And a fake-bin/mysql file:
"""
#!/bin/sh
exit 127
"""
And a fake-bin/mariadb file:
"""
#!/bin/sh
exit 127
"""

When I run `chmod +x fake-bin/mysql fake-bin/mariadb`
And I try `env PATH={RUN_DIR}/fake-bin:$PATH wp db query "SELECT COUNT(ID) FROM wp_users;" --debug`
Then STDOUT should be:
"""
COUNT(ID)
1
"""
And STDERR should contain:
"""
MySQL/MariaDB binary not available, falling back to wpdb.
"""
50 changes: 50 additions & 0 deletions features/db.feature
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,56 @@ Feature: Perform database operations
Query succeeded. Rows affected: 1
"""

@require-mysql-or-mariadb
Scenario: Database drop falls back to wpdb when mysql binary is unavailable
Given a WP install
And a fake-bin/mysql file:
"""
#!/bin/sh
exit 127
"""
And a fake-bin/mariadb file:
"""
#!/bin/sh
exit 127
"""

When I run `chmod +x fake-bin/mysql fake-bin/mariadb`
And I try `env PATH={RUN_DIR}/fake-bin:$PATH wp db drop --yes --debug`
Then STDOUT should contain:
"""
Success: Database dropped.
"""
And STDERR should contain:
"""
Query via wpdb:
"""

@require-mysql-or-mariadb
Scenario: Database reset falls back to wpdb when mysql binary is unavailable
Given a WP install
And a fake-bin/mysql file:
"""
#!/bin/sh
exit 127
"""
And a fake-bin/mariadb file:
"""
#!/bin/sh
exit 127
"""

When I run `chmod +x fake-bin/mysql fake-bin/mariadb`
And I try `env PATH={RUN_DIR}/fake-bin:$PATH wp db reset --yes --debug`
Then STDOUT should contain:
"""
Success: Database reset.
"""
And STDERR should contain:
"""
Query via wpdb:
"""

@require-sqlite
Scenario: SQLite DB CRUD operations
Given a WP install
Expand Down
Loading
Loading