D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
psa
/
admin
/
plib
/
modules
/
catalog
/
vendor
/
tedivm
/
stash
/
tests
/
Stash
/
Test
/
Filename :
CacheExceptionTest.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; use PleskCatalog\Stash\Test\Stubs\DriverExceptionStub; use PleskCatalog\Stash\Test\Stubs\PoolGetDriverStub; use PleskCatalog\Stash\Pool; use PleskCatalog\Stash\Item; /** * @package Stash * @author Robert Hafner <tedivm@tedivm.com> */ class CacheExceptionTest extends \PleskCatalog\PHPUnit\Framework\TestCase { public function testSet() { $item = new Item(); $poolStub = new PoolGetDriverStub(); $poolStub->setDriver(new DriverExceptionStub()); $item->setPool($poolStub); $item->setKey(array('path', 'to', 'store')); $this->assertFalse($item->isDisabled()); $this->assertFalse($item->set(array(1, 2, 3), 3600)->save()); $this->assertTrue($item->isDisabled(), 'Is disabled after exception is thrown in driver'); } public function testGet() { $item = new Item(); $poolStub = new PoolGetDriverStub(); $poolStub->setDriver(new DriverExceptionStub()); $item->setPool($poolStub); $item->setKey(array('path', 'to', 'get')); $this->assertFalse($item->isDisabled()); $this->assertNull($item->get()); $this->assertTrue($item->isDisabled(), 'Is disabled after exception is thrown in driver'); } public function testClear() { $item = new Item(); $poolStub = new PoolGetDriverStub(); $poolStub->setDriver(new DriverExceptionStub()); $item->setPool($poolStub); $item->setKey(array('path', 'to', 'clear')); $this->assertFalse($item->isDisabled()); $this->assertFalse($item->clear()); $this->assertTrue($item->isDisabled(), 'Is disabled after exception is thrown in driver'); } public function testPurge() { $pool = new Pool(); $pool->setDriver(new DriverExceptionStub()); $item = $pool->getItem('test'); $this->assertFalse($item->isDisabled()); $this->assertFalse($pool->purge()); $item = $pool->getItem('test'); $this->assertTrue($item->isDisabled(), 'Is disabled after exception is thrown in driver'); $this->assertFalse($pool->purge()); } public function testPoolClear() { $pool = new Pool(); $pool->setDriver(new DriverExceptionStub()); $item = $pool->getItem('test'); $this->assertFalse($item->isDisabled()); $this->assertFalse($pool->clear()); $item = $pool->getItem('test'); $this->assertTrue($item->isDisabled(), 'Is disabled after exception is thrown in driver'); $this->assertFalse($pool->clear()); } }