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\MemcacheSessionHandler;
 15: 
 16: class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase
 17: {
 18:     const PREFIX = 'prefix_';
 19:     const TTL = 1000;
 20:     /**
 21:      * @var MemcacheSessionHandler
 22:      */
 23:     protected $storage;
 24: 
 25:     protected $memcache;
 26: 
 27:     protected function setUp()
 28:     {
 29:         if (!class_exists('Memcache')) {
 30:             $this->markTestSkipped('Skipped tests Memcache class is not present');
 31:         }
 32: 
 33:         $this->memcache = $this->getMock('Memcache');
 34:         $this->storage = new MemcacheSessionHandler(
 35:             $this->memcache,
 36:             array('prefix' => self::PREFIX, 'expiretime' => self::TTL)
 37:         );
 38:     }
 39: 
 40:     protected function tearDown()
 41:     {
 42:         $this->memcache = null;
 43:         $this->storage = null;
 44:     }
 45: 
 46:     public function testOpenSession()
 47:     {
 48:         $this->assertTrue($this->storage->open('', ''));
 49:     }
 50: 
 51:     public function testCloseSession()
 52:     {
 53:         $this->memcache
 54:             ->expects($this->once())
 55:             ->method('close')
 56:             ->will($this->returnValue(true))
 57:         ;
 58: 
 59:         $this->assertTrue($this->storage->close());
 60:     }
 61: 
 62:     public function testReadSession()
 63:     {
 64:         $this->memcache
 65:             ->expects($this->once())
 66:             ->method('get')
 67:             ->with(self::PREFIX.'id')
 68:         ;
 69: 
 70:         $this->assertEquals('', $this->storage->read('id'));
 71:     }
 72: 
 73:     public function testWriteSession()
 74:     {
 75:         $this->memcache
 76:             ->expects($this->once())
 77:             ->method('set')
 78:             ->with(self::PREFIX.'id', 'data', 0, $this->equalTo(time() + self::TTL, 2))
 79:             ->will($this->returnValue(true))
 80:         ;
 81: 
 82:         $this->assertTrue($this->storage->write('id', 'data'));
 83:     }
 84: 
 85:     public function testDestroySession()
 86:     {
 87:         $this->memcache
 88:             ->expects($this->once())
 89:             ->method('delete')
 90:             ->with(self::PREFIX.'id')
 91:             ->will($this->returnValue(true))
 92:         ;
 93: 
 94:         $this->assertTrue($this->storage->destroy('id'));
 95:     }
 96: 
 97:     public function testGcSession()
 98:     {
 99:         $this->assertTrue($this->storage->gc(123));
100:     }
101: 
102:     /**
103:      * @dataProvider getOptionFixtures
104:      */
105:     public function testSupportedOptions($options, $supported)
106:     {
107:         try {
108:             new MemcacheSessionHandler($this->memcache, $options);
109:             $this->assertTrue($supported);
110:         } catch (\InvalidArgumentException $e) {
111:             $this->assertFalse($supported);
112:         }
113:     }
114: 
115:     public function getOptionFixtures()
116:     {
117:         return array(
118:             array(array('prefix' => 'session'), true),
119:             array(array('expiretime' => 100), true),
120:             array(array('prefix' => 'session', 'expiretime' => 200), true),
121:             array(array('expiretime' => 100, 'foo' => 'bar'), false),
122:         );
123:     }
124: 
125:     public function testGetConnection()
126:     {
127:         $method = new \ReflectionMethod($this->storage, 'getMemcache');
128:         $method->setAccessible(true);
129: 
130:         $this->assertInstanceOf('\Memcache', $method->invoke($this->storage));
131:     }
132: }
133: 
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen