Skip to content

Commit 8a53a79

Browse files
committed
Reformat PSR2 Code
1 parent ea3850c commit 8a53a79

File tree

9 files changed

+180
-6
lines changed

9 files changed

+180
-6
lines changed

.gitignore

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
.DS_Store
2-
composer.lock
3-
wp-cli.local.yml
2+
3+
# NodeJs
44
node_modules/
5+
6+
# Composer Vendor
7+
composer.lock
58
vendor/
9+
10+
# WP-CLI Config
11+
wp-cli.local.yml
12+
13+
# WordPress
614
wordpress/
715
/.subsplit
816
/deploy/*
917
!/deploy/*.sh
1018
!/deploy/*.enc
19+
20+
# PHP Storm
1121
.idea
22+
23+
# PHP-CS-Fixer
24+
/.php_cs
25+
/.php_cs.cache
26+
27+
# PHPUnit
28+
.phpunit.result.cache

.travis.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: php
2+
3+
services:
4+
- mysql
5+
6+
php:
7+
- 5.6
8+
- 7.1
9+
- 7.2
10+
- 7.3
11+
12+
install:
13+
- composer install
14+
15+
before_script:
16+
- composer validate --strict
17+
- mysql -e 'CREATE DATABASE wp_cli_test;' -uroot
18+
- mysql -e 'GRANT ALL PRIVILEGES ON wp_cli_test.* TO "wp_cli_test"@"localhost" IDENTIFIED BY "password1"' -uroot
19+
20+
script:
21+
- composer test
22+
23+
cache:
24+
directories:
25+
- vendor

composer.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
"wp-packagist/wp-cli-helper": "dev-master",
2929
"ext-json": "*"
3030
},
31+
"require-dev": {
32+
"wp-cli/wp-cli": "^2.0",
33+
"phpunit/phpunit": "^8"
34+
},
3135
"extra": {
3236
"commands": [
3337
"global-config",
@@ -38,10 +42,10 @@
3842
"global-config get"
3943
]
4044
},
41-
"require-dev": {
42-
"wp-cli/wp-cli": "^2.0"
43-
},
4445
"support": {
4546
"issues": "https://github.com/wp-packagist/wp-cli-global-config-command/issues"
47+
},
48+
"scripts": {
49+
"test": "phpunit"
4650
}
4751
}

phpcs.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PSR2">
3+
<description>The PSR2 coding standard.</description>
4+
<rule ref="PSR2">
5+
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
6+
<exclude name="Generic.NamingConventions.CamelCapsFunctionName.Invalid"/>
7+
<exclude name="Generic.Files.LineLength"/>
8+
</rule>
9+
10+
<file>src/</file>
11+
<file>test/</file>
12+
13+
<exclude-pattern>vendor</exclude-pattern>
14+
<exclude-pattern>resources</exclude-pattern>
15+
<exclude-pattern>database/</exclude-pattern>
16+
<exclude-pattern>storage/</exclude-pattern>
17+
<exclude-pattern>node_modules/</exclude-pattern>
18+
</ruleset>

phpunit.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
bootstrap="tests/bootstrap.php"
6+
colors="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false"
12+
>
13+
<testsuites>
14+
<testsuite name="unit">
15+
<directory>./tests/unit/</directory>
16+
</testsuite>
17+
</testsuites>
18+
</phpunit>

src/Global_Config_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public function reset($_, $assoc)
267267
WP_CLI::error("The config list is empty.");
268268
}
269269

270-
WP_CLI::confirm("Are you sure you want to reset config ?");
270+
WP_CLI::confirm("Are you sure you want to reset config?");
271271
$wp_cli_config->remove_config_file();
272272
WP_CLI::success("Config reset.");
273273
}

tests/Logger.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
/**
4+
* PHPUnit logger
5+
*/
6+
class Logger
7+
{
8+
9+
/**
10+
* @param string $message Message to write.
11+
*
12+
* @return string
13+
*/
14+
public function info($message)
15+
{
16+
print $message;
17+
}
18+
19+
/**
20+
* @param $message
21+
*
22+
* @return mixed
23+
*/
24+
public function success($message)
25+
{
26+
print $message;
27+
}
28+
29+
/**
30+
* @param $message
31+
*
32+
* @return mixed
33+
*/
34+
public function warning($message)
35+
{
36+
print $message;
37+
}
38+
39+
/**
40+
* @param $message
41+
*
42+
* @return mixed
43+
*/
44+
public function error($message)
45+
{
46+
print $message;
47+
}
48+
49+
/**
50+
* @param $message_lines
51+
*
52+
* @return string
53+
*/
54+
public function error_multi_line($message_lines)
55+
{
56+
$message = implode("\n", $message_lines);
57+
58+
print $message;
59+
}
60+
}

tests/bootstrap.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$vendorDir = realpath(dirname(__FILE__) . '/..') . '/vendor';
4+
if (!defined('WP_CLI_ROOT')) {
5+
define('WP_CLI_ROOT', $vendorDir . '/wp-cli/wp-cli');
6+
}
7+
8+
include WP_CLI_ROOT . '/php/utils.php';
9+
include WP_CLI_ROOT . '/php/dispatcher.php';
10+
include WP_CLI_ROOT . '/php/class-wp-cli.php';
11+
include WP_CLI_ROOT . '/php/class-wp-cli-command.php';
12+
13+
\WP_CLI\Utils\load_dependencies();
14+
15+
require_once 'Logger.php';
16+
\WP_CLI::set_logger(new Logger());

tests/unit/CommandRunTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace test\unit;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
class CommandRunTest extends TestCase
8+
{
9+
10+
/** @test */
11+
public function ExistSpycLoadFunction()
12+
{
13+
$this->assertTrue(function_exists('spyc_load_file'));
14+
}
15+
16+
}

0 commit comments

Comments
 (0)