feat: add GitHub-powered updates to WordPress admin
Build plugin release / release (push) Failing after 4s
Build plugin release / release (push) Failing after 4s
This commit is contained in:
@@ -278,6 +278,50 @@ function test_debug_error_details(): void
|
||||
pass('Debug mode displays full exception details and stack trace');
|
||||
}
|
||||
|
||||
function test_plugin_update_discovery(): void
|
||||
{
|
||||
$packageUrl = 'https://github.com/dabestaniha/mahak-authenticate-bridge/releases/download/v2.3.0/mahak-authenticate-bridge.zip';
|
||||
$mockRelease = function ($response, array $request, string $url) use ($packageUrl) {
|
||||
if ($url !== 'https://api.github.com/repos/dabestaniha/mahak-authenticate-bridge/releases/latest') {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return [
|
||||
'headers' => [],
|
||||
'body' => json_encode([
|
||||
'tag_name' => 'v2.3.0',
|
||||
'html_url' => 'https://github.com/dabestaniha/mahak-authenticate-bridge/releases/tag/v2.3.0',
|
||||
'body' => 'Test release',
|
||||
'draft' => false,
|
||||
'prerelease' => false,
|
||||
'assets' => [[
|
||||
'name' => 'mahak-authenticate-bridge.zip',
|
||||
'browser_download_url' => $packageUrl,
|
||||
]],
|
||||
], JSON_THROW_ON_ERROR),
|
||||
'response' => ['code' => 200, 'message' => 'OK'],
|
||||
'cookies' => [],
|
||||
'filename' => null,
|
||||
];
|
||||
};
|
||||
|
||||
delete_site_transient('mahak_authenticate_bridge_release');
|
||||
add_filter('pre_http_request', $mockRelease, 10, 3);
|
||||
|
||||
$updates = apply_filters('pre_set_site_transient_update_plugins', (object) [
|
||||
'checked' => [TEST_PLUGIN => MAHAK_AUTHENTICATE_BRIDGE_VERSION],
|
||||
'response' => [],
|
||||
]);
|
||||
|
||||
remove_filter('pre_http_request', $mockRelease, 10);
|
||||
|
||||
assert_true(isset($updates->response[TEST_PLUGIN]), 'A newer GitHub release was not offered as a WordPress update.');
|
||||
assert_true($updates->response[TEST_PLUGIN]->new_version === '2.3.0', 'The offered plugin version was incorrect.');
|
||||
assert_true($updates->response[TEST_PLUGIN]->package === $packageUrl, 'The release package URL was incorrect.');
|
||||
|
||||
pass('Published GitHub releases are discovered by the WordPress updater');
|
||||
}
|
||||
|
||||
boot_wordpress();
|
||||
install_wordpress();
|
||||
activate_and_configure_plugin();
|
||||
@@ -285,5 +329,6 @@ wait_for_http();
|
||||
test_valid_authentication();
|
||||
test_invalid_authentication();
|
||||
test_debug_error_details();
|
||||
test_plugin_update_discovery();
|
||||
|
||||
echo "[OK] Authentication integration test passed\n";
|
||||
|
||||
Reference in New Issue
Block a user