Skip to content

Commit 36fb7e1

Browse files
committed
Namespaces, tests
1 parent 719cb77 commit 36fb7e1

6 files changed

Lines changed: 16 additions & 28 deletions

File tree

db-command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
require_once $wpcli_db_autoloader;
1010
}
1111

12-
WP_CLI::add_command( 'db', 'DB_Command' );
13-
WP_CLI::add_command( 'db users', 'DB_Users_Command' );
12+
WP_CLI::add_command( 'db', DB_Command::class );
13+
WP_CLI::add_command( 'db users', \WP_CLI\Db\DB_Users_Command::class );

features/db-users.feature

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1+
@skip-sqlite
12
Feature: Manage database users
23

34
Scenario: Create database user without privileges
45
Given an empty directory
56
And WP files
67
And wp-config.php
78

8-
When I run `wp db create`
9-
Then STDOUT should be:
10-
"""
11-
Success: Database created.
12-
"""
9+
When I try `wp db create`
1310

1411
When I run `wp db users create testuser localhost --password=testpass123`
1512
Then STDOUT should contain:
@@ -28,11 +25,7 @@ Feature: Manage database users
2825
And WP files
2926
And wp-config.php
3027

31-
When I run `wp db create`
32-
Then STDOUT should be:
33-
"""
34-
Success: Database created.
35-
"""
28+
When I try `wp db create`
3629

3730
When I run `wp db users create appuser localhost --password=secret123 --grant-privileges`
3831
Then STDOUT should contain:
@@ -49,11 +42,7 @@ Feature: Manage database users
4942
And WP files
5043
And wp-config.php
5144

52-
When I run `wp db create`
53-
Then STDOUT should be:
54-
"""
55-
Success: Database created.
56-
"""
45+
When I try `wp db create`
5746

5847
When I run `wp db users create remoteuser '%' --password=remote123`
5948
Then STDOUT should contain:
@@ -66,11 +55,7 @@ Feature: Manage database users
6655
And WP files
6756
And wp-config.php
6857

69-
When I run `wp db create`
70-
Then STDOUT should be:
71-
"""
72-
Success: Database created.
73-
"""
58+
When I try `wp db create`
7459

7560
When I run `wp db users create nopassuser localhost`
7661
Then STDOUT should contain:

phpcs.xml.dist

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@
5454
<!-- Exclude existing classes from the prefix rule as it would break BC to prefix them now. -->
5555
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound">
5656
<exclude-pattern>*/src/DB_Command\.php$</exclude-pattern>
57-
<exclude-pattern>*/src/DB_Users_Command\.php$</exclude-pattern>
58-
</rule>
59-
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedTraitFound">
60-
<exclude-pattern>*/src/DB_Command_SQLite\.php$</exclude-pattern>
6157
</rule>
6258

6359
<exclude-pattern>/tests/phpstan/scan-files</exclude-pattern>

src/DB_Command.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
use WP_CLI\Formatter;
44
use WP_CLI\Utils;
55
use cli\table\Column;
6-
7-
require_once __DIR__ . '/DB_Command_SQLite.php';
6+
use WP_CLI\Db\DB_Command_SQLite;
87

98
/**
109
* Performs basic database operations using credentials stored in wp-config.php.

src/DB_Command_SQLite.php

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

3+
namespace WP_CLI\Db;
4+
35
use WP_CLI\Formatter;
46
use WP_CLI\Utils;
7+
use WP_CLI;
8+
use Exception;
59

610
/**
711
* SQLite-specific database operations for DB_Command.

src/DB_Users_Command.php

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

3+
namespace WP_CLI\Db;
4+
5+
use DB_Command;
6+
use WP_CLI;
37
use WP_CLI\Utils;
48

59
/**

0 commit comments

Comments
 (0)