From a6f5b5b2a0cb09e2e0ea4a788bd2bec4f99f74ab Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 18 Mar 2014 17:44:01 +0100 Subject: [PATCH 01/24] Json: error Invalid UTF-8 sequence is detectable since PHP 5.3.1, removed workaround --- Nette/Utils/Json.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Nette/Utils/Json.php b/Nette/Utils/Json.php index ab39bd5a27..b7cdc5e1f2 100644 --- a/Nette/Utils/Json.php +++ b/Nette/Utils/Json.php @@ -26,7 +26,7 @@ class Json JSON_ERROR_STATE_MISMATCH => 'Syntax error, malformed JSON', JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', - 5 /*JSON_ERROR_UTF8*/ => 'Invalid UTF-8 sequence', + 5 /*JSON_ERROR_UTF8*/ => 'Invalid UTF-8 sequence', // exists since 5.3.3, but is returned since 5.3.1 6 /*JSON_ERROR_RECURSION*/ => 'Recursion detected', 7 /*JSON_ERROR_INF_OR_NAN*/ => 'Inf and NaN cannot be JSON encoded', 8 /*JSON_ERROR_UNSUPPORTED_TYPE*/ => 'Type is not supported', @@ -50,9 +50,6 @@ final public function __construct() */ public static function encode($value, $options = 0) { - if (function_exists('ini_set')) { // workaround for PHP bugs #52397, #54109, #63004 - $old = ini_set('display_errors', 0); // needed to receive 'Invalid UTF-8 sequence' error - } set_error_handler(function($severity, $message) { // needed to receive 'recursion detected' error restore_error_handler(); throw new JsonException($message); @@ -62,12 +59,10 @@ public static function encode($value, $options = 0) PHP_VERSION_ID >= 50400 ? (JSON_UNESCAPED_UNICODE | ($options & self::PRETTY ? JSON_PRETTY_PRINT : 0)) : 0 ); restore_error_handler(); - if (isset($old)) { - ini_set('display_errors', $old); - } if ($error = json_last_error()) { throw new JsonException(isset(static::$messages[$error]) ? static::$messages[$error] : 'Unknown error', $error); } + $json = str_replace(array("\xe2\x80\xa8", "\xe2\x80\xa9"), array('\u2028', '\u2029'), $json); return $json; } @@ -93,7 +88,7 @@ public static function decode($json, $options = 0) } $value = call_user_func_array('json_decode', $args); - if ($value === NULL && $json !== '' && strcasecmp($json, 'null')) { // '' do not clean json_last_error + if ($value === NULL && $json !== '' && strcasecmp($json, 'null')) { // '' is not clearing json_last_error $error = json_last_error(); throw new JsonException(isset(static::$messages[$error]) ? static::$messages[$error] : 'Unknown error', $error); } From b0e132657ed3e57b7e9d7e8f36eacce92f7e940d Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 18 Mar 2014 17:45:13 +0100 Subject: [PATCH 02/24] Json: added support for future error messages --- Nette/Utils/Json.php | 7 +++---- tests/Nette/Utils/Json.encode().phpt | 7 +++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Nette/Utils/Json.php b/Nette/Utils/Json.php index b7cdc5e1f2..b81d118eca 100644 --- a/Nette/Utils/Json.php +++ b/Nette/Utils/Json.php @@ -27,9 +27,6 @@ class Json JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', 5 /*JSON_ERROR_UTF8*/ => 'Invalid UTF-8 sequence', // exists since 5.3.3, but is returned since 5.3.1 - 6 /*JSON_ERROR_RECURSION*/ => 'Recursion detected', - 7 /*JSON_ERROR_INF_OR_NAN*/ => 'Inf and NaN cannot be JSON encoded', - 8 /*JSON_ERROR_UNSUPPORTED_TYPE*/ => 'Type is not supported', ); @@ -60,7 +57,9 @@ public static function encode($value, $options = 0) ); restore_error_handler(); if ($error = json_last_error()) { - throw new JsonException(isset(static::$messages[$error]) ? static::$messages[$error] : 'Unknown error', $error); + $message = isset(static::$messages[$error]) ? static::$messages[$error] + : (PHP_VERSION_ID >= 50500 ? json_last_error_msg() : 'Unknown error'); + throw new JsonException($message, $error); } $json = str_replace(array("\xe2\x80\xa8", "\xe2\x80\xa9"), array('\u2028', '\u2029'), $json); diff --git a/tests/Nette/Utils/Json.encode().phpt b/tests/Nette/Utils/Json.encode().phpt index 146213db50..53b27c9e56 100644 --- a/tests/Nette/Utils/Json.encode().phpt +++ b/tests/Nette/Utils/Json.encode().phpt @@ -36,3 +36,10 @@ if (PHP_VERSION_ID >= 50400) { // JSON_PRETTY_PRINT Assert::same( "[\n 1,\n 2,\n 3\n]", Json::encode(array(1,2,3,), Json::PRETTY) ); } + + +if (PHP_VERSION_ID >= 50500) { + Assert::exception(function() { + Json::encode(NAN); + }, 'Nette\Utils\JsonException', 'Inf and NaN cannot be JSON encoded'); +} From 104885dc4fa0330f82d5fca12743f4221be669d6 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 18 Mar 2014 18:11:21 +0100 Subject: [PATCH 03/24] Json: own error handler is required only in PHP < 5.5 --- Nette/Utils/Json.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Nette/Utils/Json.php b/Nette/Utils/Json.php index b81d118eca..d7299ebf8b 100644 --- a/Nette/Utils/Json.php +++ b/Nette/Utils/Json.php @@ -47,15 +47,21 @@ final public function __construct() */ public static function encode($value, $options = 0) { - set_error_handler(function($severity, $message) { // needed to receive 'recursion detected' error - restore_error_handler(); - throw new JsonException($message); - }); + if (PHP_VERSION_ID < 50500) { + set_error_handler(function($severity, $message) { // needed to receive 'recursion detected' error + restore_error_handler(); + throw new JsonException($message); + }); + } + $json = json_encode( $value, PHP_VERSION_ID >= 50400 ? (JSON_UNESCAPED_UNICODE | ($options & self::PRETTY ? JSON_PRETTY_PRINT : 0)) : 0 ); - restore_error_handler(); + + if (PHP_VERSION_ID < 50500) { + restore_error_handler(); + } if ($error = json_last_error()) { $message = isset(static::$messages[$error]) ? static::$messages[$error] : (PHP_VERSION_ID >= 50500 ? json_last_error_msg() : 'Unknown error'); From 654ed08d472432e7a3f93e9e00ab92b2a9089c8a Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 18 Mar 2014 18:20:42 +0100 Subject: [PATCH 04/24] removed obsolete function_exists() --- Nette/Http/Response.php | 2 +- Nette/Mail/MimePart.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Nette/Http/Response.php b/Nette/Http/Response.php index dfa3bf3a21..3382f32c66 100644 --- a/Nette/Http/Response.php +++ b/Nette/Http/Response.php @@ -92,7 +92,7 @@ public function getCode() public function setHeader($name, $value) { self::checkHeaders(); - if ($value === NULL && function_exists('header_remove')) { + if ($value === NULL) { header_remove($name); } elseif (strcasecmp($name, 'Content-Length') === 0 && ini_get('zlib.output_compression')) { // ignore, PHP bug #44164 diff --git a/Nette/Mail/MimePart.php b/Nette/Mail/MimePart.php index fb5b674131..79ec9cbab3 100644 --- a/Nette/Mail/MimePart.php +++ b/Nette/Mail/MimePart.php @@ -257,7 +257,7 @@ public function getEncodedMessage() if ($body !== '') { switch ($this->getEncoding()) { case self::ENCODING_QUOTED_PRINTABLE: - $output .= function_exists('quoted_printable_encode') ? quoted_printable_encode($body) : self::encodeQuotedPrintable($body); + $output .= quoted_printable_encode($body); break; case self::ENCODING_BASE64: From db6ce51ea721489fb0571e4d5326405eaf1f87f2 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 20 Mar 2014 20:24:59 +0100 Subject: [PATCH 05/24] MimeTypeDetector: used FILEINFO_MIME_TYPE --- Nette/Utils/MimeTypeDetector.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Nette/Utils/MimeTypeDetector.php b/Nette/Utils/MimeTypeDetector.php index 0694a1b32b..0b41ee8a4e 100644 --- a/Nette/Utils/MimeTypeDetector.php +++ b/Nette/Utils/MimeTypeDetector.php @@ -43,13 +43,13 @@ public static function fromFile($file) return $info['mime']; } elseif (extension_loaded('fileinfo')) { - $type = preg_replace('#[\s;].*\z#', '', finfo_file(finfo_open(FILEINFO_MIME), $file)); + $type = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file); } elseif (function_exists('mime_content_type')) { $type = mime_content_type($file); } - return isset($type) && preg_match('#^\S+/\S+\z#', $type) ? $type : 'application/octet-stream'; + return isset($type) && strpos($type, '/') ? $type : 'application/octet-stream'; } @@ -60,8 +60,8 @@ public static function fromFile($file) */ public static function fromString($data) { - if (extension_loaded('fileinfo') && preg_match('#^(\S+/[^\s;]+)#', finfo_buffer(finfo_open(FILEINFO_MIME), $data), $m)) { - return $m[1]; + if (extension_loaded('fileinfo') && strpos($type = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $data), '/')) { + return $type; } elseif (strncmp($data, "\xff\xd8", 2) === 0) { return 'image/jpeg'; From 8271b21e34e02dc2ab1423f1d1db6fca409a7fb1 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 21 Mar 2014 03:07:22 +0100 Subject: [PATCH 06/24] Strings::fixEncoding() uses iconv in PHP 5.3, because htmlspecialchars can be very slow --- Nette/Utils/Strings.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Nette/Utils/Strings.php b/Nette/Utils/Strings.php index 2be31b031c..2e6b97a1f2 100644 --- a/Nette/Utils/Strings.php +++ b/Nette/Utils/Strings.php @@ -48,9 +48,8 @@ public static function checkEncoding($s, $encoding = 'UTF-8') public static function fixEncoding($s, $encoding = 'UTF-8') { // removes xD800-xDFFF, x110000 and higher - if (strcasecmp($encoding, 'UTF-8')) { - ini_set('mbstring.substitute_character', 'none'); - return mb_convert_encoding($s, $encoding, $encoding); + if (PHP_VERSION_ID < 50400 || strcasecmp($encoding, 'UTF-8')) { + return @iconv('UTF-16', $encoding . '//IGNORE', iconv($encoding, 'UTF-16//IGNORE', $s)); // intentionally @ } else { return htmlspecialchars_decode(htmlspecialchars($s, ENT_NOQUOTES | ENT_IGNORE, 'UTF-8'), ENT_NOQUOTES); } From 044ee099c0cab4c07a0bcf1a1f2eae460f4c3f01 Mon Sep 17 00:00:00 2001 From: Patrik Votocek Date: Wed, 2 Apr 2014 16:16:29 +0200 Subject: [PATCH 07/24] Fix FileUpload::__toString() when is empty --- Nette/Http/FileUpload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nette/Http/FileUpload.php b/Nette/Http/FileUpload.php index 27eb9b2048..1409b19c69 100644 --- a/Nette/Http/FileUpload.php +++ b/Nette/Http/FileUpload.php @@ -118,7 +118,7 @@ public function getTemporaryFile() */ public function __toString() { - return $this->tmpName; + return (string) $this->tmpName; } From b9dbe7d7ac576c86e1266c6f4a9c3e203abaa412 Mon Sep 17 00:00:00 2001 From: Vasek Purchart Date: Fri, 4 Apr 2014 10:55:09 +0200 Subject: [PATCH 08/24] option to disable autoloading of annotation classes --- Nette/Reflection/AnnotationsParser.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Nette/Reflection/AnnotationsParser.php b/Nette/Reflection/AnnotationsParser.php index 041df03162..8923b801da 100644 --- a/Nette/Reflection/AnnotationsParser.php +++ b/Nette/Reflection/AnnotationsParser.php @@ -28,6 +28,9 @@ class AnnotationsParser /** @var bool */ public static $useReflection; + /** @var bool */ + public static $useAnnotationClasses = TRUE; + /** @var array */ public static $inherited = array('description', 'param', 'return'); @@ -248,7 +251,7 @@ private static function parseComment($comment) } $class = $name . 'Annotation'; - if (class_exists($class)) { + if (self::$useAnnotationClasses && class_exists($class)) { $res[$name][] = new $class(is_array($value) ? $value : array('value' => $value)); } else { From 38d51effdace46ce12af1a9f731c990d3620f272 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 20 Mar 2014 22:01:25 +0100 Subject: [PATCH 09/24] tests: removed usage of Container, Button, etc. --- ...PresenterFactory.formatPresenterClass.phpt | 10 ++-- .../PresenterFactory.formatPresenterFile.phpt | 4 +- ...esenterFactory.unformatPresenterClass.phpt | 4 +- tests/Nette/Caching/FileStorage.stress.phpt | 5 -- .../ComponentModel/Container.iterator.phpt | 13 +++-- .../DI/Compiler.services.autowiring.phpt | 5 +- .../files/compiler.services.autowiring.neon | 13 ++--- .../Database/Table/Selection.page().phpt | 48 +++++++++---------- tests/Nette/Http/Session.handler.phpt | 4 +- tests/Nette/Http/Session.invalidId.phpt | 3 +- tests/Nette/Http/Session.regenerateId().phpt | 3 +- tests/Nette/Http/Session.sections.phpt | 3 +- tests/Nette/Http/Session.start.error.phpt | 3 +- tests/Nette/Http/Session.storage.phpt | 3 +- tests/Nette/Http/SessionSection.basic.phpt | 3 +- tests/Nette/Http/SessionSection.remove.phpt | 3 +- .../Nette/Http/SessionSection.separated.phpt | 3 +- .../Http/SessionSection.setExpiration().phpt | 3 +- .../Nette/Http/SessionSection.undefined.phpt | 3 +- tests/Nette/Security/MockUserStorage.php | 34 +++++++++++++ tests/Nette/Security/User.authentication.phpt | 13 +---- tests/Nette/Security/User.authorization.phpt | 5 +- tests/Nette/Utils/SafeStream.stress.phpt | 3 +- 23 files changed, 97 insertions(+), 94 deletions(-) create mode 100644 tests/Nette/Security/MockUserStorage.php diff --git a/tests/Nette/Application/PresenterFactory.formatPresenterClass.phpt b/tests/Nette/Application/PresenterFactory.formatPresenterClass.phpt index bd0d2d7d18..bae8e55d49 100644 --- a/tests/Nette/Application/PresenterFactory.formatPresenterClass.phpt +++ b/tests/Nette/Application/PresenterFactory.formatPresenterClass.phpt @@ -13,10 +13,8 @@ use Nette\Application\PresenterFactory, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); - -test(function() use ($container) { - $factory = new PresenterFactory(NULL, $container); +test(function() { + $factory = new PresenterFactory(NULL, new Nette\DI\Container); $factory->setMapping(array( 'Foo2' => 'App2\*\*Presenter', @@ -38,8 +36,8 @@ test(function() use ($container) { }); -test(function() use ($container) { - $factory = new PresenterFactory(NULL, $container); +test(function() { + $factory = new PresenterFactory(NULL, new Nette\DI\Container); $factory->setMapping(array( 'Foo2' => 'App2\*Presenter', diff --git a/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt b/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt index 5812967e55..87e4c1a174 100644 --- a/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt +++ b/tests/Nette/Application/PresenterFactory.formatPresenterFile.phpt @@ -13,9 +13,7 @@ use Nette\Application\PresenterFactory, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); - -$factory = new PresenterFactory('base', $container); +$factory = new PresenterFactory('base', new Nette\DI\Container); test(function() use ($factory) { $factory->setMapping(array( diff --git a/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt b/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt index dd0ef2041e..299fc3b4f4 100644 --- a/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt +++ b/tests/Nette/Application/PresenterFactory.unformatPresenterClass.phpt @@ -13,9 +13,7 @@ use Nette\Application\PresenterFactory, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); - -$factory = new PresenterFactory(NULL, $container); +$factory = new PresenterFactory(NULL, new Nette\DI\Container); test(function() use ($factory) { $factory->setMapping(array( diff --git a/tests/Nette/Caching/FileStorage.stress.phpt b/tests/Nette/Caching/FileStorage.stress.phpt index 1b1f014c1d..84d744a7dd 100644 --- a/tests/Nette/Caching/FileStorage.stress.phpt +++ b/tests/Nette/Caching/FileStorage.stress.phpt @@ -8,7 +8,6 @@ */ use Nette\Caching\Storages\FileStorage, - Nette\Diagnostics\Debugger, Tester\Assert; @@ -44,8 +43,6 @@ for ($i=0; $i<=COUNT_FILES; $i++) { // test loop -Debugger::timer(); - $hits = array('ok' => 0, 'notfound' => 0, 'error' => 0, 'cantwrite' => 0, 'cantdelete' => 0); for ($counter=0; $counter<1000; $counter++) { // write @@ -64,7 +61,6 @@ for ($counter=0; $counter<1000; $counter++) { elseif (checkStr($res)) $hits['ok']++; else $hits['error']++; } -$time = Debugger::timer(); Assert::same( array( @@ -83,4 +79,3 @@ Assert::same( array( // [cantdelete] => 0 // means 'delete() has timeout', should be 0 Assert::same(0, $hits['error']); -// takes $time ms diff --git a/tests/Nette/ComponentModel/Container.iterator.phpt b/tests/Nette/ComponentModel/Container.iterator.phpt index 5693fa83ce..bc76181917 100644 --- a/tests/Nette/ComponentModel/Container.iterator.phpt +++ b/tests/Nette/ComponentModel/Container.iterator.phpt @@ -8,13 +8,16 @@ use Nette\ComponentModel\Component, Nette\ComponentModel\Container, - Nette\Forms\Controls\Button, Tester\Assert; require __DIR__ . '/../bootstrap.php'; +class Button extends Component +{ +} + class ComponentX extends Component { } @@ -23,11 +26,11 @@ $c = new Container(NULL, 'top'); $c->addComponent(new Container, 'one'); $c->addComponent(new ComponentX, 'two'); -$c->addComponent(new Button('label'), 'button1'); +$c->addComponent(new Button, 'button1'); $c->getComponent('one')->addComponent(new ComponentX, 'inner'); $c->getComponent('one')->addComponent(new Container, 'inner2'); -$c->getComponent('one')->getComponent('inner2')->addComponent(new Button('label'), 'button2'); +$c->getComponent('one')->getComponent('inner2')->addComponent(new Button, 'button2'); // Normal @@ -40,7 +43,7 @@ Assert::same( array( // Filter -$list = $c->getComponents(FALSE, 'Nette\Forms\Controls\Button'); +$list = $c->getComponents(FALSE, 'Button'); Assert::same( array( "button1", ), array_keys(iterator_to_array($list)) ); @@ -83,7 +86,7 @@ Assert::same( array( // Recursive & filter I -$list = $c->getComponents(TRUE, 'Nette\Forms\Controls\Button'); +$list = $c->getComponents(TRUE, 'Button'); Assert::same( array( "button2", "button1", diff --git a/tests/Nette/DI/Compiler.services.autowiring.phpt b/tests/Nette/DI/Compiler.services.autowiring.phpt index 2676d75391..be8f1ac941 100644 --- a/tests/Nette/DI/Compiler.services.autowiring.phpt +++ b/tests/Nette/DI/Compiler.services.autowiring.phpt @@ -36,12 +36,15 @@ class Model class Lorem { /** autowiring using parameters */ - static function test(Nette\Security\SimpleAuthenticator $arg) + static function test(Ipsum $arg) { Notes::add(__METHOD__); } } +class Ipsum +{} + $loader = new DI\Config\Loader; $compiler = new DI\Compiler; diff --git a/tests/Nette/DI/files/compiler.services.autowiring.neon b/tests/Nette/DI/files/compiler.services.autowiring.neon index cf2cccd41d..79eaf8b0d1 100644 --- a/tests/Nette/DI/files/compiler.services.autowiring.neon +++ b/tests/Nette/DI/files/compiler.services.autowiring.neon @@ -1,10 +1,6 @@ -parameters: - class: Lorem - factory: Factory - services: model: - create: %factory%::createModel + create: Factory::createModel setup: # local methods - test(...) @@ -18,10 +14,9 @@ services: - @lorem::test lorem: - class: %class% + class: Lorem alias: @lorem - authenticator: - class: Nette\Security\SimpleAuthenticator - arguments: [['username': '*****']] + ipsum: + class: Ipsum diff --git a/tests/Nette/Database/Table/Selection.page().phpt b/tests/Nette/Database/Table/Selection.page().phpt index d17942ab1e..5258f60bcf 100644 --- a/tests/Nette/Database/Table/Selection.page().phpt +++ b/tests/Nette/Database/Table/Selection.page().phpt @@ -15,47 +15,47 @@ Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/../files/{$driverN //public function page($page, $itemsPerPage, & $numOfPages = NULL) test(function() use ($context) { //first page, one item per page - $numberOfPages = 0; + $numberOfPages = 0; - $tags = $context->table('tag')->page(1, 1, $numOfPages); - Assert::equal(1, count($tags)); //one item on first page - Assert::equal(4, $numOfPages); //four pages total + $tags = $context->table('tag')->page(1, 1, $numOfPages); + Assert::equal(1, count($tags)); //one item on first page + Assert::equal(4, $numOfPages); //four pages total - //calling the same without the $numOfPages reference - unset($tags); - $tags = $context->table('tag')->page(1, 1); - Assert::equal(1, count($tags)); //one item on first page + //calling the same without the $numOfPages reference + unset($tags); + $tags = $context->table('tag')->page(1, 1); + Assert::equal(1, count($tags)); //one item on first page }); test(function() use ($context) { //second page, three items per page - $numberOfPages = 0; + $numberOfPages = 0; - $tags = $context->table('tag')->page(2, 3, $numOfPages); - Assert::equal(1, count($tags)); //one item on second page - Assert::equal(2, $numOfPages); //two pages total + $tags = $context->table('tag')->page(2, 3, $numOfPages); + Assert::equal(1, count($tags)); //one item on second page + Assert::equal(2, $numOfPages); //two pages total - //calling the same without the $numOfPages reference - unset($tags); - $tags = $context->table('tag')->page(2, 3); - Assert::equal(1, count($tags)); //one item on second page + //calling the same without the $numOfPages reference + unset($tags); + $tags = $context->table('tag')->page(2, 3); + Assert::equal(1, count($tags)); //one item on second page }); test(function() use ($context) { //page with no items - $tags = $context->table('tag')->page(10, 4); - Assert::equal(0, count($tags)); //one item on second page + $tags = $context->table('tag')->page(10, 4); + Assert::equal(0, count($tags)); //one item on second page }); test(function() use ($context) { //page with no items (page not in range) - $tags = $context->table('tag')->page(100, 4); - Assert::equal(0, count($tags)); //one item on second page + $tags = $context->table('tag')->page(100, 4); + Assert::equal(0, count($tags)); //one item on second page }); test(function() use ($context) { //less items than $itemsPerPage - $tags = $context->table('tag')->page(1, 100); - Assert::equal(4, count($tags)); //all four items from db + $tags = $context->table('tag')->page(1, 100); + Assert::equal(4, count($tags)); //all four items from db }); test(function() use ($context) { //invalid params - $tags = $context->table('tag')->page('foo', 'bar'); - Assert::equal(0, count($tags)); //no items + $tags = $context->table('tag')->page('foo', 'bar'); + Assert::equal(0, count($tags)); //no items }); diff --git a/tests/Nette/Http/Session.handler.phpt b/tests/Nette/Http/Session.handler.phpt index 8384d4a75c..99eda98982 100644 --- a/tests/Nette/Http/Session.handler.phpt +++ b/tests/Nette/Http/Session.handler.phpt @@ -55,8 +55,8 @@ class MySessionStorage extends Object implements SessionHandlerInterface } -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$factory = new Nette\Http\RequestFactory; +$session = new Nette\Http\Session($factory->createHttpRequest(), new Nette\Http\Response); $session->setHandler(new MySessionStorage); $session->start(); diff --git a/tests/Nette/Http/Session.invalidId.phpt b/tests/Nette/Http/Session.invalidId.phpt index 154dc7eb20..bf6c56a292 100644 --- a/tests/Nette/Http/Session.invalidId.phpt +++ b/tests/Nette/Http/Session.invalidId.phpt @@ -17,7 +17,6 @@ require __DIR__ . '/../bootstrap.php'; $_COOKIE['PHPSESSID'] = '#'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $session = $session->start(); diff --git a/tests/Nette/Http/Session.regenerateId().phpt b/tests/Nette/Http/Session.regenerateId().phpt index 8bce4b4d9c..a95b2070a3 100644 --- a/tests/Nette/Http/Session.regenerateId().phpt +++ b/tests/Nette/Http/Session.regenerateId().phpt @@ -13,8 +13,7 @@ use Nette\Http\Session, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $path = rtrim(ini_get('session.save_path'), '/\\') . '/sess_'; diff --git a/tests/Nette/Http/Session.sections.phpt b/tests/Nette/Http/Session.sections.phpt index 8b1f579b8b..e6b4550a3c 100644 --- a/tests/Nette/Http/Session.sections.phpt +++ b/tests/Nette/Http/Session.sections.phpt @@ -16,8 +16,7 @@ require __DIR__ . '/../bootstrap.php'; ob_start(); -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); Assert::false( $session->hasSection('trees') ); // hasSection() should have returned FALSE for a section with no keys set diff --git a/tests/Nette/Http/Session.start.error.phpt b/tests/Nette/Http/Session.start.error.phpt index 70a5fc8745..8f83f7451f 100644 --- a/tests/Nette/Http/Session.start.error.phpt +++ b/tests/Nette/Http/Session.start.error.phpt @@ -17,8 +17,7 @@ require __DIR__ . '/../bootstrap.php'; ini_set('session.save_path', ';;;'); -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); Assert::exception(function() use ($session) { $session->start(); diff --git a/tests/Nette/Http/Session.storage.phpt b/tests/Nette/Http/Session.storage.phpt index 3899907cd6..8ebf7770bc 100644 --- a/tests/Nette/Http/Session.storage.phpt +++ b/tests/Nette/Http/Session.storage.phpt @@ -55,8 +55,7 @@ class MySessionStorage extends Object implements ISessionStorage } -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $session->setStorage(new MySessionStorage); $session->start(); diff --git a/tests/Nette/Http/SessionSection.basic.phpt b/tests/Nette/Http/SessionSection.basic.phpt index fb3031a633..175d1a1466 100644 --- a/tests/Nette/Http/SessionSection.basic.phpt +++ b/tests/Nette/Http/SessionSection.basic.phpt @@ -13,8 +13,7 @@ use Nette\Http\Session, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $namespace = $session->getSection('one'); $namespace->a = 'apple'; diff --git a/tests/Nette/Http/SessionSection.remove.phpt b/tests/Nette/Http/SessionSection.remove.phpt index 4dc07b357e..766807a222 100644 --- a/tests/Nette/Http/SessionSection.remove.phpt +++ b/tests/Nette/Http/SessionSection.remove.phpt @@ -13,8 +13,7 @@ use Nette\Http\Session, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $namespace = $session->getSection('three'); $namespace->a = 'apple'; diff --git a/tests/Nette/Http/SessionSection.separated.phpt b/tests/Nette/Http/SessionSection.separated.phpt index 8fe951bc41..e28f333ea8 100644 --- a/tests/Nette/Http/SessionSection.separated.phpt +++ b/tests/Nette/Http/SessionSection.separated.phpt @@ -13,8 +13,7 @@ use Nette\Http\Session, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $namespace1 = $session->getSection('namespace1'); $namespace1b = $session->getSection('namespace1'); diff --git a/tests/Nette/Http/SessionSection.setExpiration().phpt b/tests/Nette/Http/SessionSection.setExpiration().phpt index 78eed42f32..436e427205 100644 --- a/tests/Nette/Http/SessionSection.setExpiration().phpt +++ b/tests/Nette/Http/SessionSection.setExpiration().phpt @@ -13,8 +13,7 @@ use Nette\Http\Session, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $session->setExpiration('+10 seconds'); diff --git a/tests/Nette/Http/SessionSection.undefined.phpt b/tests/Nette/Http/SessionSection.undefined.phpt index f1ff51dd62..170ea3de1c 100644 --- a/tests/Nette/Http/SessionSection.undefined.phpt +++ b/tests/Nette/Http/SessionSection.undefined.phpt @@ -13,8 +13,7 @@ use Nette\Http\Session, require __DIR__ . '/../bootstrap.php'; -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); -$session = $container->getService('session'); +$session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $namespace = $session->getSection('one'); Assert::false( isset($namespace->undefined) ); diff --git a/tests/Nette/Security/MockUserStorage.php b/tests/Nette/Security/MockUserStorage.php new file mode 100644 index 0000000000..4a9824c768 --- /dev/null +++ b/tests/Nette/Security/MockUserStorage.php @@ -0,0 +1,34 @@ +auth = $state; + } + + function isAuthenticated() + { + return $this->auth; + } + + function setIdentity(Nette\Security\IIdentity $identity = NULL) + { + $this->identity = $identity; + } + + function getIdentity() + { + return $this->identity; + } + + function setExpiration($time, $flags = 0) + {} + + function getLogoutReason() + {} + +} diff --git a/tests/Nette/Security/User.authentication.phpt b/tests/Nette/Security/User.authentication.phpt index f8dfe392b7..e315640eb8 100644 --- a/tests/Nette/Security/User.authentication.phpt +++ b/tests/Nette/Security/User.authentication.phpt @@ -12,7 +12,7 @@ use Nette\Security\IAuthenticator, require __DIR__ . '/../bootstrap.php'; - +require __DIR__ . '/MockUserStorage.php'; // Setup environment $_COOKIE = array(); @@ -53,9 +53,7 @@ function onLoggedOut($user) { } -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); - -$user = $container->getService('user'); +$user = new Nette\Security\User(new MockUserStorage); $user->onLoggedIn[] = 'onLoggedIn'; $user->onLoggedOut[] = 'onLoggedOut'; @@ -116,10 +114,3 @@ Assert::null( $user->getIdentity() ); // login as john#2? $user->login('john', 'xxx'); Assert::true( $user->isLoggedIn() ); - - -// setNamespace(...) -$user->getStorage()->setNamespace('other'); - -Assert::false( $user->isLoggedIn() ); -Assert::null( $user->getIdentity() ); diff --git a/tests/Nette/Security/User.authorization.phpt b/tests/Nette/Security/User.authorization.phpt index 2e01e11eab..b18fb2b135 100644 --- a/tests/Nette/Security/User.authorization.phpt +++ b/tests/Nette/Security/User.authorization.phpt @@ -13,6 +13,7 @@ use Nette\Security\IAuthenticator, require __DIR__ . '/../bootstrap.php'; +require __DIR__ . '/MockUserStorage.php'; // Setup environment @@ -60,9 +61,7 @@ class Authorizator implements IAuthorizator } -$container = id(new Nette\Configurator)->setTempDirectory(TEMP_DIR)->createContainer(); - -$user = $container->getService('user'); +$user = new Nette\Security\User(new MockUserStorage); // guest Assert::false( $user->isLoggedIn() ); diff --git a/tests/Nette/Utils/SafeStream.stress.phpt b/tests/Nette/Utils/SafeStream.stress.phpt index f3eaf428f2..904018ab5d 100644 --- a/tests/Nette/Utils/SafeStream.stress.phpt +++ b/tests/Nette/Utils/SafeStream.stress.phpt @@ -7,8 +7,7 @@ * @multiple 5 */ -use Nette\Diagnostics\Debugger, - Tester\Assert; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; From df99d9d2807e85cab25ca334d8803e9cb7faa7c7 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 27 Mar 2014 21:00:42 +0100 Subject: [PATCH 10/24] tests: improved Latte tests, removed codefix() --- tests/Nette/Latte/Parser.shortNoEscape.phpt | 3 +-- tests/Nette/Latte/Template.inc | 10 +--------- tests/Nette/Latte/UIMacros.link.phpt | 2 +- tests/Nette/Latte/expected/macros.cache.inc.phtml | 6 +++--- tests/Nette/Latte/expected/macros.cache.phtml | 6 +++--- tests/Nette/Latte/expected/macros.defineblock.phtml | 4 ++-- tests/Nette/Latte/expected/macros.dynamicblock.phtml | 10 +++++----- .../Latte/expected/macros.dynamicsnippets.alt.phtml | 6 +++--- .../Nette/Latte/expected/macros.dynamicsnippets.phtml | 4 ++-- tests/Nette/Latte/expected/macros.first-sep-last.phtml | 2 +- tests/Nette/Latte/expected/macros.forms.get.phtml | 2 +- tests/Nette/Latte/expected/macros.general.html.phtml | 6 +++--- .../Latte/expected/macros.general.xhtml.inc1.phtml | 6 +++--- .../Latte/expected/macros.general.xhtml.inc2.phtml | 2 +- .../Latte/expected/macros.general.xhtml.inc3.phtml | 2 +- .../Latte/expected/macros.general.xhtml.menu.phtml | 4 ++-- tests/Nette/Latte/expected/macros.general.xhtml.phtml | 6 +++--- tests/Nette/Latte/expected/macros.helpers.phtml | 2 +- tests/Nette/Latte/expected/macros.ical.phtml | 2 +- tests/Nette/Latte/expected/macros.include.inc1.phtml | 8 ++++---- tests/Nette/Latte/expected/macros.include.inc2.phtml | 4 ++-- tests/Nette/Latte/expected/macros.include.inc3.phtml | 4 ++-- tests/Nette/Latte/expected/macros.include.phtml | 4 ++-- .../Nette/Latte/expected/macros.includeblock.inc.phtml | 6 +++--- tests/Nette/Latte/expected/macros.includeblock.phtml | 4 ++-- .../expected/macros.inheritance.child1.child.phtml | 6 +++--- .../expected/macros.inheritance.child1.parent.phtml | 8 ++++---- .../Latte/expected/macros.inheritance.child2.phtml | 8 ++++---- .../Latte/expected/macros.inheritance.child5.phtml | 4 ++-- tests/Nette/Latte/expected/macros.snippet.alt.phtml | 8 ++++---- tests/Nette/Latte/expected/macros.snippet.phtml | 10 +++++----- tests/Nette/Latte/expected/macros.syntax.phtml | 2 +- tests/Nette/Latte/expected/macros.unquoted.phtml | 2 +- tests/Nette/Latte/expected/macros.use.phtml | 2 +- tests/Nette/Latte/expected/macros.xml.phtml | 2 +- tests/Nette/Latte/macros.cache.phpt | 2 +- tests/Nette/Latte/macros.comments.html.phpt | 3 --- tests/Nette/Latte/macros.control.phpt | 2 -- tests/Nette/Latte/macros.defineblock.phpt | 4 +--- tests/Nette/Latte/macros.dynamicblock.phpt | 4 +--- tests/Nette/Latte/macros.dynamicsnippets.alt.phpt | 4 +--- tests/Nette/Latte/macros.dynamicsnippets.phpt | 4 +--- tests/Nette/Latte/macros.first-sep-last.phpt | 4 +--- tests/Nette/Latte/macros.forms.formContainer.phpt | 4 +--- tests/Nette/Latte/macros.forms.get.phpt | 4 +--- tests/Nette/Latte/macros.forms.phpt | 4 +--- tests/Nette/Latte/macros.general.html.phpt | 4 +--- tests/Nette/Latte/macros.general.xhtml.phpt | 4 +--- tests/Nette/Latte/macros.helpers.phpt | 4 +--- tests/Nette/Latte/macros.ical.phpt | 4 +--- tests/Nette/Latte/macros.include.phpt | 3 +-- tests/Nette/Latte/macros.includeblock.phpt | 2 +- tests/Nette/Latte/macros.inheritance.child1.phpt | 2 +- tests/Nette/Latte/macros.inheritance.child2.phpt | 4 +--- tests/Nette/Latte/macros.inheritance.child5.phpt | 4 +--- tests/Nette/Latte/macros.php.phpt | 2 +- tests/Nette/Latte/macros.recursive.phpt | 5 +---- tests/Nette/Latte/macros.snippet.alt.phpt | 4 +--- tests/Nette/Latte/macros.snippet.phpt | 4 +--- tests/Nette/Latte/macros.syntax.phpt | 4 +--- tests/Nette/Latte/macros.unquoted.phpt | 4 +--- tests/Nette/Latte/macros.use.phpt | 4 +--- tests/Nette/Latte/macros.xml.phpt | 4 +--- 63 files changed, 105 insertions(+), 163 deletions(-) diff --git a/tests/Nette/Latte/Parser.shortNoEscape.phpt b/tests/Nette/Latte/Parser.shortNoEscape.phpt index 90e9b86af2..12aa3028b4 100644 --- a/tests/Nette/Latte/Parser.shortNoEscape.phpt +++ b/tests/Nette/Latte/Parser.shortNoEscape.phpt @@ -29,6 +29,5 @@ $template->setSource('{="<>"}'); Assert::match('<>', (string) $template); Assert::error(function() use ($template) { - $template->setSource('{!="<>"}'); - Assert::match('<>', (string) $template); + $template->setSource('{!="<>"}')->compile(); }, E_USER_DEPRECATED, 'The noescape shortcut {!...} is deprecated, use {...|noescape} modifier on line 1.'); diff --git a/tests/Nette/Latte/Template.inc b/tests/Nette/Latte/Template.inc index 77384dcf30..64298f3f6a 100644 --- a/tests/Nette/Latte/Template.inc +++ b/tests/Nette/Latte/Template.inc @@ -23,15 +23,7 @@ class MockCacheStorage extends PhpFileStorage public function write($key, $data, array $dp) { - $this->phtml[basename($this->hint)] = codefix($data); + $this->phtml[basename($this->hint)] = $data; } } - - -function codefix($s) -{ - $s = preg_replace("#(?<=['_])[a-z0-9]{10,}(?=['_])#", 'xxx', $s); - $s = preg_replace('#source file:.*#', '', $s); - return $s; -} diff --git a/tests/Nette/Latte/UIMacros.link.phpt b/tests/Nette/Latte/UIMacros.link.phpt index bece2ab269..d33d9d7509 100644 --- a/tests/Nette/Latte/UIMacros.link.phpt +++ b/tests/Nette/Latte/UIMacros.link.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; $compiler = new Nette\Latte\Compiler; -$compiler->setContentType(Nette\Latte\Compiler::CONTENT_TEXT); +$compiler->setContentType($compiler::CONTENT_TEXT); UIMacros::install($compiler); // {link ...} diff --git a/tests/Nette/Latte/expected/macros.cache.inc.phtml b/tests/Nette/Latte/expected/macros.cache.inc.phtml index 7fa297d971..2eaf2aae38 100644 --- a/tests/Nette/Latte/expected/macros.cache.inc.phtml +++ b/tests/Nette/Latte/expected/macros.cache.inc.phtml @@ -1,10 +1,10 @@

