OnlineTest.php 2.8 KB

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