1<?php
2/**
3 * Prepare the test setup.
4 */
5require_once dirname(__FILE__) . '/Base.php';
6
7/**
8 * Copyright 2012-2017 Horde LLC (http://www.horde.org/)
9 *
10 * @author     Jan Schneider <jan@horde.org>
11 * @category   Horde
12 * @package    Horde_SessionHandler
13 * @subpackage UnitTests
14 * @license    http://www.horde.org/licenses/lgpl21 LGPL 2.1
15 */
16class Horde_SessionHandler_Storage_MemcacheTest extends Horde_SessionHandler_Storage_Base
17{
18    protected static $reason;
19
20    public function testWrite()
21    {
22        $this->_write();
23    }
24
25    /**
26     * @depends testWrite
27     */
28    public function testRead()
29    {
30        $this->_read();
31    }
32
33    /**
34     * @depends testWrite
35     */
36    public function testReopen()
37    {
38        $this->_reopen();
39    }
40
41    /**
42     * @depends testWrite
43     */
44    public function testList()
45    {
46        $this->_list();
47    }
48
49    /**
50     * @depends testList
51     */
52    public function testDestroy()
53    {
54        $this->_destroy();
55    }
56
57    public static function setUpBeforeClass()
58    {
59        if (!(extension_loaded('memcache') || extension_loaded('memcached'))) {
60            self::$reason = 'No memcache extension.';
61            return;
62        }
63        $config = self::getConfig('SESSIONHANDLER_MEMCACHE_TEST_CONFIG',
64                                  dirname(__FILE__) . '/..');
65        if (!$config || empty($config['sessionhandler']['memcache'])) {
66            self::$reason = 'No memcache configuration.';
67            return;
68        }
69        $memcache = new Horde_Memcache($config['sessionhandler']['memcache']);
70        $memcache->delete('sessionid');
71        $memcache->delete('sessionid2');
72        self::$handler = new Horde_SessionHandler_Storage_Memcache(
73            array('memcache' => $memcache, 'track' => true));
74        parent::setUpBeforeClass();
75    }
76
77    public function setUp()
78    {
79        if (!self::$handler) {
80            $this->markTestSkipped(self::$reason);
81        }
82    }
83}
84