diff --git a/src/Http/RequestFactory.php b/src/Http/RequestFactory.php index f44490e7..4dc78463 100644 --- a/src/Http/RequestFactory.php +++ b/src/Http/RequestFactory.php @@ -70,7 +70,7 @@ public function fromGlobals(): Request $this->getMethod(), $remoteAddr, $remoteHost, - fn(): string => file_get_contents('php://input') + fn(): string => file_get_contents('php://input'), ); } diff --git a/src/Http/Url.php b/src/Http/Url.php index de9860f0..447f5e63 100644 --- a/src/Http/Url.php +++ b/src/Http/Url.php @@ -100,6 +100,7 @@ public function getScheme(): string } + /** @deprecated */ public function setUser(string $user): static { $this->user = $user; @@ -107,12 +108,14 @@ public function setUser(string $user): static } + /** @deprecated */ public function getUser(): string { return $this->user; } + /** @deprecated */ public function setPassword(string $password): static { $this->password = $password; @@ -120,6 +123,7 @@ public function setPassword(string $password): static } + /** @deprecated */ public function getPassword(): string { return $this->password; diff --git a/src/Http/UrlImmutable.php b/src/Http/UrlImmutable.php index 9702135f..aa8e9992 100644 --- a/src/Http/UrlImmutable.php +++ b/src/Http/UrlImmutable.php @@ -78,6 +78,7 @@ public function getScheme(): string } + /** @deprecated */ public function withUser(string $user): static { $dolly = clone $this; @@ -87,12 +88,14 @@ public function withUser(string $user): static } + /** @deprecated */ public function getUser(): string { return $this->user; } + /** @deprecated */ public function withPassword(string $password): static { $dolly = clone $this; @@ -102,12 +105,14 @@ public function withPassword(string $password): static } + /** @deprecated */ public function getPassword(): string { return $this->password; } + /** @deprecated */ public function withoutUserInfo(): static { $dolly = clone $this; diff --git a/src/Http/UserStorage.php b/src/Http/UserStorage.php index bbcebfb8..ea70baeb 100644 --- a/src/Http/UserStorage.php +++ b/src/Http/UserStorage.php @@ -22,7 +22,7 @@ class UserStorage implements Nette\Security\IUserStorage private string $namespace = ''; - private SessionSection $sessionSection; + private ?SessionSection $sessionSection = null; public function __construct( diff --git a/tests/Http.DI/HttpExtension.cookie.phpt b/tests/Http.DI/HttpExtension.cookie.phpt index 3635d81a..bfaa6823 100644 --- a/tests/Http.DI/HttpExtension.cookie.phpt +++ b/tests/Http.DI/HttpExtension.cookie.phpt @@ -10,7 +10,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('cookiePath & cookieDomain', function () { +test('cookie path and domain configuration', function () { $compiler = new DI\Compiler; $compiler->addExtension('http', new HttpExtension); $compiler->addExtension('session', new SessionExtension(false, PHP_SAPI === 'cli')); @@ -30,7 +30,7 @@ test('cookiePath & cookieDomain', function () { }); -test('cookieDomain = domain', function () { +test('cookie domain normalization based on request host', function () { $compiler = new DI\Compiler; $compiler->addExtension('http', new HttpExtension); $compiler->addExtension('session', new SessionExtension(false, PHP_SAPI === 'cli')); diff --git a/tests/Http.DI/HttpExtension.cookieSecure.phpt b/tests/Http.DI/HttpExtension.cookieSecure.phpt index 106ffc49..191051c3 100644 --- a/tests/Http.DI/HttpExtension.cookieSecure.phpt +++ b/tests/Http.DI/HttpExtension.cookieSecure.phpt @@ -10,7 +10,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('cookie secure flag disabled', function () { $compiler = new DI\Compiler; $compiler->addExtension('http', new HttpExtension); $compiler->addExtension('session', new SessionExtension(false, PHP_SAPI === 'cli')); @@ -30,7 +30,7 @@ test('', function () { }); -test('', function () { +test('cookie secure flag enabled', function () { $compiler = new DI\Compiler; $compiler->addExtension('http', new HttpExtension); $compiler->addExtension('session', new SessionExtension(false, PHP_SAPI === 'cli')); @@ -50,7 +50,7 @@ test('', function () { }); -test('', function () { +test('auto cookie secure flag based on HTTPS', function () { $compiler = new DI\Compiler; $compiler->addExtension('http', new HttpExtension); $compiler->addExtension('session', new SessionExtension(false, PHP_SAPI === 'cli')); diff --git a/tests/Http/FileUpload.basic.phpt b/tests/Http/FileUpload.basic.phpt index acce33f4..ec9157e4 100644 --- a/tests/Http/FileUpload.basic.phpt +++ b/tests/Http/FileUpload.basic.phpt @@ -12,7 +12,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('basic upload properties', function () { $upload = new FileUpload([ 'name' => 'readme.txt', 'full_path' => 'path/to/readme.txt', @@ -38,7 +38,7 @@ test('', function () { }); -test('', function () { +test('sanitizing name with image detection', function () { $upload = new FileUpload([ 'name' => '../.image.png', 'type' => 'text/plain', @@ -57,7 +57,7 @@ test('', function () { }); -test('', function () { +test('no file uploaded', function () { $upload = new FileUpload([ 'name' => '', 'type' => '', @@ -75,7 +75,7 @@ test('', function () { }); -test('', function () { +test('empty upload data', function () { $upload = new FileUpload([]); Assert::false($upload->isOk()); @@ -87,7 +87,7 @@ test('', function () { }); -test('', function () { +test('upload from file path', function () { $upload = new FileUpload($file = __DIR__ . '/files/file.txt'); Assert::same('file.txt', $upload->getName()); diff --git a/tests/Http/FileUpload.getSanitizedName.phpt b/tests/Http/FileUpload.getSanitizedName.phpt index 2245a101..c4a3a459 100644 --- a/tests/Http/FileUpload.getSanitizedName.phpt +++ b/tests/Http/FileUpload.getSanitizedName.phpt @@ -23,7 +23,7 @@ function getSanitizedName(string $name, ?string $type = null): string } -test('name', function () { +test('sanitized name without MIME', function () { Assert::same('unknown', getSanitizedName('')); Assert::same('unknown', getSanitizedName('--')); Assert::same('foo', getSanitizedName('foo')); @@ -36,7 +36,7 @@ test('name', function () { }); -test('name & extension', function () { +test('sanitized name with PDF type', function () { Assert::same('unknown', getSanitizedName('', 'application/pdf')); Assert::same('unknown', getSanitizedName('--', 'application/pdf')); Assert::same('foo', getSanitizedName('foo', 'application/pdf')); @@ -46,7 +46,7 @@ test('name & extension', function () { }); -test('image name & extension', function () { +test('sanitized name with JPEG type', function () { Assert::same('unknown.jpeg', getSanitizedName('', 'image/jpeg')); Assert::same('unknown.jpeg', getSanitizedName('--', 'image/jpeg')); Assert::same('foo.jpeg', getSanitizedName('foo', 'image/jpeg')); diff --git a/tests/Http/Helpers.phpt b/tests/Http/Helpers.phpt index 87b1a4dd..cf844fa6 100644 --- a/tests/Http/Helpers.phpt +++ b/tests/Http/Helpers.phpt @@ -12,7 +12,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('IPv4 address matching', function () { Assert::true(Helpers::ipMatch('192.168.68.233', '192.168.68.233')); Assert::false(Helpers::ipMatch('192.168.68.234', '192.168.68.233')); Assert::true(Helpers::ipMatch('192.168.64.0', '192.168.68.233/20')); @@ -27,7 +27,7 @@ test('', function () { -test('', function () { +test('IPv6 address matching', function () { Assert::true(Helpers::ipMatch('2001:db8:0:0:0:0:0:0', '2001:db8::')); Assert::false(Helpers::ipMatch('2001:db8:0:0:0:0:0:0', '2002:db8::')); Assert::false(Helpers::ipMatch('2001:db8:0:0:0:0:0:1', '2001:db8::')); @@ -40,7 +40,7 @@ test('', function () { -test('', function () { +test('date formatting', function () { Assert::same('Tue, 15 Nov 1994 08:12:31 GMT', Helpers::formatDate('1994-11-15T08:12:31+0000')); Assert::same('Tue, 15 Nov 1994 08:12:31 GMT', Helpers::formatDate('1994-11-15T10:12:31+0200')); Assert::same('Tue, 15 Nov 1994 08:12:31 GMT', Helpers::formatDate(new DateTime('1994-11-15T06:12:31-0200'))); diff --git a/tests/Http/Request.detectLanguage.phpt b/tests/Http/Request.detectLanguage.phpt index c1dea634..3e3e79c2 100644 --- a/tests/Http/Request.detectLanguage.phpt +++ b/tests/Http/Request.detectLanguage.phpt @@ -12,7 +12,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('basic language preference', function () { $headers = ['Accept-Language' => 'en, cs']; $request = new Http\Request(new Http\UrlScript, headers: $headers); @@ -22,7 +22,7 @@ test('', function () { }); -test('', function () { +test('language with quality weights', function () { $headers = ['Accept-Language' => 'da, en-gb;q=0.8, en;q=0.7']; $request = new Http\Request(new Http\UrlScript, headers: $headers); @@ -31,7 +31,7 @@ test('', function () { }); -test('', function () { +test('no Accept-Language header', function () { $headers = []; $request = new Http\Request(new Http\UrlScript, headers: $headers); @@ -39,7 +39,7 @@ test('', function () { }); -test('', function () { +test('invalid Accept-Language header', function () { $headers = ['Accept-Language' => 'garbage']; $request = new Http\Request(new Http\UrlScript, headers: $headers); diff --git a/tests/Http/Request.files.directory.phpt b/tests/Http/Request.files.directory.phpt index 366c105a..d13db65f 100644 --- a/tests/Http/Request.files.directory.phpt +++ b/tests/Http/Request.files.directory.phpt @@ -19,7 +19,7 @@ $_FILES = [ 'name' => ['a.jpg', 'c.jpg'], 'type' => ['image/jpeg', 'image/jpeg'], 'full_path' => ['a.jpg', 'b/c.jpg'], - 'tmp_name' => ['C:\\PHP\\temp\\php1D5D.tmp', 'C:\\PHP\\temp\\php1D5E.tmp'], + 'tmp_name' => ['C:\PHP\temp\php1D5D.tmp', 'C:\PHP\temp\php1D5E.tmp'], 'error' => [0, 0], 'size' => [12345, 54321], ], diff --git a/tests/Http/Request.files.phpt b/tests/Http/Request.files.phpt index b369ead4..d2ee3405 100644 --- a/tests/Http/Request.files.phpt +++ b/tests/Http/Request.files.phpt @@ -17,7 +17,7 @@ $_FILES = [ 'file1' => [ 'name' => 'readme.txt', 'type' => 'text/plain', - 'tmp_name' => 'C:\\PHP\\temp\\php1D5B.tmp', + 'tmp_name' => 'C:\PHP\temp\php1D5B.tmp', 'error' => 0, 'size' => 209, ], @@ -32,7 +32,7 @@ $_FILES = [ ], 'tmp_name' => [ - 2 => 'C:\\PHP\\temp\\php1D5C.tmp', + 2 => 'C:\PHP\temp\php1D5C.tmp', ], 'error' => [ @@ -61,9 +61,9 @@ $_FILES = [ 'tmp_name' => [ 'y' => [ - 'z' => 'C:\\PHP\\temp\\php1D5D.tmp', + 'z' => 'C:\PHP\temp\php1D5D.tmp', ], - 1 => 'C:\\PHP\\temp\\php1D5E.tmp', + 1 => 'C:\PHP\temp\php1D5E.tmp', ], 'error' => [ diff --git a/tests/Http/Request.files2.phpt b/tests/Http/Request.files2.phpt index b4024960..b7d86458 100644 --- a/tests/Http/Request.files2.phpt +++ b/tests/Http/Request.files2.phpt @@ -17,7 +17,7 @@ $_FILES = [ 'files' => [ 'name' => ['1a.jpg'], 'type' => ['image/jpeg'], - 'tmp_name' => ['C:\\PHP\\temp\\php1D5D.tmp'], + 'tmp_name' => ['C:\PHP\temp\php1D5D.tmp'], 'error' => [0], 'size' => [12345], ], diff --git a/tests/Http/Request.getOrigin.phpt b/tests/Http/Request.getOrigin.phpt index febebb89..65bdf535 100644 --- a/tests/Http/Request.getOrigin.phpt +++ b/tests/Http/Request.getOrigin.phpt @@ -9,13 +9,13 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('missing origin', function () { +test('no Origin header', function () { $request = new Http\Request(new Http\UrlScript); Assert::null($request->getOrigin()); }); -test('opaque origin', function () { +test('origin header \'null\'', function () { $request = new Http\Request(new Http\UrlScript, headers: [ 'Origin' => 'null', ]); @@ -23,7 +23,7 @@ test('opaque origin', function () { }); -test('normal origin', function () { +test('valid Origin header', function () { $request = new Http\Request(new Http\UrlScript, headers: [ 'Origin' => 'https://nette.org', ]); diff --git a/tests/Http/Request.getRawBody.phpt b/tests/Http/Request.getRawBody.phpt index 9d2f556f..76796de7 100644 --- a/tests/Http/Request.getRawBody.phpt +++ b/tests/Http/Request.getRawBody.phpt @@ -12,14 +12,14 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('raw body retrieval with callback', function () { $request = new Http\Request(new Http\UrlScript, rawBodyCallback: fn() => 'raw body'); Assert::same('raw body', $request->getRawBody()); }); -test('', function () { +test('raw body absence without callback', function () { $request = new Http\Request(new Http\UrlScript); Assert::null($request->getRawBody()); diff --git a/tests/Http/Request.headers.phpt b/tests/Http/Request.headers.phpt index 7c607151..39b97482 100644 --- a/tests/Http/Request.headers.phpt +++ b/tests/Http/Request.headers.phpt @@ -12,17 +12,17 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('empty headers by default', function () { $request = new Http\Request(new Http\UrlScript); Assert::same([], $request->getHeaders()); }); -test('', function () { +test('headers initialization without parameters', function () { $request = new Http\Request(new Http\UrlScript); Assert::same([], $request->getHeaders()); }); -test('', function () { +test('header normalization and case insensitivity', function () { $request = new Http\Request(new Http\UrlScript, headers: [ 'one' => '1', 'TWO' => '2', diff --git a/tests/Http/Request.invalidEncoding.phpt b/tests/Http/Request.invalidEncoding.phpt index 96410a3f..8d05275d 100644 --- a/tests/Http/Request.invalidEncoding.phpt +++ b/tests/Http/Request.invalidEncoding.phpt @@ -44,27 +44,27 @@ $_FILES = [ INVALID => [ 'name' => 'readme.txt', 'type' => 'text/plain', - 'tmp_name' => 'C:\\PHP\\temp\\php1D5B.tmp', + 'tmp_name' => 'C:\PHP\temp\php1D5B.tmp', 'error' => 0, 'size' => 209, ], CONTROL_CHARACTERS => [ 'name' => 'readme.txt', 'type' => 'text/plain', - 'tmp_name' => 'C:\\PHP\\temp\\php1D5B.tmp', + 'tmp_name' => 'C:\PHP\temp\php1D5B.tmp', 'error' => 0, 'size' => 209, ], 'file1' => [ 'name' => INVALID, 'type' => 'text/plain', - 'tmp_name' => 'C:\\PHP\\temp\\php1D5B.tmp', + 'tmp_name' => 'C:\PHP\temp\php1D5B.tmp', 'error' => 0, 'size' => 209, ], ]; -test('unfiltered data', function () { +test('binary data preservation with invalid encoding', function () { $factory = new Http\RequestFactory; $factory->setBinary(); $request = $factory->fromGlobals(); @@ -93,7 +93,7 @@ test('unfiltered data', function () { }); -test('filtered data', function () { +test('invalid encoding sanitization by default', function () { $factory = new Http\RequestFactory; $request = $factory->fromGlobals(); diff --git a/tests/Http/Request.invalidType.phpt b/tests/Http/Request.invalidType.phpt index 68875dca..b02d6169 100644 --- a/tests/Http/Request.invalidType.phpt +++ b/tests/Http/Request.invalidType.phpt @@ -12,7 +12,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('invalid POST', function () { +test('non-string type in POST data', function () { $_POST = [ 'int' => 1, ]; @@ -25,7 +25,7 @@ test('invalid POST', function () { }); -test('invalid COOKIE', function () { +test('non-string type in cookie array', function () { $_POST = []; $_COOKIE = ['x' => [1]]; diff --git a/tests/Http/Request.manipulation.phpt b/tests/Http/Request.manipulation.phpt index 7db214d6..ffee403a 100644 --- a/tests/Http/Request.manipulation.phpt +++ b/tests/Http/Request.manipulation.phpt @@ -8,7 +8,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('URL modification and query synchronization', function () { $url = new Http\UrlScript('http://nette.org/?arg=hello'); $request = new Http\Request($url); diff --git a/tests/Http/Request.request.phpt b/tests/Http/Request.request.phpt index d51e7e07..a86b5d73 100644 --- a/tests/Http/Request.request.phpt +++ b/tests/Http/Request.request.phpt @@ -19,11 +19,11 @@ $_SERVER = [ 'QUERY_STRING' => 'x param=val.&pa%%72am=val2¶m3=v%20a%26l%3Du%2Be)', 'REMOTE_ADDR' => '192.168.188.66', 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/file.php?x param=val.&pa%%72am=val2"es\\"=\\"¶m3=v%20a%26l%3Du%2Be)', + 'REQUEST_URI' => '/file.php?x param=val.&pa%%72am=val2"es\"=\"¶m3=v%20a%26l%3Du%2Be)', 'SCRIPT_NAME' => '/file.php', ]; -test('', function () { +test('URL parsing with custom filters', function () { $factory = new Http\RequestFactory; $factory->urlFilters['path'] = ['#%20#' => '']; $factory->urlFilters['url'] = ['#[.,)]\z#' => '']; @@ -54,7 +54,7 @@ test('', function () { }); -test('', function () { +test('URL components with special characters', function () { $factory = new Http\RequestFactory; $factory->urlFilters['path'] = []; $factory->urlFilters['url'] = []; diff --git a/tests/Http/RequestFactory.authorization.phpt b/tests/Http/RequestFactory.authorization.phpt index 7ddbb6d4..39316615 100644 --- a/tests/Http/RequestFactory.authorization.phpt +++ b/tests/Http/RequestFactory.authorization.phpt @@ -12,7 +12,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('Basic', function () { +test('basic authentication via PHP_AUTH_* variables', function () { $_SERVER = [ 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'password', @@ -32,7 +32,7 @@ test('Basic', function () { -test('Digest', function () { +test('digest authentication header parsing', function () { $_SERVER = [ 'PHP_AUTH_DIGEST' => 'username="admin"', ]; @@ -47,7 +47,7 @@ test('Digest', function () { }); -test('empty', function () { +test('absence of authentication headers', function () { $_SERVER = []; $factory = new RequestFactory; $request = $factory->fromGlobals(); diff --git a/tests/Http/RequestFactory.proxy.forwarded.phpt b/tests/Http/RequestFactory.proxy.forwarded.phpt index 3805db12..30f9df86 100644 --- a/tests/Http/RequestFactory.proxy.forwarded.phpt +++ b/tests/Http/RequestFactory.proxy.forwarded.phpt @@ -11,7 +11,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('forwarded header handling with proxy', function () { $_SERVER = [ 'REMOTE_ADDR' => '127.0.0.3', 'REMOTE_HOST' => 'localhost', @@ -32,7 +32,7 @@ test('', function () { Assert::same('192.168.0.1', $url->getHost()); }); -test('', function () { +test('forwarded header with port numbers', function () { $_SERVER = [ 'REMOTE_ADDR' => '127.0.0.3', 'REMOTE_HOST' => 'localhost', @@ -51,7 +51,7 @@ test('', function () { }); -test('', function () { +test('IPv6 addresses in Forwarded header', function () { $_SERVER = [ 'REMOTE_ADDR' => '127.0.0.3', 'REMOTE_HOST' => 'localhost', @@ -68,7 +68,7 @@ test('', function () { Assert::same('[2001:db8:cafe::18]', $url->getHost()); }); -test('', function () { +test('IPv6 addresses and ports in Forwarded header', function () { $_SERVER = [ 'REMOTE_ADDR' => '127.0.0.3', 'REMOTE_HOST' => 'localhost', @@ -87,7 +87,7 @@ test('', function () { }); -test('', function () { +test('forwarded protocol (HTTPS) handling', function () { $_SERVER = [ 'REMOTE_ADDR' => '127.0.0.3', 'REMOTE_HOST' => 'localhost', diff --git a/tests/Http/RequestFactory.proxy.x-forwarded.phpt b/tests/Http/RequestFactory.proxy.x-forwarded.phpt index 7b3fa87b..58dca049 100644 --- a/tests/Http/RequestFactory.proxy.x-forwarded.phpt +++ b/tests/Http/RequestFactory.proxy.x-forwarded.phpt @@ -12,7 +12,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('X-Forwarded headers handling with proxy', function () { $_SERVER = [ 'REMOTE_ADDR' => '127.0.0.3', 'REMOTE_HOST' => 'localhost', @@ -34,7 +34,7 @@ test('', function () { Assert::same(80, $url->getPort()); }); -test('', function () { +test('X-Forwarded-Host with port', function () { $_SERVER = [ 'REMOTE_ADDR' => '127.0.0.3', 'REMOTE_HOST' => 'localhost', @@ -52,7 +52,7 @@ test('', function () { Assert::same(8080, $url->getPort()); }); -test('', function () { +test('X-Forwarded protocol and port', function () { $_SERVER = [ 'REMOTE_ADDR' => '127.0.0.3', 'HTTP_X_FORWARDED_FOR' => '23.75.45.200', @@ -70,7 +70,7 @@ test('', function () { Assert::same(8080, $url->getPort()); }); -test('', function () { +test('multiple proxies in X-Forwarded headers', function () { $_SERVER = [ 'REMOTE_ADDR' => '10.0.0.2', //proxy2 'REMOTE_HOST' => 'proxy2', @@ -96,7 +96,7 @@ test('', function () { Assert::same(80, $url->getPort()); }); -test('', function () { +test('X-Forwarded-Host with multiple entries and port', function () { $_SERVER = [ 'REMOTE_ADDR' => '10.0.0.2', //proxy2 'REMOTE_HOST' => 'proxy2', diff --git a/tests/Http/RequestFactory.query.phpt b/tests/Http/RequestFactory.query.phpt index 5d19df5e..5ab60f87 100644 --- a/tests/Http/RequestFactory.query.phpt +++ b/tests/Http/RequestFactory.query.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; $factory = new RequestFactory; -test('', function () use ($factory) { +test('base URL without query parameters', function () use ($factory) { $_SERVER = [ 'HTTP_HOST' => 'nette.org', 'REQUEST_URI' => '/', @@ -24,7 +24,7 @@ test('', function () use ($factory) { }); -test('', function () use ($factory) { +test('URL with query parameters', function () use ($factory) { $_SERVER = [ 'HTTP_HOST' => 'nette.org', 'REQUEST_URI' => '/?a=b', diff --git a/tests/Http/RequestFactory.scriptPath.phpt b/tests/Http/RequestFactory.scriptPath.phpt index 93a6896a..0c9c371e 100644 --- a/tests/Http/RequestFactory.scriptPath.phpt +++ b/tests/Http/RequestFactory.scriptPath.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; $factory = new RequestFactory; -test('', function () use ($factory) { +test('script path detection from REQUEST_URI and SCRIPT_NAME', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/projects/modules-usage/www/', 'SCRIPT_NAME' => '/projects/modules-usage/www/index.php', @@ -24,7 +24,7 @@ test('', function () use ($factory) { }); -test('', function () use ($factory) { +test('URL-encoded path normalization in script path', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/projects/modules-usage/%77%77%77/', 'SCRIPT_NAME' => '/projects/modules-usage/www/index.php', @@ -34,7 +34,7 @@ test('', function () use ($factory) { }); -test('', function () use ($factory) { +test('nested path detection with script in subdirectory', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/projects/modules-usage/www/default/add-item', 'SCRIPT_NAME' => '/projects/modules-usage/www/index.php', @@ -44,7 +44,7 @@ test('', function () use ($factory) { }); -test('', function () use ($factory) { +test('script path when REQUEST_URI matches SCRIPT_NAME exactly', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/www/index.php', 'SCRIPT_NAME' => '/www/index.php', @@ -54,7 +54,7 @@ test('', function () use ($factory) { }); -test('', function () use ($factory) { +test('directory-like SCRIPT_NAME handling', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/www/', 'SCRIPT_NAME' => '/www/', @@ -64,7 +64,7 @@ test('', function () use ($factory) { }); -test('', function () use ($factory) { +test('path truncation to script directory', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/test/in', 'SCRIPT_NAME' => '/test/index.php', @@ -74,7 +74,7 @@ test('', function () use ($factory) { }); -test('', function () use ($factory) { +test('double slash normalization in script path', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/test//', 'SCRIPT_NAME' => '/test/index.php', @@ -84,7 +84,7 @@ test('', function () use ($factory) { }); -test('http://forum.nette.org/cs/5932-lepsi-detekce-requesturi-a-scriptpath', function () use ($factory) { +test('exact match of REQUEST_URI and SCRIPT_NAME as directory', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/sign/in/', 'SCRIPT_NAME' => '/sign/in/', @@ -94,7 +94,7 @@ test('http://forum.nette.org/cs/5932-lepsi-detekce-requesturi-a-scriptpath', fun }); -test('http://forum.nette.org/cs/9139-spatny-urlscript-scriptpath', function () use ($factory) { +test('mismatched directory levels between URI and script', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/configuration/', 'SCRIPT_NAME' => '/configuration/www/index.php', @@ -104,7 +104,7 @@ test('http://forum.nette.org/cs/9139-spatny-urlscript-scriptpath', function () u }); -test('', function () use ($factory) { +test('case sensitivity in script path components', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/blog/WWW/', 'SCRIPT_NAME' => '/blog/www/index.php', @@ -114,27 +114,27 @@ test('', function () use ($factory) { }); -test('', function () use ($factory) { +test('Windows-style SCRIPT_NAME handling', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/', - 'SCRIPT_NAME' => 'c:\\index.php', + 'SCRIPT_NAME' => 'c:\index.php', ]; Assert::same('/', $factory->fromGlobals()->getUrl()->getScriptPath()); }); -test('', function () use ($factory) { +test('missing REQUEST_URI fallback', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => null, - 'SCRIPT_NAME' => 'c:\\index.php', + 'SCRIPT_NAME' => 'c:\index.php', ]; Assert::same('/', $factory->fromGlobals()->getUrl()->getScriptPath()); }); -test('', function () use ($factory) { +test('missing SCRIPT_NAME fallback', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/', 'SCRIPT_NAME' => null, @@ -144,7 +144,7 @@ test('', function () use ($factory) { }); -test('', function () use ($factory) { +test('complete absence of URI and script data', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => null, 'SCRIPT_NAME' => null, @@ -153,7 +153,7 @@ test('', function () use ($factory) { Assert::same('/', $factory->fromGlobals()->getUrl()->getScriptPath()); }); -test('', function () use ($factory) { +test('root script path detection with deep URI', function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/documents/show/5474', 'SCRIPT_NAME' => '/index.php', diff --git a/tests/Http/SessionSection.setExpiration().phpt b/tests/Http/SessionSection.setExpiration().phpt index 0328ad3b..9200cd73 100644 --- a/tests/Http/SessionSection.setExpiration().phpt +++ b/tests/Http/SessionSection.setExpiration().phpt @@ -16,7 +16,7 @@ $session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Net $session->setExpiration('+10 seconds'); -test('try to expire whole namespace', function () use ($session) { +test('global expiration of entire session section', function () use ($session) { $namespace = $session->getSection('expire'); $namespace->set('a', 'apple'); $namespace->set('p', 'pear'); @@ -31,7 +31,7 @@ test('try to expire whole namespace', function () use ($session) { }); -test('try to expire only 1 of the keys', function () use ($session) { +test('individual key expiration in session section', function () use ($session) { $namespace = $session->getSection('expireSingle'); $namespace->setExpiration('1 second', 'g'); $namespace->set('g', 'guava'); diff --git a/tests/Http/Url.fileScheme.phpt b/tests/Http/Url.fileScheme.phpt index 518d247b..abc1e2ba 100644 --- a/tests/Http/Url.fileScheme.phpt +++ b/tests/Http/Url.fileScheme.phpt @@ -12,7 +12,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('file URL parsing with explicit host', function () { $url = new Url('file://localhost/D:/dokumentace/rfc3986.txt'); Assert::same('file://localhost/D:/dokumentace/rfc3986.txt', (string) $url); Assert::same('file', $url->scheme); @@ -26,7 +26,7 @@ test('', function () { }); -test('', function () { +test('file URL parsing without host (local path)', function () { $url = new Url('file:///D:/dokumentace/rfc3986.txt'); Assert::same('file:D:/dokumentace/rfc3986.txt', (string) $url); Assert::same('file', $url->scheme); diff --git a/tests/Http/Url.removeDotSegments.phpt b/tests/Http/Url.removeDotSegments.phpt index 37da2c83..83d5fabc 100644 --- a/tests/Http/Url.removeDotSegments.phpt +++ b/tests/Http/Url.removeDotSegments.phpt @@ -8,7 +8,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('begins with /', function () { +test('dot segment removal in absolute paths', function () { Assert::same('/', Url::removeDotSegments('/')); Assert::same('/file', Url::removeDotSegments('/file')); Assert::same('/file/', Url::removeDotSegments('/file/')); @@ -23,7 +23,7 @@ test('begins with /', function () { }); -test('not begins with /', function () { +test('dot segment removal in relative paths', function () { Assert::same('', Url::removeDotSegments('')); Assert::same('file', Url::removeDotSegments('file')); Assert::same('file/', Url::removeDotSegments('file/')); @@ -38,7 +38,7 @@ test('not begins with /', function () { }); -test('incorrect ..', function () { +test('excessive parent directory traversal handling', function () { Assert::same('/', Url::removeDotSegments('/file/../..')); Assert::same('/', Url::removeDotSegments('/file/../../')); Assert::same('/bar', Url::removeDotSegments('/file/../../bar')); @@ -48,7 +48,7 @@ test('incorrect ..', function () { }); -test('double slash', function () { +test('double slash preservation', function () { Assert::same('//', Url::removeDotSegments('//')); Assert::same('//foo//', Url::removeDotSegments('//foo//')); Assert::same('//foo//', Url::removeDotSegments('//foo//..//')); diff --git a/tests/Http/UrlImmutable.manipulation.phpt b/tests/Http/UrlImmutable.manipulation.phpt index 06d66c41..4e36a7e7 100644 --- a/tests/Http/UrlImmutable.manipulation.phpt +++ b/tests/Http/UrlImmutable.manipulation.phpt @@ -8,7 +8,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('immutable URL component modifications', function () { $url = new UrlImmutable('http://username%3A:password%3A@hostn%61me:60/p%61th/script.php?%61rg=value#%61nchor'); $url = $url->withScheme(''); @@ -34,7 +34,7 @@ test('', function () { }); -test('', function () { +test('path manipulation in immutable URL', function () { $url = new UrlImmutable('http://username%3A:password%3A@hostn%61me:60/p%61th/script.php?%61rg=value#%61nchor'); $url = $url->withPath(''); @@ -60,7 +60,7 @@ test('', function () { }); -test('', function () { +test('query parameter replacement and removal', function () { $url = new UrlImmutable('http://hostname/path?arg=value'); Assert::same('arg=value', $url->query); @@ -78,7 +78,7 @@ test('', function () { }); -test('', function () { +test('individual query parameter manipulation', function () { $url = new UrlImmutable('http://hostname/path?arg=value'); Assert::same('arg=value', $url->query); diff --git a/tests/Http/UrlScript.manipulation.phpt b/tests/Http/UrlScript.manipulation.phpt index 11c098fa..94d9c001 100644 --- a/tests/Http/UrlScript.manipulation.phpt +++ b/tests/Http/UrlScript.manipulation.phpt @@ -8,7 +8,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('base and script path adjustments', function () { $url = new UrlScript('http://nette.org:8080/test/?q=search', '/test/index.php'); Assert::same('/test/', $url->basePath); Assert::same('/test/index.php', $url->scriptPath); diff --git a/tests/Http/UrlScript.usage.phpt b/tests/Http/UrlScript.usage.phpt index 8283c8a7..ce3db669 100644 --- a/tests/Http/UrlScript.usage.phpt +++ b/tests/Http/UrlScript.usage.phpt @@ -12,7 +12,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test('', function () { +test('script path detection in root directory', function () { $url = new UrlScript('http://nette.org:8080/file.php?q=search'); Assert::same('/file.php', $url->scriptPath); Assert::same('http://nette.org:8080/', $url->baseUrl); @@ -23,7 +23,7 @@ test('', function () { }); -test('', function () { +test('script path as root directory', function () { $url = new UrlScript('http://nette.org:8080/file.php?q=search', '/'); Assert::same('/', $url->scriptPath); Assert::same('http://nette.org:8080/', $url->baseUrl); @@ -34,7 +34,7 @@ test('', function () { }); -test('', function () { +test('subdirectory script path and URL components', function () { $url = new UrlScript('http://nette.org:8080/test/?q=search', '/test/index.php'); Assert::same('/test/index.php', $url->scriptPath); Assert::same('http://nette.org:8080/test/', $url->baseUrl); @@ -46,7 +46,7 @@ test('', function () { }); -test('', function () { +test('directory-based script path handling', function () { $url = new UrlScript('http://nette.org:8080/www/about', '/www/'); Assert::same('/www/about', $url->path); Assert::same('/www/', $url->scriptPath); @@ -55,7 +55,7 @@ test('', function () { }); -test('', function () { +test('exact script path match', function () { $url = new UrlScript('http://nette.org:8080/www/index.php', '/www/index.php'); Assert::same('/www/index.php', $url->path); Assert::same('/www/index.php', $url->scriptPath); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f1ff2142..f70c927f 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -19,9 +19,9 @@ function getTempDir(): string { $dir = __DIR__ . '/tmp/' . getmypid(); - if (empty($GLOBALS['\\lock'])) { + if (empty($GLOBALS['\lock'])) { // garbage collector - $GLOBALS['\\lock'] = $lock = fopen(__DIR__ . '/lock', 'w'); + $GLOBALS['\lock'] = $lock = fopen(__DIR__ . '/lock', 'w'); if (rand(0, 100)) { flock($lock, LOCK_SH); @mkdir(dirname($dir));