forked from jpatokal/openflights
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflights.php
More file actions
44 lines (36 loc) · 1.31 KB
/
flights.php
File metadata and controls
44 lines (36 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
include_once(dirname(__FILE__) . '/config.php');
//
// Test cases for php/flights.php
// Check demo user map
class BlockAnonExportCase extends WebTestCase {
public function test() {
global $webroot;
$params = array("export" => "true");
$this->get($webroot . "php/flights.php", $params);
$this->assertText("You must be logged in to export.");
}
}
class ExportAirlineToCSVCase extends WebTestCase {
public function test() {
global $webroot, $route;
// First figure out the correct results
$dbh = db_connect();
$sth = $dbh->prepare("SELECT alid FROM airlines WHERE iata=?");
$sth->execute([$route["core_al_iata"]]) or die($sth->errorInfo());
if ($row = $sth->fetch()) {
$alid = $row["alid"];
}
$sth = $dbh->prepare("SELECT COUNT(*) AS count FROM routes WHERE alid=?");
$sth->execute([$alid]) or die($sth->errorInfo());
if ($row = $sth->fetch()) {
$route_count = intval($row["count"]);
}
// Then test
assert_login($this);
$params = array("export" => "export", "id" => "L" . $alid);
$csv = $this->get($webroot . "php/flights.php", $params);
$rows = explode("\n", $csv);
$this->assertEqual(count($rows), $route_count + 1);
}
}