Skip to content

Commit

Permalink
fix: improve error message when plugin is not downloadable
Browse files Browse the repository at this point in the history
  • Loading branch information
jsantos42 committed Oct 11, 2024
1 parent 47a5d2a commit 54017d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/Marketplace/Api/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ public function getDownloadUrl($pluginOrThemeName)
{
$plugin = $this->getPluginInfo($pluginOrThemeName);

if (empty($plugin['isDownloadable'])) {
throw new Exception('Plugin is not downloadable. License may be missing or expired.');
}

if (empty($plugin['versions'])) {
throw new Exception('Plugin has no versions.');
}
Expand Down
8 changes: 8 additions & 0 deletions plugins/Marketplace/tests/System/Api/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ public function testGetDownloadUrl()
$this->assertRegExp('/\d+\.\d+\.\d+/', $version);
}

public function testGetDownloadUrlMissingLicense()
{
$this->expectException(\Piwik\Plugins\Marketplace\Api\Exception::class);
$this->expectExceptionMessage('Plugin is not downloadable');

$this->client->getDownloadUrl('FormAnalytics');
}

public function testClientResponseShouldBeCached()
{
$params = array(
Expand Down

0 comments on commit 54017d8

Please sign in to comment.