diff --git a/src/Application/Responses/FileResponse.php b/src/Application/Responses/FileResponse.php index 66dd36f9d..7dbeb4be3 100644 --- a/src/Application/Responses/FileResponse.php +++ b/src/Application/Responses/FileResponse.php @@ -124,7 +124,7 @@ public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $htt $httpResponse->setHeader('Content-Length', $length); while (!feof($handle) && $length > 0) { - echo $s = fread($handle, min(4e6, $length)); + echo $s = fread($handle, min(4000000, $length)); $length -= strlen($s); } fclose($handle); diff --git a/src/Application/Routers/Route.php b/src/Application/Routers/Route.php index 3b7fbdefa..0461256c2 100644 --- a/src/Application/Routers/Route.php +++ b/src/Application/Routers/Route.php @@ -21,6 +21,7 @@ class Route implements Application\IRouter use Nette\SmartObject; const PRESENTER_KEY = 'presenter'; + const MODULE_KEY = 'module'; /** @internal url type */ @@ -30,10 +31,15 @@ class Route implements Application\IRouter /** key used in {@link Route::$styles} or metadata {@link Route::__construct} */ const VALUE = 'value'; + const PATTERN = 'pattern'; + const FILTER_IN = 'filterIn'; + const FILTER_OUT = 'filterOut'; + const FILTER_TABLE = 'filterTable'; + const FILTER_STRICT = 'filterStrict'; /** @internal fixity types - how to handle default value? {@link Route::$metadata} */ diff --git a/src/Application/Routers/SimpleRouter.php b/src/Application/Routers/SimpleRouter.php index 7d052e80b..ecd71e92a 100644 --- a/src/Application/Routers/SimpleRouter.php +++ b/src/Application/Routers/SimpleRouter.php @@ -19,6 +19,7 @@ class SimpleRouter implements Application\IRouter use Nette\SmartObject; const PRESENTER_KEY = 'presenter'; + const MODULE_KEY = 'module'; /** @var string */ diff --git a/src/Application/UI/ComponentReflection.php b/src/Application/UI/ComponentReflection.php index 31145bfa2..8e13bff96 100644 --- a/src/Application/UI/ComponentReflection.php +++ b/src/Application/UI/ComponentReflection.php @@ -248,7 +248,7 @@ public static function parseAnnotation(\Reflector $ref, $name) /** - * @return [string, bool] + * @return array [string|null, bool] */ public static function getParameterType(\ReflectionParameter $param) { diff --git a/src/Bridges/ApplicationLatte/Template.php b/src/Bridges/ApplicationLatte/Template.php index dd4b56d40..37383678c 100644 --- a/src/Bridges/ApplicationLatte/Template.php +++ b/src/Bridges/ApplicationLatte/Template.php @@ -53,6 +53,16 @@ public function render($file = null, array $params = []) } + /** + * Renders template to output. + * @return string + */ + public function renderToString($file = null, array $params = []) + { + return $this->latte->renderToString($file ?: $this->file, $params + $this->params); + } + + /** * Renders template to string. * @param can throw exceptions? (hidden parameter) diff --git a/tests/Bridges.DI/LatteExtension.basic.phpt b/tests/Bridges.DI/LatteExtension.basic.phpt index 518ec201b..7d69f1251 100644 --- a/tests/Bridges.DI/LatteExtension.basic.phpt +++ b/tests/Bridges.DI/LatteExtension.basic.phpt @@ -46,7 +46,6 @@ class FooMacros extends Latte\Macros\MacroSet class NonStaticMacrosFactory { - /** @var string */ private $parameter; diff --git a/tests/Responses/FileResponse.full.phpt b/tests/Responses/FileResponse.full.phpt index 364733695..a89808f6d 100644 --- a/tests/Responses/FileResponse.full.phpt +++ b/tests/Responses/FileResponse.full.phpt @@ -12,6 +12,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; +/* A small file */ test(function () { $file = __FILE__; $fileResponse = new FileResponse($file); @@ -21,3 +22,22 @@ test(function () { $fileResponse->send(new Http\Request(new Http\UrlScript), new Http\Response); Assert::same($origData, ob_get_clean()); }); + +/* A big file */ +test(function () { + $file = Tester\FileMock::create(); + + $data = ''; + for ($i = 0; $i < 20000; $i++) { + $data .= 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi efficitur nisl mauris, ' . + 'sed bibendum leo tempor ornare. Etiam sodales enim sem. Proin lobortis metus at sagittis ' . + 'imperdiet. In non fringilla libero, ac porta purus. Nam gravida quis tellus quis semper.'; + } + + file_put_contents($file, $data); + $fileResponse = new FileResponse($file); + + ob_start(); + $fileResponse->send(new Http\Request(new Http\UrlScript), new Http\Response); + Assert::same($data, ob_get_clean()); +}); diff --git a/tests/UI/Presenter.storeRequest().phpt b/tests/UI/Presenter.storeRequest().phpt index 900f55433..a6ea51b66 100644 --- a/tests/UI/Presenter.storeRequest().phpt +++ b/tests/UI/Presenter.storeRequest().phpt @@ -39,9 +39,13 @@ class MockSession extends Http\Session class MockSessionSection implements \ArrayAccess { public $testedKeyExistence; + public $storedKey; + public $storedValue; + public $testExpiration; + public $testExpirationVariables;