Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3421017
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-3421017
Commits
ae750411
Commit
ae750411
authored
1 year ago
by
catch
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3417557
by longwave: Remove withConsecutive() in CronSuspendQueueDelayTest
parent
c794a0e0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/phpstan-baseline.neon
+0
-5
0 additions, 5 deletions
core/phpstan-baseline.neon
core/tests/Drupal/Tests/Core/Cron/CronSuspendQueueDelayTest.php
+32
-31
32 additions, 31 deletions
...ests/Drupal/Tests/Core/Cron/CronSuspendQueueDelayTest.php
with
32 additions
and
36 deletions
core/phpstan-baseline.neon
+
0
−
5
View file @
ae750411
...
@@ -3296,11 +3296,6 @@ parameters:
...
@@ -3296,11 +3296,6 @@ parameters:
count: 1
count: 1
path: tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
path: tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
-
message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
count: 3
path: tests/Drupal/Tests/Core/Cron/CronSuspendQueueDelayTest.php
-
-
message: """
message: """
#^Call to deprecated method expectError\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\:
#^Call to deprecated method expectError\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\:
...
...
This diff is collapsed.
Click to expand it.
core/tests/Drupal/Tests/Core/Cron/CronSuspendQueueDelayTest.php
+
32
−
31
View file @
ae750411
...
@@ -135,12 +135,12 @@ public function testSuspendQueue(): void {
...
@@ -135,12 +135,12 @@ public function testSuspendQueue(): void {
->
setConstructorArgs
(
$this
->
cronConstructorArguments
)
->
setConstructorArgs
(
$this
->
cronConstructorArguments
)
->
getMock
();
->
getMock
();
$cron
->
expects
(
$this
->
exactly
(
2
))
$delays
=
[
2000000
,
3000000
];
$cron
->
expects
(
$this
->
exactly
(
count
(
$delays
)))
->
method
(
'usleep'
)
->
method
(
'usleep'
)
->
withConsecutive
(
->
with
(
$this
->
callback
(
function
(
int
$delay
)
use
(
&
$delays
):
bool
{
[
$this
->
equalTo
(
2000000
)],
return
array_shift
(
$delays
)
===
$delay
;
[
$this
->
equalTo
(
3000000
)],
}));
);
$queueManager
->
expects
(
$this
->
once
())
$queueManager
->
expects
(
$this
->
once
())
->
method
(
'getDefinitions'
)
->
method
(
'getDefinitions'
)
...
@@ -391,19 +391,22 @@ public function testSuspendQueueOrder(): void {
...
@@ -391,19 +391,22 @@ public function testSuspendQueueOrder(): void {
[
'test_worker_d'
,
[],
$this
->
workerA
],
[
'test_worker_d'
,
[],
$this
->
workerA
],
]);
]);
$this
->
workerA
->
expects
(
$this
->
exactly
(
6
))
$queues
=
[
// All queues are executed in sequence of definition:
'test_data_from_queue_a'
,
'test_data_from_queue_b'
,
'test_data_from_queue_c'
,
'test_data_from_queue_d'
,
// Queue C is executed again, and before queue B.
'test_data_from_queue_c'
,
// Queue B is executed again, after queue C since its delay was longer.
'test_data_from_queue_b'
,
];
$this
->
workerA
->
expects
(
$this
->
exactly
(
count
(
$queues
)))
->
method
(
'processItem'
)
->
method
(
'processItem'
)
->
withConsecutive
(
->
with
(
$this
->
callback
(
function
(
$queue
)
use
(
&
$queues
):
bool
{
// All queues are executed in sequence of definition:
return
array_shift
(
$queues
)
===
$queue
;
[
$this
->
equalTo
(
'test_data_from_queue_a'
)],
}))
[
$this
->
equalTo
(
'test_data_from_queue_b'
)],
[
$this
->
equalTo
(
'test_data_from_queue_c'
)],
[
$this
->
equalTo
(
'test_data_from_queue_d'
)],
// Queue C is executed again, and before queue B.
[
$this
->
equalTo
(
'test_data_from_queue_c'
)],
// Queue B is executed again, after queue C since its delay was longer.
[
$this
->
equalTo
(
'test_data_from_queue_b'
)],
)
->
willReturnOnConsecutiveCalls
(
->
willReturnOnConsecutiveCalls
(
NULL
,
NULL
,
$this
->
throwException
(
new
SuspendQueueException
(
''
,
0
,
NULL
,
16.0
)),
$this
->
throwException
(
new
SuspendQueueException
(
''
,
0
,
NULL
,
16.0
)),
...
@@ -425,21 +428,19 @@ public function testSuspendQueueOrder(): void {
...
@@ -425,21 +428,19 @@ public function testSuspendQueueOrder(): void {
return
(
float
)
$currentTime
;
return
(
float
)
$currentTime
;
});
});
$cron
->
expects
(
$this
->
exactly
(
2
))
$delays
=
[
// Expect to wait for 8 seconds, then accelerate time by 4 seconds.
4
,
8000000
,
// SuspendQueueException requests to delay by 16 seconds, but 4 seconds
// have passed above, so there are just 12 seconds remaining:
0
,
12000000
,
];
$cron
->
expects
(
$this
->
exactly
(
count
(
$delays
)
/
2
))
->
method
(
'usleep'
)
->
method
(
'usleep'
)
->
withConsecutive
(
->
with
(
$this
->
callback
(
function
(
int
$delay
)
use
(
&
$currentTime
,
&
$delays
):
bool
{
// Expect to wait for 8 seconds.
$currentTime
+=
array_shift
(
$delays
);
[
return
array_shift
(
$delays
)
===
$delay
;
$this
->
callback
(
function
(
int
$microseconds
)
use
(
&
$currentTime
)
{
}));
// Accelerate time by 4 seconds.
$currentTime
+=
4
;
return
$microseconds
===
8000000
;
}),
],
// SuspendQueueException requests to delay by 16 seconds, but 4 seconds
// have passed above, so there are just 12 seconds remaining:
[
$this
->
equalTo
(
12000000
)],
);
$cron
->
run
();
$cron
->
run
();
}
}
...
...
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