HookFivestarWidgetsTest.php in Fivestar 8
File
tests/src/Kernel/HookFivestarWidgetsTest.php
View source
<?php
namespace Drupal\Tests\fivestar\Kernel;
use Drupal\KernelTests\KernelTestBase;
class HookFivestarWidgetsTest extends KernelTestBase {
protected $widgetManager;
protected static $modules = [
'votingapi',
'fivestar',
'fivestar_widget_provider',
];
protected function setUp() {
parent::setUp();
$this->widgetManager = $this->container
->get('fivestar.widget_manager');
}
public function testWidgetDiscovery() {
$expected = [
'awesome' => [
'library' => 'fivestar_widget_provider/awesome',
'label' => 'Awesome Stars',
],
'cool' => [
'library' => 'fivestar_widget_provider/cool',
'label' => 'Cool Stars',
],
];
$widgets = $this->widgetManager
->getWidgets();
$this
->assertArrayHasKey('awesome', $widgets);
$this
->assertEquals($expected['awesome']['label'], $widgets['awesome']['label']);
$this
->assertEquals($expected['awesome']['library'], $widgets['awesome']['library']);
$this
->assertArrayHasKey('cool', $widgets);
$this
->assertEquals($expected['cool']['label'], $widgets['cool']['label']);
$this
->assertEquals($expected['cool']['library'], $widgets['cool']['library']);
}
}