diff --git a/src/Bridges/HttpDI/SessionExtension.php b/src/Bridges/HttpDI/SessionExtension.php index fe2c334f..6b2656e1 100644 --- a/src/Bridges/HttpDI/SessionExtension.php +++ b/src/Bridges/HttpDI/SessionExtension.php @@ -48,7 +48,7 @@ public function loadConfiguration() if ($this->debugMode && $config['debugger']) { $session->addSetup('@Tracy\Bar::addPanel', [ - new Nette\DI\Statement('Nette\Bridges\HttpTracy\SessionPanel') + new Nette\DI\Statement('Nette\Bridges\HttpTracy\SessionPanel'), ]); } diff --git a/src/Http/IResponse.php b/src/Http/IResponse.php index a3c7eecd..2b002317 100644 --- a/src/Http/IResponse.php +++ b/src/Http/IResponse.php @@ -41,7 +41,7 @@ interface IResponse S303_POST_GET = 303, S304_NOT_MODIFIED = 304, S305_USE_PROXY = 305, - S307_TEMPORARY_REDIRECT= 307, + S307_TEMPORARY_REDIRECT = 307, S400_BAD_REQUEST = 400, S401_UNAUTHORIZED = 401, S402_PAYMENT_REQUIRED = 402, diff --git a/src/Http/Request.php b/src/Http/Request.php index df966589..ab4b21bb 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -319,7 +319,8 @@ public function detectLanguage(array $langs) foreach ($matches[1] as $key => $value) { $q = $matches[2][$key] === '' ? 1.0 : (float) $matches[2][$key]; if ($q > $max) { - $max = $q; $lang = $value; + $max = $q; + $lang = $value; } } diff --git a/src/Http/RequestFactory.php b/src/Http/RequestFactory.php index 4523e2d3..b34a55c8 100644 --- a/src/Http/RequestFactory.php +++ b/src/Http/RequestFactory.php @@ -213,7 +213,7 @@ public function createHttpRequest() } // raw body - $rawBodyCallback = function() { + $rawBodyCallback = function () { static $rawBody; if (PHP_VERSION_ID >= 50600) { diff --git a/src/Http/Response.php b/src/Http/Response.php index 2f7e8825..e19e6b09 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -291,7 +291,7 @@ private function checkHeaders() if (headers_sent($file, $line)) { throw new Nette\InvalidStateException('Cannot send header after HTTP headers have been sent' . ($file ? " (output started at $file:$line)." : '.')); - } elseif ($this->warnOnBuffer && ob_get_length() && !array_filter(ob_get_status(TRUE), function($i) { return !$i['chunk_size']; })) { + } elseif ($this->warnOnBuffer && ob_get_length() && !array_filter(ob_get_status(TRUE), function ($i) { return !$i['chunk_size']; })) { trigger_error('Possible problem: you are sending a HTTP header while already having some data in output buffer. Try Tracy\OutputDebugger or start session earlier.', E_USER_NOTICE); } } diff --git a/src/Http/Session.php b/src/Http/Session.php index eb3dc83d..0b5de947 100644 --- a/src/Http/Session.php +++ b/src/Http/Session.php @@ -224,7 +224,7 @@ public function regenerateId() { if (self::$started && !$this->regenerated) { if (headers_sent($file, $line)) { - throw new Nette\InvalidStateException("Cannot regenerate session ID after HTTP headers have been sent" . ($file ? " (output started at $file:$line)." : ".")); + throw new Nette\InvalidStateException('Cannot regenerate session ID after HTTP headers have been sent' . ($file ? " (output started at $file:$line)." : '.')); } session_regenerate_id(TRUE); session_write_close(); @@ -413,7 +413,7 @@ private function configure(array $config) } else { if (defined('SID')) { - throw new Nette\InvalidStateException("Unable to set 'session.$key' to value '$value' when session has been started" . ($this->started ? "." : " by session.auto_start or session_start().")); + throw new Nette\InvalidStateException("Unable to set 'session.$key' to value '$value' when session has been started" . ($this->started ? '.' : ' by session.auto_start or session_start().')); } if (isset($special[$key])) { $key = "session_$key"; @@ -479,7 +479,7 @@ public function setCookieParameters($path, $domain = NULL, $secure = NULL) return $this->setOptions([ 'cookie_path' => $path, 'cookie_domain' => $domain, - 'cookie_secure' => $secure + 'cookie_secure' => $secure, ]); } diff --git a/src/Http/SessionSection.php b/src/Http/SessionSection.php index 1aa53b63..a391ebda 100644 --- a/src/Http/SessionSection.php +++ b/src/Http/SessionSection.php @@ -39,7 +39,7 @@ class SessionSection extends Nette\Object implements \IteratorAggregate, \ArrayA public function __construct(Session $session, $name) { if (!is_string($name)) { - throw new Nette\InvalidArgumentException("Session namespace must be a string, " . gettype($name) . " given."); + throw new Nette\InvalidArgumentException('Session namespace must be a string, ' . gettype($name) . ' given.'); } $this->session = $session; diff --git a/src/Http/Url.php b/src/Http/Url.php index a4c74f11..8ee47bca 100644 --- a/src/Http/Url.php +++ b/src/Http/Url.php @@ -443,7 +443,7 @@ public function canonicalize() { $this->path = preg_replace_callback( '#[^!$&\'()*+,/:;=@%]+#', - function($m) { return rawurlencode($m[0]); }, + function ($m) { return rawurlencode($m[0]); }, self::unescape($this->path, '%/') ); $this->host = strtolower($this->host); @@ -474,7 +474,7 @@ public static function unescape($s, $reserved = '%;/?:@&=+$,') if ($reserved !== '') { $s = preg_replace_callback( '#%(' . substr(chunk_split(bin2hex($reserved), 2, '|'), 0, -1) . ')#i', - function($m) { return '%25' . strtoupper($m[1]); }, + function ($m) { return '%25' . strtoupper($m[1]); }, $s ); } diff --git a/src/Http/UserStorage.php b/src/Http/UserStorage.php index 9b40dbd9..2e8f1e6e 100644 --- a/src/Http/UserStorage.php +++ b/src/Http/UserStorage.php @@ -29,7 +29,7 @@ class UserStorage extends Nette\Object implements Nette\Security\IUserStorage private $sessionSection; - public function __construct(Session $sessionHandler) + public function __construct(Session $sessionHandler) { $this->sessionHandler = $sessionHandler; } diff --git a/tests/Http.DI/HttpExtension.defaultHeaders.phpt b/tests/Http.DI/HttpExtension.defaultHeaders.phpt index 599089b8..72168af5 100644 --- a/tests/Http.DI/HttpExtension.defaultHeaders.phpt +++ b/tests/Http.DI/HttpExtension.defaultHeaders.phpt @@ -24,6 +24,6 @@ $container = new Container1; $container->initialize(); $headers = headers_list(); -Assert::contains( 'X-Frame-Options: SAMEORIGIN', $headers ); -Assert::contains( 'Content-Type: text/html; charset=utf-8', $headers ); -Assert::contains( 'X-Powered-By: Nette Framework', $headers ); +Assert::contains('X-Frame-Options: SAMEORIGIN', $headers); +Assert::contains('Content-Type: text/html; charset=utf-8', $headers); +Assert::contains('X-Powered-By: Nette Framework', $headers); diff --git a/tests/Http.DI/HttpExtension.headers.phpt b/tests/Http.DI/HttpExtension.headers.phpt index ea84f040..b57835ae 100644 --- a/tests/Http.DI/HttpExtension.headers.phpt +++ b/tests/Http.DI/HttpExtension.headers.phpt @@ -32,19 +32,19 @@ $container = new Container1; $container->initialize(); $headers = headers_list(); -Assert::contains( 'X-Frame-Options: SAMEORIGIN', $headers ); -Assert::contains( 'Content-Type: text/html; charset=utf-8', $headers ); -Assert::contains( 'X-Powered-By: Nette Framework', $headers ); -Assert::contains( 'A: b', $headers ); -Assert::notContains( 'C:', $headers ); +Assert::contains('X-Frame-Options: SAMEORIGIN', $headers); +Assert::contains('Content-Type: text/html; charset=utf-8', $headers); +Assert::contains('X-Powered-By: Nette Framework', $headers); +Assert::contains('A: b', $headers); +Assert::notContains('C:', $headers); echo ' '; @ob_flush(); flush(); -Assert::true( headers_sent() ); +Assert::true(headers_sent()); -Assert::error(function() use ($container) { +Assert::error(function () use ($container) { $container->initialize(); }, [ [E_WARNING, 'Cannot modify header information - headers already sent %a%'], diff --git a/tests/Http/FileUpload.basic.phpt b/tests/Http/FileUpload.basic.phpt index e07cfdd1..3d688043 100644 --- a/tests/Http/FileUpload.basic.phpt +++ b/tests/Http/FileUpload.basic.phpt @@ -11,7 +11,7 @@ use Nette\Http\FileUpload, require __DIR__ . '/../bootstrap.php'; -test(function() { +test(function () { $upload = new FileUpload([ 'name' => 'readme.txt', 'type' => 'text/plain', @@ -20,19 +20,19 @@ test(function() { 'size' => 209, ]); - Assert::same( 'readme.txt', $upload->getName() ); - Assert::same( 'readme.txt', $upload->getSanitizedName() ); - Assert::same( 209, $upload->getSize() ); - Assert::same( __DIR__ . '/files/file.txt', $upload->getTemporaryFile() ); - Assert::same( __DIR__ . '/files/file.txt', (string) $upload ); - Assert::same( 0, $upload->getError() ); - Assert::true( $upload->isOk() ); - Assert::false( $upload->isImage() ); - Assert::same( file_get_contents(__DIR__ . '/files/file.txt'), $upload->getContents() ); + Assert::same('readme.txt', $upload->getName()); + Assert::same('readme.txt', $upload->getSanitizedName()); + Assert::same(209, $upload->getSize()); + Assert::same(__DIR__ . '/files/file.txt', $upload->getTemporaryFile()); + Assert::same(__DIR__ . '/files/file.txt', (string) $upload); + Assert::same(0, $upload->getError()); + Assert::true($upload->isOk()); + Assert::false($upload->isImage()); + Assert::same(file_get_contents(__DIR__ . '/files/file.txt'), $upload->getContents()); }); -test(function() { +test(function () { $upload = new FileUpload([ 'name' => '../.image.png', 'type' => 'text/plain', @@ -41,8 +41,8 @@ test(function() { 'size' => 209, ]); - Assert::same( '../.image.png', $upload->getName() ); - Assert::same( 'image.png', $upload->getSanitizedName() ); - Assert::same( 'image/png', $upload->getContentType() ); - Assert::true( $upload->isImage() ); + Assert::same('../.image.png', $upload->getName()); + Assert::same('image.png', $upload->getSanitizedName()); + Assert::same('image/png', $upload->getContentType()); + Assert::true($upload->isImage()); }); diff --git a/tests/Http/Helpers.phpt b/tests/Http/Helpers.phpt index 410a7df8..2b93a22a 100644 --- a/tests/Http/Helpers.phpt +++ b/tests/Http/Helpers.phpt @@ -11,37 +11,37 @@ use Nette\Http\Helpers, require __DIR__ . '/../bootstrap.php'; -test(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') ); - Assert::false( Helpers::ipMatch('192.168.63.255', '192.168.68.233/20') ); - Assert::true( Helpers::ipMatch('192.168.79.254', '192.168.68.233/20') ); - Assert::false( Helpers::ipMatch('192.168.80.0', '192.168.68.233/20') ); - Assert::true( Helpers::ipMatch('127.0.0.1', '192.168.68.233/0') ); - Assert::false( Helpers::ipMatch('127.0.0.1', '192.168.68.233/33') ); - - Assert::false( Helpers::ipMatch('127.0.0.1', '7F00:0001::') ); +test(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')); + Assert::false(Helpers::ipMatch('192.168.63.255', '192.168.68.233/20')); + Assert::true(Helpers::ipMatch('192.168.79.254', '192.168.68.233/20')); + Assert::false(Helpers::ipMatch('192.168.80.0', '192.168.68.233/20')); + Assert::true(Helpers::ipMatch('127.0.0.1', '192.168.68.233/0')); + Assert::false(Helpers::ipMatch('127.0.0.1', '192.168.68.233/33')); + + Assert::false(Helpers::ipMatch('127.0.0.1', '7F00:0001::')); }); -test(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::') ); - Assert::true( Helpers::ipMatch('2001:db8:0:0:0:0:0:0', '2001:db8::/48') ); - Assert::true( Helpers::ipMatch('2001:db8:0:ffff:ffff:ffff:ffff:ffff', '2001:db8::/48') ); - Assert::false( Helpers::ipMatch('2001:db8:1::', '2001:db8::/48') ); - Assert::false( Helpers::ipMatch('2001:db8:0:0:0:0:0:0', '2001:db8::/129') ); - Assert::false( Helpers::ipMatch('2001:db8:0:0:0:0:0:0', '32.1.13.184/32') ); +test(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::')); + Assert::true(Helpers::ipMatch('2001:db8:0:0:0:0:0:0', '2001:db8::/48')); + Assert::true(Helpers::ipMatch('2001:db8:0:ffff:ffff:ffff:ffff:ffff', '2001:db8::/48')); + Assert::false(Helpers::ipMatch('2001:db8:1::', '2001:db8::/48')); + Assert::false(Helpers::ipMatch('2001:db8:0:0:0:0:0:0', '2001:db8::/129')); + Assert::false(Helpers::ipMatch('2001:db8:0:0:0:0:0:0', '32.1.13.184/32')); }); -test(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')) ); - Assert::same( 'Tue, 15 Nov 1994 08:12:31 GMT', Helpers::formatDate(784887151) ); +test(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'))); + Assert::same('Tue, 15 Nov 1994 08:12:31 GMT', Helpers::formatDate(784887151)); }); diff --git a/tests/Http/Request.detectLanguage.phpt b/tests/Http/Request.detectLanguage.phpt index 6b540d93..9be992cc 100644 --- a/tests/Http/Request.detectLanguage.phpt +++ b/tests/Http/Request.detectLanguage.phpt @@ -11,36 +11,36 @@ use Nette\Http, require __DIR__ . '/../bootstrap.php'; -test(function() { +test(function () { $headers = ['Accept-Language' => 'en, cs']; $request = new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, $headers); - Assert::same( 'en', $request->detectLanguage(['en', 'cs']) ); - Assert::same( 'en', $request->detectLanguage(['cs', 'en']) ); - Assert::null( $request->detectLanguage(['xx']) ); + Assert::same('en', $request->detectLanguage(['en', 'cs'])); + Assert::same('en', $request->detectLanguage(['cs', 'en'])); + Assert::null($request->detectLanguage(['xx'])); }); -test(function() { +test(function () { $headers = ['Accept-Language' => 'da, en-gb;q=0.8, en;q=0.7']; $request = new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, $headers); - Assert::same( 'en-gb', $request->detectLanguage(['en', 'en-gb']) ); - Assert::same( 'en', $request->detectLanguage(['en']) ); + Assert::same('en-gb', $request->detectLanguage(['en', 'en-gb'])); + Assert::same('en', $request->detectLanguage(['en'])); }); -test(function() { +test(function () { $headers = []; $request = new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, $headers); - Assert::null( $request->detectLanguage(['en']) ); + Assert::null($request->detectLanguage(['en'])); }); -test(function() { +test(function () { $headers = ['Accept-Language' => 'garbage']; $request = new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, $headers); - Assert::null( $request->detectLanguage(['en']) ); + Assert::null($request->detectLanguage(['en'])); }); diff --git a/tests/Http/Request.files.phpt b/tests/Http/Request.files.phpt index c0d2f78a..bb660aff 100644 --- a/tests/Http/Request.files.phpt +++ b/tests/Http/Request.files.phpt @@ -100,13 +100,13 @@ $_FILES = [ $factory = new Http\RequestFactory; $request = $factory->createHttpRequest(); -Assert::type( 'Nette\Http\FileUpload', $request->files['file1'] ); -Assert::type( 'Nette\Http\FileUpload', $request->files['file2'][2] ); -Assert::type( 'Nette\Http\FileUpload', $request->files['file3']['y']['z'] ); -Assert::type( 'Nette\Http\FileUpload', $request->files['file3'][1] ); +Assert::type('Nette\Http\FileUpload', $request->files['file1']); +Assert::type('Nette\Http\FileUpload', $request->files['file2'][2]); +Assert::type('Nette\Http\FileUpload', $request->files['file3']['y']['z']); +Assert::type('Nette\Http\FileUpload', $request->files['file3'][1]); -Assert::false( isset($request->files['file0']) ); -Assert::true( isset($request->files['file1']) ); +Assert::false(isset($request->files['file0'])); +Assert::true(isset($request->files['file1'])); -Assert::null( $request->getFile('empty1') ); -Assert::same( [NULL], $request->getFile('empty2') ); +Assert::null($request->getFile('empty1')); +Assert::same([NULL], $request->getFile('empty2')); diff --git a/tests/Http/Request.getRawBody.phpt b/tests/Http/Request.getRawBody.phpt index 232cfe14..48c8471a 100644 --- a/tests/Http/Request.getRawBody.phpt +++ b/tests/Http/Request.getRawBody.phpt @@ -11,17 +11,17 @@ use Nette\Http, require __DIR__ . '/../bootstrap.php'; -test(function() { - $request = new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, function() { +test(function () { + $request = new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, function () { return 'raw body'; }); - Assert::same( 'raw body', $request->getRawBody() ); + Assert::same('raw body', $request->getRawBody()); }); -test(function() { +test(function () { $request = new Http\Request(new Http\UrlScript); - Assert::null( $request->getRawBody() ); + Assert::null($request->getRawBody()); }); diff --git a/tests/Http/Request.headers.phpt b/tests/Http/Request.headers.phpt index 04f820a9..05be473e 100644 --- a/tests/Http/Request.headers.phpt +++ b/tests/Http/Request.headers.phpt @@ -11,17 +11,17 @@ use Nette\Http, require __DIR__ . '/../bootstrap.php'; -test(function() { +test(function () { $request = new Http\Request(new Http\UrlScript); Assert::same([], $request->getHeaders()); }); -test(function() { +test(function () { $request = new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, []); Assert::same([], $request->getHeaders()); }); -test(function() { +test(function () { $request = new Http\Request(new Http\UrlScript, NULL, NULL, NULL, NULL, [ 'one' => '1', 'TWO' => '2', diff --git a/tests/Http/Request.invalidEncoding.phpt b/tests/Http/Request.invalidEncoding.phpt index edc77291..4cfccf6e 100644 --- a/tests/Http/Request.invalidEncoding.phpt +++ b/tests/Http/Request.invalidEncoding.phpt @@ -63,59 +63,59 @@ $_FILES = [ ], ]; -test(function() { // unfiltered data +test(function () { // unfiltered data $factory = new Http\RequestFactory; $factory->setBinary(); $request = $factory->createHttpRequest(); - Assert::same( $request->getQuery('invalid'), INVALID ); - Assert::same( $request->getQuery('control'), CONTROL_CHARACTERS ); - Assert::same( '1', $request->getQuery(INVALID) ); - Assert::same( '1', $request->getQuery(CONTROL_CHARACTERS) ); - Assert::same( '1', $request->query['array'][INVALID] ); - - Assert::same( $request->getPost('invalid'), INVALID ); - Assert::same( $request->getPost('control'), CONTROL_CHARACTERS ); - Assert::same( '1', $request->getPost(INVALID) ); - Assert::same( '1', $request->getPost(CONTROL_CHARACTERS) ); - Assert::same( '1', $request->post['array'][INVALID] ); - - Assert::same( $request->getCookie('invalid'), INVALID ); - Assert::same( $request->getCookie('control'), CONTROL_CHARACTERS ); - Assert::same( '1', $request->getCookie(INVALID) ); - Assert::same( '1', $request->getCookie(CONTROL_CHARACTERS) ); - Assert::same( '1', $request->cookies['array'][INVALID] ); - - Assert::type( 'Nette\Http\FileUpload', $request->getFile(INVALID) ); - Assert::type( 'Nette\Http\FileUpload', $request->getFile(CONTROL_CHARACTERS) ); - Assert::type( 'Nette\Http\FileUpload', $request->files['file1'] ); + Assert::same($request->getQuery('invalid'), INVALID); + Assert::same($request->getQuery('control'), CONTROL_CHARACTERS); + Assert::same('1', $request->getQuery(INVALID)); + Assert::same('1', $request->getQuery(CONTROL_CHARACTERS)); + Assert::same('1', $request->query['array'][INVALID]); + + Assert::same($request->getPost('invalid'), INVALID); + Assert::same($request->getPost('control'), CONTROL_CHARACTERS); + Assert::same('1', $request->getPost(INVALID)); + Assert::same('1', $request->getPost(CONTROL_CHARACTERS)); + Assert::same('1', $request->post['array'][INVALID]); + + Assert::same($request->getCookie('invalid'), INVALID); + Assert::same($request->getCookie('control'), CONTROL_CHARACTERS); + Assert::same('1', $request->getCookie(INVALID)); + Assert::same('1', $request->getCookie(CONTROL_CHARACTERS)); + Assert::same('1', $request->cookies['array'][INVALID]); + + Assert::type('Nette\Http\FileUpload', $request->getFile(INVALID)); + Assert::type('Nette\Http\FileUpload', $request->getFile(CONTROL_CHARACTERS)); + Assert::type('Nette\Http\FileUpload', $request->files['file1']); }); -test(function() { // filtered data +test(function () { // filtered data $factory = new Http\RequestFactory; $request = $factory->createHttpRequest(); - Assert::same( '', $request->getQuery('invalid') ); - Assert::same( 'ABC', $request->getQuery('control') ); - Assert::null( $request->getQuery(INVALID) ); - Assert::null( $request->getQuery(CONTROL_CHARACTERS) ); - Assert::false( isset($request->query['array'][INVALID]) ); - - Assert::same( '', $request->getPost('invalid') ); - Assert::same( 'ABC', $request->getPost('control') ); - Assert::null( $request->getPost(INVALID) ); - Assert::null( $request->getPost(CONTROL_CHARACTERS) ); - Assert::false( isset($request->post['array'][INVALID]) ); - - Assert::same( '', $request->getCookie('invalid') ); - Assert::same( 'ABC', $request->getCookie('control') ); - Assert::null( $request->getCookie(INVALID) ); - Assert::null( $request->getCookie(CONTROL_CHARACTERS) ); - Assert::false( isset($request->cookies['array'][INVALID]) ); - - Assert::null( $request->getFile(INVALID) ); - Assert::null( $request->getFile(CONTROL_CHARACTERS) ); - Assert::type( 'Nette\Http\FileUpload', $request->files['file1'] ); - Assert::same( '', $request->files['file1']->name ); + Assert::same('', $request->getQuery('invalid')); + Assert::same('ABC', $request->getQuery('control')); + Assert::null($request->getQuery(INVALID)); + Assert::null($request->getQuery(CONTROL_CHARACTERS)); + Assert::false(isset($request->query['array'][INVALID])); + + Assert::same('', $request->getPost('invalid')); + Assert::same('ABC', $request->getPost('control')); + Assert::null($request->getPost(INVALID)); + Assert::null($request->getPost(CONTROL_CHARACTERS)); + Assert::false(isset($request->post['array'][INVALID])); + + Assert::same('', $request->getCookie('invalid')); + Assert::same('ABC', $request->getCookie('control')); + Assert::null($request->getCookie(INVALID)); + Assert::null($request->getCookie(CONTROL_CHARACTERS)); + Assert::false(isset($request->cookies['array'][INVALID])); + + Assert::null($request->getFile(INVALID)); + Assert::null($request->getFile(CONTROL_CHARACTERS)); + Assert::type('Nette\Http\FileUpload', $request->files['file1']); + Assert::same('', $request->files['file1']->name); }); diff --git a/tests/Http/Request.request.phpt b/tests/Http/Request.request.phpt index 1df3c9c1..243c7b32 100644 --- a/tests/Http/Request.request.phpt +++ b/tests/Http/Request.request.phpt @@ -22,55 +22,55 @@ $_SERVER = [ 'SCRIPT_NAME' => '/file.php', ]; -test(function() { +test(function () { $factory = new Http\RequestFactory; $factory->urlFilters['path'] = ['#%20#' => '']; $factory->urlFilters['url'] = ['#[.,)]\z#' => '']; $request = $factory->createHttpRequest(); - Assert::same( 'GET', $request->getMethod() ); - Assert::true( $request->isSecured() ); - Assert::same( '192.168.188.66', $request->getRemoteAddress() ); + Assert::same('GET', $request->getMethod()); + Assert::true($request->isSecured()); + Assert::same('192.168.188.66', $request->getRemoteAddress()); - Assert::same( '/file.php', $request->getUrl()->scriptPath ); - Assert::same( 'https', $request->getUrl()->scheme ); - Assert::same( '', $request->getUrl()->user ); - Assert::same( '', $request->getUrl()->password ); - Assert::same( 'nette.org', $request->getUrl()->host ); - Assert::same( 8080, $request->getUrl()->port ); - Assert::same( '/file.php', $request->getUrl()->path ); - Assert::same( 'x_param=val.&pa%25ram=val2"es%5C%22=%5C%22¶m3=v%20a%26l%3Du%2Be', $request->getUrl()->query ); - Assert::same( '', $request->getUrl()->fragment ); - Assert::same( 'val.', $request->getQuery('x_param') ); - Assert::same( 'val2', $request->getQuery('pa%ram') ); - Assert::same( 'nette.org:8080', $request->getUrl()->authority ); - Assert::same( 'https://nette.org:8080', $request->getUrl()->hostUrl ); - Assert::same( 'https://nette.org:8080/', $request->getUrl()->baseUrl ); - Assert::same( '/', $request->getUrl()->basePath ); - Assert::same( 'file.php?x_param=val.&pa%25ram=val2"es%5C%22=%5C%22¶m3=v%20a%26l%3Du%2Be', $request->getUrl()->relativeUrl ); - Assert::same( 'https://nette.org:8080/file.php?x_param=val.&pa%25ram=val2"es%5C%22=%5C%22¶m3=v%20a%26l%3Du%2Be', $request->getUrl()->absoluteUrl ); - Assert::same( '', $request->getUrl()->pathInfo ); + Assert::same('/file.php', $request->getUrl()->scriptPath); + Assert::same('https', $request->getUrl()->scheme); + Assert::same('', $request->getUrl()->user); + Assert::same('', $request->getUrl()->password); + Assert::same('nette.org', $request->getUrl()->host); + Assert::same(8080, $request->getUrl()->port); + Assert::same('/file.php', $request->getUrl()->path); + Assert::same('x_param=val.&pa%25ram=val2"es%5C%22=%5C%22¶m3=v%20a%26l%3Du%2Be', $request->getUrl()->query); + Assert::same('', $request->getUrl()->fragment); + Assert::same('val.', $request->getQuery('x_param')); + Assert::same('val2', $request->getQuery('pa%ram')); + Assert::same('nette.org:8080', $request->getUrl()->authority); + Assert::same('https://nette.org:8080', $request->getUrl()->hostUrl); + Assert::same('https://nette.org:8080/', $request->getUrl()->baseUrl); + Assert::same('/', $request->getUrl()->basePath); + Assert::same('file.php?x_param=val.&pa%25ram=val2"es%5C%22=%5C%22¶m3=v%20a%26l%3Du%2Be', $request->getUrl()->relativeUrl); + Assert::same('https://nette.org:8080/file.php?x_param=val.&pa%25ram=val2"es%5C%22=%5C%22¶m3=v%20a%26l%3Du%2Be', $request->getUrl()->absoluteUrl); + Assert::same('', $request->getUrl()->pathInfo); }); -test(function() { +test(function () { $factory = new Http\RequestFactory; $factory->urlFilters['path'] = []; $factory->urlFilters['url'] = []; $request = $factory->createHttpRequest(); - Assert::same( 'https', $request->getUrl()->scheme ); - Assert::same( '', $request->getUrl()->user ); - Assert::same( '', $request->getUrl()->password ); - Assert::same( 'nette.org', $request->getUrl()->host ); - Assert::same( 8080, $request->getUrl()->port ); - Assert::same( '/file.php', $request->getUrl()->path ); - Assert::same( 'x_param=val.&pa%25ram=val2"es%5C%22=%5C%22¶m3=v%20a%26l%3Du%2Be%29', $request->getUrl()->query ); - Assert::same( '', $request->getUrl()->fragment ); - Assert::same( 'val.', $request->getQuery('x_param') ); - Assert::same( 'val2', $request->getQuery('pa%ram') ); - Assert::same( 'v a&l=u+e)', $request->getQuery('param3') ); + Assert::same('https', $request->getUrl()->scheme); + Assert::same('', $request->getUrl()->user); + Assert::same('', $request->getUrl()->password); + Assert::same('nette.org', $request->getUrl()->host); + Assert::same(8080, $request->getUrl()->port); + Assert::same('/file.php', $request->getUrl()->path); + Assert::same('x_param=val.&pa%25ram=val2"es%5C%22=%5C%22¶m3=v%20a%26l%3Du%2Be%29', $request->getUrl()->query); + Assert::same('', $request->getUrl()->fragment); + Assert::same('val.', $request->getQuery('x_param')); + Assert::same('val2', $request->getQuery('pa%ram')); + Assert::same('v a&l=u+e)', $request->getQuery('param3')); if (!function_exists('apache_request_headers')) { - Assert::same( 'nette.org:8080', $request->headers['host'] ); + Assert::same('nette.org:8080', $request->headers['host']); } }); diff --git a/tests/Http/RequestFactory.host.phpt b/tests/Http/RequestFactory.host.phpt index 54bd950e..ae9fee2d 100644 --- a/tests/Http/RequestFactory.host.phpt +++ b/tests/Http/RequestFactory.host.phpt @@ -15,39 +15,39 @@ $_SERVER = [ 'HTTP_HOST' => 'localhost', ]; $factory = new RequestFactory; -Assert::same( 'http://localhost/', (string) $factory->createHttpRequest()->getUrl() ); +Assert::same('http://localhost/', (string) $factory->createHttpRequest()->getUrl()); $_SERVER = [ 'HTTP_HOST' => 'www-x.nette.org', ]; $factory = new RequestFactory; -Assert::same( 'http://www-x.nette.org/', (string) $factory->createHttpRequest()->getUrl() ); +Assert::same('http://www-x.nette.org/', (string) $factory->createHttpRequest()->getUrl()); $_SERVER = [ 'HTTP_HOST' => '192.168.0.1:8080', ]; $factory = new RequestFactory; -Assert::same( 'http://192.168.0.1:8080/', (string) $factory->createHttpRequest()->getUrl() ); +Assert::same('http://192.168.0.1:8080/', (string) $factory->createHttpRequest()->getUrl()); $_SERVER = [ 'HTTP_HOST' => '[::1aF]:8080', ]; $factory = new RequestFactory; -Assert::same( 'http://[::1af]:8080/', (string) $factory->createHttpRequest()->getUrl() ); +Assert::same('http://[::1af]:8080/', (string) $factory->createHttpRequest()->getUrl()); $_SERVER = [ 'HTTP_HOST' => "a.cz\n", ]; $factory = new RequestFactory; -Assert::same( 'http:///', (string) $factory->createHttpRequest()->getUrl() ); +Assert::same('http:///', (string) $factory->createHttpRequest()->getUrl()); $_SERVER = [ 'HTTP_HOST' => 'AB', ]; $factory = new RequestFactory; -Assert::same( 'http://ab/', (string) $factory->createHttpRequest()->getUrl() ); +Assert::same('http://ab/', (string) $factory->createHttpRequest()->getUrl()); diff --git a/tests/Http/RequestFactory.method.phpt b/tests/Http/RequestFactory.method.phpt index 45bc57ad..772631d0 100644 --- a/tests/Http/RequestFactory.method.phpt +++ b/tests/Http/RequestFactory.method.phpt @@ -16,7 +16,7 @@ $_SERVER = [ 'HTTP_X_HTTP_METHOD_OVERRIDE' => 'PATCH', ]; $factory = new RequestFactory; -Assert::same( 'GET', $factory->createHttpRequest()->getMethod() ); +Assert::same('GET', $factory->createHttpRequest()->getMethod()); $_SERVER = [ @@ -24,7 +24,7 @@ $_SERVER = [ 'HTTP_X_HTTP_METHOD_OVERRIDE' => 'PATCH', ]; $factory = new RequestFactory; -Assert::same( 'PATCH', $factory->createHttpRequest()->getMethod() ); +Assert::same('PATCH', $factory->createHttpRequest()->getMethod()); $_SERVER = [ @@ -32,4 +32,4 @@ $_SERVER = [ 'HTTP_X_HTTP_METHOD_OVERRIDE' => ' *', ]; $factory = new RequestFactory; -Assert::same( 'POST', $factory->createHttpRequest()->getMethod() ); +Assert::same('POST', $factory->createHttpRequest()->getMethod()); diff --git a/tests/Http/RequestFactory.proxy.phpt b/tests/Http/RequestFactory.proxy.phpt index f125d633..705ec569 100644 --- a/tests/Http/RequestFactory.proxy.phpt +++ b/tests/Http/RequestFactory.proxy.phpt @@ -11,7 +11,7 @@ use Nette\Http\RequestFactory, require __DIR__ . '/../bootstrap.php'; -test(function() { +test(function () { $_SERVER = [ 'REMOTE_ADDR' => '127.0.0.3', 'REMOTE_HOST' => 'localhost', @@ -21,10 +21,10 @@ test(function() { $factory = new RequestFactory; $factory->setProxy('127.0.0.1'); - Assert::same( '127.0.0.3', $factory->createHttpRequest()->getRemoteAddress() ); - Assert::same( 'localhost', $factory->createHttpRequest()->getRemoteHost() ); + Assert::same('127.0.0.3', $factory->createHttpRequest()->getRemoteAddress()); + Assert::same('localhost', $factory->createHttpRequest()->getRemoteHost()); $factory->setProxy('127.0.0.1/8'); - Assert::same( '23.75.345.200', $factory->createHttpRequest()->getRemoteAddress() ); - Assert::same( 'otherhost', $factory->createHttpRequest()->getRemoteHost() ); + Assert::same('23.75.345.200', $factory->createHttpRequest()->getRemoteAddress()); + Assert::same('otherhost', $factory->createHttpRequest()->getRemoteHost()); }); diff --git a/tests/Http/RequestFactory.scriptPath.phpt b/tests/Http/RequestFactory.scriptPath.phpt index 2972874e..7ebcaae9 100644 --- a/tests/Http/RequestFactory.scriptPath.phpt +++ b/tests/Http/RequestFactory.scriptPath.phpt @@ -13,152 +13,152 @@ require __DIR__ . '/../bootstrap.php'; $factory = new RequestFactory; -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/projects/modules-usage/www/', 'SCRIPT_NAME' => '/projects/modules-usage/www/index.php', ]; - Assert::same( '/projects/modules-usage/www/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/projects/modules-usage/www/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/projects/modules-usage/%77%77%77/', 'SCRIPT_NAME' => '/projects/modules-usage/www/index.php', ]; - Assert::same( '/projects/modules-usage/www/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/projects/modules-usage/www/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/projects/modules-usage/www/default/add-item', 'SCRIPT_NAME' => '/projects/modules-usage/www/index.php', ]; - Assert::same( '/projects/modules-usage/www/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/projects/modules-usage/www/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/www/index.php', 'SCRIPT_NAME' => '/www/index.php', ]; - Assert::same( '/www/index.php', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/www/index.php', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/www/', 'SCRIPT_NAME' => '/www/', ]; - Assert::same( '/www/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/www/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/test/in', 'SCRIPT_NAME' => '/test/index.php', ]; - Assert::same( '/test/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/test/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/test//', 'SCRIPT_NAME' => '/test/index.php', ]; - Assert::same( '/test/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/test/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); // http://forum.nette.org/cs/5932-lepsi-detekce-requesturi-a-scriptpath -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/sign/in/', 'SCRIPT_NAME' => '/sign/in/', ]; - Assert::same( '/sign/in/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/sign/in/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); // http://forum.nette.org/cs/9139-spatny-urlscript-scriptpath -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/configuration/', 'SCRIPT_NAME' => '/configuration/www/index.php', ]; - Assert::same( '/configuration/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/configuration/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/blog/WWW/', 'SCRIPT_NAME' => '/blog/www/index.php', ]; - Assert::same( '/blog/WWW/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/blog/WWW/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/', 'SCRIPT_NAME' => 'c:\\index.php', ]; - Assert::same( '/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => NULL, 'SCRIPT_NAME' => 'c:\\index.php', ]; - Assert::same( '/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/', 'SCRIPT_NAME' => NULL, ]; - Assert::same( '/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => NULL, 'SCRIPT_NAME' => NULL, ]; - Assert::same( '/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); -test(function() use ($factory) { +test(function () use ($factory) { $_SERVER = [ 'REQUEST_URI' => '/documents/show/5474', 'SCRIPT_NAME' => '/index.php', ]; - Assert::same( '/', $factory->createHttpRequest()->getUrl()->getScriptPath() ); + Assert::same('/', $factory->createHttpRequest()->getUrl()->getScriptPath()); }); diff --git a/tests/Http/Response.error.phpt b/tests/Http/Response.error.phpt index 817f33bc..503d16a9 100644 --- a/tests/Http/Response.error.phpt +++ b/tests/Http/Response.error.phpt @@ -24,7 +24,7 @@ $response->setHeader('A', 'b'); // full buffer ob_end_clean(); -Assert::error(function() use ($response) { +Assert::error(function () use ($response) { ob_start(NULL, 4096); echo ' '; $response->setHeader('A', 'b'); @@ -35,7 +35,7 @@ $response->warnOnBuffer = FALSE; $response->setHeader('A', 'b'); -Assert::exception(function() use ($response) { +Assert::exception(function () use ($response) { ob_flush(); $response->setHeader('A', 'b'); }, 'Nette\InvalidStateException', 'Cannot send header after HTTP headers have been sent (output started at ' . __FILE__ . ':' . (__LINE__ - 2) . ').'); diff --git a/tests/Http/Response.setCookie.phpt b/tests/Http/Response.setCookie.phpt index 24a37d27..56583284 100644 --- a/tests/Http/Response.setCookie.phpt +++ b/tests/Http/Response.setCookie.phpt @@ -22,14 +22,14 @@ $response = new Http\Response; $response->setCookie('test', 'value', 0); $headers = array_values(array_diff(headers_list(), $old, ['Set-Cookie:'])); $headers = str_replace('HttpOnly', 'httponly', $headers); -Assert::same( [ +Assert::same([ 'Set-Cookie: test=value; path=/; httponly', -], $headers ); +], $headers); $response->setCookie('test', 'newvalue', 0); $headers = array_values(array_diff(headers_list(), $old, ['Set-Cookie:'])); $headers = str_replace('HttpOnly', 'httponly', $headers); -Assert::same( [ +Assert::same([ 'Set-Cookie: test=newvalue; path=/; httponly', -], $headers ); +], $headers); diff --git a/tests/Http/Session.regenerateId().phpt b/tests/Http/Session.regenerateId().phpt index 8bcd57f0..c4a78b30 100644 --- a/tests/Http/Session.regenerateId().phpt +++ b/tests/Http/Session.regenerateId().phpt @@ -17,14 +17,14 @@ $path = rtrim(ini_get('session.save_path'), '/\\') . '/sess_'; $session->start(); $oldId = $session->getId(); -Assert::true( is_file($path . $oldId) ); +Assert::true(is_file($path . $oldId)); $ref = & $_SESSION['var']; $ref = 10; $session->regenerateId(); $newId = $session->getId(); -Assert::same( $newId, $oldId ); // new session is regenerated by $session->start() -Assert::true( is_file($path . $newId) ); +Assert::same($newId, $oldId); // new session is regenerated by $session->start() +Assert::true(is_file($path . $newId)); $ref = 20; -Assert::same( 20, $_SESSION['var'] ); +Assert::same(20, $_SESSION['var']); diff --git a/tests/Http/Session.sections.phpt b/tests/Http/Session.sections.phpt index 5a46c87e..e73a4b7b 100644 --- a/tests/Http/Session.sections.phpt +++ b/tests/Http/Session.sections.phpt @@ -16,13 +16,13 @@ ob_start(); $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 +Assert::false($session->hasSection('trees')); // hasSection() should have returned FALSE for a section with no keys set $section = $session->getSection('trees'); -Assert::false( $session->hasSection('trees') ); // hasSection() should have returned FALSE for a section with no keys set +Assert::false($session->hasSection('trees')); // hasSection() should have returned FALSE for a section with no keys set $section->hello = 'world'; -Assert::true( $session->hasSection('trees') ); // hasSection() should have returned TRUE for a section with keys set +Assert::true($session->hasSection('trees')); // hasSection() should have returned TRUE for a section with keys set $section = $session->getSection('default'); -Assert::type( 'Nette\Http\SessionSection', $section ); +Assert::type('Nette\Http\SessionSection', $section); diff --git a/tests/Http/Session.start.error.phpt b/tests/Http/Session.start.error.phpt index 3567e119..9a2ed284 100644 --- a/tests/Http/Session.start.error.phpt +++ b/tests/Http/Session.start.error.phpt @@ -17,6 +17,6 @@ ini_set('session.save_path', ';;;'); $session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); -Assert::exception(function() use ($session) { +Assert::exception(function () use ($session) { $session->start(); -}, 'Nette\InvalidStateException', "session_start(): open(%A%) failed: %a%"); +}, 'Nette\InvalidStateException', 'session_start(): open(%A%) failed: %a%'); diff --git a/tests/Http/SessionSection.basic.phpt b/tests/Http/SessionSection.basic.phpt index 389e474d..151f5535 100644 --- a/tests/Http/SessionSection.basic.phpt +++ b/tests/Http/SessionSection.basic.phpt @@ -21,20 +21,20 @@ $namespace['o'] = 'orange'; foreach ($namespace as $key => $val) { $tmp[] = "$key=$val"; } -Assert::same( [ +Assert::same([ 'a=apple', 'p=pear', 'o=orange', -], $tmp ); +], $tmp); -Assert::true( isset($namespace['p']) ); -Assert::true( isset($namespace->o) ); -Assert::false( isset($namespace->undefined) ); +Assert::true(isset($namespace['p'])); +Assert::true(isset($namespace->o)); +Assert::false(isset($namespace->undefined)); unset($namespace['a']); unset($namespace->p); unset($namespace->o); unset($namespace->undef); -Assert::same( '', http_build_query($namespace->getIterator()) ); +Assert::same('', http_build_query($namespace->getIterator())); diff --git a/tests/Http/SessionSection.remove.phpt b/tests/Http/SessionSection.remove.phpt index c0e732d5..ec051978 100644 --- a/tests/Http/SessionSection.remove.phpt +++ b/tests/Http/SessionSection.remove.phpt @@ -19,9 +19,9 @@ $namespace->p = 'papaya'; $namespace['c'] = 'cherry'; $namespace = $session->getSection('three'); -Assert::same( 'a=apple&p=papaya&c=cherry', http_build_query($namespace->getIterator()) ); +Assert::same('a=apple&p=papaya&c=cherry', http_build_query($namespace->getIterator())); // removing $namespace->remove(); -Assert::same( '', http_build_query($namespace->getIterator()) ); +Assert::same('', http_build_query($namespace->getIterator())); diff --git a/tests/Http/SessionSection.separated.phpt b/tests/Http/SessionSection.separated.phpt index 1c68eba7..93e8fdcd 100644 --- a/tests/Http/SessionSection.separated.phpt +++ b/tests/Http/SessionSection.separated.phpt @@ -22,7 +22,7 @@ $namespace3b = $session->getSection('default'); $namespace1->a = 'apple'; $namespace2->a = 'pear'; $namespace3->a = 'orange'; -Assert::true( $namespace1->a !== $namespace2->a && $namespace1->a !== $namespace3->a && $namespace2->a !== $namespace3->a ); -Assert::same( $namespace1->a, $namespace1b->a ); -Assert::same( $namespace2->a, $namespace2b->a ); -Assert::same( $namespace3->a, $namespace3b->a ); +Assert::true($namespace1->a !== $namespace2->a && $namespace1->a !== $namespace3->a && $namespace2->a !== $namespace3->a); +Assert::same($namespace1->a, $namespace1b->a); +Assert::same($namespace2->a, $namespace2b->a); +Assert::same($namespace3->a, $namespace3b->a); diff --git a/tests/Http/SessionSection.setExpiration().phpt b/tests/Http/SessionSection.setExpiration().phpt index fe47548e..76bffb0f 100644 --- a/tests/Http/SessionSection.setExpiration().phpt +++ b/tests/Http/SessionSection.setExpiration().phpt @@ -15,7 +15,7 @@ $session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Net $session->setExpiration('+10 seconds'); -test(function() use ($session) { // try to expire whole namespace +test(function () use ($session) { // try to expire whole namespace $namespace = $session->getSection('expire'); $namespace->a = 'apple'; $namespace->p = 'pear'; @@ -27,11 +27,11 @@ test(function() use ($session) { // try to expire whole namespace $session->start(); $namespace = $session->getSection('expire'); - Assert::same( '', http_build_query($namespace->getIterator()) ); + Assert::same('', http_build_query($namespace->getIterator())); }); -test(function() use ($session) { // try to expire only 1 of the keys +test(function () use ($session) { // try to expire only 1 of the keys $namespace = $session->getSection('expireSingle'); $namespace->setExpiration(1, 'g'); $namespace->g = 'guava'; @@ -42,12 +42,12 @@ test(function() use ($session) { // try to expire only 1 of the keys $session->start(); $namespace = $session->getSection('expireSingle'); - Assert::same( 'p=plum', http_build_query($namespace->getIterator()) ); + Assert::same('p=plum', http_build_query($namespace->getIterator())); }); // small expiration -Assert::error(function() use ($session) { +Assert::error(function () use ($session) { $namespace = $session->getSection('tmp'); $namespace->setExpiration(100); -}, E_USER_NOTICE, "The expiration time is greater than the session expiration 10 seconds"); +}, E_USER_NOTICE, 'The expiration time is greater than the session expiration 10 seconds'); diff --git a/tests/Http/SessionSection.setExpirationUnlimited.phpt b/tests/Http/SessionSection.setExpirationUnlimited.phpt index b53c0faa..e834e27f 100644 --- a/tests/Http/SessionSection.setExpirationUnlimited.phpt +++ b/tests/Http/SessionSection.setExpirationUnlimited.phpt @@ -18,4 +18,4 @@ $session->setOptions(['gc_maxlifetime' => '0']); //memcache handler supports unl $namespace = $session->getSection('maxlifetime'); $namespace->setExpiration(100); -Assert::same(true, true); //Fix Error: This test forgets to execute an assertion. +Assert::same(TRUE, TRUE); // fix Error: This test forgets to execute an assertion. diff --git a/tests/Http/SessionSection.undefined.phpt b/tests/Http/SessionSection.undefined.phpt index 68ac5303..ea05bc5a 100644 --- a/tests/Http/SessionSection.undefined.phpt +++ b/tests/Http/SessionSection.undefined.phpt @@ -14,6 +14,6 @@ require __DIR__ . '/../bootstrap.php'; $session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Nette\Http\Response); $namespace = $session->getSection('one'); -Assert::false( isset($namespace->undefined) ); -Assert::null( $namespace->undefined ); // Getting value of non-existent key -Assert::same( '', http_build_query($namespace->getIterator()) ); +Assert::false(isset($namespace->undefined)); +Assert::null($namespace->undefined); // Getting value of non-existent key +Assert::same('', http_build_query($namespace->getIterator())); diff --git a/tests/Http/Url.canonicalize.phpt b/tests/Http/Url.canonicalize.phpt index 164afbdd..1df4017b 100644 --- a/tests/Http/Url.canonicalize.phpt +++ b/tests/Http/Url.canonicalize.phpt @@ -13,18 +13,18 @@ require __DIR__ . '/../bootstrap.php'; $url = new Url('http://hostname/path?arg=value&arg2=v%20a%26l%3Du%2Be'); $url->canonicalize(); -Assert::same( 'http://hostname/path?arg=value&arg2=v%20a%26l%3Du%2Be', (string) $url ); +Assert::same('http://hostname/path?arg=value&arg2=v%20a%26l%3Du%2Be', (string) $url); $url = new Url('http://username%3A:password%3A@hostN%61me:60/p%61th%2f%25()?arg=value&arg2=v%20a%26l%3Du%2Be#%61nchor'); $url->canonicalize(); -Assert::same( 'http://hostname:60/path%2F%25()?arg=value&arg2=v%20a%26l%3Du%2Be#anchor', (string) $url ); +Assert::same('http://hostname:60/path%2F%25()?arg=value&arg2=v%20a%26l%3Du%2Be#anchor', (string) $url); $url = new Url('http://host/%1f%20 %21!%22"%23%24$%25%26&%27\'%28(%29)%2a*%2b+%2c,%2d-%2e.%2f/%300%311%322%333%344%355%366%377%388%399%3a:%3b;%3c<%3d=%3e>%3f%40@' . '%41A%42B%43C%44D%45E%46F%47G%48H%49I%4aJ%4bK%4cL%4dM%4eN%4fO%50P%51Q%52R%53S%54T%55U%56V%57W%58X%59Y%5aZ%5b[%5c\%5d]%5e^%5f_%60`' . '%61a%62b%63c%64d%65e%66f%67g%68h%69i%6aj%6bk%6cl%6dm%6en%6fo%70p%71q%72r%73s%74t%75u%76v%77w%78x%79y%7az%7b{%7c|%7d}%7e~%7fá'); $url->canonicalize(); -Assert::same( 'http://host/%1F%20%20!!%22%22%23$$%25&&\'\'(())**++,,--..%2F/00112233445566778899::;;%3C%3C==%3E%3E%3F@@' +Assert::same('http://host/%1F%20%20!!%22%22%23$$%25&&\'\'(())**++,,--..%2F/00112233445566778899::;;%3C%3C==%3E%3E%3F@@' . 'AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ%5B%5B%5C%5C%5D%5D%5E%5E__%60%60' - . 'aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz%7B%7B%7C%7C%7D%7D~~%7F%C3%A1', (string) $url ); + . 'aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz%7B%7B%7C%7C%7D%7D~~%7F%C3%A1', (string) $url); diff --git a/tests/Http/Url.fileScheme.phpt b/tests/Http/Url.fileScheme.phpt index 2f64c9d0..042b6b44 100644 --- a/tests/Http/Url.fileScheme.phpt +++ b/tests/Http/Url.fileScheme.phpt @@ -11,29 +11,29 @@ use Nette\Http\Url, require __DIR__ . '/../bootstrap.php'; -test(function() { +test(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 ); - Assert::same( '', $url->user ); - Assert::same( '', $url->password ); - Assert::same( 'localhost', $url->host ); - Assert::null( $url->port ); - Assert::same( '/D:/dokumentace/rfc3986.txt', $url->path ); - Assert::same( '', $url->query ); - Assert::same( '', $url->fragment ); + Assert::same('file://localhost/D:/dokumentace/rfc3986.txt', (string) $url); + Assert::same('file', $url->scheme); + Assert::same('', $url->user); + Assert::same('', $url->password); + Assert::same('localhost', $url->host); + Assert::null($url->port); + Assert::same('/D:/dokumentace/rfc3986.txt', $url->path); + Assert::same('', $url->query); + Assert::same('', $url->fragment); }); -test(function() { +test(function () { $url = new Url('file:///D:/dokumentace/rfc3986.txt'); - Assert::same( 'file://D:/dokumentace/rfc3986.txt', (string) $url ); - Assert::same( 'file', $url->scheme ); - Assert::same( '', $url->user ); - Assert::same( '', $url->password ); - Assert::same( '', $url->host ); - Assert::null( $url->port ); - Assert::same( 'D:/dokumentace/rfc3986.txt', $url->path ); - Assert::same( '', $url->query ); - Assert::same( '', $url->fragment ); + Assert::same('file://D:/dokumentace/rfc3986.txt', (string) $url); + Assert::same('file', $url->scheme); + Assert::same('', $url->user); + Assert::same('', $url->password); + Assert::same('', $url->host); + Assert::null($url->port); + Assert::same('D:/dokumentace/rfc3986.txt', $url->path); + Assert::same('', $url->query); + Assert::same('', $url->fragment); }); diff --git a/tests/Http/Url.ftpScheme.phpt b/tests/Http/Url.ftpScheme.phpt index 144521f2..ac93d186 100644 --- a/tests/Http/Url.ftpScheme.phpt +++ b/tests/Http/Url.ftpScheme.phpt @@ -13,14 +13,14 @@ require __DIR__ . '/../bootstrap.php'; $url = new Url('ftp://ftp.is.co.za/rfc/rfc3986.txt'); -Assert::same( 'ftp', $url->scheme ); -Assert::same( '', $url->user ); -Assert::same( '', $url->password ); -Assert::same( 'ftp.is.co.za', $url->host ); -Assert::same( 21, $url->port ); -Assert::same( '/rfc/rfc3986.txt', $url->path ); -Assert::same( '', $url->query ); -Assert::same( '', $url->fragment ); -Assert::same( 'ftp.is.co.za', $url->authority ); -Assert::same( 'ftp://ftp.is.co.za', $url->hostUrl ); -Assert::same( 'ftp://ftp.is.co.za/rfc/rfc3986.txt', $url->absoluteUrl ); +Assert::same('ftp', $url->scheme); +Assert::same('', $url->user); +Assert::same('', $url->password); +Assert::same('ftp.is.co.za', $url->host); +Assert::same(21, $url->port); +Assert::same('/rfc/rfc3986.txt', $url->path); +Assert::same('', $url->query); +Assert::same('', $url->fragment); +Assert::same('ftp.is.co.za', $url->authority); +Assert::same('ftp://ftp.is.co.za', $url->hostUrl); +Assert::same('ftp://ftp.is.co.za/rfc/rfc3986.txt', $url->absoluteUrl); diff --git a/tests/Http/Url.httpScheme.phpt b/tests/Http/Url.httpScheme.phpt index b4248680..8648371c 100644 --- a/tests/Http/Url.httpScheme.phpt +++ b/tests/Http/Url.httpScheme.phpt @@ -13,42 +13,42 @@ require __DIR__ . '/../bootstrap.php'; $url = new Url('http://username%3A:password%3A@hostn%61me:60/p%61th/script.php?%61rg=value#%61nchor'); -Assert::same( 'http://hostname:60/p%61th/script.php?arg=value#anchor', (string) $url ); -Assert::same( 'http', $url->scheme ); -Assert::same( 'username:', $url->user ); -Assert::same( 'password:', $url->password ); -Assert::same( 'hostname', $url->host ); -Assert::same( 60, $url->port ); -Assert::same( '/p%61th/script.php', $url->path ); -Assert::same( '/p%61th/', $url->basePath ); -Assert::same( 'arg=value', $url->query ); -Assert::same( 'anchor', $url->fragment ); -Assert::same( 'hostname:60', $url->authority ); -Assert::same( 'http://hostname:60', $url->hostUrl ); -Assert::same( 'http://hostname:60/p%61th/script.php?arg=value#anchor', $url->absoluteUrl ); -Assert::same( 'http://hostname:60/p%61th/', $url->baseUrl ); -Assert::same( 'script.php?arg=value#anchor', $url->relativeUrl ); +Assert::same('http://hostname:60/p%61th/script.php?arg=value#anchor', (string) $url); +Assert::same('http', $url->scheme); +Assert::same('username:', $url->user); +Assert::same('password:', $url->password); +Assert::same('hostname', $url->host); +Assert::same(60, $url->port); +Assert::same('/p%61th/script.php', $url->path); +Assert::same('/p%61th/', $url->basePath); +Assert::same('arg=value', $url->query); +Assert::same('anchor', $url->fragment); +Assert::same('hostname:60', $url->authority); +Assert::same('http://hostname:60', $url->hostUrl); +Assert::same('http://hostname:60/p%61th/script.php?arg=value#anchor', $url->absoluteUrl); +Assert::same('http://hostname:60/p%61th/', $url->baseUrl); +Assert::same('script.php?arg=value#anchor', $url->relativeUrl); $url->setPath(''); -Assert::same( '/', $url->getPath() ); +Assert::same('/', $url->getPath()); $url->setPath('/'); -Assert::same( '/', $url->getPath() ); +Assert::same('/', $url->getPath()); $url->setPath('x'); -Assert::same( '/x', $url->getPath() ); +Assert::same('/x', $url->getPath()); $url->setPath('/x'); -Assert::same( '/x', $url->getPath() ); +Assert::same('/x', $url->getPath()); $url->setScheme(NULL); -Assert::same( '//username%3A:password%3A@hostname:60/x?arg=value#anchor', $url->absoluteUrl ); +Assert::same('//username%3A:password%3A@hostname:60/x?arg=value#anchor', $url->absoluteUrl); $url->setPath(''); -Assert::same( '/', $url->getPath() ); +Assert::same('/', $url->getPath()); $url->setHost(NULL)->setPath(NULL); -Assert::same( '//?arg=value#anchor', $url->absoluteUrl ); +Assert::same('//?arg=value#anchor', $url->absoluteUrl); $url->setPath(''); -Assert::same( '', $url->getPath() ); +Assert::same('', $url->getPath()); diff --git a/tests/Http/Url.isEqual().phpt b/tests/Http/Url.isEqual().phpt index 271ef13b..72459e94 100644 --- a/tests/Http/Url.isEqual().phpt +++ b/tests/Http/Url.isEqual().phpt @@ -12,42 +12,42 @@ require __DIR__ . '/../bootstrap.php'; $url = new Url('http://exampl%65.COM/p%61th?text=foo%20bar+foo&value'); -Assert::true( $url->isEqual('http://example.com/path?text=foo+bar%20foo&value') ); -Assert::true( $url->isEqual('http://example.com/%70ath?value&text=foo+bar%20foo') ); -Assert::false( $url->isEqual('http://example.com/Path?text=foo+bar%20foo&value') ); -Assert::false( $url->isEqual('http://example.com/path?value&text=foo+bar%20foo#abc') ); -Assert::false( $url->isEqual('http://example.com/path?text=foo+bar%20foo') ); -Assert::false( $url->isEqual('https://example.com/path?text=foo+bar%20foo&value') ); -Assert::false( $url->isEqual('http://example.org/path?text=foo+bar%20foo&value') ); +Assert::true($url->isEqual('http://example.com/path?text=foo+bar%20foo&value')); +Assert::true($url->isEqual('http://example.com/%70ath?value&text=foo+bar%20foo')); +Assert::false($url->isEqual('http://example.com/Path?text=foo+bar%20foo&value')); +Assert::false($url->isEqual('http://example.com/path?value&text=foo+bar%20foo#abc')); +Assert::false($url->isEqual('http://example.com/path?text=foo+bar%20foo')); +Assert::false($url->isEqual('https://example.com/path?text=foo+bar%20foo&value')); +Assert::false($url->isEqual('http://example.org/path?text=foo+bar%20foo&value')); $url = new Url('http://example.com'); -Assert::true( $url->isEqual('http://example.com/') ); -Assert::true( $url->isEqual('http://example.com') ); +Assert::true($url->isEqual('http://example.com/')); +Assert::true($url->isEqual('http://example.com')); $url = new Url('http://example.com/?arr[]=item1&arr[]=item2'); -Assert::true( $url->isEqual('http://example.com/?arr[0]=item1&arr[1]=item2') ); -Assert::false( $url->isEqual('http://example.com/?arr[1]=item1&arr[0]=item2') ); +Assert::true($url->isEqual('http://example.com/?arr[0]=item1&arr[1]=item2')); +Assert::false($url->isEqual('http://example.com/?arr[1]=item1&arr[0]=item2')); $url = new Url('http://example.com/?a=9999&b=127.0.0.1&c=1234&d=123456789'); -Assert::true( $url->isEqual('http://example.com/?d=123456789&a=9999&b=127.0.0.1&c=1234') ); +Assert::true($url->isEqual('http://example.com/?d=123456789&a=9999&b=127.0.0.1&c=1234')); $url = new Url('http://example.com/?a=123&b=456'); -Assert::false( $url->isEqual('http://example.com/?a=456&b=123') ); +Assert::false($url->isEqual('http://example.com/?a=456&b=123')); $url = new Url('http://user:pass@example.com'); -Assert::true( $url->isEqual('http://example.com') ); +Assert::true($url->isEqual('http://example.com')); $url = new Url('ftp://user:pass@example.com'); -Assert::false( $url->isEqual('ftp://example.com') ); +Assert::false($url->isEqual('ftp://example.com')); $url = new Url; $url->setScheme('http'); $url->setHost('example.com'); -Assert::true( $url->isEqual('http://example.com') ); +Assert::true($url->isEqual('http://example.com')); diff --git a/tests/Http/Url.malformedUri.phpt b/tests/Http/Url.malformedUri.phpt index abbb104a..f419f964 100644 --- a/tests/Http/Url.malformedUri.phpt +++ b/tests/Http/Url.malformedUri.phpt @@ -11,6 +11,6 @@ use Nette\Http\Url, require __DIR__ . '/../bootstrap.php'; -Assert::exception(function() { +Assert::exception(function () { $url = new Url('http:///'); }, 'InvalidArgumentException', "Malformed or unsupported URI 'http:///'."); diff --git a/tests/Http/Url.parseQuery.phpt b/tests/Http/Url.parseQuery.phpt index 7e3042cb..36548605 100644 --- a/tests/Http/Url.parseQuery.phpt +++ b/tests/Http/Url.parseQuery.phpt @@ -11,13 +11,13 @@ use Nette\Http\Url, require __DIR__ . '/../bootstrap.php'; -Assert::same( [], Url::parseQuery('') ); -Assert::same( ['key' => ''], Url::parseQuery('key') ); -Assert::same( ['key' => ''], Url::parseQuery('key=') ); -Assert::same( ['key' => 'val'], Url::parseQuery('key=val') ); -Assert::same( ['key' => ''], Url::parseQuery('&key=&') ); -Assert::same( ['a' => ['val', 'val']], Url::parseQuery('a[]=val&a[]=val') ); -Assert::same( ['a' => ['x' => 'val', 'y' => 'val']], Url::parseQuery('%61[x]=val&%61[y]=val') ); -Assert::same( ['a_b' => 'val', 'c' => ['d e' => 'val']], Url::parseQuery('a b=val&c[d e]=val') ); -Assert::same( ['a_b' => 'val', 'c' => ['d.e' => 'val']], Url::parseQuery('a.b=val&c[d.e]=val') ); -Assert::same( ['key"\'' => '"\''], Url::parseQuery('key"\'="\'') ); // magic quotes +Assert::same([], Url::parseQuery('')); +Assert::same(['key' => ''], Url::parseQuery('key')); +Assert::same(['key' => ''], Url::parseQuery('key=')); +Assert::same(['key' => 'val'], Url::parseQuery('key=val')); +Assert::same(['key' => ''], Url::parseQuery('&key=&')); +Assert::same(['a' => ['val', 'val']], Url::parseQuery('a[]=val&a[]=val')); +Assert::same(['a' => ['x' => 'val', 'y' => 'val']], Url::parseQuery('%61[x]=val&%61[y]=val')); +Assert::same(['a_b' => 'val', 'c' => ['d e' => 'val']], Url::parseQuery('a b=val&c[d e]=val')); +Assert::same(['a_b' => 'val', 'c' => ['d.e' => 'val']], Url::parseQuery('a.b=val&c[d.e]=val')); +Assert::same(['key"\'' => '"\''], Url::parseQuery('key"\'="\'')); // magic quotes diff --git a/tests/Http/Url.query.phpt b/tests/Http/Url.query.phpt index 301ed9ee..181ae833 100644 --- a/tests/Http/Url.query.phpt +++ b/tests/Http/Url.query.phpt @@ -12,55 +12,55 @@ require __DIR__ . '/../bootstrap.php'; $url = new Url('http://hostname/path?arg=value'); -Assert::same( 'arg=value', $url->query ); -Assert::same( ['arg' => 'value'], $url->getQueryParameters() ); +Assert::same('arg=value', $url->query); +Assert::same(['arg' => 'value'], $url->getQueryParameters()); $url->appendQuery(NULL); -Assert::same( 'arg=value', $url->query ); -Assert::same( ['arg' => 'value'], $url->getQueryParameters() ); +Assert::same('arg=value', $url->query); +Assert::same(['arg' => 'value'], $url->getQueryParameters()); $url->appendQuery([NULL]); -Assert::same( 'arg=value', $url->query ); -Assert::same( [NULL, 'arg' => 'value'], $url->getQueryParameters() ); +Assert::same('arg=value', $url->query); +Assert::same([NULL, 'arg' => 'value'], $url->getQueryParameters()); $url->appendQuery('arg2=value2'); -Assert::same( 'arg=value&arg2=value2', $url->query ); -Assert::same( ['arg' => 'value', 'arg2' => 'value2'], $url->getQueryParameters() ); +Assert::same('arg=value&arg2=value2', $url->query); +Assert::same(['arg' => 'value', 'arg2' => 'value2'], $url->getQueryParameters()); $url->appendQuery(['arg3' => 'value3']); -Assert::same( 'arg3=value3&arg=value&arg2=value2', $url->query ); +Assert::same('arg3=value3&arg=value&arg2=value2', $url->query); $url->appendQuery('arg4[]=1'); $url->appendQuery('arg4[]=2'); -Assert::same( 'arg3=value3&arg=value&arg2=value2&arg4%5B0%5D=1&arg4%5B1%5D=2', $url->query ); +Assert::same('arg3=value3&arg=value&arg2=value2&arg4%5B0%5D=1&arg4%5B1%5D=2', $url->query); $url->appendQuery('arg4[0]=3'); -Assert::same( 'arg3=value3&arg=value&arg2=value2&arg4%5B0%5D=3&arg4%5B1%5D=2', $url->query ); +Assert::same('arg3=value3&arg=value&arg2=value2&arg4%5B0%5D=3&arg4%5B1%5D=2', $url->query); $url->appendQuery(['arg4' => 4]); -Assert::same( 'arg4=4&arg3=value3&arg=value&arg2=value2', $url->query ); +Assert::same('arg4=4&arg3=value3&arg=value&arg2=value2', $url->query); $url->setQuery(['arg3' => 'value3']); -Assert::same( 'arg3=value3', $url->query ); -Assert::same( ['arg3' => 'value3'], $url->getQueryParameters() ); +Assert::same('arg3=value3', $url->query); +Assert::same(['arg3' => 'value3'], $url->getQueryParameters()); $url->setQuery(['arg' => 'value']); -Assert::same( 'value', $url->getQueryParameter('arg') ); -Assert::same( NULL, $url->getQueryParameter('invalid') ); -Assert::same( 123, $url->getQueryParameter('invalid', 123) ); +Assert::same('value', $url->getQueryParameter('arg')); +Assert::same(NULL, $url->getQueryParameter('invalid')); +Assert::same(123, $url->getQueryParameter('invalid', 123)); $url->setQueryParameter('arg2', 'abc'); -Assert::same( 'abc', $url->getQueryParameter('arg2') ); -Assert::same( ['arg' => 'value', 'arg2' => 'abc'], $url->getQueryParameters() ); +Assert::same('abc', $url->getQueryParameter('arg2')); +Assert::same(['arg' => 'value', 'arg2' => 'abc'], $url->getQueryParameters()); $url->setQueryParameter('arg2', 'def'); -Assert::same( 'def', $url->getQueryParameter('arg2') ); -Assert::same( ['arg' => 'value', 'arg2' => 'def'], $url->getQueryParameters() ); +Assert::same('def', $url->getQueryParameter('arg2')); +Assert::same(['arg' => 'value', 'arg2' => 'def'], $url->getQueryParameters()); $url->setQueryParameter('arg2', NULL); -Assert::same( NULL, $url->getQueryParameter('arg2') ); -Assert::same( ['arg' => 'value', 'arg2' => NULL], $url->getQueryParameters() ); +Assert::same(NULL, $url->getQueryParameter('arg2')); +Assert::same(['arg' => 'value', 'arg2' => NULL], $url->getQueryParameters()); $url = new Url('http://hostname/path?arg=value'); $url->setQuery([NULL]); -Assert::same( 'http://hostname/path', $url->getAbsoluteUrl() ); +Assert::same('http://hostname/path', $url->getAbsoluteUrl()); diff --git a/tests/Http/Url.unescape.phpt b/tests/Http/Url.unescape.phpt index 789f29ee..fed9f83d 100644 --- a/tests/Http/Url.unescape.phpt +++ b/tests/Http/Url.unescape.phpt @@ -11,11 +11,11 @@ use Nette\Http\Url, require __DIR__ . '/../bootstrap.php'; -Assert::same( 'foo + bar', Url::unescape('foo + bar') ); -Assert::same( 'foo + bar', Url::unescape('foo + bar', '') ); -Assert::same( 'foo', Url::unescape('%66%6F%6F', '') ); -Assert::same( 'f%6F%6F', Url::unescape('%66%6F%6F', 'o') ); -Assert::same( '%66oo', Url::unescape('%66%6F%6F', 'f') ); -Assert::same( '%66%6F%6F', Url::unescape('%66%6F%6F', 'fo') ); -Assert::same( '%66%6F%6F', Url::unescape('%66%6f%6f', 'fo') ); -Assert::same( "%00\x01%02", Url::unescape('%00%01%02', "\x00\x02") ); +Assert::same('foo + bar', Url::unescape('foo + bar')); +Assert::same('foo + bar', Url::unescape('foo + bar', '')); +Assert::same('foo', Url::unescape('%66%6F%6F', '')); +Assert::same('f%6F%6F', Url::unescape('%66%6F%6F', 'o')); +Assert::same('%66oo', Url::unescape('%66%6F%6F', 'f')); +Assert::same('%66%6F%6F', Url::unescape('%66%6F%6F', 'fo')); +Assert::same('%66%6F%6F', Url::unescape('%66%6f%6f', 'fo')); +Assert::same("%00\x01%02", Url::unescape('%00%01%02', "\x00\x02")); diff --git a/tests/Http/UrlScript.modify.phpt b/tests/Http/UrlScript.modify.phpt index 04e4fbe4..96d73bf9 100644 --- a/tests/Http/UrlScript.modify.phpt +++ b/tests/Http/UrlScript.modify.phpt @@ -15,9 +15,9 @@ $url = new UrlScript('http://nette.org:8080/file.php?q=search'); $url->path = '/test/'; $url->scriptPath = '/test/index.php'; -Assert::same( '/test/index.php', $url->scriptPath ); -Assert::same( 'http://nette.org:8080/test/', $url->baseUrl ); -Assert::same( '/test/', $url->basePath ); -Assert::same( '?q=search', $url->relativeUrl ); -Assert::same( '', $url->pathInfo ); -Assert::same( 'http://nette.org:8080/test/?q=search', $url->absoluteUrl); +Assert::same('/test/index.php', $url->scriptPath); +Assert::same('http://nette.org:8080/test/', $url->baseUrl); +Assert::same('/test/', $url->basePath); +Assert::same('?q=search', $url->relativeUrl); +Assert::same('', $url->pathInfo); +Assert::same('http://nette.org:8080/test/?q=search', $url->absoluteUrl); diff --git a/tests/Http/UrlScript.parse.phpt b/tests/Http/UrlScript.parse.phpt index fdc6b27f..a28736ff 100644 --- a/tests/Http/UrlScript.parse.phpt +++ b/tests/Http/UrlScript.parse.phpt @@ -12,8 +12,8 @@ require __DIR__ . '/../bootstrap.php'; $url = new UrlScript('http://nette.org:8080/file.php?q=search'); -Assert::same( '/', $url->scriptPath ); -Assert::same( 'http://nette.org:8080/', $url->baseUrl ); -Assert::same( '/', $url->basePath ); -Assert::same( 'file.php?q=search', $url->relativeUrl ); -Assert::same( 'file.php', $url->pathInfo ); +Assert::same('/', $url->scriptPath); +Assert::same('http://nette.org:8080/', $url->baseUrl); +Assert::same('/', $url->basePath); +Assert::same('file.php?q=search', $url->relativeUrl); +Assert::same('file.php', $url->pathInfo);