-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
40 lines (34 loc) · 958 Bytes
/
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
<?php
namespace PMVC\App\error;
use PMVC;
use PHPUnit_Framework_TestCase;
PMVC\Load::plug();
PMVC\addPlugInFolders(['../']);
PMVC\l(__DIR__.'/vendor/pmvc-plugin/controller/tests/resources/FakeView.php');
class ErrorActionTest extends PHPUnit_Framework_TestCase
{
function testPlugin()
{
$view = \PMVC\plug(
'view',
[
_CLASS => '\PMVC\FakeView',
]
);
$c = \PMVC\plug('controller');
$c->setApp('error');
$c->plugApp(['../']);
$r = $c->getRequest();
$r['errors'] = ['1001'];
$result = $c->process();
$actual = \PMVC\value($view->get('data'), [
'errors',
0
]);
$expected = new Error('1001', [
'message'=>'Username can\'t empty, and must be at least 6 characters long',
'field'=>'username',
]);
$this->assertEquals($expected, $actual);
}
}