D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
psa
/
admin
/
plib
/
modules
/
catalog
/
vendor
/
tedivm
/
stash
/
tests
/
Stash
/
Test
/
Driver
/
Filename :
MemcacheTest.php
back
Copy
<?php /* * This file is part of the Stash package. * * (c) Robert Hafner <tedivm@tedivm.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace PleskCatalog\Stash\Test\Driver; use PleskCatalog\Stash\Test\Stubs\PoolGetDriverStub; use PleskCatalog\Stash\Driver\Memcache; use PleskCatalog\Stash\Item; /** * @package Stash * @author Robert Hafner <tedivm@tedivm.com> */ class MemcacheTest extends AbstractDriverTestCase { protected $driverClass = 'PleskCatalog\\Stash\\Driver\\Memcache'; protected $extension = 'memcache'; protected $servers = array('127.0.0.1', '11211'); protected $persistence = \true; protected function getOptions() { return array('extension' => $this->extension, 'servers' => $this->servers); } protected function setUp() : void { if (!$this->setup) { $this->startTime = \time(); $this->expiration = $this->startTime + 3600; $driverClass = $this->driverClass; if (!$driverClass::isAvailable()) { $this->markTestSkipped('Driver class unsuited for current environment'); return; } if (!\class_exists(\ucfirst($this->extension))) { $this->markTestSkipped('Test requires ' . $this->extension . ' extension'); return; } if (!($sock = @\fsockopen($this->servers[0], $this->servers[1], $errno, $errstr, 1))) { $this->markTestSkipped('Memcache tests require memcache server'); return; } \fclose($sock); $this->data['object'] = new \stdClass(); } } public function testIsAvailable() { $this->assertTrue(\PleskCatalog\Stash\Driver\Sub\Memcache::isAvailable()); } public function testConstructionOptions() { $key = array('apple', 'sauce'); $options = array(); $options['servers'][] = array('127.0.0.1', '11211', '50'); $options['servers'][] = array('127.0.0.1', '11211'); $options['extension'] = $this->extension; $driver = new Memcache($options); $item = new Item(); $poolStub = new PoolGetDriverStub(); $poolStub->setDriver($driver); $item->setPool($poolStub); $item->setKey($key); $this->assertTrue($item->set($key)->save(), 'Able to load and store memcache driver using multiple servers'); $options = array(); $options['extension'] = $this->extension; $driver = new Memcache($options); $item = new Item(); $poolStub = new PoolGetDriverStub(); $poolStub->setDriver($driver); $item->setPool($poolStub); $item->setKey($key); $this->assertTrue($item->set($key)->save(), 'Able to load and store memcache driver using default server'); } }