Skip to content

Commit 0e1637e

Browse files
committed
More fixes
1 parent 8eeea43 commit 0e1637e

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

features/db-import.feature

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Feature: Import a WordPress database
144144
When I try `wp db import --no-defaults --debug`
145145
Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysql|mariadb) --no-defaults --no-auto-rehash#
146146

147-
@require-wp-4.2
147+
@require-wp-4.2 @require-mysql-or-mariadb
148148
Scenario: Import db that has emoji in post
149149
Given a WP install
150150

@@ -180,3 +180,32 @@ Feature: Import a WordPress database
180180
"""
181181
🍣
182182
"""
183+
184+
@require-wp-4.2 @require-sqlite
185+
Scenario: Import db that has emoji in post
186+
Given a WP install
187+
188+
When I run `wp post create --post_title="🍣"`
189+
And I run `wp post list`
190+
Then the return code should be 0
191+
And STDOUT should contain:
192+
"""
193+
🍣
194+
"""
195+
196+
When I try `wp db export wp_cli_test.sql --debug`
197+
Then the return code should be 0
198+
And the wp_cli_test.sql file should exist
199+
200+
When I run `wp db import --dbuser=wp_cli_test --dbpass=password1`
201+
Then STDOUT should be:
202+
"""
203+
Success: Imported from 'wp_cli_test.sql'.
204+
"""
205+
206+
When I run `wp post list`
207+
Then the return code should be 0
208+
And STDOUT should contain:
209+
"""
210+
🍣
211+
"""

features/db-size.feature

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ Feature: Display database size
187187
MB
188188
"""
189189

190+
@require-mysql-or-mariadb
190191
Scenario: Display database size in bytes with specific format for a WordPress install
191192
Given a WP install
192193

@@ -207,6 +208,27 @@ Feature: Display database size
207208

208209
But STDOUT should not be a number
209210

211+
@require-sqlite
212+
Scenario: Display database size in bytes with specific format for a WordPress install
213+
Given a WP install
214+
215+
When I run `wp db size --size_format=b --format=csv`
216+
Then STDOUT should contain:
217+
"""
218+
Name,Size
219+
.ht.sqlite,"
220+
"""
221+
222+
But STDOUT should not be a number
223+
224+
When I run `wp db size --size_format=b --format=json`
225+
Then STDOUT should contain:
226+
"""
227+
[{"Name":".ht.sqlite","Size":"
228+
"""
229+
230+
But STDOUT should not be a number
231+
210232
Scenario: Display all table sizes for a WordPress install
211233
Given a WP install
212234

src/DB_Command.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,10 @@ public function size( $args, $assoc_args ) {
12441244
$size_key = floor( log( (float) $row['Size'] ) / log( 1000 ) );
12451245
$sizes = [ 'B', 'KB', 'MB', 'GB', 'TB' ];
12461246

1247+
if ( is_infinite( $size_key ) ) {
1248+
$size_key = 0;
1249+
}
1250+
12471251
$size_format = isset( $sizes[ $size_key ] ) ? $sizes[ $size_key ] : $sizes[0];
12481252
}
12491253

src/DB_Command_SQLite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ protected function sqlite_export( $file, $assoc_args ) {
323323
}
324324

325325
$exclude_tables = Utils\get_flag_value( $assoc_args, 'exclude_tables', '' );
326-
$exclude_tables = explode( ',', trim( $assoc_args['exclude_tables'], ',' ) );
326+
$exclude_tables = explode( ',', trim( $exclude_tables, ',' ) );
327327
$exclude_tables = array_map( 'strtolower', $exclude_tables );
328328

329329
try {

0 commit comments

Comments
 (0)