3
3
/*
4
4
* This file is part of the PHPCR API Tests package
5
5
*
6
- * Copyright (c) 2013 Liip and others
6
+ * Copyright (c) 2015 Liip and others
7
7
*
8
8
* For the full copyright and license information, please view the LICENSE
9
9
* file that was distributed with this source code.
@@ -35,7 +35,7 @@ public function testExportSystemView()
35
35
$ output ->loadXML (stream_get_contents ($ stream ));
36
36
$ expected = new DOMDocument ();
37
37
$ expected ->preserveWhiteSpace = false ;
38
- $ expected ->load (__DIR__ . '/../../fixtures/07_Export/systemview.xml ' );
38
+ $ expected ->load (__DIR__ . '/../../fixtures/07_Export/systemview.xml ' );
39
39
fclose ($ stream );
40
40
$ this ->assertEquivalentSystem ($ expected ->documentElement , $ output ->documentElement , new DOMXPath ($ output ));
41
41
}
@@ -55,12 +55,12 @@ private function buildPath(DOMNode $n)
55
55
if ($ name == null ) {
56
56
$ elem = 'sv:node(unnamed) ' ;
57
57
} else {
58
- $ elem = $ n ->tagName . '( ' . $ name ->value . ') ' ;
58
+ $ elem = $ n ->tagName . '( ' . $ name ->value . ') ' ;
59
59
}
60
60
} else {
61
61
$ elem = $ n ->nodeName ;
62
62
}
63
- $ ret = $ elem . '/ ' . $ ret ;
63
+ $ ret = $ elem. '/ ' . $ ret ;
64
64
$ n = $ n ->parentNode ;
65
65
}
66
66
@@ -85,7 +85,7 @@ private function assertEquivalentSystem(DOMElement $expected, DOMElement $output
85
85
foreach ($ expected ->attributes as $ attr ) {
86
86
//i.e. sv:name attribute
87
87
$ oattr = $ output ->attributes ->getNamedItem ($ attr ->name );
88
- $ this ->assertNotNull ($ oattr , 'missing attribute ' . $ attr ->name );
88
+ $ this ->assertNotNull ($ oattr , 'missing attribute ' . $ attr ->name );
89
89
$ this ->assertEquals ($ attr ->value , $ oattr ->value , 'wrong attribute value ' );
90
90
}
91
91
@@ -97,12 +97,12 @@ private function assertEquivalentSystem(DOMElement $expected, DOMElement $output
97
97
foreach ($ expected ->childNodes as $ index => $ child ) {
98
98
$ this ->assertEquals ('sv:value ' , $ child ->tagName );
99
99
$ o = $ output ->childNodes ->item ($ index );
100
- $ this ->assertInstanceOf ('DOMElement ' , $ o , "No child element at $ index in " . $ this ->buildPath ($ child ));
101
- $ this ->assertEquals ('sv:value ' , $ o ->tagName , 'Unexpected tag name at ' . $ this ->buildPath ($ expected ) . "sv:value[ $ index] " );
100
+ $ this ->assertInstanceOf ('DOMElement ' , $ o , "No child element at $ index in " . $ this ->buildPath ($ child ));
101
+ $ this ->assertEquals ('sv:value ' , $ o ->tagName , 'Unexpected tag name at ' . $ this ->buildPath ($ expected ). "sv:value[ $ index] " );
102
102
if ($ this ->isDate ($ child ->textContent ) && $ this ->isDate ($ o ->textContent )) {
103
- $ this ->assertEqualDateString ($ child ->textContent , $ o ->textContent , 'Not the same date at ' . $ this ->buildPath ($ output ) . "sv:value[ $ index] " );
103
+ $ this ->assertEqualDateString ($ child ->textContent , $ o ->textContent , 'Not the same date at ' . $ this ->buildPath ($ output ). "sv:value[ $ index] " );
104
104
} else {
105
- $ this ->assertEquals ($ child ->textContent , $ o ->textContent , 'Not the same text at ' . $ this ->buildPath ($ output ) . "sv:value[ $ index] " );
105
+ $ this ->assertEquals ($ child ->textContent , $ o ->textContent , 'Not the same text at ' . $ this ->buildPath ($ output ). "sv:value[ $ index] " );
106
106
}
107
107
}
108
108
}
@@ -111,8 +111,8 @@ private function assertEquivalentSystem(DOMElement $expected, DOMElement $output
111
111
foreach ($ expected ->childNodes as $ child ) {
112
112
$ this ->assertContains ($ child ->tagName , array ('sv:property ' , 'sv:node ' ), 'unexpected child of sv:node ' );
113
113
$ childname = $ child ->attributes ->getNamedItem ('name ' )->value ;
114
- $ q = $ oxpath ->query ($ child ->tagName . '[@sv:name=" ' . $ childname . '"] ' , $ output );
115
- $ this ->assertEquals (1 , $ q ->length , 'expected to find exactly one node named ' . $ childname . ' under ' . $ this ->buildPath ($ output ));
114
+ $ q = $ oxpath ->query ($ child ->tagName . '[@sv:name=" ' . $ childname. '"] ' , $ output );
115
+ $ this ->assertEquals (1 , $ q ->length , 'expected to find exactly one node named ' . $ childname. ' under ' . $ this ->buildPath ($ output ));
116
116
$ this ->assertEquivalentSystem ($ child , $ q ->item (0 ), $ oxpath );
117
117
}
118
118
}
@@ -128,7 +128,7 @@ public function testExportDocumentView()
128
128
$ output ->loadXML (stream_get_contents ($ stream ));
129
129
$ expected = new DOMDocument ();
130
130
$ expected ->preserveWhiteSpace = false ;
131
- $ expected ->load (__DIR__ . '/../../fixtures/07_Export/documentview.xml ' );
131
+ $ expected ->load (__DIR__ . '/../../fixtures/07_Export/documentview.xml ' );
132
132
fclose ($ stream );
133
133
$ this ->assertEquivalentDocument ($ expected ->documentElement , $ output ->documentElement , new DOMXPath ($ output ));
134
134
}
@@ -142,7 +142,7 @@ public function testExportDocumentView()
142
142
private function assertEquivalentDocument (DOMElement $ expected , DOMElement $ output , DOMXPath $ oxpath )
143
143
{
144
144
if ($ expected instanceof DOMText) {
145
- $ this ->assertEquals ($ expected ->textContent , $ output ->textContent , 'Not the same text at ' . $ this ->buildPath ($ expected ));
145
+ $ this ->assertEquals ($ expected ->textContent , $ output ->textContent , 'Not the same text at ' . $ this ->buildPath ($ expected ));
146
146
} elseif ($ expected instanceof DOMElement) {
147
147
$ this ->assertEquals ($ expected ->tagName , $ output ->tagName );
148
148
@@ -151,18 +151,18 @@ private function assertEquivalentDocument(DOMElement $expected, DOMElement $outp
151
151
$ this ->assertNotEmpty ($ attr ->value );
152
152
} else {
153
153
$ oattr = $ output ->attributes ->getNamedItem ($ attr ->name );
154
- $ this ->assertNotNull ($ oattr , 'missing attribute ' . $ attr ->name . ' at ' . $ this ->buildPath ($ expected ));
154
+ $ this ->assertNotNull ($ oattr , 'missing attribute ' . $ attr ->name . ' at ' . $ this ->buildPath ($ expected ));
155
155
if ($ this ->isDate ($ attr ->value ) && $ this ->isDate ($ oattr ->value )) {
156
- $ this ->assertEqualDateString ($ attr ->value , $ oattr ->value , 'wrong attribute value at ' . $ this ->buildPath ($ expected ) . '/ ' . $ attr ->name );
156
+ $ this ->assertEqualDateString ($ attr ->value , $ oattr ->value , 'wrong attribute value at ' . $ this ->buildPath ($ expected ). '/ ' . $ attr ->name );
157
157
} else {
158
- $ this ->assertEquals ($ attr ->value , $ oattr ->value , 'wrong attribute value at ' . $ this ->buildPath ($ expected ) . '/ ' . $ attr ->name );
158
+ $ this ->assertEquals ($ attr ->value , $ oattr ->value , 'wrong attribute value at ' . $ this ->buildPath ($ expected ). '/ ' . $ attr ->name );
159
159
}
160
160
}
161
161
}
162
162
163
163
foreach ($ expected ->childNodes as $ child ) {
164
164
$ q = $ oxpath ->query ($ child ->tagName , $ output ); //TODO: same-name siblings
165
- $ this ->assertEquals (1 , $ q ->length , 'expected to find exactly one node named ' . $ child ->tagName . ' under ' . $ this ->buildPath ($ expected ));
165
+ $ this ->assertEquals (1 , $ q ->length , 'expected to find exactly one node named ' . $ child ->tagName . ' under ' . $ this ->buildPath ($ expected ));
166
166
$ this ->assertEquivalentDocument ($ child , $ q ->item (0 ), $ oxpath );
167
167
}
168
168
}
0 commit comments