/
test.php
58 lines (50 loc) · 1.49 KB
/
test.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
<?php
namespace PMVC\PlugIn\app_action_router;
use PHPUnit_Framework_TestCase;
\PMVC\Load::plug();
\PMVC\addPlugInFolders(['../']);
class RoutingTest extends PHPUnit_Framework_TestCase
{
private $_plug = 'app_action_router';
function setup()
{
\PMVC\unplug('url');
\PMVC\unplug('http');
\PMVC\unplug($this->_plug);
}
function testPlugin()
{
ob_start();
print_r(\PMVC\plug($this->_plug));
$output = ob_get_contents();
ob_end_clean();
$this->assertContains($this->_plug,$output);
}
function testOnMapRequest()
{
$url = \PMVC\plug('url', [
'REQUEST_URI'=>'/fake/index.php/hello',
'SCRIPT_NAME'=>'/fake/index.php'
]);
$http = \PMVC\plug('http');
$http->onMapRequest();
$p = \PMVC\plug($this->_plug);
$p->onMapRequest();
$r = \PMVC\plug('controller')->getRequest();
$this->assertEquals(['hello'],\PMVC\get($r));
$this->assertEquals('hello',\PMVC\plug('controller')->getApp());
}
public function testGetSeo()
{
$url = \PMVC\plug('url', [
'REQUEST_URI'=>'/fake/index.php/foo+',
'SCRIPT_NAME'=>'/fake/index.php'
]);
$http = \PMVC\plug('http');
$http->onMapRequest();
$p = \PMVC\plug($this->_plug, ['seo'=>true]);
$p->onMapRequest();
$r = \PMVC\plug('controller')->getRequest();
$this->assertEquals('foo',\PMVC\get($r, SEO));
}
}