MessageBodyTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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_Amf
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2014 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. if (!defined('PHPUnit_MAIN_METHOD')) {
  23. define('PHPUnit_MAIN_METHOD', 'Zend_Amf_Value_MessageBodyTest::main');
  24. }
  25. require_once 'Zend/Amf/Value/MessageBody.php';
  26. /**
  27. * Test case for Zend_Amf_Value_MessageBody
  28. *
  29. * @category Zend
  30. * @package Zend_Amf
  31. * @subpackage UnitTests
  32. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. * @group Zend_Amf
  35. */
  36. class Zend_Amf_Value_MessageBodyTest extends PHPUnit_Framework_TestCase
  37. {
  38. /**
  39. * Runs the test methods of this class.
  40. *
  41. * @return void
  42. */
  43. public static function main()
  44. {
  45. $suite = new PHPUnit_Framework_TestSuite("Zend_Amf_Value_MessageBodyTest");
  46. $result = PHPUnit_TextUI_TestRunner::run($suite);
  47. }
  48. public function setUp()
  49. {
  50. $this->body = new Zend_Amf_Value_MessageBody('/foo', '/bar', 'data');
  51. }
  52. public function testMessageBodyShouldAllowSettingData()
  53. {
  54. $this->assertEquals('data', $this->body->getData());
  55. $this->body->setData('foobar');
  56. $this->assertEquals('foobar', $this->body->getData());
  57. }
  58. public function testMessageBodyShouldAttachDataAsIs()
  59. {
  60. $object = new Zend_Amf_Value_MessageBodyTest_SerializableData();
  61. $this->body->setData($object);
  62. $this->assertSame($object, $this->body->getData());
  63. }
  64. public function testReplyMethodShouldModifyTargetUri()
  65. {
  66. $this->body->setReplyMethod('?action=bar');
  67. $this->assertEquals('/foo?action=bar', $this->body->getTargetUri());
  68. }
  69. public function testReplyMethodShouldInsertPathSeparatorIfNoQueryStringProvided()
  70. {
  71. $this->body->setReplyMethod('bar');
  72. $this->assertEquals('/foo/bar', $this->body->getTargetUri());
  73. }
  74. public function testPassingNullToTargetUriShouldResultInEmptyString()
  75. {
  76. $this->body->setTargetUri(null);
  77. $this->assertSame('', $this->body->getTargetUri());
  78. }
  79. }
  80. class Zend_Amf_Value_MessageBodyTest_SerializableData
  81. {
  82. public function __toString()
  83. {
  84. return __CLASS__;
  85. }
  86. }
  87. if (PHPUnit_MAIN_METHOD == 'Zend_Amf_Value_MessageBodyTest::main') {
  88. Zend_Amf_Value_MessageBodyTest::main();
  89. }