Skip to content
Permalink
Browse files

Response is not nullable

  • Loading branch information...
mabar authored and f3l1x committed Jul 5, 2019
1 parent 455dddf commit bcc35c0788b6b1f114bd65dcfb6a416bf02d6566
@@ -12,10 +12,10 @@ class PresenterShutdownEvent extends Event
/** @var Presenter */
private $presenter;
/** @var IResponse|null */
/** @var IResponse */
private $response;
public function __construct(Presenter $presenter, ?IResponse $response = null)
public function __construct(Presenter $presenter, IResponse $response)
{
$this->presenter = $presenter;
$this->response = $response;
@@ -26,7 +26,7 @@ public function getPresenter(): Presenter
return $this->presenter;
}
public function getResponse(): ?IResponse
public function getResponse(): IResponse
{
return $this->response;
}
@@ -7,6 +7,7 @@
use Contributte\EventDispatcher\DI\EventDispatcherExtension;
use Contributte\Events\Extra\DI\EventApplicationBridgeExtension;
use Nette\Application\Application;
use Nette\Application\Responses\VoidResponse;
use Nette\Bridges\ApplicationDI\ApplicationExtension;
use Nette\Bridges\HttpDI\HttpExtension;
use Nette\DI\Compiler;
@@ -67,7 +68,8 @@ test(function (): void {
$presenter = new FakePresenter();
$application->onPresenter($application, $presenter);
$presenter->onStartup($presenter);
$presenter->onShutdown($presenter, null);
$response = new VoidResponse();
$presenter->onShutdown($presenter, $response);
/** @var FakePresenterStartupSubscriber $presenterStartupSubscriber */
$presenterStartupSubscriber = $container->getByType(FakePresenterStartupSubscriber::class);
@@ -78,5 +80,5 @@ test(function (): void {
$presenterShutdownSubscriber = $container->getByType(FakePresenterShutdownSubscriber::class);
Assert::count(1, $presenterShutdownSubscriber->onCall);
Assert::same($presenter, $presenterShutdownSubscriber->onCall[0]->getPresenter());
Assert::null($presenterShutdownSubscriber->onCall[0]->getResponse());
Assert::same($response, $presenterShutdownSubscriber->onCall[0]->getResponse());
});
@@ -2,11 +2,7 @@
namespace Tests\Fixtures;
use Nette\Application\IPresenter;
use Nette\Application\IResponse;
use Nette\Application\Request;
use Nette\Application\UI\Presenter;
use Nette\SmartObject;
class FakePresenter extends Presenter
{

0 comments on commit bcc35c0

Please sign in to comment.
You can’t perform that action at this time.