From b7676b52c5e3595a6dde3e84026d87c66b7f398d Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 20 May 2015 15:19:22 +0200 Subject: [PATCH 01/11] opened v2.3 --- composer.json | 7 +------ readme.md | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 7ca3e37a1..dc7cff93a 100644 --- a/composer.json +++ b/composer.json @@ -38,10 +38,5 @@ "autoload": { "classmap": ["src/"] }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - } + "minimum-stability": "dev" } diff --git a/readme.md b/readme.md index 134253809..8e92dcb97 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ Nette Application MVC ===================== [![Downloads this Month](https://img.shields.io/packagist/dm/nette/application.svg)](https://packagist.org/packages/nette/application) -[![Build Status](https://travis-ci.org/nette/application.svg?branch=master)](https://travis-ci.org/nette/application) +[![Build Status](https://travis-ci.org/nette/application.svg?branch=v2.3)](https://travis-ci.org/nette/application) Model-View-Controller is a software architecture that was created to satisfy the need to separate utility code (controller) from application logic code (model) and from code for displaying data (view) in applications with graphical user interface. With this approach we make the application better understandable, simplify future development and enable testing each unit of the application separately. From bded03778fa1a2c4a4c72b62b74c9d427c4e83af Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 21 May 2015 15:02:10 +0200 Subject: [PATCH 02/11] UIMacros: Latte 2.4 generates short array syntax --- composer.json | 2 +- src/Bridges/ApplicationLatte/UIMacros.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index dc7cff93a..c84468f31 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "nette/di": "~2.3", "nette/forms": "~2.2", "nette/robot-loader": "~2.2", - "latte/latte": "~2.3" + "latte/latte": "~2.3.0" }, "conflict": { "nette/nette": "<2.2" diff --git a/src/Bridges/ApplicationLatte/UIMacros.php b/src/Bridges/ApplicationLatte/UIMacros.php index 853d03589..3039dcdfd 100644 --- a/src/Bridges/ApplicationLatte/UIMacros.php +++ b/src/Bridges/ApplicationLatte/UIMacros.php @@ -73,7 +73,7 @@ public function macroControl(MacroNode $node, PhpWriter $writer) $method = Strings::match($method, '#^\w*\z#') ? "render$method" : "{\"render$method\"}"; $param = $writer->formatArray(); if (!Strings::contains($node->args, '=>')) { - $param = substr($param, 6, -1); // removes array() + $param = substr($param, $param[0] === '[' ? 1 : 6, -1); // removes array() or [] } return ($name[0] === '$' ? "if (is_object($name)) \$_l->tmp = $name; else " : '') . '$_l->tmp = $_control->getComponent(' . $name . '); ' From c9b98e07e484b54e487de44b0da52f52bd0cb871 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 17 Jun 2015 14:15:24 +0200 Subject: [PATCH 03/11] ApplicationExtension: missing RobotLoader throws exception [Closes #78] --- src/Bridges/ApplicationDI/ApplicationExtension.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Bridges/ApplicationDI/ApplicationExtension.php b/src/Bridges/ApplicationDI/ApplicationExtension.php index cad62518c..3d609b757 100644 --- a/src/Bridges/ApplicationDI/ApplicationExtension.php +++ b/src/Bridges/ApplicationDI/ApplicationExtension.php @@ -123,6 +123,9 @@ private function findPresenters() $classes = array(); if ($config['scanDirs']) { + if (!class_exists('Nette\Loaders\RobotLoader')) { + throw new Nette\NotSupportedException("RobotLoader is required to find presenters, install package `nette/robot-loader` or disable option {$this->prefix('scanDirs')}: false"); + } $robot = new Nette\Loaders\RobotLoader; $robot->setCacheStorage(new Nette\Caching\Storages\DevNullStorage); $robot->addDirectory($config['scanDirs']); From 10f0fa6ca9095398b0efcf63f81a06ff818c276b Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 18 Jun 2015 16:31:27 +0200 Subject: [PATCH 04/11] improved coding style --- src/Application/Application.php | 12 +- src/Application/ErrorPresenter.php | 6 +- src/Application/MicroPresenter.php | 10 +- src/Application/PresenterFactory.php | 4 +- .../Responses/RedirectResponse.php | 4 +- src/Application/Routers/CliRouter.php | 4 +- src/Application/Routers/Route.php | 6 +- src/Application/Routers/SimpleRouter.php | 4 +- src/Application/UI/Presenter.php | 49 ++-- .../UI/PresenterComponentReflection.php | 18 +- .../ApplicationDI/ApplicationExtension.php | 6 +- src/Bridges/ApplicationDI/LatteExtension.php | 8 +- .../ApplicationDI/RoutingExtension.php | 2 +- .../ApplicationLatte/ILatteFactory.php | 4 +- src/Bridges/ApplicationLatte/Loader.php | 4 +- src/Bridges/ApplicationLatte/Template.php | 6 +- .../ApplicationLatte/TemplateFactory.php | 12 +- src/Bridges/ApplicationLatte/UIMacros.php | 14 +- src/Bridges/ApplicationTracy/RoutingPanel.php | 16 +- .../ApplicationExtension.basic.phpt | 14 +- .../ApplicationExtension.invalidLink.phpt | 16 +- .../ApplicationExtension.scan.phpt | 32 +-- .../Application.DI/LatteExtension.basic.phpt | 6 +- .../RoutingExtension.basic.phpt | 8 +- .../RoutingExtension.cache.phpt | 19 +- tests/Application.Latte/Template.filters.phpt | 6 +- .../TemplateFactory.filters.phpt | 36 +-- .../TemplateFactory.onCompile.phpt | 18 +- .../Application.Latte/UIMacros.control.2.phpt | 52 ++-- tests/Application.Latte/UIMacros.control.phpt | 22 +- .../UIMacros.dynamicsnippets.alt.phpt | 4 +- .../UIMacros.dynamicsnippets.phpt | 4 +- .../UIMacros.isLinkCurrent.phpt | 4 +- tests/Application.Latte/UIMacros.link.2.phpt | 7 +- tests/Application.Latte/UIMacros.link.phpt | 28 +- .../UIMacros.renderSnippets.extends.phpt | 6 +- .../UIMacros.renderSnippets.phpt | 6 +- .../UIMacros.renderSnippets2.phpt | 6 +- .../UIMacros.snippet.alt.phpt | 6 +- tests/Application.Latte/UIMacros.snippet.phpt | 6 +- .../Application.Latte/UIMacros.snippet1.phpt | 4 +- .../Application.Latte/UIMacros.snippet2.phpt | 4 +- .../Application.Latte/UIMacros.snippet3.phpt | 4 +- .../CliRouter.invalid.phpt | 8 +- tests/Application.Routers/CliRouter.phpt | 16 +- tests/Application.Routers/LinkGenerator.phpt | 8 +- .../Route.arrayParams.phpt | 4 +- tests/Application.Routers/Route.basic.phpt | 12 +- .../Route.camelcapsVsDash.phpt | 4 +- .../Route.combinedUrlParam.phpt | 4 +- .../Route.extraDefaultParam.phpt | 4 +- .../Route.filter.global.phpt | 8 +- .../Route.filter.query.phpt | 8 +- .../Route.filter.url.object.phpt | 10 +- .../Application.Routers/Route.filter.url.phpt | 8 +- .../Route.filterTable.query.phpt | 4 +- .../Route.filterTable.strict.phpt | 4 +- .../Route.filterTable.url.phpt | 4 +- .../Route.firstOptionalParam.phpt | 4 +- .../Route.fooParameter.default.phpt | 4 +- .../Route.fooParameter.phpt | 4 +- .../Route.fullMatchParam.phpt | 4 +- tests/Application.Routers/Route.inc | 12 +- .../Route.longParameter.phpt | 4 +- .../Route.mandatoryAction.phpt | 4 +- tests/Application.Routers/Route.modules.phpt | 28 +- .../Route.noDefaultParams.phpt | 4 +- tests/Application.Routers/Route.noParams.phpt | 4 +- tests/Application.Routers/Route.oneWay.phpt | 4 +- .../Route.optional.autooptional1.phpt | 4 +- .../Route.optional.autooptional2.phpt | 4 +- .../Route.optional.module.phpt | 4 +- .../Route.optional.nested.phpt | 4 +- tests/Application.Routers/Route.optional.phpt | 4 +- .../Route.optional.precedence.phpt | 4 +- .../Route.optional.preferred.nested1.phpt | 4 +- .../Route.optional.preferred.nested2.phpt | 4 +- .../Route.optional.preferred.nested3.phpt | 4 +- .../Route.optional.preferred.phpt | 4 +- .../Route.optional.regexp.phpt | 4 +- tests/Application.Routers/Route.secured.phpt | 4 +- tests/Application.Routers/Route.slash.phpt | 6 +- tests/Application.Routers/Route.type.phpt | 6 +- .../Route.urlEncoding.phpt | 4 +- .../Application.Routers/Route.utf8Param.phpt | 4 +- .../Application.Routers/Route.variables.phpt | 4 +- .../Route.withAbsolutePath.phpt | 4 +- .../Route.withDefaultPresenterAndAction.phpt | 4 +- tests/Application.Routers/Route.withHost.phpt | 4 +- .../Route.withNamedParamsInQuery.phpt | 4 +- .../Route.withParamsInQuery.phpt | 4 +- .../Route.withUserClassAlt.phpt | 4 +- .../Application.Routers/RouteList.basic.phpt | 6 +- .../SimpleRouter.invalid.phpt | 14 +- .../SimpleRouter.module.phpt | 12 +- tests/Application.Routers/SimpleRouter.phpt | 18 +- .../SimpleRouter.secured.phpt | 8 +- .../Presenter.formatLayoutTemplateFiles.phpt | 28 +- .../Presenter.formatTemplateFiles.phpt | 28 +- .../Application/Control.isControlInvalid.phpt | 8 +- .../FileResponse.contentDisposition.phpt | 20 +- tests/Application/FileResponse.full.phpt | 10 +- tests/Application/FileResponse.range.phpt | 42 +-- tests/Application/Form.phpt | 8 +- tests/Application/MicroPresenter.invoke.phpt | 14 +- .../Application/MicroPresenter.response.phpt | 246 +++++++++--------- tests/Application/Presenter.link().phpt | 106 ++++---- .../Application/Presenter.paramChecking.phpt | 28 +- .../Application/Presenter.storeRequest().phpt | 12 +- .../PresenterComponent.redirect().phpt | 16 +- ...erComponentReflection.parseAnnotation.phpt | 4 +- ...PresenterFactory.formatPresenterClass.phpt | 36 +-- ...esenterFactory.unformatPresenterClass.phpt | 42 +-- tests/Application/Request.phpt | 18 +- 114 files changed, 758 insertions(+), 751 deletions(-) diff --git a/src/Application/Application.php b/src/Application/Application.php index d7cb9992e..08235c8a7 100644 --- a/src/Application/Application.php +++ b/src/Application/Application.php @@ -31,22 +31,22 @@ class Application extends Nette\Object /** @var string */ public $errorPresenter; - /** @var callable[] function(Application $sender); Occurs before the application loads presenter */ + /** @var callable[] function (Application $sender); Occurs before the application loads presenter */ public $onStartup; - /** @var callable[] function(Application $sender, \Exception $e = NULL); Occurs before the application shuts down */ + /** @var callable[] function (Application $sender, \Exception $e = NULL); Occurs before the application shuts down */ public $onShutdown; - /** @var callable[] function(Application $sender, Request $request); Occurs when a new request is received */ + /** @var callable[] function (Application $sender, Request $request); Occurs when a new request is received */ public $onRequest; - /** @var callable[] function(Application $sender, Presenter $presenter); Occurs when a presenter is created */ + /** @var callable[] function (Application $sender, Presenter $presenter); Occurs when a presenter is created */ public $onPresenter; - /** @var callable[] function(Application $sender, IResponse $response); Occurs when a new response is ready for dispatch */ + /** @var callable[] function (Application $sender, IResponse $response); Occurs when a new response is ready for dispatch */ public $onResponse; - /** @var callable[] function(Application $sender, \Exception $e); Occurs when an unhandled exception occurs in the application */ + /** @var callable[] function (Application $sender, \Exception $e); Occurs when an unhandled exception occurs in the application */ public $onError; /** @var Request[] */ diff --git a/src/Application/ErrorPresenter.php b/src/Application/ErrorPresenter.php index 24a925fe7..1eb0c8884 100644 --- a/src/Application/ErrorPresenter.php +++ b/src/Application/ErrorPresenter.php @@ -7,9 +7,9 @@ namespace NetteModule; -use Nette, - Nette\Application, - Tracy\ILogger; +use Nette; +use Nette\Application; +use Tracy\ILogger; /** diff --git a/src/Application/MicroPresenter.php b/src/Application/MicroPresenter.php index 2bb1dbe8e..b61ae9ed6 100644 --- a/src/Application/MicroPresenter.php +++ b/src/Application/MicroPresenter.php @@ -7,11 +7,11 @@ namespace NetteModule; -use Nette, - Nette\Application, - Nette\Application\Responses, - Nette\Http, - Latte; +use Nette; +use Nette\Application; +use Nette\Application\Responses; +use Nette\Http; +use Latte; /** diff --git a/src/Application/PresenterFactory.php b/src/Application/PresenterFactory.php index e2005a351..e86b5e63a 100644 --- a/src/Application/PresenterFactory.php +++ b/src/Application/PresenterFactory.php @@ -34,11 +34,11 @@ class PresenterFactory extends Nette\Object implements IPresenterFactory /** - * @param callable function(string $class): IPresenter + * @param callable function (string $class): IPresenter */ public function __construct($factory = NULL) { - $this->factory = $factory ?: function($class) { return new $class; }; + $this->factory = $factory ?: function ($class) { return new $class; }; } diff --git a/src/Application/Responses/RedirectResponse.php b/src/Application/Responses/RedirectResponse.php index 03a71855f..dffb96efe 100644 --- a/src/Application/Responses/RedirectResponse.php +++ b/src/Application/Responses/RedirectResponse.php @@ -7,8 +7,8 @@ namespace Nette\Application\Responses; -use Nette, - Nette\Http; +use Nette; +use Nette\Http; /** diff --git a/src/Application/Routers/CliRouter.php b/src/Application/Routers/CliRouter.php index af87938bf..fbb89c538 100644 --- a/src/Application/Routers/CliRouter.php +++ b/src/Application/Routers/CliRouter.php @@ -7,8 +7,8 @@ namespace Nette\Application\Routers; -use Nette, - Nette\Application; +use Nette; +use Nette\Application; /** diff --git a/src/Application/Routers/Route.php b/src/Application/Routers/Route.php index 09825e7f9..89e888269 100644 --- a/src/Application/Routers/Route.php +++ b/src/Application/Routers/Route.php @@ -7,9 +7,9 @@ namespace Nette\Application\Routers; -use Nette, - Nette\Application, - Nette\Utils\Strings; +use Nette; +use Nette\Application; +use Nette\Utils\Strings; /** diff --git a/src/Application/Routers/SimpleRouter.php b/src/Application/Routers/SimpleRouter.php index 23dc97b5c..708755510 100644 --- a/src/Application/Routers/SimpleRouter.php +++ b/src/Application/Routers/SimpleRouter.php @@ -7,8 +7,8 @@ namespace Nette\Application\Routers; -use Nette, - Nette\Application; +use Nette; +use Nette\Application; /** diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index 4504d1181..a9986f3eb 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -7,10 +7,10 @@ namespace Nette\Application\UI; -use Nette, - Nette\Application, - Nette\Application\Responses, - Nette\Http; +use Nette; +use Nette\Application; +use Nette\Application\Responses; +use Nette\Http; /** @@ -48,7 +48,7 @@ abstract class Presenter extends Control implements Application\IPresenter /** @var int */ public $invalidLinkMode; - /** @var callable[] function(Presenter $sender, IResponse $response = NULL); Occurs when the presenter is shutting down */ + /** @var callable[] function (Presenter $sender, IResponse $response = NULL); Occurs when the presenter is shutting down */ public $onShutdown; /** @var Nette\Application\Request */ @@ -225,17 +225,20 @@ public function run(Application\Request $request) } catch (Application\AbortException $e) { // continue with shutting down - if ($this->isAjax()) try { - $hasPayload = (array) $this->payload; unset($hasPayload['state']); - if ($this->response instanceof Responses\TextResponse && $this->isControlInvalid()) { - $this->snippetMode = TRUE; - $this->response->send($this->httpRequest, $this->httpResponse); - $this->sendPayload(); - - } elseif (!$this->response && $hasPayload) { // back compatibility for use terminate() instead of sendPayload() + if ($this->isAjax()) { + try { + $hasPayload = (array) $this->payload; + unset($hasPayload['state']); + if ($this->response instanceof Responses\TextResponse && $this->isControlInvalid()) { + $this->snippetMode = TRUE; + $this->response->send($this->httpRequest, $this->httpResponse); + $this->sendPayload(); + } elseif (!$this->response && $hasPayload) { // back compatibility for use terminate() instead of sendPayload() $this->sendPayload(); + } + } catch (Application\AbortException $e) { } - } catch (Application\AbortException $e) { } + } if ($this->hasFlashSession()) { $this->getFlashSession()->setExpiration($this->response instanceof Responses\RedirectResponse ? '+ 30 seconds' : '+ 3 seconds'); @@ -314,7 +317,8 @@ public function processSignal() try { $component = $this->signalReceiver === '' ? $this : $this->getComponent($this->signalReceiver, FALSE); - } catch (Nette\InvalidArgumentException $e) {} + } catch (Nette\InvalidArgumentException $e) { + } if (isset($e) || $component === NULL) { throw new BadSignalException("The signal receiver component '$this->signalReceiver' is not found.", NULL, isset($e) ? $e : NULL); @@ -602,7 +606,7 @@ public function sendPayload() /** * Sends JSON data to the output. - * @param mixed $data + * @param mixed * @return void * @throws Nette\Application\AbortException */ @@ -735,7 +739,8 @@ public function canonicalize() if (!$this->isAjax() && ($this->request->isMethod('get') || $this->request->isMethod('head'))) { try { $url = $this->createRequest($this, $this->action, $this->getGlobalState() + $this->request->getParameters(), 'redirectX'); - } catch (InvalidLinkException $e) {} + } catch (InvalidLinkException $e) { + } if (isset($url) && !$this->httpRequest->getUrl()->isEqual($url)) { $this->sendResponse(new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY)); } @@ -806,7 +811,7 @@ protected function createRequest($component, $destination, array $args, $mode) } // 4) signal or empty - if (!$component instanceof Presenter || substr($destination, -1) === '!') { + if (!$component instanceof self || substr($destination, -1) === '!') { $signal = rtrim($destination, '!'); $a = strrpos($signal, ':'); if ($a !== FALSE) { @@ -814,13 +819,13 @@ protected function createRequest($component, $destination, array $args, $mode) $signal = (string) substr($signal, $a + 1); } if ($signal == NULL) { // intentionally == - throw new InvalidLinkException("Signal must be non-empty string."); + throw new InvalidLinkException('Signal must be non-empty string.'); } $destination = 'this'; } if ($destination == NULL) { // intentionally == - throw new InvalidLinkException("Destination must be non-empty string."); + throw new InvalidLinkException('Destination must be non-empty string.'); } // 5) presenter: action @@ -1314,7 +1319,7 @@ public function injectPrimary(Nette\DI\Container $context = NULL, Application\IP Http\IRequest $httpRequest, Http\IResponse $httpResponse, Http\Session $session = NULL, Nette\Security\User $user = NULL, ITemplateFactory $templateFactory = NULL) { if ($this->presenterFactory !== NULL) { - throw new Nette\InvalidStateException("Method " . __METHOD__ . " is intended for initialization and should not be called more than once."); + throw new Nette\InvalidStateException('Method ' . __METHOD__ . ' is intended for initialization and should not be called more than once.'); } $this->context = $context; @@ -1368,7 +1373,7 @@ public function getSession($namespace = NULL) { if (!$this->session) { throw new Nette\InvalidStateException('Service Session has not been set.'); - } + } return $namespace === NULL ? $this->session : $this->session->getSection($namespace); } diff --git a/src/Application/UI/PresenterComponentReflection.php b/src/Application/UI/PresenterComponentReflection.php index 69497ae80..79509b973 100644 --- a/src/Application/UI/PresenterComponentReflection.php +++ b/src/Application/UI/PresenterComponentReflection.php @@ -7,8 +7,8 @@ namespace Nette\Application\UI; -use Nette, - Nette\Application\BadRequestException; +use Nette; +use Nette\Application\BadRequestException; /** @@ -101,11 +101,13 @@ public function hasCallableMethod($method) { $class = $this->getName(); $cache = & self::$mcCache[strtolower($class . ':' . $method)]; - if ($cache === NULL) try { - $cache = FALSE; - $rm = new \ReflectionMethod($class, $method); - $cache = $this->isInstantiable() && $rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic(); - } catch (\ReflectionException $e) { + if ($cache === NULL) { + try { + $cache = FALSE; + $rm = new \ReflectionMethod($class, $method); + $cache = $this->isInstantiable() && $rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic(); + } catch (\ReflectionException $e) { + } } return $cache; } @@ -123,7 +125,7 @@ public static function combineArgs(\ReflectionFunctionAbstract $method, $args) if (isset($args[$name])) { // NULLs are ignored $res[$i++] = $args[$name]; $type = $param->isArray() ? 'array' : ($param->isDefaultValueAvailable() ? gettype($param->getDefaultValue()) : 'NULL'); - if (!self::convertType($res[$i-1], $type)) { + if (!self::convertType($res[$i - 1], $type)) { $mName = $method instanceof \ReflectionMethod ? $method->getDeclaringClass()->getName() . '::' . $method->getName() : $method->getName(); throw new BadRequestException("Invalid value for parameter '$name' in method $mName(), expected " . ($type === 'NULL' ? 'scalar' : $type) . "."); } diff --git a/src/Bridges/ApplicationDI/ApplicationExtension.php b/src/Bridges/ApplicationDI/ApplicationExtension.php index 3d609b757..2ade892b9 100644 --- a/src/Bridges/ApplicationDI/ApplicationExtension.php +++ b/src/Bridges/ApplicationDI/ApplicationExtension.php @@ -7,8 +7,8 @@ namespace Nette\Bridges\ApplicationDI; -use Nette, - Nette\Application\UI; +use Nette; +use Nette\Application\UI; /** @@ -140,7 +140,7 @@ private function findPresenters() $classFile = dirname($rc->getFileName()) . '/autoload_classmap.php'; if (is_file($classFile)) { $this->getContainerBuilder()->addDependency($classFile); - $classes = array_merge($classes, array_keys(call_user_func(function($path) { + $classes = array_merge($classes, array_keys(call_user_func(function ($path) { return require $path; }, $classFile))); } diff --git a/src/Bridges/ApplicationDI/LatteExtension.php b/src/Bridges/ApplicationDI/LatteExtension.php index 2f6d40d90..d7c095219 100644 --- a/src/Bridges/ApplicationDI/LatteExtension.php +++ b/src/Bridges/ApplicationDI/LatteExtension.php @@ -7,8 +7,8 @@ namespace Nette\Bridges\ApplicationDI; -use Nette, - Latte; +use Nette; +use Latte; /** @@ -101,10 +101,10 @@ public function addMacro($macro) $container = $this->getContainerBuilder(); $container->getDefinition('nette.latte') - ->addSetup('?->onCompile[] = function($engine) { ' . $macro . '($engine->getCompiler()); }', array('@self')); + ->addSetup('?->onCompile[] = function ($engine) { ' . $macro . '($engine->getCompiler()); }', array('@self')); $container->getDefinition($this->prefix('latteFactory')) - ->addSetup('?->onCompile[] = function($engine) { ' . $macro . '($engine->getCompiler()); }', array('@self')); + ->addSetup('?->onCompile[] = function ($engine) { ' . $macro . '($engine->getCompiler()); }', array('@self')); } } diff --git a/src/Bridges/ApplicationDI/RoutingExtension.php b/src/Bridges/ApplicationDI/RoutingExtension.php index 02f1df48d..6d3c158f1 100644 --- a/src/Bridges/ApplicationDI/RoutingExtension.php +++ b/src/Bridges/ApplicationDI/RoutingExtension.php @@ -58,7 +58,7 @@ public function beforeCompile() if ($this->debugMode && $this->config['debugger'] && $application = $container->getByType('Nette\Application\Application')) { $container->getDefinition($application)->addSetup('@Tracy\Bar::addPanel', array( - new Nette\DI\Statement('Nette\Bridges\ApplicationTracy\RoutingPanel') + new Nette\DI\Statement('Nette\Bridges\ApplicationTracy\RoutingPanel'), )); } } diff --git a/src/Bridges/ApplicationLatte/ILatteFactory.php b/src/Bridges/ApplicationLatte/ILatteFactory.php index ac3df059e..87d942185 100644 --- a/src/Bridges/ApplicationLatte/ILatteFactory.php +++ b/src/Bridges/ApplicationLatte/ILatteFactory.php @@ -7,8 +7,8 @@ namespace Nette\Bridges\ApplicationLatte; -use Nette, - Latte; +use Nette; +use Latte; interface ILatteFactory diff --git a/src/Bridges/ApplicationLatte/Loader.php b/src/Bridges/ApplicationLatte/Loader.php index 69817259b..5a3db2921 100644 --- a/src/Bridges/ApplicationLatte/Loader.php +++ b/src/Bridges/ApplicationLatte/Loader.php @@ -7,8 +7,8 @@ namespace Nette\Bridges\ApplicationLatte; -use Nette, - Latte; +use Nette; +use Latte; /** diff --git a/src/Bridges/ApplicationLatte/Template.php b/src/Bridges/ApplicationLatte/Template.php index ee8b81556..06034ceff 100644 --- a/src/Bridges/ApplicationLatte/Template.php +++ b/src/Bridges/ApplicationLatte/Template.php @@ -7,8 +7,8 @@ namespace Nette\Bridges\ApplicationLatte; -use Nette, - Latte; +use Nette; +use Latte; /** @@ -105,7 +105,7 @@ public function registerHelperLoader($loader) { trigger_error(__METHOD__ . '() is deprecated, use dynamic getLatte()->addFilter().', E_USER_DEPRECATED); $latte = $this->latte; - $this->latte->addFilter(NULL, function($name) use ($loader, $latte) { + $this->latte->addFilter(NULL, function ($name) use ($loader, $latte) { if ($callback = call_user_func($loader, $name)) { $latte->addFilter($name, $callback); } diff --git a/src/Bridges/ApplicationLatte/TemplateFactory.php b/src/Bridges/ApplicationLatte/TemplateFactory.php index 91b9e99fd..ac7f011ab 100644 --- a/src/Bridges/ApplicationLatte/TemplateFactory.php +++ b/src/Bridges/ApplicationLatte/TemplateFactory.php @@ -11,8 +11,8 @@ namespace Nette\Bridges\ApplicationLatte; -use Nette, - Nette\Application\UI; +use Nette; +use Nette\Application\UI; /** @@ -66,7 +66,7 @@ public function createTemplate(UI\Control $control = NULL) $latte->onCompile = iterator_to_array($latte->onCompile); } - array_unshift($latte->onCompile, function($latte) use ($control, $template) { + array_unshift($latte->onCompile, function ($latte) use ($control, $template) { $latte->getParser()->shortNoEscape = TRUE; $latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler())); UIMacros::install($latte->getCompiler()); @@ -82,11 +82,11 @@ public function createTemplate(UI\Control $control = NULL) foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) { $latte->addFilter($name, 'Nette\Utils\Strings::' . $name); } - $latte->addFilter('null', function() {}); - $latte->addFilter('length', function($var) { + $latte->addFilter('null', function () {}); + $latte->addFilter('length', function ($var) { return is_string($var) ? Nette\Utils\Strings::length($var) : count($var); }); - $latte->addFilter('modifyDate', function($time, $delta, $unit = NULL) { + $latte->addFilter('modifyDate', function ($time, $delta, $unit = NULL) { return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit); // intentionally == }); diff --git a/src/Bridges/ApplicationLatte/UIMacros.php b/src/Bridges/ApplicationLatte/UIMacros.php index 3039dcdfd..953901a76 100644 --- a/src/Bridges/ApplicationLatte/UIMacros.php +++ b/src/Bridges/ApplicationLatte/UIMacros.php @@ -7,12 +7,12 @@ namespace Nette\Bridges\ApplicationLatte; -use Nette, - Latte, - Latte\MacroNode, - Latte\PhpWriter, - Latte\CompileException, - Nette\Utils\Strings; +use Nette; +use Latte; +use Latte\MacroNode; +use Latte\PhpWriter; +use Latte\CompileException; +use Nette\Utils\Strings; /** @@ -32,7 +32,7 @@ public static function install(Latte\Compiler $compiler) $me = new static($compiler); $me->addMacro('control', array($me, 'macroControl')); - $me->addMacro('href', NULL, NULL, function(MacroNode $node, PhpWriter $writer) use ($me) { + $me->addMacro('href', NULL, NULL, function (MacroNode $node, PhpWriter $writer) use ($me) { return ' ?> href="macroLink($node, $writer) . ' ?>"addMacro('plink', array($me, 'macroLink')); diff --git a/src/Bridges/ApplicationTracy/RoutingPanel.php b/src/Bridges/ApplicationTracy/RoutingPanel.php index b73dc83f8..f3c72daa0 100644 --- a/src/Bridges/ApplicationTracy/RoutingPanel.php +++ b/src/Bridges/ApplicationTracy/RoutingPanel.php @@ -7,11 +7,11 @@ namespace Nette\Bridges\ApplicationTracy; -use Nette, - Nette\Application\Routers, - Nette\Application\UI\Presenter, - Tracy, - Tracy\Dumper; +use Nette; +use Nette\Application\Routers; +use Nette\Application\UI\Presenter; +use Tracy; +use Tracy\Dumper; /** @@ -42,11 +42,11 @@ class RoutingPanel extends Nette\Object implements Tracy\IBarPanel public static function initializePanel(Nette\Application\Application $application) { - Tracy\Debugger::getBlueScreen()->addPanel(function($e) use ($application) { + Tracy\Debugger::getBlueScreen()->addPanel(function ($e) use ($application) { return $e ? NULL : array( 'tab' => 'Nette Application', 'panel' => '

Requests

' . Dumper::toHtml($application->getRequests(), array(Dumper::LIVE => TRUE)) - . '

Presenter

' . Dumper::toHtml($application->getPresenter(), array(Dumper::LIVE => TRUE)) + . '

Presenter

' . Dumper::toHtml($application->getPresenter(), array(Dumper::LIVE => TRUE)), ); }); } @@ -122,7 +122,7 @@ private function analyse($router, $module = '') 'defaults' => $router instanceof Routers\Route || $router instanceof Routers\SimpleRouter ? $router->getDefaults() : array(), 'mask' => $router instanceof Routers\Route ? $router->getMask() : NULL, 'request' => $request, - 'module' => rtrim($module, ':') + 'module' => rtrim($module, ':'), ); } diff --git a/tests/Application.DI/ApplicationExtension.basic.phpt b/tests/Application.DI/ApplicationExtension.basic.phpt index 7c33722b8..89b88b376 100644 --- a/tests/Application.DI/ApplicationExtension.basic.phpt +++ b/tests/Application.DI/ApplicationExtension.basic.phpt @@ -4,15 +4,15 @@ * Test: ApplicationExtension */ -use Nette\DI, - Nette\Bridges\ApplicationDI\ApplicationExtension, - Tester\Assert; +use Nette\DI; +use Nette\Bridges\ApplicationDI\ApplicationExtension; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test(function() { +test(function () { $compiler = new DI\Compiler; $compiler->addExtension('application', new ApplicationExtension(FALSE)); @@ -27,7 +27,7 @@ test(function() { eval($code); $container = new Container1; - Assert::type( 'Nette\Application\Application', $container->getService('application') ); - Assert::type( 'Nette\Application\PresenterFactory', $container->getService('nette.presenterFactory') ); - Assert::type( 'Nette\Application\LinkGenerator', $container->getService('application.linkGenerator') ); + Assert::type('Nette\Application\Application', $container->getService('application')); + Assert::type('Nette\Application\PresenterFactory', $container->getService('nette.presenterFactory')); + Assert::type('Nette\Application\LinkGenerator', $container->getService('application.linkGenerator')); }); diff --git a/tests/Application.DI/ApplicationExtension.invalidLink.phpt b/tests/Application.DI/ApplicationExtension.invalidLink.phpt index 3fe461306..95d2fa499 100644 --- a/tests/Application.DI/ApplicationExtension.invalidLink.phpt +++ b/tests/Application.DI/ApplicationExtension.invalidLink.phpt @@ -4,10 +4,10 @@ * Test: ApplicationExtension */ -use Nette\DI, - Nette\Bridges\ApplicationDI\ApplicationExtension, - Nette\Application\UI\Presenter, - Tester\Assert; +use Nette\DI; +use Nette\Bridges\ApplicationDI\ApplicationExtension; +use Nette\Application\UI\Presenter; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -26,7 +26,7 @@ function createCompiler($config) } -test(function() { +test(function () { $compiler = createCompiler(' application: debugger: no @@ -47,7 +47,7 @@ test(function() { }); -test(function() { +test(function () { $compiler = createCompiler(' application: debugger: no @@ -68,7 +68,7 @@ test(function() { }); -test(function() { +test(function () { $compiler = createCompiler(' application: debugger: no @@ -89,7 +89,7 @@ test(function() { }); -test(function() { +test(function () { $compiler = createCompiler(' application: debugger: no diff --git a/tests/Application.DI/ApplicationExtension.scan.phpt b/tests/Application.DI/ApplicationExtension.scan.phpt index 4125637e8..753509171 100644 --- a/tests/Application.DI/ApplicationExtension.scan.phpt +++ b/tests/Application.DI/ApplicationExtension.scan.phpt @@ -4,16 +4,16 @@ * Test: ApplicationExtension */ -use Nette\DI, - Nette\Bridges\ApplicationDI\ApplicationExtension, - Tester\Assert; +use Nette\DI; +use Nette\Bridges\ApplicationDI\ApplicationExtension; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; require __DIR__ . '/files/MyPresenter.php'; -test(function() { +test(function () { $compiler = new DI\Compiler; $compiler->addExtension('application', new ApplicationExtension); @@ -28,13 +28,13 @@ test(function() { $container = new Container1; $tags = $container->findByTag('nette.presenter'); - Assert::count( 1, array_keys($tags, 'NetteModule\ErrorPresenter') ); - Assert::count( 1, array_keys($tags, 'NetteModule\MicroPresenter') ); - Assert::count( 0, array_keys($tags, 'Nette\Application\UI\Presenter') ); + Assert::count(1, array_keys($tags, 'NetteModule\ErrorPresenter')); + Assert::count(1, array_keys($tags, 'NetteModule\MicroPresenter')); + Assert::count(0, array_keys($tags, 'Nette\Application\UI\Presenter')); }); -test(function() { +test(function () { $compiler = new DI\Compiler; $compiler->addExtension('application', new ApplicationExtension); @@ -52,13 +52,13 @@ test(function() { $container = new Container2; $tags = $container->findByTag('nette.presenter'); - Assert::count( 1, array_keys($tags, 'BasePresenter') ); - Assert::count( 1, array_keys($tags, 'Presenter1') ); - Assert::count( 1, array_keys($tags, 'Presenter2') ); + Assert::count(1, array_keys($tags, 'BasePresenter')); + Assert::count(1, array_keys($tags, 'Presenter1')); + Assert::count(1, array_keys($tags, 'Presenter2')); }); -test(function() { +test(function () { $compiler = new DI\Compiler; $compiler->addExtension('application', new ApplicationExtension(FALSE, array(__DIR__ . '/files'))); @@ -82,10 +82,10 @@ test(function() { $container = new Container3; $tags = $container->findByTag('nette.presenter'); - Assert::count( 1, array_keys($tags, 'BasePresenter') ); - Assert::count( 1, array_keys($tags, 'Presenter1') ); - Assert::count( 1, array_keys($tags, 'Presenter2') ); + Assert::count(1, array_keys($tags, 'BasePresenter')); + Assert::count(1, array_keys($tags, 'Presenter1')); + Assert::count(1, array_keys($tags, 'Presenter2')); $tmp = array_keys($tags, 'Presenter1'); - Assert::same( 'test', $container->getService($tmp[0])->getView() ); + Assert::same('test', $container->getService($tmp[0])->getView()); }); diff --git a/tests/Application.DI/LatteExtension.basic.phpt b/tests/Application.DI/LatteExtension.basic.phpt index 1dcc47511..5f0d21580 100644 --- a/tests/Application.DI/LatteExtension.basic.phpt +++ b/tests/Application.DI/LatteExtension.basic.phpt @@ -4,8 +4,8 @@ * Test: LatteExtension. */ -use Nette\DI, - Tester\Assert; +use Nette\DI; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -80,7 +80,7 @@ eval($code); $container = new Container; -Assert::type( 'Nette\Bridges\ApplicationLatte\ILatteFactory', $container->getService('nette.latteFactory') ); +Assert::type('Nette\Bridges\ApplicationLatte\ILatteFactory', $container->getService('nette.latteFactory')); $container->getService('nette.latteFactory')->create()->setLoader(new Latte\Loaders\StringLoader)->compile(''); Assert::same(array( diff --git a/tests/Application.DI/RoutingExtension.basic.phpt b/tests/Application.DI/RoutingExtension.basic.phpt index d2db42455..b8d8f90c4 100644 --- a/tests/Application.DI/RoutingExtension.basic.phpt +++ b/tests/Application.DI/RoutingExtension.basic.phpt @@ -4,15 +4,15 @@ * Test: RoutingExtension. */ -use Nette\DI, - Nette\Bridges\ApplicationDI\RoutingExtension, - Tester\Assert; +use Nette\DI; +use Nette\Bridges\ApplicationDI\RoutingExtension; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test(function() { +test(function () { $loader = new DI\Config\Loader; $config = $loader->load(Tester\FileMock::create(' routing: diff --git a/tests/Application.DI/RoutingExtension.cache.phpt b/tests/Application.DI/RoutingExtension.cache.phpt index 17f5b5a18..9f1aad7fc 100644 --- a/tests/Application.DI/RoutingExtension.cache.phpt +++ b/tests/Application.DI/RoutingExtension.cache.phpt @@ -4,10 +4,10 @@ * Test: RoutingExtension caching. */ -use Nette\DI, - Nette\Bridges\ApplicationDI\RoutingExtension, - Nette\Application\Routers\Route, - Tester\Assert; +use Nette\DI; +use Nette\Bridges\ApplicationDI\RoutingExtension; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -30,7 +30,7 @@ class MyRouter implements Nette\Application\IRouter } -test(function() { +test(function () { $loader = new DI\Config\Loader; $config = $loader->load(Tester\FileMock::create(' services: @@ -48,7 +48,7 @@ test(function() { }); -test(function() { +test(function () { $loader = new DI\Config\Loader; $config = $loader->load(Tester\FileMock::create(' routing: @@ -69,11 +69,12 @@ test(function() { }); -Assert::exception(function() { +Assert::exception(function () { /** @return Nette\Application\IRouter */ - function myRouterFactory() { - return new Route('path', function(){}); + function myRouterFactory() + { + return new Route('path', function () {}); } $loader = new DI\Config\Loader; diff --git a/tests/Application.Latte/Template.filters.phpt b/tests/Application.Latte/Template.filters.phpt index 1b06fc617..57c339c20 100644 --- a/tests/Application.Latte/Template.filters.phpt +++ b/tests/Application.Latte/Template.filters.phpt @@ -4,8 +4,8 @@ * Test: Template filters */ -use Nette\Bridges\ApplicationLatte\Template, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\Template; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -19,7 +19,7 @@ Assert::exception(function () use ($template) { $engine->addFilter('length', 'strlen'); -Assert::same( 3, @$template->length('abc') ); +Assert::same(3, @$template->length('abc')); Assert::error(function () use ($template) { $template->length('abc'); diff --git a/tests/Application.Latte/TemplateFactory.filters.phpt b/tests/Application.Latte/TemplateFactory.filters.phpt index 21310e0b3..c8ad23e21 100644 --- a/tests/Application.Latte/TemplateFactory.filters.phpt +++ b/tests/Application.Latte/TemplateFactory.filters.phpt @@ -4,8 +4,8 @@ * Test: TemplateFactory filters */ -use Nette\Bridges\ApplicationLatte\TemplateFactory, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\TemplateFactory; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -33,19 +33,19 @@ $latte = $factory->createTemplate()->getLatte(); setlocale(LC_TIME, 'C'); date_default_timezone_set('Europe/Prague'); -Assert::null( $latte->invokeFilter('modifyDate', array(NULL, NULL)) ); -Assert::same( '1978-01-24 11:40:00', (string) $latte->invokeFilter('modifyDate', array(254400000, '+1 day')) ); -Assert::same( '1978-05-06 00:00:00', (string) $latte->invokeFilter('modifyDate', array('1978-05-05', '+1 day')) ); -Assert::same( '1978-05-06 00:00:00', (string) $latte->invokeFilter('modifyDate', array(new DateTime('1978-05-05'), '1day')) ); -Assert::same( '1978-01-22 11:40:00', (string) $latte->invokeFilter('modifyDate', array(254400000, -1, 'day')) ); - - -Assert::same( '%25', $latte->invokeFilter('url', array('%')) ); -Assert::same( 3, $latte->invokeFilter('length', array('abc')) ); -Assert::same( 2, $latte->invokeFilter('length', array(array(1, 2))) ); -Assert::null( $latte->invokeFilter('null', array('x')) ); -Assert::same( '', $latte->invokeFilter('normalize', array(' ')) ); -Assert::same( 'a-b', $latte->invokeFilter('webalize', array('a b')) ); -Assert::same( ' a', $latte->invokeFilter('padLeft', array('a', 3)) ); -Assert::same( 'a ', $latte->invokeFilter('padRight', array('a', 3)) ); -Assert::same( 'cba', $latte->invokeFilter('reverse', array('abc')) ); +Assert::null($latte->invokeFilter('modifyDate', array(NULL, NULL))); +Assert::same('1978-01-24 11:40:00', (string) $latte->invokeFilter('modifyDate', array(254400000, '+1 day'))); +Assert::same('1978-05-06 00:00:00', (string) $latte->invokeFilter('modifyDate', array('1978-05-05', '+1 day'))); +Assert::same('1978-05-06 00:00:00', (string) $latte->invokeFilter('modifyDate', array(new DateTime('1978-05-05'), '1day'))); +Assert::same('1978-01-22 11:40:00', (string) $latte->invokeFilter('modifyDate', array(254400000, -1, 'day'))); + + +Assert::same('%25', $latte->invokeFilter('url', array('%'))); +Assert::same(3, $latte->invokeFilter('length', array('abc'))); +Assert::same(2, $latte->invokeFilter('length', array(array(1, 2)))); +Assert::null($latte->invokeFilter('null', array('x'))); +Assert::same('', $latte->invokeFilter('normalize', array(' '))); +Assert::same('a-b', $latte->invokeFilter('webalize', array('a b'))); +Assert::same(' a', $latte->invokeFilter('padLeft', array('a', 3))); +Assert::same('a ', $latte->invokeFilter('padRight', array('a', 3))); +Assert::same('cba', $latte->invokeFilter('reverse', array('abc'))); diff --git a/tests/Application.Latte/TemplateFactory.onCompile.phpt b/tests/Application.Latte/TemplateFactory.onCompile.phpt index b5a6a4abd..80aa991d7 100644 --- a/tests/Application.Latte/TemplateFactory.onCompile.phpt +++ b/tests/Application.Latte/TemplateFactory.onCompile.phpt @@ -4,9 +4,9 @@ * Test: TemplateFactory in Bridge properly handles Latte::onCompile */ -use Nette\Bridges\ApplicationLatte\TemplateFactory, - Nette\Http, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\TemplateFactory; +use Nette\Http; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -29,10 +29,10 @@ class LatteFactoryMock implements Nette\Bridges\ApplicationLatte\ILatteFactory -test(function() { +test(function () { $engine = new Latte\Engine; $factory = new TemplateFactory(new LatteFactoryMock($engine), new Http\Request(new Http\UrlScript('http://nette.org'))); - $engine->onCompile[] = $callback = function() { }; + $engine->onCompile[] = $callback = function () { }; $factory->createTemplate(); @@ -42,10 +42,10 @@ test(function() { }); -test(function() { +test(function () { $engine = new Latte\Engine; $factory = new TemplateFactory(new LatteFactoryMock($engine), new Http\Request(new Http\UrlScript('http://nette.org'))); - $engine->onCompile = new ArrayIterator(array($callback = function() {})); + $engine->onCompile = new ArrayIterator(array($callback = function () {})); $factory->createTemplate(); @@ -55,7 +55,7 @@ test(function() { }); -test(function() { +test(function () { class Event implements IteratorAggregate { public $events; @@ -73,7 +73,7 @@ test(function() { $engine = new Latte\Engine; $factory = new TemplateFactory(new LatteFactoryMock($engine), new Http\Request(new Http\UrlScript('http://nette.org'))); - $engine->onCompile = new Event(array($callback = function() {})); + $engine->onCompile = new Event(array($callback = function () {})); $factory->createTemplate(); diff --git a/tests/Application.Latte/UIMacros.control.2.phpt b/tests/Application.Latte/UIMacros.control.2.phpt index 91941c861..db5b75ff9 100644 --- a/tests/Application.Latte/UIMacros.control.2.phpt +++ b/tests/Application.Latte/UIMacros.control.2.phpt @@ -4,9 +4,9 @@ * Test: {control ...} */ -use Nette\Object, - Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Object; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -16,8 +16,8 @@ class MockComponent extends Object { function getComponent($name) { - Notes::add( __METHOD__ ); - Notes::add( func_get_args() ); + Notes::add(__METHOD__); + Notes::add(func_get_args()); return new MockControl; } @@ -29,8 +29,8 @@ class MockControl extends Object function __call($name, $args) { - Notes::add( __METHOD__ ); - Notes::add( func_get_args() ); + Notes::add(__METHOD__); + Notes::add(func_get_args()); } } @@ -64,22 +64,22 @@ $latte->renderToString(' {control form var1 => 5, 1, 2} ', $params); -Assert::same( array( - "MockComponent::getComponent", array("name"), - "MockControl::__call", array("render", array()), - "MockComponent::getComponent", array("form"), - "MockControl::__call", array("render", array()), - "MockComponent::getComponent", array("form"), - "MockControl::__call", array("renderTest", array()), - "MockControl::__call", array("renderTest", array()), - "MockComponent::getComponent", array("form"), - "MockControl::__call", array("renderTest", array()), - "MockComponent::getComponent", array("form"), - "MockControl::__call", array("renderform", array()), - "MockComponent::getComponent", array("form"), - "MockControl::__call", array("render", array("var1")), - "MockComponent::getComponent", array("form"), - "MockControl::__call", array("render", array("var1", 1, 2)), - "MockComponent::getComponent", array("form"), - "MockControl::__call", array("render", array(array("var1" => 5, 0 => 1, 1 => 2))), -), Notes::fetch() ); +Assert::same(array( + 'MockComponent::getComponent', array('name'), + 'MockControl::__call', array('render', array()), + 'MockComponent::getComponent', array('form'), + 'MockControl::__call', array('render', array()), + 'MockComponent::getComponent', array('form'), + 'MockControl::__call', array('renderTest', array()), + 'MockControl::__call', array('renderTest', array()), + 'MockComponent::getComponent', array('form'), + 'MockControl::__call', array('renderTest', array()), + 'MockComponent::getComponent', array('form'), + 'MockControl::__call', array('renderform', array()), + 'MockComponent::getComponent', array('form'), + 'MockControl::__call', array('render', array('var1')), + 'MockComponent::getComponent', array('form'), + 'MockControl::__call', array('render', array('var1', 1, 2)), + 'MockComponent::getComponent', array('form'), + 'MockControl::__call', array('render', array(array('var1' => 5, 0 => 1, 1 => 2))), +), Notes::fetch()); diff --git a/tests/Application.Latte/UIMacros.control.phpt b/tests/Application.Latte/UIMacros.control.phpt index 3ac9cde37..daaa25562 100644 --- a/tests/Application.Latte/UIMacros.control.phpt +++ b/tests/Application.Latte/UIMacros.control.phpt @@ -4,8 +4,8 @@ * Test: UIMacros: {control ...} */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -15,12 +15,12 @@ $compiler = new Latte\Compiler; UIMacros::install($compiler); // {control ...} -Assert::match( 'getComponent("form"); %a%->render() ?>', $compiler->expandMacro('control', 'form', '')->openingCode ); -Assert::match( 'getComponent("form"); %a%->render(); echo $template->filter(%a%) ?>', $compiler->expandMacro('control', 'form', 'filter')->openingCode ); -Assert::match( 'getComponent($form); %a%->render() ?>', $compiler->expandMacro('control', '$form', '')->openingCode ); -Assert::match( 'getComponent("form"); %a%->renderType() ?>', $compiler->expandMacro('control', 'form:type', '')->openingCode ); -Assert::match( 'getComponent("form"); %a%->{"render$type"}() ?>', $compiler->expandMacro('control', 'form:$type', '')->openingCode ); -Assert::match( 'getComponent("form"); %a%->renderType(\'param\') ?>', $compiler->expandMacro('control', 'form:type param', '')->openingCode ); -Assert::match( 'getComponent("form"); %a%->renderType(array(\'param\' => 123)) ?>', $compiler->expandMacro('control', 'form:type param => 123', '')->openingCode ); -Assert::match( 'getComponent("form"); %a%->renderType(array(\'param\' => 123)) ?>', $compiler->expandMacro('control', 'form:type, param => 123', '')->openingCode ); -Assert::match( 'getComponent("form"); %a%->render(); echo $template->striptags(%a%) ?>', $compiler->expandMacro('control', 'form', 'striptags')->openingCode ); +Assert::match('getComponent("form"); %a%->render() ?>', $compiler->expandMacro('control', 'form', '')->openingCode); +Assert::match('getComponent("form"); %a%->render(); echo $template->filter(%a%) ?>', $compiler->expandMacro('control', 'form', 'filter')->openingCode); +Assert::match('getComponent($form); %a%->render() ?>', $compiler->expandMacro('control', '$form', '')->openingCode); +Assert::match('getComponent("form"); %a%->renderType() ?>', $compiler->expandMacro('control', 'form:type', '')->openingCode); +Assert::match('getComponent("form"); %a%->{"render$type"}() ?>', $compiler->expandMacro('control', 'form:$type', '')->openingCode); +Assert::match('getComponent("form"); %a%->renderType(\'param\') ?>', $compiler->expandMacro('control', 'form:type param', '')->openingCode); +Assert::match('getComponent("form"); %a%->renderType(array(\'param\' => 123)) ?>', $compiler->expandMacro('control', 'form:type param => 123', '')->openingCode); +Assert::match('getComponent("form"); %a%->renderType(array(\'param\' => 123)) ?>', $compiler->expandMacro('control', 'form:type, param => 123', '')->openingCode); +Assert::match('getComponent("form"); %a%->render(); echo $template->striptags(%a%) ?>', $compiler->expandMacro('control', 'form', 'striptags')->openingCode); diff --git a/tests/Application.Latte/UIMacros.dynamicsnippets.alt.phpt b/tests/Application.Latte/UIMacros.dynamicsnippets.alt.phpt index 45dd230fc..874af914e 100644 --- a/tests/Application.Latte/UIMacros.dynamicsnippets.alt.phpt +++ b/tests/Application.Latte/UIMacros.dynamicsnippets.alt.phpt @@ -4,8 +4,8 @@ * Test: dynamic snippets test. */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Latte/UIMacros.dynamicsnippets.phpt b/tests/Application.Latte/UIMacros.dynamicsnippets.phpt index d5e29c4b3..b29feba30 100644 --- a/tests/Application.Latte/UIMacros.dynamicsnippets.phpt +++ b/tests/Application.Latte/UIMacros.dynamicsnippets.phpt @@ -4,8 +4,8 @@ * Test: dynamic snippets test. */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Latte/UIMacros.isLinkCurrent.phpt b/tests/Application.Latte/UIMacros.isLinkCurrent.phpt index 9ea908619..2cb0e31bb 100644 --- a/tests/Application.Latte/UIMacros.isLinkCurrent.phpt +++ b/tests/Application.Latte/UIMacros.isLinkCurrent.phpt @@ -4,8 +4,8 @@ * Test: isLinkCurrent() */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Latte/UIMacros.link.2.phpt b/tests/Application.Latte/UIMacros.link.2.phpt index 227a604bc..c1d88eac0 100644 --- a/tests/Application.Latte/UIMacros.link.2.phpt +++ b/tests/Application.Latte/UIMacros.link.2.phpt @@ -4,8 +4,8 @@ * Test: {link ...}, {plink ...} */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -38,7 +38,8 @@ class MockPresenter extends MockControl return 'plink:' . strtr(json_encode($args), '"', "'"); } - public function isAjax() { + public function isAjax() + { return FALSE; } diff --git a/tests/Application.Latte/UIMacros.link.phpt b/tests/Application.Latte/UIMacros.link.phpt index 2a1d7cd77..f40e528c0 100644 --- a/tests/Application.Latte/UIMacros.link.phpt +++ b/tests/Application.Latte/UIMacros.link.phpt @@ -4,8 +4,8 @@ * Test: UIMacros: {link ...} */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -16,15 +16,15 @@ $compiler->setContentType($compiler::CONTENT_TEXT); UIMacros::install($compiler); // {link ...} -Assert::same( 'link("p") ?>', $compiler->expandMacro('link', 'p', '')->openingCode ); -Assert::same( 'filter($_control->link("p")) ?>', $compiler->expandMacro('link', 'p', 'filter')->openingCode ); -Assert::same( 'link("p:a") ?>', $compiler->expandMacro('link', 'p:a', '')->openingCode ); -Assert::same( 'link($dest) ?>', $compiler->expandMacro('link', '$dest', '')->openingCode ); -Assert::same( 'link($p:$a) ?>', $compiler->expandMacro('link', '$p:$a', '')->openingCode ); -Assert::same( 'link("$p:$a") ?>', $compiler->expandMacro('link', '"$p:$a"', '')->openingCode ); -Assert::same( 'link("p:a") ?>', $compiler->expandMacro('link', '"p:a"', '')->openingCode ); -Assert::same( 'link(\'p:a\') ?>', $compiler->expandMacro('link', "'p:a'", '')->openingCode ); - -Assert::same( 'link("p", array(\'param\')) ?>', $compiler->expandMacro('link', 'p param', '')->openingCode ); -Assert::same( 'link("p", array(\'param\' => 123)) ?>', $compiler->expandMacro('link', 'p param => 123', '')->openingCode ); -Assert::same( 'link("p", array(\'param\' => 123)) ?>', $compiler->expandMacro('link', 'p, param => 123', '')->openingCode ); +Assert::same('link("p") ?>', $compiler->expandMacro('link', 'p', '')->openingCode); +Assert::same('filter($_control->link("p")) ?>', $compiler->expandMacro('link', 'p', 'filter')->openingCode); +Assert::same('link("p:a") ?>', $compiler->expandMacro('link', 'p:a', '')->openingCode); +Assert::same('link($dest) ?>', $compiler->expandMacro('link', '$dest', '')->openingCode); +Assert::same('link($p:$a) ?>', $compiler->expandMacro('link', '$p:$a', '')->openingCode); +Assert::same('link("$p:$a") ?>', $compiler->expandMacro('link', '"$p:$a"', '')->openingCode); +Assert::same('link("p:a") ?>', $compiler->expandMacro('link', '"p:a"', '')->openingCode); +Assert::same('link(\'p:a\') ?>', $compiler->expandMacro('link', "'p:a'", '')->openingCode); + +Assert::same('link("p", array(\'param\')) ?>', $compiler->expandMacro('link', 'p param', '')->openingCode); +Assert::same('link("p", array(\'param\' => 123)) ?>', $compiler->expandMacro('link', 'p param => 123', '')->openingCode); +Assert::same('link("p", array(\'param\' => 123)) ?>', $compiler->expandMacro('link', 'p, param => 123', '')->openingCode); diff --git a/tests/Application.Latte/UIMacros.renderSnippets.extends.phpt b/tests/Application.Latte/UIMacros.renderSnippets.extends.phpt index eca0c94ad..76fd44344 100644 --- a/tests/Application.Latte/UIMacros.renderSnippets.extends.phpt +++ b/tests/Application.Latte/UIMacros.renderSnippets.extends.phpt @@ -4,8 +4,8 @@ * Test: UIMacros, renderSnippets and template with layout */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -27,7 +27,7 @@ class TestPresenter extends Nette\Application\UI\Presenter $presenter = new TestPresenter; $presenter->snippetMode = TRUE; -$presenter->redrawControl('foo');; +$presenter->redrawControl('foo'); $content = $presenter->render(); Assert::same('', $content); Assert::same(array( diff --git a/tests/Application.Latte/UIMacros.renderSnippets.phpt b/tests/Application.Latte/UIMacros.renderSnippets.phpt index 45b13400f..4c6095798 100644 --- a/tests/Application.Latte/UIMacros.renderSnippets.phpt +++ b/tests/Application.Latte/UIMacros.renderSnippets.phpt @@ -4,8 +4,8 @@ * Test: UIMacros and renderSnippets. */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -28,7 +28,7 @@ class TestPresenter extends Nette\Application\UI\Presenter { function createComponentMulti() { - return new Nette\Application\UI\Multiplier(function() { + return new Nette\Application\UI\Multiplier(function () { $control = new InnerControl(); $control->redrawControl(); return $control; diff --git a/tests/Application.Latte/UIMacros.renderSnippets2.phpt b/tests/Application.Latte/UIMacros.renderSnippets2.phpt index 99fadc894..779bec8ce 100644 --- a/tests/Application.Latte/UIMacros.renderSnippets2.phpt +++ b/tests/Application.Latte/UIMacros.renderSnippets2.phpt @@ -4,8 +4,8 @@ * Test: UIMacros, renderSnippets and control with two templates. */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -47,7 +47,7 @@ class TestPresenter extends Nette\Application\UI\Presenter { function createComponentMulti() { - return new Nette\Application\UI\Multiplier(function() { + return new Nette\Application\UI\Multiplier(function () { return new InnerControl(); }); } diff --git a/tests/Application.Latte/UIMacros.snippet.alt.phpt b/tests/Application.Latte/UIMacros.snippet.alt.phpt index 003833ed6..b4f2b83de 100644 --- a/tests/Application.Latte/UIMacros.snippet.alt.phpt +++ b/tests/Application.Latte/UIMacros.snippet.alt.phpt @@ -4,9 +4,9 @@ * Test: general snippets test. */ -use Nette\Utils\Html, - Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Utils\Html; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Latte/UIMacros.snippet.phpt b/tests/Application.Latte/UIMacros.snippet.phpt index 7ee55b328..a414803dc 100644 --- a/tests/Application.Latte/UIMacros.snippet.phpt +++ b/tests/Application.Latte/UIMacros.snippet.phpt @@ -4,9 +4,9 @@ * Test: general snippets test. */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Nette\Utils\Html, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Nette\Utils\Html; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Latte/UIMacros.snippet1.phpt b/tests/Application.Latte/UIMacros.snippet1.phpt index 63573288b..f40da5aa0 100644 --- a/tests/Application.Latte/UIMacros.snippet1.phpt +++ b/tests/Application.Latte/UIMacros.snippet1.phpt @@ -4,8 +4,8 @@ * Test: snippets. */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Latte/UIMacros.snippet2.phpt b/tests/Application.Latte/UIMacros.snippet2.phpt index 4ed9abe89..de73fa522 100644 --- a/tests/Application.Latte/UIMacros.snippet2.phpt +++ b/tests/Application.Latte/UIMacros.snippet2.phpt @@ -4,8 +4,8 @@ * Test: snippets. */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Latte/UIMacros.snippet3.phpt b/tests/Application.Latte/UIMacros.snippet3.phpt index 18ec58dbb..9b7a8fe9c 100644 --- a/tests/Application.Latte/UIMacros.snippet3.phpt +++ b/tests/Application.Latte/UIMacros.snippet3.phpt @@ -4,8 +4,8 @@ * Test: snippets. */ -use Nette\Bridges\ApplicationLatte\UIMacros, - Tester\Assert; +use Nette\Bridges\ApplicationLatte\UIMacros; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/CliRouter.invalid.phpt b/tests/Application.Routers/CliRouter.invalid.phpt index 03fa204b0..a2afa278f 100644 --- a/tests/Application.Routers/CliRouter.invalid.phpt +++ b/tests/Application.Routers/CliRouter.invalid.phpt @@ -4,9 +4,9 @@ * Test: Nette\Application\Routers\CliRouter invalid argument */ -use Nette\Http, - Nette\Application\Routers\CliRouter, - Tester\Assert; +use Nette\Http; +use Nette\Application\Routers\CliRouter; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -16,4 +16,4 @@ $_SERVER['argv'] = 1; $httpRequest = new Http\Request(new Http\UrlScript()); $router = new CliRouter; -Assert::null( $router->match($httpRequest) ); +Assert::null($router->match($httpRequest)); diff --git a/tests/Application.Routers/CliRouter.phpt b/tests/Application.Routers/CliRouter.phpt index d2eeff6f2..cb6acac52 100644 --- a/tests/Application.Routers/CliRouter.phpt +++ b/tests/Application.Routers/CliRouter.phpt @@ -4,9 +4,9 @@ * Test: Nette\Application\Routers\CliRouter basic usage */ -use Nette\Http, - Nette\Application\Routers\CliRouter, - Tester\Assert; +use Nette\Http; +use Nette\Application\Routers\CliRouter; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -32,9 +32,9 @@ $router = new CliRouter(array( )); $req = $router->match($httpRequest); -Assert::same( 'homepage', $req->getPresenterName() ); +Assert::same('homepage', $req->getPresenterName()); -Assert::same( array( +Assert::same(array( 'id' => 12, 'user' => 'john doe', 'action' => 'default', @@ -42,9 +42,9 @@ Assert::same( array( 'verbose' => TRUE, 'pass' => 'se cret', 'wait' => TRUE, -), $req->getParameters() ); +), $req->getParameters()); -Assert::true( $req->isMethod('cli') ); +Assert::true($req->isMethod('cli')); -Assert::null( $router->constructUrl($req, $httpRequest->getUrl()) ); +Assert::null($router->constructUrl($req, $httpRequest->getUrl())); diff --git a/tests/Application.Routers/LinkGenerator.phpt b/tests/Application.Routers/LinkGenerator.phpt index d8663a7e9..742586cad 100644 --- a/tests/Application.Routers/LinkGenerator.phpt +++ b/tests/Application.Routers/LinkGenerator.phpt @@ -45,7 +45,7 @@ namespace { $pf = new PresenterFactory; - test(function() use ($pf) { + test(function () use ($pf) { $generator = new LinkGenerator(new Routers\SimpleRouter, new Http\Url('http://nette.org/en/'), $pf); Assert::same('http://nette.org/en/?action=default&presenter=Homepage', $generator->link('Homepage:default')); Assert::same('http://nette.org/en/?action=default&presenter=Module%3AMy', $generator->link('Module:My:default')); @@ -57,19 +57,19 @@ namespace { }); - Assert::exception(function() use ($pf) { + Assert::exception(function () use ($pf) { $generator = new LinkGenerator(new Routers\SimpleRouter, new Http\Url('http://nette.org/en/'), $pf); $generator->link('default'); }, 'Nette\Application\UI\InvalidLinkException', "Invalid link destination 'default'."); - Assert::exception(function() use ($pf) { + Assert::exception(function () use ($pf) { $generator = new LinkGenerator(new Routers\Route('/', 'Product:'), new Http\Url('http://nette.org/en/'), $pf); $generator->link('Homepage:default', array('id' => 10)); }, 'Nette\Application\UI\InvalidLinkException', 'No route for Homepage:default(id=10)'); - test(function() { + test(function () { $generator = new LinkGenerator(new Routers\SimpleRouter, new Http\Url('http://nette.org/en/')); Assert::same('http://nette.org/en/?action=default&presenter=Homepage', $generator->link('Homepage:default')); Assert::same('http://nette.org/en/?action=default&presenter=Module%3AMy', $generator->link('Module:My:default')); diff --git a/tests/Application.Routers/Route.arrayParams.phpt b/tests/Application.Routers/Route.arrayParams.phpt index fbdf44e99..6311763fc 100644 --- a/tests/Application.Routers/Route.arrayParams.phpt +++ b/tests/Application.Routers/Route.arrayParams.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with ArrayParams */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.basic.phpt b/tests/Application.Routers/Route.basic.phpt index 8967e1059..cf3a7ca27 100644 --- a/tests/Application.Routers/Route.basic.phpt +++ b/tests/Application.Routers/Route.basic.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route default usage. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -15,13 +15,13 @@ require __DIR__ . '/Route.inc'; $route = new Route('//'); -Assert::same( 'http://example.com/homepage/', testRouteOut($route, 'Homepage') ); +Assert::same('http://example.com/homepage/', testRouteOut($route, 'Homepage')); -Assert::same( 'http://example.com/homepage/', testRouteOut($route, 'Homepage', array('action' => 'default')) ); +Assert::same('http://example.com/homepage/', testRouteOut($route, 'Homepage', array('action' => 'default'))); -Assert::null( testRouteOut($route, 'Homepage', array('id' => 'word')) ); +Assert::null(testRouteOut($route, 'Homepage', array('id' => 'word'))); -Assert::same( 'http://example.com/front.homepage/', testRouteOut($route, 'Front:Homepage') ); +Assert::same('http://example.com/front.homepage/', testRouteOut($route, 'Front:Homepage')); testRouteIn($route, '/presenter/action/12/any'); diff --git a/tests/Application.Routers/Route.camelcapsVsDash.phpt b/tests/Application.Routers/Route.camelcapsVsDash.phpt index 046b6e0cd..6eaa75c11 100644 --- a/tests/Application.Routers/Route.camelcapsVsDash.phpt +++ b/tests/Application.Routers/Route.camelcapsVsDash.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with CamelcapsVsDash */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.combinedUrlParam.phpt b/tests/Application.Routers/Route.combinedUrlParam.phpt index 26238bd27..e5f0265da 100644 --- a/tests/Application.Routers/Route.combinedUrlParam.phpt +++ b/tests/Application.Routers/Route.combinedUrlParam.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with CombinedUrlParam */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.extraDefaultParam.phpt b/tests/Application.Routers/Route.extraDefaultParam.phpt index 69f32b193..d643db6b4 100644 --- a/tests/Application.Routers/Route.extraDefaultParam.phpt +++ b/tests/Application.Routers/Route.extraDefaultParam.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with ExtraDefaultParam */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.filter.global.phpt b/tests/Application.Routers/Route.filter.global.phpt index 2b6c09d42..bace394b3 100644 --- a/tests/Application.Routers/Route.filter.global.phpt +++ b/tests/Application.Routers/Route.filter.global.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with FILTER_IN & FILTER_OUT */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -15,7 +15,7 @@ require __DIR__ . '/Route.inc'; $route = new Route('', array( NULL => array( - Route::FILTER_IN => function(array $arr) { + Route::FILTER_IN => function (array $arr) { if (substr($arr['presenter'], 0, 3) !== 'Abc') { return NULL; } @@ -23,7 +23,7 @@ $route = new Route('', array( $arr['param'] .= '.in'; return $arr; }, - Route::FILTER_OUT => function(array $arr) { + Route::FILTER_OUT => function (array $arr) { if (substr($arr['presenter'], 0, 3) !== 'Abc') { return NULL; } diff --git a/tests/Application.Routers/Route.filter.query.phpt b/tests/Application.Routers/Route.filter.query.phpt index 6c38e7535..b8e628ec7 100644 --- a/tests/Application.Routers/Route.filter.query.phpt +++ b/tests/Application.Routers/Route.filter.query.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with FILTER_IN & FILTER_OUT */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -15,10 +15,10 @@ require __DIR__ . '/Route.inc'; $route = new Route(' ? action=', array( 'presenter' => array( - Route::FILTER_IN => function($s) { + Route::FILTER_IN => function ($s) { return strrev($s); }, - Route::FILTER_OUT => function($s) { + Route::FILTER_OUT => function ($s) { return strtoupper(strrev($s)); }, ), diff --git a/tests/Application.Routers/Route.filter.url.object.phpt b/tests/Application.Routers/Route.filter.url.object.phpt index a14fe102d..2e7b853f2 100644 --- a/tests/Application.Routers/Route.filter.url.object.phpt +++ b/tests/Application.Routers/Route.filter.url.object.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with FILTER_IN & FILTER_OUT using string <=> object conversion */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; @@ -22,10 +22,10 @@ $identityMap[2] = new Object(2); $route = new Route('', array( 'presenter' => 'presenter', 'parameter' => array( - Route::FILTER_IN => function($s) use ($identityMap) { + Route::FILTER_IN => function ($s) use ($identityMap) { return isset($identityMap[$s]) ? $identityMap[$s] : NULL; }, - Route::FILTER_OUT => function($obj) { + Route::FILTER_OUT => function ($obj) { return $obj instanceof Object ? $obj->getId() : NULL; }, ), @@ -46,7 +46,7 @@ Assert::same('http://example.com/1', testRouteOut($route, 'presenter', array( // Doesn't match testRouteIn($route, '/3/'); -Assert::null( testRouteOut($route, 'presenter', array( +Assert::null(testRouteOut($route, 'presenter', array( 'parameter' => NULL, ))); diff --git a/tests/Application.Routers/Route.filter.url.phpt b/tests/Application.Routers/Route.filter.url.phpt index b6c40b1b8..57edc4341 100644 --- a/tests/Application.Routers/Route.filter.url.phpt +++ b/tests/Application.Routers/Route.filter.url.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with FILTER_IN & FILTER_OUT */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -15,10 +15,10 @@ require __DIR__ . '/Route.inc'; $route = new Route('', array( 'presenter' => array( - Route::FILTER_IN => function($s) { + Route::FILTER_IN => function ($s) { return strrev($s); }, - Route::FILTER_OUT => function($s) { + Route::FILTER_OUT => function ($s) { return strrev($s); }, ), diff --git a/tests/Application.Routers/Route.filterTable.query.phpt b/tests/Application.Routers/Route.filterTable.query.phpt index 7e380d0ed..74dc15b2d 100644 --- a/tests/Application.Routers/Route.filterTable.query.phpt +++ b/tests/Application.Routers/Route.filterTable.query.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with FilterTable */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.filterTable.strict.phpt b/tests/Application.Routers/Route.filterTable.strict.phpt index df0aacbe5..376ff4885 100644 --- a/tests/Application.Routers/Route.filterTable.strict.phpt +++ b/tests/Application.Routers/Route.filterTable.strict.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with FilterTable */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.filterTable.url.phpt b/tests/Application.Routers/Route.filterTable.url.phpt index 5a0558738..7ab810194 100644 --- a/tests/Application.Routers/Route.filterTable.url.phpt +++ b/tests/Application.Routers/Route.filterTable.url.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with FilterTable */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.firstOptionalParam.phpt b/tests/Application.Routers/Route.firstOptionalParam.phpt index df25615ea..ab1ecb675 100644 --- a/tests/Application.Routers/Route.firstOptionalParam.phpt +++ b/tests/Application.Routers/Route.firstOptionalParam.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route first optional parameter. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.fooParameter.default.phpt b/tests/Application.Routers/Route.fooParameter.default.phpt index 355687867..4a17de8f0 100644 --- a/tests/Application.Routers/Route.fooParameter.default.phpt +++ b/tests/Application.Routers/Route.fooParameter.default.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with FooParameter */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.fooParameter.phpt b/tests/Application.Routers/Route.fooParameter.phpt index 66190dbe0..a2a63b9c4 100644 --- a/tests/Application.Routers/Route.fooParameter.phpt +++ b/tests/Application.Routers/Route.fooParameter.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with FooParameter */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.fullMatchParam.phpt b/tests/Application.Routers/Route.fullMatchParam.phpt index 7d5220cbb..571c17d9e 100644 --- a/tests/Application.Routers/Route.fullMatchParam.phpt +++ b/tests/Application.Routers/Route.fullMatchParam.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route and full match parameter. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.inc b/tests/Application.Routers/Route.inc index 71cb872ea..15761f4de 100644 --- a/tests/Application.Routers/Route.inc +++ b/tests/Application.Routers/Route.inc @@ -7,10 +7,8 @@ use Tester\Assert; -function testRouteIn(Nette\Application\IRouter $route, $url, $expectedPresenter=NULL, $expectedParams=NULL, $expectedUrl=NULL) +function testRouteIn(Nette\Application\IRouter $route, $url, $expectedPresenter = NULL, $expectedParams = NULL, $expectedUrl = NULL) { - // ==> $url - $url = new Nette\Http\UrlScript("http://example.com$url"); $url->appendQuery(array( 'test' => 'testvalue', @@ -25,17 +23,17 @@ function testRouteIn(Nette\Application\IRouter $route, $url, $expectedPresenter= $params = $request->getParameters(); asort($params); asort($expectedParams); - Assert::same( $expectedPresenter, $request->getPresenterName() ); - Assert::same( $expectedParams, $params ); + Assert::same($expectedPresenter, $request->getPresenterName()); + Assert::same($expectedParams, $params); unset($params['extra']); $request->setParameters($params); $result = $route->constructUrl($request, $url); $result = strncmp($result, 'http://example.com', 18) ? $result : substr($result, 18); - Assert::same( $expectedUrl, $result ); + Assert::same($expectedUrl, $result); } else { // not matched - Assert::null( $expectedPresenter ); + Assert::null($expectedPresenter); } } diff --git a/tests/Application.Routers/Route.longParameter.phpt b/tests/Application.Routers/Route.longParameter.phpt index df58e2043..73ed9bb49 100644 --- a/tests/Application.Routers/Route.longParameter.phpt +++ b/tests/Application.Routers/Route.longParameter.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with LongParameter */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.mandatoryAction.phpt b/tests/Application.Routers/Route.mandatoryAction.phpt index 512625154..044457a7b 100644 --- a/tests/Application.Routers/Route.mandatoryAction.phpt +++ b/tests/Application.Routers/Route.mandatoryAction.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route and non-optional action. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.modules.phpt b/tests/Application.Routers/Route.modules.phpt index 54d81a089..378c14fca 100644 --- a/tests/Application.Routers/Route.modules.phpt +++ b/tests/Application.Routers/Route.modules.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with Modules */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -22,9 +22,9 @@ testRouteIn($route, '/abc', 'Module:Submodule:Abc', array( ), '/abc?test=testvalue'); testRouteIn($route, '/'); -Assert::null( testRouteOut($route, 'Homepage') ); -Assert::null( testRouteOut($route, 'Module:Homepage') ); -Assert::same( 'http://example.com/homepage', testRouteOut($route, 'Module:Submodule:Homepage') ); +Assert::null(testRouteOut($route, 'Homepage')); +Assert::null(testRouteOut($route, 'Module:Homepage')); +Assert::same('http://example.com/homepage', testRouteOut($route, 'Module:Submodule:Homepage')); $route = new Route('', array( @@ -36,9 +36,9 @@ testRouteIn($route, '/', 'Module:Submodule:Default', array( 'test' => 'testvalue', ), '/?test=testvalue'); -Assert::null( testRouteOut($route, 'Homepage') ); -Assert::null( testRouteOut($route, 'Module:Homepage') ); -Assert::same( 'http://example.com/homepage', testRouteOut($route, 'Module:Submodule:Homepage') ); +Assert::null(testRouteOut($route, 'Homepage')); +Assert::null(testRouteOut($route, 'Module:Homepage')); +Assert::same('http://example.com/homepage', testRouteOut($route, 'Module:Submodule:Homepage')); $route = new Route('/', array( @@ -49,9 +49,9 @@ testRouteIn($route, '/module.submodule', 'Module:Submodule:AnyDefault', array( 'test' => 'testvalue', ), '/module.submodule/?test=testvalue'); -Assert::null( testRouteOut($route, 'Homepage') ); -Assert::same( 'http://example.com/module/homepage', testRouteOut($route, 'Module:Homepage') ); -Assert::same( 'http://example.com/module.submodule/homepage', testRouteOut($route, 'Module:Submodule:Homepage') ); +Assert::null(testRouteOut($route, 'Homepage')); +Assert::same('http://example.com/module/homepage', testRouteOut($route, 'Module:Homepage')); +Assert::same('http://example.com/module.submodule/homepage', testRouteOut($route, 'Module:Submodule:Homepage')); $route = new Route('/', array( @@ -63,6 +63,6 @@ testRouteIn($route, '/module.submodule', 'Module:Submodule:Default', array( 'test' => 'testvalue', ), '/?test=testvalue'); -Assert::null( testRouteOut($route, 'Homepage') ); -Assert::same( 'http://example.com/module/homepage', testRouteOut($route, 'Module:Homepage') ); -Assert::same( 'http://example.com/module.submodule/homepage', testRouteOut($route, 'Module:Submodule:Homepage') ); +Assert::null(testRouteOut($route, 'Homepage')); +Assert::same('http://example.com/module/homepage', testRouteOut($route, 'Module:Homepage')); +Assert::same('http://example.com/module.submodule/homepage', testRouteOut($route, 'Module:Submodule:Homepage')); diff --git a/tests/Application.Routers/Route.noDefaultParams.phpt b/tests/Application.Routers/Route.noDefaultParams.phpt index 55f697df9..2030d6672 100644 --- a/tests/Application.Routers/Route.noDefaultParams.phpt +++ b/tests/Application.Routers/Route.noDefaultParams.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with NoDefaultParams */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.noParams.phpt b/tests/Application.Routers/Route.noParams.phpt index 80b43b991..c0b6442d6 100644 --- a/tests/Application.Routers/Route.noParams.phpt +++ b/tests/Application.Routers/Route.noParams.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route default usage. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.oneWay.phpt b/tests/Application.Routers/Route.oneWay.phpt index 3565a8d40..36a87c25b 100644 --- a/tests/Application.Routers/Route.oneWay.phpt +++ b/tests/Application.Routers/Route.oneWay.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with OneWay */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.optional.autooptional1.phpt b/tests/Application.Routers/Route.optional.autooptional1.phpt index 5fe6d0881..e3cb191b9 100644 --- a/tests/Application.Routers/Route.optional.autooptional1.phpt +++ b/tests/Application.Routers/Route.optional.autooptional1.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route and auto-optional as optional sequences. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.optional.autooptional2.phpt b/tests/Application.Routers/Route.optional.autooptional2.phpt index 72ee19164..2f625af32 100644 --- a/tests/Application.Routers/Route.optional.autooptional2.phpt +++ b/tests/Application.Routers/Route.optional.autooptional2.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route and auto-optional as optional sequences II. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.optional.module.phpt b/tests/Application.Routers/Route.optional.module.phpt index 372b57c84..869c8ae28 100644 --- a/tests/Application.Routers/Route.optional.module.phpt +++ b/tests/Application.Routers/Route.optional.module.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with module in optional sequence. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.optional.nested.phpt b/tests/Application.Routers/Route.optional.nested.phpt index a5d45f019..fc97e416d 100644 --- a/tests/Application.Routers/Route.optional.nested.phpt +++ b/tests/Application.Routers/Route.optional.nested.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with nested optional sequences. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.optional.phpt b/tests/Application.Routers/Route.optional.phpt index 2652e1132..bffd80366 100644 --- a/tests/Application.Routers/Route.optional.phpt +++ b/tests/Application.Routers/Route.optional.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with optional sequence. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.optional.precedence.phpt b/tests/Application.Routers/Route.optional.precedence.phpt index 7e21eec6e..d17f9e917 100644 --- a/tests/Application.Routers/Route.optional.precedence.phpt +++ b/tests/Application.Routers/Route.optional.precedence.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with optional sequence precedence. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.optional.preferred.nested1.phpt b/tests/Application.Routers/Route.optional.preferred.nested1.phpt index 923cba90c..4b9b8dd60 100644 --- a/tests/Application.Routers/Route.optional.preferred.nested1.phpt +++ b/tests/Application.Routers/Route.optional.preferred.nested1.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with 'required' optional sequences I. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.optional.preferred.nested2.phpt b/tests/Application.Routers/Route.optional.preferred.nested2.phpt index 6014324e4..63cd0cc65 100644 --- a/tests/Application.Routers/Route.optional.preferred.nested2.phpt +++ b/tests/Application.Routers/Route.optional.preferred.nested2.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with 'required' optional sequences II. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.optional.preferred.nested3.phpt b/tests/Application.Routers/Route.optional.preferred.nested3.phpt index 04e495204..47b6d00de 100644 --- a/tests/Application.Routers/Route.optional.preferred.nested3.phpt +++ b/tests/Application.Routers/Route.optional.preferred.nested3.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with 'required' optional sequences III. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.optional.preferred.phpt b/tests/Application.Routers/Route.optional.preferred.phpt index e9136b093..bf5c9a101 100644 --- a/tests/Application.Routers/Route.optional.preferred.phpt +++ b/tests/Application.Routers/Route.optional.preferred.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with 'required' optional sequence. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.optional.regexp.phpt b/tests/Application.Routers/Route.optional.regexp.phpt index f35f1b1af..9732cdd4f 100644 --- a/tests/Application.Routers/Route.optional.regexp.phpt +++ b/tests/Application.Routers/Route.optional.regexp.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with optional sequence and two parameters. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.secured.phpt b/tests/Application.Routers/Route.secured.phpt index e3d988d3c..073f9200a 100644 --- a/tests/Application.Routers/Route.secured.phpt +++ b/tests/Application.Routers/Route.secured.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with Secured */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.slash.phpt b/tests/Application.Routers/Route.slash.phpt index 4bf765259..f03854c4a 100644 --- a/tests/Application.Routers/Route.slash.phpt +++ b/tests/Application.Routers/Route.slash.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with slash in path. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -18,7 +18,7 @@ $route = new Route('', array( )); testRouteIn($route, '/a/b'); -Assert::null( testRouteOut($route, 'Presenter', array('param' => 'a/b')) ); +Assert::null(testRouteOut($route, 'Presenter', array('param' => 'a/b'))); $route = new Route('', array( diff --git a/tests/Application.Routers/Route.type.phpt b/tests/Application.Routers/Route.type.phpt index 100c3a52c..bca0279a9 100644 --- a/tests/Application.Routers/Route.type.phpt +++ b/tests/Application.Routers/Route.type.phpt @@ -4,9 +4,9 @@ * Test: Nette\Application\Routers\Route default usage. */ -use Nette\Application\Routers\Route, - Nette\Application\Request, - Tester\Assert; +use Nette\Application\Routers\Route; +use Nette\Application\Request; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.urlEncoding.phpt b/tests/Application.Routers/Route.urlEncoding.phpt index 0ba9af97d..a414838e8 100644 --- a/tests/Application.Routers/Route.urlEncoding.phpt +++ b/tests/Application.Routers/Route.urlEncoding.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with UrlEncoding */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.utf8Param.phpt b/tests/Application.Routers/Route.utf8Param.phpt index 3d38f60fa..ecc729630 100644 --- a/tests/Application.Routers/Route.utf8Param.phpt +++ b/tests/Application.Routers/Route.utf8Param.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route UTF-8 parameter. */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.variables.phpt b/tests/Application.Routers/Route.variables.phpt index 0989959a1..3df2ed366 100644 --- a/tests/Application.Routers/Route.variables.phpt +++ b/tests/Application.Routers/Route.variables.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with %variables% */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.withAbsolutePath.phpt b/tests/Application.Routers/Route.withAbsolutePath.phpt index 19c696890..34b70d8f8 100644 --- a/tests/Application.Routers/Route.withAbsolutePath.phpt +++ b/tests/Application.Routers/Route.withAbsolutePath.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with WithAbsolutePath */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.withDefaultPresenterAndAction.phpt b/tests/Application.Routers/Route.withDefaultPresenterAndAction.phpt index 0c836ddf1..3680d8f18 100644 --- a/tests/Application.Routers/Route.withDefaultPresenterAndAction.phpt +++ b/tests/Application.Routers/Route.withDefaultPresenterAndAction.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with WithDefaultPresenterAndAction */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.withHost.phpt b/tests/Application.Routers/Route.withHost.phpt index 1b2b79fc0..d79e4947a 100644 --- a/tests/Application.Routers/Route.withHost.phpt +++ b/tests/Application.Routers/Route.withHost.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with WithHost */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.withNamedParamsInQuery.phpt b/tests/Application.Routers/Route.withNamedParamsInQuery.phpt index 33a0ec0e8..a6db1fc72 100644 --- a/tests/Application.Routers/Route.withNamedParamsInQuery.phpt +++ b/tests/Application.Routers/Route.withNamedParamsInQuery.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with WithNamedParamsInQuery */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.withParamsInQuery.phpt b/tests/Application.Routers/Route.withParamsInQuery.phpt index 1a14dc531..2ebbfb048 100644 --- a/tests/Application.Routers/Route.withParamsInQuery.phpt +++ b/tests/Application.Routers/Route.withParamsInQuery.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with WithParamsInQuery */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/Route.withUserClassAlt.phpt b/tests/Application.Routers/Route.withUserClassAlt.phpt index 67cf4a6d7..2fa33986f 100644 --- a/tests/Application.Routers/Route.withUserClassAlt.phpt +++ b/tests/Application.Routers/Route.withUserClassAlt.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\Routers\Route with WithUserClassAlt */ -use Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/RouteList.basic.phpt b/tests/Application.Routers/RouteList.basic.phpt index 92755e238..2abc0c2cc 100644 --- a/tests/Application.Routers/RouteList.basic.phpt +++ b/tests/Application.Routers/RouteList.basic.phpt @@ -4,9 +4,9 @@ * Test: Nette\Application\Routers\RouteList default usage. */ -use Nette\Application\Routers\RouteList, - Nette\Application\Routers\Route, - Tester\Assert; +use Nette\Application\Routers\RouteList; +use Nette\Application\Routers\Route; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application.Routers/SimpleRouter.invalid.phpt b/tests/Application.Routers/SimpleRouter.invalid.phpt index 5b40d1546..7c35fa3c4 100644 --- a/tests/Application.Routers/SimpleRouter.invalid.phpt +++ b/tests/Application.Routers/SimpleRouter.invalid.phpt @@ -4,9 +4,9 @@ * Test: Nette\Application\Routers\SimpleRouter invalid request. */ -use Nette\Http, - Nette\Application\Routers\SimpleRouter, - Tester\Assert; +use Nette\Http; +use Nette\Application\Routers\SimpleRouter; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,20 +14,20 @@ require __DIR__ . '/../bootstrap.php'; -test(function() { +test(function () { $router = new SimpleRouter(); $url = new Http\UrlScript('http://nette.org?presenter[]=foo'); $httpRequest = new Http\Request($url); $req = $router->match($httpRequest); - Assert::null( $req ); + Assert::null($req); }); -test(function() { +test(function () { $router = new SimpleRouter(); $url = new Http\UrlScript('http://nette.org'); $httpRequest = new Http\Request($url); $req = $router->match($httpRequest); - Assert::null( $req ); + Assert::null($req); }); diff --git a/tests/Application.Routers/SimpleRouter.module.phpt b/tests/Application.Routers/SimpleRouter.module.phpt index 0cd447958..f0734cc89 100644 --- a/tests/Application.Routers/SimpleRouter.module.phpt +++ b/tests/Application.Routers/SimpleRouter.module.phpt @@ -4,9 +4,9 @@ * Test: Nette\Application\Routers\SimpleRouter and modules. */ -use Nette\Http, - Nette\Application, - Tester\Assert; +use Nette\Http; +use Nette\Application; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -24,10 +24,10 @@ $url->setQuery(array( $httpRequest = new Http\Request($url); $req = $router->match($httpRequest); -Assert::same( 'main:sub:myPresenter', $req->getPresenterName() ); +Assert::same('main:sub:myPresenter', $req->getPresenterName()); $url = $router->constructUrl($req, $httpRequest->getUrl()); -Assert::same( 'http://nette.org/file.php?presenter=myPresenter', $url ); +Assert::same('http://nette.org/file.php?presenter=myPresenter', $url); $req = new Application\Request( 'othermodule:presenter', @@ -35,4 +35,4 @@ $req = new Application\Request( array() ); $url = $router->constructUrl($req, $httpRequest->getUrl()); -Assert::null( $url ); +Assert::null($url); diff --git a/tests/Application.Routers/SimpleRouter.phpt b/tests/Application.Routers/SimpleRouter.phpt index 2fe480072..da506c47d 100644 --- a/tests/Application.Routers/SimpleRouter.phpt +++ b/tests/Application.Routers/SimpleRouter.phpt @@ -4,9 +4,9 @@ * Test: Nette\Application\Routers\SimpleRouter basic functions. */ -use Nette\Http, - Nette\Application\Routers\SimpleRouter, - Tester\Assert; +use Nette\Http; +use Nette\Application\Routers\SimpleRouter; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -28,11 +28,11 @@ $url->setQuery(array( $httpRequest = new Http\Request($url); $req = $router->match($httpRequest); -Assert::same( 'myPresenter', $req->getPresenterName() ); -Assert::same( 'action', $req->getParameter('action') ); -Assert::same( '12', $req->getParameter('id') ); -Assert::same( 'testvalue', $req->getParameter('test') ); -Assert::same( 'anyvalue', $req->getParameter('any') ); +Assert::same('myPresenter', $req->getPresenterName()); +Assert::same('action', $req->getParameter('action')); +Assert::same('12', $req->getParameter('id')); +Assert::same('testvalue', $req->getParameter('test')); +Assert::same('anyvalue', $req->getParameter('any')); $url = $router->constructUrl($req, $httpRequest->getUrl()); -Assert::same( 'http://nette.org/file.php?action=action&test=testvalue&presenter=myPresenter', $url ); +Assert::same('http://nette.org/file.php?action=action&test=testvalue&presenter=myPresenter', $url); diff --git a/tests/Application.Routers/SimpleRouter.secured.phpt b/tests/Application.Routers/SimpleRouter.secured.phpt index 4083531c8..456d56f32 100644 --- a/tests/Application.Routers/SimpleRouter.secured.phpt +++ b/tests/Application.Routers/SimpleRouter.secured.phpt @@ -4,9 +4,9 @@ * Test: Nette\Application\Routers\SimpleRouter with secured connection. */ -use Nette\Http, - Nette\Application, - Tester\Assert; +use Nette\Http; +use Nette\Application; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -31,4 +31,4 @@ $req = new Application\Request( ); $url = $router->constructUrl($req, $httpRequest->getUrl()); -Assert::same( 'https://nette.org/file.php?presenter=othermodule%3Apresenter', $url ); +Assert::same('https://nette.org/file.php?presenter=othermodule%3Apresenter', $url); diff --git a/tests/Application.templates/Presenter.formatLayoutTemplateFiles.phpt b/tests/Application.templates/Presenter.formatLayoutTemplateFiles.phpt index bab4848d7..3e4c7f4b1 100644 --- a/tests/Application.templates/Presenter.formatLayoutTemplateFiles.phpt +++ b/tests/Application.templates/Presenter.formatLayoutTemplateFiles.phpt @@ -4,8 +4,8 @@ * Test: Presenter::formatLayoutTemplateFiles. */ -use Nette\Application\UI\Presenter, - Tester\Assert; +use Nette\Application\UI\Presenter; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -13,54 +13,54 @@ require __DIR__ . '/one/Presenter1.inc'; require __DIR__ . '/two/Presenter2.inc'; -test(function() { // with subdir templates +test(function () { // with subdir templates $presenter = new Presenter1; $presenter->setParent(NULL, 'One'); $presenter->setLayout('my'); - Assert::same( array( + Assert::same(array( __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One/@my.latte', __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One.@my.latte', __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/@my.latte', - ), $presenter->formatLayoutTemplateFiles() ); + ), $presenter->formatLayoutTemplateFiles()); }); -test(function() { // without subdir templates +test(function () { // without subdir templates $presenter = new Presenter2; $presenter->setParent(NULL, 'Two'); - Assert::same( array( + Assert::same(array( __DIR__ . '/templates/Two/@layout.latte', __DIR__ . '/templates/Two.@layout.latte', __DIR__ . '/templates/@layout.latte', - ), $presenter->formatLayoutTemplateFiles() ); + ), $presenter->formatLayoutTemplateFiles()); }); -test(function() { // with module & subdir templates +test(function () { // with module & subdir templates $presenter = new Presenter1; $presenter->setParent(NULL, 'Module:SubModule:One'); - Assert::same( array( + Assert::same(array( __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One/@layout.latte', __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One.@layout.latte', __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/@layout.latte', __DIR__ . '/templates/@layout.latte', dirname(__DIR__) . '/templates/@layout.latte', - ), $presenter->formatLayoutTemplateFiles() ); + ), $presenter->formatLayoutTemplateFiles()); }); -test(function() { // with module & without subdir templates +test(function () { // with module & without subdir templates $presenter = new Presenter2; $presenter->setParent(NULL, 'Module:SubModule:Two'); - Assert::same( array( + Assert::same(array( __DIR__ . '/templates/Two/@layout.latte', __DIR__ . '/templates/Two.@layout.latte', __DIR__ . '/templates/@layout.latte', dirname(__DIR__) . '/templates/@layout.latte', dirname(dirname(__DIR__)) . '/templates/@layout.latte', - ), $presenter->formatLayoutTemplateFiles() ); + ), $presenter->formatLayoutTemplateFiles()); }); diff --git a/tests/Application.templates/Presenter.formatTemplateFiles.phpt b/tests/Application.templates/Presenter.formatTemplateFiles.phpt index 285d8c4fa..0b6000ea7 100644 --- a/tests/Application.templates/Presenter.formatTemplateFiles.phpt +++ b/tests/Application.templates/Presenter.formatTemplateFiles.phpt @@ -4,8 +4,8 @@ * Test: Presenter::formatTemplateFiles. */ -use Nette\Application\UI\Presenter, - Tester\Assert; +use Nette\Application\UI\Presenter; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -13,49 +13,49 @@ require __DIR__ . '/one/Presenter1.inc'; require __DIR__ . '/two/Presenter2.inc'; -test(function() { // with subdir templates +test(function () { // with subdir templates $presenter = new Presenter1; $presenter->setParent(NULL, 'One'); $presenter->setView('view'); - Assert::same( array( + Assert::same(array( __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One/view.latte', __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One.view.latte', - ), $presenter->formatTemplateFiles() ); + ), $presenter->formatTemplateFiles()); }); -test(function() { // without subdir templates +test(function () { // without subdir templates $presenter = new Presenter2; $presenter->setParent(NULL, 'Two'); $presenter->setView('view'); - Assert::same( array( + Assert::same(array( __DIR__ . '/templates/Two/view.latte', __DIR__ . '/templates/Two.view.latte', - ), $presenter->formatTemplateFiles() ); + ), $presenter->formatTemplateFiles()); }); -test(function() { // with module & subdir templates +test(function () { // with module & subdir templates $presenter = new Presenter1; $presenter->setParent(NULL, 'Module:One'); $presenter->setView('view'); - Assert::same( array( + Assert::same(array( __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One/view.latte', __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One.view.latte', - ), $presenter->formatTemplateFiles() ); + ), $presenter->formatTemplateFiles()); }); -test(function() { // with module & without subdir templates +test(function () { // with module & without subdir templates $presenter = new Presenter2; $presenter->setParent(NULL, 'Module:Two'); $presenter->setView('view'); - Assert::same( array( + Assert::same(array( __DIR__ . '/templates/Two/view.latte', __DIR__ . '/templates/Two.view.latte', - ), $presenter->formatTemplateFiles() ); + ), $presenter->formatTemplateFiles()); }); diff --git a/tests/Application/Control.isControlInvalid.phpt b/tests/Application/Control.isControlInvalid.phpt index 476583edc..dc7e2a9fd 100644 --- a/tests/Application/Control.isControlInvalid.phpt +++ b/tests/Application/Control.isControlInvalid.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\UI\Control::isControlInvalid() */ -use Nette\Application\UI, - Tester\Assert; +use Nette\Application\UI; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -17,7 +17,7 @@ class TestControl extends UI\Control } -test(function() { +test(function () { $control = new TestControl(); $child = new TestControl(); $control->addComponent($child, 'foo'); @@ -28,7 +28,7 @@ test(function() { }); -test(function() { +test(function () { $control = new TestControl(); $child = new Nette\ComponentModel\Container(); $grandChild = new TestControl(); diff --git a/tests/Application/FileResponse.contentDisposition.phpt b/tests/Application/FileResponse.contentDisposition.phpt index 673e9fb48..c940a284f 100644 --- a/tests/Application/FileResponse.contentDisposition.phpt +++ b/tests/Application/FileResponse.contentDisposition.phpt @@ -4,9 +4,9 @@ * Test: Nette\Application\Responses\FileResponse. */ -use Nette\Application\Responses\FileResponse, - Nette\Http, - Tester\Assert; +use Nette\Application\Responses\FileResponse; +use Nette\Http; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -16,7 +16,7 @@ if (PHP_SAPI === 'cli') { } -test(function() { +test(function () { $file = __FILE__; $fileResponse = new FileResponse($file); $origData = file_get_contents($file); @@ -27,12 +27,12 @@ test(function() { ob_start(); $fileResponse->send(new Http\Request(new Http\UrlScript), $response = new Http\Response); - Assert::same( $origData, ob_get_clean() ); - Assert::same( 'attachment; filename="' . $fileName . '"; filename*=utf-8\'\'' . rawurlencode($fileName), $response->getHeader('Content-Disposition') ); + Assert::same($origData, ob_get_clean()); + Assert::same('attachment; filename="' . $fileName . '"; filename*=utf-8\'\'' . rawurlencode($fileName), $response->getHeader('Content-Disposition')); }); -test(function() { +test(function () { $file = __FILE__; $fileResponse = new FileResponse($file, NULL, NULL, FALSE); $origData = file_get_contents($file); @@ -43,12 +43,12 @@ test(function() { ob_start(); $fileResponse->send(new Http\Request(new Http\UrlScript), $response = new Http\Response); - Assert::same( $origData, ob_get_clean() ); + Assert::same($origData, ob_get_clean()); Assert::same('inline; filename="' . $fileName . '"; filename*=utf-8\'\'' . rawurlencode($fileName), $response->getHeader('Content-Disposition')); }); -test(function() { +test(function () { $file = __FILE__; $fileName = 'žluťoučký kůň.txt'; $fileResponse = new FileResponse($file, $fileName); @@ -57,6 +57,6 @@ test(function() { ob_start(); $fileResponse->send(new Http\Request(new Http\UrlScript), $response = new Http\Response); - Assert::same( $origData, ob_get_clean() ); + Assert::same($origData, ob_get_clean()); Assert::same('attachment; filename="' . $fileName . '"; filename*=utf-8\'\'' . rawurlencode($fileName), $response->getHeader('Content-Disposition')); }); diff --git a/tests/Application/FileResponse.full.phpt b/tests/Application/FileResponse.full.phpt index 9e16fc8d8..364733695 100644 --- a/tests/Application/FileResponse.full.phpt +++ b/tests/Application/FileResponse.full.phpt @@ -4,20 +4,20 @@ * Test: Nette\Application\Responses\FileResponse. */ -use Nette\Application\Responses\FileResponse, - Nette\Http, - Tester\Assert; +use Nette\Application\Responses\FileResponse; +use Nette\Http; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test(function() { +test(function () { $file = __FILE__; $fileResponse = new FileResponse($file); $origData = file_get_contents($file); ob_start(); $fileResponse->send(new Http\Request(new Http\UrlScript), new Http\Response); - Assert::same( $origData, ob_get_clean() ); + Assert::same($origData, ob_get_clean()); }); diff --git a/tests/Application/FileResponse.range.phpt b/tests/Application/FileResponse.range.phpt index 45be28716..802e70cd9 100644 --- a/tests/Application/FileResponse.range.phpt +++ b/tests/Application/FileResponse.range.phpt @@ -5,9 +5,9 @@ * @httpCode - */ -use Nette\Application\Responses\FileResponse, - Nette\Http, - Tester\Assert; +use Nette\Application\Responses\FileResponse; +use Nette\Http; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -17,83 +17,83 @@ $file = __FILE__; $fileResponse = new FileResponse($file); $origData = file_get_contents($file); -test(function() use ($fileResponse, $origData) { +test(function () use ($fileResponse, $origData) { ob_start(); $fileResponse->send( new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, array('range' => 'bytes=10-20')), $response = new Http\Response ); - Assert::same( substr($origData, 10, 11), ob_get_clean() ); - Assert::same( 206, $response->getCode() ); + Assert::same(substr($origData, 10, 11), ob_get_clean()); + Assert::same(206, $response->getCode()); }); -test(function() use ($fileResponse, $origData) { +test(function () use ($fileResponse, $origData) { ob_start(); $fileResponse->send( new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, array('range' => 'bytes=10-10')), new Http\Response ); - Assert::same( substr($origData, 10, 1), ob_get_clean() ); + Assert::same(substr($origData, 10, 1), ob_get_clean()); }); -test(function() use ($fileResponse, $origData, $file) { +test(function () use ($fileResponse, $origData, $file) { ob_start(); $fileResponse->send( new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, array('range' => 'bytes=10-' . filesize($file))), new Http\Response ); - Assert::same( substr($origData, 10), ob_get_clean() ); + Assert::same(substr($origData, 10), ob_get_clean()); }); -test(function() use ($fileResponse, $origData) { // prefix +test(function () use ($fileResponse, $origData) { // prefix ob_start(); $fileResponse->send( new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, array('range' => 'bytes=20-')), new Http\Response ); - Assert::same( substr($origData, 20), ob_get_clean() ); + Assert::same(substr($origData, 20), ob_get_clean()); }); -test(function() use ($fileResponse, $origData, $file) { // prefix +test(function () use ($fileResponse, $origData, $file) { // prefix ob_start(); $fileResponse->send( new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, array('range' => 'bytes=' . (filesize($file) - 1) . '-')), new Http\Response ); - Assert::same( substr($origData, -1), ob_get_clean() ); + Assert::same(substr($origData, -1), ob_get_clean()); }); -test(function() use ($fileResponse, $file) { // prefix +test(function () use ($fileResponse, $file) { // prefix ob_start(); $fileResponse->send( new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, array('range' => 'bytes=' . filesize($file) . '-')), $response = new Http\Response ); - Assert::same( '', ob_get_clean() ); - Assert::same( 416, $response->getCode() ); + Assert::same('', ob_get_clean()); + Assert::same(416, $response->getCode()); }); -test(function() use ($fileResponse, $origData) { // suffix +test(function () use ($fileResponse, $origData) { // suffix ob_start(); $fileResponse->send( new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, array('range' => 'bytes=-20')), new Http\Response ); - Assert::same( substr($origData, -20), ob_get_clean() ); + Assert::same(substr($origData, -20), ob_get_clean()); }); -test(function() use ($fileResponse, $origData, $file) { // suffix +test(function () use ($fileResponse, $origData, $file) { // suffix ob_start(); $fileResponse->send( new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, array('range' => 'bytes=-' . filesize($file))), new Http\Response ); - Assert::same( $origData, ob_get_clean() ); + Assert::same($origData, ob_get_clean()); }); diff --git a/tests/Application/Form.phpt b/tests/Application/Form.phpt index 0adfb9cde..0c0f13171 100644 --- a/tests/Application/Form.phpt +++ b/tests/Application/Form.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\UI\Form */ -use Nette\Application\UI, - Tester\Assert; +use Nette\Application\UI; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -17,14 +17,14 @@ class TestPresenter extends UI\Presenter } -test(function() { +test(function () { $presenter = new TestPresenter; $form = new UI\Form($presenter, 'name'); $form->setMethod($form::GET); // must not throw exception }); -test(function() { // compatibility with 2.0 +test(function () { // compatibility with 2.0 $presenter = new TestPresenter; $form = new UI\Form; $form->setAction('action'); diff --git a/tests/Application/MicroPresenter.invoke.phpt b/tests/Application/MicroPresenter.invoke.phpt index 1222db3ca..9c3645ba8 100644 --- a/tests/Application/MicroPresenter.invoke.phpt +++ b/tests/Application/MicroPresenter.invoke.phpt @@ -4,8 +4,8 @@ * Test: NetteModule\MicroPresenter */ -use Nette\Application\Request, - Tester\Assert; +use Nette\Application\Request; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -20,11 +20,11 @@ class Invokable extends Nette\Object } -test(function() { +test(function () { $presenter = $p = new NetteModule\MicroPresenter; $presenter->run(new Request('Nette:Micro', 'GET', array( - 'callback' => function($id, $page, $presenter) use ($p) { + 'callback' => function ($id, $page, $presenter) use ($p) { Assert::same($p, $presenter); Notes::add('Callback id ' . $id . ' page ' . $page); }, @@ -32,12 +32,12 @@ test(function() { 'page' => 2, ))); Assert::same(array( - 'Callback id 1 page 2' + 'Callback id 1 page 2', ), Notes::fetch()); }); -test(function() { +test(function () { $presenter = new NetteModule\MicroPresenter; $presenter->run(new Request('Nette:Micro', 'GET', array( @@ -46,6 +46,6 @@ test(function() { 'page' => 2, ))); Assert::same(array( - 'Callback id 1 page 2' + 'Callback id 1 page 2', ), Notes::fetch()); }); diff --git a/tests/Application/MicroPresenter.response.phpt b/tests/Application/MicroPresenter.response.phpt index 37a36b4d9..4d5db6f89 100644 --- a/tests/Application/MicroPresenter.response.phpt +++ b/tests/Application/MicroPresenter.response.phpt @@ -4,9 +4,9 @@ * Test: NetteModule\MicroPresenter */ -use Nette\Application\Request, - Nette\Http, - Tester\Assert; +use Nette\Application\Request; +use Nette\Http; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,165 +14,165 @@ require __DIR__ . '/../bootstrap.php'; class LatteFactory implements Nette\Bridges\ApplicationLatte\ILatteFactory { - private $engine; + private $engine; - public function __construct(Latte\Engine $engine) - { - $this->engine = $engine; - } + public function __construct(Latte\Engine $engine) + { + $this->engine = $engine; + } - public function create() - { - return $this->engine; - } + public function create() + { + return $this->engine; + } } class MicroContainer extends Nette\DI\Container { - protected $meta = array( - 'types' => array( - 'Nette\\Bridges\\ApplicationLatte\\ILatteFactory' => array(1 => array('latte.latteFactory')), - ), - ); - - public static function create() - { - $container = new self(); - $container->addService('latte.latteFactory', new LatteFactory(new Latte\Engine())); - return $container; - } + protected $meta = array( + 'types' => array( + 'Nette\\Bridges\\ApplicationLatte\\ILatteFactory' => array(1 => array('latte.latteFactory')), + ), + ); + + public static function create() + { + $container = new self(); + $container->addService('latte.latteFactory', new LatteFactory(new Latte\Engine())); + return $container; + } } class Responder { - public static function render(Nette\Application\Responses\TextResponse $response) - { - ob_start(); - $response->send(new Http\Request(new Http\UrlScript()), new Http\Response(NULL)); - return ob_get_clean(); - } + public static function render(Nette\Application\Responses\TextResponse $response) + { + ob_start(); + $response->send(new Http\Request(new Http\UrlScript()), new Http\Response(NULL)); + return ob_get_clean(); + } } test(function () { - $presenter = new NetteModule\MicroPresenter(MicroContainer::create()); - $response = $presenter->run(new Request('Nette:Micro', 'GET', array( - 'callback' => function () { - return 'test'; - }, - ))); - - Assert::type('Nette\Application\Responses\TextResponse', $response); - Assert::same('test', Responder::render($response)); + $presenter = new NetteModule\MicroPresenter(MicroContainer::create()); + $response = $presenter->run(new Request('Nette:Micro', 'GET', array( + 'callback' => function () { + return 'test'; + }, + ))); + + Assert::type('Nette\Application\Responses\TextResponse', $response); + Assert::same('test', Responder::render($response)); }); test(function () { - $presenter = new NetteModule\MicroPresenter(MicroContainer::create()); - $response = $presenter->run(new Request('Nette:Micro', 'GET', array( - 'callback' => function ($param) { - return $param; - }, - 'param' => 'test' - ))); - - Assert::type('Nette\Application\Responses\TextResponse', $response); - Assert::same('test', Responder::render($response)); + $presenter = new NetteModule\MicroPresenter(MicroContainer::create()); + $response = $presenter->run(new Request('Nette:Micro', 'GET', array( + 'callback' => function ($param) { + return $param; + }, + 'param' => 'test', + ))); + + Assert::type('Nette\Application\Responses\TextResponse', $response); + Assert::same('test', Responder::render($response)); }); test(function () { - $presenter = new NetteModule\MicroPresenter(MicroContainer::create()); - $response = $presenter->run(new Request('Nette:Micro', 'GET', array( - 'callback' => function () { - return '{=date(Y)}'; - }, - ))); - - Assert::type('Nette\Application\Responses\TextResponse', $response); - Assert::same(date('Y'), Responder::render($response)); + $presenter = new NetteModule\MicroPresenter(MicroContainer::create()); + $response = $presenter->run(new Request('Nette:Micro', 'GET', array( + 'callback' => function () { + return '{=date(Y)}'; + }, + ))); + + Assert::type('Nette\Application\Responses\TextResponse', $response); + Assert::same(date('Y'), Responder::render($response)); }); test(function () { - $presenter = new NetteModule\MicroPresenter(MicroContainer::create()); - $response = $presenter->run(new Request('Nette:Micro', 'GET', array( - 'callback' => function () { - return array(new SplFileInfo(Tester\FileMock::create('{$param}')), array()); - }, - 'param' => 'test', - ))); - - Assert::type('Nette\Application\Responses\TextResponse', $response); - Assert::same('test', Responder::render($response)); + $presenter = new NetteModule\MicroPresenter(MicroContainer::create()); + $response = $presenter->run(new Request('Nette:Micro', 'GET', array( + 'callback' => function () { + return array(new SplFileInfo(Tester\FileMock::create('{$param}')), array()); + }, + 'param' => 'test', + ))); + + Assert::type('Nette\Application\Responses\TextResponse', $response); + Assert::same('test', Responder::render($response)); }); test(function () { - $latteFactory = new LatteFactory(new Latte\Engine()); - $presenter = new NetteModule\MicroPresenter; - - $response = $presenter->run(new Request('Nette:Micro', 'GET', array( - 'callback' => function ($presenter) use ($latteFactory) { - $template = $presenter->createTemplate(NULL, function () use ($latteFactory) { - return $latteFactory->create(); - }); - $template->getLatte()->setLoader(new Latte\Loaders\StringLoader); - $template->setFile('test'); - - return $template; - }, - ))); - - Assert::type('Nette\Application\Responses\TextResponse', $response); - Assert::same('test', Responder::render($response)); + $latteFactory = new LatteFactory(new Latte\Engine()); + $presenter = new NetteModule\MicroPresenter; + + $response = $presenter->run(new Request('Nette:Micro', 'GET', array( + 'callback' => function ($presenter) use ($latteFactory) { + $template = $presenter->createTemplate(NULL, function () use ($latteFactory) { + return $latteFactory->create(); + }); + $template->getLatte()->setLoader(new Latte\Loaders\StringLoader); + $template->setFile('test'); + + return $template; + }, + ))); + + Assert::type('Nette\Application\Responses\TextResponse', $response); + Assert::same('test', Responder::render($response)); }); test(function () { - $latteFactory = new LatteFactory(new Latte\Engine()); - $presenter = new NetteModule\MicroPresenter; - - $response = $presenter->run(new Request('Nette:Micro', 'GET', array( - 'callback' => function ($presenter) use ($latteFactory) { - $template = $presenter->createTemplate(NULL, function () use ($latteFactory) { - return $latteFactory->create(); - }); - $template->getLatte()->setLoader(new Latte\Loaders\FileLoader()); - $template->setFile(new SplFileInfo(Tester\FileMock::create('{$param}'))); - $template->setParameters(array('param' => 'test')); - - return $template; - }, - ))); - - Assert::type('Nette\Application\Responses\TextResponse', $response); - Assert::same('test', Responder::render($response)); + $latteFactory = new LatteFactory(new Latte\Engine()); + $presenter = new NetteModule\MicroPresenter; + + $response = $presenter->run(new Request('Nette:Micro', 'GET', array( + 'callback' => function ($presenter) use ($latteFactory) { + $template = $presenter->createTemplate(NULL, function () use ($latteFactory) { + return $latteFactory->create(); + }); + $template->getLatte()->setLoader(new Latte\Loaders\FileLoader()); + $template->setFile(new SplFileInfo(Tester\FileMock::create('{$param}'))); + $template->setParameters(array('param' => 'test')); + + return $template; + }, + ))); + + Assert::type('Nette\Application\Responses\TextResponse', $response); + Assert::same('test', Responder::render($response)); }); test(function () { - $filename = 'notfound.latte'; - Assert::throws(function () use ($filename) { - $latteFactory = new LatteFactory(new Latte\Engine()); - $presenter = new NetteModule\MicroPresenter; - - $response = $presenter->run(new Request('Nette:Micro', 'GET', array( - 'callback' => function ($presenter) use ($latteFactory, $filename) { - $template = $presenter->createTemplate(NULL, function () use ($latteFactory) { - return $latteFactory->create(); - }); - $template->getLatte()->setLoader(new Latte\Loaders\FileLoader()); - $template->setFile($filename); - $template->setParameters(array('param' => 'test')); - - return $template; - }, - ))); - - Responder::render($response); - }, '\RuntimeException', "Missing template file '$filename'."); + $filename = 'notfound.latte'; + Assert::exception(function () use ($filename) { + $latteFactory = new LatteFactory(new Latte\Engine()); + $presenter = new NetteModule\MicroPresenter; + + $response = $presenter->run(new Request('Nette:Micro', 'GET', array( + 'callback' => function ($presenter) use ($latteFactory, $filename) { + $template = $presenter->createTemplate(NULL, function () use ($latteFactory) { + return $latteFactory->create(); + }); + $template->getLatte()->setLoader(new Latte\Loaders\FileLoader()); + $template->setFile($filename); + $template->setParameters(array('param' => 'test')); + + return $template; + }, + ))); + + Responder::render($response); + }, '\RuntimeException', "Missing template file '$filename'."); }); diff --git a/tests/Application/Presenter.link().phpt b/tests/Application/Presenter.link().phpt index c2e2a1346..fcbca3505 100644 --- a/tests/Application/Presenter.link().phpt +++ b/tests/Application/Presenter.link().phpt @@ -4,9 +4,9 @@ * Test: Nette\Application\UI\Presenter::link() */ -use Nette\Http, - Nette\Application, - Tester\Assert; +use Nette\Http; +use Nette\Application; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -80,79 +80,79 @@ class TestPresenter extends Application\UI\Presenter $this->invalidLinkMode = self::INVALID_LINK_TEXTUAL; // Presenter & action link - Assert::same( '/index.php?action=product&presenter=Test', $this->link('product', array('var1' => $this->var1)) ); - Assert::same( '/index.php?var1=20&action=product&presenter=Test', $this->link('product', array('var1' => $this->var1 * 2, 'ok' => TRUE)) ); - Assert::same( '/index.php?var1=1&ok=0&action=product&presenter=Test', $this->link('product', array('var1' => TRUE, 'ok' => '0')) ); - Assert::same( "#error: Invalid value for persistent parameter 'ok' in 'Test', expected boolean.", $this->link('product', array('var1' => NULL, 'ok' => 'a')) ); - Assert::same( "#error: Invalid value for persistent parameter 'var1' in 'Test', expected integer.", $this->link('product', array('var1' => array(1), 'ok' => FALSE)) ); - Assert::same( "#error: Unable to pass parameters to action 'Test:product', missing corresponding method.", $this->link('product', 1, 2) ); - Assert::same( '/index.php?x=1&y=2&action=product&presenter=Test', $this->link('product', array('x' => 1, 'y' => 2)) ); - Assert::same( '/index.php?action=product&presenter=Test', $this->link('product') ); - Assert::same( '#error: Destination must be non-empty string.', $this->link('') ); - Assert::same( '/index.php?x=1&y=2&action=product&presenter=Test', $this->link('product?x=1&y=2') ); - Assert::same( '/index.php?x=1&y=2&action=product&presenter=Test#fragment', $this->link('product?x=1&y=2#fragment') ); - Assert::same( 'http://localhost/index.php?x=1&y=2&action=product&presenter=Test#fragment', $this->link('//product?x=1&y=2#fragment') ); + Assert::same('/index.php?action=product&presenter=Test', $this->link('product', array('var1' => $this->var1))); + Assert::same('/index.php?var1=20&action=product&presenter=Test', $this->link('product', array('var1' => $this->var1 * 2, 'ok' => TRUE))); + Assert::same('/index.php?var1=1&ok=0&action=product&presenter=Test', $this->link('product', array('var1' => TRUE, 'ok' => '0'))); + Assert::same("#error: Invalid value for persistent parameter 'ok' in 'Test', expected boolean.", $this->link('product', array('var1' => NULL, 'ok' => 'a'))); + Assert::same("#error: Invalid value for persistent parameter 'var1' in 'Test', expected integer.", $this->link('product', array('var1' => array(1), 'ok' => FALSE))); + Assert::same("#error: Unable to pass parameters to action 'Test:product', missing corresponding method.", $this->link('product', 1, 2)); + Assert::same('/index.php?x=1&y=2&action=product&presenter=Test', $this->link('product', array('x' => 1, 'y' => 2))); + Assert::same('/index.php?action=product&presenter=Test', $this->link('product')); + Assert::same('#error: Destination must be non-empty string.', $this->link('')); + Assert::same('/index.php?x=1&y=2&action=product&presenter=Test', $this->link('product?x=1&y=2')); + Assert::same('/index.php?x=1&y=2&action=product&presenter=Test#fragment', $this->link('product?x=1&y=2#fragment')); + Assert::same('http://localhost/index.php?x=1&y=2&action=product&presenter=Test#fragment', $this->link('//product?x=1&y=2#fragment')); // Other presenter & action link - Assert::same( '/index.php?var1=10&action=product&presenter=Other', $this->link('Other:product', array('var1' => $this->var1)) ); - Assert::same( '/index.php?action=product&presenter=Other', $this->link('Other:product', array('var1' => $this->var1 * 2)) ); - Assert::same( '/index.php?var1=123&presenter=Nette%3AMicro', $this->link('Nette:Micro:', array('var1' => 123)) ); + Assert::same('/index.php?var1=10&action=product&presenter=Other', $this->link('Other:product', array('var1' => $this->var1))); + Assert::same('/index.php?action=product&presenter=Other', $this->link('Other:product', array('var1' => $this->var1 * 2))); + Assert::same('/index.php?var1=123&presenter=Nette%3AMicro', $this->link('Nette:Micro:', array('var1' => 123))); // Presenter & signal link - Assert::same( '/index.php?action=default&do=buy&presenter=Test', $this->link('buy!', array('var1' => $this->var1)) ); - Assert::same( '/index.php?var1=20&action=default&do=buy&presenter=Test', $this->link('buy!', array('var1' => $this->var1 * 2)) ); - Assert::same( '/index.php?y=2&action=default&do=buy&presenter=Test', $this->link('buy!', 1, 2) ); - Assert::same( '/index.php?y=2&bool=1&str=1&action=default&do=buy&presenter=Test', $this->link('buy!', '1', '2', TRUE, TRUE) ); - Assert::same( '/index.php?y=2&str=0&action=default&do=buy&presenter=Test', $this->link('buy!', '1', '2', FALSE, FALSE) ); - Assert::same( '/index.php?action=default&do=buy&presenter=Test', $this->link('buy!', array(1), (object) array(1)) ); - Assert::same( '/index.php?y=2&action=default&do=buy&presenter=Test', $this->link('buy!', array(1, 'y' => 2)) ); - Assert::same( '/index.php?y=2&action=default&do=buy&presenter=Test', $this->link('buy!', array('x' => 1, 'y' => 2, 'var1' => $this->var1)) ); - Assert::same( '#error: Signal must be non-empty string.', $this->link('!') ); - Assert::same( '/index.php?action=default&presenter=Test', $this->link('this', array('var1' => $this->var1)) ); - Assert::same( '/index.php?action=default&presenter=Test', $this->link('this!', array('var1' => $this->var1)) ); - Assert::same( '/index.php?sort%5By%5D%5Basc%5D=1&action=default&presenter=Test', $this->link('this', array('sort' => array('y' => array('asc' => TRUE)))) ); + Assert::same('/index.php?action=default&do=buy&presenter=Test', $this->link('buy!', array('var1' => $this->var1))); + Assert::same('/index.php?var1=20&action=default&do=buy&presenter=Test', $this->link('buy!', array('var1' => $this->var1 * 2))); + Assert::same('/index.php?y=2&action=default&do=buy&presenter=Test', $this->link('buy!', 1, 2)); + Assert::same('/index.php?y=2&bool=1&str=1&action=default&do=buy&presenter=Test', $this->link('buy!', '1', '2', TRUE, TRUE)); + Assert::same('/index.php?y=2&str=0&action=default&do=buy&presenter=Test', $this->link('buy!', '1', '2', FALSE, FALSE)); + Assert::same('/index.php?action=default&do=buy&presenter=Test', $this->link('buy!', array(1), (object) array(1))); + Assert::same('/index.php?y=2&action=default&do=buy&presenter=Test', $this->link('buy!', array(1, 'y' => 2))); + Assert::same('/index.php?y=2&action=default&do=buy&presenter=Test', $this->link('buy!', array('x' => 1, 'y' => 2, 'var1' => $this->var1))); + Assert::same('#error: Signal must be non-empty string.', $this->link('!')); + Assert::same('/index.php?action=default&presenter=Test', $this->link('this', array('var1' => $this->var1))); + Assert::same('/index.php?action=default&presenter=Test', $this->link('this!', array('var1' => $this->var1))); + Assert::same('/index.php?sort%5By%5D%5Basc%5D=1&action=default&presenter=Test', $this->link('this', array('sort' => array('y' => array('asc' => TRUE))))); // Presenter & signal link type checking - Assert::same( "#error: Invalid value for parameter 'x' in method TestPresenter::handlebuy(), expected integer.", $this->link('buy!', array(array())) ); - Assert::same( "/index.php?action=default&do=buy&presenter=Test", $this->link('buy!', array(new stdClass)) ); + Assert::same("#error: Invalid value for parameter 'x' in method TestPresenter::handlebuy(), expected integer.", $this->link('buy!', array(array()))); + Assert::same('/index.php?action=default&do=buy&presenter=Test', $this->link('buy!', array(new stdClass))); // Component link - Assert::same( '#error: Signal must be non-empty string.', $this['mycontrol']->link('', 0, 1) ); - Assert::same( '/index.php?mycontrol-x=0&mycontrol-y=1&action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click', 0, 1) ); - Assert::same( '/index.php?mycontrol-x=0a&mycontrol-y=1a&action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click', '0a', '1a') ); - Assert::same( '/index.php?mycontrol-x=1&action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click', array(1), (object) array(1)) ); - Assert::same( '/index.php?mycontrol-x=1&action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click', TRUE, FALSE) ); - Assert::same( '/index.php?action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click', NULL, '') ); - Assert::same( "#error: Passed more parameters than method TestControl::handleClick() expects.", $this['mycontrol']->link('click', 1, 2, 3) ); - Assert::same( '/index.php?mycontrol-x=1&mycontrol-y=2&action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click!', array('x' => 1, 'y' => 2, 'round' => 0)) ); - Assert::same( '/index.php?mycontrol-x=1&mycontrol-round=1&action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click', array('x' => 1, 'round' => 1)) ); - Assert::same( '/index.php?mycontrol-x=1&mycontrol-round=1&action=default&presenter=Test', $this['mycontrol']->link('this', array('x' => 1, 'round' => 1)) ); - Assert::same( '/index.php?mycontrol-x=1&mycontrol-round=1&action=default&presenter=Test', $this['mycontrol']->link('this?x=1&round=1') ); - Assert::same( '/index.php?mycontrol-x=1&mycontrol-round=1&action=default&presenter=Test#frag', $this['mycontrol']->link('this?x=1&round=1#frag') ); - Assert::same( 'http://localhost/index.php?mycontrol-x=1&mycontrol-round=1&action=default&presenter=Test#frag', $this['mycontrol']->link('//this?x=1&round=1#frag') ); + Assert::same('#error: Signal must be non-empty string.', $this['mycontrol']->link('', 0, 1)); + Assert::same('/index.php?mycontrol-x=0&mycontrol-y=1&action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click', 0, 1)); + Assert::same('/index.php?mycontrol-x=0a&mycontrol-y=1a&action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click', '0a', '1a')); + Assert::same('/index.php?mycontrol-x=1&action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click', array(1), (object) array(1))); + Assert::same('/index.php?mycontrol-x=1&action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click', TRUE, FALSE)); + Assert::same('/index.php?action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click', NULL, '')); + Assert::same('#error: Passed more parameters than method TestControl::handleClick() expects.', $this['mycontrol']->link('click', 1, 2, 3)); + Assert::same('/index.php?mycontrol-x=1&mycontrol-y=2&action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click!', array('x' => 1, 'y' => 2, 'round' => 0))); + Assert::same('/index.php?mycontrol-x=1&mycontrol-round=1&action=default&do=mycontrol-click&presenter=Test', $this['mycontrol']->link('click', array('x' => 1, 'round' => 1))); + Assert::same('/index.php?mycontrol-x=1&mycontrol-round=1&action=default&presenter=Test', $this['mycontrol']->link('this', array('x' => 1, 'round' => 1))); + Assert::same('/index.php?mycontrol-x=1&mycontrol-round=1&action=default&presenter=Test', $this['mycontrol']->link('this?x=1&round=1')); + Assert::same('/index.php?mycontrol-x=1&mycontrol-round=1&action=default&presenter=Test#frag', $this['mycontrol']->link('this?x=1&round=1#frag')); + Assert::same('http://localhost/index.php?mycontrol-x=1&mycontrol-round=1&action=default&presenter=Test#frag', $this['mycontrol']->link('//this?x=1&round=1#frag')); // Component link type checking - Assert::same( "#error: Invalid value for persistent parameter 'order' in 'mycontrol', expected array.", $this['mycontrol']->link('click', array('order' => 1)) ); - Assert::same( "#error: Invalid value for persistent parameter 'round' in 'mycontrol', expected integer.", $this['mycontrol']->link('click', array('round' => array())) ); + Assert::same("#error: Invalid value for persistent parameter 'order' in 'mycontrol', expected array.", $this['mycontrol']->link('click', array('order' => 1))); + Assert::same("#error: Invalid value for persistent parameter 'round' in 'mycontrol', expected integer.", $this['mycontrol']->link('click', array('round' => array()))); $this['mycontrol']->order = 1; - Assert::same( "#error: Invalid value for persistent parameter 'order' in 'mycontrol', expected array.", $this['mycontrol']->link('click') ); + Assert::same("#error: Invalid value for persistent parameter 'order' in 'mycontrol', expected array.", $this['mycontrol']->link('click')); $this['mycontrol']->order = NULL; // silent invalid link mode $this->invalidLinkMode = self::INVALID_LINK_SILENT; - Assert::same('#', $this->link('product', array('var1' => null, 'ok' => 'a'))); + Assert::same('#', $this->link('product', array('var1' => NULL, 'ok' => 'a'))); // warning invalid link mode $this->invalidLinkMode = self::INVALID_LINK_WARNING; $me = $this; - Assert::error(function() use ($me) { - Assert::same('#', $me->link('product', array('var1' => null, 'ok' => 'a'))); + Assert::error(function () use ($me) { + Assert::same('#', $me->link('product', array('var1' => NULL, 'ok' => 'a'))); }, E_USER_WARNING, "Invalid link: Invalid value for persistent parameter 'ok' in 'Test', expected boolean."); // exception invalid link mode $this->invalidLinkMode = self::INVALID_LINK_EXCEPTION; - Assert::exception(function() use ($me) { - $me->link('product', array('var1' => null, 'ok' => 'a')); + Assert::exception(function () use ($me) { + $me->link('product', array('var1' => NULL, 'ok' => 'a')); }, 'Nette\Application\UI\InvalidLinkException', "Invalid value for persistent parameter 'ok' in 'Test', expected boolean."); } diff --git a/tests/Application/Presenter.paramChecking.phpt b/tests/Application/Presenter.paramChecking.phpt index baed26754..24e26ef4c 100644 --- a/tests/Application/Presenter.paramChecking.phpt +++ b/tests/Application/Presenter.paramChecking.phpt @@ -4,9 +4,9 @@ * Test: Nette\Application\UI\Presenter and checking params. */ -use Nette\Http, - Nette\Application, - Tester\Assert; +use Nette\Http; +use Nette\Application; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -33,66 +33,66 @@ $presenter->injectPrimary( ); -Assert::exception(function() use ($presenter) { +Assert::exception(function () use ($presenter) { $request = new Application\Request('Test', Http\Request::GET, array('action' => array())); $presenter->run($request); }, 'Nette\Application\BadRequestException', 'Action name is not alphanumeric string.'); -Assert::exception(function() use ($presenter) { +Assert::exception(function () use ($presenter) { $request = new Application\Request('Test', Http\Request::GET, array('do' => array())); $presenter->run($request); }, 'Nette\Application\BadRequestException', 'Signal name is not string.'); -Assert::exception(function() use ($presenter) { +Assert::exception(function () use ($presenter) { $request = new Application\Request('Test', Http\Request::GET, array('a' => array())); $presenter->run($request); }, 'Nette\Application\BadRequestException', "Invalid value for parameter 'a' in method TestPresenter::actionDefault(), expected scalar."); -Assert::exception(function() use ($presenter) { +Assert::exception(function () use ($presenter) { $request = new Application\Request('Test', Http\Request::GET, array('b' => array())); $presenter->run($request); }, 'Nette\Application\BadRequestException', "Invalid value for parameter 'b' in method TestPresenter::actionDefault(), expected scalar."); -Assert::exception(function() use ($presenter) { +Assert::exception(function () use ($presenter) { $request = new Application\Request('Test', Http\Request::GET, array('c' => 1)); $presenter->run($request); }, 'Nette\Application\BadRequestException', "Invalid value for parameter 'c' in method TestPresenter::actionDefault(), expected array."); -Assert::exception(function() use ($presenter) { +Assert::exception(function () use ($presenter) { $request = new Application\Request('Test', Http\Request::GET, array('d' => 1)); $presenter->run($request); }, 'Nette\Application\BadRequestException', "Invalid value for parameter 'd' in method TestPresenter::actionDefault(), expected array."); -Assert::exception(function() use ($presenter) { +Assert::exception(function () use ($presenter) { $request = new Application\Request('Test', Http\Request::GET, array('e' => 1.1)); $presenter->run($request); }, 'Nette\Application\BadRequestException', "Invalid value for parameter 'e' in method TestPresenter::actionDefault(), expected integer."); -Assert::exception(function() use ($presenter) { +Assert::exception(function () use ($presenter) { $request = new Application\Request('Test', Http\Request::GET, array('e' => '1 ')); $presenter->run($request); }, 'Nette\Application\BadRequestException', "Invalid value for parameter 'e' in method TestPresenter::actionDefault(), expected integer."); -Assert::exception(function() use ($presenter) { +Assert::exception(function () use ($presenter) { $request = new Application\Request('Test', Http\Request::GET, array('f' => '1 ')); $presenter->run($request); }, 'Nette\Application\BadRequestException', "Invalid value for parameter 'f' in method TestPresenter::actionDefault(), expected double."); -Assert::exception(function() use ($presenter) { +Assert::exception(function () use ($presenter) { $request = new Application\Request('Test', Http\Request::GET, array('g' => '')); $presenter->run($request); }, 'Nette\Application\BadRequestException', "Invalid value for parameter 'g' in method TestPresenter::actionDefault(), expected boolean."); -Assert::exception(function() use ($presenter) { +Assert::exception(function () use ($presenter) { $request = new Application\Request('Test', Http\Request::GET, array('bool' => array())); $presenter->run($request); }, 'Nette\Application\BadRequestException', "Invalid value for persistent parameter 'bool' in 'Test', expected boolean."); diff --git a/tests/Application/Presenter.storeRequest().phpt b/tests/Application/Presenter.storeRequest().phpt index 11a6172fa..90646b570 100644 --- a/tests/Application/Presenter.storeRequest().phpt +++ b/tests/Application/Presenter.storeRequest().phpt @@ -4,11 +4,11 @@ * Test: Nette\Application\UI\Presenter::storeRequest() */ -use Nette\Http, - Nette\Application, - Nette\DI, - Nette\Security, - Tester\Assert; +use Nette\Http; +use Nette\Application; +use Nette\DI; +use Nette\Security; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -42,7 +42,7 @@ class MockSessionSection extends Nette\Object implements \ArrayAccess public function __isset($name) { $this->testedKeyExistence = $name; - return false; + return FALSE; } public function __set($name, $value) diff --git a/tests/Application/PresenterComponent.redirect().phpt b/tests/Application/PresenterComponent.redirect().phpt index c717ba9da..f8fbdff0a 100644 --- a/tests/Application/PresenterComponent.redirect().phpt +++ b/tests/Application/PresenterComponent.redirect().phpt @@ -4,9 +4,9 @@ * Test: Nette\Application\UI\PresenterComponent::redirect() */ -use Nette\Http, - Nette\Application, - Tester\Assert; +use Nette\Http; +use Nette\Application; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -38,7 +38,7 @@ $presenter->injectPrimary( ); -test(function() use ($presenter) { +test(function () use ($presenter) { $presenter->redirect('foo'); Assert::type('Nette\Application\Responses\RedirectResponse', $presenter->response); Assert::same(302, $presenter->response->getCode()); @@ -46,7 +46,7 @@ test(function() use ($presenter) { }); -test(function() use ($presenter) { +test(function () use ($presenter) { $presenter->redirect('foo', array('arg' => 1)); Assert::type('Nette\Application\Responses\RedirectResponse', $presenter->response); Assert::same(302, $presenter->response->getCode()); @@ -54,7 +54,7 @@ test(function() use ($presenter) { }); -test(function() use ($presenter) { +test(function () use ($presenter) { $presenter->redirect('foo', 2); Assert::type('Nette\Application\Responses\RedirectResponse', $presenter->response); Assert::same(302, $presenter->response->getCode()); @@ -62,7 +62,7 @@ test(function() use ($presenter) { }); -test(function() use ($presenter) { +test(function () use ($presenter) { $presenter->redirect(301, 'foo', array('arg' => 1)); Assert::type('Nette\Application\Responses\RedirectResponse', $presenter->response); Assert::same(301, $presenter->response->getCode()); @@ -70,7 +70,7 @@ test(function() use ($presenter) { }); -test(function() use ($presenter) { +test(function () use ($presenter) { $presenter->redirect(301, 'foo', 2); Assert::type('Nette\Application\Responses\RedirectResponse', $presenter->response); Assert::same(301, $presenter->response->getCode()); diff --git a/tests/Application/PresenterComponentReflection.parseAnnotation.phpt b/tests/Application/PresenterComponentReflection.parseAnnotation.phpt index 8f159e7ff..0335e510b 100644 --- a/tests/Application/PresenterComponentReflection.parseAnnotation.phpt +++ b/tests/Application/PresenterComponentReflection.parseAnnotation.phpt @@ -4,8 +4,8 @@ * Test: PresenterComponentReflection annotation parser. */ -use Nette\Application\UI\PresenterComponentReflection as Reflection, - Tester\Assert; +use Nette\Application\UI\PresenterComponentReflection as Reflection; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Application/PresenterFactory.formatPresenterClass.phpt b/tests/Application/PresenterFactory.formatPresenterClass.phpt index 9ac12f461..ef18fbbd6 100644 --- a/tests/Application/PresenterFactory.formatPresenterClass.phpt +++ b/tests/Application/PresenterFactory.formatPresenterClass.phpt @@ -4,14 +4,14 @@ * Test: Nette\Application\PresenterFactory. */ -use Nette\Application\PresenterFactory, - Tester\Assert; +use Nette\Application\PresenterFactory; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test(function() { +test(function () { $factory = new PresenterFactory; $factory->setMapping(array( @@ -19,22 +19,22 @@ test(function() { 'Foo3' => 'My\App\*Mod\*Presenter', )); - Assert::same( 'FooPresenter', $factory->formatPresenterClass('Foo') ); - Assert::same( 'FooModule\BarPresenter', $factory->formatPresenterClass('Foo:Bar') ); - Assert::same( 'FooModule\BarModule\BazPresenter', $factory->formatPresenterClass('Foo:Bar:Baz') ); + Assert::same('FooPresenter', $factory->formatPresenterClass('Foo')); + Assert::same('FooModule\BarPresenter', $factory->formatPresenterClass('Foo:Bar')); + Assert::same('FooModule\BarModule\BazPresenter', $factory->formatPresenterClass('Foo:Bar:Baz')); - Assert::same( 'Foo2Presenter', $factory->formatPresenterClass('Foo2') ); - Assert::same( 'App2\BarPresenter', $factory->formatPresenterClass('Foo2:Bar') ); - Assert::same( 'App2\Bar\BazPresenter', $factory->formatPresenterClass('Foo2:Bar:Baz') ); + Assert::same('Foo2Presenter', $factory->formatPresenterClass('Foo2')); + Assert::same('App2\BarPresenter', $factory->formatPresenterClass('Foo2:Bar')); + Assert::same('App2\Bar\BazPresenter', $factory->formatPresenterClass('Foo2:Bar:Baz')); - Assert::same( 'My\App\BarPresenter', $factory->formatPresenterClass('Foo3:Bar') ); - Assert::same( 'My\App\BarMod\BazPresenter', $factory->formatPresenterClass('Foo3:Bar:Baz') ); + Assert::same('My\App\BarPresenter', $factory->formatPresenterClass('Foo3:Bar')); + Assert::same('My\App\BarMod\BazPresenter', $factory->formatPresenterClass('Foo3:Bar:Baz')); - Assert::same( 'NetteModule\FooPresenter', $factory->formatPresenterClass('Nette:Foo') ); + Assert::same('NetteModule\FooPresenter', $factory->formatPresenterClass('Nette:Foo')); }); -test(function() { +test(function () { $factory = new PresenterFactory; $factory->setMapping(array( @@ -42,10 +42,10 @@ test(function() { 'Foo3' => 'My\App\*Presenter', )); - Assert::same( 'Foo2Presenter', $factory->formatPresenterClass('Foo2') ); - Assert::same( 'App2\BarPresenter', $factory->formatPresenterClass('Foo2:Bar') ); - Assert::same( 'App2\BarModule\BazPresenter', $factory->formatPresenterClass('Foo2:Bar:Baz') ); + Assert::same('Foo2Presenter', $factory->formatPresenterClass('Foo2')); + Assert::same('App2\BarPresenter', $factory->formatPresenterClass('Foo2:Bar')); + Assert::same('App2\BarModule\BazPresenter', $factory->formatPresenterClass('Foo2:Bar:Baz')); - Assert::same( 'My\App\BarPresenter', $factory->formatPresenterClass('Foo3:Bar') ); - Assert::same( 'My\App\BarModule\BazPresenter', $factory->formatPresenterClass('Foo3:Bar:Baz') ); + Assert::same('My\App\BarPresenter', $factory->formatPresenterClass('Foo3:Bar')); + Assert::same('My\App\BarModule\BazPresenter', $factory->formatPresenterClass('Foo3:Bar:Baz')); }); diff --git a/tests/Application/PresenterFactory.unformatPresenterClass.phpt b/tests/Application/PresenterFactory.unformatPresenterClass.phpt index ac87a68e0..51af70b50 100644 --- a/tests/Application/PresenterFactory.unformatPresenterClass.phpt +++ b/tests/Application/PresenterFactory.unformatPresenterClass.phpt @@ -4,8 +4,8 @@ * Test: Nette\Application\PresenterFactory. */ -use Nette\Application\PresenterFactory, - Tester\Assert; +use Nette\Application\PresenterFactory; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -13,41 +13,41 @@ require __DIR__ . '/../bootstrap.php'; $factory = new PresenterFactory; -test(function() use ($factory) { +test(function () use ($factory) { $factory->setMapping(array( 'Foo2' => 'App2\*\*Presenter', 'Foo3' => 'My\App\*Mod\*Presenter', )); - Assert::same( 'Foo', $factory->unformatPresenterClass('FooPresenter') ); - Assert::same( 'Foo:Bar', $factory->unformatPresenterClass('FooModule\BarPresenter') ); - Assert::same( 'Foo:Bar:Baz', $factory->unformatPresenterClass('FooModule\BarModule\BazPresenter') ); + Assert::same('Foo', $factory->unformatPresenterClass('FooPresenter')); + Assert::same('Foo:Bar', $factory->unformatPresenterClass('FooModule\BarPresenter')); + Assert::same('Foo:Bar:Baz', $factory->unformatPresenterClass('FooModule\BarModule\BazPresenter')); - Assert::same( 'Foo2', $factory->unformatPresenterClass('Foo2Presenter') ); - Assert::same( 'Foo2:Bar', $factory->unformatPresenterClass('App2\BarPresenter') ); - Assert::same( 'Foo2:Bar:Baz', $factory->unformatPresenterClass('App2\Bar\BazPresenter') ); + Assert::same('Foo2', $factory->unformatPresenterClass('Foo2Presenter')); + Assert::same('Foo2:Bar', $factory->unformatPresenterClass('App2\BarPresenter')); + Assert::same('Foo2:Bar:Baz', $factory->unformatPresenterClass('App2\Bar\BazPresenter')); - Assert::same( 'Foo3:Bar', $factory->unformatPresenterClass('My\App\BarPresenter') ); - Assert::same( 'Foo3:Bar:Baz', $factory->unformatPresenterClass('My\App\BarMod\BazPresenter') ); + Assert::same('Foo3:Bar', $factory->unformatPresenterClass('My\App\BarPresenter')); + Assert::same('Foo3:Bar:Baz', $factory->unformatPresenterClass('My\App\BarMod\BazPresenter')); - Assert::null( $factory->unformatPresenterClass('Foo') ); - Assert::null( $factory->unformatPresenterClass('FooMod\BarPresenter') ); + Assert::null($factory->unformatPresenterClass('Foo')); + Assert::null($factory->unformatPresenterClass('FooMod\BarPresenter')); }); -test(function() use ($factory) { +test(function () use ($factory) { $factory->setMapping(array( 'Foo2' => 'App2\*Presenter', 'Foo3' => 'My\App\*Presenter', )); - Assert::same( 'Foo2', $factory->unformatPresenterClass('Foo2Presenter') ); - Assert::same( 'Foo2:Bar', $factory->unformatPresenterClass('App2\BarPresenter') ); - Assert::same( 'Foo2:Bar:Baz', $factory->unformatPresenterClass('App2\BarModule\BazPresenter') ); + Assert::same('Foo2', $factory->unformatPresenterClass('Foo2Presenter')); + Assert::same('Foo2:Bar', $factory->unformatPresenterClass('App2\BarPresenter')); + Assert::same('Foo2:Bar:Baz', $factory->unformatPresenterClass('App2\BarModule\BazPresenter')); - Assert::same( 'Foo3:Bar', $factory->unformatPresenterClass('My\App\BarPresenter') ); - Assert::same( 'Foo3:Bar:Baz', $factory->unformatPresenterClass('My\App\BarModule\BazPresenter') ); + Assert::same('Foo3:Bar', $factory->unformatPresenterClass('My\App\BarPresenter')); + Assert::same('Foo3:Bar:Baz', $factory->unformatPresenterClass('My\App\BarModule\BazPresenter')); - Assert::null( $factory->unformatPresenterClass('App2\Bar\BazPresenter') ); - Assert::null( $factory->unformatPresenterClass('My\App\BarMod\BazPresenter') ); + Assert::null($factory->unformatPresenterClass('App2\Bar\BazPresenter')); + Assert::null($factory->unformatPresenterClass('My\App\BarMod\BazPresenter')); }); diff --git a/tests/Application/Request.phpt b/tests/Application/Request.phpt index 995135953..ccc6faf4f 100644 --- a/tests/Application/Request.phpt +++ b/tests/Application/Request.phpt @@ -4,25 +4,25 @@ * Test: Nette\Application\Request */ -use Nette\Application\Request, - Tester\Assert; +use Nette\Application\Request; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test(function() { +test(function () { $request = new Request('Homepage', 'GET', array('a' => 1, 'b' => NULL)); - Assert::same( 1, $request->getParameter('a') ); - Assert::same( NULL, $request->getParameter('b') ); + Assert::same(1, $request->getParameter('a')); + Assert::same(NULL, $request->getParameter('b')); }); -test(function() { +test(function () { $request = new Request('Homepage', 'GET', array(), array('a' => 1, 'b' => NULL)); - Assert::same( array('a' => 1, 'b' => NULL), $request->getPost() ); - Assert::same( 1, $request->getPost('a') ); - Assert::same( NULL, $request->getPost('b') ); + Assert::same(array('a' => 1, 'b' => NULL), $request->getPost()); + Assert::same(1, $request->getPost('a')); + Assert::same(NULL, $request->getPost('b')); }); From 4c0bf7b15a6ecd8b086edfa2613ffb19c833d27f Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 29 Jun 2015 13:41:30 +0200 Subject: [PATCH 05/11] removed @author --- src/Application/Application.php | 2 -- src/Application/ErrorPresenter.php | 2 -- src/Application/IPresenter.php | 2 -- src/Application/IPresenterFactory.php | 2 -- src/Application/IResponse.php | 2 -- src/Application/IRouter.php | 2 -- src/Application/MicroPresenter.php | 2 -- src/Application/PresenterFactory.php | 2 -- src/Application/Request.php | 2 -- src/Application/Responses/FileResponse.php | 2 -- src/Application/Responses/ForwardResponse.php | 2 -- src/Application/Responses/JsonResponse.php | 2 -- src/Application/Responses/RedirectResponse.php | 2 -- src/Application/Responses/TextResponse.php | 2 -- src/Application/Routers/CliRouter.php | 2 -- src/Application/Routers/Route.php | 2 -- src/Application/Routers/RouteList.php | 2 -- src/Application/Routers/SimpleRouter.php | 2 -- src/Application/UI/BadSignalException.php | 2 -- src/Application/UI/Control.php | 2 -- src/Application/UI/Form.php | 2 -- src/Application/UI/IRenderable.php | 2 -- src/Application/UI/ISignalReceiver.php | 2 -- src/Application/UI/IStatePersistent.php | 2 -- src/Application/UI/InvalidLinkException.php | 2 -- src/Application/UI/Link.php | 2 -- src/Application/UI/Multiplier.php | 2 -- src/Application/UI/Presenter.php | 2 -- src/Application/UI/PresenterComponent.php | 2 -- src/Application/UI/PresenterComponentReflection.php | 2 -- src/Bridges/ApplicationDI/ApplicationExtension.php | 2 -- src/Bridges/ApplicationDI/LatteExtension.php | 3 --- src/Bridges/ApplicationDI/RoutingExtension.php | 2 -- src/Bridges/ApplicationLatte/Loader.php | 2 -- src/Bridges/ApplicationLatte/Template.php | 2 -- src/Bridges/ApplicationLatte/TemplateFactory.php | 2 -- src/Bridges/ApplicationLatte/UIMacros.php | 2 -- src/Bridges/ApplicationTracy/RoutingPanel.php | 2 -- 38 files changed, 77 deletions(-) diff --git a/src/Application/Application.php b/src/Application/Application.php index 08235c8a7..6267fc2c2 100644 --- a/src/Application/Application.php +++ b/src/Application/Application.php @@ -13,8 +13,6 @@ /** * Front Controller. * - * @author David Grudl - * * @property-read array $requests * @property-read IPresenter $presenter * @property-read IRouter $router diff --git a/src/Application/ErrorPresenter.php b/src/Application/ErrorPresenter.php index 1eb0c8884..013d9c72b 100644 --- a/src/Application/ErrorPresenter.php +++ b/src/Application/ErrorPresenter.php @@ -14,8 +14,6 @@ /** * Default Error Presenter. - * - * @author David Grudl */ class ErrorPresenter extends Nette\Object implements Application\IPresenter { diff --git a/src/Application/IPresenter.php b/src/Application/IPresenter.php index 182d3f956..bc5c75f12 100644 --- a/src/Application/IPresenter.php +++ b/src/Application/IPresenter.php @@ -12,8 +12,6 @@ /** * Presenter converts Request to IResponse. - * - * @author David Grudl */ interface IPresenter { diff --git a/src/Application/IPresenterFactory.php b/src/Application/IPresenterFactory.php index ad1cf2bc6..9c2d7d997 100644 --- a/src/Application/IPresenterFactory.php +++ b/src/Application/IPresenterFactory.php @@ -12,8 +12,6 @@ /** * Responsible for creating a new instance of given presenter. - * - * @author Jan Tichý */ interface IPresenterFactory { diff --git a/src/Application/IResponse.php b/src/Application/IResponse.php index 3b5a4299d..ace0054f8 100644 --- a/src/Application/IResponse.php +++ b/src/Application/IResponse.php @@ -12,8 +12,6 @@ /** * Any response returned by presenter. - * - * @author David Grudl */ interface IResponse { diff --git a/src/Application/IRouter.php b/src/Application/IRouter.php index 456f53540..b2ae7cb0b 100644 --- a/src/Application/IRouter.php +++ b/src/Application/IRouter.php @@ -12,8 +12,6 @@ /** * The bi-directional router. - * - * @author David Grudl */ interface IRouter { diff --git a/src/Application/MicroPresenter.php b/src/Application/MicroPresenter.php index b61ae9ed6..5d9ecf799 100644 --- a/src/Application/MicroPresenter.php +++ b/src/Application/MicroPresenter.php @@ -17,8 +17,6 @@ /** * Micro presenter. * - * @author David Grudl - * * @property-read Nette\Application\IRequest $request */ class MicroPresenter extends Nette\Object implements Application\IPresenter diff --git a/src/Application/PresenterFactory.php b/src/Application/PresenterFactory.php index e86b5e63a..c44e07273 100644 --- a/src/Application/PresenterFactory.php +++ b/src/Application/PresenterFactory.php @@ -12,8 +12,6 @@ /** * Default presenter loader. - * - * @author David Grudl */ class PresenterFactory extends Nette\Object implements IPresenterFactory { diff --git a/src/Application/Request.php b/src/Application/Request.php index 281d5f7d4..364fd3daa 100644 --- a/src/Application/Request.php +++ b/src/Application/Request.php @@ -13,8 +13,6 @@ /** * Presenter request. Immutable object. * - * @author David Grudl - * * @property string $presenterName * @property array $parameters * @property array $post diff --git a/src/Application/Responses/FileResponse.php b/src/Application/Responses/FileResponse.php index 86142655e..e63bd851c 100644 --- a/src/Application/Responses/FileResponse.php +++ b/src/Application/Responses/FileResponse.php @@ -13,8 +13,6 @@ /** * File download response. * - * @author David Grudl - * * @property-read string $file * @property-read string $name * @property-read string $contentType diff --git a/src/Application/Responses/ForwardResponse.php b/src/Application/Responses/ForwardResponse.php index f7e3b911a..3d7d82599 100644 --- a/src/Application/Responses/ForwardResponse.php +++ b/src/Application/Responses/ForwardResponse.php @@ -13,8 +13,6 @@ /** * Forwards to new request. * - * @author David Grudl - * * @property-read Nette\Application\Request $request */ class ForwardResponse extends Nette\Object implements Nette\Application\IResponse diff --git a/src/Application/Responses/JsonResponse.php b/src/Application/Responses/JsonResponse.php index 21f11afe9..799946ad9 100644 --- a/src/Application/Responses/JsonResponse.php +++ b/src/Application/Responses/JsonResponse.php @@ -13,8 +13,6 @@ /** * JSON response used mainly for AJAX requests. * - * @author David Grudl - * * @property-read array|\stdClass $payload * @property-read string $contentType */ diff --git a/src/Application/Responses/RedirectResponse.php b/src/Application/Responses/RedirectResponse.php index dffb96efe..00654c740 100644 --- a/src/Application/Responses/RedirectResponse.php +++ b/src/Application/Responses/RedirectResponse.php @@ -14,8 +14,6 @@ /** * Redirects to new URI. * - * @author David Grudl - * * @property-read string $url * @property-read int $code */ diff --git a/src/Application/Responses/TextResponse.php b/src/Application/Responses/TextResponse.php index cf4676250..67e1985fc 100644 --- a/src/Application/Responses/TextResponse.php +++ b/src/Application/Responses/TextResponse.php @@ -13,8 +13,6 @@ /** * String output response. * - * @author David Grudl - * * @property-read mixed $source */ class TextResponse extends Nette\Object implements Nette\Application\IResponse diff --git a/src/Application/Routers/CliRouter.php b/src/Application/Routers/CliRouter.php index fbb89c538..59ffb7592 100644 --- a/src/Application/Routers/CliRouter.php +++ b/src/Application/Routers/CliRouter.php @@ -14,8 +14,6 @@ /** * The unidirectional router for CLI. (experimental) * - * @author David Grudl - * * @property-read array $defaults */ class CliRouter extends Nette\Object implements Application\IRouter diff --git a/src/Application/Routers/Route.php b/src/Application/Routers/Route.php index 89e888269..64dfbb89b 100644 --- a/src/Application/Routers/Route.php +++ b/src/Application/Routers/Route.php @@ -16,8 +16,6 @@ * The bidirectional route is responsible for mapping * HTTP request to a Request object for dispatch and vice-versa. * - * @author David Grudl - * * @property-read string $mask * @property-read array $defaults * @property-read int $flags diff --git a/src/Application/Routers/RouteList.php b/src/Application/Routers/RouteList.php index 588776b2c..7bea1ed3a 100644 --- a/src/Application/Routers/RouteList.php +++ b/src/Application/Routers/RouteList.php @@ -12,8 +12,6 @@ /** * The router broker. - * - * @author David Grudl * @property-read string $module */ class RouteList extends Nette\Utils\ArrayList implements Nette\Application\IRouter diff --git a/src/Application/Routers/SimpleRouter.php b/src/Application/Routers/SimpleRouter.php index 708755510..7365f4109 100644 --- a/src/Application/Routers/SimpleRouter.php +++ b/src/Application/Routers/SimpleRouter.php @@ -14,8 +14,6 @@ /** * The bidirectional route for trivial routing via query parameters. * - * @author David Grudl - * * @property-read array $defaults * @property-read int $flags */ diff --git a/src/Application/UI/BadSignalException.php b/src/Application/UI/BadSignalException.php index c2fc8dc55..4d4b1d9f8 100644 --- a/src/Application/UI/BadSignalException.php +++ b/src/Application/UI/BadSignalException.php @@ -12,8 +12,6 @@ /** * Signal exception. - * - * @author David Grudl */ class BadSignalException extends Nette\Application\BadRequestException { diff --git a/src/Application/UI/Control.php b/src/Application/UI/Control.php index 7a6a7d726..bdc7c49fc 100644 --- a/src/Application/UI/Control.php +++ b/src/Application/UI/Control.php @@ -13,8 +13,6 @@ /** * Control is renderable Presenter component. * - * @author David Grudl - * * @property-read ITemplate $template * @property-read string $snippetId */ diff --git a/src/Application/UI/Form.php b/src/Application/UI/Form.php index 195b335ea..a70e74c7c 100644 --- a/src/Application/UI/Form.php +++ b/src/Application/UI/Form.php @@ -13,8 +13,6 @@ /** * Web form adapted for Presenter. * - * @author David Grudl - * * @property-read Presenter $presenter */ class Form extends Nette\Forms\Form implements ISignalReceiver diff --git a/src/Application/UI/IRenderable.php b/src/Application/UI/IRenderable.php index 898062e18..d9a49cd8d 100644 --- a/src/Application/UI/IRenderable.php +++ b/src/Application/UI/IRenderable.php @@ -12,8 +12,6 @@ /** * Component with ability to repaint. - * - * @author David Grudl */ interface IRenderable { diff --git a/src/Application/UI/ISignalReceiver.php b/src/Application/UI/ISignalReceiver.php index 13075cfad..ac1863b53 100644 --- a/src/Application/UI/ISignalReceiver.php +++ b/src/Application/UI/ISignalReceiver.php @@ -12,8 +12,6 @@ /** * Component with ability to receive signal. - * - * @author David Grudl */ interface ISignalReceiver { diff --git a/src/Application/UI/IStatePersistent.php b/src/Application/UI/IStatePersistent.php index 6837c9006..0a3e6267d 100644 --- a/src/Application/UI/IStatePersistent.php +++ b/src/Application/UI/IStatePersistent.php @@ -12,8 +12,6 @@ /** * Component with ability to save and load its state. - * - * @author David Grudl */ interface IStatePersistent { diff --git a/src/Application/UI/InvalidLinkException.php b/src/Application/UI/InvalidLinkException.php index b340b7b65..5ef74fc11 100644 --- a/src/Application/UI/InvalidLinkException.php +++ b/src/Application/UI/InvalidLinkException.php @@ -12,8 +12,6 @@ /** * Link generation exception. - * - * @author David Grudl */ class InvalidLinkException extends \Exception { diff --git a/src/Application/UI/Link.php b/src/Application/UI/Link.php index 00e7243d8..8feb23b74 100644 --- a/src/Application/UI/Link.php +++ b/src/Application/UI/Link.php @@ -13,8 +13,6 @@ /** * Lazy encapsulation of PresenterComponent::link(). * Do not instantiate directly, use PresenterComponent::lazyLink() - * - * @author David Grudl * @internal * * @property-read string $destination diff --git a/src/Application/UI/Multiplier.php b/src/Application/UI/Multiplier.php index 0f39a2575..01ebd0c98 100644 --- a/src/Application/UI/Multiplier.php +++ b/src/Application/UI/Multiplier.php @@ -12,8 +12,6 @@ /** * Component multiplier. - * - * @author David Grudl */ class Multiplier extends PresenterComponent { diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index a9986f3eb..c627bc9ce 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -16,8 +16,6 @@ /** * Presenter component represents a webpage instance. It converts Request to IResponse. * - * @author David Grudl - * * @property-read Nette\Application\Request $request * @property-read array|NULL $signal * @property-read string $action diff --git a/src/Application/UI/PresenterComponent.php b/src/Application/UI/PresenterComponent.php index b98b6304b..e8b36c925 100644 --- a/src/Application/UI/PresenterComponent.php +++ b/src/Application/UI/PresenterComponent.php @@ -17,8 +17,6 @@ * other child components, and interact with user. Components have properties * for storing their status, and responds to user command. * - * @author David Grudl - * * @property-read Presenter $presenter * @property-read string $uniqueId */ diff --git a/src/Application/UI/PresenterComponentReflection.php b/src/Application/UI/PresenterComponentReflection.php index 79509b973..a87cb8785 100644 --- a/src/Application/UI/PresenterComponentReflection.php +++ b/src/Application/UI/PresenterComponentReflection.php @@ -13,8 +13,6 @@ /** * Helpers for Presenter & PresenterComponent. - * - * @author David Grudl * @internal */ class PresenterComponentReflection extends Nette\Reflection\ClassType diff --git a/src/Bridges/ApplicationDI/ApplicationExtension.php b/src/Bridges/ApplicationDI/ApplicationExtension.php index 2ade892b9..9b6f4cf41 100644 --- a/src/Bridges/ApplicationDI/ApplicationExtension.php +++ b/src/Bridges/ApplicationDI/ApplicationExtension.php @@ -13,8 +13,6 @@ /** * Application extension for Nette DI. - * - * @author David Grudl */ class ApplicationExtension extends Nette\DI\CompilerExtension { diff --git a/src/Bridges/ApplicationDI/LatteExtension.php b/src/Bridges/ApplicationDI/LatteExtension.php index d7c095219..3321f612c 100644 --- a/src/Bridges/ApplicationDI/LatteExtension.php +++ b/src/Bridges/ApplicationDI/LatteExtension.php @@ -13,9 +13,6 @@ /** * Latte extension for Nette DI. - * - * @author David Grudl - * @author Petr Morávek */ class LatteExtension extends Nette\DI\CompilerExtension { diff --git a/src/Bridges/ApplicationDI/RoutingExtension.php b/src/Bridges/ApplicationDI/RoutingExtension.php index 6d3c158f1..a45e6979d 100644 --- a/src/Bridges/ApplicationDI/RoutingExtension.php +++ b/src/Bridges/ApplicationDI/RoutingExtension.php @@ -12,8 +12,6 @@ /** * Routing extension for Nette DI. - * - * @author David Grudl */ class RoutingExtension extends Nette\DI\CompilerExtension { diff --git a/src/Bridges/ApplicationLatte/Loader.php b/src/Bridges/ApplicationLatte/Loader.php index 5a3db2921..61da3ac45 100644 --- a/src/Bridges/ApplicationLatte/Loader.php +++ b/src/Bridges/ApplicationLatte/Loader.php @@ -13,8 +13,6 @@ /** * Template loader. - * - * @author David Grudl */ class Loader extends Latte\Loaders\FileLoader { diff --git a/src/Bridges/ApplicationLatte/Template.php b/src/Bridges/ApplicationLatte/Template.php index 06034ceff..2b5eb21e7 100644 --- a/src/Bridges/ApplicationLatte/Template.php +++ b/src/Bridges/ApplicationLatte/Template.php @@ -13,8 +13,6 @@ /** * Latte powered template. - * - * @author David Grudl */ class Template extends Nette\Object implements Nette\Application\UI\ITemplate { diff --git a/src/Bridges/ApplicationLatte/TemplateFactory.php b/src/Bridges/ApplicationLatte/TemplateFactory.php index ac7f011ab..c7972a1f9 100644 --- a/src/Bridges/ApplicationLatte/TemplateFactory.php +++ b/src/Bridges/ApplicationLatte/TemplateFactory.php @@ -17,8 +17,6 @@ /** * Latte powered template factory. - * - * @author David Grudl */ class TemplateFactory extends Nette\Object implements UI\ITemplateFactory { diff --git a/src/Bridges/ApplicationLatte/UIMacros.php b/src/Bridges/ApplicationLatte/UIMacros.php index 953901a76..6d311aae5 100644 --- a/src/Bridges/ApplicationLatte/UIMacros.php +++ b/src/Bridges/ApplicationLatte/UIMacros.php @@ -21,8 +21,6 @@ * - {link destination ...} control link * - {plink destination ...} presenter link * - {snippet ?} ... {/snippet ?} control snippet - * - * @author David Grudl */ class UIMacros extends Latte\Macros\MacroSet { diff --git a/src/Bridges/ApplicationTracy/RoutingPanel.php b/src/Bridges/ApplicationTracy/RoutingPanel.php index f3c72daa0..71e061a5c 100644 --- a/src/Bridges/ApplicationTracy/RoutingPanel.php +++ b/src/Bridges/ApplicationTracy/RoutingPanel.php @@ -16,8 +16,6 @@ /** * Routing debugger for Debug Bar. - * - * @author David Grudl */ class RoutingPanel extends Nette\Object implements Tracy\IBarPanel { From abf9600e03fa4bbad16b7bd4c8fbe4d8d62423aa Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 29 Jun 2015 15:33:33 +0200 Subject: [PATCH 06/11] typo: removed unused use --- src/Application/IPresenter.php | 2 -- src/Application/IPresenterFactory.php | 2 -- src/Application/UI/IRenderable.php | 2 -- src/Application/UI/ISignalReceiver.php | 2 -- src/Application/UI/IStatePersistent.php | 2 -- src/Application/UI/ITemplate.php | 2 -- src/Application/UI/ITemplateFactory.php | 2 -- src/Application/UI/InvalidLinkException.php | 2 -- src/Application/exceptions.php | 2 -- src/Bridges/ApplicationLatte/ILatteFactory.php | 3 --- 10 files changed, 21 deletions(-) diff --git a/src/Application/IPresenter.php b/src/Application/IPresenter.php index bc5c75f12..ba3ab380e 100644 --- a/src/Application/IPresenter.php +++ b/src/Application/IPresenter.php @@ -7,8 +7,6 @@ namespace Nette\Application; -use Nette; - /** * Presenter converts Request to IResponse. diff --git a/src/Application/IPresenterFactory.php b/src/Application/IPresenterFactory.php index 9c2d7d997..40c308e5b 100644 --- a/src/Application/IPresenterFactory.php +++ b/src/Application/IPresenterFactory.php @@ -7,8 +7,6 @@ namespace Nette\Application; -use Nette; - /** * Responsible for creating a new instance of given presenter. diff --git a/src/Application/UI/IRenderable.php b/src/Application/UI/IRenderable.php index d9a49cd8d..101dda91f 100644 --- a/src/Application/UI/IRenderable.php +++ b/src/Application/UI/IRenderable.php @@ -7,8 +7,6 @@ namespace Nette\Application\UI; -use Nette; - /** * Component with ability to repaint. diff --git a/src/Application/UI/ISignalReceiver.php b/src/Application/UI/ISignalReceiver.php index ac1863b53..db8cee9d0 100644 --- a/src/Application/UI/ISignalReceiver.php +++ b/src/Application/UI/ISignalReceiver.php @@ -7,8 +7,6 @@ namespace Nette\Application\UI; -use Nette; - /** * Component with ability to receive signal. diff --git a/src/Application/UI/IStatePersistent.php b/src/Application/UI/IStatePersistent.php index 0a3e6267d..8069055ef 100644 --- a/src/Application/UI/IStatePersistent.php +++ b/src/Application/UI/IStatePersistent.php @@ -7,8 +7,6 @@ namespace Nette\Application\UI; -use Nette; - /** * Component with ability to save and load its state. diff --git a/src/Application/UI/ITemplate.php b/src/Application/UI/ITemplate.php index 4d0584406..2794e343f 100644 --- a/src/Application/UI/ITemplate.php +++ b/src/Application/UI/ITemplate.php @@ -7,8 +7,6 @@ namespace Nette\Application\UI; -use Nette; - /** * Defines template. diff --git a/src/Application/UI/ITemplateFactory.php b/src/Application/UI/ITemplateFactory.php index d0717e015..4567f654e 100644 --- a/src/Application/UI/ITemplateFactory.php +++ b/src/Application/UI/ITemplateFactory.php @@ -7,8 +7,6 @@ namespace Nette\Application\UI; -use Nette; - /** * Defines ITemplate factory. diff --git a/src/Application/UI/InvalidLinkException.php b/src/Application/UI/InvalidLinkException.php index 5ef74fc11..cd1f97f0f 100644 --- a/src/Application/UI/InvalidLinkException.php +++ b/src/Application/UI/InvalidLinkException.php @@ -7,8 +7,6 @@ namespace Nette\Application\UI; -use Nette; - /** * Link generation exception. diff --git a/src/Application/exceptions.php b/src/Application/exceptions.php index 4913d9c07..4a62e692a 100644 --- a/src/Application/exceptions.php +++ b/src/Application/exceptions.php @@ -7,8 +7,6 @@ namespace Nette\Application; -use Nette; - /** * The exception that is thrown when user attempts to terminate the current presenter or application. diff --git a/src/Bridges/ApplicationLatte/ILatteFactory.php b/src/Bridges/ApplicationLatte/ILatteFactory.php index 87d942185..7f5b3dcf7 100644 --- a/src/Bridges/ApplicationLatte/ILatteFactory.php +++ b/src/Bridges/ApplicationLatte/ILatteFactory.php @@ -7,9 +7,6 @@ namespace Nette\Bridges\ApplicationLatte; -use Nette; -use Latte; - interface ILatteFactory { From 53e08138563b332f5531d716d92c7e6daa5dcd90 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 1 Jul 2015 14:50:42 +0200 Subject: [PATCH 07/11] test: fixed & added tests --- .../expected/UIMacros.snippet.phtml | 2 +- ...senterComponentReflection.convertType.phpt | 107 ++++++++++++++++++ 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 tests/Application/PresenterComponentReflection.convertType.phpt diff --git a/tests/Application.Latte/expected/UIMacros.snippet.phtml b/tests/Application.Latte/expected/UIMacros.snippet.phtml index f819ad3aa..320e30d5c 100644 --- a/tests/Application.Latte/expected/UIMacros.snippet.phtml +++ b/tests/Application.Latte/expected/UIMacros.snippet.phtml @@ -1,7 +1,7 @@ %A% // block _ // -if (!function_exists($_b->blocks['_'][] = '_%[a-z0-9]+%__')) { function _%[a-z0-9]+%__($_b, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl(false, FALSE) +if (!function_exists($_b->blocks['_'][] = '_%[a-z0-9]+%__')) { function _%[a-z0-9]+%__($_b, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl(%[false']+%, FALSE) ; }} diff --git a/tests/Application/PresenterComponentReflection.convertType.phpt b/tests/Application/PresenterComponentReflection.convertType.phpt new file mode 100644 index 000000000..7f286d4a0 --- /dev/null +++ b/tests/Application/PresenterComponentReflection.convertType.phpt @@ -0,0 +1,107 @@ + Date: Wed, 1 Jul 2015 14:50:42 +0200 Subject: [PATCH 08/11] PresenterComponentReflection::convertType() do not change $val on error, added tests --- src/Application/UI/PresenterComponentReflection.php | 7 ++++--- .../PresenterComponentReflection.convertType.phpt | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Application/UI/PresenterComponentReflection.php b/src/Application/UI/PresenterComponentReflection.php index a87cb8785..3712616de 100644 --- a/src/Application/UI/PresenterComponentReflection.php +++ b/src/Application/UI/PresenterComponentReflection.php @@ -153,11 +153,12 @@ public static function convertType(& $val, $type) return FALSE; } elseif ($type !== 'NULL') { - $old = $val = ($val === FALSE ? '0' : (string) $val); - settype($val, $type); - if ($old !== ($val === FALSE ? '0' : (string) $val)) { + $old = $tmp = ($val === FALSE ? '0' : (string) $val); + settype($tmp, $type); + if ($old !== ($tmp === FALSE ? '0' : (string) $tmp)) { return FALSE; // data-loss occurs } + $val = $tmp; } return TRUE; } diff --git a/tests/Application/PresenterComponentReflection.convertType.phpt b/tests/Application/PresenterComponentReflection.convertType.phpt index 7f286d4a0..f0f12d04a 100644 --- a/tests/Application/PresenterComponentReflection.convertType.phpt +++ b/tests/Application/PresenterComponentReflection.convertType.phpt @@ -15,10 +15,11 @@ function testIt($type, $val, $res = NULL) { if (func_num_args() === 3) { Assert::true(PresenterComponentReflection::convertType($val, $type)); - Assert::same($res, $val); } else { + $res = $val; Assert::false(PresenterComponentReflection::convertType($val, $type)); } + Assert::same($res, $val); } $obj = new stdClass; From f24edc2a7221d19f68544467f5b93de4233287aa Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 1 Jul 2015 17:23:10 +0200 Subject: [PATCH 09/11] UIMacros: runtime helpers moved to UIRuntime --- src/Bridges/ApplicationLatte/UIMacros.php | 43 +------------ src/Bridges/ApplicationLatte/UIRuntime.php | 61 +++++++++++++++++++ .../UIMacros.dynamicsnippets.alt.phtml | 2 +- .../expected/UIMacros.dynamicsnippets.phtml | 2 +- .../expected/UIMacros.snippet.alt.phtml | 2 +- .../expected/UIMacros.snippet.phtml | 2 +- 6 files changed, 68 insertions(+), 44 deletions(-) create mode 100644 src/Bridges/ApplicationLatte/UIRuntime.php diff --git a/src/Bridges/ApplicationLatte/UIMacros.php b/src/Bridges/ApplicationLatte/UIMacros.php index 6d311aae5..8f4e94cfd 100644 --- a/src/Bridges/ApplicationLatte/UIMacros.php +++ b/src/Bridges/ApplicationLatte/UIMacros.php @@ -48,7 +48,7 @@ public function finalize() $prolog = ' // snippets support if (empty($_l->extends) && !empty($_control->snippetMode)) { - return Nette\Bridges\ApplicationLatte\UIMacros::renderSnippets($_control, $_b, get_defined_vars()); + return Nette\Bridges\ApplicationLatte\UIRuntime::renderSnippets($_control, $_b, get_defined_vars()); }'; return array($prolog, ''); } @@ -105,47 +105,10 @@ public function macroIfCurrent(MacroNode $node, PhpWriter $writer) } - /********************* run-time helpers ****************d*g**/ - - + /** @deprecated */ public static function renderSnippets(Nette\Application\UI\Control $control, \stdClass $local, array $params) { - $control->snippetMode = FALSE; - $payload = $control->getPresenter()->getPayload(); - if (isset($local->blocks)) { - foreach ($local->blocks as $name => $function) { - if ($name[0] !== '_' || !$control->isControlInvalid(substr($name, 1))) { - continue; - } - ob_start(); - $function = reset($function); - $snippets = $function($local, $params + array('_snippetMode' => TRUE)); - $payload->snippets[$id = $control->getSnippetId(substr($name, 1))] = ob_get_clean(); - if ($snippets !== NULL) { // pass FALSE from snippetArea - if ($snippets) { - $payload->snippets += $snippets; - } - unset($payload->snippets[$id]); - } - } - } - $control->snippetMode = TRUE; - if ($control instanceof Nette\Application\UI\IRenderable) { - $queue = array($control); - do { - foreach (array_shift($queue)->getComponents() as $child) { - if ($child instanceof Nette\Application\UI\IRenderable) { - if ($child->isControlInvalid()) { - $child->snippetMode = TRUE; - $child->render(); - $child->snippetMode = FALSE; - } - } elseif ($child instanceof Nette\ComponentModel\IContainer) { - $queue[] = $child; - } - } - } while ($queue); - } + UIRuntime::renderSnippets($control, $local, $params); } } diff --git a/src/Bridges/ApplicationLatte/UIRuntime.php b/src/Bridges/ApplicationLatte/UIRuntime.php new file mode 100644 index 000000000..eb71cfd7a --- /dev/null +++ b/src/Bridges/ApplicationLatte/UIRuntime.php @@ -0,0 +1,61 @@ +snippetMode = FALSE; + $payload = $control->getPresenter()->getPayload(); + if (isset($local->blocks)) { + foreach ($local->blocks as $name => $function) { + if ($name[0] !== '_' || !$control->isControlInvalid(substr($name, 1))) { + continue; + } + ob_start(); + $function = reset($function); + $snippets = $function($local, $params + array('_snippetMode' => TRUE)); + $payload->snippets[$id = $control->getSnippetId(substr($name, 1))] = ob_get_clean(); + if ($snippets !== NULL) { // pass FALSE from snippetArea + if ($snippets) { + $payload->snippets += $snippets; + } + unset($payload->snippets[$id]); + } + } + } + $control->snippetMode = TRUE; + if ($control instanceof UI\IRenderable) { + $queue = array($control); + do { + foreach (array_shift($queue)->getComponents() as $child) { + if ($child instanceof UI\IRenderable) { + if ($child->isControlInvalid()) { + $child->snippetMode = TRUE; + $child->render(); + $child->snippetMode = FALSE; + } + } elseif ($child instanceof Nette\ComponentModel\IContainer) { + $queue[] = $child; + } + } + } while ($queue); + } + } + +} diff --git a/tests/Application.Latte/expected/UIMacros.dynamicsnippets.alt.phtml b/tests/Application.Latte/expected/UIMacros.dynamicsnippets.alt.phtml index 0f1337c2e..afe04ba11 100644 --- a/tests/Application.Latte/expected/UIMacros.dynamicsnippets.alt.phtml +++ b/tests/Application.Latte/expected/UIMacros.dynamicsnippets.alt.phtml @@ -42,7 +42,7 @@ if ($_l->extends) { ob_start();} // snippets support if (empty($_l->extends) && !empty($_control->snippetMode)) { - return Nette\Bridges\ApplicationLatte\UIMacros::renderSnippets($_control, $_b, get_defined_vars()); + return Nette\Bridges\ApplicationLatte\UIRuntime::renderSnippets($_control, $_b, get_defined_vars()); } // diff --git a/tests/Application.Latte/expected/UIMacros.dynamicsnippets.phtml b/tests/Application.Latte/expected/UIMacros.dynamicsnippets.phtml index 0663b00ac..c0ba0562f 100644 --- a/tests/Application.Latte/expected/UIMacros.dynamicsnippets.phtml +++ b/tests/Application.Latte/expected/UIMacros.dynamicsnippets.phtml @@ -32,7 +32,7 @@ if ($_l->extends) { ob_start();} // snippets support if (empty($_l->extends) && !empty($_control->snippetMode)) { - return Nette\Bridges\ApplicationLatte\UIMacros::renderSnippets($_control, $_b, get_defined_vars()); + return Nette\Bridges\ApplicationLatte\UIRuntime::renderSnippets($_control, $_b, get_defined_vars()); } // diff --git a/tests/Application.Latte/expected/UIMacros.snippet.alt.phtml b/tests/Application.Latte/expected/UIMacros.snippet.alt.phtml index 16ba4f82c..e3d541cdc 100644 --- a/tests/Application.Latte/expected/UIMacros.snippet.alt.phtml +++ b/tests/Application.Latte/expected/UIMacros.snippet.alt.phtml @@ -39,7 +39,7 @@ if ($_l->extends) { ob_start();} // snippets support if (empty($_l->extends) && !empty($_control->snippetMode)) { - return Nette\Bridges\ApplicationLatte\UIMacros::renderSnippets($_control, $_b, get_defined_vars()); + return Nette\Bridges\ApplicationLatte\UIRuntime::renderSnippets($_control, $_b, get_defined_vars()); } // diff --git a/tests/Application.Latte/expected/UIMacros.snippet.phtml b/tests/Application.Latte/expected/UIMacros.snippet.phtml index 320e30d5c..ecdc2f95f 100644 --- a/tests/Application.Latte/expected/UIMacros.snippet.phtml +++ b/tests/Application.Latte/expected/UIMacros.snippet.phtml @@ -40,7 +40,7 @@ if (!function_exists($_b->blocks['_title2'][] = '_%[a-z0-9]+%__title2')) { funct // // end of blocks %A% - return Nette\Bridges\ApplicationLatte\UIMacros::renderSnippets($_control, $_b, get_defined_vars()); + return Nette\Bridges\ApplicationLatte\UIRuntime::renderSnippets($_control, $_b, get_defined_vars()); %A%
blocks['_']), $_b, $template->getParameters()) ?>
From a6d69c6b82a69a19cf5345a714c44ca7b5413619 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 1 Jul 2015 16:07:42 +0200 Subject: [PATCH 10/11] UIMacros: {snippet} and {snippetArea} without name has name '' in both PHP 5 and PHP 7 --- src/Bridges/ApplicationLatte/UIRuntime.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bridges/ApplicationLatte/UIRuntime.php b/src/Bridges/ApplicationLatte/UIRuntime.php index eb71cfd7a..5e63e2b4b 100644 --- a/src/Bridges/ApplicationLatte/UIRuntime.php +++ b/src/Bridges/ApplicationLatte/UIRuntime.php @@ -24,13 +24,13 @@ public static function renderSnippets(UI\Control $control, \stdClass $local, arr $payload = $control->getPresenter()->getPayload(); if (isset($local->blocks)) { foreach ($local->blocks as $name => $function) { - if ($name[0] !== '_' || !$control->isControlInvalid(substr($name, 1))) { + if ($name[0] !== '_' || !$control->isControlInvalid((string) substr($name, 1))) { continue; } ob_start(); $function = reset($function); $snippets = $function($local, $params + array('_snippetMode' => TRUE)); - $payload->snippets[$id = $control->getSnippetId(substr($name, 1))] = ob_get_clean(); + $payload->snippets[$id = $control->getSnippetId((string) substr($name, 1))] = ob_get_clean(); if ($snippets !== NULL) { // pass FALSE from snippetArea if ($snippets) { $payload->snippets += $snippets; From 785801e441ef83fa4d75cc47c292afedee9b3e4e Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 1 Jul 2015 16:30:23 +0200 Subject: [PATCH 11/11] Control: *global* snippet changed from NULL to \0 to be distinguished from '' --- src/Application/UI/Control.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Application/UI/Control.php b/src/Application/UI/Control.php index bdc7c49fc..171157f97 100644 --- a/src/Application/UI/Control.php +++ b/src/Application/UI/Control.php @@ -107,7 +107,7 @@ public function flashMessage($message, $type = 'info') public function redrawControl($snippet = NULL, $redraw = TRUE) { if ($redraw) { - $this->invalidSnippets[$snippet] = TRUE; + $this->invalidSnippets[$snippet === NULL ? "\0" : $snippet] = TRUE; } elseif ($snippet === NULL) { $this->invalidSnippets = array(); @@ -162,7 +162,7 @@ public function isControlInvalid($snippet = NULL) } } else { - return isset($this->invalidSnippets[NULL]) || isset($this->invalidSnippets[$snippet]); + return isset($this->invalidSnippets["\0"]) || isset($this->invalidSnippets[$snippet]); } }