2
0

ActionMetadataTest.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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/ActionMetadata.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_ActionMetadataTest extends PHPUnit_Framework_TestCase
  42. {
  43. /**
  44. * @var Zend_Tool_Framework_Manifest_ActionMetadata
  45. */
  46. protected $_metadata = null;
  47. public function setup()
  48. {
  49. $this->_metadata = new Zend_Tool_Framework_Manifest_ActionMetadata();
  50. }
  51. public function teardown()
  52. {
  53. $this->_metadata = null;
  54. }
  55. public function testInitialTypeNameIsCorrect()
  56. {
  57. $this->assertEquals('Action', $this->_metadata->getType());
  58. }
  59. public function testConstructorWillAcceptAndPersistValues()
  60. {
  61. $obj1 = new ArrayObject();
  62. $metadata = new Zend_Tool_Framework_Manifest_ActionMetadata(array(
  63. 'name' => 'Foo',
  64. 'actionName' => 'BarBaz',
  65. 'value' => 'Bar',
  66. 'reference' => $obj1
  67. ));
  68. $this->assertEquals('Foo', $metadata->getName());
  69. $this->assertEquals('BarBaz', $metadata->getActionName());
  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. 'actionName' => 'BarBaz',
  79. 'value' => 'Bar',
  80. 'reference' => $obj1
  81. ));
  82. $this->assertEquals('Foo', $this->_metadata->getName());
  83. $this->assertEquals('BarBaz', $this->_metadata->getActionName());
  84. $this->assertEquals('Bar', $this->_metadata->getValue());
  85. $this->assertTrue($obj1 === $this->_metadata->getReference());
  86. }
  87. public function testSettersPersistValuesAndAreRetievableThroughGetters()
  88. {
  89. $this->_metadata->setActionName('Bar');
  90. $this->assertEquals('Bar', $this->_metadata->getActionName());
  91. }
  92. public function testMetadataObjectCanCastToStringRepresentation()
  93. {
  94. $obj1 = new ArrayObject();
  95. $this->_metadata->setOptions(array(
  96. 'name' => 'Foo',
  97. 'actionName' => 'BarBaz',
  98. 'value' => 'Bar',
  99. 'reference' => $obj1
  100. ));
  101. $this->assertEquals('Type: Action, Name: Foo, Value: Bar (ActionName: BarBaz)', (string) $this->_metadata);
  102. }
  103. }