Completed
Push — master ( 9b2b5e...32f380 )
by Gordon
06:13
created

SiteMapTest::testSiteMap()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 29
Code Lines 17

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 29
rs 8.8571
cc 3
eloc 17
nc 4
nop 0
1
<?php
2
3
class SiteMapTest extends FunctionalTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    protected static $fixture_file = 'SiteMapTest.yml';
6
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());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SiteMapTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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']);
0 ignored issues
show
Bug introduced by
The method assertGreaterThan() does not seem to exist on object<SiteMapTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
        $this->assertGreaterThan($positions['2'], $positions['3']);
0 ignored issues
show
Bug introduced by
The method assertGreaterThan() does not seem to exist on object<SiteMapTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
        $this->assertGreaterThan($positions['1'], $positions['2']);
0 ignored issues
show
Bug introduced by
The method assertGreaterThan() does not seem to exist on object<SiteMapTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
    }
36
}
37