ProviderMetadataTest.php 4.4 KB

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