1bebf30454
Commits -------ed8c1c0
Fixed AbstractProfilerStorageTest and some minor CS changes.1ac581e
Overwrite the profile data if the token already exists like in the other implementations.198d406
Return profiler results sorted by time in descending order like in the other implementations.9d8e3f2
Refactored profiler storage tests to share some code. Discussion ---------- [WIP] Refactored profiler tests including some storage fixes Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes While refactoring the tests I came across some inconsistencies. Two of them are already fixed in this PR. One thing left is the [MongoDbProfilerStorageTest::testCleanup()](9d8e3f2da4/tests/Symfony/Tests/Component/HttpKernel/Profiler/MongoDbProfilerStorageTest.php (L51)
) test which fails in all other storage implementations. The mongodb implementation uses the `time` value from the profiler data to clean up the storage while the others additionally save a `created_at` value which is then used. For me this `created_at` value does not make any sense and I would suggest to change the other implementations to use the `time` value for cleaning up. What do you think? --------------------------------------------------------------------------- by pulzarraider at 2012-02-27T06:55:06Z +1 for refactoring profiler tests, I will update my RedisProfilerStorage after your changes will be merged. --------------------------------------------------------------------------- by snc at 2012-02-28T20:05:12Z Any suggestions about the cleanup issue?
69 lines
1.8 KiB
PHP
69 lines
1.8 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Tests\Component\HttpKernel\Profiler;
|
|
|
|
use Symfony\Component\HttpKernel\Profiler\MemcacheProfilerStorage;
|
|
use Symfony\Component\HttpKernel\Profiler\Profile;
|
|
|
|
class DummyMemcacheProfilerStorage extends MemcacheProfilerStorage
|
|
{
|
|
public function getMemcache()
|
|
{
|
|
return parent::getMemcache();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @group memcached
|
|
*/
|
|
class MemcacheProfilerStorageTest extends AbstractProfilerStorageTest
|
|
{
|
|
protected static $storage;
|
|
|
|
public static function tearDownAfterClass()
|
|
{
|
|
if (self::$storage) {
|
|
self::$storage->purge();
|
|
}
|
|
}
|
|
|
|
protected function setUp()
|
|
{
|
|
if (!extension_loaded('memcache')) {
|
|
$this->markTestSkipped('MemcacheProfilerStorageTest requires that the extension memcache is loaded');
|
|
}
|
|
|
|
self::$storage = new DummyMemcacheProfilerStorage('memcache://127.0.0.1/11211', '', '', 86400);
|
|
try {
|
|
self::$storage->getMemcache();
|
|
$stats = self::$storage->getMemcache()->getExtendedStats();
|
|
if (!isset($stats['127.0.0.1:11211']) || $stats['127.0.0.1:11211'] === false) {
|
|
throw new \Exception();
|
|
}
|
|
} catch (\Exception $e) {
|
|
$this->markTestSkipped('MemcacheProfilerStorageTest requires that there is a Memcache server present on localhost');
|
|
}
|
|
|
|
if (self::$storage) {
|
|
self::$storage->purge();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface
|
|
*/
|
|
protected function getStorage()
|
|
{
|
|
return self::$storage;
|
|
}
|
|
}
|