Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Jan 18, 2025
1 parent fe33f5d commit 954c07c
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/Plugin/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Closure;
use Composer\InstalledVersions;
use Exception;
use Kirby\Cms\App;
use Kirby\Cms\Helpers;
use Kirby\Cms\System\UpdateStatus;
Expand Down
2 changes: 1 addition & 1 deletion tests/Panel/Areas/SystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function unknownLicenseStatus(): array
'dialog' => null,
'drawer' => null,
'icon' => 'question',
'label' => 'Unknown license',
'label' => 'Unknown',
'link' => null,
'theme' => 'passive',
'value' => 'unknown',
Expand Down
56 changes: 52 additions & 4 deletions tests/Plugin/LicenseStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,36 @@ public function testFromArray(): void
$this->assertSame('active', $status->value());
}

/**
* @covers ::dialog
*/
public function testDialog(): void
{
$status = new LicenseStatus(
value: 'missing',
icon: 'alert',
label: 'Enter license',
dialog: $dialog = 'my/dialog'
);

$this->assertSame($dialog, $status->dialog());
}

/**
* @covers ::drawer
*/
public function testDrawer(): void
{
$status = new LicenseStatus(
value: 'missing',
icon: 'alert',
label: 'Enter license',
drawer: $drawer = 'my/drawer'
);

$this->assertSame($drawer, $status->drawer());
}

/**
* @covers ::from
*/
Expand Down Expand Up @@ -112,6 +142,21 @@ public function testLabel(): void
$this->assertSame('Valid license', $status->label());
}

/**
* @covers ::link
*/
public function testLink(): void
{
$status = new LicenseStatus(
value: 'missing',
icon: 'alert',
label: 'Buy license',
link: $url = 'https://getkirby.com/buy'
);

$this->assertSame($url, $status->link());
}

/**
* @covers ::theme
*/
Expand Down Expand Up @@ -139,10 +184,13 @@ public function testToArray(): void
);

$this->assertSame([
'icon' => 'check',
'label' => 'Valid license',
'theme' => null,
'value' => 'active'
'dialog' => null,
'drawer' => null,
'icon' => 'check',
'label' => 'Valid license',
'link' => null,
'theme' => null,
'value' => 'active'
], $status->toArray());
}

Expand Down
11 changes: 7 additions & 4 deletions tests/Plugin/LicenseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,13 @@ public function testToArray(): void
'link' => null,
'name' => 'Custom license',
'status' => [
'icon' => 'question',
'label' => 'Unknown license',
'theme' => 'passive',
'value' => 'unknown',
'dialog' => null,
'drawer' => null,
'icon' => 'question',
'label' => 'Unknown',
'link' => null,
'theme' => 'passive',
'value' => 'unknown',
]
], $license->toArray());
}
Expand Down
24 changes: 19 additions & 5 deletions tests/Plugin/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,22 @@ public function testInfoFromProps()
$plugin = new Plugin(
name: 'getkirby/test-plugin',
info: [
'license' => 'MIT'
'license' => 'MIT',
'authors' => [
[
'name' => 'A',
'email' => '[email protected]'
],
[
'name' => 'B',
'email' => '[email protected]'
]
]
]
);

$this->assertSame('MIT', $plugin->info()['license']);
$this->assertSame('A, B', $plugin->authorsNames());
}

/**
Expand Down Expand Up @@ -473,10 +484,13 @@ public function testToArray()
'link' => null,
'name' => 'MIT',
'status' => [
'icon' => 'check',
'label' => 'Valid license',
'theme' => 'positive',
'value' => 'active',
'dialog' => null,
'drawer' => null,
'icon' => 'check',
'label' => 'Valid license',
'link' => null,
'theme' => 'positive',
'value' => 'active',
]
],
'link' => 'https://getkirby.com',
Expand Down

0 comments on commit 954c07c

Please sign in to comment.