/** * @covers ::buildOneAvailablePlugin */ public function testBuildOneAvailablePlugin() { $plugin_id = $this->randomMachineName(); $plugin_form = array('#type' => $this->randomMachineName()); $plugin = $this->getMockForAbstractClass(AdvancedPluginSelectorBaseUnitTestPluginFormPluginInterface::class); $plugin->expects($this->atLeastOnce())->method('getPluginId')->willReturn($plugin_id); $plugin->expects($this->once())->method('buildConfigurationForm')->willReturn($plugin_form); $element = array('#available_plugins' => array($plugin)); $form_state = $this->getMock(FormStateInterface::class); $form = []; $label = $this->randomMachineName(); $this->sut->setLabel($label); $expected_build = array('#available_plugins' => array($plugin), 'select' => array('message' => ['#title' => $label, '#type' => 'item'], 'container' => array('#type' => 'container', 'plugin_id' => array('#type' => 'value', '#value' => $plugin_id))), 'plugin_form' => array('#attributes' => array('class' => array('plugin-selector-' . Html::getId($this->pluginId) . '-plugin-form')), '#type' => 'container') + $plugin_form); $build = $this->sut->buildOneAvailablePlugin($element, $form_state, $form); unset($build['plugin_form']['#id']); $this->assertSame($expected_build, $build); }
/** * @covers ::setLabel * @covers ::getLabel */ public function testGetLabel() { $label = $this->randomMachineName(); $this->assertSame($this->sut, $this->sut->setLabel($label)); $this->assertSame($label, $this->sut->getLabel()); }