home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / SOAP / Interop / interop_test.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  4.5 KB  |  138 lines

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Shane Caraveo <Shane@Caraveo.com>                           |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: interop_test.php,v 1.10 2007/01/26 17:21:44 yunosh Exp $
  20. //
  21. require_once 'SOAP/Value.php';
  22.  
  23. define('SOAP_TEST_ACTOR_NEXT','http://schemas.xmlsoap.org/soap/actor/next');
  24. define('SOAP_TEST_ACTOR_OTHER','http://some/other/actor');
  25.  
  26. class SOAP_Interop_Test {
  27.  
  28.     var $type = 'php';
  29.     var $test_name = null;
  30.     var $method_name = null;
  31.     var $method_params = null;
  32.     var $expect = null;
  33.     var $expect_fault = false;
  34.     var $headers = null;
  35.     var $headers_expect = null;
  36.     var $result = array();
  37.     var $show = 1;
  38.     var $debug = 0;
  39.     var $encoding = SOAP_DEFAULT_ENCODING;
  40.  
  41.     /**
  42.      * If multiple services, this sets to a specific service.
  43.      */
  44.     var $service = null;
  45.     
  46.     function SOAP_Interop_Test($methodname, $params, $expect = null)
  47.     {
  48.         if (strchr($methodname, '(')) {
  49.             preg_match('/(.*)\((.*)\)/', $methodname, $matches);
  50.             $this->test_name = $methodname;
  51.             $this->method_name = $matches[1];
  52.         } else {
  53.             $this->test_name = $this->method_name = $methodname;
  54.         }
  55.         $this->method_params = $params;
  56.         $this->expect = $expect;
  57.  
  58.         // determine test type
  59.         if ($params) {
  60.             $v = array_values($params);
  61.             if (gettype($v[0]) == 'object' &&
  62.                 strtolower(get_class($v[0])) == 'soap_value') {
  63.                 $this->type = 'soapval';
  64.             }
  65.         }
  66.     }
  67.     
  68.     function setResult($ok, $result, $wire, $error = '', $fault = null)
  69.     {
  70.         $this->result['success'] = $ok;
  71.         $this->result['result'] = $result;
  72.         $this->result['error'] = $error;
  73.         $this->result['wire'] = $wire;
  74.         $this->result['fault'] = $fault;
  75.     }
  76.  
  77.     function reset()
  78.     {
  79.         $this->result = array();
  80.     }
  81.     
  82.     /**
  83.      * Prints simple output about a methods result.
  84.      */    
  85.     function showTestResult($debug = 0)
  86.     {
  87.         // Debug output
  88.         if ($debug) {
  89.             $this->show = 1;
  90.             echo str_repeat('-', 50) . "\n";
  91.         }
  92.         
  93.         echo "Testing $this->test_name: ";
  94.         if ($this->headers) {
  95.             $hc = count($this->headers);
  96.             for ($i = 0; $i < $hc; $i++) {
  97.                 $h = $this->headers[$i];
  98.                 if (strtolower(get_class($h)) == 'soap_header') {
  99.                     echo "\n    {$h->name},{$h->attributes['SOAP-ENV:actor']},{$h->attributes['SOAP-ENV:mustUnderstand']} : ";
  100.                 } else {
  101.                     if (!$h[4]) {
  102.                         $h[4] = SOAP_TEST_ACTOR_NEXT;
  103.                     }
  104.                     if (!$h[3]) {
  105.                         $h[3] = 0;
  106.                     }
  107.                     echo "\n    $h[0],$h[4],$h[3] : ";
  108.                 }
  109.             }
  110.         }
  111.         
  112.         if ($debug) {
  113.             echo "method params: ";
  114.             print_r($this->params);
  115.             echo "\n";
  116.         }
  117.         
  118.         $ok = $this->result['success'];
  119.         if ($ok) {
  120.             echo "SUCCESS\n";
  121.         } else {
  122.             $fault = $this->result['fault'];
  123.             if ($fault) {
  124.                 echo "FAILED: [{$fault->faultcode}] {$fault->faultstring}\n";
  125.                 if (!empty($fault->faultdetail)) {
  126.                     echo $fault->faultdetail . "\n";
  127.                 }
  128.             } else {
  129.                 echo "FAILED: " . $this->result['result'] . "\n";
  130.             }
  131.         }
  132.         if ($debug) {
  133.             echo "\n" . $this->result['wire'] . "\n";
  134.         }
  135.     }
  136.  
  137. }
  138.