Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
186 lines (162 loc) · 5.2 KB

File metadata and controls

186 lines (162 loc) · 5.2 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
use Foolz\Plugin\Plugin;
use Foolz\Plugin\Loader;
class PluginTest extends PHPUnit_Framework_TestCase
{
public function unlinkConfig()
{
if (file_exists(__DIR__.'/../../tests/mock/foolz/fake/composer.php'))
{
unlink(__DIR__.'/../../tests/mock/foolz/fake/composer.php');
}
}
public function testConstruct()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$this->assertInstanceOf('Foolz\Plugin\Plugin', $plugin);
}
/**
* @expectedException \DomainException
*/
public function testConstructThrows()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/blabla');
}
public function testGetSetLoader()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$loader = new Loader();
$plugin->setLoader($loader);
$this->assertSame($loader, $plugin->getLoader());
}
public function testGetDir()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake');
$this->assertFalse(__DIR__.'/../../tests/mock/foolz/fake' === $plugin->getDir());
// it always adds a trailing slash
$this->assertSame(__DIR__.'/../../tests/mock/foolz/fake/', $plugin->getDir());
}
public function testGetJsonConfig()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$this->assertArrayHasKey('name', $plugin->getJsonConfig());
}
public function testGetJsonConfigKey()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$this->assertSame('Fake', $plugin->getJsonConfig('extra.name'));
}
public function testGetJsonConfigKeyFallback()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$this->assertSame('Fake', $plugin->getJsonConfig('extra.doesntexist', 'Fake'));
}
/**
* @expectedException \DomainException
*/
public function testGetJsonConfigKeyThrows()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$this->assertSame('Fake', $plugin->getJsonConfig('extra.doesntexist'));
}
/**
* @expectedException \DomainException
*/
public function testGetJsonConfigBrokenJsonThrows()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/broken_json/');
$plugin->getJsonConfig();
}
public function testJsonToConfig()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$plugin->jsonToConfig();
$this->assertSame($plugin->getJsonConfig(), $plugin->getConfig());
$this->unlinkConfig();
}
public function testGetConfig()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$this->assertArrayHasKey('name', $plugin->getConfig());
$this->unlinkConfig();
}
public function testGetConfigKey()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$this->assertSame('Fake', $plugin->getConfig('extra.name'));
$this->unlinkConfig();
}
public function testGetConfigKeyFallback()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$this->assertSame('Fake', $plugin->getConfig('extra.doesntexist', 'Fake'));
$this->unlinkConfig();
}
/**
* @expectedException \DomainException
*/
public function testGetConfigKeyFallbackThrows()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$plugin->getConfig('extra.doesntexist');
$this->unlinkConfig();
}
public function testRefreshConfig()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$plugin->getConfig();
$plugin->refreshConfig();
$this->assertFalse(file_exists(__DIR__.'/../../tests/mock/foolz/fake/composer.php'));
$this->unlinkConfig();
}
public function testBootstrap()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$plugin->bootstrap();
// we set a trap in the bootstrap file
$result = \Foolz\Plugin\Hook::forge('the.bootstrap.was.loaded')->execute()->get('no load');
$this->assertSame('success', $result);
$this->unlinkConfig();
}
public function testExecute()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$plugin->execute();
$result = \Foolz\Plugin\Hook::forge('foolz\plugin\plugin.execute.foolz/fake')
->execute()->get('no load');
$this->assertSame('success', $result);
$this->unlinkConfig();
}
public function testInstall()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$plugin->install();
$result = \Foolz\Plugin\Hook::forge('foolz\plugin\plugin.install.foolz/fake')
->execute()->get('no load');
$this->assertSame('success', $result);
$this->unlinkConfig();
}
public function testUninstall()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$plugin->uninstall();
$result = \Foolz\Plugin\Hook::forge('foolz\plugin\plugin.uninstall.foolz/fake')
->execute()->get('no load');
$this->assertSame('success', $result);
$this->unlinkConfig();
}
public function testUpgrade()
{
$plugin = new Plugin(__DIR__.'/../../tests/mock/foolz/fake/');
$plugin->upgrade();
$result = \Foolz\Plugin\Hook::forge('foolz\plugin\plugin.upgrade.foolz/fake')
->setObject($this)
->setParam('old_revision', $plugin->getConfig('extra.revision', 0))
->setParam('new_revision', $plugin->getJsonConfig('extra.revision', 0))
->execute();
$this->assertSame('success', $result->get('no load'));
$this->assertSame(0, $result->getParam('old_revision'));
$this->assertSame(0, $result->getParam('new_revision'));
$this->unlinkConfig();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.