Skip to content

Commit 77392c7

Browse files
committed
Handle missing EDAC key flag
1 parent e61fd40 commit 77392c7

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

includes/classes/class-admin-toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private function get_default_menu_items(): array {
108108
];
109109

110110
// Add Get Pro submenu item (only show if pro is not installed or license is not valid).
111-
if ( ! defined( 'EDACP_VERSION' ) || ! EDAC_KEY_VALID ) {
111+
if ( ! defined( 'EDACP_VERSION' ) || ! defined( 'EDAC_KEY_VALID' ) || ! EDAC_KEY_VALID ) {
112112
$pro_link = function_exists( 'edac_generate_link_type' )
113113
? edac_generate_link_type( [ 'utm_content' => 'admin-toolbar' ] )
114114
: 'https://equalizedigital.com/accessibility-checker/pricing/';

tests/phpunit/includes/classes/AdminToolbarTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,36 @@ public function test_get_default_menu_items_returns_array() {
9595
$this->assertArrayHasKey( 'id', $items[0] );
9696
}
9797

98+
/**
99+
* Test get_default_menu_items() handles missing EDAC_KEY_VALID when pro is defined.
100+
*
101+
* @runInSeparateProcess
102+
*/
103+
public function test_get_default_menu_items_handles_missing_edac_key_valid_constant() {
104+
if ( defined( 'EDAC_KEY_VALID' ) ) {
105+
$this->markTestSkipped( 'EDAC_KEY_VALID is already defined in this test environment.' );
106+
}
107+
if ( ! defined( 'EDACP_VERSION' ) ) {
108+
define( 'EDACP_VERSION', '1.0.0' );
109+
}
110+
111+
$reflection = new \ReflectionClass( Admin_Toolbar::class );
112+
$method = $reflection->getMethod( 'get_default_menu_items' );
113+
$method->setAccessible( true );
114+
$toolbar = new Admin_Toolbar();
115+
$items = $method->invoke( $toolbar );
116+
117+
$pro_item = null;
118+
foreach ( $items as $item ) {
119+
if ( 'accessibility-checker-pro' === $item['id'] ) {
120+
$pro_item = $item;
121+
break;
122+
}
123+
}
124+
125+
$this->assertNotNull( $pro_item );
126+
}
127+
98128
/**
99129
* Test pro menu link uses the expected UTM content parameter key.
100130
*/

0 commit comments

Comments
 (0)