Registry class tested
This commit is contained in:
70
tests/RegistryTest.php
Normal file
70
tests/RegistryTest.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
* @package Majestic
|
||||
* @subpackage UnitTests
|
||||
* @since 2011-10-06
|
||||
*
|
||||
* Unit tests for Registry
|
||||
*/
|
||||
|
||||
require_once '../Registry.php';
|
||||
|
||||
class RegistryTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
private $_registry = null;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->_registry = Registry::getInstance();
|
||||
}
|
||||
|
||||
public function testGetInstance()
|
||||
{
|
||||
$this->assertNotNull(Registry::getInstance());
|
||||
|
||||
$this->assertNotNull($this->_registry);
|
||||
|
||||
$this->assertSame(Registry::getInstance(), $this->_registry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @TODO: make __construct private
|
||||
*/
|
||||
// public function testRegistryConstructor()
|
||||
// {
|
||||
// $this->setExpectedException('PHPUnit_Framework_Error');
|
||||
// $reg = new Registry();
|
||||
// }
|
||||
|
||||
public function testSet()
|
||||
{
|
||||
Registry::set(1, 1);
|
||||
Registry::set('two', 2);
|
||||
$this->assertEquals(Registry::get(1), $this->_registry->get(1));
|
||||
$this->assertEquals(2, Registry::get('two'));
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$this->assertEquals(Registry::get(1), $this->_registry->get(1));
|
||||
$this->assertEquals(Registry::get('two'), 2);
|
||||
$this->assertNull(Registry::get(4));
|
||||
}
|
||||
|
||||
/**
|
||||
* @TODO: check input for null
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testIsRegistered()
|
||||
{
|
||||
$this->assertFalse(Registry::isRegistered(43));
|
||||
|
||||
$this->_registry->set(3, 'three');
|
||||
$this->assertTrue(Registry::isRegistered(3));
|
||||
$this->assertFalse(Registry::isRegistered(null));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user