RegistryTest.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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-2015 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 'Zend/Tool/Project/Context/Repository.php';
  23. require_once 'Zend/Debug.php';
  24. /**
  25. * @category Zend
  26. * @package Zend_Tool
  27. * @subpackage UnitTests
  28. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. *
  31. * @group Zend_Tool
  32. * @group Zend_Tool_Project
  33. */
  34. class Zend_Tool_Project_Context_RepositoryTest extends PHPUnit_Framework_TestCase
  35. {
  36. public function setUp()
  37. {
  38. Zend_Tool_Project_Context_Repository::resetInstance();
  39. }
  40. public function testGetInstanceReturnsIntstance()
  41. {
  42. $this->assertEquals('Zend_Tool_Project_Context_Repository', get_class(Zend_Tool_Project_Context_Repository::getInstance()));
  43. }
  44. public function testNewRegistryHasSystemContexts()
  45. {
  46. $this->assertEquals(3, Zend_Tool_Project_Context_Repository::getInstance()->count());
  47. }
  48. public function testRegistryReturnsSystemContext()
  49. {
  50. $this->assertEquals('Zend_Tool_Project_Context_System_ProjectProfileFile', get_class(Zend_Tool_Project_Context_Repository::getInstance()->getContext('projectProfileFile')));
  51. }
  52. public function testRegistryLoadsZFContexts()
  53. {
  54. $this->_loadZfSystem();
  55. // the number of initial ZF Components
  56. $count = Zend_Tool_Project_Context_Repository::getInstance()->count();
  57. $this->assertGreaterThanOrEqual(32, $count);
  58. }
  59. /**
  60. * @expectedException Zend_Tool_Project_Context_Exception
  61. */
  62. public function testRegistryThrowsExceptionOnUnallowedContextOverwrite()
  63. {
  64. Zend_Tool_Project_Context_Repository::getInstance()->addContextClass('Zend_Tool_Project_Context_System_ProjectDirectory');
  65. }
  66. /**
  67. * @expectedException Zend_Tool_Project_Context_Exception
  68. */
  69. public function testRegistryThrowsExceptionOnUnknownContextRequest()
  70. {
  71. Zend_Tool_Project_Context_Repository::getInstance()->getContext('somethingUnknown');
  72. }
  73. protected function _loadZfSystem()
  74. {
  75. $conextRegistry = Zend_Tool_Project_Context_Repository::getInstance();
  76. $conextRegistry->addContextsFromDirectory(dirname(__FILE__) . '/../../../../../library/Zend/Tool/Project/Context/Zf/', 'Zend_Tool_Project_Context_Zf_');
  77. }
  78. }