function ExtractorTest::testBuildConfigurationForm

Test the IconExtractorBase::buildConfigurationForm.

File

core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/ExtractorTest.php, line 49

Class

ExtractorTest
Tests icon extractor with base and finder base plugin.

Namespace

Drupal\Tests\Core\Theme\Icon\Plugin

Code

public function testBuildConfigurationForm() : void {
    // Test no settings.
    $extractorPlugin = new TestExtractor([], $this->pluginId, []);
    $form_state = $this->getMockBuilder('Drupal\\Core\\Form\\FormState')
        ->disableOriginalConstructor()
        ->getMock();
    $result = $extractorPlugin->buildConfigurationForm([], $form_state);
    $this->assertEmpty($result);
    // Test with settings.
    $extractorPlugin = new TestExtractor([
        'settings' => [
            'foo' => [
                'type' => 'string',
            ],
        ],
    ], $this->pluginId, []);
    $subform_state = $this->createMock(SubformStateInterface::class);
    $form_state = $this->createMock(SubformStateInterface::class);
    $form_state->method('getCompleteFormState')
        ->willReturn($subform_state);
    $result = $extractorPlugin->buildConfigurationForm([], $form_state);
    $expected = [
        'foo' => [
            '#title' => 'foo',
            '#type' => 'textfield',
        ],
    ];
    $this->assertSame($expected, $result);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.