Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates-3327229
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
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
automatic_updates-3327229
Commits
3b224b4f
Commit
3b224b4f
authored
2 years ago
by
Yash Rode
Browse files
Options
Downloads
Patches
Plain Diff
test fix
parent
704e600e
No related branches found
Branches containing commit
Tags
2.4.0-beta1
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/Kernel/CronUpdaterTest.php
+23
-1
23 additions, 1 deletion
tests/src/Kernel/CronUpdaterTest.php
with
23 additions
and
1 deletion
tests/src/Kernel/CronUpdaterTest.php
+
23
−
1
View file @
3b224b4f
...
...
@@ -148,7 +148,7 @@ class CronUpdaterTest extends AutomaticUpdatesKernelTestBase {
$this
->
setReleaseMetadata
(
$release_data
);
$this
->
setCoreVersion
(
'9.8.0'
);
update_get_available
(
TRUE
);
$version
=
strpos
(
$release_data
[
'drupal'
],
'9.8.2'
)
?
'9.8.2'
:
'9.8.1'
;
// Submit the configuration form programmatically, to prove our alterations
// work as expected.
$form_builder
=
$this
->
container
->
get
(
'form_builder'
);
...
...
@@ -160,6 +160,7 @@ class CronUpdaterTest extends AutomaticUpdatesKernelTestBase {
$form_state
->
setValue
(
'automatic_updates_cron'
,
$setting
);
$form_builder
->
submitForm
(
UpdateSettingsForm
::
class
,
$form_state
);
$this
->
setStagedCoreVersion
(
$version
);
// Since we're just trying to ensure that all of Package Manager's services
// are called as expected, disable validation by replacing the event
// dispatcher with a dummy version.
...
...
@@ -299,6 +300,7 @@ class CronUpdaterTest extends AutomaticUpdatesKernelTestBase {
/** @var \Drupal\automatic_updates\CronUpdater $updater */
$updater
=
$this
->
container
->
get
(
'automatic_updates.cron_updater'
);
$this
->
assertTrue
(
$updater
->
isAvailable
());
$this
->
setStagedCoreVersion
(
'9.8.1'
);
$this
->
container
->
get
(
'cron'
)
->
run
();
$logged_by_updater
=
$this
->
logger
->
hasRecord
(
$expected_log_message
,
RfcLogLevel
::
ERROR
);
...
...
@@ -358,6 +360,7 @@ class CronUpdaterTest extends AutomaticUpdatesKernelTestBase {
* Tests that email is sent when an unattended update succeeds.
*/
public
function
testEmailOnSuccess
():
void
{
$this
->
setStagedCoreVersion
(
'9.8.1'
);
$this
->
container
->
get
(
'cron'
)
->
run
();
// Ensure we sent a success message to all recipients.
...
...
@@ -414,6 +417,7 @@ END;
];
TestSubscriber1
::
setTestResult
(
$results
,
$event_class
);
$exception
=
new
StageValidationException
(
$results
);
$this
->
setStagedCoreVersion
(
'9.8.2'
);
$this
->
container
->
get
(
'cron'
)
->
run
();
$url
=
Url
::
fromRoute
(
'update.report_update'
)
...
...
@@ -448,6 +452,7 @@ END;
];
TestSubscriber1
::
setTestResult
(
$results
,
$event_class
);
$exception
=
new
StageValidationException
(
$results
);
$this
->
setStagedCoreVersion
(
'9.8.1'
);
$this
->
container
->
get
(
'cron'
)
->
run
();
$url
=
Url
::
fromRoute
(
'update.report_update'
)
...
...
@@ -475,6 +480,7 @@ END;
$error
=
new
\Exception
(
'I drink your milkshake!'
);
Committer
::
setException
(
$error
);
$this
->
setStagedCoreVersion
(
'9.8.1'
);
$this
->
container
->
get
(
'cron'
)
->
run
();
$expected_body
=
<<<END
Drupal core failed to update automatically from 9.8.0 to 9.8.1. The following error was logged:
...
...
@@ -496,4 +502,20 @@ END;
$this
->
assertSame
(
'setLogger'
,
$updater_method_calls
[
0
][
0
]);
}
/**
* Modifies staged core version.
*
* @param string $version
* Requested version.
*/
private
function
setStagedCoreVersion
(
string
$version
):
void
{
$listener
=
function
(
PreApplyEvent
$event
)
use
(
$version
):
void
{
/** @var \Drupal\automatic_updates\CronUpdater $cron_updater */
$cron_updater
=
$this
->
container
->
get
(
'automatic_updates.cron_updater'
);
$this
->
modifyCorePackageVersion
(
$cron_updater
->
getStageDirectory
(),
$version
);
};
$this
->
container
->
get
(
'event_dispatcher'
)
->
addListener
(
PreApplyEvent
::
class
,
$listener
,
PHP_INT_MAX
);
}
}
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