[ Index ]
 

Code source de PHP PEAR 1.4.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/tests/XML_RPC/tests/ -> extra-lines.php (source)

   1  <?php
   2  
   3  /**
   4   * Tests how the XML_RPC server handles parameters with empty values.
   5   *
   6   * If you are running this test from a CVS checkout, you must rename the working
   7   * directory from "XML_RPC" to "XML".
   8   *
   9   * PHP versions 4 and 5
  10   *
  11   * LICENSE: This source file is subject to version 3.01 of the PHP license
  12   * that is available through the world-wide-web at the following URI:
  13   * http://www.php.net/license/3_01.txt.  If you did not receive a copy of
  14   * the PHP License and are unable to obtain it through the web, please
  15   * send a note to license@php.net so we can mail you a copy immediately.
  16   *
  17   * @category   Web Services
  18   * @package    XML_RPC
  19   * @author     Daniel Convissor <danielc@php.net>
  20   * @copyright  2005-2006 The PHP Group
  21   * @license    http://www.php.net/license/3_01.txt  PHP License
  22   * @version    CVS: $Id: extra-lines.php,v 1.2 2006/06/11 00:25:17 danielc Exp $
  23   * @link       http://pear.php.net/package/XML_RPC
  24   * @since      File available since Release 1.4.4
  25   */
  26  
  27  /*
  28   * If the package version number is found in the left hand
  29   * portion of the if() expression below, that means this file has
  30   * come from the PEAR installer.  Therefore, let's test the
  31   * installed version of XML_RPC which should be in the include path.
  32   * 
  33   * If the version has not been substituted in the if() expression,
  34   * this file has likely come from a CVS checkout or a .tar file.
  35   * Therefore, we'll assume the tests should use the version of
  36   * XML_RPC that has come from there as well.
  37   */
  38  if ('1.5.1' != '@'.'package_version'.'@') {
  39      /**
  40       * Get the needed class from the PEAR installation
  41       */
  42      require_once  'XML/RPC.php';
  43  } else {
  44      if (substr(dirname(__FILE__), -9, -6) != 'XML') {
  45          echo "The parent directory must be named 'XML'.\n";
  46          exit;
  47      }
  48  
  49      ini_set('include_path', '../../'
  50              . PATH_SEPARATOR . '.' . PATH_SEPARATOR
  51              . ini_get('include_path')
  52      );
  53  
  54      /**
  55       * Get the needed class from the parent directory
  56       */
  57      require_once '../RPC.php';
  58  }
  59  
  60  $input = "First lfs\n\nSecond crlfs\r\n\r\nThird crs\r\rFourth line";
  61  
  62  $expect_removed = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
  63  <methodCall>
  64  <methodName>nada</methodName>
  65  <params>
  66  <param>
  67  <value><string>First lfs
  68  Second crlfs
  69  Third crs
  70  Fourth line</string></value>
  71  </param>
  72  </params>
  73  </methodCall>
  74  ";
  75  
  76  $expect_not_removed = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
  77  <methodCall>
  78  <methodName>nada</methodName>
  79  <params>
  80  <param>
  81  <value><string>First lfs
  82  
  83  Second crlfs
  84  
  85  Third crs
  86  
  87  Fourth line</string></value>
  88  </param>
  89  </params>
  90  </methodCall>
  91  ";
  92  
  93  
  94  $msg = new XML_RPC_Message('nada', array(XML_RPC_encode($input)));
  95  $msg->createPayload();
  96  if ($msg->payload == $expect_removed) {
  97      echo "passed\n";
  98  } else {
  99      echo "PROBLEM\n";
 100  }
 101  
 102  $msg = new XML_RPC_Message('nada', array(XML_RPC_encode($input)));
 103  $msg->remove_extra_lines = false;
 104  $msg->createPayload();
 105  if ($msg->payload == $expect_not_removed) {
 106      echo "passed\n";
 107  } else {
 108      echo "PROBLEM\n";
 109  }


Généré le : Sun Feb 25 14:08:00 2007 par Balluche grâce à PHPXref 0.7