Skip to content

Commit 4c1b539

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: harden test to not depend on the actual time [ProxyManager] fix tests actually compare the order of entries when any sorting is applied
2 parents 1169b8f + 62b9794 commit 4c1b539

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Tests/Profiler/FileProfilerStorageTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,26 +213,25 @@ public function testRetrieveByUrl()
213213

214214
public function testStoreTime()
215215
{
216-
$dt = new \DateTime('now');
217-
$start = $dt->getTimestamp();
216+
$start = $now = time();
218217

219218
for ($i = 0; $i < 3; ++$i) {
220-
$dt->modify('+1 minute');
219+
$now += 60;
221220
$profile = new Profile('time_'.$i);
222221
$profile->setIp('127.0.0.1');
223222
$profile->setUrl('http://foo.bar');
224-
$profile->setTime($dt->getTimestamp());
223+
$profile->setTime($now);
225224
$profile->setMethod('GET');
226225
$this->storage->write($profile);
227226
}
228227

229-
$records = $this->storage->find('', '', 3, 'GET', $start, time() + 3 * 60);
228+
$records = $this->storage->find('', '', 3, 'GET', $start, $start + 3 * 60);
230229
$this->assertCount(3, $records, '->find() returns all previously added records');
231230
$this->assertEquals('time_2', $records[0]['token'], '->find() returns records ordered by time in descendant order');
232231
$this->assertEquals('time_1', $records[1]['token'], '->find() returns records ordered by time in descendant order');
233232
$this->assertEquals('time_0', $records[2]['token'], '->find() returns records ordered by time in descendant order');
234233

235-
$records = $this->storage->find('', '', 3, 'GET', $start, time() + 2 * 60);
234+
$records = $this->storage->find('', '', 3, 'GET', $start, $start + 2 * 60);
236235
$this->assertCount(2, $records, '->find() should return only first two of the previously added records');
237236
}
238237

0 commit comments

Comments
 (0)