diff --git a/src/Application/PresenterFactory.php b/src/Application/PresenterFactory.php index 97a828a3b..f67474ae8 100644 --- a/src/Application/PresenterFactory.php +++ b/src/Application/PresenterFactory.php @@ -99,10 +99,16 @@ public function getPresenterClass(& $name) public function setMapping(array $mapping) { foreach ($mapping as $module => $mask) { - if (!preg_match('#^\\\\?([\w\\\\]*\\\\)?(\w*\*\w*?\\\\)?([\w\\\\]*\*\w*)\z#', $mask, $m)) { - throw new Nette\InvalidStateException("Invalid mapping mask '$mask'."); + if (is_string($mask)) { + if (!preg_match('#^\\\\?([\w\\\\]*\\\\)?(\w*\*\w*?\\\\)?([\w\\\\]*\*\w*)\z#', $mask, $m)) { + throw new Nette\InvalidStateException("Invalid mapping mask '$mask'."); + } + $this->mapping[$module] = array($m[1], $m[2] ?: '*Module\\', $m[3]); + } elseif (is_array($mask) && count($mask) === 3) { + $this->mapping[$module] = array($mask[0] ? $mask[0] . '\\' : '', $mask[1] . '\\', $mask[2]); + } else { + throw new Nette\InvalidStateException("Invalid mapping mask for module $module."); } - $this->mapping[$module] = array($m[1], $m[2] ?: '*Module\\', $m[3]); } return $this; } diff --git a/src/Application/Responses/JsonResponse.php b/src/Application/Responses/JsonResponse.php index aece0e5b9..832b53660 100644 --- a/src/Application/Responses/JsonResponse.php +++ b/src/Application/Responses/JsonResponse.php @@ -61,7 +61,7 @@ public function getContentType() */ public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse) { - $httpResponse->setContentType($this->contentType); + $httpResponse->setContentType($this->contentType, 'utf-8'); $httpResponse->setExpiration(FALSE); echo Nette\Utils\Json::encode($this->payload); } diff --git a/src/Application/Routers/RouteList.php b/src/Application/Routers/RouteList.php index 4c1adbbf3..878913915 100644 --- a/src/Application/Routers/RouteList.php +++ b/src/Application/Routers/RouteList.php @@ -55,22 +55,7 @@ public function match(Nette\Http\IRequest $httpRequest) public function constructUrl(Nette\Application\Request $appRequest, Nette\Http\Url $refUrl) { if ($this->cachedRoutes === NULL) { - $routes = array(); - $routes['*'] = array(); - - foreach ($this as $route) { - $presenters = $route instanceof Route && is_array($tmp = $route->getTargetPresenters()) - ? $tmp : array_keys($routes); - - foreach ($presenters as $presenter) { - if (!isset($routes[$presenter])) { - $routes[$presenter] = $routes['*']; - } - $routes[$presenter][] = $route; - } - } - - $this->cachedRoutes = $routes; + $this->warmupCache(); } if ($this->module) { @@ -98,6 +83,29 @@ public function constructUrl(Nette\Application\Request $appRequest, Nette\Http\U } + /** @internal */ + public function warmupCache() + { + $routes = array(); + $routes['*'] = array(); + + foreach ($this as $route) { + $presenters = $route instanceof Route && is_array($tmp = $route->getTargetPresenters()) + ? $tmp + : array_keys($routes); + + foreach ($presenters as $presenter) { + if (!isset($routes[$presenter])) { + $routes[$presenter] = $routes['*']; + } + $routes[$presenter][] = $route; + } + } + + $this->cachedRoutes = $routes; + } + + /** * Adds the router. * @param mixed diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index ab4031a58..3cabb6920 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -873,7 +873,7 @@ protected function createRequest($component, $destination, array $args, $mode) throw new InvalidLinkException("Unknown signal '$signal', missing handler {$reflection->getName()}::$method()"); } // convert indexed parameters to named - self::argsToParams(get_class($component), $method, $args); + self::argsToParams(get_class($component), $method, $args, array(), $mode === 'test'); } // counterpart of IStatePersistent @@ -914,12 +914,8 @@ protected function createRequest($component, $destination, array $args, $mode) if (array_key_exists(0, $args)) { throw new InvalidLinkException("Unable to pass parameters to action '$presenter:$action', missing corresponding method."); } - - } elseif ($destination === 'this') { - self::argsToParams($presenterClass, $method, $args, $this->params); - } else { - self::argsToParams($presenterClass, $method, $args); + self::argsToParams($presenterClass, $method, $args, $destination === 'this' ? $this->params : array(), $mode === 'test'); } // counterpart of IStatePersistent @@ -1003,11 +999,12 @@ protected function createRequest($component, $destination, array $args, $mode) * @param string method name * @param array arguments * @param array supplemental arguments + * @param bool prevents 'Missing parameter' exception * @return void * @throws InvalidLinkException * @internal */ - public static function argsToParams($class, $method, & $args, $supplemental = array()) + public static function argsToParams($class, $method, & $args, $supplemental = array(), $ignoreMissing = FALSE) { $i = 0; $rm = new \ReflectionMethod($class, $method); @@ -1028,7 +1025,7 @@ public static function argsToParams($class, $method, & $args, $supplemental = ar } if (!isset($args[$name])) { - if ($param->isDefaultValueAvailable() || $type === 'NULL' || $type === 'array' || $isClass) { + if ($param->isDefaultValueAvailable() || $type === 'NULL' || $type === 'array' || $isClass || $ignoreMissing) { continue; } throw new InvalidLinkException("Missing parameter \$$name required by $class::{$rm->getName()}()"); diff --git a/src/Bridges/ApplicationDI/RoutingExtension.php b/src/Bridges/ApplicationDI/RoutingExtension.php index ea594d146..93f7e0e55 100644 --- a/src/Bridges/ApplicationDI/RoutingExtension.php +++ b/src/Bridges/ApplicationDI/RoutingExtension.php @@ -68,13 +68,17 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class) if (!empty($this->config['cache'])) { $method = $class->getMethod(Nette\DI\Container::getMethodName($this->prefix('router'))); try { - $router = serialize(eval($method->getBody())); + $router = eval($method->getBody()); + if ($router instanceof Nette\Application\Routers\RouteList) { + $router->warmupCache(); + } + $s = serialize($router); } catch (\Throwable $e) { throw new Nette\DI\ServiceCreationException('Unable to cache router due to error: ' . $e->getMessage(), 0, $e); } catch (\Exception $e) { throw new Nette\DI\ServiceCreationException('Unable to cache router due to error: ' . $e->getMessage(), 0, $e); } - $method->setBody('return unserialize(?);', array($router)); + $method->setBody('return unserialize(?);', array($s)); } } diff --git a/src/Bridges/ApplicationLatte/UIMacros.php b/src/Bridges/ApplicationLatte/UIMacros.php index 497bd27a9..3c0702231 100644 --- a/src/Bridges/ApplicationLatte/UIMacros.php +++ b/src/Bridges/ApplicationLatte/UIMacros.php @@ -76,7 +76,7 @@ public function macroControl(MacroNode $node, PhpWriter $writer) return ($name[0] === '$' ? "if (is_object($name)) \$_l->tmp = $name; else " : '') . '$_l->tmp = $_control->getComponent(' . $name . '); ' . 'if ($_l->tmp instanceof Nette\Application\UI\IRenderable) $_l->tmp->redrawControl(NULL, FALSE); ' - . ($node->modifiers === '' ? "\$_l->tmp->$method($param)" : $writer->write("ob_start(); \$_l->tmp->$method($param); echo %modify(ob_get_clean())")); + . ($node->modifiers === '' ? "\$_l->tmp->$method($param)" : $writer->write("ob_start(function () {}); \$_l->tmp->$method($param); echo %modify(ob_get_clean())")); } diff --git a/src/Bridges/ApplicationLatte/UIRuntime.php b/src/Bridges/ApplicationLatte/UIRuntime.php index a79f91183..14e26df3a 100644 --- a/src/Bridges/ApplicationLatte/UIRuntime.php +++ b/src/Bridges/ApplicationLatte/UIRuntime.php @@ -27,7 +27,7 @@ public static function renderSnippets(UI\Control $control, \stdClass $local, arr if ($name[0] !== '_' || !$control->isControlInvalid((string) substr($name, 1))) { continue; } - ob_start(); + ob_start(function () {}); $function = reset($function); $snippets = $function($local, $params + array('_snippetMode' => TRUE)); $payload->snippets[$id = $control->getSnippetId((string) substr($name, 1))] = ob_get_clean(); diff --git a/src/Bridges/ApplicationTracy/RoutingPanel.php b/src/Bridges/ApplicationTracy/RoutingPanel.php index c0cbd93a6..03652c693 100644 --- a/src/Bridges/ApplicationTracy/RoutingPanel.php +++ b/src/Bridges/ApplicationTracy/RoutingPanel.php @@ -65,7 +65,7 @@ public function __construct(Nette\Application\IRouter $router, Nette\Http\IReque public function getTab() { $this->analyse($this->router); - ob_start(); + ob_start(function () {}); $request = $this->request; require __DIR__ . '/templates/RoutingPanel.tab.phtml'; return ob_get_clean(); @@ -78,7 +78,7 @@ public function getTab() */ public function getPanel() { - ob_start(); + ob_start(function () {}); $request = $this->request; $routers = $this->routers; $source = $this->source; diff --git a/src/Bridges/ApplicationTracy/templates/RoutingPanel.panel.phtml b/src/Bridges/ApplicationTracy/templates/RoutingPanel.panel.phtml index 705bb4362..65a9e5585 100644 --- a/src/Bridges/ApplicationTracy/templates/RoutingPanel.panel.phtml +++ b/src/Bridges/ApplicationTracy/templates/RoutingPanel.panel.phtml @@ -59,7 +59,7 @@ use Tracy\Dumper;
$value): ?>
diff --git a/tests/Application/PresenterFactory.formatPresenterClass.phpt b/tests/Application/PresenterFactory.formatPresenterClass.phpt
index ef18fbbd6..cfbc0103c 100644
--- a/tests/Application/PresenterFactory.formatPresenterClass.phpt
+++ b/tests/Application/PresenterFactory.formatPresenterClass.phpt
@@ -49,3 +49,34 @@ test(function () {
Assert::same('My\App\BarPresenter', $factory->formatPresenterClass('Foo3:Bar'));
Assert::same('My\App\BarModule\BazPresenter', $factory->formatPresenterClass('Foo3:Bar:Baz'));
});
+
+
+test(function () {
+ $factory = new PresenterFactory;
+ $factory->setMapping(array(
+ '*' => array('App', 'Module\*', 'Presenter\*'),
+ ));
+ Assert::same('App\Module\Foo\Presenter\Bar', $factory->formatPresenterClass('Foo:Bar'));
+ Assert::same('App\Module\Universe\Module\Foo\Presenter\Bar', $factory->formatPresenterClass('Universe:Foo:Bar'));
+});
+
+
+test(function () {
+ $factory = new PresenterFactory;
+ $factory->setMapping(array(
+ '*' => array('', '*', '*'),
+ ));
+ Assert::same('Module\Foo\Bar', $factory->formatPresenterClass('Module:Foo:Bar'));
+});
+
+
+Assert::exception(
+ function () {
+ $factory = new PresenterFactory;
+ $factory->setMapping(array(
+ '*' => array('*', '*'),
+ ));
+ },
+ 'Nette\InvalidStateException',
+ 'Invalid mapping mask for module *.'
+);
diff --git a/tests/Bridges.Latte/Template.filters.phpt b/tests/Bridges.Latte/Template.filters.phpt
index 57c339c20..a6a6cca6f 100644
--- a/tests/Bridges.Latte/Template.filters.phpt
+++ b/tests/Bridges.Latte/Template.filters.phpt
@@ -14,13 +14,13 @@ $engine = new Latte\Engine;
$template = new Template($engine);
Assert::exception(function () use ($template) {
- @$template->length('abc');
-}, 'LogicException', "Filter 'length' is not defined.");
+ @$template->undefinedFilter('abc');
+}, 'LogicException', "Filter 'undefinedFilter' is not defined.");
-$engine->addFilter('length', 'strlen');
+$engine->addFilter('undefinedFilter', 'strlen');
-Assert::same(3, @$template->length('abc'));
+Assert::same(3, @$template->undefinedFilter('abc'));
Assert::error(function () use ($template) {
- $template->length('abc');
+ $template->undefinedFilter('abc');
}, E_USER_DEPRECATED, 'Invoking filters on Template object is deprecated, use getLatte()->invokeFilter().');
diff --git a/tests/Bridges.Latte/expected/UIMacros.dynamicsnippets.alt.phtml b/tests/Bridges.Latte/expected/UIMacros.dynamicsnippets.alt.phtml
index 8cf68b339..d191da14f 100644
--- a/tests/Bridges.Latte/expected/UIMacros.dynamicsnippets.alt.phtml
+++ b/tests/Bridges.Latte/expected/UIMacros.dynamicsnippets.alt.phtml
@@ -36,7 +36,7 @@ if (!function_exists($_b->blocks['_outer2'][] = '_%[a-z0-9]+%__outer2')) { funct
$_l->extends = empty($_g->extended) && isset($_control) && $_control instanceof Nette\Application\UI\Presenter ? $_control->findLayoutTemplateFile() : NULL; $_g->extended = TRUE;
-if ($_l->extends) { ob_start();}
+if ($_l->extends) { ob_start(%a?%);}
// prolog Nette\Bridges\ApplicationLatte\UIMacros
diff --git a/tests/Bridges.Latte/expected/UIMacros.dynamicsnippets.phtml b/tests/Bridges.Latte/expected/UIMacros.dynamicsnippets.phtml
index be1f5056e..70100788b 100644
--- a/tests/Bridges.Latte/expected/UIMacros.dynamicsnippets.phtml
+++ b/tests/Bridges.Latte/expected/UIMacros.dynamicsnippets.phtml
@@ -26,7 +26,7 @@ if (!function_exists($_b->blocks['_outer'][] = '_%[a-z0-9]+%__outer')) { functio
$_l->extends = empty($_g->extended) && isset($_control) && $_control instanceof Nette\Application\UI\Presenter ? $_control->findLayoutTemplateFile() : NULL; $_g->extended = TRUE;
-if ($_l->extends) { ob_start();}
+if ($_l->extends) { ob_start(%a?%);}
// prolog Nette\Bridges\ApplicationLatte\UIMacros
diff --git a/tests/Bridges.Latte/expected/UIMacros.snippet.alt.phtml b/tests/Bridges.Latte/expected/UIMacros.snippet.alt.phtml
index e3d541cdc..16d71f658 100644
--- a/tests/Bridges.Latte/expected/UIMacros.snippet.alt.phtml
+++ b/tests/Bridges.Latte/expected/UIMacros.snippet.alt.phtml
@@ -33,7 +33,7 @@ if (!function_exists($_b->blocks['_gallery'][] = '_%[a-z0-9]+%__gallery')) { fun
$_l->extends = empty($_g->extended) && isset($_control) && $_control instanceof Nette\Application\UI\Presenter ? $_control->findLayoutTemplateFile() : NULL; $_g->extended = TRUE;
-if ($_l->extends) { ob_start();}
+if ($_l->extends) { ob_start(%a?%);}
// prolog Nette\Bridges\ApplicationLatte\UIMacros
diff --git a/tests/Responses/JsonResponse.contentType.phpt b/tests/Responses/JsonResponse.contentType.phpt
new file mode 100644
index 000000000..b160215a6
--- /dev/null
+++ b/tests/Responses/JsonResponse.contentType.phpt
@@ -0,0 +1,28 @@
+ 'hello world');
+ $encoded = json_encode($data);
+ $jsonResponse = new JsonResponse($data, 'application/json');
+
+ ob_start();
+ $jsonResponse->send(new Http\Request(new Http\UrlScript), $response = new Http\Response);
+
+ Assert::same($encoded, ob_get_clean());
+ Assert::same('application/json; charset=utf-8', $response->getHeader('Content-Type'));
+});
diff --git a/tests/UI/MockPresenterFactory.php b/tests/UI/MockPresenterFactory.php
new file mode 100644
index 000000000..5611616d5
--- /dev/null
+++ b/tests/UI/MockPresenterFactory.php
@@ -0,0 +1,12 @@
+setScriptPath('/index.php');
diff --git a/tests/UI/Presenter.link().phpt b/tests/UI/Presenter.link().phpt
index e9c2be335..26a54be1f 100644
--- a/tests/UI/Presenter.link().phpt
+++ b/tests/UI/Presenter.link().phpt
@@ -10,6 +10,7 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
+require __DIR__ . '/MockPresenterFactory.php';
class TestControl extends Application\UI\Control
@@ -207,18 +208,6 @@ class OtherPresenter extends TestPresenter
}
-class MockPresenterFactory extends Nette\Object implements Nette\Application\IPresenterFactory
-{
- function getPresenterClass(& $name)
- {
- return str_replace(':', 'Module\\', $name) . 'Presenter';
- }
-
- function createPresenter($name)
- {}
-}
-
-
$url = new Http\UrlScript('http://localhost/index.php');
$url->setScriptPath('/index.php');
diff --git a/tests/UI/PresenterComponent.isLinkCurrent().asserts.php b/tests/UI/PresenterComponent.isLinkCurrent().asserts.php
new file mode 100644
index 000000000..07e60ad82
--- /dev/null
+++ b/tests/UI/PresenterComponent.isLinkCurrent().asserts.php
@@ -0,0 +1,340 @@
+setScriptPath('/index.php');
+
+ $presenter->injectPrimary(
+ NULL,
+ new MockPresenterFactory,
+ new Application\Routers\SimpleRouter,
+ new Http\Request($url),
+ new Http\Response
+ );
+ $presenter->run($request);
+
+ return $component->isLinkCurrent($destination, $args);
+}
+
+Assert::true(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, 'bool' => TRUE)),
+ 'Test:default',
+ array()
+));
+
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, 'bool' => TRUE)),
+ 'Test:default',
+ array('int' => 2)
+));
+
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array(Application\UI\Presenter::ACTION_KEY => 'otherAction')),
+ 'Test:default',
+ array()
+));
+
+Assert::true(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array(Application\UI\Presenter::ACTION_KEY => 'otherAction')),
+ 'Test:otherAction',
+ array()
+));
+
+Assert::true(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, 'bool' => TRUE)),
+ 'Test:default',
+ array('bool' => TRUE)
+));
+
+Assert::true(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, 'bool' => TRUE)),
+ 'Test:default',
+ array(
+ 'bool' => TRUE,
+ 'int' => 1,
+ )
+));
+
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, 'bool' => TRUE)),
+ 'Test:default',
+ array(
+ 'bool' => FALSE,
+ 'int' => 1,
+ )
+));
+
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, 'bool' => TRUE)),
+ 'Test:default',
+ array(
+ 'bool' => FALSE,
+ 'int' => 2,
+ )
+));
+
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, 'bool' => TRUE, Application\UI\Presenter::ACTION_KEY => 'otherAction')),
+ 'Test:default',
+ array(
+ 'bool' => TRUE,
+ 'int' => 1,
+ )
+));
+
+Assert::true(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, 'bool' => TRUE, Application\UI\Presenter::ACTION_KEY => 'otherAction')),
+ 'Test:otherAction',
+ array(
+ 'bool' => TRUE,
+ 'int' => 1,
+ )
+));
+
+Assert::true(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, 'bool' => TRUE)),
+ 'Test:*',
+ array()
+));
+
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, 'bool' => TRUE)),
+ 'Test:*',
+ array('float' => 1.0)
+));
+
+Assert::true(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, 'bool' => TRUE, 'float' => 1.0)),
+ 'Test:*',
+ array('float' => 1.0)
+));
+
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, 'bool' => TRUE, 'float' => 1.0)),
+ 'Test:*',
+ array('float' => 2.0)
+));
+
+Assert::true(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 1, Application\UI\Presenter::ACTION_KEY => 'otherAction')),
+ 'Test:*',
+ array(
+ 'int' => 1,
+ )
+));
+
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array('int' => 2, Application\UI\Presenter::ACTION_KEY => 'otherAction')),
+ 'Test:*',
+ array(
+ 'int' => 1,
+ )
+));
+
+Assert::true(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::SIGNAL_KEY => 'signal',
+ 'int' => 1,
+ 'bool' => TRUE,
+ )),
+ 'Test:default',
+ array()
+));
+
+Assert::true(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::SIGNAL_KEY => 'signal',
+ 'int' => 1,
+ 'bool' => TRUE,
+ )),
+ 'signal!',
+ array()
+));
+
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::SIGNAL_KEY => 'signal',
+ 'int' => 1,
+ 'bool' => TRUE,
+ )),
+ 'otherSignal!',
+ array()
+));
+
+
+// conflicting action in destination string and args
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::ACTION_KEY => 'default',
+ 'int' => 1,
+ 'bool' => TRUE,
+ )),
+ 'Test:default',
+ array(
+ Application\UI\Presenter::ACTION_KEY => 'otherAction',
+ )
+));
+
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::ACTION_KEY => 'default',
+ 'int' => 1,
+ 'bool' => TRUE,
+ )),
+ 'Test:otherAction',
+ array(
+ Application\UI\Presenter::ACTION_KEY => 'default',
+ )
+));
+
+
+// conflicting signal in destination string and args
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::SIGNAL_KEY => 'signal',
+ 'int' => 1,
+ 'bool' => TRUE,
+ )),
+ 'signal!',
+ array(
+ Application\UI\Presenter::SIGNAL_KEY => 'otherSignal',
+ )
+));
+
+Assert::false(callIsLinkCurrent(
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::SIGNAL_KEY => 'signal',
+ 'int' => 1,
+ 'bool' => TRUE,
+ )),
+ 'otherSignal!',
+ array(
+ Application\UI\Presenter::SIGNAL_KEY => 'signal',
+ )
+));
+
+
+// signal for nested component
+$testPresenter = new TestPresenter;
+$testControl = new TestControl;
+$testPresenter['test'] = $testControl;
+Assert::true(callIsComponentLinkCurrent(
+ $testPresenter,
+ $testControl,
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::SIGNAL_KEY => 'test-click',
+ 'int' => 1,
+ 'bool' => TRUE,
+ )),
+ 'click!',
+ array()
+));
+
+$testPresenter = new TestPresenter;
+$testControl = new TestControl;
+$testPresenter['test'] = $testControl;
+Assert::false(callIsComponentLinkCurrent(
+ $testPresenter,
+ $testControl,
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::SIGNAL_KEY => 'test-click',
+ 'int' => 1,
+ 'bool' => TRUE,
+ )),
+ 'otherSignal!',
+ array()
+));
+
+$testPresenter = new TestPresenter;
+$testControl = new TestControl;
+$testPresenter['test'] = $testControl;
+Assert::true(callIsComponentLinkCurrent(
+ $testPresenter,
+ $testControl,
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::SIGNAL_KEY => 'test-click',
+ 'int' => 1,
+ 'bool' => TRUE,
+ 'test-x' => 1,
+ )),
+ 'click!',
+ array(
+ 'x' => 1,
+ )
+));
+
+$testPresenter = new TestPresenter;
+$testControl = new TestControl;
+$testPresenter['test'] = $testControl;
+Assert::false(callIsComponentLinkCurrent(
+ $testPresenter,
+ $testControl,
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::SIGNAL_KEY => 'test-click',
+ 'int' => 1,
+ 'bool' => TRUE,
+ 'test-x' => 1,
+ )),
+ 'click!',
+ array(
+ 'x' => 2,
+ )
+));
+
+$testPresenter = new TestPresenter;
+$testControlWithAnotherTestControl = new TestControl;
+$testPresenter['test'] = $testControlWithAnotherTestControl;
+$testControlWithAnotherTestControl['test'] = new TestControl;
+Assert::true(callIsComponentLinkCurrent(
+ $testPresenter,
+ $testControlWithAnotherTestControl,
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::SIGNAL_KEY => 'test-test-click',
+ 'int' => 1,
+ 'bool' => TRUE,
+ 'test-test-x' => 1,
+ )),
+ 'test:click!',
+ array(
+ 'x' => 1,
+ )
+));
+
+$testPresenter = new TestPresenter;
+$testControlWithAnotherTestControl = new TestControl;
+$testPresenter['test'] = $testControlWithAnotherTestControl;
+$testControlWithAnotherTestControl['test'] = new TestControl;
+Assert::false(callIsComponentLinkCurrent(
+ $testPresenter,
+ $testControlWithAnotherTestControl,
+ new Application\Request('Test', Http\Request::GET, array(
+ Application\UI\Presenter::SIGNAL_KEY => 'test-test-click',
+ 'int' => 1,
+ 'bool' => TRUE,
+ 'test-test-x' => 1,
+ )),
+ 'test:click!',
+ array(
+ 'x' => 2,
+ )
+));
diff --git a/tests/UI/PresenterComponent.isLinkCurrent().php7.phpt b/tests/UI/PresenterComponent.isLinkCurrent().php7.phpt
new file mode 100644
index 000000000..2a2c7defc
--- /dev/null
+++ b/tests/UI/PresenterComponent.isLinkCurrent().php7.phpt
@@ -0,0 +1,43 @@
+