| @@ 115-147 (lines=33) @@ | ||
| 112 | ); |
|
| 113 | } |
|
| 114 | ||
| 115 | public function testBacklinks() { |
|
| 116 | $request = new TestRequest(); |
|
| 117 | $response = $request->get(array('id'=>'backlinks_syntax'), '/doku.php'); |
|
| 118 | ||
| 119 | $this->assertTrue( |
|
| 120 | strpos($response->getContent(), 'Backlinks to what Bob Ross says') !== false, |
|
| 121 | '"Backlinks to what Bob Ross says" was not in the output' |
|
| 122 | ); |
|
| 123 | ||
| 124 | $doc = phpQuery::newDocument($response->getContent()); |
|
| 125 | // look for id="plugin__backlinks" |
|
| 126 | $this->assertEquals( |
|
| 127 | 1, |
|
| 128 | pq('#plugin__backlinks', $doc)->length, |
|
| 129 | 'There should be one backlinks element' |
|
| 130 | ); |
|
| 131 | ||
| 132 | $wikilinks = pq('#plugin__backlinks ul li', $doc); |
|
| 133 | dbglog($wikilinks->text(), 'found backlinks'); |
|
| 134 | $this->assertEquals( |
|
| 135 | 4, |
|
| 136 | $wikilinks->contents()->length, |
|
| 137 | 'There should be 4 backlinks' |
|
| 138 | ); |
|
| 139 | ||
| 140 | $lastlink = pq('a:last',$wikilinks); |
|
| 141 | dbglog($lastlink->text(),"last backlink"); |
|
| 142 | $this->assertEquals( |
|
| 143 | $lastlink->text(), |
|
| 144 | 'A link to Bob Ross', |
|
| 145 | 'The last backlink should be a link to Bob Ross' |
|
| 146 | ); |
|
| 147 | } |
|
| 148 | } |
|
| 149 | ||
| @@ 76-108 (lines=33) @@ | ||
| 73 | } |
|
| 74 | } |
|
| 75 | ||
| 76 | public function testInclude() { |
|
| 77 | $request = new TestRequest(); |
|
| 78 | $response = $request->get(array('id'=>'backlinks_include_syntax'), '/doku.php'); |
|
| 79 | ||
| 80 | $this->assertTrue( |
|
| 81 | strpos($response->getContent(), 'Backlinks to what Bob Ross says (including only)') !== false, |
|
| 82 | '"Backlinks to what Bob Ross says (including only)" was not in the output' |
|
| 83 | ); |
|
| 84 | ||
| 85 | $doc = phpQuery::newDocument($response->getContent()); |
|
| 86 | // look for id="plugin__backlinks" |
|
| 87 | $this->assertEquals( |
|
| 88 | 1, |
|
| 89 | pq('#plugin__backlinks', $doc)->length, |
|
| 90 | 'There should be one backlinks element' |
|
| 91 | ); |
|
| 92 | ||
| 93 | $wikilinks = pq('#plugin__backlinks ul li', $doc); |
|
| 94 | dbglog($wikilinks->text(), 'found backlinks'); |
|
| 95 | $this->assertEquals( |
|
| 96 | 1, |
|
| 97 | $wikilinks->contents()->length, |
|
| 98 | 'There should be 1 backlink' |
|
| 99 | ); |
|
| 100 | ||
| 101 | $lastlink = pq('a:last',$wikilinks); |
|
| 102 | dbglog($lastlink->text(),"last backlink"); |
|
| 103 | $this->assertEquals( |
|
| 104 | $lastlink->text(), |
|
| 105 | 'An included link to Bob Ross', |
|
| 106 | 'The last backlink should be "An included link to Bob Ross"' |
|
| 107 | ); |
|
| 108 | } |
|
| 109 | } |
|
| 110 | ||