protected function ConfigEntityQueryTest::testDotted

Tests dotted path matching.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Entity/ConfigEntityQueryTest.php, line 432
Contains \Drupal\system\Tests\ConfigEntityQueryTest.

Class

ConfigEntityQueryTest
Tests the config entity query.

Namespace

Drupal\system\Tests\Entity

Code

protected 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 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());
}