Файловый менеджер - Редактировать - /home/skymarketplace/public_html/uploads/test.tar
Назад
Console_Getopt/tests/001-getopt.phpt 0000644 00000002316 15004366340 0013332 0 ustar 00 --TEST-- Console_Getopt --FILE-- <?php require_once 'Console/Getopt.php'; PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s\n\n"); function test($argstr, $optstr) { $argv = preg_split('/[[:space:]]+/', $argstr); if (PEAR::isError($options = Console_Getopt::getopt($argv, $optstr))) { return; } $opts = $options[0]; $non_opts = $options[1]; $i = 0; print "options: "; foreach ($opts as $o => $d) { if ($i++ > 0) { print ", "; } print $d[0] . '=' . $d[1]; } print "\n"; print "params: " . implode(", ", $non_opts) . "\n"; print "\n"; } test("-abc", "abc"); test("-abc foo", "abc"); test("-abc foo", "abc:"); test("-abc foo bar gazonk", "abc"); test("-abc foo bar gazonk", "abc:"); test("-a -b -c", "abc"); test("-a -b -c", "abc:"); test("-abc", "ab:c"); test("-abc foo -bar gazonk", "abc"); ?> --EXPECT-- options: a=, b=, c= params: options: a=, b=, c= params: foo options: a=, b=, c=foo params: options: a=, b=, c= params: foo, bar, gazonk options: a=, b=, c=foo params: bar, gazonk options: a=, b=, c= params: Console_Getopt: option requires an argument --c options: a=, b=c params: options: a=, b=, c= params: foo, -bar, gazonk Console_Getopt/tests/bug10557.phpt 0000644 00000000756 15004366340 0012717 0 ustar 00 --TEST-- Console_Getopt [bug 10557] --SKIPIF-- --FILE-- <?php $_SERVER['argv'] = $argv = array('hi', '-fjjohnston@mail.com', '--to', '--mailpack', '--debug'); require_once 'Console/Getopt.php'; $ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'f:t:', array('from=','to=','mailpack=','direction=','verbose','debug')); if(PEAR::isError($ret)) { echo $ret->getMessage()."\n"; echo 'FATAL'; exit; } print_r($ret); ?> --EXPECT-- Console_Getopt: option requires an argument --to FATAL Console_Getopt/tests/bug11068.phpt 0000644 00000001431 15004366340 0012704 0 ustar 00 --TEST-- Console_Getopt [bug 11068] --SKIPIF-- --FILE-- <?php $_SERVER['argv'] = $argv = array('hi', '-fjjohnston@mail.com', '--to', 'hi', '-'); require_once 'Console/Getopt.php'; $ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'f:t:', array('from=','to=','mailpack=','direction=','verbose','debug')); if(PEAR::isError($ret)) { echo $ret->getMessage()."\n"; echo 'FATAL'; exit; } print_r($ret); ?> --EXPECT-- Array ( [0] => Array ( [0] => Array ( [0] => f [1] => jjohnston@mail.com ) [1] => Array ( [0] => --to [1] => hi ) ) [1] => Array ( [0] => - ) ) Console_Getopt/tests/bug13140.phpt 0000644 00000002505 15004366340 0012700 0 ustar 00 --TEST-- Console_Getopt [bug 13140] --SKIPIF-- --FILE-- <?php $_SERVER['argv'] = $argv = array('--bob', '--foo' , '-bar', '--test', '-rq', 'thisshouldbehere'); require_once 'Console/Getopt.php'; $cg = new Console_GetOpt(); print_r($cg->getopt2($cg->readPHPArgv(), 't', array('test'), true)); print_r($cg->getopt2($cg->readPHPArgv(), 'bar', array('foo'), true)); ?> --EXPECT-- Array ( [0] => Array ( [0] => Array ( [0] => --test [1] => ) ) [1] => Array ( [0] => thisshouldbehere ) ) Array ( [0] => Array ( [0] => Array ( [0] => --foo [1] => ) [1] => Array ( [0] => b [1] => ) [2] => Array ( [0] => a [1] => ) [3] => Array ( [0] => r [1] => ) [4] => Array ( [0] => r [1] => ) ) [1] => Array ( [0] => thisshouldbehere ) ) Structures_Graph/tests/AcyclicTestTest.php 0000644 00000002434 15004366340 0014776 0 ustar 00 <?php require_once dirname(__FILE__) . '/helper.inc'; require_once 'Structures/Graph/Manipulator/AcyclicTest.php'; class AcyclicTestTest extends PHPUnit_Framework_TestCase { public function testIsAcyclicFalse() { $graph = new Structures_Graph(); $node1 = new Structures_Graph_Node(); $graph->addNode($node1); $node2 = new Structures_Graph_Node(); $graph->addNode($node2); $node1->connectTo($node2); $node3 = new Structures_Graph_Node(); $graph->addNode($node3); $node2->connectTo($node3); $node3->connectTo($node1); $this->assertFalse( Structures_Graph_Manipulator_AcyclicTest::isAcyclic($graph), 'Graph is cyclic' ); } public function testIsAcyclicTrue() { $graph = new Structures_Graph(); $node1 = new Structures_Graph_Node(); $graph->addNode($node1); $node2 = new Structures_Graph_Node(); $graph->addNode($node2); $node1->connectTo($node2); $node3 = new Structures_Graph_Node(); $graph->addNode($node3); $node2->connectTo($node3); $this->assertTrue( Structures_Graph_Manipulator_AcyclicTest::isAcyclic($graph), 'Graph is acyclic' ); } } ?> Structures_Graph/tests/AllTests.php 0000644 00000000674 15004366340 0013466 0 ustar 00 <?php require_once dirname(__FILE__) . '/helper.inc'; class Structures_Graph_AllTests { public static function main() { PHPUnit_TextUI_TestRunner::run(self::suite()); } public static function suite() { $suite = new PHPUnit_Framework_TestSuite('Structures_Graph Tests'); $dir = new GlobIterator(dirname(__FILE__) . '/*Test.php'); $suite->addTestFiles($dir); return $suite; } } Structures_Graph/tests/BasicGraphTest.php 0000644 00000021552 15004366340 0014574 0 ustar 00 <?php /* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */ // +-----------------------------------------------------------------------------+ // | Copyright (c) 2003 S�rgio Gon�alves Carvalho | // +-----------------------------------------------------------------------------+ // | This file is part of Structures_Graph. | // | | // | Structures_Graph is free software; you can redistribute it and/or modify | // | it under the terms of the GNU Lesser General Public License as published by | // | the Free Software Foundation; either version 2.1 of the License, or | // | (at your option) any later version. | // | | // | Structures_Graph is distributed in the hope that it will be useful, | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | // | GNU Lesser General Public License for more details. | // | | // | You should have received a copy of the GNU Lesser General Public License | // | along with Structures_Graph; if not, write to the Free Software | // | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | // | 02111-1307 USA | // +-----------------------------------------------------------------------------+ // | Author: S�rgio Carvalho <sergio.carvalho@portugalmail.com> | // +-----------------------------------------------------------------------------+ // require_once dirname(__FILE__) . '/helper.inc'; /** * @access private */ class BasicGraph extends PHPUnit_Framework_TestCase { var $_graph = null; function test_create_graph() { $this->_graph = new Structures_Graph(); $this->assertTrue(is_a($this->_graph, 'Structures_Graph')); } function test_add_node() { $this->_graph = new Structures_Graph(); $data = 1; $node = new Structures_Graph_Node($data); $this->_graph->addNode($node); $node = new Structures_Graph_Node($data); $this->_graph->addNode($node); $node = new Structures_Graph_Node($data); $this->_graph->addNode($node); } function test_connect_node() { $this->_graph = new Structures_Graph(); $data = 1; $node1 = new Structures_Graph_Node($data); $node2 = new Structures_Graph_Node($data); $this->_graph->addNode($node1); $this->_graph->addNode($node2); $node1->connectTo($node2); $node =& $this->_graph->getNodes(); $node =& $node[0]; $node = $node->getNeighbours(); $node =& $node[0]; /* ZE1 == and === operators fail on $node,$node2 because of the recursion introduced by the _graph field in the Node object. So, we'll use the stupid method for reference testing */ $node = true; $this->assertTrue($node2); $node = false; $this->assertFalse($node2); } function test_data_references() { $this->_graph = new Structures_Graph(); $data = 1; $node = new Structures_Graph_Node(); $node->setData($data); $this->_graph->addNode($node); $data = 2; $dataInNode =& $this->_graph->getNodes(); $dataInNode =& $dataInNode[0]; $dataInNode =& $dataInNode->getData(); $this->assertEquals($data, $dataInNode); } function test_metadata_references() { $this->_graph = new Structures_Graph(); $data = 1; $node = new Structures_Graph_Node(); $node->setMetadata('5', $data); $data = 2; $dataInNode =& $node->getMetadata('5'); $this->assertEquals($data, $dataInNode); } function test_metadata_key_exists() { $this->_graph = new Structures_Graph(); $data = 1; $node = new Structures_Graph_Node(); $node->setMetadata('5', $data); $this->assertTrue($node->metadataKeyExists('5')); $this->assertFalse($node->metadataKeyExists('1')); } function test_directed_degree() { $this->_graph = new Structures_Graph(true); $node = array(); $node[] = new Structures_Graph_Node(); $node[] = new Structures_Graph_Node(); $node[] = new Structures_Graph_Node(); $this->_graph->addNode($node[0]); $this->_graph->addNode($node[1]); $this->_graph->addNode($node[2]); $this->assertEquals(0, $node[0]->inDegree(), 'inDegree test failed for node 0 with 0 arcs'); $this->assertEquals(0, $node[1]->inDegree(), 'inDegree test failed for node 1 with 0 arcs'); $this->assertEquals(0, $node[2]->inDegree(), 'inDegree test failed for node 2 with 0 arcs'); $this->assertEquals(0, $node[0]->outDegree(), 'outDegree test failed for node 0 with 0 arcs'); $this->assertEquals(0, $node[1]->outDegree(), 'outDegree test failed for node 1 with 0 arcs'); $this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 0 arcs'); $node[0]->connectTo($node[1]); $this->assertEquals(0, $node[0]->inDegree(), 'inDegree test failed for node 0 with 1 arc'); $this->assertEquals(1, $node[1]->inDegree(), 'inDegree test failed for node 1 with 1 arc'); $this->assertEquals(0, $node[2]->inDegree(), 'inDegree test failed for node 2 with 1 arc'); $this->assertEquals(1, $node[0]->outDegree(), 'outDegree test failed for node 0 with 1 arc'); $this->assertEquals(0, $node[1]->outDegree(), 'outDegree test failed for node 1 with 1 arc'); $this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 1 arc'); $node[0]->connectTo($node[2]); $this->assertEquals(0, $node[0]->inDegree(), 'inDegree test failed for node 0 with 2 arcs'); $this->assertEquals(1, $node[1]->inDegree(), 'inDegree test failed for node 1 with 2 arcs'); $this->assertEquals(1, $node[2]->inDegree(), 'inDegree test failed for node 2 with 2 arcs'); $this->assertEquals(2, $node[0]->outDegree(), 'outDegree test failed for node 0 with 2 arcs'); $this->assertEquals(0, $node[1]->outDegree(), 'outDegree test failed for node 1 with 2 arcs'); $this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 2 arcs'); } function test_undirected_degree() { $this->_graph = new Structures_Graph(false); $node = array(); $node[] = new Structures_Graph_Node(); $node[] = new Structures_Graph_Node(); $node[] = new Structures_Graph_Node(); $this->_graph->addNode($node[0]); $this->_graph->addNode($node[1]); $this->_graph->addNode($node[2]); $this->assertEquals(0, $node[0]->inDegree(), 'inDegree test failed for node 0 with 0 arcs'); $this->assertEquals(0, $node[1]->inDegree(), 'inDegree test failed for node 1 with 0 arcs'); $this->assertEquals(0, $node[2]->inDegree(), 'inDegree test failed for node 2 with 0 arcs'); $this->assertEquals(0, $node[0]->outDegree(), 'outDegree test failed for node 0 with 0 arcs'); $this->assertEquals(0, $node[1]->outDegree(), 'outDegree test failed for node 1 with 0 arcs'); $this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 0 arcs'); $node[0]->connectTo($node[1]); $this->assertEquals(1, $node[0]->inDegree(), 'inDegree test failed for node 0 with 1 arc'); $this->assertEquals(1, $node[1]->inDegree(), 'inDegree test failed for node 1 with 1 arc'); $this->assertEquals(0, $node[2]->inDegree(), 'inDegree test failed for node 2 with 1 arc'); $this->assertEquals(1, $node[0]->outDegree(), 'outDegree test failed for node 0 with 1 arc'); $this->assertEquals(1, $node[1]->outDegree(), 'outDegree test failed for node 1 with 1 arc'); $this->assertEquals(0, $node[2]->outDegree(), 'outDegree test failed for node 2 with 1 arc'); $node[0]->connectTo($node[2]); $this->assertEquals(2, $node[0]->inDegree(), 'inDegree test failed for node 0 with 2 arcs'); $this->assertEquals(1, $node[1]->inDegree(), 'inDegree test failed for node 1 with 2 arcs'); $this->assertEquals(1, $node[2]->inDegree(), 'inDegree test failed for node 2 with 2 arcs'); $this->assertEquals(2, $node[0]->outDegree(), 'outDegree test failed for node 0 with 2 arcs'); $this->assertEquals(1, $node[1]->outDegree(), 'outDegree test failed for node 1 with 2 arcs'); $this->assertEquals(1, $node[2]->outDegree(), 'outDegree test failed for node 2 with 2 arcs'); } } ?> Structures_Graph/tests/TopologicalSorterTest.php 0000644 00000003525 15004366340 0016244 0 ustar 00 <?php require_once dirname(__FILE__) . '/helper.inc'; require_once 'Structures/Graph/Manipulator/TopologicalSorter.php'; class TopologicalSorterTest extends PHPUnit_Framework_TestCase { public function testSort() { $graph = new Structures_Graph(); $name1 = 'node1'; $node1 = new Structures_Graph_Node(); $node1->setData($name1); $graph->addNode($node1); $name11 = 'node11'; $node11 = new Structures_Graph_Node(); $node11->setData($name11); $graph->addNode($node11); $node1->connectTo($node11); $name12 = 'node12'; $node12 = new Structures_Graph_Node(); $node12->setData($name12); $graph->addNode($node12); $node1->connectTo($node12); $name121 = 'node121'; $node121 = new Structures_Graph_Node(); $node121->setData($name121); $graph->addNode($node121); $node12->connectTo($node121); $name2 = 'node2'; $node2 = new Structures_Graph_Node(); $node2->setData($name2); $graph->addNode($node2); $name21 = 'node21'; $node21 = new Structures_Graph_Node(); $node21->setData($name21); $graph->addNode($node21); $node2->connectTo($node21); $nodes = Structures_Graph_Manipulator_TopologicalSorter::sort($graph); $this->assertCount(2, $nodes[0]); $this->assertEquals('node1', $nodes[0][0]->getData()); $this->assertEquals('node2', $nodes[0][1]->getData()); $this->assertCount(3, $nodes[1]); $this->assertEquals('node11', $nodes[1][0]->getData()); $this->assertEquals('node12', $nodes[1][1]->getData()); $this->assertEquals('node21', $nodes[1][2]->getData()); $this->assertCount(1, $nodes[2]); $this->assertEquals('node121', $nodes[2][0]->getData()); } } ?> Structures_Graph/tests/helper.inc 0000644 00000000551 15004366340 0013166 0 ustar 00 <?php if ('/opt/alt/php80/usr/share/pear' == '@'.'php_dir'.'@') { // This package hasn't been installed. // Adjust path to ensure includes find files in working directory. set_include_path(dirname(dirname(__FILE__)) . PATH_SEPARATOR . dirname(__FILE__) . PATH_SEPARATOR . get_include_path()); } require_once 'Structures/Graph.php'; XML_RPC/tests/actual-request.php 0000644 00000003451 15004366340 0012526 0 ustar 00 <?php /** * Actually performs an XML_RPC request. * * PHP versions 4 and 5 * * @category Web Services * @package XML_RPC * @author Daniel Convissor <danielc@php.net> * @copyright 2005-2010 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License * @version SVN: $Id: actual-request.php 300957 2010-07-02 23:55:00Z danielc $ * @link http://pear.php.net/package/XML_RPC * @since File available since Release 1.5.3 */ /* * If the package version number is found in the left hand * portion of the if() expression below, that means this file has * come from the PEAR installer. Therefore, let's test the * installed version of XML_RPC which should be in the include path. * * If the version has not been substituted in the if() expression, * this file has likely come from a SVN checkout or a .tar file. * Therefore, we'll assume the tests should use the version of * XML_RPC that has come from there as well. */ if ('1.5.5' == '@'.'package_version'.'@') { ini_set('include_path', '../' . PATH_SEPARATOR . '.' . PATH_SEPARATOR . ini_get('include_path') ); } require_once 'XML/RPC/Dump.php'; $debug = 0; $params = array( new XML_RPC_Value('php.net', 'string'), ); $msg = new XML_RPC_Message('domquery', $params); $client = new XML_RPC_Client('/api/xmlrpc', 'www.adamsnames.com'); $client->setDebug($debug); $resp = $client->send($msg); if (!$resp) { echo 'Communication error: ' . $client->errstr; exit(1); } if ($resp->faultCode()) { /* * Display problems that have been gracefully cought and * reported by the xmlrpc.php script */ echo 'Fault Code: ' . $resp->faultCode() . "\n"; echo 'Fault Reason: ' . $resp->faultString() . "\n"; exit(1); } $val = $resp->value(); XML_RPC_Dump($val); XML_RPC/tests/allgot.inc 0000644 00000002400 15004366340 0011024 0 ustar 00 <?php /** * Parses the "return" value from some of our test scripts. * * PHP versions 4 and 5 * * @category Web Services * @package XML_RPC * @author Daniel Convissor <danielc@php.net> * @copyright 2005-2010 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License * @version SVN: $Id: allgot.inc 293223 2010-01-07 15:32:19Z danielc $ * @link http://pear.php.net/package/XML_RPC * @since File available since Release 1.4.4 */ ob_start(); function returnAllGot($params) { $out = ''; $count = count($params->params); for ($i = 0; $i < $count; $i++) { $param = $params->getParam($i); if (!XML_RPC_Value::isValue($param)) { $out .= "parameter $i was error: $param\n"; continue; } $got = XML_RPC_Decode($param); $out .= "param $i: " . var_export($got, true) . "\n"; } $val = new XML_RPC_Value($out, 'string'); return new XML_RPC_Response($val); } $server = new XML_RPC_Server( array( 'allgot' => array( 'function' => 'returnAllGot', ), ) ); $got = ob_get_clean(); if ($got == $expect) { echo "passed\n"; } else { echo "FAILED\n"; echo "Expected:\n$expect\n"; echo "Got:\n$got\n"; } XML_RPC/tests/empty-value-struct.php 0000644 00000003413 15004366340 0013357 0 ustar 00 <?php /** * Tests how the XML_RPC server handles a parameter with an empty struct without * any spaces in the XML after the empty value. * * PHP versions 4 and 5 * * @category Web Services * @package XML_RPC * @author Daniel Convissor <danielc@php.net> * @copyright 2005-2010 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License * @version SVN: $Id: empty-value-struct.php 300957 2010-07-02 23:55:00Z danielc $ * @link http://pear.php.net/package/XML_RPC * @since File available since Release 1.4.4 */ /* * If the package version number is found in the left hand * portion of the if() expression below, that means this file has * come from the PEAR installer. Therefore, let's test the * installed version of XML_RPC which should be in the include path. * * If the version has not been substituted in the if() expression, * this file has likely come from a SVN checkout or a .tar file. * Therefore, we'll assume the tests should use the version of * XML_RPC that has come from there as well. */ if ('1.5.5' == '@'.'package_version'.'@') { ini_set('include_path', '../' . PATH_SEPARATOR . '.' . PATH_SEPARATOR . ini_get('include_path') ); } require_once 'XML/RPC/Server.php'; $GLOBALS['HTTP_RAW_POST_DATA'] = <<<EOPOST <?xml version="1.0"?> <methodCall> <methodName>allgot</methodName> <params> <param> <value> <struct> <member> <name>fld1</name><value></value></member></struct></value> </param> </params> </methodCall> EOPOST; $expect = <<<EOEXP <?xml version="1.0" encoding="UTF-8"?> <methodResponse> <params> <param> <value><string>param 0: array ( 'fld1' => '', ) </string></value> </param> </params> </methodResponse> EOEXP; include './allgot.inc'; XML_RPC/tests/empty-value.php 0000644 00000003371 15004366340 0012040 0 ustar 00 <?php /** * Tests how the XML_RPC server handles parameters with empty values. * * PHP versions 4 and 5 * * @category Web Services * @package XML_RPC * @author Daniel Convissor <danielc@php.net> * @copyright 2005-2010 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License * @version SVN: $Id: empty-value.php 300957 2010-07-02 23:55:00Z danielc $ * @link http://pear.php.net/package/XML_RPC * @since File available since Release 1.4.4 */ /* * If the package version number is found in the left hand * portion of the if() expression below, that means this file has * come from the PEAR installer. Therefore, let's test the * installed version of XML_RPC which should be in the include path. * * If the version has not been substituted in the if() expression, * this file has likely come from a SVN checkout or a .tar file. * Therefore, we'll assume the tests should use the version of * XML_RPC that has come from there as well. */ if ('1.5.5' == '@'.'package_version'.'@') { ini_set('include_path', '../' . PATH_SEPARATOR . '.' . PATH_SEPARATOR . ini_get('include_path') ); } require_once 'XML/RPC/Server.php'; $GLOBALS['HTTP_RAW_POST_DATA'] = <<<EOPOST <?xml version="1.0"?> <methodCall> <methodName>allgot</methodName> <params> <param><value><string></string></value></param> <param><value>first</value></param> <param><value> </value></param> <param><value></value></param> </params> </methodCall> EOPOST; $expect = <<<EOEXP <?xml version="1.0" encoding="UTF-8"?> <methodResponse> <params> <param> <value><string>param 0: '' param 1: 'first' param 2: ' ' param 3: '' </string></value> </param> </params> </methodResponse> EOEXP; include './allgot.inc'; XML_RPC/tests/encode.php 0000644 00000004321 15004366340 0011021 0 ustar 00 <?php /** * Tests encoding values. * * PHP versions 4 and 5 * * @category Web Services * @package XML_RPC * @author Daniel Convissor <danielc@php.net> * @copyright 2005-2010 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License * @version SVN: $Id: extra-lines.php 293218 2010-01-07 14:20:08Z danielc $ * @link http://pear.php.net/package/XML_RPC * @since File available since Release 1.5.3 */ /* * If the package version number is found in the left hand * portion of the if() expression below, that means this file has * come from the PEAR installer. Therefore, let's test the * installed version of XML_RPC which should be in the include path. * * If the version has not been substituted in the if() expression, * this file has likely come from a SVN checkout or a .tar file. * Therefore, we'll assume the tests should use the version of * XML_RPC that has come from there as well. */ if ('1.5.5' == '@'.'package_version'.'@') { ini_set('include_path', '../' . PATH_SEPARATOR . '.' . PATH_SEPARATOR . ini_get('include_path') ); } require_once 'XML/RPC.php'; $input = array(10, 11, 12); $expect = <<<EOT <?xml version="1.0" encoding="UTF-8"?> <methodCall> <methodName>nada</methodName> <params> <param> <value><array> <data> <value><int>10</int></value> <value><int>11</int></value> <value><int>12</int></value> </data> </array></value> </param> </params> </methodCall> EOT; $expect = trim(preg_replace("/\r\n/", "\n", $expect)); $msg = new XML_RPC_Message('nada', array(XML_RPC_encode($input))); $msg->createPayload(); $actual = trim(preg_replace("/\r\n/", "\n", $msg->payload)); if ($actual == $expect) { echo "passed\n"; } else { echo "PROBLEM\n"; echo $actual; } $msg = new XML_RPC_Message('nada', array( new XML_RPC_Value( array( new XML_RPC_Value(10, 'int'), new XML_RPC_Value(11, 'int'), new XML_RPC_Value(12, 'int'), ), 'array' ) ) ); $msg->createPayload(); $actual = trim(preg_replace("/\r\n/", "\n", $msg->payload)); if ($actual == $expect) { echo "passed\n"; } else { echo "PROBLEM\n"; echo $actual; } XML_RPC/tests/extra-lines.php 0000644 00000004311 15004366340 0012016 0 ustar 00 <?php /** * Tests how the XML_RPC server handles parameters with empty values. * * PHP versions 4 and 5 * * @category Web Services * @package XML_RPC * @author Daniel Convissor <danielc@php.net> * @copyright 2005-2010 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License * @version SVN: $Id: extra-lines.php 300958 2010-07-02 23:58:51Z danielc $ * @link http://pear.php.net/package/XML_RPC * @since File available since Release 1.4.4 */ /* * If the package version number is found in the left hand * portion of the if() expression below, that means this file has * come from the PEAR installer. Therefore, let's test the * installed version of XML_RPC which should be in the include path. * * If the version has not been substituted in the if() expression, * this file has likely come from a SVN checkout or a .tar file. * Therefore, we'll assume the tests should use the version of * XML_RPC that has come from there as well. */ if ('1.5.5' == '@'.'package_version'.'@') { ini_set('include_path', '../' . PATH_SEPARATOR . '.' . PATH_SEPARATOR . ini_get('include_path') ); } require_once 'XML/RPC.php'; $input = "First lfs\n\nSecond crlfs\r\n\r\nThird crs\r\rFourth line"; $expect_removed = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<methodCall>\r\n<methodName>nada</methodName>\r\n<params>\r\n<param>\r\n<value><string>First lfs\r\nSecond crlfs\r\nThird crs\r\nFourth line</string></value>\r\n</param>\r\n</params>\r\n</methodCall>\r\n"; $expect_not_removed = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<methodCall>\r\n<methodName>nada</methodName>\r\n<params>\r\n<param>\r\n<value><string>First lfs\r\n\r\nSecond crlfs\r\n\r\nThird crs\r\n\r\nFourth line</string></value>\r\n</param>\r\n</params>\r\n</methodCall>\r\n"; $msg = new XML_RPC_Message('nada', array(XML_RPC_encode($input))); $msg->createPayload(); if ($msg->payload == $expect_removed) { echo "passed\n"; } else { echo "PROBLEM\n"; } $msg = new XML_RPC_Message('nada', array(XML_RPC_encode($input))); $msg->remove_extra_lines = false; $msg->createPayload(); if ($msg->payload == $expect_not_removed) { echo "passed\n"; } else { echo "PROBLEM\n"; } XML_RPC/tests/protoport.php 0000644 00000025007 15004366340 0011640 0 ustar 00 <?php /** * Tests that properties of XML_RPC_Client get properly set * * Any individual tests that fail will have their name, expected result * and actual result printed out. So seeing no output when executing * this file is a good thing. * * Can be run via CLI or a web server. * * PHP versions 4 and 5 * * @category Web Services * @package XML_RPC * @author Daniel Convissor <danielc@php.net> * @copyright 2005-2010 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License * @version SVN: $Id: protoport.php 300957 2010-07-02 23:55:00Z danielc $ * @link http://pear.php.net/package/XML_RPC * @since File available since Release 1.2 */ /* * If the package version number is found in the left hand * portion of the if() expression below, that means this file has * come from the PEAR installer. Therefore, let's test the * installed version of XML_RPC which should be in the include path. * * If the version has not been substituted in the if() expression, * this file has likely come from a SVN checkout or a .tar file. * Therefore, we'll assume the tests should use the version of * XML_RPC that has come from there as well. */ if ('1.5.5' == '@'.'package_version'.'@') { ini_set('include_path', '../' . PATH_SEPARATOR . '.' . PATH_SEPARATOR . ini_get('include_path') ); } require_once 'XML/RPC.php'; /** * Compare the test result to the expected result * * If the test fails, echo out the results. * * @param array $expect the array of object properties you expect * from the test * @param object $actual the object results from the test * @param string $test_name the name of the test * * @return void */ function compare($expect, $actual, $test_name) { $actual = get_object_vars($actual); if (count(array_diff($actual, $expect))) { echo "$test_name failed.\nExpect: "; print_r($expect); echo "Actual: "; print_r($actual); echo "\n"; } } if (php_sapi_name() != 'cli') { echo "<pre>\n"; } $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'http://', 'port' => 80, 'proxy' => '', 'proxy_protocol' => 'http://', 'proxy_port' => 8080, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'theserver'); compare($x, $c, 'defaults'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'http://', 'port' => 80, 'proxy' => '', 'proxy_protocol' => 'http://', 'proxy_port' => 8080, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'http://theserver'); compare($x, $c, 'defaults with http'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'ssl://', 'port' => 443, 'proxy' => '', 'proxy_protocol' => 'http://', 'proxy_port' => 8080, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'https://theserver'); compare($x, $c, 'defaults with https'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'ssl://', 'port' => 443, 'proxy' => '', 'proxy_protocol' => 'http://', 'proxy_port' => 8080, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'ssl://theserver'); compare($x, $c, 'defaults with ssl'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'http://', 'port' => 65, 'proxy' => '', 'proxy_protocol' => 'http://', 'proxy_port' => 8080, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'theserver', 65); compare($x, $c, 'port 65'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'http://', 'port' => 65, 'proxy' => '', 'proxy_protocol' => 'http://', 'proxy_port' => 8080, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'http://theserver', 65); compare($x, $c, 'port 65 with http'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'ssl://', 'port' => 65, 'proxy' => '', 'proxy_protocol' => 'http://', 'proxy_port' => 8080, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'https://theserver', 65); compare($x, $c, 'port 65 with https'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'ssl://', 'port' => 65, 'proxy' => '', 'proxy_protocol' => 'http://', 'proxy_port' => 8080, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'ssl://theserver', 65); compare($x, $c, 'port 65 with ssl'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'http://', 'port' => 80, 'proxy' => 'theproxy', 'proxy_protocol' => 'http://', 'proxy_port' => 8080, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'theserver', 0, 'theproxy'); compare($x, $c, 'defaults proxy'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'http://', 'port' => 80, 'proxy' => 'theproxy', 'proxy_protocol' => 'http://', 'proxy_port' => 8080, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'http://theserver', 0, 'http://theproxy'); compare($x, $c, 'defaults with http proxy'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'ssl://', 'port' => 443, 'proxy' => 'theproxy', 'proxy_protocol' => 'ssl://', 'proxy_port' => 443, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'https://theserver', 0, 'https://theproxy'); compare($x, $c, 'defaults with https proxy'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'ssl://', 'port' => 443, 'proxy' => 'theproxy', 'proxy_protocol' => 'ssl://', 'proxy_port' => 443, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'ssl://theserver', 0, 'ssl://theproxy'); compare($x, $c, 'defaults with ssl proxy'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'http://', 'port' => 65, 'proxy' => 'theproxy', 'proxy_protocol' => 'http://', 'proxy_port' => 6565, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'theserver', 65, 'theproxy', 6565); compare($x, $c, 'port 65 proxy 6565'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'http://', 'port' => 65, 'proxy' => 'theproxy', 'proxy_protocol' => 'http://', 'proxy_port' => 6565, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'http://theserver', 65, 'http://theproxy', 6565); compare($x, $c, 'port 65 with http proxy 6565'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'ssl://', 'port' => 65, 'proxy' => 'theproxy', 'proxy_protocol' => 'ssl://', 'proxy_port' => 6565, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'https://theserver', 65, 'https://theproxy', 6565); compare($x, $c, 'port 65 with https proxy 6565'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'ssl://', 'port' => 65, 'proxy' => 'theproxy', 'proxy_protocol' => 'ssl://', 'proxy_port' => 6565, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'ssl://theserver', 65, 'ssl://theproxy', 6565); compare($x, $c, 'port 65 with ssl proxy 6565'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'ssl://', 'port' => 443, 'proxy' => 'theproxy', 'proxy_protocol' => 'ssl://', 'proxy_port' => 443, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'theserver', 443, 'theproxy', 443); compare($x, $c, 'port 443 no protocol and proxy port 443 no protocol'); $x = array( 'path' => 'thepath', 'server' => 'theserver', 'protocol' => 'http://', 'port' => 80, 'proxy' => 'theproxy', 'proxy_protocol' => 'ssl://', 'proxy_port' => 6565, 'proxy_user' => '', 'proxy_pass' => '', 'errno' => 0, 'errstring' => '', 'debug' => 0, 'username' => '', 'password' => '', ); $c = new XML_RPC_Client('thepath', 'theserver', 0, 'ssl://theproxy', 6565); compare($x, $c, 'port 443 no protocol and proxy port 443 no protocol'); echo "\nIf no other output was produced, these tests passed.\n"; XML_RPC/tests/test_Dump.php 0000644 00000004130 15004366340 0011526 0 ustar 00 <?php /** * Actually performs an XML_RPC request. * * PHP versions 4 and 5 * * @category Web Services * @package XML_RPC * @author Daniel Convissor <danielc@php.net> * @copyright 2005-2010 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License * @version SVN: $Id: test_Dump.php 300962 2010-07-03 02:24:24Z danielc $ * @link http://pear.php.net/package/XML_RPC */ /* * If the package version number is found in the left hand * portion of the if() expression below, that means this file has * come from the PEAR installer. Therefore, let's test the * installed version of XML_RPC which should be in the include path. * * If the version has not been substituted in the if() expression, * this file has likely come from a SVN checkout or a .tar file. * Therefore, we'll assume the tests should use the version of * XML_RPC that has come from there as well. */ if ('1.5.5' == '@'.'package_version'.'@') { ini_set('include_path', '../' . PATH_SEPARATOR . '.' . PATH_SEPARATOR . ini_get('include_path') ); } require_once 'XML/RPC/Dump.php'; $val = new XML_RPC_Value(array( 'title' =>new XML_RPC_Value('das ist der Titel', 'string'), 'startDate'=>new XML_RPC_Value(mktime(0,0,0,13,11,2004), 'dateTime.iso8601'), 'endDate' =>new XML_RPC_Value(mktime(0,0,0,15,11,2004), 'dateTime.iso8601'), 'arkey' => new XML_RPC_Value( array( new XML_RPC_Value('simple string'), new XML_RPC_Value(12345, 'int') ), 'array') ) ,'struct'); XML_RPC_Dump($val); echo '==============' . "\r\n"; $val2 = new XML_RPC_Value(44353, 'int'); XML_RPC_Dump($val2); echo '==============' . "\r\n"; $val3 = new XML_RPC_Value('this should be a string', 'string'); XML_RPC_Dump($val3); echo '==============' . "\r\n"; $val4 = new XML_RPC_Value(true, 'boolean'); XML_RPC_Dump($val4); echo '==============' . "\r\n"; echo 'Next we will test the error handling...' . "\r\n"; $val5 = new XML_RPC_Value(array( 'foo' => 'bar' ), 'struct'); XML_RPC_Dump($val5); echo '==============' . "\r\n"; echo 'DONE' . "\r\n"; XML_RPC/tests/types.php 0000644 00000004767 15004366340 0010746 0 ustar 00 <?php /** * Tests how the XML_RPC server handles a bunch of different parameter * data types. * * PHP versions 4 and 5 * * @category Web Services * @package XML_RPC * @author Daniel Convissor <danielc@php.net> * @copyright 2005-2010 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License * @version SVN: $Id: types.php 300957 2010-07-02 23:55:00Z danielc $ * @link http://pear.php.net/package/XML_RPC * @since File available since Release 1.4.4 */ /* * If the package version number is found in the left hand * portion of the if() expression below, that means this file has * come from the PEAR installer. Therefore, let's test the * installed version of XML_RPC which should be in the include path. * * If the version has not been substituted in the if() expression, * this file has likely come from a SVN checkout or a .tar file. * Therefore, we'll assume the tests should use the version of * XML_RPC that has come from there as well. */ if ('1.5.5' == '@'.'package_version'.'@') { ini_set('include_path', '../' . PATH_SEPARATOR . '.' . PATH_SEPARATOR . ini_get('include_path') ); } require_once 'XML/RPC/Server.php'; $GLOBALS['HTTP_RAW_POST_DATA'] = <<<EOPOST <?xml version="1.0"?> <methodCall> <methodName>allgot</methodName> <params> <param><value>default to string</value></param> <param><value><string>inside string</string></value></param> <param><value><int>8</int></value></param> <param><value><datetime.iso8601>20050809T01:33:44</datetime.iso8601></value></param> <param> <value> <array> <data> <value> <string>a</string> </value> <value> <string>b</string> </value> </data> </array> </value> </param> <param> <value> <struct> <member> <name>a</name> <value> <string>ay</string> </value> </member> <member> <name>b</name> <value> <string>be</string> </value> </member> </struct> </value> </param> </params> </methodCall> EOPOST; $expect = <<<EOEXP <?xml version="1.0" encoding="UTF-8"?> <methodResponse> <params> <param> <value><string>param 0: 'default to string' param 1: 'inside string' param 2: '8' param 3: '20050809T01:33:44' param 4: array ( 0 => 'a', 1 => 'b', ) param 5: array ( 'a' => 'ay', 'b' => 'be', ) </string></value> </param> </params> </methodResponse> EOEXP; include './allgot.inc'; XML_Util/tests/AbstractUnitTests.php 0000644 00000000650 15004366340 0013504 0 ustar 00 <?php /* * Allow for PHPUnit 4.* while XML_Util is still usable on PHP 5.4 */ if (!class_exists('PHPUnit_Framework_TestCase')) { class PHPUnit_Framework_TestCase extends \PHPUnit\Framework\TestCase {} } abstract class AbstractUnitTests extends \PHPUnit_Framework_TestCase { public function setUp() { // ensure the class is defined, and thus its constants are declared new XML_Util(); } } XML_Util/tests/ApiVersionTests.php 0000644 00000000335 15004366340 0013160 0 ustar 00 <?php class ApiVersionTests extends AbstractUnitTests { /** * @covers XML_Util::apiVersion() */ public function testApiVersion() { $this->assertEquals('1.4', XML_Util::apiVersion()); } } XML_Util/tests/AttributesToStringTests.php 0000644 00000017026 15004366340 0014726 0 ustar 00 <?php class AttributesToStringTests extends AbstractUnitTests { /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringBasicUsage() { $original = array('foo' => 'bar','boo' => 'baz',); $expected = " boo=\"baz\" foo=\"bar\""; $this->assertEquals($expected, XML_Util::attributesToString($original)); } /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithExplicitSortTrue() { $original = array('foo' => 'bar','boo' => 'baz',); $expected = " boo=\"baz\" foo=\"bar\""; $sort = true; $this->assertEquals($expected, XML_Util::attributesToString($original, $sort)); } /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithExplicitSortFalse() { $original = array('foo' => 'bar','boo' => 'baz',); $expected = " foo=\"bar\" boo=\"baz\""; $sort = false; $this->assertEquals($expected, XML_Util::attributesToString($original, $sort)); } /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithMultilineFalse() { $original = array('foo' => 'bar','boo' => 'baz',); $expected = " boo=\"baz\" foo=\"bar\""; $sort = true; $multiline = false; $this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline)); } /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithMultilineTrue() { $original = array('foo' => 'bar','boo' => 'baz',); $expected = <<< EOF boo="baz" foo="bar" EOF; $sort = true; $multiline = true; $this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline)); } /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithExplicitIndent() { $original = array('foo' => 'bar','boo' => 'baz',); $expected = " boo=\"baz\"\n foo=\"bar\""; $sort = true; $multiline = true; $indent = ' '; // 8 spaces $this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $indent)); } /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithExplicitLinebreak() { $original = array('foo' => 'bar','boo' => 'baz',); $expected = " boo=\"baz\"\n^foo=\"bar\""; $sort = true; $multiline = true; $linebreak = '^'; // some dummy character $this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak)); } /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithOptionsThatIncludesSort() { $original = array('foo' => 'bar','boo' => 'baz',); $options = array( 'multiline' => true, 'indent' => '----', 'linebreak' => "^", 'entities' => XML_UTIL_ENTITIES_XML, 'sort' => true, ); $expected = " boo=\"baz\"\n----foo=\"bar\""; $this->assertEquals($expected, XML_Util::attributesToString($original, $options)); } /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithOptionsThatExcludesSort() { $original = array('foo' => 'bar','boo' => 'baz',); $options = array( 'multiline' => true, 'indent' => '----', 'linebreak' => "^", 'entities' => XML_UTIL_ENTITIES_XML, ); $expected = " boo=\"baz\"\n----foo=\"bar\""; $this->assertEquals($expected, XML_Util::attributesToString($original, $options)); } /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithEntitiesNone() { $original = array("foo" => "b@&r", "boo" => "b><z"); $expected = " boo=\"b><z\" foo=\"b@&r\""; $sort = true; $multiline = false; $linebreak = ' '; $this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak, PHP_EOL, XML_UTIL_ENTITIES_NONE)); } /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithEntitiesXml() { $original = array("foo" => "b@&r", "boo" => "b><z"); $expected = " boo=\"b><z\" foo=\"b@&r\""; $sort = true; $multiline = false; $linebreak = ' '; $this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak, PHP_EOL, XML_UTIL_ENTITIES_XML)); } /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithEntitiesXmlRequired() { $original = array("foo" => "b@&r", "boo" => "b><z"); $expected = " boo=\"b><z\" foo=\"b@&r\""; $sort = true; $multiline = false; $linebreak = ' '; $this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak, PHP_EOL, XML_UTIL_ENTITIES_XML_REQUIRED)); } /** * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithEntitiesHtml() { $original = array("foo" => "b@&r", "boo" => "b><z"); $expected = " boo=\"b><z\" foo=\"b@&r\""; $sort = true; $multiline = false; $linebreak = ' '; $this->assertEquals($expected, XML_Util::attributesToString($original, $sort, $multiline, $linebreak, PHP_EOL, XML_UTIL_ENTITIES_HTML)); } /** * Tag attributes should not be treated as CDATA, * so the operation will instead quietly use XML_UTIL_ENTITIES_XML. * * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithCDataSectionForSingleAttribute() { $original = array('foo' => 'bar'); // need exactly one attribute here $options = array( 'sort' => true, // doesn't matter for this testcase 'multiline' => false, // doesn't matter for this testcase 'indent' => null, // doesn't matter for this testcase 'linebreak' => null, // doesn't matter for this testcase 'entities' => XML_UTIL_CDATA_SECTION, // DOES matter for this testcase ); $expected = " foo=\"bar\""; $this->assertEquals($expected, XML_Util::attributesToString($original, $options)); } /** * Tag attributes should not be treated as CDATA, * so the operation will instead quietly use XML_UTIL_ENTITIES_XML. * * @covers XML_Util::attributesToString() */ public function testAttributesToStringWithCDataSectionForMultipleAttributesAndMultilineFalse() { $original = array('foo' => 'bar', 'boo' => 'baz'); // need more than one attribute here $options = array( 'sort' => true, // doesn't matter for this testcase 'multiline' => false, // DOES matter for this testcase, must be false 'indent' => null, // doesn't matter for this testcase 'linebreak' => null, // doesn't matter for this testcase 'entities' => XML_UTIL_CDATA_SECTION, // DOES matter for this testcase ); $expected = " boo=\"baz\" foo=\"bar\""; $this->assertEquals($expected, XML_Util::attributesToString($original, $options)); } } XML_Util/tests/Bug18343Tests.php 0000644 00000003316 15004366340 0012223 0 ustar 00 <?php /** * Bug #18343 "Entities in file names decoded during packaging" * * No matter what flags are given to createTagFromArray(), * an attribute must *always* be at least ENTITIES_XML encoded. * * @link https://pear.php.net/bugs/bug.php?id=18343 */ class Bug18343Tests extends AbstractUnitTests { private $tagArray = array( "qname" => "install", "attributes" => array( "as" => "Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek", "name" => "test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek", ) ); public function getFlagsToTest() { new XML_Util(); // for constants to be declared return array( array('no flag', null), array('false', false), array('ENTITIES_NONE', XML_UTIL_ENTITIES_NONE), array('ENTITIES_XML', XML_UTIL_ENTITIES_XML), array('ENTITIES_XML_REQUIRED', XML_UTIL_ENTITIES_XML_REQUIRED), array('ENTITIES_HTML', XML_UTIL_ENTITIES_HTML), array('REPLACE_ENTITIES', XML_UTIL_REPLACE_ENTITIES), ); } /** * @dataProvider getFlagsToTest() */ public function testCreateTagFromArrayForBug18343($key, $flag) { // all flags for the candidate input should return the same result $expected = <<< EOF <install as="Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" name="test/Horde/Feed/fixtures/lexicon/http-p.moreover.com-cgi-local-page%2Fo=rss&s=Newsweek" /> EOF; $this->assertEquals($expected, XML_Util::createTagFromArray($this->tagArray, $flag), "Failed bugcheck for $key."); } } XML_Util/tests/Bug21177Tests.php 0000644 00000002036 15004366340 0012220 0 ustar 00 <?php /** * Bug #21177 "XML_Util::collapseEmptyTags() can return NULL" * * PREG returns NULL when it encounters an error. * In this case, it was encountering PREG_BACKTRACK_LIMIT_ERROR. * * @link https://pear.php.net/bugs/bug.php?id=21177 */ class Bug21177Tests extends AbstractUnitTests { public function getTestCandidate() { $expected = '<id_mytest_yesorno />'; return array( array('<idmytestyesorno></idmytestyesorno>', '<idmytestyesorno />'), array('<idmytestyesorno />', '<idmytestyesorno />'), array('<id_mytest_yesorno></id_mytest_yesorno>', '<id_mytest_yesorno />'), array('<id_mytest_yesorno />', '<id_mytest_yesorno />'), ); } /** * @dataProvider getTestCandidate() */ public function testCollapseEmptyTagsForBug21177($original, $expected) { $this->assertEquals($expected, XML_Util::collapseEmptyTags($original, XML_UTIL_COLLAPSE_ALL), "Failed bugcheck."); } } XML_Util/tests/Bug21184Tests.php 0000644 00000000702 15004366340 0012214 0 ustar 00 <?php /** * Bug #21184 * * PREG returns NULL when it encounters an error. * In this case, it was encountering PREG_BACKTRACK_LIMIT_ERROR. * * @link https://pear.php.net/bugs/bug.php?id=21177 */ class Bug21184 extends AbstractUnitTests { public function testBug21184() { $xml = '<XML_Serializer_Tag>one</XML_Serializer_Tag>'; $this->assertEquals($xml, XML_Util::collapseEmptyTags($xml, XML_UTIL_COLLAPSE_ALL)); } } XML_Util/tests/Bug4950Tests.php 0000644 00000001331 15004366340 0012135 0 ustar 00 <?php /** * Bug #4950 "Incorrect CDATA serializing" * * Content that looks like CDATA end characters and tags * should still be recognized solely as content text. * * @link https://pear.php.net/bugs/bug.php?id=4950 */ class Bug4950Tests extends AbstractUnitTests { public function testCreateTagForBug4950() { $qname = "test"; $attributes = array(); $content = "Content ]]></test> here!"; $namespaceUrl = null; $expected = "<test><![CDATA[Content ]]]]><![CDATA[></test> here!]]></test>"; $result = XML_Util::createTag($qname, $attributes, $content, $namespaceUrl, XML_UTIL_CDATA_SECTION); $this->assertEquals($expected, $result, "Failed bugcheck."); } } XML_Util/tests/Bug5392Tests.php 0000644 00000001377 15004366340 0012150 0 ustar 00 <?php /** * Bug #5392 "encoding of ISO-8859-1 is the only supported encoding" * * Original characters of the given encoding that are "replaced" * should then "reverse" back to perfectly match the original. * * @link https://pear.php.net/bugs/bug.php?id=5392 */ class Bug5392Tests extends AbstractUnitTests { public function testReplaceEntitiesForBug5392() { $original = 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê'; $replacedResult = XML_Util::replaceEntities($original, XML_UTIL_ENTITIES_HTML, "UTF-8"); $reversedResult = XML_Util::reverseEntities($replacedResult, XML_UTIL_ENTITIES_HTML, "UTF-8"); $this->assertEquals($original, $reversedResult, "Failed bugcheck."); } } XML_Util/tests/CollapseEmptyTagsTests.php 0000644 00000010401 15004366340 0014474 0 ustar 00 <?php class CollapseEmptyTagsTests extends AbstractUnitTests { /** * @covers XML_Util::collapseEmptyTags() */ public function testCollapseEmptyTagsBasicUsage() { $emptyTag = "<foo></foo>"; $expected = "<foo />"; $this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag)); } /** * @covers XML_Util::collapseEmptyTags() */ public function testCollapseEmptyTagsBasicUsageAlongsideNonemptyTag() { $emptyTag = "<foo></foo>"; $otherTag = "<bar>baz</bar>"; $expected = "<foo /><bar>baz</bar>"; $this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag)); } /** * @covers XML_Util::collapseEmptyTags() */ public function testCollapseEmptyTagsOnOneEmptyTagWithCollapseAll() { $emptyTag = "<foo></foo>"; $expected = "<foo />"; $this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_ALL)); } /** * @covers XML_Util::collapseEmptyTags() */ public function testCollapseEmptyTagsOnOneEmptyTagAlongsideNonemptyTagWithCollapseAll() { $emptyTag = "<foo></foo>"; $otherTag = "<bar>baz</bar>"; $expected = "<foo /><bar>baz</bar>"; $this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag, XML_UTIL_COLLAPSE_ALL)); } /** * @covers XML_Util::collapseEmptyTags() */ public function testCollapseEmptyTagsOnOneEmptyTagAlongsideNonemptyTagAlongsideEmptyTagWithCollapseAll() { $emptyTag = "<foo></foo>"; $otherTag = "<bar>baz</bar>"; $expected = "<foo /><bar>baz</bar><foo />"; $this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag . $emptyTag, XML_UTIL_COLLAPSE_ALL)); } /** * @covers XML_Util::collapseEmptyTags() */ public function testCollapseEmptyTagsOnOneEmptyPrefixedTagAlongsideNonemptyTagAlongsideEmptyPrefixedTagWithCollapseAll() { $emptyTag = "<foo:foo2></foo:foo2>"; $otherTag = "<bar>baz</bar>"; $expected = "<foo:foo2 /><bar>baz</bar><foo:foo2 />"; $this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag . $emptyTag, XML_UTIL_COLLAPSE_ALL)); } /** * @covers XML_Util::collapseEmptyTags() */ public function testCollapseEmptyTagsOnOneEmptyNsPrefixedTagAlongsideNonemptyTagAlongsideEmptyNsPrefixedTagWithCollapseAll() { $emptyTag = "<http://foo.com:foo2></http://foo.com:foo2>"; $otherTag = "<bar>baz</bar>"; $expected = "<http://foo.com:foo2 /><bar>baz</bar><http://foo.com:foo2 />"; $this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag . $emptyTag, XML_UTIL_COLLAPSE_ALL)); } /** * @covers XML_Util::collapseEmptyTags() */ public function testCollapseEmptyTagsOnOneEmptyTagWithCollapseXhtml() { $emptyTag = "<foo></foo>"; $expected = "<foo></foo>"; $this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_XHTML_ONLY)); } /** * @covers XML_Util::collapseEmptyTags() */ public function testCollapseEmptyTagsOnOneEmptyTagAlongsideNonemptyTagWithCollapseXhtml() { $emptyTag = "<foo></foo>"; $otherTag = "<bar>baz</bar>"; $xhtmlTag = "<br></br>"; $expected = "<foo></foo><br /><bar>baz</bar>"; $this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $xhtmlTag . $otherTag, XML_UTIL_COLLAPSE_XHTML_ONLY)); } /** * @covers XML_Util::collapseEmptyTags() */ public function testCollapseEmptyTagsOnOneEmptyTagWithCollapseNone() { $emptyTag = "<foo></foo>"; $expected = "<foo></foo>"; $this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag, XML_UTIL_COLLAPSE_NONE)); } /** * @covers XML_Util::collapseEmptyTags() */ public function testCollapseEmptyTagsOnOneEmptyTagAlongsideNonemptyTagWithCollapseNone() { $emptyTag = "<foo></foo>"; $otherTag = "<bar>baz</bar>"; $expected = "<foo></foo><bar>baz</bar>"; $this->assertEquals($expected, XML_Util::collapseEmptyTags($emptyTag . $otherTag, XML_UTIL_COLLAPSE_NONE)); } } XML_Util/tests/CreateCDataSectionTests.php 0000644 00000000552 15004366340 0014527 0 ustar 00 <?php class CreateCDataSectionTests extends AbstractUnitTests { /** * @covers XML_Util::createCDataSection() */ public function testCreateCDataSectionBasicUsage() { $original = "I am content."; $expected ="<![CDATA[I am content.]]>"; $this->assertEquals($expected, XML_Util::createCDataSection($original)); } } XML_Util/tests/CreateCommentTests.php 0000644 00000000524 15004366340 0013627 0 ustar 00 <?php class CreateCommentTests extends AbstractUnitTests { /** * @covers XML_Util::createComment() */ public function testCreateCommentBasicUsage() { $original = "I am comment."; $expected = "<!-- I am comment. -->"; $this->assertEquals($expected, XML_Util::createComment($original)); } } XML_Util/tests/CreateEndElementTests.php 0000644 00000001145 15004366340 0014245 0 ustar 00 <?php class CreateEndElementTests extends AbstractUnitTests { /** * @covers XML_Util::createEndElement() */ public function testCreateEndElementBasicUsage() { $original = "myTag"; $expected = "</myTag>"; $this->assertEquals($expected, XML_Util::createEndElement($original)); } /** * @covers XML_Util::createEndElement() */ public function testCreateEndElementWithNamespacedTag() { $original = "myNs:myTag"; $expected = "</myNs:myTag>"; $this->assertEquals($expected, XML_Util::createEndElement($original)); } } XML_Util/tests/CreateStartElementTests.php 0000644 00000012442 15004366340 0014636 0 ustar 00 <?php class CreateStartElementTests extends AbstractUnitTests { /** * @covers XML_Util::createStartElement() */ public function testCreateStartElementForTagOnly() { $original = "myNs:myTag"; $expected = "<myNs:myTag>"; $this->assertEquals($expected, XML_Util::createStartElement($original)); } /** * @covers XML_Util::createStartElement() */ public function testCreateStartElementForTagWithAttributes() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $expected = "<myNs:myTag foo=\"bar\">"; $this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes)); } /** * @covers XML_Util::createStartElement() */ public function testCreateStartElementForTagWithEmptyAttributes() { $originalTag = "myNs:myTag"; $originalAttributes = ""; $expected = "<myNs:myTag>"; $this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes)); } /** * @covers XML_Util::createStartElement() */ public function testCreateStartElementForTagWithAttributesAndNamespace() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $originalNamespace = "http://www.w3c.org/myNs#"; $expected = "<myNs:myTag foo=\"bar\" xmlns:myNs=\"http://www.w3c.org/myNs#\">"; $this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace)); } /** * @covers XML_Util::createStartElement() */ public function testCreateStartElementForTagWithEmptyAttributesAndNonUriNamespace() { $originalTag = "myTag"; $originalAttributes = ""; $originalNamespace = "foo"; $expected = "<myTag xmlns=\"foo\">"; $this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace)); } /** * @covers XML_Util::createStartElement() */ public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultiline() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $originalNamespace = "http://www.w3c.org/myNs#"; $expected = <<< EOF <myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#"> EOF; $multiline = true; $this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline)); } /** * @covers XML_Util::createStartElement() */ public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultilineAndIndent() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $originalNamespace = "http://www.w3c.org/myNs#"; $expected = <<< EOF <myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#"> EOF; $multiline = true; $indent = " "; $this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline, $indent)); } /** * @covers XML_Util::createStartElement() */ public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultilineAndIndentAndLinebreak() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $originalNamespace = "http://www.w3c.org/myNs#"; $expected = "<myNs:myTag foo=\"bar\"^ xmlns:myNs=\"http://www.w3c.org/myNs#\">"; $multiline = true; $indent = " "; $linebreak = "^"; $this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline, $indent, $linebreak)); } /** * @covers XML_Util::createStartElement() */ public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultilineAndIndentAndLinebreakAndSortAttributesIsTrue() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar", "boo" => "baz"); $originalNamespace = "http://www.w3c.org/myNs#"; $expected = "<myNs:myTag boo=\"baz\"^ foo=\"bar\"^ xmlns:myNs=\"http://www.w3c.org/myNs#\">"; $multiline = true; $indent = " "; $linebreak = "^"; $sortAttributes = true; $this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline, $indent, $linebreak, $sortAttributes)); } /** * @covers XML_Util::createStartElement() */ public function testCreateStartElementForTagWithAttributesAndNamespaceWithMultilineAndIndentAndLinebreakAndSortAttributesIsFalse() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar", "boo" => "baz"); $originalNamespace = "http://www.w3c.org/myNs#"; $expected = "<myNs:myTag foo=\"bar\"^ boo=\"baz\"^ xmlns:myNs=\"http://www.w3c.org/myNs#\">"; $multiline = true; $indent = " "; $linebreak = "^"; $sortAttributes = false; $this->assertEquals($expected, XML_Util::createStartElement($originalTag, $originalAttributes, $originalNamespace, $multiline, $indent, $linebreak, $sortAttributes)); } } XML_Util/tests/CreateTagFromArrayTests.php 0000644 00000032264 15004366340 0014571 0 ustar 00 <?php class CreateTagFromArrayTests extends AbstractUnitTests { /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQname() { $original = array( "qname" => "foo:bar", ); $expected = "<foo:bar />"; $this->assertEquals($expected, XML_Util::createTagFromArray($original)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndNamespace() { $original = array( "qname" => "foo:bar", "namespaceUri" => "http://foo.com", ); $expected = "<foo:bar xmlns:foo=\"http://foo.com\" />"; $this->assertEquals($expected, XML_Util::createTagFromArray($original)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributes() { $original = array( "qname" => "foo:bar", "namespaceUri" => "http://foo.com", "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ), ); $expected = "<foo:bar argh=\"fruit&vegetable\" key=\"value\" xmlns:foo=\"http://foo.com\" />"; $this->assertEquals($expected, XML_Util::createTagFromArray($original)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContent() { $original = array( "qname" => "foo:bar", "namespaceUri" => "http://foo.com", "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ), "content" => "I'm inside the tag", ); $expected = "<foo:bar argh=\"fruit&vegetable\" key=\"value\" xmlns:foo=\"http://foo.com\">I'm inside the tag</foo:bar>"; $this->assertEquals($expected, XML_Util::createTagFromArray($original)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndAttributesAndContent() { $original = array( "qname" => "foo:bar", "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ), "content" => "I'm inside the tag", ); $expected = "<foo:bar argh=\"fruit&vegetable\" key=\"value\">I'm inside the tag</foo:bar>"; $this->assertEquals($expected, XML_Util::createTagFromArray($original)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndNamespaceAndContent() { $original = array( "qname" => "foo:bar", "namespaceUri" => "http://foo.com", "content" => "I'm inside the tag", ); $expected = "<foo:bar xmlns:foo=\"http://foo.com\">I'm inside the tag</foo:bar>"; $this->assertEquals($expected, XML_Util::createTagFromArray($original)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithEntitiesNone() { $original = array( "qname" => "foo:bar", "namespaceUri" => "http://foo.com", "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ), "content" => "I'm inside the tag", ); $expected = "<foo:bar argh=\"fruit&vegetable\" key=\"value\" xmlns:foo=\"http://foo.com\">I'm inside the tag</foo:bar>"; $this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_ENTITIES_NONE)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntities() { $original = array( "qname" => "foo:bar", "namespaceUri" => "http://foo.com", "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ), "content" => "I'm inside the tag", ); $expected = "<foo:bar argh=\"fruit&vegetable\" key=\"value\" xmlns:foo=\"http://foo.com\">I'm inside the tag</foo:bar>"; $this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineFalse() { $original = array( "qname" => "foo:bar", "namespaceUri" => "http://foo.com", "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ), "content" => "I'm inside the tag", ); $multiline = false; $expected = "<foo:bar argh=\"fruit&vegetable\" key=\"value\" xmlns:foo=\"http://foo.com\">I'm inside the tag</foo:bar>"; $this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrue() { $original = array( "qname" => "foo:bar", "namespaceUri" => "http://foo.com", "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ), "content" => "I'm inside the tag", ); $multiline = true; $expected = <<< EOF <foo:bar argh="fruit&vegetable" key="value" xmlns:foo="http://foo.com">I'm inside the tag</foo:bar> EOF; $this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrueAndIndent() { $original = array( "qname" => "foo:bar", "namespaceUri" => "http://foo.com", "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ), "content" => "I'm inside the tag", ); $multiline = true; $indent = " "; $expected = <<< EOF <foo:bar argh="fruit&vegetable" key="value" xmlns:foo="http://foo.com">I'm inside the tag</foo:bar> EOF; $this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreak() { $original = array( "qname" => "foo:bar", "namespaceUri" => "http://foo.com", "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ), "content" => "I'm inside the tag", ); $multiline = true; $indent = " "; $linebreak = "^"; $expected = "<foo:bar argh=\"fruit&vegetable\"^ key=\"value\"^ xmlns:foo=\"http://foo.com\">I'm inside the tag</foo:bar>"; $this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreakAndSortAttributesTrue() { $original = array( "qname" => "foo:bar", "namespaceUri" => "http://foo.com", "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ), "content" => "I'm inside the tag", ); $multiline = true; $indent = " "; $linebreak = "^"; $sortAttributes = true; $expected = "<foo:bar argh=\"fruit&vegetable\"^ key=\"value\"^ xmlns:foo=\"http://foo.com\">I'm inside the tag</foo:bar>"; $this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak, $sortAttributes)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameAndNamespaceAndAttributesAndContentWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreakAndSortAttributesFalse() { $original = array( "qname" => "foo:bar", "namespaceUri" => "http://foo.com", "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ), "content" => "I'm inside the tag", ); $multiline = true; $indent = " "; $linebreak = "^"; $sortAttributes = false; $expected = "<foo:bar key=\"value\"^ argh=\"fruit&vegetable\"^ xmlns:foo=\"http://foo.com\">I'm inside the tag</foo:bar>"; $this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak, $sortAttributes)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithInvalidArray() { $badArray = array( "foo" => "bar", ); $expectedError = "You must either supply a qualified name (qname) or local tag name (localPart)."; $this->assertEquals($expectedError, XML_Util::createTagFromArray($badArray)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithNamespaceAndAttributesAndContentButWithoutQname() { $original = array( "namespaceUri" => "http://foo.com", "attributes" => array( "key" => "value", "argh" => "fruit&vegetable" ), "content" => "I'm inside the tag", ); $expectedError = "You must either supply a qualified name (qname) or local tag name (localPart)."; $this->assertEquals($expectedError, XML_Util::createTagFromArray($original)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithNonScalarContent() { $badArray = array( 'content' => array('foo', 'bar'), ); $expectedError = "Supplied non-scalar value as tag content"; $this->assertEquals($expectedError, XML_Util::createTagFromArray($badArray)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithArrayOfNamespaces() { $original = array( 'qname' => 'foo:bar', 'namespaces' => array('ns1' => 'uri1', 'ns2' => 'uri2'), ); $expected = "<foo:bar xmlns:ns1=\"uri1\" xmlns:ns2=\"uri2\" />"; $this->assertEquals($expected, XML_Util::createTagFromArray($original)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameDerivedFromNamespaceUriAndLocalPart() { $original = array( 'namespaceUri' => 'http://bar.org', 'localPart' => 'foo' ); $expected = "<foo xmlns=\"http://bar.org\" />"; $this->assertEquals($expected, XML_Util::createTagFromArray($original)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameDerivedFromNamespaceAndLocalPart() { $original = array( 'namespace' => 'http://foo.org', 'localPart' => 'bar' ); $expected = "<http://foo.org:bar />"; $this->assertEquals($expected, XML_Util::createTagFromArray($original)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithQnameDerivedFromLocalPart() { $original = array( 'namespace' => '', 'localPart' => 'bar' ); $expected = "<bar />"; $this->assertEquals($expected, XML_Util::createTagFromArray($original)); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayWithImplicitlyEmptyContentAndCollapseNoneDoesNotCollapseTag() { $original = array('qname' => 'tag1'); $expected = "<tag1></tag1>"; $actual = XML_Util::createTagFromArray( $original, XML_UTIL_REPLACE_ENTITIES, // default $replaceEntities false, // default $multiline '_auto', // default $indent "\n", // default $linebreak true, // default $sortAttributes XML_UTIL_COLLAPSE_NONE ); $this->assertEquals($expected, $actual); } /** * @covers XML_Util::createTagFromArray() */ public function testCreateTagFromArrayForCdataWithExplicitlyEmptyContentDoesNotCollapseTag() { $original = array('qname' => 'tag1', 'content' => ''); $expected = "<tag1><![CDATA[]]></tag1>"; $this->assertEquals($expected, XML_Util::createTagFromArray($original, XML_UTIL_CDATA_SECTION)); } } XML_Util/tests/CreateTagTests.php 0000644 00000017452 15004366340 0012750 0 ustar 00 <?php class CreateTagTests extends AbstractUnitTests { /** * @covers XML_Util::createTag() */ public function testCreateTagForTagWithAttributes() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $expected = "<myNs:myTag foo=\"bar\" />"; $this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes)); } /** * @covers XML_Util::createTag() */ public function testCreateTagForTagWithAttributesAndContent() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $originalContent = "This is inside the tag"; $expected = "<myNs:myTag foo=\"bar\">This is inside the tag</myNs:myTag>"; $this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent)); } /** * @covers XML_Util::createTag() */ public function testCreateTagForTagWithAttributesAndContentAndNamespace() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $originalContent = "This is inside the tag"; $originalNamespace = "http://www.w3c.org/myNs#"; $expected = "<myNs:myTag foo=\"bar\" xmlns:myNs=\"http://www.w3c.org/myNs#\">This is inside the tag</myNs:myTag>"; $this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace)); } /** * @covers XML_Util::createTag() */ public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithCDataSection() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $originalContent = "This is inside the tag and has < & @ > in it"; $originalNamespace = "http://www.w3c.org/myNs#"; $expected = "<myNs:myTag foo=\"bar\" xmlns:myNs=\"http://www.w3c.org/myNs#\"><![CDATA[This is inside the tag and has < & @ > in it]]></myNs:myTag>"; $this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_CDATA_SECTION)); } /** * @covers XML_Util::createTag() */ public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntities() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $originalContent = "This is inside the tag and has < & @ > in it"; $originalNamespace = "http://www.w3c.org/myNs#"; $expected = "<myNs:myTag foo=\"bar\" xmlns:myNs=\"http://www.w3c.org/myNs#\">This is inside the tag and has < & @ > in it</myNs:myTag>"; $this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES)); } /** * @covers XML_Util::createTag() */ public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineFalse() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $originalContent = "This is inside the tag and has < & @ > in it"; $originalNamespace = "http://www.w3c.org/myNs#"; $multiline = false; $expected = "<myNs:myTag foo=\"bar\" xmlns:myNs=\"http://www.w3c.org/myNs#\">This is inside the tag and has < & @ > in it</myNs:myTag>"; $this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline)); } /** * @covers XML_Util::createTag() */ public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrue() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $originalContent = "This is inside the tag and has < & @ > in it"; $originalNamespace = "http://www.w3c.org/myNs#"; $multiline = true; $expected = <<< EOF <myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag> EOF; $this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline)); } /** * @covers XML_Util::createTag() */ public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrueAndIndent() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $originalContent = "This is inside the tag and has < & @ > in it"; $originalNamespace = "http://www.w3c.org/myNs#"; $multiline = true; $indent = " "; $expected = <<< EOF <myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#">This is inside the tag and has < & @ > in it</myNs:myTag> EOF; $this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent)); } /** * @covers XML_Util::createTag() */ public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreak() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar"); $originalContent = "This is inside the tag and has < & @ > in it"; $originalNamespace = "http://www.w3c.org/myNs#"; $multiline = true; $indent = " "; $linebreak = "^"; $expected = "<myNs:myTag foo=\"bar\"^ xmlns:myNs=\"http://www.w3c.org/myNs#\">This is inside the tag and has < & @ > in it</myNs:myTag>"; $this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak)); } /** * @covers XML_Util::createTag() */ public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreakAndSortAttributesTrue() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar", "boo" => "baz"); $originalContent = "This is inside the tag and has < & @ > in it"; $originalNamespace = "http://www.w3c.org/myNs#"; $multiline = true; $indent = " "; $linebreak = "^"; $sortAttributes = true; $expected = "<myNs:myTag boo=\"baz\"^ foo=\"bar\"^ xmlns:myNs=\"http://www.w3c.org/myNs#\">This is inside the tag and has < & @ > in it</myNs:myTag>"; $this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak, $sortAttributes)); } /** * @covers XML_Util::createTag() */ public function testCreateTagForTagWithAttributesAndContentAndNamespaceWithReplaceEntitiesAndMultilineTrueAndIndentAndLinebreakAndSortAttributesFalse() { $originalTag = "myNs:myTag"; $originalAttributes = array("foo" => "bar", "boo" => "baz"); $originalContent = "This is inside the tag and has < & @ > in it"; $originalNamespace = "http://www.w3c.org/myNs#"; $multiline = true; $indent = " "; $linebreak = "^"; $sortAttributes = false; $expected = "<myNs:myTag foo=\"bar\"^ boo=\"baz\"^ xmlns:myNs=\"http://www.w3c.org/myNs#\">This is inside the tag and has < & @ > in it</myNs:myTag>"; $this->assertEquals($expected, XML_Util::createTag($originalTag, $originalAttributes, $originalContent, $originalNamespace, XML_UTIL_REPLACE_ENTITIES, $multiline, $indent, $linebreak, $sortAttributes)); } } XML_Util/tests/GetDocTypeDeclarationTests.php 0000644 00000003363 15004366340 0015262 0 ustar 00 <?php class GetDocTypeDeclarationTests extends AbstractUnitTests { /** * @covers XML_Util::getDocTypeDeclaration() */ public function testGetDocTypeDeclarationUsingRoot() { $expected = "<!DOCTYPE rootTag>"; $this->assertEquals($expected, XML_Util::getDocTypeDeclaration("rootTag")); } /** * @covers XML_Util::getDocTypeDeclaration() */ public function testGetDocTypeDeclarationUsingRootAndStringUri() { $expected = "<!DOCTYPE rootTag SYSTEM \"myDocType.dtd\">"; $this->assertEquals($expected, XML_Util::getDocTypeDeclaration("rootTag", "myDocType.dtd")); } /** * @covers XML_Util::getDocTypeDeclaration() */ public function testGetDocTypeDeclarationUsingRootAndArrayUri() { $uri = array( 'uri' => 'http://pear.php.net/dtd/package-1.0', 'id' => '-//PHP//PEAR/DTD PACKAGE 0.1' ); $expected = "<!DOCTYPE rootTag PUBLIC \"-//PHP//PEAR/DTD PACKAGE 0.1\" \"http://pear.php.net/dtd/package-1.0\">"; $this->assertEquals($expected, XML_Util::getDocTypeDeclaration("rootTag", $uri)); } /** * @covers XML_Util::getDocTypeDeclaration() */ public function testGetDocTypeDeclarationUsingRootAndArrayUriAndInternalDtd() { $uri = array( 'uri' => 'http://pear.php.net/dtd/package-1.0', 'id' => '-//PHP//PEAR/DTD PACKAGE 0.1' ); $dtdEntry = '<!ELEMENT additionalInfo (#PCDATA)>'; $expected = <<< EOF <!DOCTYPE rootTag PUBLIC "-//PHP//PEAR/DTD PACKAGE 0.1" "http://pear.php.net/dtd/package-1.0" [ <!ELEMENT additionalInfo (#PCDATA)> ]> EOF; $this->assertEquals($expected, XML_Util::getDocTypeDeclaration("rootTag", $uri, $dtdEntry)); } } XML_Util/tests/GetXmlDeclarationTests.php 0000644 00000002214 15004366340 0014445 0 ustar 00 <?php class GetXMLDeclarationTests extends AbstractUnitTests { /** * @covers XML_Util::getXMLDeclaration() */ public function testGetXMLDeclarationUsingVersion() { $version = "1.0"; $expected = "<?xml version=\"1.0\"?>"; $this->assertEquals($expected, XML_Util::getXMLDeclaration($version)); } /** * @covers XML_Util::getXMLDeclaration() */ public function testGetXMLDeclarationUsingVersionAndEncodingAndStandalone() { $version = "1.0"; $encoding = "UTF-8"; $standalone = true; $expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"; $this->assertEquals($expected, XML_Util::getXMLDeclaration($version, $encoding, $standalone)); } /** * @covers XML_Util::getXMLDeclaration() */ public function testGetXMLDeclarationUsingVersionAndStandalone() { $version = "1.0"; $encoding = null; $standalone = true; $expected = "<?xml version=\"1.0\" standalone=\"yes\"?>"; $this->assertEquals($expected, XML_Util::getXMLDeclaration($version, $encoding, $standalone)); } } XML_Util/tests/IsValidNameTests.php 0000644 00000003677 15004366340 0013251 0 ustar 00 <?php class IsValidNameTests extends AbstractUnitTests { /** * @covers XML_Util::isValidName() */ public function testIsValidNameForTagNameThatIsValid() { $tagName = "alpha-x_y_z.123"; $result = XML_Util::isValidName($tagName); $this->assertTrue($result); } /** * @covers XML_Util::isValidName() */ public function testIsValidNameForTagNameWithInvalidCharacter() { $tagName = "invalidTag?"; $result = XML_Util::isValidName($tagName); $this->assertInstanceOf('PEAR_Error', $result); $expectedError = "XML names may only contain alphanumeric chars, period, hyphen, colon and underscores"; $this->assertEquals($expectedError, $result->getMessage()); } /** * @covers XML_Util::isValidName() */ public function testIsValidNameForTagNameWithInvalidStartingCharacter() { $tagName = "1234five"; $result = XML_Util::isValidName($tagName); $this->assertInstanceOf('PEAR_Error', $result); $expectedError = "XML names may only start with letter or underscore"; $this->assertEquals($expectedError, $result->getMessage()); } /** * @covers XML_Util::isValidName() */ public function testIsValidNameForInt() { $tagName = 1; $result = XML_Util::isValidName($tagName); $this->assertInstanceOf('PEAR_Error', $result); $expectedError = "XML names may only start with letter or underscore"; $this->assertEquals($expectedError, $result->getMessage()); } /** * @covers XML_Util::isValidName() */ public function testIsValidNameForEmptyString() { $tagName = ''; $result = XML_Util::isValidName($tagName); $this->assertInstanceOf('PEAR_Error', $result); $expectedError = "XML names may only start with letter or underscore"; $this->assertEquals($expectedError, $result->getMessage()); } } XML_Util/tests/RaiseErrorTests.php 0000644 00000000700 15004366340 0013152 0 ustar 00 <?php class RaiseErrorTests extends AbstractUnitTests { /** * @covers XML_Util::raiseError() */ public function testRaiseError() { $code = 12345; $message = "I am an error"; $error = XML_Util::raiseError($message, $code); $this->assertInstanceOf('PEAR_Error', $error); $this->assertEquals($message, $error->getMessage()); $this->assertEquals($code, $error->getCode()); } } XML_Util/tests/ReplaceEntitiesTests.php 0000644 00000010341 15004366340 0014157 0 ustar 00 <?php class ReplaceEntitiesTests extends AbstractUnitTests { protected function getSimpleData() { return 'This string contains < & >.'; } protected function getUtf8Data() { return 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê'; } /** * @covers XML_Util::replaceEntities() */ public function testReplaceEntitiesForSimpleData() { $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData())); } /** * @covers XML_Util::replaceEntities() */ public function testReplaceEntitiesForSimpleDataWithInvalidOptionReturnsOriginalData() { $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), 'INVALID_OPTION')); } /** * @covers XML_Util::replaceEntities() */ public function testReplaceEntitiesForSimpleDataWithEntitiesXml() { $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML)); } /** * @covers XML_Util::replaceEntities() */ public function testReplaceEntitiesForSimpleDataWithEntitiesXmlAndEncoding() { $encoding = "UTF-8"; $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML, $encoding)); } /** * @covers XML_Util::replaceEntities() */ public function testReplaceEntitiesForUtf8DataWithEntitiesXmlAndEncoding() { $encoding = "UTF-8"; $expected = "This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê"; $this->assertEquals($expected, XML_Util::replaceEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML, $encoding)); } /** * @covers XML_Util::replaceEntities() */ public function testReplaceEntitiesForSimpleDataWithEntitiesXmlRequired() { $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED)); } /** * @covers XML_Util::replaceEntities() */ public function testReplaceEntitiesForSimpleDataWithEntitiesXmlRequiredAndEncoding() { $encoding = "UTF-8"; $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding)); } /** * @covers XML_Util::replaceEntities() */ public function testReplaceEntitiesForUtf8DataWithEntitiesXmlRequiredAndEncoding() { $encoding = "UTF-8"; $expected = "This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê"; $this->assertEquals($expected, XML_Util::replaceEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding)); } /** * @covers XML_Util::replaceEntities() */ public function testReplaceEntitiesForSimpleDataWithEntitiesHtml() { $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML)); } /** * @covers XML_Util::replaceEntities() */ public function testReplaceEntitiesForSimpleDataWithEntitiesHtmlAndEncoding() { $encoding = "UTF-8"; $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::replaceEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML, $encoding)); } /** * @covers XML_Util::replaceEntities() */ public function testReplaceEntitiesForUtf8DataWithEntitiesHtmlAndEncoding() { $encoding = "UTF-8"; $expected = "This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê"; $this->assertEquals($expected, XML_Util::replaceEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_HTML, $encoding)); } } XML_Util/tests/ReverseEntitiesTests.php 0000644 00000010326 15004366340 0014222 0 ustar 00 <?php class ReverseEntitiesTests extends AbstractUnitTests { protected function getSimpleData() { return 'This string contains < & >.'; } protected function getUtf8Data() { return 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê'; } /** * @covers XML_Util::reverseEntities() */ public function testReverseEntitiesForSimpleData() { $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData())); } /** * @covers XML_Util::reverseEntities() */ public function testReverseEntitiesForSimpleDataWithInvalidOptionReturnsOriginalData() { $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), 'INVALID_OPTION')); } /** * @covers XML_Util::reverseEntities() */ public function testReverseEntitiesForSimpleDataWithEntitiesXml() { $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML)); } /** * @covers XML_Util::reverseEntities() */ public function testReverseEntitiesForSimpleDataWithEntitiesXmlAndEncoding() { $encoding = "UTF-8"; $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML), $encoding); } /** * @covers XML_Util::reverseEntities() */ public function testReverseEntitiesForUtf8DataWithEntitiesXmlAndEncoding() { $encoding = "UTF-8"; $expected = "This data contains special chars like <, >, & and \" as well as ä, ö, ß, à and ê"; $this->assertEquals($expected, XML_Util::reverseEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML), $encoding); } /** * @covers XML_Util::reverseEntities() */ public function testReverseEntitiesForSimpleDataWithEntitiesXmlRequired() { $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED)); } /** * @covers XML_Util::reverseEntities() */ public function testReverseEntitiesForSimpleDataWithEntitiesXmlRequiredAndEncoding() { $encoding = "UTF-8"; $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding)); } /** * @covers XML_Util::reverseEntities() */ public function testReverseEntitiesForUtf8DataWithEntitiesXmlRequiredAndEncoding() { $encoding = "UTF-8"; $expected = "This data contains special chars like <, >, & and \" as well as ä, ö, ß, à and ê"; $this->assertEquals($expected, XML_Util::reverseEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding)); } /** * @covers XML_Util::reverseEntities() */ public function testReverseEntitiesForSimpleDataWithEntitiesHtml() { $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML)); } /** * @covers XML_Util::reverseEntities() */ public function testReverseEntitiesForSimpleDataWithEntitiesHtmlAndEncoding() { $encoding = "UTF-8"; $expected = "This string contains < & >."; $this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML, $encoding)); } /** * @covers XML_Util::reverseEntities() */ public function testReverseEntitiesForUtf8DataWithEntitiesHtmlAndEncoding() { $encoding = "UTF-8"; $expected = "This data contains special chars like <, >, & and \" as well as ä, ö, ß, à and ê"; $this->assertEquals($expected, XML_Util::reverseEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_HTML, $encoding)); } } XML_Util/tests/SplitQualifiedNameTests.php 0000644 00000001507 15004366340 0014623 0 ustar 00 <?php class SplitQualifiedNameTests extends AbstractUnitTests { /** * @covers XML_Util::splitQualifiedName() */ public function testSplitQualifiedNameWithoutNamespace() { $original = "xslt:stylesheet"; $expected = array( 'namespace' => 'xslt', 'localPart' => 'stylesheet', ); $this->assertEquals($expected, XML_Util::splitQualifiedName($original)); } /** * @covers XML_Util::splitQualifiedName() */ public function testSplitQualifiedNameWithNamespace() { $original = "stylesheet"; $namespace = "myNs"; $expected = array( 'namespace' => 'myNs', 'localPart' => 'stylesheet', ); $this->assertEquals($expected, XML_Util::splitQualifiedName($original, $namespace)); } } __init__.py 0000644 00000000057 15004413005 0006647 0 ustar 00 # Dummy file to make this directory a package. __pycache__/__init__.cpython-311.pyc 0000644 00000000331 15004413005 0013202 0 ustar 00 � ��bg/ � � � d S )N� r � �l/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib64/python3.11/site-packages/guppy/heapy/test/__init__.py�<module>r s �� � r __pycache__/support.cpython-311.pyc 0000644 00000015253 15004413005 0013170 0 ustar 00 � ��bg� � �� � d Z ddlZddlZddlZddlZddlZ G d� de� � Z G d� de� � Z G d� de� � Z d Z dZ G d � d� � Zdd�Z dd �Zd� Z G d� dej � � ZdS )ziSupporting definitions for the Heapy regression test. Addapted from Python standard module test_support. � Nc � � e Zd ZdZdS )�Errorz*Base class for regression test exceptions.N��__name__� __module__�__qualname__�__doc__� � �k/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib64/python3.11/site-packages/guppy/heapy/test/support.pyr r s � � � � � �4�4�4�4r r c � � e Zd ZdZdS )� TestFailedzTest failed.Nr r r r r r s � � � � � ����r r c � � e Zd ZdZdS )�TestSkippeda! Test skipped. This can be raised to indicate that a test was deliberatly skipped, but not because a feature wasn't available. For example, if some resource can't be used, such as the network appears to be unavailable, this should be raised instead of TestFailed. Nr r r r r r s � � � � � �� � � r r � c � � e Zd Zd� ZdS )�BasicTestRunnerc �B � t j � � } ||� � |S �N)�unittest� TestResult)�self�test�results r �runzBasicTestRunner.run( s"