-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtensionTest.php
More file actions
137 lines (93 loc) · 3.21 KB
/
Copy pathExtensionTest.php
File metadata and controls
137 lines (93 loc) · 3.21 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
use Mockery as m;
class ExtensionTest extends PHPUnit_Framework_TestCase {
public function setUp()
{
require_once __DIR__.'/TestExtension/TestExtension.php';
}
public function tearDown()
{
m::close();
}
public function testExtensionsAreBootstrapped()
{
list($app, $dispatcher) = $this->getApplicationAndDispatcher();
$extension = new Feather\Models\Extension(array(
'location' => 'TestExtension',
'identifier' => 'testextension',
'auto' => true
));
$dispatcher->register($extension);
$this->assertEquals('success', $app['events']->first('start_test'));
}
public function testExtensionsCanListen()
{
list($app, $dispatcher) = $this->getApplicationAndDispatcher();
$extension = new Feather\Models\Extension(array(
'location' => 'TestExtension',
'identifier' => 'testextension',
'auto' => true
));
$dispatcher->register($extension);
$extension->loaded['Feather\Extensions\TestExtension\TestExtension']->listen('foobar', function()
{
return 'barfoo';
});
$this->assertEquals('barfoo', $app['events']->first('foobar'));
}
public function testExtensionsCanOverride()
{
list($app, $dispatcher) = $this->getApplicationAndDispatcher();
$extension = new Feather\Models\Extension(array(
'location' => 'TestExtension',
'identifier' => 'testextension',
'auto' => true
));
$dispatcher->register($extension);
$extension->loaded['Feather\Extensions\TestExtension\TestExtension']->listen('foobar', function()
{
return 'barfoo';
});
$extension->loaded['Feather\Extensions\TestExtension\TestExtension']->override('foobar', function()
{
return 'barbar';
});
$this->assertEquals('barbar', $app['events']->first('foobar'));
}
public function testExtensionsCanUseMethods()
{
list($app, $dispatcher) = $this->getApplicationAndDispatcher();
$extension = new Feather\Models\Extension(array(
'location' => 'TestExtension',
'identifier' => 'testextension',
'auto' => true
));
$dispatcher->register($extension);
$extension->loaded['Feather\Extensions\TestExtension\TestExtension']->listen('foobar', 'foo');
$this->assertEquals('bar', $app['events']->first('foobar'));
}
public function testExtensionPerformsBasicOperations()
{
list($app, $dispatcher) = $this->getApplicationAndDispatcher();
$extension = new Feather\Models\Extension(array(
'location' => 'TestExtension',
'identifier' => 'testextension',
'auto' => true
));
$dispatcher->register($extension);
$extension->loaded['Feather\Extensions\TestExtension\TestExtension']->installed();
$extension->loaded['Feather\Extensions\TestExtension\TestExtension']->activated();
$extension->loaded['Feather\Extensions\TestExtension\TestExtension']->deactivated();
$extension->loaded['Feather\Extensions\TestExtension\TestExtension']->removed();
}
protected function getApplicationAndDispatcher()
{
$app = new Illuminate\Container;
$app['events'] = new Illuminate\Events\Dispatcher;
$app['files'] = m::mock('Illuminate\Filesystem');
$app['files']->shouldReceive('exists')->once()->andReturn(true);
$dispatcher = new Feather\Extensions\Dispatcher($app['files'], __DIR__);
$dispatcher->setApplication($app);
return array($app, $dispatcher);
}
}