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.

71 lines
1.8 KiB

13 years ago
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->assertFalse(Registry::isRegistered(10));
  18. $this->_registry = Registry::getInstance();
  19. }
  20. public function testGetInstance()
  21. {
  22. $this->assertNotNull(Registry::getInstance());
  23. $this->assertNotNull($this->_registry);
  24. $this->assertSame(Registry::getInstance(), $this->_registry);
  25. }
  26. /**
  27. * @TODO: Registry - make __construct private
  28. */
  29. // public function testRegistryConstructor()
  30. // {
  31. // $this->setExpectedException('PHPUnit_Framework_Error');
  32. // $reg = new Registry();
  33. // }
  34. public function testSet()
  35. {
  36. Registry::set(1, 1);
  37. Registry::set('two', 2);
  38. $this->assertSame(Registry::get(1), $this->_registry->get(1));
  39. $this->assertSame(2, Registry::get('two'));
  40. }
  41. public function testGet()
  42. {
  43. $this->assertSame(Registry::get(1), $this->_registry->get(1));
  44. $this->assertSame(Registry::get('two'), 2);
  45. $this->assertNull(Registry::get(4));
  46. }
  47. /**
  48. * @TODO: Registry::isRegistered - check input for null
  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->setExpectedException('PHPUnit_Framework_Error');
  56. $this->assertFalse(Registry::isRegistered(null));
  57. }
  58. }