Files
majestic/Tests/RegistryTest.php

72 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2011-10-06 12:11:04 +04:00
<?php
/*
* @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru
* @package Majestic
* @subpackage UnitTests
* @since 2011-10-06
*
* Unit tests for Registry
*/
2011-10-06 18:04:05 +04:00
require_once dirname(__FILE__) . '/../Registry.php';
2011-10-06 12:11:04 +04:00
class RegistryTest extends PHPUnit_Framework_TestCase
{
private $_registry = null;
public function setUp()
{
2011-10-06 19:19:40 +04:00
$this->assertFalse(Registry::isRegistered(10));
2011-10-06 12:11:04 +04:00
$this->_registry = Registry::getInstance();
}
public function testGetInstance()
{
$this->assertNotNull(Registry::getInstance());
$this->assertNotNull($this->_registry);
$this->assertSame(Registry::getInstance(), $this->_registry);
}
/**
2011-10-06 16:33:50 +04:00
* @TODO: Registry - make __construct private
2011-10-06 12:11:04 +04:00
*/
// public function testRegistryConstructor()
// {
// $this->setExpectedException('PHPUnit_Framework_Error');
// $reg = new Registry();
// }
public function testSet()
{
Registry::set(1, 1);
Registry::set('two', 2);
$this->assertSame(Registry::get(1), $this->_registry->get(1));
$this->assertSame(2, Registry::get('two'));
2011-10-06 12:11:04 +04:00
}
public function testGet()
{
$this->assertSame(Registry::get(1), $this->_registry->get(1));
$this->assertSame(Registry::get('two'), 2);
2011-10-06 12:11:04 +04:00
$this->assertNull(Registry::get(4));
}
/**
2011-10-06 16:33:50 +04:00
* @TODO: Registry::isRegistered - check input for null
2011-10-06 12:11:04 +04:00
*/
public function testIsRegistered()
{
$this->assertFalse(Registry::isRegistered(43));
$this->_registry->set(3, 'three');
$this->assertTrue(Registry::isRegistered(3));
2011-12-02 12:25:47 +04:00
$this->setExpectedException('PHPUnit_Framework_Error');
2011-10-06 12:11:04 +04:00
$this->assertFalse(Registry::isRegistered(null));
}
}