OptionsSelectDynamicValuesTest.php

Same filename in other branches
  1. 9 core/modules/options/tests/src/Functional/OptionsSelectDynamicValuesTest.php
  2. 10 core/modules/options/tests/src/Functional/OptionsSelectDynamicValuesTest.php
  3. 11.x core/modules/options/tests/src/Functional/OptionsSelectDynamicValuesTest.php

Namespace

Drupal\Tests\options\Functional

File

core/modules/options/tests/src/Functional/OptionsSelectDynamicValuesTest.php

View source
<?php

namespace Drupal\Tests\options\Functional;


/**
 * Tests an options select with a dynamic allowed values function.
 *
 * @group options
 */
class OptionsSelectDynamicValuesTest extends OptionsDynamicValuesTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected $defaultTheme = 'stark';
    
    /**
     * Tests the 'options_select' widget (single select).
     */
    public function testSelectListDynamic() {
        // Create an entity.
        $this->entity
            ->save();
        // Create a web user.
        $web_user = $this->drupalCreateUser([
            'view test entity',
            'administer entity_test content',
        ]);
        $this->drupalLogin($web_user);
        // Display form.
        $this->drupalGet('entity_test_rev/manage/' . $this->entity
            ->id() . '/edit');
        $options = $this->xpath('//select[@id="edit-test-options"]/option');
        $this->assertEqual(count($options), count($this->test) + 1);
        foreach ($options as $option) {
            $value = $option->getValue();
            if ($value != '_none') {
                $this->assertContains($value, $this->test);
            }
        }
    }

}

Classes

Title Deprecated Summary
OptionsSelectDynamicValuesTest Tests an options select with a dynamic allowed values function.

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