Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
project
automatic_updates
Commits
3891174c
Commit
3891174c
authored
2 years ago
by
Ted Bowman
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3322589
by tedbow: Assert 'type' key is set in FixtureUtilityTrait::addPackage
parent
491930a1
No related branches found
No related tags found
1 merge request
!600
Issue #3322589: Assert minimum keys in FixtureUtilityTrait::addPackage
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
package_manager/tests/src/Kernel/FixtureUtilityTraitTest.php
+19
-1
19 additions, 1 deletion
package_manager/tests/src/Kernel/FixtureUtilityTraitTest.php
package_manager/tests/src/Traits/FixtureUtilityTrait.php
+4
-2
4 additions, 2 deletions
package_manager/tests/src/Traits/FixtureUtilityTrait.php
with
23 additions
and
3 deletions
package_manager/tests/src/Kernel/FixtureUtilityTraitTest.php
+
19
−
1
View file @
3891174c
...
...
@@ -33,10 +33,12 @@ class FixtureUtilityTraitTest extends PackageManagerKernelTestBase {
$this
->
addPackage
(
$this
->
dir
,
[
'name'
=>
'my/package'
,
'type'
=>
'library'
,
]);
$this
->
addPackage
(
$this
->
dir
,
[
'name'
=>
'my/dev-package'
,
'version'
=>
'2.1.0'
,
'type'
=>
'library'
,
'install_path'
=>
'../relative/path'
,
],
TRUE
,
...
...
@@ -56,9 +58,21 @@ class FixtureUtilityTraitTest extends PackageManagerKernelTestBase {
$this
->
assertSame
(
"Failed asserting that an array has the key 'name'."
,
$e
->
getMessage
());
}
// Packages cannot be added without a type.
try
{
$this
->
addPackage
(
$this
->
dir
,
[
'name'
=>
'unknown'
]);
$this
->
fail
(
'Adding an package without a type should raise an error.'
);
}
catch
(
AssertionFailedError
$e
)
{
$this
->
assertSame
(
"Failed asserting that an array has the key 'type'."
,
$e
->
getMessage
());
}
// We should not be able to add an existing package.
try
{
$this
->
addPackage
(
$this
->
dir
,
[
'name'
=>
'my/package'
]);
$this
->
addPackage
(
$this
->
dir
,
[
'name'
=>
'my/package'
,
'type'
=>
'library'
,
]);
$this
->
fail
(
'Trying to add an existing package should raise an error.'
);
}
catch
(
AssertionFailedError
$e
)
{
...
...
@@ -71,6 +85,7 @@ class FixtureUtilityTraitTest extends PackageManagerKernelTestBase {
$this
->
addPackage
(
$this
->
dir
,
[
'name'
=>
'absolute/path'
,
'install_path'
=>
'/absolute/path'
,
'type'
=>
'library'
,
]);
$this
->
fail
(
'Add package should have failed.'
);
}
...
...
@@ -81,10 +96,12 @@ class FixtureUtilityTraitTest extends PackageManagerKernelTestBase {
$installed_json_expected_packages
=
[
'my/package'
=>
[
'name'
=>
'my/package'
,
'type'
=>
'library'
,
],
'my/dev-package'
=>
[
'name'
=>
'my/dev-package'
,
'version'
=>
'2.1.0'
,
'type'
=>
'library'
,
],
];
$installed_php_expected_packages
=
$installed_json_expected_packages
;
...
...
@@ -174,6 +191,7 @@ class FixtureUtilityTraitTest extends PackageManagerKernelTestBase {
'my/dev-package'
=>
[
'name'
=>
'my/dev-package'
,
'version'
=>
'3.2.1'
,
'type'
=>
'library'
,
],
'my/other-package'
=>
[
'name'
=>
'my/other-package'
,
...
...
This diff is collapsed.
Click to expand it.
package_manager/tests/src/Traits/FixtureUtilityTrait.php
+
4
−
2
View file @
3891174c
...
...
@@ -92,12 +92,14 @@ trait FixtureUtilityTrait {
* area).
* @param array $package
* The package info that should be added to installed.json and
* installed.php. Must include
a
`name` key.
* installed.php. Must include
the
`name`
and `type`
key
s
.
* @param bool $is_dev_requirement
* Whether or not the package is a development requirement.
*/
protected
function
addPackage
(
string
$dir
,
array
$package
,
bool
$is_dev_requirement
=
FALSE
):
void
{
$this
->
assertArrayHasKey
(
'name'
,
$package
);
foreach
([
'name'
,
'type'
]
as
$required_key
)
{
$this
->
assertArrayHasKey
(
$required_key
,
$package
);
}
$this
->
setPackage
(
$dir
,
$package
[
'name'
],
$package
,
FALSE
,
$is_dev_requirement
);
}
...
...
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