Completed
Push — 3.1 ( 6c19c5...97d1e4 )
by Gordon
04:55
created

NearestPOIPage_ControllerTest::testFind()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 51
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 42
CRAP Score 2
Metric Value
dl 0
loc 51
ccs 42
cts 42
cp 1
rs 9.411
cc 2
eloc 40
nc 2
nop 0
crap 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
class NearestPOIPage_ControllerTest extends FunctionalTest
0 ignored issues
show
Coding Style introduced by
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
4
{
5
    protected static $fixture_file = 'mappable-poi/tests/pointsofinterest.yml';
6
7 1
    public function testFind()
8
    {
9
        // page needs to be live
10 1
        $nearPage = $this->objFromFixture('NearestPOIPage', 'StationFinder');
11 1
        $this->logInWithPermission('ADMIN');
12 1
        $nearPage->doPublish();
13 1
        if (Member::currentUser()) {
14 1
            Member::currentUser()->logOut();
15 1
        }
16 1
        $link = $nearPage->Link();
17 1
        error_log('POI PAGE LINK:'.$link);
18
19 1
        $url = $link;
20 1
        error_log('TRYING URL '.$url);
21 1
        $response = $this->get($url);
22 1
        $this->assertEquals(200, $response->getStatusCode());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<NearestPOIPage_ControllerTest>.

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...
23
24
        // location is MBK
25 1
        $url = $link.'find?lat=13.7444513&lng=100.5290196';
26 1
        $response = $this->get($url);
27 1
        $this->assertEquals(200, $response->getStatusCode());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<NearestPOIPage_ControllerTest>.

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...
28
        $expected = array(
29 1
            'Ratchathewi',
30 1
            'Phaya Thai',
31 1
            'Chit Lom',
32 1
            'Victory Monument',
33 1
            'Nana',
34 1
            'Sanam Pao',
35 1
            'Ari',
36 1
            'Saphan Khwai',
37 1
            'Mo Chit',
38 1
        );
39 1
        $this->assertExactMatchBySelector('table#nearestPOIs td.name', $expected);
40
41
        // location is victory monument
42 1
        $url = $link.'find?lat=13.7650776&lng=100.5369724';
43 1
        $response = $this->get($url);
44 1
        $this->assertEquals(200, $response->getStatusCode());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<NearestPOIPage_ControllerTest>.

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...
45
        $expected = array(
46 1
            'Victory Monument',
47 1
            'Phaya Thai',
48 1
            'Sanam Pao',
49 1
            'Ratchathewi',
50 1
            'Ari',
51 1
            'Chit Lom',
52 1
            'Nana',
53 1
            'Saphan Khwai',
54 1
            'Mo Chit',
55 1
        );
56 1
        $this->assertExactMatchBySelector('table#nearestPOIs td.name', $expected);
57 1
    }
58
}
59