Fix Gitea release fetch: /releases/latest returns a single object, not an array
Release / Build & publish plugin zip (push) Successful in 7s

This commit is contained in:
Keith Solomon
2026-08-11 16:52:27 -05:00
parent 365a3898b9
commit aab39f66af
2 changed files with 30 additions and 1 deletions
+23
View File
@@ -136,6 +136,29 @@ class Gitea_Provider_Test extends \PHPUnit\Framework\TestCase {
);
}
public function test_release_object_shape_picks_first_tag_from_object(): void {
// Gitea's /releases/latest returns a single release OBJECT (associative array),
// not a list. The implementation must accept either shape.
$body = json_encode( [
'tag_name' => 'v2.1.0',
'name' => 'v2.1.0',
'assets' => [
[ 'name' => 'release.zip', 'browser_download_url' => 'https://example/release.zip' ],
],
] );
\Brain\Monkey\Functions\expect( 'wp_remote_get' )
->twice() // get_release_url and get_latest_version both fetch
->andReturn( [
'response' => [ 'code' => 200 ],
'headers' => [],
'body' => $body,
] );
$provider = $this->make();
$this->assertSame( 'https://example/release.zip', $provider->get_release_url() );
$this->assertSame( 'v2.1.0', $provider->get_latest_version() );
}
public function test_release_url_empty_array_returns_null(): void {
\Brain\Monkey\Functions\expect( 'wp_remote_get' )
->once()