ProviderMetadataTest.php 4.3 KB

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