Skip to content
Snippets Groups Projects
Verified Commit 24a5b5a5 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3439039 by mondrake: Change QueryFactoryTest:providerTestGetKeys to static

(cherry picked from commit efe11919)
parent 4cca1a28
Branches
Tags
5 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type"
Pipeline #140603 passed with warnings
Pipeline: drupal

#140637

    Pipeline: drupal

    #140633

      Pipeline: drupal

      #140632

        +7
        ......@@ -7,6 +7,7 @@
        use Drupal\Core\Config\Config;
        use Drupal\Core\Config\Entity\Query\QueryFactory;
        use Drupal\Tests\UnitTestCase;
        use PHPUnit\Framework\MockObject\MockObject;
        /**
        * @coversDefaultClass \Drupal\Core\Config\Entity\Query\QueryFactory
        ......@@ -20,7 +21,11 @@ class QueryFactoryTest extends UnitTestCase {
        *
        * @dataProvider providerTestGetKeys
        */
        public function testGetKeys(array $expected, $key, Config $config) {
        public function testGetKeys(array $expected, string $key, array $sets): void {
        $config = $this->getConfigObject('test');
        foreach ($sets as $set) {
        $config->set(...$set);
        }
        $config_factory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface');
        $key_value_factory = $this->createMock('Drupal\Core\KeyValueStore\KeyValueFactoryInterface');
        $config_manager = $this->createMock('Drupal\Core\Config\ConfigManagerInterface');
        ......@@ -32,68 +37,68 @@ public function testGetKeys(array $expected, $key, Config $config) {
        $this->assertEquals($expected, $actual);
        }
        public function providerTestGetKeys() {
        $tests = [];
        $tests[] = [
        public static function providerTestGetKeys(): \Generator {
        yield [
        ['uuid:abc'],
        'uuid',
        $this->getConfigObject('test')->set('uuid', 'abc'),
        [['uuid', 'abc']],
        ];
        // Tests a lookup being set to a top level key when sub-keys exist.
        $tests[] = [
        yield [
        [],
        'uuid',
        $this->getConfigObject('test')->set('uuid.blah', 'abc'),
        [['uuid.blah', 'abc']],
        ];
        // Tests a non existent key.
        $tests[] = [
        yield [
        [],
        'uuid',
        $this->getConfigObject('test'),
        [],
        ];
        // Tests a non existent sub key.
        $tests[] = [
        yield [
        [],
        'uuid.blah',
        $this->getConfigObject('test')->set('uuid', 'abc'),
        [['uuid', 'abc']],
        ];
        // Tests an existent sub key.
        $tests[] = [
        yield [
        ['uuid.blah:abc'],
        'uuid.blah',
        $this->getConfigObject('test')->set('uuid.blah', 'abc'),
        [['uuid.blah', 'abc']],
        ];
        // One wildcard.
        $tests[] = [
        yield [
        ['test.*.value:a', 'test.*.value:b'],
        'test.*.value',
        $this->getConfigObject('test')->set('test.a.value', 'a')->set('test.b.value', 'b'),
        [['test.a.value', 'a'], ['test.b.value', 'b']],
        ];
        // Three wildcards.
        $tests[] = [
        yield [
        ['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'),
        [
        ['test.a.sub2.a.sub4.a.value', 'aaa'],
        ['test.a.sub2.a.sub4.b.value', 'aab'],
        ['test.b.sub2.a.sub4.b.value', 'bab'],
        ],
        ];
        // Three wildcards in a row.
        $tests[] = [
        yield [
        ['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'),
        [
        ['test.a.b.c.value', 'abc'],
        ['test.a.b.d.value', 'abd'],
        ],
        ];
        return $tests;
        }
        /**
        ......@@ -122,11 +127,11 @@ public function testGetKeysWildCardEnd() {
        * @param string $name
        * The config name.
        *
        * @return \Drupal\Core\Config\Config|\PHPUnit\Framework\MockObject\MockObject
        * @return \Drupal\Core\Config\Config&\PHPUnit\Framework\MockObject\MockObject
        * The test configuration object.
        */
        protected function getConfigObject($name) {
        $config = $this->getMockBuilder('Drupal\Core\Config\Config')
        protected function getConfigObject(string $name): Config&MockObject {
        $config = $this->getMockBuilder(Config::class)
        ->disableOriginalConstructor()
        ->onlyMethods(['save', 'delete'])
        ->getMock();
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment