MessageBodyTest.php 3.0 KB

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