From 1e947c745590e455459878cc10c67091e3f2774e Mon Sep 17 00:00:00 2001 From: David Matejka Date: Fri, 24 Jul 2015 22:15:39 +0200 Subject: [PATCH] Presenter: added test for initGlobalParameters --- tests/Application/Presenter.parameters.phpt | 89 +++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 tests/Application/Presenter.parameters.phpt diff --git a/tests/Application/Presenter.parameters.phpt b/tests/Application/Presenter.parameters.phpt new file mode 100644 index 000000000..e349ae917 --- /dev/null +++ b/tests/Application/Presenter.parameters.phpt @@ -0,0 +1,89 @@ +ajax; + } + + + protected function startup() + { + parent::startup(); + throw new Application\AbortException(); + } + + +} + + +function createPresenter() +{ + $presenter = new TestPresenter(); + $presenter->injectPrimary(NULL, NULL, NULL, new Http\Request(new Http\UrlScript()), new Http\Response()); + $presenter->autoCanonicalize = FALSE; + return $presenter; +} + + +test(function () { + //signal in GET + $presenter = createPresenter(); + $presenter->run(new Application\Request('Foo', 'GET', array( + 'do' => 'foo' + ))); + Assert::same(array('', 'foo'), $presenter->getSignal()); +}); + +test(function () { + //signal for subcomponent in GET + $presenter = createPresenter(); + $presenter->run(new Application\Request('Foo', 'GET', array( + 'do' => 'foo-bar' + ))); + Assert::same(array('foo', 'bar'), $presenter->getSignal()); +}); + +test(function () { + //signal in POST + $presenter = createPresenter(); + $presenter->run(new Application\Request('Foo', 'POST', array(), array( + 'do' => 'foo' + ))); + Assert::same(array('', 'foo'), $presenter->getSignal()); +}); + +test(function () { + //signal in POST overwriting empty GET + $presenter = createPresenter(); + $presenter->run(new Application\Request('Foo', 'POST', array('do' => NULL), array( + 'do' => 'foo' + ))); + Assert::same(array('', 'foo'), $presenter->getSignal()); +}); + +test(function () { + //AJAX: signal in POST + $presenter = createPresenter(); + $presenter->ajax = TRUE; + $presenter->run(new Application\Request('Foo', 'POST', array(), array( + 'do' => 'foo' + ))); + Assert::same(array('', 'foo'), $presenter->getSignal()); +});