You are here

public function ConfigEntityQueryTest::testDotted in Zircon Profile 8

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

Tests dotted path matching.

File

core/modules/system/src/Tests/Entity/ConfigEntityQueryTest.php, line 555
Contains \Drupal\system\Tests\Entity\ConfigEntityQueryTest.

Class

ConfigEntityQueryTest
Tests Config Entity Query functionality.

Namespace

Drupal\system\Tests\Entity

Code

public function testDotted() {
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->condition('array.level1.*', 1)
    ->execute();
  $this
    ->assertResults(array(
    '1',
    '3',
  ));
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->condition('*.level1.level2', 2)
    ->execute();
  $this
    ->assertResults(array(
    '2',
    '4',
  ));
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->condition('array.level1.*', 3)
    ->execute();
  $this
    ->assertResults(array(
    '5',
  ));
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->condition('array.level1.level2', 3)
    ->execute();
  $this
    ->assertResults(array(
    '5',
  ));

  // Make sure that values on the wildcard level do not match if there are
  // sub-keys defined. This must not find anything even if entity 2 has a
  // top-level key number with value 41.
  $this->queryResults = $this->factory
    ->get('config_query_test')
    ->condition('*.level1.level2', 41)
    ->execute();
  $this
    ->assertResults(array());
}