Overview

Namespaces

  • Composer
    • Autoload
  • Guzzle
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
        • Header
      • QueryAggregator
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Mock
    • Stream
  • Mockery
    • Adapter
      • Phpunit
    • CountValidator
    • Exception
    • Generator
      • StringManipulation
        • Pass
    • Loader
    • Matcher
  • None
  • Omnipay
    • Common
      • Exception
      • Message
    • Dummy
      • Message
    • Fatzebra
      • Message
  • PHP
  • Symfony
    • Component
      • EventDispatcher
        • Debug
        • DependencyInjection
        • Tests
          • Debug
          • DependencyInjection
      • HttpFoundation
        • File
          • Exception
          • MimeType
        • Session
          • Attribute
          • Flash
          • Storage
            • Handler
            • Proxy
        • Tests
          • File
            • MimeType
          • Session
            • Attribute
            • Flash
            • Storage
              • Handler
              • Proxy
      • Yaml
        • Exception
        • Tests

Classes

  • Symfony\Component\Yaml\Tests\A
  • Symfony\Component\Yaml\Tests\B
  • Symfony\Component\Yaml\Tests\DumperTest
  • Symfony\Component\Yaml\Tests\InlineTest
  • Symfony\Component\Yaml\Tests\ParseExceptionTest
  • Symfony\Component\Yaml\Tests\ParserTest
  • Symfony\Component\Yaml\Tests\YamlTest
  • Overview
  • Namespace
  • Function
  • Tree
  1: <?php
  2: 
  3: /*
  4:  * This file is part of the Symfony package.
  5:  *
  6:  * (c) Fabien Potencier <fabien@symfony.com>
  7:  *
  8:  * For the full copyright and license information, please view the LICENSE
  9:  * file that was distributed with this source code.
 10:  */
 11: 
 12: namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
 13: 
 14: use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler;
 15: 
 16: class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase
 17: {
 18:     const PREFIX = 'prefix_';
 19:     const TTL = 1000;
 20: 
 21:     /**
 22:      * @var MemcachedSessionHandler
 23:      */
 24:     protected $storage;
 25: 
 26:     protected $memcached;
 27: 
 28:     protected function setUp()
 29:     {
 30:         if (!class_exists('Memcached')) {
 31:             $this->markTestSkipped('Skipped tests Memcached class is not present');
 32:         }
 33: 
 34:         if (version_compare(phpversion('memcached'), '2.2.0', '>=')) {
 35:             $this->markTestSkipped('Tests can only be run with memcached extension 2.1.0 or lower');
 36:         }
 37: 
 38:         $this->memcached = $this->getMock('Memcached');
 39:         $this->storage = new MemcachedSessionHandler(
 40:             $this->memcached,
 41:             array('prefix' => self::PREFIX, 'expiretime' => self::TTL)
 42:         );
 43:     }
 44: 
 45:     protected function tearDown()
 46:     {
 47:         $this->memcached = null;
 48:         $this->storage = null;
 49:     }
 50: 
 51:     public function testOpenSession()
 52:     {
 53:         $this->assertTrue($this->storage->open('', ''));
 54:     }
 55: 
 56:     public function testCloseSession()
 57:     {
 58:         $this->assertTrue($this->storage->close());
 59:     }
 60: 
 61:     public function testReadSession()
 62:     {
 63:         $this->memcached
 64:             ->expects($this->once())
 65:             ->method('get')
 66:             ->with(self::PREFIX.'id')
 67:         ;
 68: 
 69:         $this->assertEquals('', $this->storage->read('id'));
 70:     }
 71: 
 72:     public function testWriteSession()
 73:     {
 74:         $this->memcached
 75:             ->expects($this->once())
 76:             ->method('set')
 77:             ->with(self::PREFIX.'id', 'data', $this->equalTo(time() + self::TTL, 2))
 78:             ->will($this->returnValue(true))
 79:         ;
 80: 
 81:         $this->assertTrue($this->storage->write('id', 'data'));
 82:     }
 83: 
 84:     public function testDestroySession()
 85:     {
 86:         $this->memcached
 87:             ->expects($this->once())
 88:             ->method('delete')
 89:             ->with(self::PREFIX.'id')
 90:             ->will($this->returnValue(true))
 91:         ;
 92: 
 93:         $this->assertTrue($this->storage->destroy('id'));
 94:     }
 95: 
 96:     public function testGcSession()
 97:     {
 98:         $this->assertTrue($this->storage->gc(123));
 99:     }
100: 
101:     /**
102:      * @dataProvider getOptionFixtures
103:      */
104:     public function testSupportedOptions($options, $supported)
105:     {
106:         try {
107:             new MemcachedSessionHandler($this->memcached, $options);
108:             $this->assertTrue($supported);
109:         } catch (\InvalidArgumentException $e) {
110:             $this->assertFalse($supported);
111:         }
112:     }
113: 
114:     public function getOptionFixtures()
115:     {
116:         return array(
117:             array(array('prefix' => 'session'), true),
118:             array(array('expiretime' => 100), true),
119:             array(array('prefix' => 'session', 'expiretime' => 200), true),
120:             array(array('expiretime' => 100, 'foo' => 'bar'), false),
121:         );
122:     }
123: 
124:     public function testGetConnection()
125:     {
126:         $method = new \ReflectionMethod($this->storage, 'getMemcached');
127:         $method->setAccessible(true);
128: 
129:         $this->assertInstanceOf('\Memcached', $method->invoke($this->storage));
130:     }
131: }
132: 
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen