Skip to content

Commit

Permalink
Add feature test for update scaffolded plugin test bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Apr 26, 2024
1 parent 121e557 commit f9a0de9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
25 changes: 25 additions & 0 deletions features/scaffold-plugin-tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,28 @@ Feature: Scaffold plugin unit tests
"""
bootstrap.php
"""

Scenario: Scaffold plugin tests with custom main file
Given a WP install
And a wp-content/plugins/foo/bar.php file:
"""
<?php
/**
* Plugin Name: Foo
* Plugin URI: https://example.com
* Description: Foo desctiption
* Author: John Doe
* Author URI: https://example.com
* Text Domain: foo
* Domain Path: /languages
* Version: 0.1.0
*
* @package Foo
*/
"""

When I run `wp scaffold plugin-tests foo`
Then the wp-content/plugins/foo/tests/bootstrap.php file should contain:
"""
require dirname( dirname( __FILE__ ) ) . '/bar.php';
"""
6 changes: 5 additions & 1 deletion src/Scaffold_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -869,9 +869,13 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) {
$wp_versions_to_test[] = 'latest';
$wp_versions_to_test[] = 'trunk';

$main_file = '';
$main_file = "{$slug}.php";

if ( 'plugin' === $type ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}

$all_plugins = get_plugins();

if ( ! empty( $all_plugins ) ) {
Expand Down

0 comments on commit f9a0de9

Please sign in to comment.