Skip to content

Commit

Permalink
Separate class files in feature tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Jul 11, 2024
1 parent 22774e7 commit 8f74139
Showing 1 changed file with 40 additions and 27 deletions.
67 changes: 40 additions & 27 deletions tests/behat/features/plugin-check.feature
Original file line number Diff line number Diff line change
Expand Up @@ -286,23 +286,33 @@ Feature: Test that the WP-CLI command works.

Scenario: Check a plugin with addon enabled with extra checks
Given a WP install with the Plugin Check plugin
And a wp-content/plugins/pcp-addon/pcp-addon.php file:
And a wp-content/plugins/pcp-addon/class-postsperpage-check.php file:
"""
<?php
/**
* Plugin Name: PCP Addon
* Plugin URI: https://example.com
* Description: Plugin Check addon.
* Version: 0.1.0
* Author: WordPress Performance Team
* Author URI: https://make.wordpress.org/performance/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
use WordPress\Plugin_Check\Checker\Checks\Abstract_PHP_CodeSniffer_Check;
use WordPress\Plugin_Check\Traits\Stable_Check;
class PostsPerPage_Check extends Abstract_PHP_CodeSniffer_Check {
use Stable_Check;
public function get_categories() {
return array( 'new_category' );
}
protected function get_args() {
return array(
'extensions' => 'php',
'standard' => plugin_dir_path( __FILE__ ) . 'postsperpage.xml',
);
}
}
"""
And a wp-content/plugins/pcp-addon/class-prohibited-text-check.php file:
"""
<?php
use WordPress\Plugin_Check\Checker\Check_Result;
use WordPress\Plugin_Check\Checker\Checks\Abstract_File_Check;
use WordPress\Plugin_Check\Checker\Checks\Abstract_PHP_CodeSniffer_Check;
use WordPress\Plugin_Check\Traits\Amend_Check_Result;
use WordPress\Plugin_Check\Traits\Stable_Check;
Expand All @@ -328,22 +338,22 @@ Feature: Test that the WP-CLI command works.
}
}
}
"""

class PostsPerPage_Check extends Abstract_PHP_CodeSniffer_Check {
use Stable_Check;
public function get_categories() {
return array( 'new_category' );
}
protected function get_args() {
return array(
'extensions' => 'php',
'standard' => plugin_dir_path( __FILE__ ) . 'postsperpage.xml',
);
}
}
And a wp-content/plugins/pcp-addon/pcp-addon.php file:
"""
<?php
/**
* Plugin Name: PCP Addon
* Plugin URI: https://example.com
* Description: Plugin Check addon.
* Version: 0.1.0
* Author: WordPress Performance Team
* Author URI: https://make.wordpress.org/performance/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Requires Plugins: plugin-check
*/
add_filter(
'wp_plugin_check_categories',
Expand All @@ -355,6 +365,9 @@ Feature: Test that the WP-CLI command works.
add_filter(
'wp_plugin_check_checks',
function ( array $checks ) {
require_once plugin_dir_path( __FILE__ ) . 'class-prohibited-text-check.php';
require_once plugin_dir_path( __FILE__ ) . 'class-postsperpage-check.php';
return array_merge(
$checks,
array(
Expand Down

0 comments on commit 8f74139

Please sign in to comment.