OnlineTest.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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_Soap
  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. require_once dirname(__FILE__)."/../../../TestHelper.php";
  23. require_once dirname(__FILE__)."/../_files/commontypes.php";
  24. /** Zend_Soap_Server */
  25. require_once 'Zend/Soap/Client.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Soap
  29. * @subpackage UnitTests
  30. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. * @group Zend_Soap
  33. */
  34. class Zend_Soap_AutoDiscover_OnlineTest extends PHPUnit_Framework_TestCase
  35. {
  36. protected $baseuri;
  37. public function setUp()
  38. {
  39. if(!defined('TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI') || constant('TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI') == false) {
  40. $this->markTestSkipped('The constant TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI has to be defined to allow the Online test to work.');
  41. }
  42. $this->baseuri = TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI;
  43. }
  44. public function testNestedObjectArrayResponse()
  45. {
  46. $wsdl = $this->baseuri."/server1.php?wsdl";
  47. $b = new Zend_Soap_Wsdl_ComplexTypeB();
  48. $b->bar = "test";
  49. $b->foo = "test";
  50. $client = new Zend_Soap_Client($wsdl);
  51. $ret = $client->request($b);
  52. $this->assertTrue( is_array($ret) );
  53. $this->assertEquals(1, count($ret) );
  54. $this->assertTrue( is_array($ret[0]->baz) );
  55. $this->assertEquals(3, count($ret[0]->baz) );
  56. $baz = $ret[0]->baz;
  57. $this->assertEquals("bar", $baz[0]->bar);
  58. $this->assertEquals("bar", $baz[0]->foo);
  59. $this->assertEquals("foo", $baz[1]->bar);
  60. $this->assertEquals("foo", $baz[1]->foo);
  61. $this->assertEquals("test", $baz[2]->bar);
  62. $this->assertEquals("test", $baz[2]->foo);
  63. }
  64. public function testObjectResponse()
  65. {
  66. $wsdl = $this->baseuri."/server2.php?wsdl";
  67. $client = new Zend_Soap_Client($wsdl);
  68. $ret = $client->request("test", "test");
  69. $this->assertTrue( ($ret instanceof stdClass) );
  70. $this->assertEquals("test", $ret->foo);
  71. $this->assertEquals("test", $ret->bar);
  72. }
  73. }