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
Merge requests
!264
Issue
#3273017
: Create a validator service for Extension update to confirm they were installed via Composer
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3273017
: Create a validator service for Extension update to confirm they were installed via Composer
issue/automatic_updates-3273017:3273017-create-a-validator
into
8.x-2.x
Overview
61
Commits
29
Pipelines
0
Changes
2
Merged
Kunal Sachdev
requested to merge
issue/automatic_updates-3273017:3273017-create-a-validator
into
8.x-2.x
2 years ago
Overview
12
Commits
29
Pipelines
0
Changes
2
Expand
0
0
Merge request reports
Viewing commit
ffbe7456
Prev
Next
Show latest version
2 files
+
77
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
Unverified
ffbe7456
added notes
· ffbe7456
Ted Bowman
authored
2 years ago
automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php
+
65
−
0
Options
@@ -2,7 +2,11 @@
namespace
Drupal\Tests\automatic_updates_extensions\Kernel
;
use
Drupal\automatic_updates_extensions
\ExtensionUpdater
;
use
Drupal\Core\Extension\ExtensionVersion
;
use
Drupal\package_manager
\Exception\StageValidationException
;
use
Drupal\Tests\automatic_updates
\Kernel\AutomaticUpdatesKernelTestBase
;
use
Drupal\Tests\package_manager
\Kernel\TestStage
;
abstract
class
AutomaticUpdatesExtensionsKernelTestBase
extends
AutomaticUpdatesKernelTestBase
{
@@ -16,4+20,4 @@
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
}
/**
* Creates a stage object for testing purposes.
*
* @return \Drupal\automatic_updates_extensions\ExtensionUpdater
* A stage object, with test-only modifications.
*/
protected
function
createUpdater
():
ExtensionUpdater
{
// @todo Do we need a TestsExtensionUpdater like the other base tests?
return
new
ExtensionUpdater
(
$this
->
container
->
get
(
'config.factory'
),
$this
->
container
->
get
(
'package_manager.path_locator'
),
$this
->
container
->
get
(
'package_manager.beginner'
),
$this
->
container
->
get
(
'package_manager.stager'
),
$this
->
container
->
get
(
'package_manager.committer'
),
$this
->
container
->
get
(
'file_system'
),
$this
->
container
->
get
(
'event_dispatcher'
),
$this
->
container
->
get
(
'tempstore.shared'
),
$this
->
container
->
get
(
'datetime.time'
)
);
}
/**
* Asserts validation results are returned from a stage life cycle event.
*
* @todo Not sure if this is the correct way or we will need to do something like
* \Drupal\Tests\automatic_updates\Kernel\ReadinessValidation\StagedProjectsValidatorTest::validate()
* which basically sets up a test where
* $active = $stage->getActiveComposer();
$stage = $stage->getStageComposer();
* will both point to our fixture directories and not to real directories.
*
* @param string[] $packages
* As passed to require().
* @param \Drupal\package_manager\ValidationResult[] $expected_results
* The expected validation results.
* @param string|null $event_class
* (optional) The class of the event which should return the results. Must
* be passed if $expected_results is not empty.
*/
protected
function
assertUpdateResults
(
array
$packages
,
array
$expected_results
,
string
$event_class
=
NULL
):
void
{
$updater
=
$this
->
createUpdater
();
try
{
$updater
->
begin
(
$packages
);
$updater
->
stage
();
$updater
->
apply
();
$updater
->
destroy
();
// If we did not get an exception, ensure we didn't expect any results.
$this
->
assertEmpty
(
$expected_results
);
}
catch
(
StageValidationException
$e
)
{
$this
->
assertNotEmpty
(
$expected_results
);
$this
->
assertValidationResultsEqual
(
$expected_results
,
$e
->
getResults
());
// TestStage::dispatch() attaches the event object to the exception so
// that we can analyze it.
$this
->
assertNotEmpty
(
$event_class
);
$this
->
assertInstanceOf
(
$event_class
,
$e
->
event
);
}
}
}
Loading