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 3333 <html outputDirectory =" test-coverage-report/" />
3434 </report >
3535 </coverage >
36+
37+ <logging >
38+ <log type =" coverage-clover" target =" coverage/clover.xml" />
39+ </logging >
40+
3641</phpunit >
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ class Kernel implements KernelInterface
3434 */
3535 public function __construct (
3636 private readonly array $ applicationPluginCollection ,
37- private readonly iterable $ pluginBootLoaderCollection ,
37+ private array $ pluginBootLoaderCollection ,
3838 private readonly Container $ container
3939 ) {
4040 $ this ->isStarted = false ;
@@ -43,6 +43,28 @@ public function __construct(
4343 $ this ->plugins = [];
4444 }
4545
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+
4668 /**
4769 * {@inheritDoc}
4870 */
Original file line number Diff line number Diff line change 1212namespace Micro \Framework \Kernel ;
1313
1414use Micro \Component \DependencyInjection \Container ;
15+ use Micro \Framework \Kernel \Plugin \PluginBootLoaderInterface ;
1516
1617/**
1718 * The kernel is needed for plugin management. A plugin can be any class object.
@@ -25,6 +26,18 @@ interface KernelInterface
2526 */
2627 public function container (): Container ;
2728
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+
2841 /**
2942 * Run application.
3043 *
Original file line number Diff line number Diff line change @@ -46,13 +46,22 @@ protected function setUp(): void
4646
4747 $ this ->kernel = new Kernel (
4848 $ plugins ,
49- $ bootLoaders ,
49+ [] ,
5050 $ this ->container ,
5151 );
5252
53+ $ this ->kernel ->setBootLoaders ($ bootLoaders );
54+ $ this ->kernel ->addBootLoader ($ this ->createMock (PluginBootLoaderInterface::class));
55+
5356 $ this ->kernel ->run ();
5457 }
5558
59+ public function testExceptionWhenTryBootloaderInstallAfterKernelRun ()
60+ {
61+ $ this ->expectException (\LogicException::class);
62+ $ this ->kernel ->addBootLoader ($ this ->createMock (PluginBootLoaderInterface::class));
63+ }
64+
5665 public function testKernelPlugins ()
5766 {
5867 foreach ($ this ->kernel ->plugins (\stdClass::class) as $ plugin ) {
You can’t perform that action at this time.
0 commit comments