RegistryTest.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. require_once dirname(__FILE__) . '/../../../../TestHelper.php';
  3. require_once 'Zend/Tool/Project/Context/Repository.php';
  4. require_once 'Zend/Debug.php';
  5. class Zend_Tool_Project_Context_RepositoryTest extends PHPUnit_Framework_TestCase
  6. {
  7. public function setUp()
  8. {
  9. Zend_Tool_Project_Context_Repository::resetInstance();
  10. }
  11. public function testGetInstanceReturnsIntstance()
  12. {
  13. $this->assertEquals('Zend_Tool_Project_Context_Repository', get_class(Zend_Tool_Project_Context_Repository::getInstance()));
  14. }
  15. public function testNewRegistryHasSystemContexts()
  16. {
  17. $this->assertEquals(3, Zend_Tool_Project_Context_Repository::getInstance()->count());
  18. }
  19. public function testRegistryReturnsSystemContext()
  20. {
  21. $this->assertEquals('Zend_Tool_Project_Context_System_ProjectProfileFile', get_class(Zend_Tool_Project_Context_Repository::getInstance()->getContext('projectProfileFile')));
  22. }
  23. public function testRegistryLoadsZFContexts()
  24. {
  25. $this->_loadZfSystem();
  26. // the number of initial ZF Components
  27. $count = Zend_Tool_Project_Context_Repository::getInstance()->count();
  28. $this->assertGreaterThanOrEqual(32, $count);
  29. }
  30. /**
  31. * @expectedException Zend_Tool_Project_Context_Exception
  32. */
  33. public function testRegistryThrowsExceptionOnUnallowedContextOverwrite()
  34. {
  35. Zend_Tool_Project_Context_Repository::getInstance()->addContextClass('Zend_Tool_Project_Context_System_ProjectDirectory');
  36. }
  37. /**
  38. * @expectedException Zend_Tool_Project_Context_Exception
  39. */
  40. public function testRegistryThrowsExceptionOnUnknownContextRequest()
  41. {
  42. Zend_Tool_Project_Context_Repository::getInstance()->getContext('somethingUnknown');
  43. }
  44. protected function _loadZfSystem()
  45. {
  46. $conextRegistry = Zend_Tool_Project_Context_Repository::getInstance();
  47. $conextRegistry->addContextsFromDirectory(dirname(__FILE__) . '/../../../../../library/Zend/Tool/Project/Context/Zf/', 'Zend_Tool_Project_Context_Zf_');
  48. }
  49. }