ActionMetadataTest.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. */
  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/ActionMetadata.php';
  29. /**
  30. * @category Zend
  31. * @package Zend_Tool
  32. * @subpackage UnitTests
  33. * @copyright Copyright (c) 2005-2009 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_ActionMetadataTest extends PHPUnit_Framework_TestCase
  40. {
  41. /**
  42. * @var Zend_Tool_Framework_Manifest_ActionMetadata
  43. */
  44. protected $_metadata = null;
  45. public function setup()
  46. {
  47. $this->_metadata = new Zend_Tool_Framework_Manifest_ActionMetadata();
  48. }
  49. public function teardown()
  50. {
  51. $this->_metadata = null;
  52. }
  53. public function testInitialTypeNameIsCorrect()
  54. {
  55. $this->assertEquals('Action', $this->_metadata->getType());
  56. }
  57. public function testConstructorWillAcceptAndPersistValues()
  58. {
  59. $obj1 = new ArrayObject();
  60. $metadata = new Zend_Tool_Framework_Manifest_ActionMetadata(array(
  61. 'name' => 'Foo',
  62. 'actionName' => 'BarBaz',
  63. 'value' => 'Bar',
  64. 'reference' => $obj1
  65. ));
  66. $this->assertEquals('Foo', $metadata->getName());
  67. $this->assertEquals('BarBaz', $metadata->getActionName());
  68. $this->assertEquals('Bar', $metadata->getValue());
  69. $this->assertTrue($obj1 === $metadata->getReference());
  70. }
  71. public function testSetOptionsPersistValues()
  72. {
  73. $obj1 = new ArrayObject();
  74. $this->_metadata->setOptions(array(
  75. 'name' => 'Foo',
  76. 'actionName' => 'BarBaz',
  77. 'value' => 'Bar',
  78. 'reference' => $obj1
  79. ));
  80. $this->assertEquals('Foo', $this->_metadata->getName());
  81. $this->assertEquals('BarBaz', $this->_metadata->getActionName());
  82. $this->assertEquals('Bar', $this->_metadata->getValue());
  83. $this->assertTrue($obj1 === $this->_metadata->getReference());
  84. }
  85. public function testSettersPersistValuesAndAreRetievableThroughGetters()
  86. {
  87. $this->_metadata->setActionName('Bar');
  88. $this->assertEquals('Bar', $this->_metadata->getActionName());
  89. }
  90. public function testMetadataObjectCanCastToStringRepresentation()
  91. {
  92. $obj1 = new ArrayObject();
  93. $this->_metadata->setOptions(array(
  94. 'name' => 'Foo',
  95. 'actionName' => 'BarBaz',
  96. 'value' => 'Bar',
  97. 'reference' => $obj1
  98. ));
  99. $this->assertEquals('Type: Action, Name: Foo, Value: Bar (ActionName: BarBaz)', (string) $this->_metadata);
  100. }
  101. }