@@ -22,26 +22,26 @@ discard block |
||
22 | 22 | $toemail = ''; |
23 | 23 | $template = 'alert_new_mp'; |
24 | 24 | for ($k=1; $k<$argc; $k++) { |
25 | - if ($argv[$k] == '--nomail') |
|
26 | - $nomail = true; |
|
27 | - if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) |
|
28 | - $onlyemail = $m[1]; |
|
29 | - if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) |
|
30 | - $fromemail = $m[1]; |
|
31 | - if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) |
|
32 | - $toemail = $m[1]; |
|
25 | + if ($argv[$k] == '--nomail') |
|
26 | + $nomail = true; |
|
27 | + if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) |
|
28 | + $onlyemail = $m[1]; |
|
29 | + if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) |
|
30 | + $fromemail = $m[1]; |
|
31 | + if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) |
|
32 | + $toemail = $m[1]; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | if (DEVSITE) |
36 | - $nomail = true; |
|
36 | + $nomail = true; |
|
37 | 37 | |
38 | 38 | # Change this to the end date |
39 | 39 | $END_DATE = '2017-05-03'; |
40 | 40 | |
41 | 41 | if ($nomail) mlog("NOT SENDING EMAIL\n"); |
42 | 42 | if (($fromemail && $onlyemail) || ($toemail && $onlyemail)) { |
43 | - mlog("Can't have both from/to and only!\n"); |
|
44 | - exit; |
|
43 | + mlog("Can't have both from/to and only!\n"); |
|
44 | + exit; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $active = 0; |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | $members = array(); |
67 | 67 | $start_time = time(); |
68 | 68 | foreach ($alertdata as $alertitem) { |
69 | - $active++; |
|
70 | - $email = $alertitem['email']; |
|
69 | + $active++; |
|
70 | + $email = $alertitem['email']; |
|
71 | 71 | if ($onlyemail && $email != $onlyemail) continue; |
72 | 72 | if ($fromemail && strtolower($email) == $fromemail) $fromflag = true; |
73 | 73 | if ($fromemail && !$fromflag) continue; |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | |
144 | 144 | $sss = "Active alerts: $active\nEmail lookups: $registered registered, $unregistered unregistered\nQuery lookups: $queries\nSent emails: $sentemails\n"; |
145 | 145 | if ($globalsuccess) { |
146 | - $sss .= 'Everything went swimmingly, in '; |
|
146 | + $sss .= 'Everything went swimmingly, in '; |
|
147 | 147 | } else { |
148 | - $sss .= 'Something went wrong! Total time: '; |
|
148 | + $sss .= 'Something went wrong! Total time: '; |
|
149 | 149 | } |
150 | 150 | $sss .= (getmicrotime()-$global_start)."\n\n"; |
151 | 151 | mlog($sss); |
@@ -155,7 +155,7 @@ |
||
155 | 155 | global $globalsuccess, $sentemails, $nomail, $start_time; |
156 | 156 | |
157 | 157 | $sentemails++; |
158 | - mlog("SEND $sentemails : Sending email to $current[email] ... "); |
|
158 | + mlog("send $sentemails : Sending email to $current[email] ... "); |
|
159 | 159 | $d = array('to' => $current['email'], 'template' => $template); |
160 | 160 | $m = array( |
161 | 161 | 'DATA' => join("\n", $data), |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $fromflag = false; |
22 | 22 | $toemail = ''; |
23 | 23 | $template = 'alert_new_mp'; |
24 | -for ($k=1; $k<$argc; $k++) { |
|
24 | +for ($k = 1; $k < $argc; $k++) { |
|
25 | 25 | if ($argv[$k] == '--nomail') |
26 | 26 | $nomail = true; |
27 | 27 | if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | // skip if they didn't lose their westminster seat in the most recent election |
92 | 92 | if ($member->left_house(1)['date'] != $END_DATE) continue; |
93 | 93 | |
94 | - if ( !isset($cons[$member->constituency]) ) { |
|
94 | + if (!isset($cons[$member->constituency])) { |
|
95 | 95 | $cons_member = new MEMBER(array('constituency' => $member->constituency, 'house' => 1)); |
96 | - if ( !$cons_member ) { |
|
96 | + if (!$cons_member) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | $cons[$member->constituency] = $cons_member; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | // these should never happen but let's just be sure |
105 | - if ( $cons_member->person_id == $member->person_id ) continue; |
|
105 | + if ($cons_member->person_id == $member->person_id) continue; |
|
106 | 106 | if (!$cons_member->current_member_anywhere()) continue; |
107 | 107 | |
108 | 108 | if ($email != $current['email']) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $user_id = 0; |
123 | 123 | $unregistered++; |
124 | 124 | } |
125 | - mlog("\nEMAIL: $email, uid $user_id; memory usage : ".memory_get_usage()."\n"); |
|
125 | + mlog("\nEMAIL: $email, uid $user_id; memory usage : " . memory_get_usage() . "\n"); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $lh = $member->left_house(); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } else { |
148 | 148 | $sss .= 'Something went wrong! Total time: '; |
149 | 149 | } |
150 | -$sss .= (getmicrotime()-$global_start)."\n\n"; |
|
150 | +$sss .= (getmicrotime() - $global_start) . "\n\n"; |
|
151 | 151 | mlog($sss); |
152 | 152 | mlog(date('r') . "\n"); |
153 | 153 | |
@@ -160,18 +160,18 @@ discard block |
||
160 | 160 | $m = array( |
161 | 161 | 'DATA' => join("\n", $data), |
162 | 162 | 'CHANGE' => join("\n", $change), |
163 | - 'ALERT_IS' => count($data)==1 ? 'alert is' : 'alerts are', |
|
164 | - 'MPS' => count($data)==1 ? 'This MP' : 'These MPs', |
|
165 | - 'MPS2' => count($data)==1 ? 'MP' : 'MPs', |
|
166 | - 'ALERTS' => count($data)==1 ? 'an alert' : 'some alerts', |
|
167 | - 'ALERTS2' => count($data)==1 ? 'alert' : 'alerts', |
|
168 | - 'LINKS' => count($data)==1 ? 'link' : 'links', |
|
163 | + 'ALERT_IS' => count($data) == 1 ? 'alert is' : 'alerts are', |
|
164 | + 'MPS' => count($data) == 1 ? 'This MP' : 'These MPs', |
|
165 | + 'MPS2' => count($data) == 1 ? 'MP' : 'MPs', |
|
166 | + 'ALERTS' => count($data) == 1 ? 'an alert' : 'some alerts', |
|
167 | + 'ALERTS2' => count($data) == 1 ? 'alert' : 'alerts', |
|
168 | + 'LINKS' => count($data) == 1 ? 'link' : 'links', |
|
169 | 169 | ); |
170 | 170 | if (!$nomail) { |
171 | 171 | $success = send_template_email($d, $m, true); |
172 | 172 | mlog("sent ... "); |
173 | 173 | # sleep if time between sending mails is less than a certain number of seconds on average |
174 | - if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than |
|
174 | + if (((time() - $start_time) / $sentemails) < 0.5) { # number of seconds per mail not to be quicker than |
|
175 | 175 | mlog("pausing ... "); |
176 | 176 | sleep(1); |
177 | 177 | } |
@@ -22,23 +22,30 @@ discard block |
||
22 | 22 | $toemail = ''; |
23 | 23 | $template = 'alert_new_mp'; |
24 | 24 | for ($k=1; $k<$argc; $k++) { |
25 | - if ($argv[$k] == '--nomail') |
|
26 | - $nomail = true; |
|
27 | - if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) |
|
28 | - $onlyemail = $m[1]; |
|
29 | - if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) |
|
30 | - $fromemail = $m[1]; |
|
31 | - if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) |
|
32 | - $toemail = $m[1]; |
|
33 | -} |
|
34 | - |
|
35 | -if (DEVSITE) |
|
25 | + if ($argv[$k] == '--nomail') { |
|
26 | + $nomail = true; |
|
27 | + } |
|
28 | + if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) { |
|
29 | + $onlyemail = $m[1]; |
|
30 | + } |
|
31 | + if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) { |
|
32 | + $fromemail = $m[1]; |
|
33 | + } |
|
34 | + if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) { |
|
35 | + $toemail = $m[1]; |
|
36 | + } |
|
37 | + } |
|
38 | + |
|
39 | +if (DEVSITE) { |
|
36 | 40 | $nomail = true; |
41 | +} |
|
37 | 42 | |
38 | 43 | # Change this to the end date |
39 | 44 | $END_DATE = '2017-05-03'; |
40 | 45 | |
41 | -if ($nomail) mlog("NOT SENDING EMAIL\n"); |
|
46 | +if ($nomail) { |
|
47 | + mlog("NOT SENDING EMAIL\n"); |
|
48 | +} |
|
42 | 49 | if (($fromemail && $onlyemail) || ($toemail && $onlyemail)) { |
43 | 50 | mlog("Can't have both from/to and only!\n"); |
44 | 51 | exit; |
@@ -68,14 +75,24 @@ discard block |
||
68 | 75 | foreach ($alertdata as $alertitem) { |
69 | 76 | $active++; |
70 | 77 | $email = $alertitem['email']; |
71 | - if ($onlyemail && $email != $onlyemail) continue; |
|
72 | - if ($fromemail && strtolower($email) == $fromemail) $fromflag = true; |
|
73 | - if ($fromemail && !$fromflag) continue; |
|
74 | - if ($toemail && strtolower($email) >= $toemail) continue; |
|
78 | + if ($onlyemail && $email != $onlyemail) { |
|
79 | + continue; |
|
80 | + } |
|
81 | + if ($fromemail && strtolower($email) == $fromemail) { |
|
82 | + $fromflag = true; |
|
83 | + } |
|
84 | + if ($fromemail && !$fromflag) { |
|
85 | + continue; |
|
86 | + } |
|
87 | + if ($toemail && strtolower($email) >= $toemail) { |
|
88 | + continue; |
|
89 | + } |
|
75 | 90 | $criteria_raw = $alertitem['criteria']; |
76 | 91 | |
77 | 92 | // we only care about alerts for people speaking |
78 | - if (!strstr($criteria_raw, 'speaker:')) continue; |
|
93 | + if (!strstr($criteria_raw, 'speaker:')) { |
|
94 | + continue; |
|
95 | + } |
|
79 | 96 | |
80 | 97 | preg_match('#speaker:(\d+)#', $criteria_raw, $m); |
81 | 98 | $person_id = $m[1]; |
@@ -86,10 +103,14 @@ discard block |
||
86 | 103 | $member = $members[$person_id]; |
87 | 104 | |
88 | 105 | // if they're still elected then don't send the email |
89 | - if ($member->current_member_anywhere()) continue; |
|
106 | + if ($member->current_member_anywhere()) { |
|
107 | + continue; |
|
108 | + } |
|
90 | 109 | |
91 | 110 | // skip if they didn't lose their westminster seat in the most recent election |
92 | - if ($member->left_house(1)['date'] != $END_DATE) continue; |
|
111 | + if ($member->left_house(1)['date'] != $END_DATE) { |
|
112 | + continue; |
|
113 | + } |
|
93 | 114 | |
94 | 115 | if ( !isset($cons[$member->constituency]) ) { |
95 | 116 | $cons_member = new MEMBER(array('constituency' => $member->constituency, 'house' => 1)); |
@@ -102,8 +123,12 @@ discard block |
||
102 | 123 | } |
103 | 124 | |
104 | 125 | // these should never happen but let's just be sure |
105 | - if ( $cons_member->person_id == $member->person_id ) continue; |
|
106 | - if (!$cons_member->current_member_anywhere()) continue; |
|
126 | + if ( $cons_member->person_id == $member->person_id ) { |
|
127 | + continue; |
|
128 | + } |
|
129 | + if (!$cons_member->current_member_anywhere()) { |
|
130 | + continue; |
|
131 | + } |
|
107 | 132 | |
108 | 133 | if ($email != $current['email']) { |
109 | 134 | if ($email_text && $change_text) { |
@@ -171,7 +196,8 @@ discard block |
||
171 | 196 | $success = send_template_email($d, $m, true); |
172 | 197 | mlog("sent ... "); |
173 | 198 | # sleep if time between sending mails is less than a certain number of seconds on average |
174 | - if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than |
|
199 | + if (((time() - $start_time) / $sentemails) < 0.5 ) { |
|
200 | +# number of seconds per mail not to be quicker than |
|
175 | 201 | mlog("pausing ... "); |
176 | 202 | sleep(1); |
177 | 203 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | # Done directly as storing everything in an array as $db->query() does runs out of memory, unsurprisingly |
12 | 12 | $q = mysql_query( |
13 | - 'select section.body, gid, yes_votes, no_votes |
|
13 | + 'select section.body, gid, yes_votes, no_votes |
|
14 | 14 | from hansard |
15 | 15 | inner join epobject as section on hansard.section_id = section.epobject_id |
16 | 16 | left join anonvotes on hansard.epobject_id = anonvotes.epobject_id |
@@ -24,34 +24,34 @@ discard block |
||
24 | 24 | |
25 | 25 | $votes = array(); |
26 | 26 | while ($row = mysql_fetch_assoc($q)) { |
27 | - $dept = $row['body']; |
|
28 | - if (!isset($votes[$dept])) $votes[$dept] = array( |
|
29 | - 'verymoreyes'=>0, 'moreyes'=>0, 'verymoreno'=>0, 'moreno'=>0, 'same'=>0, 'none'=>0 |
|
30 | - ); |
|
31 | - $yes = $row['yes_votes']; |
|
32 | - $no = $row['no_votes']; |
|
33 | - $gid = $row['gid']; |
|
34 | - if (is_null($yes)) { |
|
35 | - $votes[$dept]['none']++; |
|
36 | - } else { |
|
37 | - if ($no > $yes+10) { |
|
38 | - $votes[$dept]['verymoreno']++; |
|
39 | - } elseif ($no > $yes) { |
|
40 | - $votes[$dept]['moreno']++; |
|
41 | - } elseif ($no + 10 < $yes) { |
|
42 | - $votes[$dept]['verymoreyes']++; |
|
43 | - } elseif ($no < $yes) { |
|
44 | - $votes[$dept]['moreyes']++; |
|
45 | - } else { |
|
46 | - $votes[$dept]['same']++; |
|
47 | - } |
|
48 | - } |
|
27 | + $dept = $row['body']; |
|
28 | + if (!isset($votes[$dept])) $votes[$dept] = array( |
|
29 | + 'verymoreyes'=>0, 'moreyes'=>0, 'verymoreno'=>0, 'moreno'=>0, 'same'=>0, 'none'=>0 |
|
30 | + ); |
|
31 | + $yes = $row['yes_votes']; |
|
32 | + $no = $row['no_votes']; |
|
33 | + $gid = $row['gid']; |
|
34 | + if (is_null($yes)) { |
|
35 | + $votes[$dept]['none']++; |
|
36 | + } else { |
|
37 | + if ($no > $yes+10) { |
|
38 | + $votes[$dept]['verymoreno']++; |
|
39 | + } elseif ($no > $yes) { |
|
40 | + $votes[$dept]['moreno']++; |
|
41 | + } elseif ($no + 10 < $yes) { |
|
42 | + $votes[$dept]['verymoreyes']++; |
|
43 | + } elseif ($no < $yes) { |
|
44 | + $votes[$dept]['moreyes']++; |
|
45 | + } else { |
|
46 | + $votes[$dept]['same']++; |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | print "Department,11+ more yes votes than no,1-10 more yes votes than no,11+ more no votes than yes,1-10 more no votes than yes,Same votes yes/no,No votes\n"; |
52 | 52 | foreach ($votes as $dept => $v) { |
53 | - #if (!$v['moreyes'] && !$v['moreno'] && !$v['same']) continue; |
|
54 | - if (strstr($dept, ',')) |
|
55 | - $dept = "\"$dept\""; |
|
56 | - print "$dept,$v[verymoreyes],$v[moreyes],$v[verymoreno],$v[moreno],$v[same],$v[none]\n"; |
|
53 | + #if (!$v['moreyes'] && !$v['moreno'] && !$v['same']) continue; |
|
54 | + if (strstr($dept, ',')) |
|
55 | + $dept = "\"$dept\""; |
|
56 | + print "$dept,$v[verymoreyes],$v[moreyes],$v[verymoreno],$v[moreno],$v[same],$v[none]\n"; |
|
57 | 57 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | if (is_null($yes)) { |
35 | 35 | $votes[$dept]['none']++; |
36 | 36 | } else { |
37 | - if ($no > $yes+10) { |
|
37 | + if ($no > $yes + 10) { |
|
38 | 38 | $votes[$dept]['verymoreno']++; |
39 | 39 | } elseif ($no > $yes) { |
40 | 40 | $votes[$dept]['moreno']++; |
@@ -25,9 +25,11 @@ discard block |
||
25 | 25 | $votes = array(); |
26 | 26 | while ($row = mysql_fetch_assoc($q)) { |
27 | 27 | $dept = $row['body']; |
28 | - if (!isset($votes[$dept])) $votes[$dept] = array( |
|
28 | + if (!isset($votes[$dept])) { |
|
29 | + $votes[$dept] = array( |
|
29 | 30 | 'verymoreyes'=>0, 'moreyes'=>0, 'verymoreno'=>0, 'moreno'=>0, 'same'=>0, 'none'=>0 |
30 | 31 | ); |
32 | + } |
|
31 | 33 | $yes = $row['yes_votes']; |
32 | 34 | $no = $row['no_votes']; |
33 | 35 | $gid = $row['gid']; |
@@ -51,7 +53,8 @@ discard block |
||
51 | 53 | print "Department,11+ more yes votes than no,1-10 more yes votes than no,11+ more no votes than yes,1-10 more no votes than yes,Same votes yes/no,No votes\n"; |
52 | 54 | foreach ($votes as $dept => $v) { |
53 | 55 | #if (!$v['moreyes'] && !$v['moreno'] && !$v['same']) continue; |
54 | - if (strstr($dept, ',')) |
|
55 | - $dept = "\"$dept\""; |
|
56 | + if (strstr($dept, ',')) { |
|
57 | + $dept = "\"$dept\""; |
|
58 | + } |
|
56 | 59 | print "$dept,$v[verymoreyes],$v[moreyes],$v[verymoreno],$v[moreno],$v[same],$v[none]\n"; |
57 | 60 | } |
@@ -133,14 +133,14 @@ |
||
133 | 133 | ); |
134 | 134 | |
135 | 135 | foreach ($all_topics as $name => $topic) { |
136 | - $existing = $topics->getTopic($name); |
|
137 | - if ($existing) { |
|
138 | - print "$name already exists\n"; |
|
139 | - } else { |
|
140 | - $topic['slug'] = $name; |
|
141 | - $topic['description'] = $topic['blurb']; |
|
142 | - $topic = new MySociety\TheyWorkForYou\Topic($topic); |
|
143 | - $topic->save(); |
|
144 | - print "created $name\n"; |
|
145 | - } |
|
136 | + $existing = $topics->getTopic($name); |
|
137 | + if ($existing) { |
|
138 | + print "$name already exists\n"; |
|
139 | + } else { |
|
140 | + $topic['slug'] = $name; |
|
141 | + $topic['description'] = $topic['blurb']; |
|
142 | + $topic = new MySociety\TheyWorkForYou\Topic($topic); |
|
143 | + $topic->save(); |
|
144 | + print "created $name\n"; |
|
145 | + } |
|
146 | 146 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | <?php |
4 | 4 | |
5 | -include_once dirname(__FILE__) .'/../www/includes/easyparliament/init.php'; |
|
5 | +include_once dirname(__FILE__) . '/../www/includes/easyparliament/init.php'; |
|
6 | 6 | |
7 | 7 | $topics = new MySociety\TheyWorkForYou\Topics(); |
8 | 8 |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | |
326 | 326 | $msps = array( |
327 | 327 | array( |
328 | - 'person_id' => "19", |
|
329 | - 'name' => "Mr Regional MSP1", |
|
330 | - 'constituency' => "Mid Scotland and Fife", |
|
331 | - 'house' => "4" |
|
328 | + 'person_id' => "19", |
|
329 | + 'name' => "Mr Regional MSP1", |
|
330 | + 'constituency' => "Mid Scotland and Fife", |
|
331 | + 'house' => "4" |
|
332 | 332 | ), |
333 | 333 | array( |
334 | 334 | 'person_id' => "20", |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | $this->assertEquals($msps, \MySociety\TheyWorkForYou\Member::getRegionalList('KY16 8YG', 4, 'SPE')); |
341 | 341 | $mlas = array( |
342 | 342 | array( |
343 | - 'person_id' => "21", |
|
344 | - 'name' => "Mr Regional MLA1", |
|
345 | - 'constituency' => "Belfast West", |
|
346 | - 'house' => "3" |
|
343 | + 'person_id' => "21", |
|
344 | + 'name' => "Mr Regional MLA1", |
|
345 | + 'constituency' => "Belfast West", |
|
346 | + 'house' => "3" |
|
347 | 347 | ), |
348 | 348 | array( |
349 | 349 | 'person_id' => "22", |
@@ -11,7 +11,7 @@ |
||
11 | 11 | */ |
12 | 12 | public function getDataSet() |
13 | 13 | { |
14 | - return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/member.xml'); |
|
14 | + return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/member.xml'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -18,7 +18,7 @@ |
||
18 | 18 | /** |
19 | 19 | * Test converting a postcode to a constituency |
20 | 20 | */ |
21 | - public function testPostcodeToConstituency() |
|
21 | + public function testPostcodeToConstituency() |
|
22 | 22 | { |
23 | 23 | $this->assertEquals( |
24 | 24 | 'Cities of London and Westminster', |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | public function getDataSet() |
14 | 14 | { |
15 | - return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/postcode.xml'); |
|
15 | + return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/postcode.xml'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -17,7 +17,7 @@ |
||
17 | 17 | /** |
18 | 18 | * Ensures the database is prepared and the comment class is included for every test. |
19 | 19 | */ |
20 | - public function setUp() { |
|
20 | + public function setUp() { |
|
21 | 21 | |
22 | 22 | parent::setUp(); |
23 | 23 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | public function getDataSet() |
13 | 13 | { |
14 | - return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/comment.xml'); |
|
14 | + return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/comment.xml'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function testHTMLCleaningOfAngleBrackets() { |
57 | 57 | $text = 'Is 2 < 3?'; |
58 | 58 | |
59 | - $this->assertEquals('Is 2 < 3?', filter_user_input( $text, 'comment' ) ); |
|
59 | + $this->assertEquals('Is 2 < 3?', filter_user_input($text, 'comment')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | public function testHTMLCleaningWithNonASCIIChars() |
@@ -100,7 +100,7 @@ |
||
100 | 100 | ); |
101 | 101 | |
102 | 102 | $expectedTable = $this->createXmlDataSet(dirname(__FILE__).'/_fixtures/expectedTokens.xml') |
103 | - ->getTable("tokens"); |
|
103 | + ->getTable("tokens"); |
|
104 | 104 | $this->assertTablesEqual($expectedTable, $queryTable); |
105 | 105 | |
106 | 106 | $alertCount = $this->getConnection()->getRowCount('alerts', 'email = "[email protected]"'); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | public function getDataSet() |
13 | 13 | { |
14 | - return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/user.xml'); |
|
14 | + return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/user.xml'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | $id = $u->user_id(); |
44 | 44 | $u->init($id); |
45 | 45 | |
46 | - $this->assertEquals( 'Test', $u->firstname() ); |
|
47 | - $this->assertEquals( 'EH1 99SP', $u->postcode() ); |
|
46 | + $this->assertEquals('Test', $u->firstname()); |
|
47 | + $this->assertEquals('EH1 99SP', $u->postcode()); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function testEditUser() { |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | $u = new THEUSER(); |
53 | 53 | $u->loggedin = 1; |
54 | 54 | |
55 | - $this->assertEquals( 'Test', $u->firstname() ); |
|
55 | + $this->assertEquals('Test', $u->firstname()); |
|
56 | 56 | |
57 | - $d = $u->update_self( array( |
|
57 | + $d = $u->update_self(array( |
|
58 | 58 | 'firstname' => 'Experiment', |
59 | 59 | 'lastname' => 'User', |
60 | 60 | 'postcode' => 'EH1 99SP', |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | 'url' => '', |
63 | 63 | 'optin' => '', |
64 | 64 | 'user_id' => 1 |
65 | - ) ); |
|
65 | + )); |
|
66 | 66 | |
67 | - $this->assertEquals( 'Experiment', $u->firstname() ); |
|
67 | + $this->assertEquals('Experiment', $u->firstname()); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | public function testEditUserEmail() { |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | $u = new THEUSER(); |
73 | 73 | $u->loggedin = 1; |
74 | 74 | |
75 | - $this->assertEquals( '[email protected]', $u->email() ); |
|
75 | + $this->assertEquals('[email protected]', $u->email()); |
|
76 | 76 | |
77 | - $d = $u->update_self( array( |
|
77 | + $d = $u->update_self(array( |
|
78 | 78 | 'firstname' => 'Experiment', |
79 | 79 | 'lastname' => 'User', |
80 | 80 | 'email' => '[email protected]', |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | 'url' => '', |
84 | 84 | 'optin' => '', |
85 | 85 | 'user_id' => 1 |
86 | - ), false ); |
|
86 | + ), false); |
|
87 | 87 | |
88 | 88 | // email should not change as user needs to confirm |
89 | - $this->assertEquals( '[email protected]', $u->email() ); |
|
89 | + $this->assertEquals('[email protected]', $u->email()); |
|
90 | 90 | |
91 | 91 | $tokenCount = $this->getConnection()->getRowCount('tokens', 'data = "1::[email protected]"'); |
92 | 92 | $this->assertEquals(1, $tokenCount, 'correct number of email confirm tokens'); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'tokens', 'SELECT type, data FROM tokens WHERE data = "1::[email protected]"' |
97 | 97 | ); |
98 | 98 | |
99 | - $expectedTable = $this->createXmlDataSet(dirname(__FILE__).'/_fixtures/expectedTokens.xml') |
|
99 | + $expectedTable = $this->createXmlDataSet(dirname(__FILE__) . '/_fixtures/expectedTokens.xml') |
|
100 | 100 | ->getTable("tokens"); |
101 | 101 | $this->assertTablesEqual($expectedTable, $queryTable); |
102 | 102 | |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | $tokenRow = $queryTable->getRow(0); |
111 | 111 | $token = '2-' . $tokenRow['token']; |
112 | 112 | |
113 | - $u->confirm_email($token,false); |
|
113 | + $u->confirm_email($token, false); |
|
114 | 114 | |
115 | - $this->assertEquals( '[email protected]', $u->email(), 'confirming with token updates email address' ); |
|
115 | + $this->assertEquals('[email protected]', $u->email(), 'confirming with token updates email address'); |
|
116 | 116 | $tokenCount = $this->getConnection()->getRowCount('tokens', 'data = "1::[email protected]"'); |
117 | 117 | $this->assertEquals(0, $tokenCount, 'token deleted once email confirmed'); |
118 | 118 | |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | $u = new THEUSER(); |
129 | 129 | $u->loggedin = 1; |
130 | 130 | |
131 | - $this->assertEquals( '[email protected]', $u->email(), 'confirming inital email address' ); |
|
131 | + $this->assertEquals('[email protected]', $u->email(), 'confirming inital email address'); |
|
132 | 132 | |
133 | 133 | $tokenCount = $this->getConnection()->getRowCount('tokens', 'data = "1::[email protected]"'); |
134 | 134 | $this->assertEquals(1, $tokenCount, 'correct number of email confirm tokens'); |
135 | 135 | |
136 | 136 | $token = '2-lkdsjafhsadjhf'; |
137 | 137 | |
138 | - $u->confirm_email($token,false); |
|
139 | - $this->assertEquals( '[email protected]', $u->email(), 'expired token does not update email address' ); |
|
138 | + $u->confirm_email($token, false); |
|
139 | + $this->assertEquals('[email protected]', $u->email(), 'expired token does not update email address'); |
|
140 | 140 | |
141 | 141 | $tokenCount = $this->getConnection()->getRowCount('tokens', 'data = "1::[email protected]"'); |
142 | 142 | $this->assertEquals(1, $tokenCount, 'correct number of email confirm tokens'); |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Ensures the database is prepared and the glossary class is included for every test. |
19 | 19 | */ |
20 | - public function setUp() |
|
21 | - { |
|
20 | + public function setUp() |
|
21 | + { |
|
22 | 22 | parent::setUp(); |
23 | 23 | |
24 | 24 | include_once('www/includes/easyparliament/glossary.php'); |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * Test that glossarising a single word works as expected. |
29 | 29 | */ |
30 | - public function testGlossariseNormal() |
|
30 | + public function testGlossariseNormal() |
|
31 | 31 | { |
32 | 32 | $args['sort'] = "regexp_replace"; |
33 | - $glossary = new GLOSSARY($args); |
|
33 | + $glossary = new GLOSSARY($args); |
|
34 | 34 | |
35 | 35 | $this->assertEquals('<a href="/glossary/?gl=1" title="In a general election, each Constituency chooses an MP to represent them...." class="glossary">constituency</a>', $glossary->glossarise('constituency')); |
36 | 36 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function testGlossariseInLink() |
42 | 42 | { |
43 | 43 | $args['sort'] = "regexp_replace"; |
44 | - $glossary = new GLOSSARY($args); |
|
44 | + $glossary = new GLOSSARY($args); |
|
45 | 45 | |
46 | 46 | $this->assertEquals('<a href="#">constituency</a>', $glossary->glossarise('<a href="#">constituency</a>')); |
47 | 47 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function testGlossariseInString() |
53 | 53 | { |
54 | 54 | $args['sort'] = "regexp_replace"; |
55 | - $glossary = new GLOSSARY($args); |
|
55 | + $glossary = new GLOSSARY($args); |
|
56 | 56 | |
57 | 57 | $this->assertEquals('fooconstituencybar', $glossary->glossarise('fooconstituencybar')); |
58 | 58 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | public function testGlossariseInSpacedString() |
64 | 64 | { |
65 | 65 | $args['sort'] = "regexp_replace"; |
66 | - $glossary = new GLOSSARY($args); |
|
66 | + $glossary = new GLOSSARY($args); |
|
67 | 67 | |
68 | 68 | $this->assertEquals('foo <a href="/glossary/?gl=1" title="In a general election, each Constituency chooses an MP to represent them...." class="glossary">constituency</a> bar', $glossary->glossarise('foo constituency bar')); |
69 | 69 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function testWikipediaLinkNormal() |
75 | 75 | { |
76 | 76 | $args['sort'] = "regexp_replace"; |
77 | - $glossary = new GLOSSARY($args); |
|
77 | + $glossary = new GLOSSARY($args); |
|
78 | 78 | |
79 | 79 | $this->assertEquals('<a href="https://en.wikipedia.org/wiki/MP">MP</a>', $glossary->glossarise('MP')); |
80 | 80 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function testWikipediaLinkInLink() |
86 | 86 | { |
87 | 87 | $args['sort'] = "regexp_replace"; |
88 | - $glossary = new GLOSSARY($args); |
|
88 | + $glossary = new GLOSSARY($args); |
|
89 | 89 | |
90 | 90 | $this->assertEquals('<a href="#">MP</a>', $glossary->glossarise('<a href="#">MP</a>')); |
91 | 91 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function testWikipediaLinkInString() |
97 | 97 | { |
98 | 98 | $args['sort'] = "regexp_replace"; |
99 | - $glossary = new GLOSSARY($args); |
|
99 | + $glossary = new GLOSSARY($args); |
|
100 | 100 | |
101 | 101 | $this->assertEquals('fooMPbar', $glossary->glossarise('fooMPbar')); |
102 | 102 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | public function testWikipediaLinkInSpacedString() |
108 | 108 | { |
109 | 109 | $args['sort'] = "regexp_replace"; |
110 | - $glossary = new GLOSSARY($args); |
|
110 | + $glossary = new GLOSSARY($args); |
|
111 | 111 | |
112 | 112 | $this->assertEquals('foo <a href="https://en.wikipedia.org/wiki/MP">MP</a> bar', $glossary->glossarise('foo MP bar')); |
113 | 113 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | */ |
12 | 12 | public function getDataSet() |
13 | 13 | { |
14 | - return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/glossary.xml'); |
|
14 | + return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/glossary.xml'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | |
7 | 7 | class UtilityTest extends PHPUnit_Framework_TestCase |
8 | 8 | { |
9 | - public function setUp() |
|
10 | - { |
|
9 | + public function setUp() |
|
10 | + { |
|
11 | 11 | parent::setUp(); |
12 | 12 | include_once('www/includes/utility.php'); |
13 | 13 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * Test the escaping of replacement strings for use with |
17 | 17 | * preg_replace. |
18 | 18 | */ |
19 | - public function testPregReplacement() |
|
19 | + public function testPregReplacement() |
|
20 | 20 | { |
21 | 21 | $example = 'try \1 and $0, also backslash \ and dollar $ alone'; |
22 | 22 | $this->assertEquals( |