From 51b53edffd7498f6ec02552af76f658245f01ede Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 18 Jun 2015 16:31:27 +0200 Subject: [PATCH] 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 | 8 +- .../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, 757 insertions(+), 748 deletions(-) diff --git a/src/Application/Application.php b/src/Application/Application.php index 42dafccce..addb2b3cd 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 1ff7b5ce8..307cfe14e 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 c190c5772..5ebd1a519 100644 --- a/src/Application/PresenterFactory.php +++ b/src/Application/PresenterFactory.php @@ -31,11 +31,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 950e831b6..ca7d721e4 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 9c6169801..836a6a49e 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 5fc83596b..38e56b74d 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 4e5968fed..600aa43f8 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 3ac36deaa..5b8bee78d 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 8212785d6..5655f672e 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 784890d91..3710941b8 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; /** @@ -47,7 +47,7 @@ public function loadConfiguration() $config = $this->validateConfig($this->defaults); $container = $this->getContainerBuilder(); - $latteFactory = $container->addDefinition($this->prefix('latteFactory')) + $container->addDefinition($this->prefix('latteFactory')) ->setClass('Latte\Engine') ->addSetup('setTempDirectory', [$this->tempDir]) ->addSetup('setAutoRefresh', [$this->debugMode]) @@ -83,7 +83,7 @@ public function addMacro($macro) $container = $this->getContainerBuilder(); $container->getDefinition($this->prefix('latteFactory')) - ->addSetup('?->onCompile[] = function($engine) { ' . $macro . '($engine->getCompiler()); }', ['@self']); + ->addSetup('?->onCompile[] = function ($engine) { ' . $macro . '($engine->getCompiler()); }', ['@self']); } } diff --git a/src/Bridges/ApplicationDI/RoutingExtension.php b/src/Bridges/ApplicationDI/RoutingExtension.php index 78ac61468..1c5ddcfdb 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', [ - 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 b86234189..065c223d5 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 95464d155..935864304 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 (['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 bbc4a55b2..098242e1e 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', [$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', [$me, 'macroLink']); diff --git a/src/Bridges/ApplicationTracy/RoutingPanel.php b/src/Bridges/ApplicationTracy/RoutingPanel.php index ee7c482be..1d0611817 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 : [ 'tab' => 'Nette Application', 'panel' => '

Requests

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

Presenter

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

Presenter

' . Dumper::toHtml($application->getPresenter(), [Dumper::LIVE => TRUE]), ]; }); } @@ -122,7 +122,7 @@ private function analyse($router, $module = '') 'defaults' => $router instanceof Routers\Route || $router instanceof Routers\SimpleRouter ? $router->getDefaults() : [], '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 31d3c8818..b967f4424 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 46847d3bc..0c7fd9e45 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 522fdb8ed..bf58d64e7 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, [__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 e08f968ab..59931dc2f 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([ 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 b1914faed..6375da2af 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', [NULL, NULL]) ); -Assert::same( '1978-01-24 11:40:00', (string) $latte->invokeFilter('modifyDate', [254400000, '+1 day']) ); -Assert::same( '1978-05-06 00:00:00', (string) $latte->invokeFilter('modifyDate', ['1978-05-05', '+1 day']) ); -Assert::same( '1978-05-06 00:00:00', (string) $latte->invokeFilter('modifyDate', [new DateTime('1978-05-05'), '1day']) ); -Assert::same( '1978-01-22 11:40:00', (string) $latte->invokeFilter('modifyDate', [254400000, -1, 'day']) ); - - -Assert::same( '%25', $latte->invokeFilter('url', ['%']) ); -Assert::same( 3, $latte->invokeFilter('length', ['abc']) ); -Assert::same( 2, $latte->invokeFilter('length', [[1, 2]]) ); -Assert::null( $latte->invokeFilter('null', ['x']) ); -Assert::same( '', $latte->invokeFilter('normalize', [' ']) ); -Assert::same( 'a-b', $latte->invokeFilter('webalize', ['a b']) ); -Assert::same( ' a', $latte->invokeFilter('padLeft', ['a', 3]) ); -Assert::same( 'a ', $latte->invokeFilter('padRight', ['a', 3]) ); -Assert::same( 'cba', $latte->invokeFilter('reverse', ['abc']) ); +Assert::null($latte->invokeFilter('modifyDate', [NULL, NULL])); +Assert::same('1978-01-24 11:40:00', (string) $latte->invokeFilter('modifyDate', [254400000, '+1 day'])); +Assert::same('1978-05-06 00:00:00', (string) $latte->invokeFilter('modifyDate', ['1978-05-05', '+1 day'])); +Assert::same('1978-05-06 00:00:00', (string) $latte->invokeFilter('modifyDate', [new DateTime('1978-05-05'), '1day'])); +Assert::same('1978-01-22 11:40:00', (string) $latte->invokeFilter('modifyDate', [254400000, -1, 'day'])); + + +Assert::same('%25', $latte->invokeFilter('url', ['%'])); +Assert::same(3, $latte->invokeFilter('length', ['abc'])); +Assert::same(2, $latte->invokeFilter('length', [[1, 2]])); +Assert::null($latte->invokeFilter('null', ['x'])); +Assert::same('', $latte->invokeFilter('normalize', [' '])); +Assert::same('a-b', $latte->invokeFilter('webalize', ['a b'])); +Assert::same(' a', $latte->invokeFilter('padLeft', ['a', 3])); +Assert::same('a ', $latte->invokeFilter('padRight', ['a', 3])); +Assert::same('cba', $latte->invokeFilter('reverse', ['abc'])); diff --git a/tests/Application.Latte/TemplateFactory.onCompile.phpt b/tests/Application.Latte/TemplateFactory.onCompile.phpt index 4bb079c45..98ce16503 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([$callback = function() {}]); + $engine->onCompile = new ArrayIterator([$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([$callback = function() {}]); + $engine->onCompile = new Event([$callback = function () {}]); $factory->createTemplate(); diff --git a/tests/Application.Latte/UIMacros.control.2.phpt b/tests/Application.Latte/UIMacros.control.2.phpt index 4d0e17b67..b1a2988b2 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( [ - "MockComponent::getComponent", ["name"], - "MockControl::__call", ["render", []], - "MockComponent::getComponent", ["form"], - "MockControl::__call", ["render", []], - "MockComponent::getComponent", ["form"], - "MockControl::__call", ["renderTest", []], - "MockControl::__call", ["renderTest", []], - "MockComponent::getComponent", ["form"], - "MockControl::__call", ["renderTest", []], - "MockComponent::getComponent", ["form"], - "MockControl::__call", ["renderform", []], - "MockComponent::getComponent", ["form"], - "MockControl::__call", ["render", ["var1"]], - "MockComponent::getComponent", ["form"], - "MockControl::__call", ["render", ["var1", 1, 2]], - "MockComponent::getComponent", ["form"], - "MockControl::__call", ["render", [["var1" => 5, 0 => 1, 1 => 2]]], -], Notes::fetch() ); +Assert::same([ + 'MockComponent::getComponent', ['name'], + 'MockControl::__call', ['render', []], + 'MockComponent::getComponent', ['form'], + 'MockControl::__call', ['render', []], + 'MockComponent::getComponent', ['form'], + 'MockControl::__call', ['renderTest', []], + 'MockControl::__call', ['renderTest', []], + 'MockComponent::getComponent', ['form'], + 'MockControl::__call', ['renderTest', []], + 'MockComponent::getComponent', ['form'], + 'MockControl::__call', ['renderform', []], + 'MockComponent::getComponent', ['form'], + 'MockControl::__call', ['render', ['var1']], + 'MockComponent::getComponent', ['form'], + 'MockControl::__call', ['render', ['var1', 1, 2]], + 'MockComponent::getComponent', ['form'], + 'MockControl::__call', ['render', [['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 b4036d1c6..b6837f867 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([\'param\' => 123]) ?>', $compiler->expandMacro('control', 'form:type param => 123', '')->openingCode ); -Assert::match( 'getComponent("form"); %a%->renderType([\'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([\'param\' => 123]) ?>', $compiler->expandMacro('control', 'form:type param => 123', '')->openingCode); +Assert::match('getComponent("form"); %a%->renderType([\'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 7db18142b..22ec92479 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 2749e3fa6..8a5488246 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", [\'param\']) ?>', $compiler->expandMacro('link', 'p param', '')->openingCode ); -Assert::same( 'link("p", [\'param\' => 123]) ?>', $compiler->expandMacro('link', 'p param => 123', '')->openingCode ); -Assert::same( 'link("p", [\'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", [\'param\']) ?>', $compiler->expandMacro('link', 'p param', '')->openingCode); +Assert::same('link("p", [\'param\' => 123]) ?>', $compiler->expandMacro('link', 'p param => 123', '')->openingCode); +Assert::same('link("p", [\'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 acf08fd14..67186627a 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([ diff --git a/tests/Application.Latte/UIMacros.renderSnippets.phpt b/tests/Application.Latte/UIMacros.renderSnippets.phpt index 181bd535f..9edb3bef5 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 d9e7d6db5..a7941a170 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 cb2029a95..d627d76a4 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 ecbea3559..3fff37f59 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 b852e5fd8..df1424170 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([ ]); $req = $router->match($httpRequest); -Assert::same( 'homepage', $req->getPresenterName() ); +Assert::same('homepage', $req->getPresenterName()); -Assert::same( [ +Assert::same([ 'id' => 12, 'user' => 'john doe', 'action' => 'default', @@ -42,9 +42,9 @@ Assert::same( [ '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 dad9efb04..e089cb0a4 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', ['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 4e6aaca91..e6258ccc8 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 e0feb9833..c859699f3 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', ['action' => 'default']) ); +Assert::same('http://example.com/homepage/', testRouteOut($route, 'Homepage', ['action' => 'default'])); -Assert::null( testRouteOut($route, 'Homepage', ['id' => 'word']) ); +Assert::null(testRouteOut($route, 'Homepage', ['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 e16c805fb..a4f771698 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 2a49197ca..efc4a3e36 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 5ebe2ed4f..9fb39c1d3 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 bef9ec998..b29e946fa 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('', [ NULL => [ - 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('', [ $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 62723bcad..f75fdd0a3 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=', [ 'presenter' => [ - 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 dcc8d0608..36e08d9d4 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('', [ 'presenter' => 'presenter', 'parameter' => [ - 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', [ // Doesn't match testRouteIn($route, '/3/'); -Assert::null( testRouteOut($route, 'presenter', [ +Assert::null(testRouteOut($route, 'presenter', [ 'parameter' => NULL, ])); diff --git a/tests/Application.Routers/Route.filter.url.phpt b/tests/Application.Routers/Route.filter.url.phpt index facdf101d..830fdf675 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('', [ 'presenter' => [ - 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 22bb2ef9a..afc95ed1a 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 9b7738c57..6d59f2d9f 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 66b15f73d..bca18b2b6 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 60139a8c6..39ace0451 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 dcb736d70..9ce0f1377 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 bd99fb776..b09a7dbfb 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 c0b03e711..f3fed0f8f 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..53f5a0666 100644 --- a/tests/Application.Routers/Route.inc +++ b/tests/Application.Routers/Route.inc @@ -25,17 +25,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 de9dfc5c7..ac9fe8cf5 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 ec791142c..b5a9dffc2 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 b69ee8e03..fcfaaad20 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', [ ], '/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('', [ @@ -36,9 +36,9 @@ testRouteIn($route, '/', 'Module:Submodule:Default', [ '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('/', [ @@ -49,9 +49,9 @@ testRouteIn($route, '/module.submodule', 'Module:Submodule:AnyDefault', [ '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('/', [ @@ -63,6 +63,6 @@ testRouteIn($route, '/module.submodule', 'Module:Submodule:Default', [ '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 e91611135..f46c1954c 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 257577fb0..ebdeff66e 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 8cb422c0a..af38d3c83 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 5a67b8f41..f6434a220 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 e9ea76a9b..f67d1eece 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 b6078ac1f..442cdaf0a 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 d3e61428e..476267071 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 fc3d09ed3..8dc00dd91 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 6100dde6e..7f66913c0 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 dcad86082..f60fbc0b1 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 b2d13ce04..46ffc3a93 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 516046ab5..47ac3a726 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 d1ba18407..98d604c0c 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 11b1a5767..e95f9e21d 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 744295623..490dc7080 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 492b993ca..f125decd1 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('', [ ]); testRouteIn($route, '/a/b'); -Assert::null( testRouteOut($route, 'Presenter', ['param' => 'a/b']) ); +Assert::null(testRouteOut($route, 'Presenter', ['param' => 'a/b'])); $route = new Route('', [ diff --git a/tests/Application.Routers/Route.type.phpt b/tests/Application.Routers/Route.type.phpt index f50b7c147..a91328217 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 6f011a19c..dfdf77e68 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 c5a7c1fd8..cdeef21ea 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 b19a7cd5c..e1d8eecf1 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 72dcac4b0..540be3da8 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 904b35031..a3f969fd5 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 e0d7d79b3..8854d823b 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 4a2c39ef9..5995fcb1f 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 de71b1690..b220c6e58 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 05f4474e9..83138f6cc 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 830ee2d36..389430329 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 440b7c888..0790b3920 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([ $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( [] ); $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 0441308ce..ee8d4c513 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([ $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 9f39f67fa..554d6c8de 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 8097eefcc..2672f6814 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( [ + Assert::same([ __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( [ + Assert::same([ __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( [ + Assert::same([ __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( [ + Assert::same([ __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 7380dfce2..b2bb677a9 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( [ + Assert::same([ __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( [ + Assert::same([ __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( [ + Assert::same([ __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( [ + Assert::same([ __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 8ba159261..85385e035 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, ['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, ['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, ['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, ['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, ['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, ['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, ['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, ['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 4ad0a97cd..a705cdeec 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', [ - '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([ - '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', [ @@ -46,6 +46,6 @@ test(function() { 'page' => 2, ])); Assert::same([ - '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 aa4e141ab..044bd1aa4 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 = [ - 'types' => [ - 'Nette\\Bridges\\ApplicationLatte\\ILatteFactory' => [1 => ['latte.latteFactory']], - ], - ]; - - public static function create() - { - $container = new self(); - $container->addService('latte.latteFactory', new LatteFactory(new Latte\Engine())); - return $container; - } + protected $meta = [ + 'types' => [ + 'Nette\\Bridges\\ApplicationLatte\\ILatteFactory' => [1 => ['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', [ - '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', [ + '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', [ - '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', [ + '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', [ - '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', [ + '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', [ - 'callback' => function () { - return [new SplFileInfo(Tester\FileMock::create('{$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', [ + 'callback' => function () { + return [new SplFileInfo(Tester\FileMock::create('{$param}')), []]; + }, + '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', [ - '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', [ + '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', [ - '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(['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', [ + '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(['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', [ - '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(['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', [ + '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(['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 39e78c84e..7769f9db3 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', ['var1' => $this->var1]) ); - Assert::same( '/index.php?var1=20&action=product&presenter=Test', $this->link('product', ['var1' => $this->var1 * 2, 'ok' => TRUE]) ); - Assert::same( '/index.php?var1=1&ok=0&action=product&presenter=Test', $this->link('product', ['var1' => TRUE, 'ok' => '0']) ); - Assert::same( "#error: Invalid value for persistent parameter 'ok' in 'Test', expected boolean.", $this->link('product', ['var1' => NULL, 'ok' => 'a']) ); - Assert::same( "#error: Invalid value for persistent parameter 'var1' in 'Test', expected integer.", $this->link('product', ['var1' => [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', ['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', ['var1' => $this->var1])); + Assert::same('/index.php?var1=20&action=product&presenter=Test', $this->link('product', ['var1' => $this->var1 * 2, 'ok' => TRUE])); + Assert::same('/index.php?var1=1&ok=0&action=product&presenter=Test', $this->link('product', ['var1' => TRUE, 'ok' => '0'])); + Assert::same("#error: Invalid value for persistent parameter 'ok' in 'Test', expected boolean.", $this->link('product', ['var1' => NULL, 'ok' => 'a'])); + Assert::same("#error: Invalid value for persistent parameter 'var1' in 'Test', expected integer.", $this->link('product', ['var1' => [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', ['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', ['var1' => $this->var1]) ); - Assert::same( '/index.php?action=product&presenter=Other', $this->link('Other:product', ['var1' => $this->var1 * 2]) ); - Assert::same( '/index.php?var1=123&presenter=Nette%3AMicro', $this->link('Nette:Micro:', ['var1' => 123]) ); + Assert::same('/index.php?var1=10&action=product&presenter=Other', $this->link('Other:product', ['var1' => $this->var1])); + Assert::same('/index.php?action=product&presenter=Other', $this->link('Other:product', ['var1' => $this->var1 * 2])); + Assert::same('/index.php?var1=123&presenter=Nette%3AMicro', $this->link('Nette:Micro:', ['var1' => 123])); // Presenter & signal link - Assert::same( '/index.php?action=default&do=buy&presenter=Test', $this->link('buy!', ['var1' => $this->var1]) ); - Assert::same( '/index.php?var1=20&action=default&do=buy&presenter=Test', $this->link('buy!', ['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!', [1], (object) [1]) ); - Assert::same( '/index.php?y=2&action=default&do=buy&presenter=Test', $this->link('buy!', [1, 'y' => 2]) ); - Assert::same( '/index.php?y=2&action=default&do=buy&presenter=Test', $this->link('buy!', ['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', ['var1' => $this->var1]) ); - Assert::same( '/index.php?action=default&presenter=Test', $this->link('this!', ['var1' => $this->var1]) ); - Assert::same( '/index.php?sort%5By%5D%5Basc%5D=1&action=default&presenter=Test', $this->link('this', ['sort' => ['y' => ['asc' => TRUE]]]) ); + Assert::same('/index.php?action=default&do=buy&presenter=Test', $this->link('buy!', ['var1' => $this->var1])); + Assert::same('/index.php?var1=20&action=default&do=buy&presenter=Test', $this->link('buy!', ['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!', [1], (object) [1])); + Assert::same('/index.php?y=2&action=default&do=buy&presenter=Test', $this->link('buy!', [1, 'y' => 2])); + Assert::same('/index.php?y=2&action=default&do=buy&presenter=Test', $this->link('buy!', ['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', ['var1' => $this->var1])); + Assert::same('/index.php?action=default&presenter=Test', $this->link('this!', ['var1' => $this->var1])); + Assert::same('/index.php?sort%5By%5D%5Basc%5D=1&action=default&presenter=Test', $this->link('this', ['sort' => ['y' => ['asc' => TRUE]]])); // Presenter & signal link type checking - Assert::same( "#error: Invalid value for parameter 'x' in method TestPresenter::handlebuy(), expected integer.", $this->link('buy!', [[]]) ); - Assert::same( "/index.php?action=default&do=buy&presenter=Test", $this->link('buy!', [new stdClass]) ); + Assert::same("#error: Invalid value for parameter 'x' in method TestPresenter::handlebuy(), expected integer.", $this->link('buy!', [[]])); + Assert::same('/index.php?action=default&do=buy&presenter=Test', $this->link('buy!', [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', [1], (object) [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!', ['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', ['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', $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', [1], (object) [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!', ['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', ['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', $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', ['order' => 1]) ); - Assert::same( "#error: Invalid value for persistent parameter 'round' in 'mycontrol', expected integer.", $this['mycontrol']->link('click', ['round' => []]) ); + Assert::same("#error: Invalid value for persistent parameter 'order' in 'mycontrol', expected array.", $this['mycontrol']->link('click', ['order' => 1])); + Assert::same("#error: Invalid value for persistent parameter 'round' in 'mycontrol', expected integer.", $this['mycontrol']->link('click', ['round' => []])); $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', ['var1' => null, 'ok' => 'a'])); + Assert::same('#', $this->link('product', ['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', ['var1' => null, 'ok' => 'a'])); + Assert::error(function () use ($me) { + Assert::same('#', $me->link('product', ['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', ['var1' => null, 'ok' => 'a']); + Assert::exception(function () use ($me) { + $me->link('product', ['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 5ce213e75..0c2f588f4 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, ['action' => []]); $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, ['do' => []]); $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, ['a' => []]); $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, ['b' => []]); $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, ['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, ['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, ['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, ['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, ['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, ['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, ['bool' => []]); $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 95a1ea528..f4e19783d 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 3eef66ae0..dfb40b2d6 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', ['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', ['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 1839c83cd..33d007569 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 2d2a08bc9..3206998f8 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([ @@ -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([ @@ -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 6893f654c..025465d1c 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([ '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([ '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 66dc2dc82..9199980ed 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', ['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', [], ['a' => 1, 'b' => NULL]); - Assert::same( ['a' => 1, 'b' => NULL], $request->getPost() ); - Assert::same( 1, $request->getPost('a') ); - Assert::same( NULL, $request->getPost('b') ); + Assert::same(['a' => 1, 'b' => NULL], $request->getPost()); + Assert::same(1, $request->getPost('a')); + Assert::same(NULL, $request->getPost('b')); });