Skip to content

Commit 4a616b6

Browse files
authored
Merge pull request #2 from swissspidy/tov2
Fix tests in PR
2 parents f143a85 + 0b40497 commit 4a616b6

File tree

4 files changed

+27
-34
lines changed

4 files changed

+27
-34
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
"require": {
2020
"php": ">=5.4",
2121
"wp-cli/package-command": "^2",
22-
"wp-cli/wp-cli": "2"
22+
"wp-cli/wp-cli": "^2"
2323
},
2424
"require-dev": {
2525
"wp-cli/extension-command": "^2",
26-
"wp-cli/wp-cli-tests": "2"
26+
"wp-cli/wp-cli-tests": "^2.0.7"
2727
},
2828
"config": {
2929
"platform": {
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
Feature: Generate cache
22

3-
Scenario: Manage wp-super-cache via cli
3+
Scenario: Manage wp-super-cache via CLI
44
Given a WP install
55

66
When I run `wp plugin install wp-super-cache`
77
Then STDOUT should contain:
8-
"""
9-
Downloading install
10-
"""
11-
And STDOUT should contain:
128
"""
139
Plugin installed successfully.
1410
"""
1511
And the wp-content/plugins/wp-super-cache directory should exist
1612

17-
When I run `wp package install wojsmol/wp-super-cache-cli:tov2`
18-
Then STDOUT should contain:
13+
When I try `wp super-cache enable`
14+
Then STDERR should contain:
1915
"""
20-
Success: Package installed.
16+
Error: WP Super Cache needs to be enabled to use its WP-CLI commands.
2117
"""
2218

23-
When I run `wp super-cache enable`
24-
Then STDOUT should contain:
19+
When I run `wp plugin activate wp-super-cache`
20+
And I run `wp super-cache enable`
21+
Then STDOUT should contain:
2522
"""
2623
Success: The WP Super Cache is enabled.
2724
"""
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Manages the WP Super Cache plugin
55
*/
6-
class WPSuperCache_Command extends WP_CLI_Command {
6+
class WP_Super_Cache_Command extends WP_CLI_Command {
77

88
/**
99
* Clear something from the cache.
@@ -167,13 +167,3 @@ protected function preload_status( $preload_counter, $pending_cancel ) {
167167
}
168168
}
169169
}
170-
171-
WP_CLI::add_command(
172-
'super-cache', 'WPSuperCache_Command', array(
173-
'before_invoke' => function() {
174-
if ( ! function_exists( 'wp_super_cache_enable' ) ) {
175-
WP_CLI::error( 'WP Super Cache needs to be enabled to use its WP-CLI commands.' );
176-
}
177-
},
178-
)
179-
);

wp-super-cache-cli.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
<?php
2-
/*
3-
Plugin Name: WP Super Cache CLI
4-
Version: 1.0
5-
Description: A CLI interface for the WP Super Cache plugin
6-
Author: WP-CLI Team
7-
Author URI: http://github.com/wp-cli
8-
Plugin URI: http://github.com/wp-cli/wp-super-cache-cli
9-
License: MIT
10-
*/
11-
12-
$autoload = __DIR__ . '/vendor/autoload.php';
2+
3+
$autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
4+
135
if ( file_exists( $autoload ) ) {
146
require_once $autoload;
157
}
8+
9+
if ( ! class_exists( 'WP_CLI' ) ) {
10+
return;
11+
}
12+
13+
WP_CLI::add_command(
14+
'super-cache', 'WP_Super_Cache_Command', array(
15+
'before_invoke' => function() {
16+
if ( ! function_exists( 'wp_super_cache_enable' ) ) {
17+
WP_CLI::error( 'WP Super Cache needs to be enabled to use its WP-CLI commands.' );
18+
}
19+
},
20+
)
21+
);

0 commit comments

Comments
 (0)