|
|
@@ -14,6 +14,7 @@
|
|
|
*/
|
|
|
namespace Cake\Test\TestCase\Http;
|
|
|
|
|
|
+use Cake\Core\BasePlugin;
|
|
|
use Cake\Core\Configure;
|
|
|
use Cake\Core\Plugin;
|
|
|
use Cake\Http\BaseApplication;
|
|
|
@@ -25,6 +26,7 @@ use Cake\Routing\RouteCollection;
|
|
|
use Cake\Routing\Router;
|
|
|
use Cake\TestSuite\TestCase;
|
|
|
use InvalidArgumentException;
|
|
|
+use Psr\Http\Message\ResponseInterface;
|
|
|
use TestPlugin\Plugin as TestPlugin;
|
|
|
|
|
|
/**
|
|
|
@@ -69,20 +71,27 @@ class BaseApplicationTest extends TestCase
|
|
|
'pass' => []
|
|
|
]);
|
|
|
|
|
|
- $app = $this->getMockForAbstractClass('Cake\Http\BaseApplication', [$this->path]);
|
|
|
+ $app = $this->getMockForAbstractClass(BaseApplication::class, [$this->path]);
|
|
|
$result = $app($request, $response, $next);
|
|
|
- $this->assertInstanceOf('Psr\Http\Message\ResponseInterface', $result);
|
|
|
+ $this->assertInstanceOf(ResponseInterface::class, $result);
|
|
|
$this->assertEquals('Hello Jane', '' . $result->getBody());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Ensure that plugins with no plugin class can be loaded.
|
|
|
+ * This makes adopting the new API easier
|
|
|
+ */
|
|
|
public function testAddPluginUnknownClass()
|
|
|
{
|
|
|
- $this->expectException(InvalidArgumentException::class);
|
|
|
- $this->expectExceptionMessage('cannot be found');
|
|
|
$app = $this->getMockForAbstractClass(BaseApplication::class, [$this->path]);
|
|
|
$app->addPlugin('SomethingBad');
|
|
|
+ $plugin = $app->getPlugins()->get('SomethingBad');
|
|
|
+ $this->assertInstanceOf(BasePlugin::class, $plugin);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Ensure that plugin interfaces are implemented.
|
|
|
+ */
|
|
|
public function testAddPluginBadClass()
|
|
|
{
|
|
|
$this->expectException(InvalidArgumentException::class);
|