Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3101671
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-3101671
Commits
bc0b5a19
Verified
Commit
bc0b5a19
authored
1 year ago
by
Dave Long
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3422095
by mondrake: Change ConstraintTest::providerIsCompatible and family to static
parent
9b73314e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/tests/Drupal/Tests/Component/Version/ConstraintTest.php
+34
-34
34 additions, 34 deletions
core/tests/Drupal/Tests/Component/Version/ConstraintTest.php
with
34 additions
and
34 deletions
core/tests/Drupal/Tests/Component/Version/ConstraintTest.php
+
34
−
34
View file @
bc0b5a19
...
...
@@ -17,14 +17,14 @@ class ConstraintTest extends TestCase {
* @covers ::isCompatible
* @dataProvider providerIsCompatible
*/
public
function
testIsCompatible
(
Constraint
$version_info
,
$current_version
,
$result
)
{
public
function
testIsCompatible
(
Constraint
$version_info
,
string
$current_version
,
bool
$result
)
:
void
{
$this
->
assertSame
(
$result
,
$version_info
->
isCompatible
(
$current_version
));
}
/**
* Provider for testIsCompatible.
*/
public
function
providerIsCompatible
()
{
public
static
function
providerIsCompatible
()
:
array
{
$tests
=
[];
$tests
[
'no-dependencies'
]
=
[
new
Constraint
(
''
,
'8.x'
),
'8.1.x'
,
TRUE
];
...
...
@@ -42,8 +42,8 @@ public function providerIsCompatible() {
'>= 1.0, <= 2.0'
,
];
foreach
(
$whitespace_variation_constraints
as
$whitespace_variation_constraint
)
{
$tests
+=
$this
->
createTestsForVersions
(
$whitespace_variation_constraint
,
[
'1.0'
,
'2.0'
,
'1.5'
],
TRUE
,
'8.x'
);
$tests
+=
$this
->
createTestsForVersions
(
$whitespace_variation_constraint
,
[
'0.9'
,
'2.1'
],
FALSE
,
'8.x'
);
$tests
+=
self
::
createTestsForVersions
(
$whitespace_variation_constraint
,
[
'1.0'
,
'2.0'
,
'1.5'
],
TRUE
,
'8.x'
);
$tests
+=
self
::
createTestsForVersions
(
$whitespace_variation_constraint
,
[
'0.9'
,
'2.1'
],
FALSE
,
'8.x'
);
}
// We support both '=' and '==' for the equal operator. If no operator is
...
...
@@ -62,89 +62,89 @@ public function providerIsCompatible() {
else
{
$constraint
=
"< 8.x-4.x, > 8.x-1.x"
;
}
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'4.0'
,
'3.9'
,
'2.1'
,
'1.9'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'4.0'
,
'3.9'
,
'2.1'
,
'1.9'
],
FALSE
,
$core_compatibility
);
// Stable version. For example "=8.x-1.0".
$constraint
=
"
{
$equal_operator
}
$core_compatibility
-1.0"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.0'
],
TRUE
,
$core_compatibility
);
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.1'
,
'0.9'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.0'
],
TRUE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.1'
,
'0.9'
],
FALSE
,
$core_compatibility
);
// Alpha version. For example "=8.x-1.1-alpha12".
$constraint
=
"
{
$equal_operator
}
$core_compatibility
-1.1-alpha12"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.1-alpha12'
],
TRUE
,
$core_compatibility
);
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.1-alpha10'
,
'1.1-beta1'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.1-alpha12'
],
TRUE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.1-alpha10'
,
'1.1-beta1'
],
FALSE
,
$core_compatibility
);
// Beta version. For example "=8.x-1.1-beta8".
$constraint
=
"
{
$equal_operator
}
$core_compatibility
-1.1-beta8"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.1-beta8'
],
TRUE
,
$core_compatibility
);
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.1-beta4'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.1-beta8'
],
TRUE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.1-beta4'
],
FALSE
,
$core_compatibility
);
// RC version. For example "=8.x-1.1-rc11".
$constraint
=
"
{
$equal_operator
}
$core_compatibility
-1.1-rc11"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.1-rc11'
],
TRUE
,
$core_compatibility
);
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.1-rc2'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.1-rc11'
],
TRUE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.1-rc2'
],
FALSE
,
$core_compatibility
);
// Test greater than. For example ">8.x-1.x".
$constraint
=
">
$core_compatibility
-1.x"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'2.0'
],
TRUE
,
$core_compatibility
);
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.1'
,
'0.9'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'2.0'
],
TRUE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.1'
,
'0.9'
],
FALSE
,
$core_compatibility
);
// Test greater than or equal ">=8.x-1.0".
$tests
+=
$this
->
createTestsForVersions
(
">=
$core_compatibility
-1.0"
,
[
'1.1'
,
'1.0'
],
TRUE
,
$core_compatibility
);
$tests
+=
$this
->
createTestsForVersions
(
">=
$core_compatibility
-1.1"
,
[
'1.0'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
">=
$core_compatibility
-1.0"
,
[
'1.1'
,
'1.0'
],
TRUE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
">=
$core_compatibility
-1.1"
,
[
'1.0'
],
FALSE
,
$core_compatibility
);
// Test less than. For examples"<8.x-1.1".
$constraint
=
"<
$core_compatibility
-1.1"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.1'
],
FALSE
,
$core_compatibility
);
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.0'
],
TRUE
,
$core_compatibility
);
$tests
+=
$this
->
createTestsForVersions
(
"<
$core_compatibility
-1.0"
,
[
'1.1'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.1'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.0'
],
TRUE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
"<
$core_compatibility
-1.0"
,
[
'1.1'
],
FALSE
,
$core_compatibility
);
// Test less than or equal. For example "<=8.x-1.x".
$constraint
=
"<=
$core_compatibility
-1.x"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'2.0'
],
FALSE
,
$core_compatibility
);
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.9'
,
'1.1'
,
'0.9'
],
TRUE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'2.0'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.9'
,
'1.1'
,
'0.9'
],
TRUE
,
$core_compatibility
);
// Test greater than and less than. For example "<8.x-4.x,>8.x-1.x".
$constraint
=
"<
$core_compatibility
-4.x, >
$core_compatibility
-1.x"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'4.0'
,
'1.9'
],
FALSE
,
$core_compatibility
);
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'3.9'
,
'2.1'
],
TRUE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'4.0'
,
'1.9'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'3.9'
,
'2.1'
],
TRUE
,
$core_compatibility
);
// Test greater than and less than with no core version in
// constraint. For example "<4.x,>1.x".
$constraint
=
"< 4.x, > 1.x"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'4.0'
,
'1.9'
],
FALSE
,
$core_compatibility
);
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'3.9'
,
'2.1'
],
TRUE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'4.0'
,
'1.9'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'3.9'
,
'2.1'
],
TRUE
,
$core_compatibility
);
// Test greater than or equals and equals minor version. Both of
// these conditions will pass. For example "8.x-2.x,>=2.4-alpha2".
$constraint
=
"
{
$equal_operator
}
$core_compatibility
-2.x, >= 2.4-alpha2"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'2.4-beta3'
],
TRUE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'2.4-beta3'
],
TRUE
,
$core_compatibility
);
// Test greater than or equals and equals exact version. For example
// "8.x-2.0,>=2.4-alpha2".
$constraint
=
"
{
$equal_operator
}
$core_compatibility
-2.0, >= 2.4-alpha2"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'2.4-beta3'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'2.4-beta3'
],
FALSE
,
$core_compatibility
);
// Test unsatisfiable greater than and less than. For example
// "> 8.x-4.x,<8.x-1.x".
$constraint
=
">
$core_compatibility
-4.x, <
$core_compatibility
-1.x"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'4.0'
,
'3.9'
,
'2.1'
,
'1.9'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'4.0'
,
'3.9'
,
'2.1'
,
'1.9'
],
FALSE
,
$core_compatibility
);
// Test 2 equals with 1 that is compatible and 1 that is not. For
// example "=2.x,=2.4-beta".
$constraint
=
"
{
$equal_operator
}
{
$core_compatibility
}
2.x,
{
$equal_operator
}
2.4-beta3"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'2.4-beta3'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'2.4-beta3'
],
FALSE
,
$core_compatibility
);
// Test unsatisfiable multiple equals. For example
// "8.x-2.1,8.x-2.3,\"(>1.0,<=3.2,!=3.0)-8.x.2.5".
$constraint
=
"
{
$equal_operator
}
$core_compatibility
-2.1,
{
$equal_operator
}
$core_compatibility
-2.3,
\"
(> 1.0, <= 3.2,
{
$not_equal_operator
}
3.0)-8.x.2.5"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'2.1'
,
'2.2'
,
'2.3'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'2.1'
,
'2.2'
,
'2.3'
],
FALSE
,
$core_compatibility
);
// Test with a range and multiple exclusions. For example
// ">1.0,<=3.2,!=3.0,!=1.5,!=2.7".
$constraint
=
"> 1.0, <= 3.2,
$not_equal_operator
3.0,
$not_equal_operator
1.5,
$not_equal_operator
2.7"
;
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'1.1'
,
'3.1'
,
'2.1'
],
TRUE
,
$core_compatibility
);
$tests
+=
$this
->
createTestsForVersions
(
$constraint
,
[
'3.0'
,
'1.5'
,
'2.7'
,
'3.3'
],
FALSE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'1.1'
,
'3.1'
,
'2.1'
],
TRUE
,
$core_compatibility
);
$tests
+=
self
::
createTestsForVersions
(
$constraint
,
[
'3.0'
,
'1.5'
,
'2.7'
,
'3.3'
],
FALSE
,
$core_compatibility
);
}
}
}
...
...
@@ -171,7 +171,7 @@ public function providerIsCompatible() {
* @return array[]
* The test cases to be used with ::testIsCompatible().
*/
private
function
createTestsForVersions
(
$constraint_string
,
array
$versions
,
$expected_result
,
$core_compatibility
=
'8.x'
)
{
private
static
function
createTestsForVersions
(
string
$constraint_string
,
array
$versions
,
bool
$expected_result
,
string
$core_compatibility
=
'8.x'
)
:
array
{
$constraint
=
new
Constraint
(
$constraint_string
,
$core_compatibility
);
$tests
=
[];
foreach
(
$versions
as
$version
)
{
...
...
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