From: Antoine Musso Date: Wed, 22 Oct 2014 21:22:10 +0000 (+0200) Subject: Remove useless sleep() in JobQueueTest X-Git-Tag: 1.31.0-rc.0~13490^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22calendrier%22%2C%22type=semaine%22%29%20.%20%22?a=commitdiff_plain;h=7fff25afc15c39d8d9ed1a704fdf0e01002c7fe7;p=lhc%2Fweb%2Fwiklou.git Remove useless sleep() in JobQueueTest I noticed JobQueueTest::testRootDeduplication takes ~ 6.5 seconds, which is due to the test method using sleep(1) and being passed the provider provider_queueLists which yields six items. The reason is to have the array returned by Job::newRootJobParams() to have an incread value for 'rootJobTimestamp'. Instead, just copy the previous array of parameters and increment the UNIX timestamp and converting back to TS_MW format. Change-Id: I75066df73f9f92e56b89eb6d928c41e949a2d6a9 --- diff --git a/tests/phpunit/includes/jobqueue/JobQueueTest.php b/tests/phpunit/includes/jobqueue/JobQueueTest.php index 69e4006822..ea1a4f6314 100644 --- a/tests/phpunit/includes/jobqueue/JobQueueTest.php +++ b/tests/phpunit/includes/jobqueue/JobQueueTest.php @@ -247,8 +247,13 @@ class JobQueueTest extends MediaWikiTestCase { $this->assertNull( $queue->push( $this->newJob( 0, $root1 ) ), "Push worked ($desc)" ); } $queue->deduplicateRootJob( $this->newJob( 0, $root1 ) ); - sleep( 1 ); // roo job timestamp will increase - $root2 = Job::newRootJobParams( "nulljobspam:$id" ); // task ID/timestamp + + $root2 = $root1; + # Add a second to UNIX epoch and format back to TS_MW + $root2_ts = strtotime( $root2['rootJobTimestamp'] ); + $root2_ts++; + $root2['rootJobTimestamp'] = wfTimestamp( TS_MW, $root2_ts ); + $this->assertNotEquals( $root1['rootJobTimestamp'], $root2['rootJobTimestamp'], "Root job signatures have different timestamps." ); for ( $i = 0; $i < 5; ++$i ) {