| Conditions | 3 |
| Paths | 4 |
| Total Lines | 29 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 7 | public function testSiteMap() |
||
| 8 | { |
||
| 9 | $this->logInWithPermission('ADMIN'); |
||
| 10 | // pages need published, fixtures are not |
||
| 11 | foreach (Page::get() as $page) { |
||
| 12 | $page->doPublish(); |
||
| 13 | error_log($page->ClassName . ':' . $page->Link()); |
||
| 14 | } |
||
| 15 | $response = $this->get('/sitemap/'); |
||
| 16 | $this->assertEquals(200, $response->getStatusCode()); |
||
| 17 | $positions = array(); |
||
| 18 | $body = $response->getBody(); |
||
| 19 | |||
| 20 | // assert is a sitemap |
||
| 21 | $this->assertContains('<ul class="sitemap-list">', $body); |
||
| 22 | |||
| 23 | // assert root level pages |
||
| 24 | for ($i=1; $i <= 4; $i++) { |
||
| 25 | $row = '<li><a href="page-' . $i . '" title="Go to the Page ' . $i . ' page">Page ' . $i . '</a>'; |
||
| 26 | $this->assertContains($row, $body); |
||
| 27 | |||
| 28 | $positions["{$i}"] = strpos($body, $row); |
||
| 29 | } |
||
| 30 | |||
| 31 | //assert order |
||
| 32 | $this->assertGreaterThan($positions['3'], $positions['4']); |
||
| 33 | $this->assertGreaterThan($positions['2'], $positions['3']); |
||
| 34 | $this->assertGreaterThan($positions['1'], $positions['2']); |
||
| 35 | } |
||
| 36 | } |
||
| 37 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.