OptionsDynamicValuesApiTest.php

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

Namespace

Drupal\Tests\options\Functional

File

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

View source
<?php

namespace Drupal\Tests\options\Functional;


/**
 * Tests the options allowed values api.
 *
 * @group options
 */
class OptionsDynamicValuesApiTest extends OptionsDynamicValuesTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected $defaultTheme = 'stark';
    
    /**
     * Tests options_allowed_values().
     *
     * @see options_test_dynamic_values_callback()
     */
    public function testOptionsAllowedValues() {
        // Test allowed values without passed $items.
        $values = options_allowed_values($this->fieldStorage);
        $this->assertEquals([], $values);
        $values = options_allowed_values($this->fieldStorage, $this->entity);
        $expected_values = [
            $this->entity
                ->label(),
            $this->entity
                ->toUrl()
                ->toString(),
            $this->entity
                ->uuid(),
            $this->entity
                ->bundle(),
        ];
        $expected_values = array_combine($expected_values, $expected_values);
        $this->assertEquals($expected_values, $values);
    }

}

Classes

Title Deprecated Summary
OptionsDynamicValuesApiTest Tests the options allowed values api.

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