function EntityQueryTest::testBaseFieldMultipleColumns

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::testBaseFieldMultipleColumns()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::testBaseFieldMultipleColumns()
  3. 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php \Drupal\KernelTests\Core\Entity\EntityQueryTest::testBaseFieldMultipleColumns()

Test base fields with multiple columns.

File

core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php, line 968

Class

EntityQueryTest
Tests Entity Query functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testBaseFieldMultipleColumns() {
    $this->enableModules([
        'taxonomy',
    ]);
    $this->installEntitySchema('taxonomy_term');
    Vocabulary::create([
        'vid' => 'tags',
    ]);
    $term1 = Term::create([
        'name' => $this->randomMachineName(),
        'vid' => 'tags',
        'description' => [
            'value' => $this->randomString(),
            'format' => 'format1',
        ],
    ]);
    $term1->save();
    $term2 = Term::create([
        'name' => $this->randomMachineName(),
        'vid' => 'tags',
        'description' => [
            'value' => $this->randomString(),
            'format' => 'format2',
        ],
    ]);
    $term2->save();
    $ids = $this->container
        ->get('entity_type.manager')
        ->getStorage('taxonomy_term')
        ->getQuery()
        ->condition('description.format', 'format1')
        ->execute();
    $this->assertCount(1, $ids);
    $this->assertEqual($term1->id(), reset($ids));
}

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