-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
XMLFormatterTest.php
68 lines (51 loc) · 1.33 KB
/
XMLFormatterTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php namespace CodeIgniter\Format;
class XMLFormatterTest extends \CIUnitTestCase
{
protected $xmlFormatter;
public function setUp()
{
parent::setUp();
$this->xmlFormatter = new XMLFormatter();
}
public function testBasicXML()
{
$data = [
'foo' => 'bar'
];
$expected = <<<EOH
<?xml version="1.0"?>
<response><foo>bar</foo></response>
EOH;
$this->assertEquals($expected, $this->xmlFormatter->format($data));
}
public function testFormatXMLWithMultilevelArray()
{
$data = [
'foo' => ['bar']
];
$expected = <<<EOH
<?xml version="1.0"?>
<response><foo><0>bar</0></foo></response>
EOH;
$this->assertEquals($expected, $this->xmlFormatter->format($data));
}
public function testFormatXMLWithMultilevelArrayAndNumericKey()
{
$data = [
['foo']
];
$expected = <<<EOH
<?xml version="1.0"?>
<response><item0><0>foo</0></item0></response>
EOH;
$this->assertEquals($expected, $this->xmlFormatter->format($data));
}
public function testStringFormatting() {
$data = ['Something'];
$expected = <<<EOH
<?xml version="1.0"?>
<response><0>Something</0></response>
EOH;
$this->assertEquals($expected, $this->xmlFormatter->format($data));
}
}