|
|
@@ -31,6 +31,8 @@ use TestPlugin\Plugin as TestPlugin;
|
|
|
|
|
|
/**
|
|
|
* Base application test.
|
|
|
+ *
|
|
|
+ * @coversDefaultClass \Cake\Http\BaseApplication
|
|
|
*/
|
|
|
class BaseApplicationTest extends TestCase
|
|
|
{
|
|
|
@@ -261,4 +263,35 @@ class BaseApplicationTest extends TestCase
|
|
|
$this->assertContains('route class', $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Tests that loading a non existing plugin through addOptionalPlugin() does not throw an exception
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @covers ::addOptionalPlugin
|
|
|
+ */
|
|
|
+ public function testAddOptionalPluginLoadingNonExistingPlugin()
|
|
|
+ {
|
|
|
+ $app = $this->getMockForAbstractClass(BaseApplication::class, [$this->path]);
|
|
|
+ $pluginCountBefore = count($app->getPlugins());
|
|
|
+ $nonExistingPlugin = 'NonExistingPlugin';
|
|
|
+ $app->addOptionalPlugin($nonExistingPlugin);
|
|
|
+ $pluginCountAfter = count($app->getPlugins());
|
|
|
+ $this->assertSame($pluginCountBefore, $pluginCountAfter);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Tests that loading an existing plugin through addOptionalPlugin() works
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @covers ::addOptionalPlugin
|
|
|
+ */
|
|
|
+ public function testAddOptionalPluginLoadingNonExistingPluginValid()
|
|
|
+ {
|
|
|
+ $app = $this->getMockForAbstractClass(BaseApplication::class, [$this->path]);
|
|
|
+ $app->addOptionalPlugin(TestPlugin::class);
|
|
|
+
|
|
|
+ $this->assertCount(1, $app->getPlugins());
|
|
|
+ $this->assertTrue($app->getPlugins()->has('TestPlugin'));
|
|
|
+ }
|
|
|
}
|