- */
-class RedisMock
-{
- private $connected = false;
- private $storage = array();
-
- /**
- * Add a server to connection pool.
- *
- * @param string $host
- * @param int $port
- * @param float $timeout
- *
- * @return bool
- */
- public function connect($host, $port = 6379, $timeout = 0)
- {
- if ('127.0.0.1' == $host && 6379 == $port) {
- $this->connected = true;
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Set client option.
- *
- * @param int $name
- * @param int $value
- *
- * @return bool
- */
- public function setOption($name, $value)
- {
- if (!$this->connected) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Verify if the specified key exists.
- *
- * @param string $key
- *
- * @return bool
- */
- public function exists($key)
- {
- if (!$this->connected) {
- return false;
- }
-
- return isset($this->storage[$key]);
- }
-
- /**
- * Store data at the server with expiration time.
- *
- * @param string $key
- * @param int $ttl
- * @param mixed $value
- *
- * @return bool
- */
- public function setex($key, $ttl, $value)
- {
- if (!$this->connected) {
- return false;
- }
-
- $this->storeData($key, $value);
-
- return true;
- }
-
- /**
- * Sets an expiration time on an item.
- *
- * @param string $key
- * @param int $ttl
- *
- * @return bool
- */
- public function setTimeout($key, $ttl)
- {
- if (!$this->connected) {
- return false;
- }
-
- if (isset($this->storage[$key])) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Retrieve item from the server.
- *
- * @param string $key
- *
- * @return bool
- */
- public function get($key)
- {
- if (!$this->connected) {
- return false;
- }
-
- return $this->getData($key);
- }
-
- /**
- * Append data to an existing item.
- *
- * @param string $key
- * @param string $value
- *
- * @return int Size of the value after the append.
- */
- public function append($key, $value)
- {
- if (!$this->connected) {
- return false;
- }
-
- if (isset($this->storage[$key])) {
- $this->storeData($key, $this->getData($key).$value);
-
- return strlen($this->storage[$key]);
- }
-
- return false;
- }
-
- /**
- * Remove specified keys.
- *
- * @param string|array $key
- *
- * @return int
- */
- public function delete($key)
- {
- if (!$this->connected) {
- return false;
- }
-
- if (is_array($key)) {
- $result = 0;
- foreach ($key as $k) {
- if (isset($this->storage[$k])) {
- unset($this->storage[$k]);
- ++$result;
- }
- }
-
- return $result;
- }
-
- if (isset($this->storage[$key])) {
- unset($this->storage[$key]);
-
- return 1;
- }
-
- return 0;
- }
-
- /**
- * Flush all existing items from all databases at the server.
- *
- * @return bool
- */
- public function flushAll()
- {
- if (!$this->connected) {
- return false;
- }
-
- $this->storage = array();
-
- return true;
- }
-
- /**
- * Close Redis server connection.
- *
- * @return bool
- */
- public function close()
- {
- $this->connected = false;
-
- return true;
- }
-
- private function getData($key)
- {
- if (isset($this->storage[$key])) {
- return unserialize($this->storage[$key]);
- }
-
- return false;
- }
-
- private function storeData($key, $value)
- {
- $this->storage[$key] = serialize($value);
-
- return true;
- }
-
- public function select($dbnum)
- {
- if (!$this->connected) {
- return false;
- }
-
- if (0 > $dbnum) {
- return false;
- }
-
- return true;
- }
-}
diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php
deleted file mode 100644
index 43c79d9cc69f7..0000000000000
--- a/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php
+++ /dev/null
@@ -1,156 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\HttpKernel\Tests\Profiler;
-
-use Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage;
-use Symfony\Component\HttpKernel\Profiler\Profile;
-use Symfony\Component\HttpKernel\DataCollector\DataCollector;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
-
-class MongoDbProfilerStorageTestDataCollector extends DataCollector
-{
- public function setData($data)
- {
- $this->data = $data;
- }
-
- public function getData()
- {
- return $this->data;
- }
-
- public function collect(Request $request, Response $response, \Exception $exception = null)
- {
- }
-
- public function getName()
- {
- return 'test_data_collector';
- }
-}
-
-/**
- * @group legacy
- */
-class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest
-{
- private $storage;
-
- public function getDsns()
- {
- return array(
- array('mongodb://localhost/symfony_tests/profiler_data', array(
- 'mongodb://localhost/symfony_tests',
- 'symfony_tests',
- 'profiler_data',
- )),
- array('mongodb://user:password@localhost/symfony_tests/profiler_data', array(
- 'mongodb://user:password@localhost/symfony_tests',
- 'symfony_tests',
- 'profiler_data',
- )),
- array('mongodb://user:password@localhost/admin/symfony_tests/profiler_data', array(
- 'mongodb://user:password@localhost/admin',
- 'symfony_tests',
- 'profiler_data',
- )),
- array('mongodb://user:password@localhost:27009,localhost:27010/?replicaSet=rs-name&authSource=admin/symfony_tests/profiler_data', array(
- 'mongodb://user:password@localhost:27009,localhost:27010/?replicaSet=rs-name&authSource=admin',
- 'symfony_tests',
- 'profiler_data',
- )),
- );
- }
-
- public function testCleanup()
- {
- $dt = new \DateTime('-2 day');
- for ($i = 0; $i < 3; ++$i) {
- $dt->modify('-1 day');
- $profile = new Profile('time_'.$i);
- $profile->setTime($dt->getTimestamp());
- $profile->setMethod('GET');
- $this->storage->write($profile);
- }
- $records = $this->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');
- $this->storage->purge();
- }
-
- /**
- * @dataProvider getDsns
- */
- public function testDsnParser($dsn, $expected)
- {
- $m = new \ReflectionMethod($this->storage, 'parseDsn');
- $m->setAccessible(true);
-
- $this->assertEquals($expected, $m->invoke($this->storage, $dsn));
- }
-
- public function testUtf8()
- {
- $profile = new Profile('utf8_test_profile');
-
- $data = 'HЁʃʃϿ, ϢorЃd!';
- $nonUtf8Data = mb_convert_encoding($data, 'UCS-2');
-
- $collector = new MongoDbProfilerStorageTestDataCollector();
- $collector->setData($nonUtf8Data);
-
- $profile->setCollectors(array($collector));
-
- $this->storage->write($profile);
-
- $readProfile = $this->storage->read('utf8_test_profile');
- $collectors = $readProfile->getCollectors();
-
- $this->assertCount(1, $collectors);
- $this->assertArrayHasKey('test_data_collector', $collectors);
- $this->assertEquals($nonUtf8Data, $collectors['test_data_collector']->getData(), 'Non-UTF8 data is properly encoded/decoded');
- }
-
- /**
- * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface
- */
- protected function getStorage()
- {
- return $this->storage;
- }
-
- protected function setUp()
- {
- if (!extension_loaded('mongo')) {
- $this->markTestSkipped('MongoDbProfilerStorageTest requires the mongo PHP extension and a MongoDB server on localhost');
- }
-
- $this->storage = new MongoDbProfilerStorage('mongodb://localhost/symfony_tests/profiler_data', '', '', 86400);
- $m = new \ReflectionMethod($this->storage, 'getMongo');
- $m->setAccessible(true);
- try {
- $m->invoke($this->storage);
- } catch (\MongoConnectionException $e) {
- $this->storage = null;
- }
-
- $this->storage->purge();
- }
-
- protected function tearDown()
- {
- if ($this->storage) {
- $this->storage->purge();
- }
- }
-}
diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/RedisProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/RedisProfilerStorageTest.php
deleted file mode 100644
index 1ddc2debda9cf..0000000000000
--- a/src/Symfony/Component/HttpKernel/Tests/Profiler/RedisProfilerStorageTest.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\HttpKernel\Tests\Profiler;
-
-use Symfony\Component\HttpKernel\Profiler\RedisProfilerStorage;
-use Symfony\Component\HttpKernel\Tests\Profiler\Mock\RedisMock;
-
-/**
- * @group legacy
- */
-class RedisProfilerStorageTest extends AbstractProfilerStorageTest
-{
- protected static $storage;
-
- protected function setUp()
- {
- $redisMock = new RedisMock();
- $redisMock->connect('127.0.0.1', 6379);
-
- self::$storage = new RedisProfilerStorage('redis://127.0.0.1:6379', '', '', 86400);
- self::$storage->setRedis($redisMock);
-
- if (self::$storage) {
- self::$storage->purge();
- }
- }
-
- protected function tearDown()
- {
- if (self::$storage) {
- self::$storage->purge();
- self::$storage = false;
- }
- }
-
- /**
- * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface
- */
- protected function getStorage()
- {
- return self::$storage;
- }
-}
diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php
deleted file mode 100644
index 8f91ac1ac53b3..0000000000000
--- a/src/Symfony/Component/HttpKernel/Tests/Profiler/SqliteProfilerStorageTest.php
+++ /dev/null
@@ -1,51 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\HttpKernel\Tests\Profiler;
-
-use Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage;
-
-/**
- * @group legacy
- */
-class SqliteProfilerStorageTest extends AbstractProfilerStorageTest
-{
- private $dbFile;
- private $storage;
-
- protected function setUp()
- {
- if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) {
- $this->markTestSkipped('This test requires SQLite support in your environment');
- }
-
- $this->dbFile = tempnam(sys_get_temp_dir(), 'sf2_sqlite_storage');
- if (file_exists($this->dbFile)) {
- @unlink($this->dbFile);
- }
- $this->storage = new SqliteProfilerStorage('sqlite:'.$this->dbFile);
-
- $this->storage->purge();
- }
-
- protected function tearDown()
- {
- @unlink($this->dbFile);
- }
-
- /**
- * @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface
- */
- protected function getStorage()
- {
- return $this->storage;
- }
-}
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy