Skip to content

Commit 75f52d2

Browse files
committed
More test fixes
1 parent b3bb681 commit 75f52d2

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

features/db-export.feature

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,10 @@ Feature: Export a WordPress database
2323
Scenario: Exclude tables when exporting the database
2424
Given a WP install
2525

26-
When I run `wp db export wp_cli_test.sql --exclude_tables=wp_users --porcelain`
26+
When I try `wp db export wp_cli_test.sql --exclude_tables=wp_users --porcelain`
2727
Then the wp_cli_test.sql file should exist
28-
And the wp_cli_test.sql file should not contain:
29-
"""
30-
CREATE TABLE wp_users
31-
"""
32-
And the wp_cli_test.sql file should contain:
33-
"""
34-
CREATE TABLE wp_options
35-
"""
36-
And the wp_cli_test.sql file should not contain:
37-
"""
38-
CREATE TABLE "wp_users"
39-
"""
40-
And the wp_cli_test.sql file should contain:
41-
"""
42-
CREATE TABLE "wp_options"
43-
"""
28+
And the contents of the wp_cli_test.sql file should not match /CREATE TABLE "?wp_users"?/
29+
And the contents of the wp_cli_test.sql file should match /CREATE TABLE "?wp_options"?/
4430

4531
Scenario: Export database to STDOUT
4632
Given a WP install
@@ -86,6 +72,7 @@ Feature: Export a WordPress database
8672
"""
8773
And STDOUT should be empty
8874

75+
@require-mysql-or-mariadb
8976
Scenario: MySQL defaults are available as appropriate with --defaults flag
9077
Given a WP install
9178

features/db-import.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ Feature: Import a WordPress database
127127
"""
128128
wp db import
129129
"""
130+
131+
@require-mysql-or-mariadb
130132
Scenario: MySQL defaults are available as appropriate with --defaults flag
131133
Given a WP install
132134

features/db-query.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Feature: Query the database with WordPress' MySQL config
7272
"""
7373
And STDOUT should be empty
7474

75+
@require-mysql-or-mariadb
7576
Scenario: MySQL defaults are available as appropriate with --defaults flag
7677
Given a WP install
7778

src/DB_Command_SQLite.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use WP_CLI\Utils;
4+
35
/**
46
* SQLite-specific database operations for DB_Command.
57
*
@@ -320,6 +322,10 @@ protected function sqlite_export( $file, $assoc_args ) {
320322
WP_CLI::error( "Could not open file for writing: {$file}" );
321323
}
322324

325+
$exclude_tables = Utils\get_flag_value( $assoc_args, 'exclude_tables', '' );
326+
$exclude_tables = explode( ',', trim( $assoc_args['exclude_tables'], ',' ) );
327+
$exclude_tables = array_map( 'strtolower', $exclude_tables );
328+
323329
try {
324330
// Export schema and data as SQL.
325331
fwrite( $output, "-- SQLite database dump\n" );
@@ -335,6 +341,10 @@ protected function sqlite_export( $file, $assoc_args ) {
335341
$tables = $stmt->fetchAll( PDO::FETCH_COLUMN );
336342

337343
foreach ( $tables as $table ) {
344+
if ( in_array( $table, $exclude_tables, true ) ) {
345+
continue;
346+
}
347+
338348
// Escape table name for identifiers.
339349
$escaped_table = '"' . str_replace( '"', '""', $table ) . '"';
340350

0 commit comments

Comments
 (0)