RegistryTest.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Tool
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. require_once dirname(__FILE__) . '/../../../../TestHelper.php';
  23. require_once 'Zend/Tool/Project/Context/Repository.php';
  24. require_once 'Zend/Debug.php';
  25. /**
  26. * @category Zend
  27. * @package Zend_Tool
  28. * @subpackage UnitTests
  29. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. *
  32. * @group Zend_Tool
  33. * @group Zend_Tool_Project
  34. */
  35. class Zend_Tool_Project_Context_RepositoryTest extends PHPUnit_Framework_TestCase
  36. {
  37. public function setUp()
  38. {
  39. Zend_Tool_Project_Context_Repository::resetInstance();
  40. }
  41. public function testGetInstanceReturnsIntstance()
  42. {
  43. $this->assertEquals('Zend_Tool_Project_Context_Repository', get_class(Zend_Tool_Project_Context_Repository::getInstance()));
  44. }
  45. public function testNewRegistryHasSystemContexts()
  46. {
  47. $this->assertEquals(3, Zend_Tool_Project_Context_Repository::getInstance()->count());
  48. }
  49. public function testRegistryReturnsSystemContext()
  50. {
  51. $this->assertEquals('Zend_Tool_Project_Context_System_ProjectProfileFile', get_class(Zend_Tool_Project_Context_Repository::getInstance()->getContext('projectProfileFile')));
  52. }
  53. public function testRegistryLoadsZFContexts()
  54. {
  55. $this->_loadZfSystem();
  56. // the number of initial ZF Components
  57. $count = Zend_Tool_Project_Context_Repository::getInstance()->count();
  58. $this->assertGreaterThanOrEqual(32, $count);
  59. }
  60. /**
  61. * @expectedException Zend_Tool_Project_Context_Exception
  62. */
  63. public function testRegistryThrowsExceptionOnUnallowedContextOverwrite()
  64. {
  65. Zend_Tool_Project_Context_Repository::getInstance()->addContextClass('Zend_Tool_Project_Context_System_ProjectDirectory');
  66. }
  67. /**
  68. * @expectedException Zend_Tool_Project_Context_Exception
  69. */
  70. public function testRegistryThrowsExceptionOnUnknownContextRequest()
  71. {
  72. Zend_Tool_Project_Context_Repository::getInstance()->getContext('somethingUnknown');
  73. }
  74. protected function _loadZfSystem()
  75. {
  76. $conextRegistry = Zend_Tool_Project_Context_Repository::getInstance();
  77. $conextRegistry->addContextsFromDirectory(dirname(__FILE__) . '/../../../../../library/Zend/Tool/Project/Context/Zf/', 'Zend_Tool_Project_Context_Zf_');
  78. }
  79. }