Issues (404)

tests/PostcodeTest.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * Testing for postcode Utility functions
5
 */
6
7
class PostcodeTest extends TWFY_Database_TestCase {
8
    /**
9
     * Loads the member testing fixture.
10
     */
11
    public function getDataSet() {
12
        return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/postcode.xml');
0 ignored issues
show
Are you sure the usage of $this->createMySQLXMLDat...fixtures/postcode.xml') targeting TWFY_Database_TestCase::createMySQLXMLDataSet() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
13
    }
14
15
    /**
16
     * Test converting a postcode to a constituency
17
     */
18
    public function testPostcodeToConstituency() {
19
        $this->assertEquals(
20
            'Cities of London and Westminster',
21
            MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituency('SW1A 1AA')
22
        );
23
    }
24
25
    /**
26
     * Test converting a broken postcode to a constituency, make sure we get an empty string
27
     */
28
    public function testBrokenPostcodeToConstituency() {
29
        $this->assertEquals(
30
            '',
31
            MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituency('ZZ00 ABC')
32
        );
33
    }
34
35
    /**
36
     * Test canonicalising a postcode
37
     */
38
    public function testCanonicalisePostcode() {
39
        $this->assertEquals(
40
            'SW1A 1AA',
41
            MySociety\TheyWorkForYou\Utility\Postcode::canonicalisePostcode('SW1A 1AA')
42
        );
43
        $this->assertEquals(
44
            'SW1A 1AA',
45
            MySociety\TheyWorkForYou\Utility\Postcode::canonicalisePostcode('SW1A1AA')
46
        );
47
        $this->assertEquals(
48
            'SW1A 1AA',
49
            MySociety\TheyWorkForYou\Utility\Postcode::canonicalisePostcode('sw1a 1aa')
50
        );
51
        $this->assertEquals(
52
            'SW1A 1AA',
53
            MySociety\TheyWorkForYou\Utility\Postcode::canonicalisePostcode(' SW1A 1AA ')
54
        );
55
        $this->assertEquals(
56
            'SW1A 1AA',
57
            MySociety\TheyWorkForYou\Utility\Postcode::canonicalisePostcode('SW1 A1AA')
58
        );
59
    }
60
61
    /**
62
     * Test testing for Scottish postcode
63
     */
64
    public function testPostcodeIsScottish() {
65
        $this->assertEquals(
66
            "Edinburgh",
67
            MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituency('EH1 0AA')
68
        );
69
    }
70
71
    /**
72
     * Test testing for NI postcode
73
     */
74
    public function testPostcodeIsNi() {
75
        $this->assertEquals(
76
            "Belfast",
77
            MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituency('BT1 0AA')
78
        );
79
    }
80
81
}
82