-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathKernelTest.php
More file actions
61 lines (53 loc) · 1.66 KB
/
KernelTest.php
File metadata and controls
61 lines (53 loc) · 1.66 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
<?php
use PHPUnit\Framework\TestCase;
class KernelTest extends TestCase
{
public function testInstance()
{
$this->assertEquals(is_object($this->getKernelInstance()), true);
$this->assertEquals(is_object(\TastPHP\Framework\Kernel::getInstance()), true);
}
public function testSingleton()
{
$kernel = $this->getKernelInstance();
$stdClass = new stdClass();
$kernel->singleton('testkey', function () use ($stdClass) {
return $stdClass;
});
$this->assertEquals($kernel['testkey'], $stdClass);
}
/**
* @expectedException InvalidArgumentException
*/
public function testNotMatchReplaceServiceProvider()
{
$key = 'Configs';
$serviceProvider = 'TastPHP\Test\Config\ConfigServiceProvider';
$kernel = $this->getKernelInstance();
$kernel->replaceServiceProvider($key, $serviceProvider);
}
/**
* @expectedException InvalidArgumentException
*/
public function testNotMatchReplaceAlias()
{
$alias = 'Configs';
$class = 'TastPHP\Test\Config\ConfigServiceProvider';
$kernel = $this->getKernelInstance();
$kernel->replaceAlias($alias, $class);
}
/**
* @expectedException InvalidArgumentException
*/
public function testNotMatchReplaceListener()
{
$eventName = 'app.test.request';
$lisenter = 'TastPHP\Test\Listener\RequestListener@onTestRequestAction';
$kernel = $this->getKernelInstance();
$kernel->replaceListener($eventName, $lisenter);
}
protected function getKernelInstance()
{
return new \TastPHP\Framework\Kernel();
}
}