Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
0b8335ff
Commit
0b8335ff
authored
9 years ago
by
Joas Schilling
Browse files
Options
Downloads
Patches
Plain Diff
Make the JobList test more robust by sorting the result of getAll before comparison
parent
6efa7286
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/lib/backgroundjob/joblist.php
+24
-12
24 additions, 12 deletions
tests/lib/backgroundjob/joblist.php
with
24 additions
and
12 deletions
tests/lib/backgroundjob/joblist.php
+
24
−
12
View file @
0b8335ff
...
...
@@ -8,6 +8,8 @@
namespace
Test\BackgroundJob
;
use
OCP\BackgroundJob\IJob
;
class
JobList
extends
\Test\TestCase
{
/**
* @var \OC\BackgroundJob\JobList
...
...
@@ -27,6 +29,16 @@ class JobList extends \Test\TestCase {
$this
->
instance
=
new
\OC\BackgroundJob\JobList
(
$conn
,
$this
->
config
);
}
protected
function
getAllSorted
()
{
$jobs
=
$this
->
instance
->
getAll
();
usort
(
$jobs
,
function
(
IJob
$job1
,
IJob
$job2
)
{
return
$job1
->
getId
()
-
$job2
->
getId
();
});
return
$jobs
;
}
public
function
argumentProvider
()
{
return
array
(
array
(
null
),
...
...
@@ -45,11 +57,11 @@ class JobList extends \Test\TestCase {
* @param $argument
*/
public
function
testAddRemove
(
$argument
)
{
$existingJobs
=
$this
->
instance
->
getAll
();
$existingJobs
=
$this
->
getAll
Sorted
();
$job
=
new
TestJob
();
$this
->
instance
->
add
(
$job
,
$argument
);
$jobs
=
$this
->
instance
->
getAll
();
$jobs
=
$this
->
getAll
Sorted
();
$this
->
assertCount
(
count
(
$existingJobs
)
+
1
,
$jobs
);
$addedJob
=
$jobs
[
count
(
$jobs
)
-
1
];
...
...
@@ -58,7 +70,7 @@ class JobList extends \Test\TestCase {
$this
->
instance
->
remove
(
$job
,
$argument
);
$jobs
=
$this
->
instance
->
getAll
();
$jobs
=
$this
->
getAll
Sorted
();
$this
->
assertEquals
(
$existingJobs
,
$jobs
);
}
...
...
@@ -67,19 +79,19 @@ class JobList extends \Test\TestCase {
* @param $argument
*/
public
function
testRemoveDifferentArgument
(
$argument
)
{
$existingJobs
=
$this
->
instance
->
getAll
();
$existingJobs
=
$this
->
getAll
Sorted
();
$job
=
new
TestJob
();
$this
->
instance
->
add
(
$job
,
$argument
);
$jobs
=
$this
->
instance
->
getAll
();
$jobs
=
$this
->
getAll
Sorted
();
$this
->
instance
->
remove
(
$job
,
10
);
$jobs2
=
$this
->
instance
->
getAll
();
$jobs2
=
$this
->
getAll
Sorted
();
$this
->
assertEquals
(
$jobs
,
$jobs2
);
$this
->
instance
->
remove
(
$job
,
$argument
);
$jobs
=
$this
->
instance
->
getAll
();
$jobs
=
$this
->
getAll
Sorted
();
$this
->
assertEquals
(
$existingJobs
,
$jobs
);
}
...
...
@@ -126,7 +138,7 @@ class JobList extends \Test\TestCase {
$this
->
instance
->
add
(
$job
,
1
);
$this
->
instance
->
add
(
$job
,
2
);
$jobs
=
$this
->
instance
->
getAll
();
$jobs
=
$this
->
getAll
Sorted
();
$savedJob1
=
$jobs
[
count
(
$jobs
)
-
2
];
$savedJob2
=
$jobs
[
count
(
$jobs
)
-
1
];
...
...
@@ -149,7 +161,7 @@ class JobList extends \Test\TestCase {
$this
->
instance
->
add
(
$job
,
1
);
$this
->
instance
->
add
(
$job
,
2
);
$jobs
=
$this
->
instance
->
getAll
();
$jobs
=
$this
->
getAll
Sorted
();
$savedJob2
=
$jobs
[
count
(
$jobs
)
-
1
];
...
...
@@ -174,7 +186,7 @@ class JobList extends \Test\TestCase {
$job
=
new
TestJob
();
$this
->
instance
->
add
(
$job
,
$argument
);
$jobs
=
$this
->
instance
->
getAll
();
$jobs
=
$this
->
getAll
Sorted
();
$addedJob
=
$jobs
[
count
(
$jobs
)
-
1
];
...
...
@@ -187,7 +199,7 @@ class JobList extends \Test\TestCase {
$job
=
new
TestJob
();
$this
->
instance
->
add
(
$job
);
$jobs
=
$this
->
instance
->
getAll
();
$jobs
=
$this
->
getAll
Sorted
();
$addedJob
=
$jobs
[
count
(
$jobs
)
-
1
];
...
...
@@ -209,7 +221,7 @@ class JobList extends \Test\TestCase {
$this
->
instance
->
add
(
'\OC\Non\Existing\Class'
);
$this
->
instance
->
add
(
$job
,
2
);
$jobs
=
$this
->
instance
->
getAll
();
$jobs
=
$this
->
getAll
Sorted
();
$savedJob1
=
$jobs
[
count
(
$jobs
)
-
2
];
$savedJob2
=
$jobs
[
count
(
$jobs
)
-
1
];
...
...
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