Same name and namespace in other branches
  1. 8.x-2.x tests/src/Functional/ColorFieldWidgetTest.php \Drupal\Tests\color_field\Functional\ColorFieldWidgetTest 1 comment

Tests color field widgets.

@group color_field

Hierarchy

  • class \Drupal\Tests\color_field\Functional\ColorFieldFunctionalTestBase extends \Drupal\Tests\BrowserTestBase
    • class \Drupal\Tests\color_field\Functional\ColorFieldWidgetTest extends \Drupal\Tests\color_field\Functional\ColorFieldFunctionalTestBase

Expanded class hierarchy of ColorFieldWidgetTest

File

tests/src/Functional/ColorFieldWidgetTest.php, line 12

Namespace

Drupal\Tests\color_field\Functional
View source
class ColorFieldWidgetTest extends ColorFieldFunctionalTestBase {
    
    /**
     * Test color_field_widget_html5.
     */
    public function testColorFieldWidgetHtml5() : void {
        $this->form
            ->setComponent('field_color', [
            'type' => 'color_field_widget_html5',
        ])
            ->save();
        $this->display
            ->setComponent('field_color', [
            'type' => 'color_field_formatter_text',
            'weight' => 1,
        ])
            ->save();
        $session = $this->assertSession();
        // Confirm field label and description are rendered.
        $this->drupalGet('node/add/article');
        $session->fieldExists("field_color[0][color]");
        $session->fieldExists("field_color[0][opacity]");
        $session->responseContains('Freeform Color');
        $session->responseContains('Color field description');
        // Test basic entry of color field.
        $edit = [
            'title[0][value]' => $this->randomMachineName(),
            'field_color[0][color]' => "#E70000",
            'field_color[0][opacity]' => 1,
        ];
        $this->submitForm($edit, t('Save'));
        $session->responseContains('#E70000 1</div>');
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
ColorFieldFunctionalTestBase::$defaultTheme protected property
ColorFieldFunctionalTestBase::$display protected property The Entity View Display for the article node type.
ColorFieldFunctionalTestBase::$form protected property The Entity Form Display for the article node type.
ColorFieldFunctionalTestBase::$modules protected static property Modules to enable. 1
ColorFieldFunctionalTestBase::setUp protected function
ColorFieldWidgetTest::testColorFieldWidgetHtml5 public function Test color_field_widget_html5.