Assert the page really lands under the Nolimit menu, and bump to 1.5.0
Kristian's menu screenshot showed four plugins under Nolimit and not this one, after a build that moved the page there had already merged. Two separate problems behind that. The version never moved. The rename and the menu change went out still calling themselves 1.4.6 — the same number as the copy already installed. So two different builds carried one version, which is the one thing a version number exists to prevent, and nothing offered the new one as an update. Now 1.5.0. And the tests could not have caught it if the code HAD been wrong. The only menu assertion was that this plugin claims the label through wpmgr_menu_title — which passes while the plugin is absent from the menu entirely. The label and the membership are different facts, and the screenshot showed exactly that pair: the menu said Nolimit, this plugin was not in it. Three assertions now. The parent exists after wpmgr_ensure_menu(), this plugin's page is among the children of WPMGR_MENU_SLUG, and — separately — the main file lists includes/shared-menu.php in its is_admin() branch. That third one is there because the first two are a reduced repro and say so: the admin menu is only built in an admin request, and these run under WP-CLI where is_admin() is false and class-admin.php is never included, so the test has to require the files by hand. A by-hand require would pass even if the plugin never loaded them in a real request. That is the half a reduced repro always omits, so it is asserted on its own rather than assumed. Checked while here, from the security session's report: no human_time_diff anywhere in this plugin, so the half-translated "4 timer ago" seam does not exist here. Nothing to fix. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
79b2fefeeb
commit
4c7731ae01
+1
-1
@@ -4,7 +4,7 @@ Tags: woocommerce, discount, email, shipping, coupon
|
||||
Requires at least: 5.8
|
||||
Tested up to: 7.1
|
||||
Requires PHP: 7.4
|
||||
Stable tag: 1.4.6
|
||||
Stable tag: 1.5.0
|
||||
WC requires at least: 6.0
|
||||
WC tested up to: 11.1.0
|
||||
License: GPLv2 or later
|
||||
|
||||
@@ -238,6 +238,55 @@ wc_edm_is(
|
||||
apply_filters( 'wpmgr_menu_title', 'Manager' )
|
||||
);
|
||||
|
||||
// The filter above proves this plugin CLAIMS the label. It does not prove the
|
||||
// page is registered under that parent, and those are different failures: the
|
||||
// menu said Nolimit while this plugin was still absent from it.
|
||||
//
|
||||
// Loaded and invoked by hand because the admin menu is only built in an admin
|
||||
// request and these run under WP-CLI, where is_admin() is false and
|
||||
// class-admin.php is therefore never included. That makes this a reduced
|
||||
// repro, so it asserts the loading half separately below rather than trusting
|
||||
// that the by-hand path matches the real one.
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
require_once WC_EDM_PLUGIN_DIR . 'includes/shared-menu.php';
|
||||
require_once WC_EDM_PLUGIN_DIR . 'includes/class-admin.php';
|
||||
|
||||
wp_set_current_user( 1 );
|
||||
global $menu, $submenu, $admin_page_hooks;
|
||||
$menu = array();
|
||||
$submenu = array();
|
||||
$admin_page_hooks = array();
|
||||
|
||||
$wc_edm_admin = new WC_EDM_Admin();
|
||||
$wc_edm_admin->register_menu();
|
||||
|
||||
wc_edm_ok(
|
||||
'the parent Nolimit menu exists',
|
||||
isset( $admin_page_hooks[ WPMGR_MENU_SLUG ] ),
|
||||
'wpmgr_ensure_menu() did not register it'
|
||||
);
|
||||
|
||||
$wc_edm_pages = isset( $submenu[ WPMGR_MENU_SLUG ] )
|
||||
? wp_list_pluck( $submenu[ WPMGR_MENU_SLUG ], 2 )
|
||||
: array();
|
||||
wc_edm_ok(
|
||||
'and this plugin has a page under it',
|
||||
in_array( WC_EDM_Admin::PAGE_SLUG, $wc_edm_pages, true ),
|
||||
'pages found: ' . ( $wc_edm_pages ? implode( ', ', $wc_edm_pages ) : 'none' )
|
||||
);
|
||||
|
||||
// The other half: the by-hand require above would pass even if the plugin
|
||||
// never loaded the file in a real admin request. This is the assertion that
|
||||
// covers that, and it is the half a reduced repro always omits.
|
||||
wc_edm_ok(
|
||||
'and the plugin itself loads the shared menu file in admin',
|
||||
false !== strpos(
|
||||
file_get_contents( WC_EDM_PLUGIN_FILE ),
|
||||
"'includes/shared-menu.php',"
|
||||
),
|
||||
'it is not in the is_admin() branch of includes(), so nothing would define wpmgr_ensure_menu()'
|
||||
);
|
||||
|
||||
// includes/shared-menu.php is byte-identical in all five plugins, and which
|
||||
// copy a site loads is decided by activation order. Editing it here would make
|
||||
// a site with three of five updated show one label or another depending on who
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Plugin URI: https://gitea.nolimit.dk/kw/woo-discount-manager
|
||||
* Update URI: https://gitea.nolimit.dk/kw/nolimit-discounts-dist
|
||||
* Description: Apply discounts and show/hide shipping methods based on the customer's email address (full address, domain or partial match).
|
||||
* Version: 1.4.6
|
||||
* Version: 1.5.0
|
||||
* Author: Kristian Wind
|
||||
* Author URI: https://gitea.nolimit.dk/kw
|
||||
* License: GPL-2.0-or-later
|
||||
@@ -28,7 +28,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
define( 'WC_EDM_VERSION', '1.4.6' );
|
||||
define( 'WC_EDM_VERSION', '1.5.0' );
|
||||
define( 'WC_EDM_PLUGIN_FILE', __FILE__ );
|
||||
define( 'WC_EDM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||
define( 'WC_EDM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
Reference in New Issue
Block a user