ILIAS  trunk Revision v11.0_alpha-2658-ge2404539063
PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest Class Reference
+ Inheritance diagram for PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest:
+ Collaboration diagram for PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest:

Public Member Functions

 testCompareEqual ()
 
 testCompareNewDeleted ()
 
 testCompareChanged ()
 
 testCompareTextChanges ()
 

Protected Member Functions

 getElementChange (string $pcid, array $changes)
 
- Protected Member Functions inherited from COPageTestBase
 setGlobalVariable (string $name, $value)
 
 setUp ()
 
 getIdGeneratorMock ()
 
 getPCDefinition ()
 
 setPCIdCnt (int $cnt)
 
 getIDManager (\ilPageObject $page)
 
 insertParagraphAt (\ilPageObject $page, string $hier_id, string $text="")
 
 tearDown ()
 
 normalize (string $html)
 
 assertXmlEquals (string $expected_xml_as_string, string $html_xml_string)
 
 getEmptyPageWithDom ()
 
 legacyHtmlToXml (string $content)
 
 getMediaObjectMock ()
 

Additional Inherited Members

- Protected Attributes inherited from COPageTestBase
int $pc_cnt
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 29 of file PageCompareTest.php.

Member Function Documentation

◆ getElementChange()

PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest::getElementChange ( string  $pcid,
array  $changes 
)
protected

Definition at line 31 of file PageCompareTest.php.

Referenced by PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest\testCompareChanged(), PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest\testCompareEqual(), and PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest\testCompareNewDeleted().

31  : string
32  {
33  return $changes[str_pad($pcid, 32, "0", STR_PAD_LEFT)]["change"] ?? "";
34  }
+ Here is the caller graph for this function:

◆ testCompareChanged()

PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest::testCompareChanged ( )

Definition at line 90 of file PageCompareTest.php.

References $res, PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest\getElementChange(), COPageTestBase\getEmptyPageWithDom(), COPageTestBase\insertParagraphAt(), and COPageTestBase\setPCIdCnt().

90  : void
91  {
92  $compare = new PageCompare();
93 
94  $l_page = $this->getEmptyPageWithDom();
95  $this->insertParagraphAt($l_page, "pg", "Hello World!");
96  $l_page->insertPCIds();
97 
98  $this->setPCIdCnt(1); // reset PCID counter to get same PCID
99 
100  $r_page = $this->getEmptyPageWithDom();
101  $this->insertParagraphAt($r_page, "pg", "Hello little World!");
102  $r_page->insertPCIds();
103 
104  $res = $compare->compare($l_page, $l_page, $r_page);
105 
106  $this->assertEquals(
107  "Modified",
108  $this->getElementChange("1", $res["l_changes"])
109  );
110 
111  $this->assertEquals(
112  "Modified",
113  $this->getElementChange("1", $res["r_changes"])
114  );
115  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
$res
Definition: ltiservices.php:66
setPCIdCnt(int $cnt)
+ Here is the call graph for this function:

◆ testCompareEqual()

PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest::testCompareEqual ( )

Definition at line 35 of file PageCompareTest.php.

References $res, PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest\getElementChange(), COPageTestBase\getEmptyPageWithDom(), COPageTestBase\insertParagraphAt(), and COPageTestBase\setPCIdCnt().

35  : void
36  {
37  $compare = new PageCompare();
38 
39  $l_page = $this->getEmptyPageWithDom();
40  $this->insertParagraphAt($l_page, "pg");
41  $l_page->insertPCIds();
42 
43  $this->setPCIdCnt(1); // reset PCID counter to get same PCID
44 
45  $r_page = $this->getEmptyPageWithDom();
46  $this->insertParagraphAt($r_page, "pg");
47  $r_page->insertPCIds();
48 
49  $res = $compare->compare($l_page, $l_page, $r_page);
50 
51  $this->assertEquals(
52  "",
53  $this->getElementChange("1", $res["l_changes"])
54  );
55 
56  $this->assertEquals(
57  "",
58  $this->getElementChange("1", $res["r_changes"])
59  );
60  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
$res
Definition: ltiservices.php:66
setPCIdCnt(int $cnt)
+ Here is the call graph for this function:

◆ testCompareNewDeleted()

PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest::testCompareNewDeleted ( )

Definition at line 62 of file PageCompareTest.php.

References $res, PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest\getElementChange(), COPageTestBase\getEmptyPageWithDom(), and COPageTestBase\insertParagraphAt().

62  : void
63  {
64  $compare = new PageCompare();
65 
66  $l_page = $this->getEmptyPageWithDom();
67  $this->insertParagraphAt($l_page, "pg");
68  $l_page->insertPCIds();
69 
70  // Note, since we do not reset the PCID counter
71  // the second will get a pc id of 2
72 
73  $r_page = $this->getEmptyPageWithDom();
74  $this->insertParagraphAt($r_page, "pg");
75  $r_page->insertPCIds();
76 
77  $res = $compare->compare($l_page, $l_page, $r_page);
78 
79  $this->assertEquals(
80  "Deleted",
81  $this->getElementChange("1", $res["l_changes"])
82  );
83 
84  $this->assertEquals(
85  "New",
86  $this->getElementChange("2", $res["r_changes"])
87  );
88  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

◆ testCompareTextChanges()

PHPUnit\Framework\Attributes\Test\Compare\PageCompareTest::testCompareTextChanges ( )

Definition at line 117 of file PageCompareTest.php.

References $res, COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), COPageTestBase\insertParagraphAt(), and COPageTestBase\setPCIdCnt().

117  : void
118  {
119  $compare = new PageCompare();
120 
121  $l_page = $this->getEmptyPageWithDom();
122  $this->insertParagraphAt($l_page, "pg", "Hello World!");
123  $l_page->insertPCIds();
124 
125  $this->setPCIdCnt(1); // reset PCID counter to get same PCID
126 
127  $r_page = $this->getEmptyPageWithDom();
128  $this->insertParagraphAt($r_page, "pg", "Hello little World!");
129  $r_page->insertPCIds();
130 
131  $res = $compare->compare($l_page, $l_page, $r_page);
132 
133  $expected = <<<EOT
134 <PageObject HierId="pg"><PageContent HierId="1" PCID="00000000000000000000000000000001">Hello [ilDiffInsStart]little [ilDiffInsEnd]World!</PageContent><DivClass HierId="1" Class="ilEditModified"/></PageObject>
135 EOT;
136 
137  $this->assertXmlEquals(
138  $expected,
139  $r_page->getXMLFromDom()
140  );
141  }
insertParagraphAt(\ilPageObject $page, string $hier_id, string $text="")
$res
Definition: ltiservices.php:66
setPCIdCnt(int $cnt)
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
+ Here is the call graph for this function:

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