You are here

public function EntityQueryTest::testBaseFieldMultipleColumns in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/EntityQueryTest.php \Drupal\system\Tests\Entity\EntityQueryTest::testBaseFieldMultipleColumns()

Test base fields with multiple columns.

File

core/modules/system/src/Tests/Entity/EntityQueryTest.php, line 778
Contains \Drupal\system\Tests\Entity\EntityQueryTest.

Class

EntityQueryTest
Tests Entity Query functionality.

Namespace

Drupal\system\Tests\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' => array(
      'value' => $this
        ->randomString(),
      'format' => 'format1',
    ),
  ]);
  $term1
    ->save();
  $term2 = Term::create([
    'name' => $this
      ->randomMachineName(),
    'vid' => 'tags',
    'description' => array(
      'value' => $this
        ->randomString(),
      'format' => 'format2',
    ),
  ]);
  $term2
    ->save();
  $ids = \Drupal::entityQuery('taxonomy_term')
    ->condition('description.format', 'format1')
    ->execute();
  $this
    ->assertEqual(count($ids), 1);
  $this
    ->assertEqual($term1
    ->id(), reset($ids));
}