ActionMetadataTest.php 3.4 KB

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