public function HookFivestarWidgetsTest::testWidgetDiscovery in Fivestar 8
Tests finding widgets defined by hook_fivestar_widgets().
File
- tests/
src/ Kernel/ HookFivestarWidgetsTest.php, line 42
Class
- HookFivestarWidgetsTest
- Tests the operation of hook_fivestar_widgets().
Namespace
Drupal\Tests\fivestar\KernelCode
public function testWidgetDiscovery() {
$expected = [
// Awesome Stars is defined in the fivestar_widget_provider module.
'awesome' => [
'library' => 'fivestar_widget_provider/awesome',
'label' => 'Awesome Stars',
],
// Cools Stars is defined in the fivestar_widget_provider module.
'cool' => [
'library' => 'fivestar_widget_provider/cool',
'label' => 'Cool Stars',
],
];
// Invoke the hook and collect all defined widgets.
$widgets = $this->widgetManager
->getWidgets();
// Verify "Awesome Stars" was discovered.
$this
->assertArrayHasKey('awesome', $widgets);
$this
->assertEquals($expected['awesome']['label'], $widgets['awesome']['label']);
$this
->assertEquals($expected['awesome']['library'], $widgets['awesome']['library']);
// Verify "Cool Stars" was discovered.
$this
->assertArrayHasKey('cool', $widgets);
$this
->assertEquals($expected['cool']['label'], $widgets['cool']['label']);
$this
->assertEquals($expected['cool']['library'], $widgets['cool']['library']);
}