You are here

public function QueryFactoryTest::providerTestGetKeys in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Config/Entity/Query/QueryFactoryTest.php \Drupal\Tests\Core\Config\Entity\Query\QueryFactoryTest::providerTestGetKeys()
  2. 9 core/tests/Drupal/Tests/Core/Config/Entity/Query/QueryFactoryTest.php \Drupal\Tests\Core\Config\Entity\Query\QueryFactoryTest::providerTestGetKeys()

File

core/tests/Drupal/Tests/Core/Config/Entity/Query/QueryFactoryTest.php, line 34

Class

QueryFactoryTest
@coversDefaultClass \Drupal\Core\Config\Entity\Query\QueryFactory @group Config

Namespace

Drupal\Tests\Core\Config\Entity\Query

Code

public function providerTestGetKeys() {
  $tests = [];
  $tests[] = [
    [
      'uuid:abc',
    ],
    'uuid',
    $this
      ->getConfigObject('test')
      ->set('uuid', 'abc'),
  ];

  // Tests a lookup being set to a top level key when sub-keys exist.
  $tests[] = [
    [],
    'uuid',
    $this
      ->getConfigObject('test')
      ->set('uuid.blah', 'abc'),
  ];

  // Tests a non existent key.
  $tests[] = [
    [],
    'uuid',
    $this
      ->getConfigObject('test'),
  ];

  // Tests a non existent sub key.
  $tests[] = [
    [],
    'uuid.blah',
    $this
      ->getConfigObject('test')
      ->set('uuid', 'abc'),
  ];

  // Tests an existent sub key.
  $tests[] = [
    [
      'uuid.blah:abc',
    ],
    'uuid.blah',
    $this
      ->getConfigObject('test')
      ->set('uuid.blah', 'abc'),
  ];

  // One wildcard.
  $tests[] = [
    [
      'test.*.value:a',
      'test.*.value:b',
    ],
    'test.*.value',
    $this
      ->getConfigObject('test')
      ->set('test.a.value', 'a')
      ->set('test.b.value', 'b'),
  ];

  // Three wildcards.
  $tests[] = [
    [
      'test.*.sub2.*.sub4.*.value:aaa',
      'test.*.sub2.*.sub4.*.value:aab',
      'test.*.sub2.*.sub4.*.value:bab',
    ],
    'test.*.sub2.*.sub4.*.value',
    $this
      ->getConfigObject('test')
      ->set('test.a.sub2.a.sub4.a.value', 'aaa')
      ->set('test.a.sub2.a.sub4.b.value', 'aab')
      ->set('test.b.sub2.a.sub4.b.value', 'bab'),
  ];

  // Three wildcards in a row.
  $tests[] = [
    [
      'test.*.*.*.value:abc',
      'test.*.*.*.value:abd',
    ],
    'test.*.*.*.value',
    $this
      ->getConfigObject('test')
      ->set('test.a.b.c.value', 'abc')
      ->set('test.a.b.d.value', 'abd'),
  ];
  return $tests;
}