Cache classes tested
This commit is contained in:
70
tests/cache/CacherTest.php
vendored
Normal file
70
tests/cache/CacherTest.php
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
* @package Majestic
|
||||
* @subpackage UnitTests
|
||||
* @since 2011-10-25
|
||||
*
|
||||
* Unit tests for Cacher class
|
||||
*/
|
||||
|
||||
|
||||
require_once dirname(__FILE__) . '/../../cache/Cache.php';
|
||||
require_once dirname(__FILE__) . '/../../cache/Cacher.php';
|
||||
require_once dirname(__FILE__) . '/../../Registry.php';
|
||||
require_once dirname(__FILE__) . '/../../Config.php';
|
||||
|
||||
class CacherTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
private $mock;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
set_new_overload(array($this, 'newCallback'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExcepptionMessage Cache driver
|
||||
*/
|
||||
public function testNotExtendsCache()
|
||||
{
|
||||
Cacher::get('Cacher');
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$this->mock = $this->getMockForAbstractClass(
|
||||
'Cache', /* name of class to mock */
|
||||
array(), /* list of methods to mock */
|
||||
'CacheMock' /* name for mocked class */
|
||||
);
|
||||
|
||||
$this->assertTrue(Cacher::get('Cache') instanceof Cache);
|
||||
}
|
||||
|
||||
public function testCacheAlreadySet()
|
||||
{
|
||||
$this->assertTrue(Cacher::get('Cache') instanceof Cache);
|
||||
}
|
||||
|
||||
protected function newCallback($className)
|
||||
{
|
||||
switch ($className) {
|
||||
case 'Cache':
|
||||
return 'CacheMock';
|
||||
default:
|
||||
return $className;
|
||||
}
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
unset_new_overload();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user