| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* Unit Tests for serializing arrays
|
|
|
4 |
*
|
|
|
5 |
* @package XML_Serializer
|
|
|
6 |
* @subpackage tests
|
|
|
7 |
* @author Stephan Schmidt <schst@php-tools.net>
|
|
|
8 |
* @author Chuck Burgess <ashnazg@php.net>
|
|
|
9 |
*/
|
|
|
10 |
|
|
|
11 |
/**
|
|
|
12 |
* PHPUnit main() hack
|
|
|
13 |
*
|
|
|
14 |
* "Call class::main() if this source file is executed directly."
|
|
|
15 |
*/
|
|
|
16 |
if (!defined('PHPUnit_MAIN_METHOD')) {
|
|
|
17 |
define('PHPUnit_MAIN_METHOD', 'XML_Serializer_Option_Indent_TestCase::main');
|
|
|
18 |
}
|
|
|
19 |
require_once 'PHPUnit/Framework/TestCase.php';
|
|
|
20 |
require_once 'PHPUnit/Framework/TestSuite.php';
|
|
|
21 |
require_once 'PHPUnit/TextUI/TestRunner.php';
|
|
|
22 |
|
|
|
23 |
require_once 'XML/Serializer.php';
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Unit Tests for serializing arrays
|
|
|
27 |
*
|
|
|
28 |
* @package XML_Serializer
|
|
|
29 |
* @subpackage tests
|
|
|
30 |
* @author Stephan Schmidt <schst@php-tools.net>
|
|
|
31 |
* @author Chuck Burgess <ashnazg@php.net>
|
|
|
32 |
*/
|
|
|
33 |
class XML_Serializer_Option_Indent_TestCase extends PHPUnit_Framework_TestCase {
|
|
|
34 |
|
|
|
35 |
private $options = array(
|
|
|
36 |
XML_SERIALIZER_OPTION_LINEBREAKS => "\n",
|
|
|
37 |
);
|
|
|
38 |
|
|
|
39 |
public static function main() {
|
|
|
40 |
$suite = new PHPUnit_Framework_TestSuite('XML_Serializer_Option_Indent_TestCase');
|
|
|
41 |
$result = PHPUnit_TextUI_TestRunner::run($suite);
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
protected function setUp() {}
|
|
|
45 |
|
|
|
46 |
protected function tearDown() {}
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* Indent with spaces
|
|
|
50 |
*/
|
|
|
51 |
public function testSpaces()
|
|
|
52 |
{
|
|
|
53 |
$s = new XML_Serializer($this->options);
|
|
|
54 |
$s->setOption(XML_SERIALIZER_OPTION_INDENT, ' ');
|
|
|
55 |
$s->serialize(array('foo' => 'bar'));
|
|
|
56 |
$this->assertEquals('<array>
|
|
|
57 |
<foo>bar</foo>
|
|
|
58 |
</array>', $s->getSerializedData());
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* Indent with tabs
|
|
|
63 |
*/
|
|
|
64 |
public function testTabs()
|
|
|
65 |
{
|
|
|
66 |
$s = new XML_Serializer($this->options);
|
|
|
67 |
$s->setOption(XML_SERIALIZER_OPTION_INDENT, "\t");
|
|
|
68 |
$s->serialize(array('foo' => 'bar'));
|
|
|
69 |
$this->assertEquals('<array>
|
|
|
70 |
<foo>bar</foo>
|
|
|
71 |
</array>', $s->getSerializedData());
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
/**
|
|
|
77 |
* PHPUnit main() hack
|
|
|
78 |
* "Call class::main() if this source file is executed directly."
|
|
|
79 |
*/
|
|
|
80 |
if (PHPUnit_MAIN_METHOD == 'XML_Serializer_Option_Indent_TestCase::main') {
|
|
|
81 |
XML_Serializer_Option_Indent_TestCase::main();
|
|
|
82 |
}
|
|
|
83 |
?>
|