/
routes.php
101 lines (72 loc) · 2.15 KB
/
routes.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
require_once __DIR__ . '/helper.php';
require_once __DIR__ . '/apps/routes.php';
use Waffles\Test as Test;
Test::group("Test the routes system", function()
{
Test::add("Test a regular route", function($test)
{
global $app;
// Fake a request
$app_response = run_application('/', $app);
$test->expects($app_response)->to()->equal('index method');
});
Test::add("Test a sub route", function($test)
{
global $app;
// Fake a request
$app_response = run_application('/hello/world', $app);
$test->expects($app_response)->to()->equal('sub method');
});
Test::add("Test an alphabetical route", function($test)
{
global $app;
// Fake a request
$app_response = run_application('/abc', $app);
$test->expects($app_response)->to()->equal('alphabetic method');
});
Test::add("Test a numeric route", function($test)
{
global $app;
// Fake a request
$app_response = run_application('/123', $app);
$test->expects($app_response)->to()->equal('numeric method');
});
Test::add("Test an alphanumeric route", function($test)
{
global $app;
// Fake a request
$app_response = run_application('/abc123', $app);
$test->expects($app_response)->to()->equal('alphanumeric method');
});
Test::add("Test a regex route", function($test)
{
global $app;
// Fake a request
$app_response = run_application('/koi-123', $app);
$test->expects($app_response)->to()->equal('regex method');
});
Test::add("Test a 404 route", function($test)
{
global $app;
// Fake a request
$app_response = run_application('/does-not-exist', $app);
$test->expects($app_response)->to()->equal('404 method');
});
Test::add("Test a sub 404 route", function($test)
{
global $app;
// Fake a request
$app_response = run_application('/sublevel/does-not-exist', $app);
$test->expects($app_response)->to()->equal('sub 404 method');
});
Test::add("Test a route with arguments", function($test)
{
global $app;
// Fake a request
$app_response = run_application('/route_args/123', $app);
$test->expects($app_response)->to()->equal('route with args method 123');
});
});
// Run all our tests
Test::run_all();