[Pkg-owncloud-commits] [owncloud] 29/86: Make the JobList test more robust by sorting the result of getAll before comparison

David Prévot taffit at moszumanska.debian.org
Tue Dec 22 16:51:56 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v8.1.5
in repository owncloud.

commit 6ce3419914bbc2872ae9940216e8323387f02319
Author: Joas Schilling <nickvergessen at owncloud.com>
Date:   Thu Nov 19 09:25:34 2015 +0100

    Make the JobList test more robust by sorting the result of getAll before comparison
---
 tests/lib/backgroundjob/joblist.php | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/tests/lib/backgroundjob/joblist.php b/tests/lib/backgroundjob/joblist.php
index 13bee12..d152d39 100644
--- a/tests/lib/backgroundjob/joblist.php
+++ b/tests/lib/backgroundjob/joblist.php
@@ -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->getAllSorted();
 		$job = new TestJob();
 		$this->instance->add($job, $argument);
 
-		$jobs = $this->instance->getAll();
+		$jobs = $this->getAllSorted();
 
 		$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->getAllSorted();
 		$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->getAllSorted();
 		$job = new TestJob();
 		$this->instance->add($job, $argument);
 
-		$jobs = $this->instance->getAll();
+		$jobs = $this->getAllSorted();
 		$this->instance->remove($job, 10);
-		$jobs2 = $this->instance->getAll();
+		$jobs2 = $this->getAllSorted();
 
 		$this->assertEquals($jobs, $jobs2);
 
 		$this->instance->remove($job, $argument);
 
-		$jobs = $this->instance->getAll();
+		$jobs = $this->getAllSorted();
 		$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->getAllSorted();
 
 		$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->getAllSorted();
 
 		$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->getAllSorted();
 
 		$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->getAllSorted();
 
 		$addedJob = $jobs[count($jobs) - 1];
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list