UiPatternsSourceManagerTest.php in UI Patterns 8
File
tests/src/Kernel/UiPatternsSourceManagerTest.php
View source
<?php
namespace Drupal\Tests\ui_patterns\Kernel;
class UiPatternsSourceManagerTest extends AbstractUiPatternsTest {
public static $modules = [
'ui_patterns',
'ui_patterns_field_source_test',
];
public function testProcessDefinition() {
$plugin_manager = \Drupal::service('plugin.manager.ui_patterns_source');
$definitions = $plugin_manager
->getDefinitions();
$this
->assertNotEmpty($definitions);
$this
->assertArrayHasKey('test_source', $definitions);
$expected = [
[
'name' => 'field_1',
'label' => 'Field 1',
],
[
'name' => 'field_2',
'label' => 'Field 2',
],
[
'name' => 'field_3',
'label' => 'Field 3',
],
[
'name' => 'field_4',
'label' => 'Field 4',
],
[
'name' => 'field_5',
'label' => 'Field 5',
],
];
$plugin = $plugin_manager
->createInstance('test_source');
foreach ($plugin
->getSourceFields() as $key => $field) {
$this
->assertEquals($expected[$key]['name'], $field
->getFieldName());
$this
->assertEquals($expected[$key]['label'], $field
->getFieldLabel());
}
}
}