2014-05-14 13:24:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
2014-09-20 10:33:09 +00:00
|
|
|
use Backend\Classes\Controller;
|
2014-05-14 13:24:20 +00:00
|
|
|
use Backend\Classes\WidgetManager;
|
|
|
|
|
|
2020-02-07 08:59:39 +00:00
|
|
|
class WidgetManagerTest extends TestCase
|
2014-05-14 13:24:20 +00:00
|
|
|
{
|
|
|
|
|
public function testListFormWidgets()
|
|
|
|
|
{
|
|
|
|
|
$manager = WidgetManager::instance();
|
|
|
|
|
$widgets = $manager->listFormWidgets();
|
|
|
|
|
|
2015-07-25 01:05:58 +00:00
|
|
|
$this->assertArrayHasKey('TestVendor\Test\FormWidgets\Sample', $widgets);
|
|
|
|
|
$this->assertArrayHasKey('October\Tester\FormWidgets\Preview', $widgets);
|
2014-05-14 13:24:20 +00:00
|
|
|
}
|
2017-05-30 21:49:35 +00:00
|
|
|
|
|
|
|
|
public function testIfWidgetsCanBeExtended()
|
|
|
|
|
{
|
|
|
|
|
$manager = WidgetManager::instance();
|
|
|
|
|
$manager->registerReportWidget('Acme\Fake\ReportWidget\HelloWorld', [
|
|
|
|
|
'name' => 'Hello World Test',
|
|
|
|
|
'context' => 'dashboard'
|
|
|
|
|
]);
|
|
|
|
|
$widgets = $manager->listReportWidgets();
|
|
|
|
|
|
|
|
|
|
$this->assertArrayHasKey('Acme\Fake\ReportWidget\HelloWorld', $widgets);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testIfWidgetsCanBeRemoved()
|
|
|
|
|
{
|
|
|
|
|
$manager = WidgetManager::instance();
|
|
|
|
|
$manager->registerReportWidget('Acme\Fake\ReportWidget\HelloWorld', [
|
|
|
|
|
'name' => 'Hello World Test',
|
|
|
|
|
'context' => 'dashboard'
|
|
|
|
|
]);
|
|
|
|
|
$manager->registerReportWidget('Acme\Fake\ReportWidget\ByeWorld', [
|
|
|
|
|
'name' => 'Hello World Bye',
|
|
|
|
|
'context' => 'dashboard'
|
|
|
|
|
]);
|
|
|
|
|
|
2017-06-02 14:51:13 +00:00
|
|
|
$manager->removeReportWidget('Acme\Fake\ReportWidget\ByeWorld');
|
2017-05-30 21:49:35 +00:00
|
|
|
|
|
|
|
|
$widgets = $manager->listReportWidgets();
|
|
|
|
|
|
|
|
|
|
$this->assertCount(1, $widgets);
|
|
|
|
|
}
|
2017-04-24 11:38:19 +00:00
|
|
|
}
|