Included file ()

-caches)) { ?> +caches)) { ?> lower($title), ENT_NOQUOTES) ?> tmp = array_pop($_g->caches); if (!$_l->tmp instanceof stdClass) $_l->tmp->end(); } diff --git a/tests/Nette/Latte/expected/macros.cache.phtml b/tests/Nette/Latte/expected/macros.cache.phtml index 405b2ab0ee..67dc68a6e1 100644 --- a/tests/Nette/Latte/expected/macros.cache.phtml +++ b/tests/Nette/Latte/expected/macros.cache.phtml @@ -1,6 +1,6 @@ Noncached content -caches, array($id, 'tags' => 'mytag'))) { ?> +caches, array($id, 'tags' => 'mytag'))) { ?>

upper($title), ENT_NOQUOTES) ?>

- 11) + $template->getParameters(), $_l->templates['xxx'])->render() ?> + 11) + $template->getParameters(), $_l->templates['%[a-z0-9]+%'])->render() ?> tmp = array_pop($_g->caches); if (!$_l->tmp instanceof stdClass) $_l->tmp->end(); } diff --git a/tests/Nette/Latte/expected/macros.defineblock.phtml b/tests/Nette/Latte/expected/macros.defineblock.phtml index 29410dc2b7..5198091529 100644 --- a/tests/Nette/Latte/expected/macros.defineblock.phtml +++ b/tests/Nette/Latte/expected/macros.defineblock.phtml @@ -1,12 +1,12 @@ blocks['test'][] = '_xxx_test')) { function _xxx_test($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v +if (!function_exists($_l->blocks['test'][] = '_%[a-z0-9]+%_test')) { function _%[a-z0-9]+%_test($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?> This is definition # blocks['static'][] = '_xxx_static')) { function _xxx_static($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v +if (!function_exists($_l->blocks['static'][] = '_%[a-z0-9]+%_static')) { function _%[a-z0-9]+%_static($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?> Static block # blocks['static']), $_l, get_defined_vars()) ?> // // block $name // -if (!function_exists($_l->blocks[$name]['xxx'] = '_xxx__name')) { function _xxx__name($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?> +if (!function_exists($_l->blocks[$name]['%[a-z0-9]+%'] = '_%[a-z0-9]+%__name')) { function _%[a-z0-9]+%__name($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?> Dynamic block # blocks[$name]), $_l, get_defined_vars()) ;$iterations++; } array_pop($_l->its); $iterator = end($_l->its) ?> @@ -54,11 +54,11 @@ if (!function_exists($_l->blocks[$name]['xxx'] = '_xxx__name')) { function _xxx_ // // block word$name // -if (!function_exists($_l->blocks["word$name"]['xxx'] = '_xxx_word_name')) { function _xxx_word_name($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ;}} call_user_func(reset($_l->blocks["word$name"]), $_l, get_defined_vars()) ?> +if (!function_exists($_l->blocks["word$name"]['%[a-z0-9]+%'] = '_%[a-z0-9]+%_word_name')) { function _%[a-z0-9]+%_word_name($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ;}} call_user_func(reset($_l->blocks["word$name"]), $_l, get_defined_vars()) ?> blocks["word$name"]['xxx'] = '_xxx__word_name_')) { function _xxx__word_name_($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ;}} call_user_func(reset($_l->blocks["word$name"]), $_l, get_defined_vars()) ?> +if (!function_exists($_l->blocks["word$name"]['%[a-z0-9]+%'] = '_%[a-z0-9]+%__word_name_')) { function _%[a-z0-9]+%__word_name_($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ;}} call_user_func(reset($_l->blocks["word$name"]), $_l, get_defined_vars()) ?> diff --git a/tests/Nette/Latte/expected/macros.dynamicsnippets.alt.phtml b/tests/Nette/Latte/expected/macros.dynamicsnippets.alt.phtml index f14db75a9c..03a500b184 100644 --- a/tests/Nette/Latte/expected/macros.dynamicsnippets.alt.phtml +++ b/tests/Nette/Latte/expected/macros.dynamicsnippets.alt.phtml @@ -1,12 +1,12 @@ blocks['_outer1'][] = '_xxx__outer1')) { function _xxx__outer1($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl('outer1', FALSE) +if (!function_exists($_l->blocks['_outer1'][] = '_%[a-z0-9]+%__outer1')) { function _%[a-z0-9]+%__outer1($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl('outer1', FALSE) ;$iterations = 0; foreach (array(1,2,3) as $id) { ?> > # @@ -19,7 +19,7 @@ if (!function_exists($_l->blocks['_outer1'][] = '_xxx__outer1')) { function _xxx // // block _outer2 // -if (!function_exists($_l->blocks['_outer2'][] = '_xxx__outer2')) { function _xxx__outer2($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl('outer2', FALSE) +if (!function_exists($_l->blocks['_outer2'][] = '_%[a-z0-9]+%__outer2')) { function _%[a-z0-9]+%__outer2($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl('outer2', FALSE) ;$iterations = 0; foreach (array(1,2,3) as $id) { ?> > # diff --git a/tests/Nette/Latte/expected/macros.dynamicsnippets.phtml b/tests/Nette/Latte/expected/macros.dynamicsnippets.phtml index 0937e20ebf..545bf5637d 100644 --- a/tests/Nette/Latte/expected/macros.dynamicsnippets.phtml +++ b/tests/Nette/Latte/expected/macros.dynamicsnippets.phtml @@ -1,12 +1,12 @@ blocks['_outer'][] = '_xxx__outer')) { function _xxx__outer($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl('outer', FALSE) +if (!function_exists($_l->blocks['_outer'][] = '_%[a-z0-9]+%__outer')) { function _%[a-z0-9]+%__outer($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v; $_control->redrawControl('outer', FALSE) ;$iterations = 0; foreach (array(1,2,3) as $id) { ?>
"> # diff --git a/tests/Nette/Latte/expected/macros.first-sep-last.phtml b/tests/Nette/Latte/expected/macros.first-sep-last.phtml index 4928c9df5c..cc51138da7 100644 --- a/tests/Nette/Latte/expected/macros.first-sep-last.phtml +++ b/tests/Nette/Latte/expected/macros.first-sep-last.phtml @@ -1,6 +1,6 @@ blocks['menu'][] = '_xxx_menu')) { function _xxx_menu($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v +if (!function_exists($_l->blocks['menu'][] = '_%[a-z0-9]+%_menu')) { function _%[a-z0-9]+%_menu($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?>
    its[] = new Nette\Iterators\CachingIterator($menu) as $item) { ?>
  • @@ -20,7 +20,7 @@ if (!function_exists($_l->blocks['menu'][] = '_xxx_menu')) { function _xxx_menu( // // block bl // -if (!function_exists($_l->blocks['bl'][] = '_xxx_bl')) { function _xxx_bl($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v +if (!function_exists($_l->blocks['bl'][] = '_%[a-z0-9]+%_bl')) { function _%[a-z0-9]+%_bl($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?>
    • diff --git a/tests/Nette/Latte/expected/macros.general.xhtml.inc1.phtml b/tests/Nette/Latte/expected/macros.general.xhtml.inc1.phtml index d1ba33a419..612329684e 100644 --- a/tests/Nette/Latte/expected/macros.general.xhtml.inc1.phtml +++ b/tests/Nette/Latte/expected/macros.general.xhtml.inc1.phtml @@ -2,7 +2,7 @@ // -?>

      Included file #1

      - 20) + $template->getParameters(), $_l->templates['xxx'])->render() ?> + 20) + $template->getParameters(), $_l->templates['%[a-z0-9]+%'])->render() ?> -getParameters(), $_l->templates['xxx'])->render() ?> +getParameters(), $_l->templates['%[a-z0-9]+%'])->render() ?>