Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"phpstan/extension-installer": "^1.1"
},
"scripts": {
"test": "php tests/product-versions-remote-download-regression.php"
"test": [
"php tests/downloads-page-woocommerce-guard-regression.php",
"php tests/product-versions-remote-download-regression.php"
]
},
"config": {
"allow-plugins": {
Expand Down
2 changes: 1 addition & 1 deletion inc/class-downloads-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function override_downloads_template(string $template, string $template_n
*/
public function enqueue_assets(): void {

if ( ! is_account_page()) {
if ( ! function_exists('is_account_page') || ! \is_account_page()) {
return;
}

Expand Down
35 changes: 35 additions & 0 deletions tests/downloads-page-woocommerce-guard-regression.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Regression checks for Downloads_Page WooCommerce availability guards.
*
* @package WP_Update_Server_Plugin
*/

declare(strict_types=1);

namespace WP_Update_Server_Plugin {
require_once dirname(__DIR__) . '/inc/class-downloads-page.php';
}

namespace {
/**
* @param bool $condition Assertion condition.
* @param string $message Failure message.
* @return void
*/
function assert_true(bool $condition, string $message): void {

if ( ! $condition) {
throw new RuntimeException($message);
}
}

assert_true( ! function_exists('is_account_page'), 'WooCommerce is_account_page() should be unavailable in this regression test');

$reflection = new ReflectionClass(\WP_Update_Server_Plugin\Downloads_Page::class);
$downloads = $reflection->newInstanceWithoutConstructor();

$downloads->enqueue_assets();

fwrite(STDOUT, "Downloads_Page WooCommerce guard regression checks passed.\n");
}