Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/**
4
 * Tests encoding values.
5
 *
6
 * PHP versions 4 and 5
7
 *
8
 * @category   Web Services
9
 * @package    XML_RPC
10
 * @author     Daniel Convissor <danielc@php.net>
11
 * @copyright  2005-2010 The PHP Group
12
 * @license    http://www.php.net/license/3_01.txt  PHP License
13
 * @version    SVN: $Id: encode.php 657 2011-08-29 19:39:57Z tiefland $
14
 * @link       http://pear.php.net/package/XML_RPC
15
 * @since      File available since Release 1.5.3
16
 */
17
 
18
/*
19
 * If the package version number is found in the left hand
20
 * portion of the if() expression below, that means this file has
21
 * come from the PEAR installer.  Therefore, let's test the
22
 * installed version of XML_RPC which should be in the include path.
23
 *
24
 * If the version has not been substituted in the if() expression,
25
 * this file has likely come from a SVN checkout or a .tar file.
26
 * Therefore, we'll assume the tests should use the version of
27
 * XML_RPC that has come from there as well.
28
 */
29
if ('1.5.5' == '@'.'package_version'.'@') {
30
    ini_set('include_path', '../'
31
            . PATH_SEPARATOR . '.' . PATH_SEPARATOR
32
            . ini_get('include_path')
33
    );
34
}
35
require_once 'XML/RPC.php';
36
 
37
 
38
$input = array(10, 11, 12);
39
 
40
$expect = <<<EOT
41
<?xml version="1.0" encoding="UTF-8"?>
42
<methodCall>
43
<methodName>nada</methodName>
44
<params>
45
<param>
46
<value><array>
47
<data>
48
<value><int>10</int></value>
49
<value><int>11</int></value>
50
<value><int>12</int></value>
51
</data>
52
</array></value>
53
</param>
54
</params>
55
</methodCall>
56
EOT;
57
 
58
$expect = trim(preg_replace("/\r\n/", "\n", $expect));
59
 
60
$msg = new XML_RPC_Message('nada', array(XML_RPC_encode($input)));
61
$msg->createPayload();
62
$actual = trim(preg_replace("/\r\n/", "\n", $msg->payload));
63
if ($actual == $expect) {
64
    echo "passed\n";
65
} else {
66
    echo "PROBLEM\n";
67
    echo $actual;
68
}
69
 
70
$msg = new XML_RPC_Message('nada',
71
    array(
72
        new XML_RPC_Value(
73
            array(
74
                new XML_RPC_Value(10, 'int'),
75
                new XML_RPC_Value(11, 'int'),
76
                new XML_RPC_Value(12, 'int'),
77
            ),
78
            'array'
79
        )
80
    )
81
);
82
$msg->createPayload();
83
$actual = trim(preg_replace("/\r\n/", "\n", $msg->payload));
84
if ($actual == $expect) {
85
    echo "passed\n";
86
} else {
87
    echo "PROBLEM\n";
88
    echo $actual;
89
}