function TypedDataDefinitionTest::testNotImplementedGetType

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/TypedData/TypedDataDefinitionTest.php \Drupal\KernelTests\Core\TypedData\TypedDataDefinitionTest::testNotImplementedGetType()

Tests getString() throws exception when getType() is not implemented.

File

core/tests/Drupal/KernelTests/Core/TypedData/TypedDataDefinitionTest.php, line 108

Class

TypedDataDefinitionTest
Tests deriving metadata of core data types.

Namespace

Drupal\KernelTests\Core\TypedData

Code

public function testNotImplementedGetType() : void {
    $language_reference_definition = DataReferenceDefinition::create('language');
    $language_reference = $this->typedDataManager
        ->create($language_reference_definition);
    $this->assertInstanceOf(DataReferenceInterface::class, $language_reference);
    $this->expectException(\BadMethodCallException::class);
    $this->expectExceptionMessageMatches('/getType\\(\\) not implemented/');
    $language_reference->getString();
}

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