|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Provides test methods to ensure pages contain what we want them to in various ways. |
|
5
|
|
|
*/ |
|
6
|
|
|
class AlertsPageTest extends FetchPageTestCase { |
|
7
|
|
|
/** |
|
8
|
|
|
* Loads the member testing fixture. |
|
9
|
|
|
*/ |
|
10
|
|
|
public function getDataSet() { |
|
11
|
|
|
return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/alertspage.xml'); |
|
|
|
|
|
|
12
|
|
|
} |
|
13
|
|
|
|
|
14
|
|
|
private function fetch_page($vars) { |
|
15
|
|
|
return $this->base_fetch_page($vars, 'alert'); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
private function get_page($vars = []) { |
|
19
|
|
|
return $this->base_fetch_page_user($vars, '1.fbb689a0c092f5534b929d302db2c8a9', 'alert'); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function testFetchPage() { |
|
23
|
|
|
$page = $this->fetch_page([]); |
|
24
|
|
|
$this->assertStringContainsString('TheyWorkForYou Email Alerts', $page); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testKeywordOnly() { |
|
28
|
|
|
$page = $this->fetch_page([ 'alertsearch' => 'elephant']); |
|
29
|
|
|
$this->assertStringContainsString('What word or phrase would you like to recieve alerts about', $page); |
|
30
|
|
|
$this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value="elephant"', $page); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function testSpeakerId() { |
|
34
|
|
|
$page = $this->fetch_page([ 'alertsearch' => 'speaker:2']); |
|
35
|
|
|
$this->assertStringContainsString('Mrs Test Current-MP', $page); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testPostCodeOnly() { |
|
39
|
|
|
$page = $this->fetch_page([ 'alertsearch' => 'SE17 3HE']); |
|
40
|
|
|
$this->assertStringContainsString('Mrs Test Current-MP', $page); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testPostCodeWithKeyWord() { |
|
44
|
|
|
$page = $this->fetch_page([ 'alertsearch' => 'SE17 3HE elephant']); |
|
45
|
|
|
$this->assertStringContainsString('You have used a postcode and something else', $page); |
|
46
|
|
|
$this->assertStringContainsString('Mentions of [elephant] by your MP, Mrs Test Current-MP', $page); |
|
47
|
|
|
$this->assertStringNotContainsString('by your MSP', $page); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function testScottishPostcodeWithKeyword() { |
|
51
|
|
|
$page = $this->fetch_page([ 'alertsearch' => 'PH6 2DB elephant']); |
|
52
|
|
|
$this->assertStringContainsString('You have used a postcode and something else', $page); |
|
53
|
|
|
$this->assertStringContainsString('Mentions of [elephant] by your MP, Mr Test2 Current-MP', $page); |
|
54
|
|
|
$this->assertStringContainsString('Mentions of [elephant] by your MSP, Mrs Test Current-MSP', $page); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function testPostcodeAndKeywordWithNoSittingMP() { |
|
58
|
|
|
$page = $this->fetch_page([ 'alertsearch' => 'OX1 4LF elephant']); |
|
59
|
|
|
$this->assertStringContainsString('You have used a postcode and something else', $page); |
|
60
|
|
|
$this->assertStringNotContainsString('Did you mean to get alerts for when your MP', $page); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function testBasicKeyWordAlertsCreation() { |
|
64
|
|
|
$page = $this->fetch_page([ 'step' => 'define']); |
|
65
|
|
|
$this->assertStringContainsString('What word or phrase would you like to recieve alerts about', $page); |
|
66
|
|
|
$this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); |
|
67
|
|
|
|
|
68
|
|
|
$page = $this->fetch_page([ 'step' => 'review', 'email' => '[email protected]', 'words[]' => 'fish']); |
|
69
|
|
|
$this->assertStringContainsString('Review Your Alert', $page); |
|
70
|
|
|
$this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); |
|
71
|
|
|
|
|
72
|
|
|
$page = $this->fetch_page([ 'step' => 'confirm', 'email' => '[email protected]', 'words[]' => 'fish']); |
|
73
|
|
|
$this->assertStringContainsString('We’re nearly done', $page); |
|
74
|
|
|
$this->assertStringContainsString('You should receive an email shortly', $page); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function testMultipleKeyWordAlertsCreation() { |
|
78
|
|
|
$page = $this->fetch_page([ 'step' => 'define']); |
|
79
|
|
|
$this->assertStringContainsString('What word or phrase would you like to recieve alerts about', $page); |
|
80
|
|
|
$this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); |
|
81
|
|
|
|
|
82
|
|
|
$page = $this->fetch_page([ 'step' => 'review', 'email' => '[email protected]', 'words[]' => ['fish', 'salmon']]); |
|
83
|
|
|
$this->assertStringContainsString('Review Your Alert', $page); |
|
84
|
|
|
$this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); |
|
85
|
|
|
$this->assertStringContainsString('<input type="hidden" name="words[]" value="salmon"', $page); |
|
86
|
|
|
|
|
87
|
|
|
$page = $this->fetch_page([ 'step' => 'confirm', 'email' => '[email protected]', 'words[]' => ['fish', 'salmon']]); |
|
88
|
|
|
$this->assertStringContainsString('You should receive an email shortly', $page); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function testMultipleKeyWordAlertsCreationLoggedIn() { |
|
92
|
|
|
$page = $this->get_page(['step' => 'define']); |
|
93
|
|
|
$this->assertStringContainsString('What word or phrase would you like to recieve alerts about', $page); |
|
94
|
|
|
$this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); |
|
95
|
|
|
|
|
96
|
|
|
$page = $this->get_page([ 'step' => 'review', 'words[]' => ['fish', 'salmon']]); |
|
97
|
|
|
$this->assertStringContainsString('Review Your Alert', $page); |
|
98
|
|
|
$this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); |
|
99
|
|
|
$this->assertStringContainsString('<input type="hidden" name="words[]" value="salmon"', $page); |
|
100
|
|
|
|
|
101
|
|
|
$page = $this->get_page([ 'step' => 'confirm', 'words[]' => ['fish', 'salmon']]); |
|
102
|
|
|
$this->assertStringContainsString('You will now receive email alerts on any day when [fish salmon] is mentioned in parliament', $page); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
public function testKeyWordAndSectionAlertsCreationLoggedIn() { |
|
106
|
|
|
$page = $this->get_page(['step' => 'define']); |
|
107
|
|
|
$this->assertStringContainsString('What word or phrase would you like to recieve alerts about', $page); |
|
108
|
|
|
$this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); |
|
109
|
|
|
|
|
110
|
|
|
$page = $this->get_page(['step' => 'review', 'words[]' => 'fish', 'search_section' => 'debates']); |
|
111
|
|
|
$this->assertStringContainsString('Review Your Alert', $page); |
|
112
|
|
|
$this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); |
|
113
|
|
|
|
|
114
|
|
|
$page = $this->get_page(['step' => 'confirm', 'words[]' => 'fish', 'search_section' => 'debates']); |
|
115
|
|
|
$this->assertStringContainsString('You will now receive email alerts on any day when [fish] is mentioned in House of Commons debates', $page); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
public function testKeyWordAndSpeakerAlertsCreationLoggedIn() { |
|
119
|
|
|
$page = $this->get_page(['step' => 'define']); |
|
120
|
|
|
$this->assertStringContainsString('What word or phrase would you like to recieve alerts about', $page); |
|
121
|
|
|
$this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); |
|
122
|
|
|
|
|
123
|
|
|
$page = $this->get_page(['step' => 'review', 'words[]' => 'fish', 'representative' => 'Mrs Test Current-MP']); |
|
124
|
|
|
$this->assertStringContainsString('Review Your Alert', $page); |
|
125
|
|
|
$this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); |
|
126
|
|
|
$this->assertStringContainsString('<input type="hidden" name="representative" value="Mrs Test Current-MP"', $page); |
|
127
|
|
|
|
|
128
|
|
|
$page = $this->get_page([ 'step' => 'confirm', 'words[]' => 'fish', 'representative' => 'Mrs Test Current-MP']); |
|
129
|
|
|
$this->assertStringContainsString('You will now receive email alerts on any day when Mrs Test Current-MP mentions [fish] in parliament', $page); |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|
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.