function EntityQueryRelationshipTest::testInvalidFieldName

Tests a non-existent field name in a complex query relationship.

@dataProvider providerTestInvalidFieldName

File

core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php, line 233

Class

EntityQueryRelationshipTest
Tests the Entity Query relationship API.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testInvalidFieldName(string $field_name) : void {
    $this->expectException(QueryException::class);
    $this->expectExceptionMessage("'non_existent_field_name' not found");
    // Check that non-existent field names in a complex relationship query
    // throws a meaningful exception.
    $this->container
        ->get('entity_type.manager')
        ->getStorage('entity_test')
        ->getQuery()
        ->accessCheck()
        ->condition($field_name, $this->randomString(), '=')
        ->execute();
}

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