ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilServicesXmlTest Class Reference
+ Inheritance diagram for ilServicesXmlTest:
+ Collaboration diagram for ilServicesXmlTest:

Public Member Functions

 testHeader ()
 
 testStartEndTag ()
 
 testElements ()
 

Protected Member Functions

 brutallyTrim (string $string)
 

Detailed Description

Definition at line 24 of file ilServicesXmlTest.php.

Member Function Documentation

◆ brutallyTrim()

ilServicesXmlTest::brutallyTrim ( string  $string)
protected

Definition at line 63 of file ilServicesXmlTest.php.

Referenced by testElements(), testHeader(), and testStartEndTag().

63  : 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  }
+ Here is the caller graph for this function:

◆ testElements()

ilServicesXmlTest::testElements ( )

Definition at line 48 of file ilServicesXmlTest.php.

References brutallyTrim().

48  : 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  }
brutallyTrim(string $string)
+ Here is the call graph for this function:

◆ testHeader()

ilServicesXmlTest::testHeader ( )

Definition at line 26 of file ilServicesXmlTest.php.

References brutallyTrim().

26  : 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  }
brutallyTrim(string $string)
+ Here is the call graph for this function:

◆ testStartEndTag()

ilServicesXmlTest::testStartEndTag ( )

Definition at line 37 of file ilServicesXmlTest.php.

References brutallyTrim().

37  : 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  }
brutallyTrim(string $string)
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: