forked from flightphp/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapTest.php
More file actions
65 lines (49 loc) · 1.4 KB
/
MapTest.php
File metadata and controls
65 lines (49 loc) · 1.4 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2012, Mike Cao <[email protected]>
* @license MIT, http://flightphp.com/license
*/
require_once 'PHPUnit/Autoload.php';
require_once __DIR__.'/../flight/autoload.php';
require_once __DIR__.'/classes/Hello.php';
class MapTest extends PHPUnit_Framework_TestCase
{
/**
* @var \flight\Engine
*/
private $app;
function setUp() {
$this->app = new \flight\Engine();
}
// Map a closure
function testClosureMapping(){
$this->app->map('map1', function(){
return 'hello';
});
$result = $this->app->map1();
$this->assertEquals('hello', $result);
}
// Map a function
function testFunctionMapping(){
$this->app->map('map2', function(){
return 'hello';
});
$result = $this->app->map2();
$this->assertEquals('hello', $result);
}
// Map a class method
function testClassMethodMapping(){
$h = new Hello();
$this->app->map('map3', array($h, 'sayHi'));
$result = $this->app->map3();
$this->assertEquals('hello', $result);
}
// Map a static class method
function testStaticClassMethodMapping(){
$this->app->map('map4', array('Hello', 'sayBye'));
$result = $this->app->map4();
$this->assertEquals('goodbye', $result);
}
}