File tree Expand file tree Collapse file tree 4 files changed +51
-2
lines changed Expand file tree Collapse file tree 4 files changed +51
-2
lines changed Original file line number Diff line number Diff line change 33
33
<html outputDirectory =" test-coverage-report/" />
34
34
</report >
35
35
</coverage >
36
+
37
+ <logging >
38
+ <log type =" coverage-clover" target =" coverage/clover.xml" />
39
+ </logging >
40
+
36
41
</phpunit >
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ class Kernel implements KernelInterface
34
34
*/
35
35
public function __construct (
36
36
private readonly array $ applicationPluginCollection ,
37
- private readonly iterable $ pluginBootLoaderCollection ,
37
+ private array $ pluginBootLoaderCollection ,
38
38
private readonly Container $ container
39
39
) {
40
40
$ this ->isStarted = false ;
@@ -43,6 +43,28 @@ public function __construct(
43
43
$ this ->plugins = [];
44
44
}
45
45
46
+ public function addBootLoader (PluginBootLoaderInterface $ bootLoader ): self
47
+ {
48
+ if ($ this ->isStarted ) {
49
+ throw new \LogicException ('Bootloaders must be installed before starting the kernel. ' );
50
+ }
51
+
52
+ $ this ->pluginBootLoaderCollection [] = $ bootLoader ;
53
+
54
+ return $ this ;
55
+ }
56
+
57
+ public function setBootLoaders (iterable $ bootLoaders ): self
58
+ {
59
+ $ this ->pluginBootLoaderCollection = [];
60
+
61
+ foreach ($ bootLoaders as $ loader ) {
62
+ $ this ->addBootLoader ($ loader );
63
+ }
64
+
65
+ return $ this ;
66
+ }
67
+
46
68
/**
47
69
* {@inheritDoc}
48
70
*/
Original file line number Diff line number Diff line change 12
12
namespace Micro \Framework \Kernel ;
13
13
14
14
use Micro \Component \DependencyInjection \Container ;
15
+ use Micro \Framework \Kernel \Plugin \PluginBootLoaderInterface ;
15
16
16
17
/**
17
18
* The kernel is needed for plugin management. A plugin can be any class object.
@@ -25,6 +26,18 @@ interface KernelInterface
25
26
*/
26
27
public function container (): Container ;
27
28
29
+ /**
30
+ * @throws \RuntimeException
31
+ */
32
+ public function addBootLoader (PluginBootLoaderInterface $ bootLoader ): self ;
33
+
34
+ /**
35
+ * @param iterable<PluginBootLoaderInterface> $bootLoaders
36
+ *
37
+ * @throws \RuntimeException
38
+ */
39
+ public function setBootLoaders (iterable $ bootLoaders ): self ;
40
+
28
41
/**
29
42
* Run application.
30
43
*
Original file line number Diff line number Diff line change @@ -46,13 +46,22 @@ protected function setUp(): void
46
46
47
47
$ this ->kernel = new Kernel (
48
48
$ plugins ,
49
- $ bootLoaders ,
49
+ [] ,
50
50
$ this ->container ,
51
51
);
52
52
53
+ $ this ->kernel ->setBootLoaders ($ bootLoaders );
54
+ $ this ->kernel ->addBootLoader ($ this ->createMock (PluginBootLoaderInterface::class));
55
+
53
56
$ this ->kernel ->run ();
54
57
}
55
58
59
+ public function testExceptionWhenTryBootloaderInstallAfterKernelRun ()
60
+ {
61
+ $ this ->expectException (\LogicException::class);
62
+ $ this ->kernel ->addBootLoader ($ this ->createMock (PluginBootLoaderInterface::class));
63
+ }
64
+
56
65
public function testKernelPlugins ()
57
66
{
58
67
foreach ($ this ->kernel ->plugins (\stdClass::class) as $ plugin ) {
You can’t perform that action at this time.
0 commit comments