-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRoutesTest.php
34 lines (29 loc) · 1.04 KB
/
RoutesTest.php
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
<?php
require_once 'LocalServerTest.php';
class RoutesTest extends LocalServerTest {
var $routes = [
'/slim-app/hello/PHP'
];
public function testRoutesStatusCodes() {
$this->output("\nTesting routes for HTTP error codes");
foreach ($this->routes as $route) {
$response = $this->makeRequest($route);
$statusCode = $response->getStatusCode();
$this->output(sprintf("\t%s: %d", $route, $statusCode));
$this->assertEquals(200, $statusCode);
}
}
public function testRoutesHtmlCode() {
$this->output("\nValidating routes output");
foreach ($this->routes as $route) {
$response = $this->makeRequest($route);
$body = $response->getBody();
// I wanted to use a real HTML validator here, but
// DOMDocument does not understand HTML5 and
// Tidy did not report any error with missing closing tags... seriously, PHP?
$valid = (strpos($body, 'Hello, PHP!') !== false);
$this->output(sprintf("\t%s: %d", $route, $valid));
$this->assertEquals(true, $valid);
}
}
}