Skip to content

Commit

Permalink
[HttpKernel] Fix missing $method argument in MongoDbProfilerStorageTest
Browse files Browse the repository at this point in the history
This test case fixes failures related to a signature change for ProfilerStorageInterface::find(). See: 1aef4e8 and 5f22268.
  • Loading branch information
jmikola committed Dec 31, 2011
1 parent d12f5b2 commit 3ef0594
Showing 1 changed file with 25 additions and 12 deletions.
Expand Up @@ -44,9 +44,10 @@ public function testStore()
$profile = new Profile('token_'.$i);
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo.bar');
$profile->setMethod('GET');
self::$storage->write($profile);
}
$this->assertCount(10, self::$storage->find('127.0.0.1', 'http://foo.bar', 20), '->write() stores data in the database');
$this->assertCount(10, self::$storage->find('127.0.0.1', 'http://foo.bar', 20, 'GET'), '->write() stores data in the database');
self::$storage->purge();
}

Expand All @@ -56,16 +57,19 @@ public function testStoreSpecialCharsInUrl()
// supposed to contain them)
$profile = new Profile('simple_quote');
$profile->setUrl('127.0.0.1', 'http://foo.bar/\'');
$profile->setMethod('GET');
self::$storage->write($profile);
$this->assertTrue(false !== self::$storage->read('simple_quote'), '->write() accepts single quotes in URL');

$profile = new Profile('double_quote');
$profile->setUrl('127.0.0.1', 'http://foo.bar/"');
$profile->setMethod('GET');
self::$storage->write($profile);
$this->assertTrue(false !== self::$storage->read('double_quote'), '->write() accepts double quotes in URL');

$profile = new Profile('backslash');
$profile->setUrl('127.0.0.1', 'http://foo.bar/\\');
$profile->setMethod('GET');
self::$storage->write($profile);
$this->assertTrue(false !== self::$storage->read('backslash'), '->write() accpets backslash in URL');

Expand All @@ -81,9 +85,10 @@ public function testStoreTime()
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo.bar');
$profile->setTime($dt->getTimestamp());
$profile->setMethod('GET');
self::$storage->write($profile);
}
$records = self::$storage->find('', '', 3);
$records = self::$storage->find('', '', 3, 'GET');
$this->assertCount(3, $records, '->find() returns all previously added records');
$this->assertEquals($records[0]['token'], 'time_2', '->find() returns records ordered by time in descendant order');
$this->assertEquals($records[1]['token'], 'time_1', '->find() returns records ordered by time in descendant order');
Expand All @@ -95,12 +100,13 @@ public function testRetrieveByIp()
{
$profile = new Profile('token');
$profile->setIp('127.0.0.1');
$profile->setMethod('GET');

self::$storage->write($profile);

$this->assertCount(1, self::$storage->find('127.0.0.1', '', 10), '->find() retrieve a record by IP');
$this->assertCount(0, self::$storage->find('127.0.%.1', '', 10), '->find() does not interpret a "%" as a wildcard in the IP');
$this->assertCount(0, self::$storage->find('127.0._.1', '', 10), '->find() does not interpret a "_" as a wildcard in the IP');
$this->assertCount(1, self::$storage->find('127.0.0.1', '', 10, 'GET'), '->find() retrieve a record by IP');
$this->assertCount(0, self::$storage->find('127.0.%.1', '', 10, 'GET'), '->find() does not interpret a "%" as a wildcard in the IP');
$this->assertCount(0, self::$storage->find('127.0._.1', '', 10, 'GET'), '->find() does not interpret a "_" as a wildcard in the IP');

self::$storage->purge();
}
Expand All @@ -110,33 +116,38 @@ public function testRetrieveByUrl()
$profile = new Profile('simple_quote');
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo.bar/\'');
$profile->setMethod('GET');
self::$storage->write($profile);

$profile = new Profile('double_quote');
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo.bar/"');
$profile->setMethod('GET');
self::$storage->write($profile);

$profile = new Profile('backslash');
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo\\bar/');
$profile->setMethod('GET');
self::$storage->write($profile);

$profile = new Profile('percent');
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo.bar/%');
$profile->setMethod('GET');
self::$storage->write($profile);

$profile = new Profile('underscore');
$profile->setIp('127.0.0.1');
$profile->setUrl('http://foo.bar/_');
$profile->setMethod('GET');
self::$storage->write($profile);

$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/\'', 10), '->find() accepts single quotes in URLs');
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/"', 10), '->find() accepts double quotes in URLs');
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo\\bar/', 10), '->find() accepts backslash in URLs');
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/%', 10), '->find() does not interpret a "%" as a wildcard in the URL');
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/_', 10), '->find() does not interpret a "_" as a wildcard in the URL');
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/\'', 10, 'GET'), '->find() accepts single quotes in URLs');
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/"', 10, 'GET'), '->find() accepts double quotes in URLs');
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo\\bar/', 10, 'GET'), '->find() accepts backslash in URLs');
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/%', 10, 'GET'), '->find() does not interpret a "%" as a wildcard in the URL');
$this->assertCount(1, self::$storage->find('127.0.0.1', 'http://foo.bar/_', 10, 'GET'), '->find() does not interpret a "_" as a wildcard in the URL');

self::$storage->purge();
}
Expand All @@ -145,9 +156,10 @@ public function testRetrieveByEmptyUrlAndIp()
{
for ($i = 0; $i < 5; $i++) {
$profile = new Profile('token_'.$i);
$profile->setMethod('GET');
self::$storage->write($profile);
}
$this->assertCount(5, self::$storage->find('', '', 10), '->find() returns all previously added records');
$this->assertCount(5, self::$storage->find('', '', 10, 'GET'), '->find() returns all previously added records');
self::$storage->purge();
}

Expand All @@ -158,9 +170,10 @@ public function testCleanup()
$dt->modify('-1 day');
$profile = new Profile('time_'.$i);
$profile->setTime($dt->getTimestamp());
$profile->setMethod('GET');
self::$storage->write($profile);
}
$records = self::$storage->find('', '', 3);
$records = self::$storage->find('', '', 3, 'GET');
$this->assertCount(1, $records, '->find() returns only one record');
$this->assertEquals($records[0]['token'], 'time_2', '->find() returns the latest added record');
self::$storage->purge();
Expand Down

0 comments on commit 3ef0594

Please sign in to comment.