ILIAS
trunk Revision v11.0_alpha-1761-g6dbbfa7b760
◀ ilDoc Overview
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
+
Variables
$
c
e
g
h
j
l
m
p
s
t
u
v
+
Enumerations
a
c
e
f
i
j
l
m
n
o
p
r
s
t
u
v
z
+
Enumerator
a
c
d
e
f
g
i
l
m
n
o
p
q
s
t
u
v
y
+
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
+
Data Fields
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Ö
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Ö
Enumerations
Enumerator
+
Files
File List
+
Globals
+
All
$
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
z
+
Functions
a
b
c
d
e
f
g
h
i
m
n
p
r
s
t
u
v
+
Variables
$
a
c
e
g
h
i
m
n
o
p
r
s
t
u
v
z
Enumerations
Enumerator
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Enumerations
Enumerator
Modules
Pages
ilServicesXmlTest.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
use
PHPUnit\Framework\TestCase
;
22
use
ILIAS\DI\Container
;
23
24
class
ilServicesXmlTest
extends
TestCase
25
{
26
public
function
testHeader
(): void
27
{
28
$writer =
new
ilXmlWriter
();
29
$writer->xmlHeader();
30
31
$this->assertEquals(
32
$this->
brutallyTrim
(
"<?xml version=\"1.0\" encoding=\"utf-8\"?><!--Generated by ILIAS XmlWriter-->"
),
33
$this->
brutallyTrim
($writer->xmlDumpMem())
34
);
35
}
36
37
public
function
testStartEndTag
(): void
38
{
39
$writer =
new
ilXmlWriter
();
40
$writer->xmlStartTag(
'lorem'
);
41
$writer->xmlEndTag(
'lorem'
);
42
$this->assertEquals(
43
$this->
brutallyTrim
(
"<lorem></lorem>"
),
44
$this->
brutallyTrim
($writer->xmlDumpMem())
45
);
46
}
47
48
public
function
testElements
(): void
49
{
50
$writer =
new
ilXmlWriter
();
51
$writer->xmlStartTag(
'lorem'
);
52
$writer->xmlElement(
'ipsum'
, [
'attr1'
=> 1],
'data1'
);
53
$writer->xmlElement(
'dolor'
, [
'attr2'
=> 2,
'attr3'
=> 3],
'data2'
);
54
$writer->xmlEndTag(
'lorem'
);
55
$this->assertEquals(
56
$this->
brutallyTrim
(
57
"<lorem><ipsum attr1=\"1\"> data1</ipsum><dolor attr2=\"2\" attr3=\"3\"> data2</dolor></lorem>"
58
),
59
$this->
brutallyTrim
($writer->xmlDumpMem())
60
);
61
}
62
63
protected
function
brutallyTrim
(
string
$string): string
64
{
65
$string = str_replace([
"\n"
,
"\r"
,
"\t"
],
""
, $string);
66
$string = preg_replace(
'# {2,}#'
,
" "
, $string);
67
$string = preg_replace(
"/>(\s+)</"
,
"><"
, $string);
68
$string = str_replace(
" >"
,
">"
, $string);
69
$string = str_replace(
" <"
,
"<"
, $string);
70
return
trim($string);
71
}
72
}
ilXmlWriter
ilServicesXmlTest
Definition:
ilServicesXmlTest.php:24
ilServicesXmlTest\testStartEndTag
testStartEndTag()
Definition:
ilServicesXmlTest.php:37
ilServicesXmlTest\testElements
testElements()
Definition:
ilServicesXmlTest.php:48
Container
ilServicesXmlTest\testHeader
testHeader()
Definition:
ilServicesXmlTest.php:26
ilServicesXmlTest\brutallyTrim
brutallyTrim(string $string)
Definition:
ilServicesXmlTest.php:63
TestCase
TestCase
components
ILIAS
Xml
tests
ilServicesXmlTest.php
Generated on Fri Apr 11 2025 23:04:35 for ILIAS by
1.8.13 (using
Doxyfile
)