Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3424701
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3424701
Commits
efe11919
Verified
Commit
efe11919
authored
11 months ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3439039
by mondrake: Change QueryFactoryTest:providerTestGetKeys to static
parent
c0a39c90
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/tests/Drupal/Tests/Core/Config/Entity/Query/QueryFactoryTest.php
+33
-28
33 additions, 28 deletions
...rupal/Tests/Core/Config/Entity/Query/QueryFactoryTest.php
with
33 additions
and
28 deletions
core/tests/Drupal/Tests/Core/Config/Entity/Query/QueryFactoryTest.php
+
33
−
28
View file @
efe11919
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
use
Drupal\Core\Config\Config
;
use
Drupal\Core\Config\Config
;
use
Drupal\Core\Config\Entity\Query\QueryFactory
;
use
Drupal\Core\Config\Entity\Query\QueryFactory
;
use
Drupal\Tests\UnitTestCase
;
use
Drupal\Tests\UnitTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
/**
/**
* @coversDefaultClass \Drupal\Core\Config\Entity\Query\QueryFactory
* @coversDefaultClass \Drupal\Core\Config\Entity\Query\QueryFactory
...
@@ -20,7 +21,11 @@ class QueryFactoryTest extends UnitTestCase {
...
@@ -20,7 +21,11 @@ class QueryFactoryTest extends UnitTestCase {
*
*
* @dataProvider providerTestGetKeys
* @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'
);
$config_factory
=
$this
->
createMock
(
'Drupal\Core\Config\ConfigFactoryInterface'
);
$key_value_factory
=
$this
->
createMock
(
'Drupal\Core\KeyValueStore\KeyValueFactoryInterface'
);
$key_value_factory
=
$this
->
createMock
(
'Drupal\Core\KeyValueStore\KeyValueFactoryInterface'
);
$config_manager
=
$this
->
createMock
(
'Drupal\Core\Config\ConfigManagerInterface'
);
$config_manager
=
$this
->
createMock
(
'Drupal\Core\Config\ConfigManagerInterface'
);
...
@@ -32,68 +37,68 @@ public function testGetKeys(array $expected, $key, Config $config) {
...
@@ -32,68 +37,68 @@ public function testGetKeys(array $expected, $key, Config $config) {
$this
->
assertEquals
(
$expected
,
$actual
);
$this
->
assertEquals
(
$expected
,
$actual
);
}
}
public
function
providerTestGetKeys
()
{
public
static
function
providerTestGetKeys
():
\Generator
{
$tests
=
[];
yield
[
$tests
[]
=
[
[
'uuid:abc'
],
[
'uuid:abc'
],
'uuid'
,
'uuid'
,
$this
->
getConfigObject
(
'test'
)
->
set
(
'uuid'
,
'abc'
)
,
[[
'uuid'
,
'abc'
]]
,
];
];
// Tests a lookup being set to a top level key when sub-keys exist.
// Tests a lookup being set to a top level key when sub-keys exist.
$tests
[]
=
[
yield
[
[],
[],
'uuid'
,
'uuid'
,
$this
->
getConfigObject
(
'test'
)
->
set
(
'uuid.blah'
,
'abc'
)
,
[[
'uuid.blah'
,
'abc'
]]
,
];
];
// Tests a non existent key.
// Tests a non existent key.
$tests
[]
=
[
yield
[
[],
[],
'uuid'
,
'uuid'
,
$this
->
getConfigObject
(
'test'
)
,
[]
,
];
];
// Tests a non existent sub key.
// Tests a non existent sub key.
$tests
[]
=
[
yield
[
[],
[],
'uuid.blah'
,
'uuid.blah'
,
$this
->
getConfigObject
(
'test'
)
->
set
(
'uuid'
,
'abc'
)
,
[[
'uuid'
,
'abc'
]]
,
];
];
// Tests an existent sub key.
// Tests an existent sub key.
$tests
[]
=
[
yield
[
[
'uuid.blah:abc'
],
[
'uuid.blah:abc'
],
'uuid.blah'
,
'uuid.blah'
,
$this
->
getConfigObject
(
'test'
)
->
set
(
'uuid.blah'
,
'abc'
)
,
[[
'uuid.blah'
,
'abc'
]]
,
];
];
// One wildcard.
// One wildcard.
$tests
[]
=
[
yield
[
[
'test.*.value:a'
,
'test.*.value:b'
],
[
'test.*.value:a'
,
'test.*.value:b'
],
'test.*.value'
,
'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.
// Three wildcards.
$tests
[]
=
[
yield
[
[
'test.*.sub2.*.sub4.*.value:aaa'
,
'test.*.sub2.*.sub4.*.value:aab'
,
'test.*.sub2.*.sub4.*.value:bab'
],
[
'test.*.sub2.*.sub4.*.value:aaa'
,
'test.*.sub2.*.sub4.*.value:aab'
,
'test.*.sub2.*.sub4.*.value:bab'
],
'test.*.sub2.*.sub4.*.value'
,
'test.*.sub2.*.sub4.*.value'
,
$this
->
getConfigObject
(
'test'
)
[
->
set
(
'test.a.sub2.a.sub4.a.value'
,
'aaa'
)
[
'test.a.sub2.a.sub4.a.value'
,
'aaa'
],
->
set
(
'test.a.sub2.a.sub4.b.value'
,
'aab'
)
[
'test.a.sub2.a.sub4.b.value'
,
'aab'
],
->
set
(
'test.b.sub2.a.sub4.b.value'
,
'bab'
),
[
'test.b.sub2.a.sub4.b.value'
,
'bab'
],
],
];
];
// Three wildcards in a row.
// Three wildcards in a row.
$tests
[]
=
[
yield
[
[
'test.*.*.*.value:abc'
,
'test.*.*.*.value:abd'
],
[
'test.*.*.*.value:abc'
,
'test.*.*.*.value:abd'
],
'test.*.*.*.value'
,
'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() {
...
@@ -122,11 +127,11 @@ public function testGetKeysWildCardEnd() {
* @param string $name
* @param string $name
* The config 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.
* The test configuration object.
*/
*/
protected
function
getConfigObject
(
$name
)
{
protected
function
getConfigObject
(
string
$name
):
Config
&
MockObject
{
$config
=
$this
->
getMockBuilder
(
'Drupal\Core\Config\Config'
)
$config
=
$this
->
getMockBuilder
(
Config
::
class
)
->
disableOriginalConstructor
()
->
disableOriginalConstructor
()
->
onlyMethods
([
'save'
,
'delete'
])
->
onlyMethods
([
'save'
,
'delete'
])
->
getMock
();
->
getMock
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment