You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.7 KiB

<?php
/*
* @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru
* @package Majestic
* @subpackage UnitTests
* @since 2011-10-06
*
* Unit tests for Registry
*/
require_once dirname(__FILE__) . '/../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: Registry - 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: Registry::isRegistered - 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));
}
}