mirror of
https://github.com/flarum/framework.git
synced 2024-11-30 13:36:10 +08:00
Integration tests: Memoize request handler as well
This is useful to send HTTP requests (or their PSR-7 equivalents) through the entire application's middleware stack (instead of talking to specific controllers, which should be considered implementation detail).
This commit is contained in:
parent
5632ffb62b
commit
a7259bbd5f
|
@ -24,27 +24,36 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
||||||
$this->app();
|
$this->app();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Flarum\Foundation\InstalledApp
|
||||||
|
*/
|
||||||
protected $app;
|
protected $app;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Psr\Http\Server\RequestHandlerInterface
|
||||||
|
*/
|
||||||
|
protected $server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Flarum\Foundation\InstalledApp
|
* @return \Flarum\Foundation\InstalledApp
|
||||||
*/
|
*/
|
||||||
protected function app()
|
protected function app()
|
||||||
{
|
{
|
||||||
if (! is_null($this->app)) {
|
if (is_null($this->app)) {
|
||||||
return $this->app;
|
$site = new InstalledSite(
|
||||||
|
[
|
||||||
|
'base' => __DIR__.'/tmp',
|
||||||
|
'public' => __DIR__.'/tmp/public',
|
||||||
|
'storage' => __DIR__.'/tmp/storage',
|
||||||
|
],
|
||||||
|
include __DIR__.'/tmp/config.php'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->app = $site->bootApp();
|
||||||
|
$this->server = $this->app->getRequestHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
$site = new InstalledSite(
|
return $this->app;
|
||||||
[
|
|
||||||
'base' => __DIR__.'/tmp',
|
|
||||||
'public' => __DIR__.'/tmp/public',
|
|
||||||
'storage' => __DIR__.'/tmp/storage',
|
|
||||||
],
|
|
||||||
include __DIR__.'/tmp/config.php'
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->app = $site->bootApp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $database;
|
protected $database;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user