-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDispatcherTest.php
More file actions
91 lines (59 loc) · 1.98 KB
/
Copy pathDispatcherTest.php
File metadata and controls
91 lines (59 loc) · 1.98 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
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
<?php
use Mockery as m;
class DispatcherTest extends PHPUnit_Framework_TestCase {
public function setUp()
{
require_once __DIR__.'/TestExtension/TestExtension.php';
}
public function tearDown()
{
m::close();
}
public function testDispatcherRegistersExtensionsFromArray()
{
define('FEATHER_DATABASE', 'feather');
$dispatcher = $this->getDispatcher();
$extension = new Feather\Models\Extension(array(
'location' => '/',
'identifier' => 'foobar',
'auto' => false
));
$dispatcher->registerExtensions(array($extension));
$this->assertInstanceOf('Feather\Models\Extension', $dispatcher['extension.foobar']);
$this->assertEquals('foobar', $dispatcher['extension.foobar']->identifier);
}
public function testDispatcherRegisterExtension()
{
$dispatcher = $this->getDispatcher();
$extension = new Feather\Models\Extension(array(
'location' => '/',
'identifier' => 'foobar',
'auto' => false
));
$dispatcher->register($extension);
$this->assertInstanceOf('Feather\Models\Extension', $dispatcher['extension.foobar']);
$this->assertEquals('foobar', $dispatcher['extension.foobar']->identifier);
}
public function testDispatcherAutoStartExtension()
{
$dispatcher = $this->getDispatcher();
$extension = new Feather\Models\Extension(array(
'location' => 'TestExtension',
'identifier' => 'testextension',
'auto' => true
));
$dispatcher->register($extension);
$this->assertArrayHasKey('Feather\Extensions\TestExtension\TestExtension', $extension->loaded);
$this->assertEquals('bar', $extension->loaded['Feather\Extensions\TestExtension\TestExtension']->foo());
}
protected function getDispatcher()
{
$app = new Illuminate\Container;
$app['events'] = new Illuminate\Events\Dispatcher;
$files = m::mock('Illuminate\Filesystem');
$files->shouldReceive('exists')->once()->andReturn(true);
$dispatcher = new Feather\Extensions\Dispatcher($files, __DIR__);
$dispatcher->setApplication($app);
return $dispatcher;
}
}