2
0

ProviderMetadataTest.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * @see TestHelper.php
  23. */
  24. require_once dirname(__FILE__) . '/../../../../TestHelper.php';
  25. /**
  26. * @see Zend_Tool_Framework_Action_Base
  27. */
  28. require_once 'Zend/Tool/Framework/Manifest/ProviderMetadata.php';
  29. /**
  30. * @category Zend
  31. * @package Zend_Tool
  32. * @subpackage UnitTests
  33. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. *
  36. * @group Zend_Tool_Framework
  37. * @group Zend_Tool_Framework_Action
  38. */
  39. class Zend_Tool_Framework_Manifest_ProviderMetadataTest extends PHPUnit_Framework_TestCase
  40. {
  41. /**
  42. * @var Zend_Tool_Framework_Manifest_ProviderMetadata
  43. */
  44. protected $_metadata = null;
  45. public function setup()
  46. {
  47. $this->_metadata = new Zend_Tool_Framework_Manifest_ProviderMetadata();
  48. }
  49. public function teardown()
  50. {
  51. $this->_metadata = null;
  52. }
  53. public function testInitialTypeNameIsCorrect()
  54. {
  55. $this->assertEquals('Provider', $this->_metadata->getType());
  56. }
  57. public function testConstructorWillAcceptAndPersistValues()
  58. {
  59. $obj1 = new ArrayObject();
  60. $metadata = new Zend_Tool_Framework_Manifest_ProviderMetadata(array(
  61. 'name' => 'Foo',
  62. 'providerName' => 'FooBar',
  63. 'actionName' => 'BarBaz',
  64. 'specialtyName' => 'FooBarBaz',
  65. 'value' => 'Bar',
  66. 'reference' => $obj1
  67. ));
  68. $this->assertEquals('Foo', $metadata->getName());
  69. $this->assertEquals('FooBar', $metadata->getProviderName());
  70. $this->assertEquals('BarBaz', $metadata->getActionName());
  71. $this->assertEquals('FooBarBaz', $metadata->getSpecialtyName());
  72. $this->assertEquals('Bar', $metadata->getValue());
  73. $this->assertTrue($obj1 === $metadata->getReference());
  74. }
  75. public function testSetOptionsPersistValues()
  76. {
  77. $obj1 = new ArrayObject();
  78. $this->_metadata->setOptions(array(
  79. 'name' => 'Foo',
  80. 'providerName' => 'FooBar',
  81. 'actionName' => 'BarBaz',
  82. 'specialtyName' => 'FooBarBaz',
  83. 'value' => 'Bar',
  84. 'reference' => $obj1
  85. ));
  86. $this->assertEquals('Foo', $this->_metadata->getName());
  87. $this->assertEquals('FooBar', $this->_metadata->getProviderName());
  88. $this->assertEquals('BarBaz', $this->_metadata->getActionName());
  89. $this->assertEquals('FooBarBaz', $this->_metadata->getSpecialtyName());
  90. $this->assertEquals('Bar', $this->_metadata->getValue());
  91. $this->assertTrue($obj1 === $this->_metadata->getReference());
  92. }
  93. public function testSettersPersistValuesAndAreRetievableThroughGetters()
  94. {
  95. $this->_metadata->setProviderName('Foo');
  96. $this->assertEquals('Foo', $this->_metadata->getProviderName());
  97. $this->_metadata->setActionName('Bar');
  98. $this->assertEquals('Bar', $this->_metadata->getActionName());
  99. $this->_metadata->setSpecialtyName('FooBar');
  100. $this->assertEquals('FooBar', $this->_metadata->getSpecialtyName());
  101. }
  102. public function testMetadataObjectCanCastToStringRepresentation()
  103. {
  104. $obj1 = new ArrayObject();
  105. $this->_metadata->setOptions(array(
  106. 'name' => 'Foo',
  107. 'providerName' => 'FooBar',
  108. 'actionName' => 'BarBaz',
  109. 'specialtyName' => 'FooBarBaz',
  110. 'value' => 'Bar',
  111. 'reference' => $obj1
  112. ));
  113. $this->assertEquals('Type: Provider, Name: Foo, Value: Bar (ProviderName: FooBar, ActionName: BarBaz, SpecialtyName: FooBarBaz)', (string) $this->_metadata);
  114. }
  115. }