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.

69 lines
1.7 KiB

13 years ago
13 years ago
  1. <?php
  2. /*
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage UnitTests
  7. * @since 2011-10-06
  8. *
  9. * Unit tests for Registry
  10. */
  11. require_once dirname(__FILE__) . '/../Registry.php';
  12. class RegistryTest extends PHPUnit_Framework_TestCase
  13. {
  14. private $_registry = null;
  15. public function setUp()
  16. {
  17. $this->_registry = Registry::getInstance();
  18. }
  19. public function testGetInstance()
  20. {
  21. $this->assertNotNull(Registry::getInstance());
  22. $this->assertNotNull($this->_registry);
  23. $this->assertSame(Registry::getInstance(), $this->_registry);
  24. }
  25. /**
  26. * @TODO: Registry - make __construct private
  27. */
  28. // public function testRegistryConstructor()
  29. // {
  30. // $this->setExpectedException('PHPUnit_Framework_Error');
  31. // $reg = new Registry();
  32. // }
  33. public function testSet()
  34. {
  35. Registry::set(1, 1);
  36. Registry::set('two', 2);
  37. $this->assertEquals(Registry::get(1), $this->_registry->get(1));
  38. $this->assertEquals(2, Registry::get('two'));
  39. }
  40. public function testGet()
  41. {
  42. $this->assertEquals(Registry::get(1), $this->_registry->get(1));
  43. $this->assertEquals(Registry::get('two'), 2);
  44. $this->assertNull(Registry::get(4));
  45. }
  46. /**
  47. * @TODO: Registry::isRegistered - check input for null
  48. * @expectedException PHPUnit_Framework_Error
  49. */
  50. public function testIsRegistered()
  51. {
  52. $this->assertFalse(Registry::isRegistered(43));
  53. $this->_registry->set(3, 'three');
  54. $this->assertTrue(Registry::isRegistered(3));
  55. $this->assertFalse(Registry::isRegistered(null));
  56. }
  57. }