ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SubjectTest.php
Go to the documentation of this file.
1 <?php
3 
6 
10 class SubjectTest extends TestCase
11 {
12  protected $nestingLimit = 15;
13 
21  public function oneLevelCountsUseIsCorrect()
22  {
23  $first = new \DOMElement('first');
24  $firstSubject = new Subject($first, $this->nestingLimit);
25  self::assertSame(0, $firstSubject->countUse(false));
26  self::assertSame(0, $firstSubject->countUse(true));
27  }
28 
37  public function twoLevelsCountUseIsCorrect()
38  {
39  $first = new \DOMElement('first');
40  $second = new \DOMElement('second');
41  $firstSubject = new Subject($first, $this->nestingLimit);
42  $secondSubject = new Subject($second, $this->nestingLimit);
43  $firstSubject->addUse($secondSubject);
44  $firstSubject->addUse($secondSubject);
45  self::assertSame(2, $firstSubject->countUse(false));
46  self::assertSame(2, $firstSubject->countUse(true));
47  }
48 
65  public function threeLevelsCountUseIsCorrect()
66  {
67  $first = new \DOMElement('first');
68  $second = new \DOMElement('second');
69  $third = new \DOMElement('third');
70  $firstSubject = new Subject($first, $this->nestingLimit);
71  $secondSubject = new Subject($second, $this->nestingLimit);
72  $thirdSubject = new Subject($third, $this->nestingLimit);
73  $firstSubject->addUse($secondSubject);
74  $firstSubject->addUse($secondSubject);
75  $secondSubject->addUse($thirdSubject);
76  $secondSubject->addUse($thirdSubject);
77  $secondSubject->addUse($thirdSubject);
78  self::assertSame(6, $firstSubject->countUse(false));
79  self::assertSame(8, $firstSubject->countUse(true));
80  }
81 
89  {
90  $first = new \DOMElement('first');
91  $firstSubject = new Subject($first, $this->nestingLimit);
92  self::assertSame(0, $firstSubject->countUsedIn());
93  }
94 
104  {
105  $first = new \DOMElement('first');
106  $second = new \DOMElement('second');
107  $firstSubject = new Subject($first, $this->nestingLimit);
108  $secondSubject = new Subject($second, $this->nestingLimit);
109  $secondSubject->addUsedIn($firstSubject);
110  $secondSubject->addUsedIn($firstSubject);
111  self::assertSame(2, $secondSubject->countUsedIn());
112  }
113 
131  {
132  $first = new \DOMElement('first');
133  $second = new \DOMElement('second');
134  $third = new \DOMElement('third');
135  $firstSubject = new Subject($first, $this->nestingLimit);
136  $secondSubject = new Subject($second, $this->nestingLimit);
137  $thirdSubject = new Subject($third, $this->nestingLimit);
138  $thirdSubject->addUsedIn($secondSubject);
139  $thirdSubject->addUsedIn($secondSubject);
140  $thirdSubject->addUsedIn($secondSubject);
141  $secondSubject->addUsedIn($firstSubject);
142  $secondSubject->addUsedIn($firstSubject);
143  self::assertSame(6, $thirdSubject->countUsedIn());
144  }
145 }
threeLevelsCountUsedInIsCorrect()
<first> <second> <third> <third> <third> </second> <second> <third> <third> <third> </second> </first...
oneLevelCountsUseIsCorrect()
<first></first>
Definition: SubjectTest.php:21
threeLevelsCountUseIsCorrect()
<first> <second> <third> <third> <third> </second> <second> <third> <third> <third> </second> </first...
Definition: SubjectTest.php:65
oneLevelCountsUsedInIsCorrect()
<first> </first>
Definition: SubjectTest.php:88
twoLevelsCountUsedInIsCorrect()
<first> <second> <second> </first>
twoLevelsCountUseIsCorrect()
<first> <second> <second> </first>
Definition: SubjectTest.php:37