| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 | 
							- <?php
 
- /**
 
-  * Zend Framework
 
-  *
 
-  * LICENSE
 
-  *
 
-  * This source file is subject to the new BSD license that is bundled
 
-  * with this package in the file LICENSE.txt.
 
-  * It is also available through the world-wide-web at this URL:
 
-  * http://framework.zend.com/license/new-bsd
 
-  * If you did not receive a copy of the license and are unable to
 
-  * obtain it through the world-wide-web, please send an email
 
-  * to license@zend.com so we can send you a copy immediately.
 
-  *
 
-  * @category   Zend
 
-  * @package    Zend_Cache
 
-  * @subpackage UnitTests
 
-  * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 
-  * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
-  * @version    $Id: CommonBackendTest.php 23775 2011-03-01 17:25:24Z ralph $
 
-  */
 
- // backward compatibility (https://stackoverflow.com/a/42828632/187780)
 
- if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) {
 
-     class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
 
- }
 
- /**
 
-  * @category   Zend
 
-  * @package    Zend_Cache
 
-  * @subpackage UnitTests
 
-  * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 
-  * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
-  * @group      Zend_Cache
 
-  */
 
- abstract class Zend_Cache_CommonBackendTest extends \PHPUnit\Framework\TestCase {
 
-     protected $_instance;
 
-     protected $_className;
 
-     protected $_root;
 
-     public function __construct($name = null, array $data = array(), $dataName = '')
 
-     {
 
-         $this->_className = $name;
 
-         $this->_root = dirname(__FILE__);
 
-         date_default_timezone_set('UTC');
 
-         parent::__construct($name, $data, $dataName);
 
-     }
 
-     public function setUp($notag = false)
 
-     {
 
-         $this->mkdir();
 
-         $this->_instance->setDirectives(array('logging' => true));
 
-         if ($notag) {
 
-             $this->_instance->save('bar : data to cache', 'bar');
 
-             $this->_instance->save('bar2 : data to cache', 'bar2');
 
-             $this->_instance->save('bar3 : data to cache', 'bar3');
 
-         } else {
 
-             $this->_instance->save('bar : data to cache', 'bar', array('tag3', 'tag4'));
 
-             $this->_instance->save('bar2 : data to cache', 'bar2', array('tag3', 'tag1'));
 
-             $this->_instance->save('bar3 : data to cache', 'bar3', array('tag2', 'tag3'));
 
-         }
 
-     }
 
-     public function mkdir()
 
-     {
 
-         @mkdir($this->getTmpDir());
 
-     }
 
-     public function rmdir()
 
-     {
 
-         $tmpDir = $this->getTmpDir(false);
 
-         foreach (glob("$tmpDir*") as $dirname) {
 
-             @rmdir($dirname);
 
-         }
 
-     }
 
-     public function getTmpDir($date = true)
 
-     {
 
-         $suffix = '';
 
-         if ($date) {
 
-             $suffix = date('mdyHis');
 
-         }
 
-         if (is_writeable($this->_root)) {
 
-             return $this->_root . DIRECTORY_SEPARATOR . 'zend_cache_tmp_dir_' . $suffix;
 
-         } else if (getenv('TMPDIR')){
 
-             return getenv('TMPDIR') . DIRECTORY_SEPARATOR . 'zend_cache_tmp_dir_' . $suffix;
 
-         } else {
 
-             die("no writable tmpdir found");
 
-         }
 
-     }
 
-     public function tearDown()
 
-     {
 
-         if ($this->_instance) {
 
-             $this->_instance->clean();
 
-         }
 
-         $this->rmdir();
 
-     }
 
-     public function testConstructorCorrectCall()
 
-     {
 
-         $this->fail('PLEASE IMPLEMENT A testConstructorCorrectCall !!!');
 
-     }
 
-     public function testConstructorBadOption()
 
-     {
 
-         try {
 
-             $class = $this->_className;
 
-             $test = new $class(array(1 => 'bar'));
 
-         } catch (Zend_Cache_Exception $e) {
 
-             return;
 
-         }
 
-         $this->fail('Zend_Cache_Exception was expected but not thrown');
 
-     }
 
-     public function testSetDirectivesCorrectCall()
 
-     {
 
-         $this->_instance->setDirectives(array('lifetime' => 3600, 'logging' => true));
 
-     }
 
-     public function testSetDirectivesBadArgument()
 
-     {
 
-         try {
 
-             $this->_instance->setDirectives('foo');
 
-         } catch (Zend_Cache_Exception $e) {
 
-             return;
 
-         }
 
-         $this->fail('Zend_Cache_Exception was expected but not thrown');
 
-     }
 
-     public function testSetDirectivesBadDirective()
 
-     {
 
-         // A bad directive (not known by a specific backend) is possible
 
-         // => so no exception here
 
-         $this->_instance->setDirectives(array('foo' => true, 'lifetime' => 3600));
 
-     }
 
-     public function testSetDirectivesBadDirective2()
 
-     {
 
-         try {
 
-             $this->_instance->setDirectives(array('foo' => true, 12 => 3600));
 
-         } catch (Zend_Cache_Exception $e) {
 
-             return;
 
-         }
 
-         $this->fail('Zend_Cache_Exception was expected but not thrown');
 
-     }
 
-     public function testSaveCorrectCall()
 
-     {
 
-         $res = $this->_instance->save('data to cache', 'foo', array('tag1', 'tag2'));
 
-         $this->assertTrue($res);
 
-     }
 
-     public function testSaveWithNullLifeTime()
 
-     {
 
-         $this->_instance->setDirectives(array('lifetime' => null));
 
-         $res = $this->_instance->save('data to cache', 'foo', array('tag1', 'tag2'));
 
-         $this->assertTrue($res);
 
-     }
 
-     public function testSaveWithSpecificLifeTime()
 
-     {
 
-         $this->_instance->setDirectives(array('lifetime' => 3600));
 
-         $res = $this->_instance->save('data to cache', 'foo', array('tag1', 'tag2'), 10);
 
-         $this->assertTrue($res);
 
-     }
 
-     public function testRemoveCorrectCall()
 
-     {
 
-         $this->assertTrue($this->_instance->remove('bar'));
 
-         $this->assertFalse($this->_instance->test('bar'));
 
-         $this->assertFalse($this->_instance->remove('barbar'));
 
-         $this->assertFalse($this->_instance->test('barbar'));
 
-     }
 
-     public function testTestWithAnExistingCacheId()
 
-     {
 
-         $res = $this->_instance->test('bar');
 
-         if (!$res) {
 
-             $this->fail('test() return false');
 
-         }
 
-         if (!($res > 999999)) {
 
-             $this->fail('test() return an incorrect integer');
 
-         }
 
-         return;
 
-     }
 
-     public function testTestWithANonExistingCacheId()
 
-     {
 
-         $this->assertFalse($this->_instance->test('barbar'));
 
-     }
 
-     public function testTestWithAnExistingCacheIdAndANullLifeTime()
 
-     {
 
-         $this->_instance->setDirectives(array('lifetime' => null));
 
-         $res = $this->_instance->test('bar');
 
-         if (!$res) {
 
-             $this->fail('test() return false');
 
-         }
 
-         if (!($res > 999999)) {
 
-             $this->fail('test() return an incorrect integer');
 
-         }
 
-         return;
 
-     }
 
-     public function testGetWithANonExistingCacheId()
 
-     {
 
-         $this->assertFalse($this->_instance->load('barbar'));
 
-     }
 
-     public function testGetWithAnExistingCacheId()
 
-     {
 
-         $this->assertEquals('bar : data to cache', $this->_instance->load('bar'));
 
-     }
 
-     public function testGetWithAnExistingCacheIdAndUTFCharacters()
 
-     {
 
-         $data = '"""""' . "'" . '\n' . 'ééééé';
 
-         $this->_instance->save($data, 'foo');
 
-         $this->assertEquals($data, $this->_instance->load('foo'));
 
-     }
 
-     public function testGetWithAnExpiredCacheId()
 
-     {
 
-         $this->_instance->___expire('bar');
 
-         $this->_instance->setDirectives(array('lifetime' => -1));
 
-         $this->assertFalse($this->_instance->load('bar'));
 
-         $this->assertEquals('bar : data to cache', $this->_instance->load('bar', true));
 
-     }
 
-     public function testCleanModeAll()
 
-     {
 
-         $this->assertTrue($this->_instance->clean('all'));
 
-         $this->assertFalse($this->_instance->test('bar'));
 
-         $this->assertFalse($this->_instance->test('bar2'));
 
-     }
 
-     public function testCleanModeOld()
 
-     {
 
-         $this->_instance->___expire('bar2');
 
-         $this->assertTrue($this->_instance->clean('old'));
 
-         $this->assertTrue($this->_instance->test('bar') > 999999);
 
-         $this->assertFalse($this->_instance->test('bar2'));
 
-     }
 
-     public function testCleanModeMatchingTags()
 
-     {
 
-         $this->assertTrue($this->_instance->clean('matchingTag', array('tag3')));
 
-         $this->assertFalse($this->_instance->test('bar'));
 
-         $this->assertFalse($this->_instance->test('bar2'));
 
-     }
 
-     public function testCleanModeMatchingTags2()
 
-     {
 
-         $this->assertTrue($this->_instance->clean('matchingTag', array('tag3', 'tag4')));
 
-         $this->assertFalse($this->_instance->test('bar'));
 
-         $this->assertTrue($this->_instance->test('bar2') > 999999);
 
-     }
 
-     public function testCleanModeNotMatchingTags()
 
-     {
 
-         $this->assertTrue($this->_instance->clean('notMatchingTag', array('tag3')));
 
-         $this->assertTrue($this->_instance->test('bar') > 999999);
 
-         $this->assertTrue($this->_instance->test('bar2') > 999999);
 
-     }
 
-     public function testCleanModeNotMatchingTags2()
 
-     {
 
-         $this->assertTrue($this->_instance->clean('notMatchingTag', array('tag4')));
 
-         $this->assertTrue($this->_instance->test('bar') > 999999);
 
-         $this->assertFalse($this->_instance->test('bar2'));
 
-     }
 
-     public function testCleanModeNotMatchingTags3()
 
-     {
 
-         $this->assertTrue($this->_instance->clean('notMatchingTag', array('tag4', 'tag1')));
 
-         $this->assertTrue($this->_instance->test('bar') > 999999);
 
-         $this->assertTrue($this->_instance->test('bar2') > 999999);
 
-         $this->assertFalse($this->_instance->test('bar3'));
 
-     }
 
- }
 
 
  |