Skip to content

Commit f53e452

Browse files
committed
Various test related cleanup
1 parent aa1725c commit f53e452

22 files changed

+367
-197
lines changed

test/client/AirportSearchTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
2+
23
include_once dirname(__FILE__) . '/OpenFlightsSeleniumTestCase.php';
34

4-
class AirportSearchTest extends OpenFlightsSeleniumTestCase
5-
{
6-
public function testAnonAirportSearch()
7-
{
5+
class AirportSearchTest extends OpenFlightsSeleniumTestCase {
6+
public function testAnonAirportSearch() {
87
global $airport;
98

109
$this->open("/html/apsearch");
@@ -21,8 +20,7 @@ public function testAnonAirportSearch()
2120
$this->assertValue("airport", $airport['name']);
2221
}
2322

24-
public function testAnonAirportSearchPreload()
25-
{
23+
public function testAnonAirportSearchPreload() {
2624
global $airport;
2725

2826
$apid = db_apid(db_connect());
@@ -42,8 +40,7 @@ public function testAnonAirportSearchPreload()
4240
$this->assertValue("iata", "");
4341
}
4442

45-
public function testLoggedInAirportEdit()
46-
{
43+
public function testLoggedInAirportEdit() {
4744
global $settings, $airport;
4845

4946
$this->open('/');

test/client/OpenFlightsSeleniumTestCase.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44

55
include_once dirname(__FILE__) . '/../server/config.php';
66

7-
class OpenFlightsSeleniumTestCase extends Selenium2TestCase
8-
{
7+
class OpenFlightsSeleniumTestCase extends Selenium2TestCase {
98
protected $captureScreenshotOnFailure = true;
109
protected $screenshotPath = '/tmp/screenshots';
1110
protected $screenshotUrl = '/tmp/screenshots';
1211

13-
protected function setUp(): void
14-
{
12+
protected function setUp(): void {
1513
$this->setBrowser('*firefox /Applications/Firefox.app/Contents/MacOS/firefox-bin');
1614
$this->setBrowserUrl('http://openflights.local/');
1715
$this->setSpeed(100);

test/client/WebLoginTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
2+
23
include_once dirname(__FILE__) . '/OpenFlightsSeleniumTestCase.php';
34

4-
class WebLoginTest extends OpenFlightsSeleniumTestCase
5-
{
6-
public function testFailedLogin()
7-
{
5+
class WebLoginTest extends OpenFlightsSeleniumTestCase {
6+
public function testFailedLogin() {
87
global $settings;
98

109
$this->open('/');
@@ -28,8 +27,7 @@ public function testFailedLogin()
2827
$this->click('close');
2928
}
3029

31-
public function testSuccessfulLogin()
32-
{
30+
public function testSuccessfulLogin() {
3331
global $settings;
3432

3533
$this->open('/');
@@ -45,8 +43,7 @@ public function testSuccessfulLogin()
4543
$this->verifyTextPresent("Add new flights");
4644
}
4745

48-
public function testReload()
49-
{
46+
public function testReload() {
5047
global $settings;
5148

5249
$this->open('/');

test/client/WebMapPublicTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
2+
23
include_once dirname(__FILE__) . '/OpenFlightsSeleniumTestCase.php';
34

4-
class WebMapPublicTest extends OpenFlightsSeleniumTestCase
5-
{
6-
public function testPublicUserMapAsAnonymous()
7-
{
5+
class WebMapPublicTest extends OpenFlightsSeleniumTestCase {
6+
public function testPublicUserMapAsAnonymous() {
87
global $settings;
98

109
$this->open("/user/" . $settings['name']);
@@ -24,7 +23,7 @@ public function testPublicUserMapAsAnonymous()
2423
$this->click('link=Decatur Aviation');
2524
$this->verifyTextPresent($settings['name'] . "'s flights on Decatur Aviation");
2625

27-
# Back to main map
26+
# Back to the main map
2827
$this->select('Airlines', 'label=All carriers');
2928
$this->verifyTextPresent($settings['name'] . "'s flights");
3029
}

test/server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This test suite validates PHP calls and MySQL database content.
66
1. `php composer.phar install`
77
2. Configure `config.php`
88
3. Run `php settings.php` to populate test user
9-
4. Then run eg. `php login.php` to test login cases, _or_
9+
4. Then run e.g. `php login.php` to test login cases, _or_
1010
5. Load `/test/server/test_all.php` in a browser to test all.
1111

1212
NOTE: Many cases are dependent on each other. Generally, run settings.php first, all cases afterward, and cleanup.php last.

test/server/alsearch.php

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
$new_alid = null;
77
$new_rlid = null;
88

9-
// Try to add airline before logging in
9+
/**
10+
* Try to add airline before logging in
11+
*/
1012
class RecordAirlineNotLoggedInTest extends WebTestCase {
1113
public function test() {
1214
global $webroot;
@@ -17,7 +19,9 @@ public function test() {
1719
}
1820
}
1921

20-
// Try to reuse an existing airline's code
22+
/**
23+
* Try to reuse an existing airline's code
24+
*/
2125
class RecordAirlineDuplicateICAOTest extends WebTestCase {
2226
public function test() {
2327
global $webroot, $airline;
@@ -31,7 +35,9 @@ public function test() {
3135
}
3236
}
3337

34-
// Add new airline
38+
/**
39+
* Add new airline
40+
*/
3541
class RecordNewAirlineTest extends WebTestCase {
3642
public function test() {
3743
global $webroot, $airline, $new_alid;
@@ -49,7 +55,9 @@ public function test() {
4955
}
5056
}
5157

52-
// Try to record it again
58+
/**
59+
* Try to record it again
60+
*/
5361
class RecordAirlineDuplicateTest extends WebTestCase {
5462
public function test() {
5563
global $webroot, $airline;
@@ -62,7 +70,9 @@ public function test() {
6270
}
6371
}
6472

65-
// Add new railway
73+
/**
74+
* Add new railway
75+
*/
6676
class RecordNewRailwayTest extends WebTestCase {
6777
public function test() {
6878
global $webroot, $railway, $new_rlid;
@@ -78,7 +88,9 @@ public function test() {
7888
}
7989
}
8090

81-
// Try to add the railway again
91+
/**
92+
* Try to add the railway again
93+
*/
8294
class RecordRailwayDuplicateTest extends WebTestCase {
8395
public function test() {
8496
global $webroot, $railway;
@@ -91,22 +103,26 @@ public function test() {
91103
}
92104
}
93105

94-
// Try to edit an airline not belonging to us
106+
/**
107+
* Try to edit an airline not belonging to us
108+
*/
95109
class EditWrongAirlineTest extends WebTestCase {
96110
public function test() {
97111
global $webroot, $airline;
98112

99113
login($this);
100114
$params = $airline;
101-
$params["alid"] = 1; // this is presumably not owned by us
115+
$params["alid"] = 1; // this airline should not be "owned" by this user
102116
$params["icao"] = "ZZZY";
103117
$params += array("action" => "RECORD");
104118
$msg = $this->post($webroot . "php/alsearch.php", $params);
105119
$this->assertText('0;');
106120
}
107121
}
108122

109-
// Try to reuse an existing airline's code
123+
/**
124+
* Try to reuse an existing airline's code
125+
*/
110126
class EditAirlineDuplicateICAOTest extends WebTestCase {
111127
public function test() {
112128
global $webroot, $airline, $new_alid;
@@ -121,7 +137,9 @@ public function test() {
121137
}
122138
}
123139

124-
// Try to edit to overwrite existing airline
140+
/**
141+
* Try to edit to overwrite existing airline
142+
*/
125143
class EditAirlineSuccessfulTest extends WebTestCase {
126144
public function test() {
127145
global $webroot, $airline, $new_alid;
@@ -137,7 +155,9 @@ public function test() {
137155
}
138156

139157

140-
// Search by IATA
158+
/**
159+
* Search for an airline by IATA code
160+
*/
141161
class SearchAirlineByIATATest extends WebTestCase {
142162
public function test() {
143163
global $webroot, $airline;
@@ -156,7 +176,9 @@ public function test() {
156176
}
157177
}
158178

159-
// Search by ICAO
179+
/**
180+
* Search for an airline by ICAO code
181+
*/
160182
class SearchAirlineByICAOTest extends WebTestCase {
161183
public function test() {
162184
global $webroot, $airline;
@@ -172,7 +194,9 @@ public function test() {
172194
}
173195
}
174196

175-
// Search railway by name
197+
/**
198+
* Search railway by name
199+
*/
176200
class SearchRailwayByNameTest extends WebTestCase {
177201
public function test() {
178202
global $webroot, $railway;

test/server/apsearch.php

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
// Store temporary airport ID
66
$new_apid = null;
77

8-
// Check that we can load up the country data
8+
/**
9+
* Check that we can load up the country data
10+
*/
911
class LoadCountriesTest extends WebTestCase {
1012
public function test() {
1113
global $webroot;
@@ -17,7 +19,9 @@ public function test() {
1719
}
1820
}
1921

20-
// Try to add airport before logging in
22+
/**
23+
* Try to add an airport before logging in
24+
*/
2125
class RecordAirportNotLoggedInTest extends WebTestCase {
2226
public function test() {
2327
global $webroot;
@@ -28,7 +32,9 @@ public function test() {
2832
}
2933
}
3034

31-
// Add new airport
35+
/**
36+
* Add new airport
37+
*/
3238
class RecordNewAirportTest extends WebTestCase {
3339
public function test() {
3440
global $webroot, $airport, $new_apid;
@@ -42,7 +48,9 @@ public function test() {
4248
}
4349
}
4450

45-
// Try to add it again
51+
/**
52+
* Try to add it again
53+
*/
4654
class RecordAirportDuplicateTest extends WebTestCase {
4755
public function test() {
4856
global $webroot, $airport;
@@ -58,7 +66,9 @@ public function test() {
5866
}
5967
}
6068

61-
// Try to edit an airport not belonging to us
69+
/**
70+
* Try to edit an airport not belonging to us
71+
*/
6272
class EditWrongAirportTest extends WebTestCase {
6373
public function test() {
6474
global $webroot, $airport;
@@ -77,7 +87,9 @@ public function test() {
7787
}
7888
}
7989

80-
// Try to reuse an existing airport's code
90+
/**
91+
* Try to reuse an existing airport's code
92+
*/
8193
class EditAirportDuplicateICAOTest extends WebTestCase {
8294
public function test() {
8395
global $webroot, $airport, $new_apid;
@@ -95,7 +107,9 @@ public function test() {
95107
}
96108
}
97109

98-
// Try to edit to overwrite existing airport
110+
/**
111+
* Try to edit to overwrite existing airport
112+
*/
99113
class EditAirportSuccessfulTest extends WebTestCase {
100114
public function test() {
101115
global $webroot, $airport, $new_apid;
@@ -111,7 +125,9 @@ public function test() {
111125
}
112126
}
113127

114-
// Add new location with null codes
128+
/**
129+
* Add new location with null codes
130+
*/
115131
class RecordNewNullCodePlaceTest extends WebTestCase {
116132
public function test() {
117133
global $webroot, $settings, $airport, $new_apid;
@@ -144,7 +160,9 @@ public function test() {
144160
}
145161
}
146162

147-
// Load a single airport
163+
/**
164+
* Load a single airport
165+
*/
148166
class LoadAirportByApidTest extends WebTestCase {
149167
public function test() {
150168
global $webroot, $airport, $new_apid;
@@ -171,7 +189,9 @@ public function test() {
171189
}
172190
}
173191

174-
// Load a single airport
192+
/**
193+
* Load a single airport
194+
*/
175195
class LoadAirportByInvalidApidTest extends WebTestCase {
176196
public function test() {
177197
global $webroot;
@@ -185,7 +205,9 @@ public function test() {
185205
}
186206
}
187207

188-
// Search OpenFlights DB by IATA (of just-added airport)
208+
/**
209+
* Search OpenFlights DB by IATA code (of just-added airport)
210+
*/
189211
class SearchAirportOFDBByIATATest extends WebTestCase {
190212
public function test() {
191213
global $webroot, $airport;

0 commit comments

Comments
 (0)