1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Provides test methods to ensure pages contain what we want them to in various ways. |
||
5 | */ |
||
6 | class PageTest extends FetchPageTestCase { |
||
7 | /** |
||
8 | * Loads the member testing fixture. |
||
9 | */ |
||
10 | public function getDataSet() { |
||
11 | return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/member.xml'); |
||
0 ignored issues
–
show
|
|||
12 | } |
||
13 | |||
14 | private function fetch_page($vars) { |
||
15 | return $this->base_fetch_page($vars, 'mp'); |
||
16 | } |
||
17 | |||
18 | public function testQueenie() { |
||
19 | $page = $this->fetch_page([ 'representative_type' => 'royal', 'n' => 'elizabeth_the_second' ]); |
||
20 | $this->assertStringContainsString('Elizabeth the Second', $page); |
||
21 | $this->assertStringContainsString('Coronated on 2 June 1953', $page); |
||
22 | } |
||
23 | |||
24 | public function testSittingMP() { |
||
25 | $page = $this->fetch_page([ 'pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency' ]); |
||
26 | $this->assertStringContainsString('Test Current-MP', $page); |
||
27 | $this->assertMatchesRegularExpression('#<span class="person-header__about__position__constituency">\s*Test Westminster Constituency\s*</span>#', $page); |
||
28 | $this->assertMatchesRegularExpression('#<span class="person-header__about__position__role">\s*Labour\s*MP\s*</span>#', $page); |
||
29 | } |
||
30 | |||
31 | public function testSittingMLA() { |
||
32 | $page = $this->fetch_page([ 'pid' => 4, 'representative_type' => 'mla', 'url' => '/mp/4/test_current-mla' ]); |
||
33 | $this->assertStringContainsString('Test Current-MLA', $page); |
||
34 | $this->assertMatchesRegularExpression('#<span class="person-header__about__position__constituency">\s*Test Northern Ireland Constituency\s*</span>#', $page); |
||
35 | $this->assertMatchesRegularExpression('#<span class="person-header__about__position__role">\s*Sinn Féin\s*MLA\s*</span>#', $page); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Ensure that the Sinn Fein message is displayed for SF MPs. |
||
40 | */ |
||
41 | public function testSittingSinnFeinMP() { |
||
42 | $page = $this->fetch_page([ 'pid' => 15, 'url' => '/mp/15/test_current-sf-mp/test_westminster_constituency' ]); |
||
43 | $this->assertStringContainsString('Sinn Féin MPs do not take their seats in Parliament.', $page); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Ensure that the Sinn Fein message is not displayed for non-SF MPs. |
||
48 | */ |
||
49 | public function testSittingNonSinnFeinMP() { |
||
50 | $page = $this->fetch_page([ 'pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency' ]); |
||
51 | $this->assertStringNotContainsString('Sinn Féin MPs do not take their seats in Parliament.', $page); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Ensure that the Speaker is given the correct constituency. |
||
56 | */ |
||
57 | public function testSpeaker() { |
||
58 | $page = $this->fetch_page([ 'pid' => 13, 'url' => '/mp/13/test_speaker/buckingham' ]); |
||
59 | $this->assertMatchesRegularExpression('#<span class="person-header__about__position__role">\s*Speaker\s*MP\s*</span>#', $page); |
||
60 | } |
||
61 | |||
62 | public function testBanner() { |
||
63 | $banner = new MySociety\TheyWorkForYou\Model\AnnouncementManagement(); |
||
64 | |||
65 | # makes sure it is empty in case there's something hanging |
||
66 | # about in memcached |
||
67 | $banner->set_text('', "banner"); |
||
68 | $page = $this->fetch_page([ 'url' => '/' ]); |
||
69 | $this->assertStringNotContainsString('<div class="banner">', $page); |
||
70 | $this->assertStringNotContainsString('This is a banner', $page); |
||
71 | |||
72 | $banner_config = ' |
||
73 | [ |
||
74 | { |
||
75 | "id":"basic-donate", |
||
76 | "content":"This is a banner", |
||
77 | "button_text":"Donate", |
||
78 | "button_link":"https://www.mysociety.org/donate/", |
||
79 | "button_class": "button--negative", |
||
80 | "weight":1, |
||
81 | "lang": "en", |
||
82 | "published":true |
||
83 | } |
||
84 | ] |
||
85 | '; |
||
86 | |||
87 | $banner->set_text($banner_config, "banner"); |
||
88 | $page = $this->fetch_page([ 'url' => '/' ]); |
||
89 | $this->assertStringContainsString('This is a banner', $page); |
||
90 | |||
91 | $banner->set_text('', "banner"); |
||
92 | $page = $this->fetch_page([ 'url' => '/' ]); |
||
93 | $this->assertStringNotContainsString('<div class="banner">', $page); |
||
94 | $this->assertStringNotContainsString('This is a banner', $page); |
||
95 | } |
||
96 | |||
97 | public function testNewMPMessage() { |
||
98 | $page = $this->fetch_page([ 'pid' => 17, 'url' => '/mp/17/recent_mp/test_westminster_constituency' ]); |
||
99 | $this->assertStringNotContainsString('is a recently elected MP', $page); |
||
100 | self::$db->query('UPDATE member SET entered_house = NOW() WHERE person_id = 17'); |
||
101 | $page = $this->fetch_page([ 'pid' => 17, 'url' => '/mp/17/recent_mp/test_westminster_constituency' ]); |
||
102 | $this->assertStringContainsString('is a recently elected MP', $page); |
||
103 | } |
||
104 | |||
105 | } |
||
106 |
This check looks for function or method calls that always return null and whose return value is used.
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.