merged branch henrikbjorn/filesystem-limit (PR #7886)

This PR was submitted for the master branch but it was merged into the 2.1 branch instead (closes #7886).

Discussion
----------

[HttpKernel][Profile] Fixes #7883

Commits
-------

0172fc1 [HttpKernel][Profile] use while loop for iterating
This commit is contained in:
Fabien Potencier 2013-05-01 05:56:56 +02:00
commit 4ab05a35bc
2 changed files with 16 additions and 5 deletions

View File

@ -58,10 +58,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
fseek($file, 0, SEEK_END);
$result = array();
while ($limit > 0) {
$line = $this->readLineFromFile($file);
while (count($result) < $limit && $line = $this->readLineFromFile($file)) {
if (false === $line) {
break;
}
@ -84,7 +81,6 @@ class FileProfilerStorage implements ProfilerStorageInterface
'time' => $csvTime,
'parent' => $csvParent,
);
--$limit;
}
fclose($file);

View File

@ -183,6 +183,21 @@ abstract class AbstractProfilerStorageTest extends \PHPUnit_Framework_TestCase
$this->getStorage()->purge();
}
public function testRetrieveByMethodAndLimit()
{
foreach (array('POST', 'GET') as $method) {
for ($i = 0; $i < 5; $i++) {
$profile = new Profile('token_'.$i.$method);
$profile->setMethod($method);
$this->getStorage()->write($profile);
}
}
$this->assertCount(5, $this->getStorage()->find('', '', 5, 'POST'));
$this->getStorage()->purge();
}
public function testPurge()
{
$profile = new Profile('token1');