diff --git a/tests/_support/Commands/AppInfo.php b/tests/_support/Commands/AppInfo.php index e7bf3093e658..efb6d941a953 100644 --- a/tests/_support/Commands/AppInfo.php +++ b/tests/_support/Commands/AppInfo.php @@ -23,12 +23,12 @@ class AppInfo extends BaseCommand protected $arguments = ['draft' => 'unused']; protected $description = 'Displays basic application information.'; - public function run(array $params) + public function run(array $params): void { CLI::write('CI Version: ' . CLI::color(CodeIgniter::CI_VERSION, 'red')); } - public function bomb() + public function bomb(): void { try { CLI::color('test', 'white', 'Background'); @@ -37,7 +37,7 @@ public function bomb() } } - public function helpme() + public function helpme(): void { $this->call('help'); } diff --git a/tests/_support/Commands/InvalidCommand.php b/tests/_support/Commands/InvalidCommand.php index 5b4acf936b08..e69827669290 100644 --- a/tests/_support/Commands/InvalidCommand.php +++ b/tests/_support/Commands/InvalidCommand.php @@ -27,7 +27,7 @@ public function __construct() throw new ReflectionException(); } - public function run(array $params) + public function run(array $params): void { CLI::write('CI Version: ' . CLI::color(CodeIgniter::CI_VERSION, 'red')); } diff --git a/tests/_support/Commands/LanguageCommand.php b/tests/_support/Commands/LanguageCommand.php index e495d250a295..978099e5257f 100644 --- a/tests/_support/Commands/LanguageCommand.php +++ b/tests/_support/Commands/LanguageCommand.php @@ -27,7 +27,7 @@ class LanguageCommand extends BaseCommand '--sort' => 'Turn on/off the sortImports flag.', ]; - public function run(array $params) + public function run(array $params): void { $this->setHasClassName(false); $params[0] = 'Foobar'; diff --git a/tests/_support/Commands/ParamsReveal.php b/tests/_support/Commands/ParamsReveal.php index 76be444e69d1..331c1471611f 100644 --- a/tests/_support/Commands/ParamsReveal.php +++ b/tests/_support/Commands/ParamsReveal.php @@ -21,7 +21,7 @@ class ParamsReveal extends BaseCommand protected $description = 'Reveal params'; public static $args; - public function run(array $params) + public function run(array $params): void { static::$args = $params; } diff --git a/tests/_support/Commands/Unsuffixable.php b/tests/_support/Commands/Unsuffixable.php index 36a752e25891..cf906071d7ef 100644 --- a/tests/_support/Commands/Unsuffixable.php +++ b/tests/_support/Commands/Unsuffixable.php @@ -65,7 +65,7 @@ class Unsuffixable extends BaseCommand /** * Actually execute a command. */ - public function run(array $params) + public function run(array $params): void { $this->component = 'Command'; $this->directory = 'Commands'; diff --git a/tests/_support/Controllers/Popcorn.php b/tests/_support/Controllers/Popcorn.php index 660a405cccc2..2084c3b81713 100644 --- a/tests/_support/Controllers/Popcorn.php +++ b/tests/_support/Controllers/Popcorn.php @@ -33,7 +33,7 @@ public function pop() return $this->respond('Oops', 567, 'Surprise'); } - public function popper() + public function popper(): void { throw new RuntimeException('Surprise', 500); } @@ -61,12 +61,12 @@ public function index3() return $this->response->setJSON(['lang' => $this->request->getLocale()]); } - public function canyon() + public function canyon(): void { echo 'Hello-o-o ' . $this->request->getGet('foo'); } - public function cat() + public function cat(): void { } diff --git a/tests/_support/Database/Migrations/20160428212500_Create_test_tables.php b/tests/_support/Database/Migrations/20160428212500_Create_test_tables.php index ac489ecbb57b..6e3d9be574fa 100644 --- a/tests/_support/Database/Migrations/20160428212500_Create_test_tables.php +++ b/tests/_support/Database/Migrations/20160428212500_Create_test_tables.php @@ -15,7 +15,7 @@ class Migration_Create_test_tables extends Migration { - public function up() + public function up(): void { // User Table $this->forge->addField([ @@ -160,7 +160,7 @@ public function up() } } - public function down() + public function down(): void { $this->forge->dropTable('user', true); $this->forge->dropTable('job', true); diff --git a/tests/_support/Database/Seeds/AnotherSeeder.php b/tests/_support/Database/Seeds/AnotherSeeder.php index aaf7c7e93410..09c9a93d8af8 100644 --- a/tests/_support/Database/Seeds/AnotherSeeder.php +++ b/tests/_support/Database/Seeds/AnotherSeeder.php @@ -15,7 +15,7 @@ class AnotherSeeder extends Seeder { - public function run() + public function run(): void { $row = [ 'name' => 'Jerome Lohan', diff --git a/tests/_support/Database/Seeds/CITestSeeder.php b/tests/_support/Database/Seeds/CITestSeeder.php index 9353578246b5..1749970fe338 100644 --- a/tests/_support/Database/Seeds/CITestSeeder.php +++ b/tests/_support/Database/Seeds/CITestSeeder.php @@ -15,7 +15,7 @@ class CITestSeeder extends Seeder { - public function run() + public function run(): void { // Job Data $data = [ diff --git a/tests/_support/Filters/Customfilter.php b/tests/_support/Filters/Customfilter.php index 7efbb6c0ddb8..6804cacf62b4 100644 --- a/tests/_support/Filters/Customfilter.php +++ b/tests/_support/Filters/Customfilter.php @@ -23,7 +23,7 @@ public function before(RequestInterface $request, $arguments = null) return $request; } - public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) + public function after(RequestInterface $request, ResponseInterface $response, $arguments = null): void { } } diff --git a/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102301_Some_migration.php b/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102301_Some_migration.php index 39eb6e0879cc..e0a34f3eb03c 100644 --- a/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102301_Some_migration.php +++ b/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102301_Some_migration.php @@ -13,7 +13,7 @@ class Migration_some_migration extends \CodeIgniter\Database\Migration { - public function up() + public function up(): void { $this->forge->addField([ 'key' => [ @@ -28,7 +28,7 @@ public function up() ]); } - public function down() + public function down(): void { $this->forge->dropTable('foo', true); } diff --git a/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102302_Another_migration.php b/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102302_Another_migration.php index f1606eff56e1..0006da2a347d 100644 --- a/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102302_Another_migration.php +++ b/tests/_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102302_Another_migration.php @@ -13,7 +13,7 @@ class Migration_another_migration extends \CodeIgniter\Database\Migration { - public function up() + public function up(): void { $fields = [ 'value' => [ @@ -29,7 +29,7 @@ public function up() ]); } - public function down() + public function down(): void { if ($this->db->tableExists('foo')) { $this->forge->dropColumn('foo', 'value'); diff --git a/tests/_support/Publishers/TestPublisher.php b/tests/_support/Publishers/TestPublisher.php index 95d9fa72c250..0e3b67ab23a5 100644 --- a/tests/_support/Publishers/TestPublisher.php +++ b/tests/_support/Publishers/TestPublisher.php @@ -39,7 +39,7 @@ final class TestPublisher extends Publisher /** * Fakes an error on the given file. */ - public static function setResult(bool $result) + public static function setResult(bool $result): void { self::$result = $result; } diff --git a/tests/_support/View/Cells/AdditionCell.php b/tests/_support/View/Cells/AdditionCell.php index aaa89a6560cb..0b5b8a5ddc74 100644 --- a/tests/_support/View/Cells/AdditionCell.php +++ b/tests/_support/View/Cells/AdditionCell.php @@ -17,7 +17,7 @@ class AdditionCell extends Cell { public int $value = 2; - public function mount(?int $number = null, bool $skipAddition = false) + public function mount(?int $number = null, bool $skipAddition = false): void { $this->value = ! $skipAddition ? $this->value + (int) $number diff --git a/tests/_support/View/SampleClassWithInitController.php b/tests/_support/View/SampleClassWithInitController.php index 32eb4f70a7a3..8b12326c5b58 100644 --- a/tests/_support/View/SampleClassWithInitController.php +++ b/tests/_support/View/SampleClassWithInitController.php @@ -25,7 +25,7 @@ class SampleClassWithInitController { private ResponseInterface $response; - public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) + public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger): void { $this->response = $response; } diff --git a/tests/system/API/ResponseTraitTest.php b/tests/system/API/ResponseTraitTest.php index b8a522da86dd..693eff53f33d 100644 --- a/tests/system/API/ResponseTraitTest.php +++ b/tests/system/API/ResponseTraitTest.php @@ -95,14 +95,14 @@ public function __construct(&$request, &$response, &$formatter) $this->formatter = $formatter; } - public function resetFormatter() + public function resetFormatter(): void { $this->formatter = null; } }; } - public function testNoFormatterJSON() + public function testNoFormatterJSON(): void { $this->formatter = null; $controller = $this->makeController([], 'http://codeigniter.com', ['Accept' => 'application/json']); @@ -120,7 +120,7 @@ public function testNoFormatterJSON() $this->assertSame($expected, $this->response->getBody()); } - public function testNoFormatter() + public function testNoFormatter(): void { $this->formatter = null; $controller = $this->makeController([], 'http://codeigniter.com', ['Accept' => 'application/json']); @@ -130,7 +130,7 @@ public function testNoFormatter() $this->assertSame('A Custom Reason', $this->response->getBody()); } - public function testAssociativeArrayPayload() + public function testAssociativeArrayPayload(): void { $this->formatter = null; $controller = $this->makeController(); @@ -146,7 +146,7 @@ public function testAssociativeArrayPayload() $this->assertSame($expected, $this->response->getBody()); } - public function testArrayPayload() + public function testArrayPayload(): void { $this->formatter = null; $controller = $this->makeController(); @@ -168,7 +168,7 @@ public function testArrayPayload() $this->assertSame($expected, $this->response->getBody()); } - public function testPHPtoArrayPayload() + public function testPHPtoArrayPayload(): void { $this->formatter = null; $controller = $this->makeController(); @@ -187,7 +187,7 @@ public function testPHPtoArrayPayload() $this->assertSame($expected, $this->response->getBody()); } - public function testRespondSets404WithNoData() + public function testRespondSets404WithNoData(): void { $controller = $this->makeController(); @@ -197,7 +197,7 @@ public function testRespondSets404WithNoData() $this->assertNull($this->response->getBody()); } - public function testRespondSetsStatusWithEmptyData() + public function testRespondSetsStatusWithEmptyData(): void { $controller = $this->makeController(); @@ -207,7 +207,7 @@ public function testRespondSetsStatusWithEmptyData() $this->assertNull($this->response->getBody()); } - public function testRespondSetsCorrectBodyAndStatus() + public function testRespondSetsCorrectBodyAndStatus(): void { $controller = $this->makeController(); @@ -219,7 +219,7 @@ public function testRespondSetsCorrectBodyAndStatus() $this->assertSame('Created', $this->response->getReason()); } - public function testRespondWithCustomReason() + public function testRespondWithCustomReason(): void { $controller = $this->makeController(); @@ -229,7 +229,7 @@ public function testRespondWithCustomReason() $this->assertSame('A Custom Reason', $this->response->getReason()); } - public function testFailSingleMessage() + public function testFailSingleMessage(): void { $controller = $this->makeController(); @@ -248,7 +248,7 @@ public function testFailSingleMessage() $this->assertSame('A Custom Reason', $this->response->getReason()); } - public function testCreated() + public function testCreated(): void { $controller = $this->makeController(); @@ -259,7 +259,7 @@ public function testCreated() $this->assertSame($this->formatter->format(['id' => 3]), $this->response->getBody()); } - public function testDeleted() + public function testDeleted(): void { $controller = $this->makeController(); @@ -270,7 +270,7 @@ public function testDeleted() $this->assertSame($this->formatter->format(['id' => 3]), $this->response->getBody()); } - public function testUpdated() + public function testUpdated(): void { $controller = $this->makeController(); @@ -281,7 +281,7 @@ public function testUpdated() $this->assertSame($this->formatter->format(['id' => 3]), $this->response->getBody()); } - public function testUnauthorized() + public function testUnauthorized(): void { $controller = $this->makeController(); @@ -299,7 +299,7 @@ public function testUnauthorized() $this->assertSame($this->formatter->format($expected), $this->response->getBody()); } - public function testForbidden() + public function testForbidden(): void { $controller = $this->makeController(); @@ -317,7 +317,7 @@ public function testForbidden() $this->assertSame($this->formatter->format($expected), $this->response->getBody()); } - public function testNoContent() + public function testNoContent(): void { $controller = $this->makeController(); @@ -328,7 +328,7 @@ public function testNoContent() $this->assertSame(204, $this->response->getStatusCode()); } - public function testNotFound() + public function testNotFound(): void { $controller = $this->makeController(); @@ -346,7 +346,7 @@ public function testNotFound() $this->assertSame($this->formatter->format($expected), $this->response->getBody()); } - public function testValidationError() + public function testValidationError(): void { $controller = $this->makeController(); @@ -364,7 +364,7 @@ public function testValidationError() $this->assertSame($this->formatter->format($expected), $this->response->getBody()); } - public function testValidationErrors() + public function testValidationErrors(): void { $controller = $this->makeController(); @@ -383,7 +383,7 @@ public function testValidationErrors() $this->assertSame($this->formatter->format($expected), $this->response->getBody()); } - public function testResourceExists() + public function testResourceExists(): void { $controller = $this->makeController(); @@ -401,7 +401,7 @@ public function testResourceExists() $this->assertSame($this->formatter->format($expected), $this->response->getBody()); } - public function testResourceGone() + public function testResourceGone(): void { $controller = $this->makeController(); @@ -419,7 +419,7 @@ public function testResourceGone() $this->assertSame($this->formatter->format($expected), $this->response->getBody()); } - public function testTooManyRequests() + public function testTooManyRequests(): void { $controller = $this->makeController(); @@ -437,7 +437,7 @@ public function testTooManyRequests() $this->assertSame($this->formatter->format($expected), $this->response->getBody()); } - public function testServerError() + public function testServerError(): void { $controller = $this->makeController(); @@ -454,7 +454,7 @@ public function testServerError() ]), $this->response->getBody()); } - public function testValidContentTypes() + public function testValidContentTypes(): void { $chars = '; charset=UTF-8'; $goodMimes = [ @@ -469,7 +469,7 @@ public function testValidContentTypes() } } - private function tryValidContentType($mimeType, $contentType) + private function tryValidContentType($mimeType, $contentType): void { $original = $_SERVER; $_SERVER['CONTENT_TYPE'] = $mimeType; @@ -482,7 +482,7 @@ private function tryValidContentType($mimeType, $contentType) $_SERVER = $original; } - public function testValidResponses() + public function testValidResponses(): void { $chars = '; charset=UTF-8'; $goodMimes = [ @@ -497,7 +497,7 @@ public function testValidResponses() } } - public function testXMLFormatter() + public function testXMLFormatter(): void { $this->formatter = new XMLFormatter(); $controller = $this->makeController(); @@ -514,7 +514,7 @@ public function testXMLFormatter() $this->assertSame($expected, $this->response->getBody()); } - public function testFormatByRequestNegotiateIfFormatIsNotJsonOrXML() + public function testFormatByRequestNegotiateIfFormatIsNotJsonOrXML(): void { $config = new App(); @@ -559,7 +559,7 @@ public function __construct(&$request, &$response) $this->assertStringStartsWith(config('Format')->supportedResponseFormats[0], $response->getHeaderLine('Content-Type')); } - public function testResponseFormat() + public function testResponseFormat(): void { $data = ['foo' => 'something']; $controller = $this->makeController(); @@ -576,7 +576,7 @@ public function testResponseFormat() $this->assertStringStartsWith('application/xml', $this->response->getHeaderLine('Content-Type')); } - public function testXMLResponseFormat() + public function testXMLResponseFormat(): void { $data = ['foo' => 'bar']; $controller = $this->makeController(); diff --git a/tests/system/Autoloader/AutoloaderTest.php b/tests/system/Autoloader/AutoloaderTest.php index bfe7a0fac8da..a116bc9515d6 100644 --- a/tests/system/Autoloader/AutoloaderTest.php +++ b/tests/system/Autoloader/AutoloaderTest.php @@ -59,12 +59,12 @@ protected function tearDown(): void parent::tearDown(); } - public function testLoadStoredClass() + public function testLoadStoredClass(): void { $this->assertInstanceOf('UnnamespacedClass', new UnnamespacedClass()); } - public function testInitializeWithInvalidArguments() + public function testInitializeWithInvalidArguments(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Config array must contain either the 'psr4' key or the 'classmap' key."); @@ -78,7 +78,7 @@ public function testInitializeWithInvalidArguments() (new Autoloader())->initialize($config, $modules); } - public function testInitializeTwice() + public function testInitializeTwice(): void { $loader = new Autoloader(); $loader->initialize(new Autoload(), new Modules()); @@ -94,7 +94,7 @@ public function testInitializeTwice() $this->assertSame('ROOTPATH/app', clean_path($ns['App'][0])); } - public function testServiceAutoLoaderFromShareInstances() + public function testServiceAutoLoaderFromShareInstances(): void { $autoloader = Services::autoloader(); // look for Home controller, as that should be in base repo @@ -103,7 +103,7 @@ public function testServiceAutoLoaderFromShareInstances() $this->assertSame($expected, realpath($actual) ?: $actual); } - public function testServiceAutoLoader() + public function testServiceAutoLoader(): void { $autoloader = Services::autoloader(false); $autoloader->initialize(new Autoload(), new Modules()); @@ -117,7 +117,7 @@ public function testServiceAutoLoader() $autoloader->unregister(); } - public function testExistingFile() + public function testExistingFile(): void { $actual = $this->loader->loadClass(Home::class); $expected = APPPATH . 'Controllers' . DIRECTORY_SEPARATOR . 'Home.php'; @@ -128,26 +128,26 @@ public function testExistingFile() $this->assertSame($expected, $actual); } - public function testMatchesWithPrecedingSlash() + public function testMatchesWithPrecedingSlash(): void { $actual = $this->loader->loadClass(Home::class); $expected = APPPATH . 'Controllers' . DIRECTORY_SEPARATOR . 'Home.php'; $this->assertSame($expected, $actual); } - public function testMatchesWithFileExtension() + public function testMatchesWithFileExtension(): void { $actual = $this->loader->loadClass('\App\Controllers\Home.php'); $expected = APPPATH . 'Controllers' . DIRECTORY_SEPARATOR . 'Home.php'; $this->assertSame($expected, $actual); } - public function testMissingFile() + public function testMissingFile(): void { $this->assertFalse($this->loader->loadClass('\App\Missing\Classname')); } - public function testAddNamespaceWorks() + public function testAddNamespaceWorks(): void { $this->assertFalse($this->loader->loadClass('My\App\Class')); @@ -159,7 +159,7 @@ public function testAddNamespaceWorks() $this->assertSame($expected, $actual); } - public function testAddNamespaceMultiplePathsWorks() + public function testAddNamespaceMultiplePathsWorks(): void { $this->loader->addNamespace([ 'My\App' => [ @@ -177,7 +177,7 @@ public function testAddNamespaceMultiplePathsWorks() $this->assertSame($expected, $actual); } - public function testAddNamespaceStringToArray() + public function testAddNamespaceStringToArray(): void { $this->loader->addNamespace('App\Controllers', __DIR__); @@ -187,7 +187,7 @@ public function testAddNamespaceStringToArray() ); } - public function testGetNamespaceGivesArray() + public function testGetNamespaceGivesArray(): void { $this->assertSame([ 'App' => [APPPATH], @@ -198,7 +198,7 @@ public function testGetNamespaceGivesArray() $this->assertSame([], $this->loader->getNamespace('Foo')); } - public function testRemoveNamespace() + public function testRemoveNamespace(): void { $this->loader->addNamespace('My\App', __DIR__); $this->assertSame(__FILE__, $this->loader->loadClass('My\App\AutoloaderTest')); @@ -207,12 +207,12 @@ public function testRemoveNamespace() $this->assertFalse((bool) $this->loader->loadClass('My\App\AutoloaderTest')); } - public function testloadClassNonNamespaced() + public function testloadClassNonNamespaced(): void { $this->assertFalse($this->loader->loadClass('Modules')); } - public function testSanitizationContailsSpecialChars() + public function testSanitizationContailsSpecialChars(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage( @@ -224,7 +224,7 @@ public function testSanitizationContailsSpecialChars() $this->loader->sanitizeFilename($test); } - public function testSanitizationFilenameEdges() + public function testSanitizationFilenameEdges(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage( @@ -236,7 +236,7 @@ public function testSanitizationFilenameEdges() $this->loader->sanitizeFilename($test); } - public function testSanitizationRegexError() + public function testSanitizationRegexError(): void { $this->expectException(RuntimeException::class); @@ -245,21 +245,21 @@ public function testSanitizationRegexError() $this->loader->sanitizeFilename($test); } - public function testSanitizationAllowUnicodeChars() + public function testSanitizationAllowUnicodeChars(): void { $test = 'Ä/path/to/some/file.php'; $this->assertSame($test, $this->loader->sanitizeFilename($test)); } - public function testSanitizationAllowsWindowsFilepaths() + public function testSanitizationAllowsWindowsFilepaths(): void { $test = 'C:\path\to\some/file.php'; $this->assertSame($test, $this->loader->sanitizeFilename($test)); } - public function testFindsComposerRoutes() + public function testFindsComposerRoutes(): void { $config = new Autoload(); $modules = new Modules(); @@ -272,7 +272,7 @@ public function testFindsComposerRoutes() $this->assertArrayHasKey('Laminas\\Escaper', $namespaces); } - public function testComposerNamespaceDoesNotOverwriteConfigAutoloadPsr4() + public function testComposerNamespaceDoesNotOverwriteConfigAutoloadPsr4(): void { $config = new Autoload(); $config->psr4 = [ @@ -289,7 +289,7 @@ public function testComposerNamespaceDoesNotOverwriteConfigAutoloadPsr4() $this->assertStringContainsString(VENDORPATH, $namespaces['Psr\Log'][1]); } - public function testComposerPackagesOnly() + public function testComposerPackagesOnly(): void { $config = new Autoload(); $config->psr4 = []; @@ -306,7 +306,7 @@ public function testComposerPackagesOnly() $this->assertStringContainsString(VENDORPATH, $namespaces['Laminas\Escaper'][0]); } - public function testComposerPackagesExclude() + public function testComposerPackagesExclude(): void { $config = new Autoload(); $config->psr4 = []; @@ -328,7 +328,7 @@ public function testComposerPackagesExclude() $this->assertArrayNotHasKey('Laminas\\Escaper', $namespaces); } - public function testComposerPackagesOnlyAndExclude() + public function testComposerPackagesOnlyAndExclude(): void { $this->expectException(ConfigException::class); $this->expectExceptionMessage('Cannot use "only" and "exclude" at the same time in "Config\Modules::$composerPackages".'); @@ -346,7 +346,7 @@ public function testComposerPackagesOnlyAndExclude() $loader->initialize($config, $modules); } - public function testFindsComposerRoutesWithComposerPathNotFound() + public function testFindsComposerRoutesWithComposerPathNotFound(): void { $composerPath = COMPOSER_PATH; diff --git a/tests/system/Autoloader/FileLocatorTest.php b/tests/system/Autoloader/FileLocatorTest.php index fc5f56a66d3b..1cf32cfa5ad1 100644 --- a/tests/system/Autoloader/FileLocatorTest.php +++ b/tests/system/Autoloader/FileLocatorTest.php @@ -51,7 +51,7 @@ protected function setUp(): void $this->locator = new FileLocator($autoloader); } - public function testLocateFileNotNamespacedFindsInAppDirectory() + public function testLocateFileNotNamespacedFindsInAppDirectory(): void { $file = 'Controllers/Home'; // not namespaced @@ -60,14 +60,14 @@ public function testLocateFileNotNamespacedFindsInAppDirectory() $this->assertSame($expected, $this->locator->locateFile($file)); } - public function testLocateFileNotNamespacedNotFound() + public function testLocateFileNotNamespacedNotFound(): void { $file = 'Unknown'; // not namespaced $this->assertFalse($this->locator->locateFile($file)); } - public function testLocateFileNotNamespacedFindsWithFolderInAppDirectory() + public function testLocateFileNotNamespacedFindsWithFolderInAppDirectory(): void { $file = 'welcome_message'; // not namespaced @@ -76,7 +76,7 @@ public function testLocateFileNotNamespacedFindsWithFolderInAppDirectory() $this->assertSame($expected, $this->locator->locateFile($file, 'Views')); } - public function testLocateFileNotNamespacedFindesWithoutFolderInAppDirectory() + public function testLocateFileNotNamespacedFindesWithoutFolderInAppDirectory(): void { $file = 'Common'; // not namespaced @@ -85,7 +85,7 @@ public function testLocateFileNotNamespacedFindesWithoutFolderInAppDirectory() $this->assertSame($expected, $this->locator->locateFile($file)); } - public function testLocateFileNotNamespacedWorksInNestedAppDirectory() + public function testLocateFileNotNamespacedWorksInNestedAppDirectory(): void { $file = 'Controllers/Home'; // not namespaced @@ -95,7 +95,7 @@ public function testLocateFileNotNamespacedWorksInNestedAppDirectory() $this->assertSame($expected, $this->locator->locateFile($file, 'Controllers')); } - public function testLocateFileWithFolderNameInFile() + public function testLocateFileWithFolderNameInFile(): void { $file = '\App\Views/errors/html/error_404.php'; @@ -105,7 +105,7 @@ public function testLocateFileWithFolderNameInFile() $this->assertSame($expected, $this->locator->locateFile($file, 'Views')); } - public function testLocateFileNotNamespacedWithFolderNameInFile() + public function testLocateFileNotNamespacedWithFolderNameInFile(): void { $file = 'Views/welcome_message.php'; // not namespaced @@ -115,7 +115,7 @@ public function testLocateFileNotNamespacedWithFolderNameInFile() $this->assertSame($expected, $this->locator->locateFile($file, 'Views')); } - public function testLocateFileCanFindNamespacedView() + public function testLocateFileCanFindNamespacedView(): void { $file = '\Errors\error_404'; @@ -125,7 +125,7 @@ public function testLocateFileCanFindNamespacedView() $this->assertSame($expected, $this->locator->locateFile($file, 'html')); } - public function testLocateFileCanFindNestedNamespacedView() + public function testLocateFileCanFindNestedNamespacedView(): void { $file = '\Errors\html/error_404'; @@ -134,7 +134,7 @@ public function testLocateFileCanFindNestedNamespacedView() $this->assertSame($expected, $this->locator->locateFile($file, 'html')); } - public function testLocateFileCanFindNamespacedViewWhenVendorHasTwoNamespaces() + public function testLocateFileCanFindNamespacedViewWhenVendorHasTwoNamespaces(): void { $file = '\CodeIgniter\Devkit\View\Views/simple'; @@ -143,21 +143,21 @@ public function testLocateFileCanFindNamespacedViewWhenVendorHasTwoNamespaces() $this->assertSame($expected, $this->locator->locateFile($file, 'Views')); } - public function testLocateFileNotFoundExistingNamespace() + public function testLocateFileNotFoundExistingNamespace(): void { $file = '\App\Views/unexistence-file.php'; $this->assertFalse($this->locator->locateFile($file, 'Views')); } - public function testLocateFileNotFoundWithBadNamespace() + public function testLocateFileNotFoundWithBadNamespace(): void { $file = '\Blogger\admin/posts.php'; $this->assertFalse($this->locator->locateFile($file, 'Views')); } - public function testLocateFileWithProperNamespace() + public function testLocateFileWithProperNamespace(): void { $file = 'Acme\SampleProject\View\Views\simple'; @@ -166,7 +166,7 @@ public function testLocateFileWithProperNamespace() $this->assertSame($expected, $this->locator->locateFile($file, 'Views')); } - public function testSearchSimple() + public function testSearchSimple(): void { $expected = APPPATH . 'Config/App.php'; @@ -175,7 +175,7 @@ public function testSearchSimple() $this->assertSame($expected, $foundFiles[0]); } - public function testSearchWithFileExtension() + public function testSearchWithFileExtension(): void { $expected = APPPATH . 'Config/App.php'; @@ -184,7 +184,7 @@ public function testSearchWithFileExtension() $this->assertSame($expected, $foundFiles[0]); } - public function testSearchWithMultipleFilesFound() + public function testSearchWithMultipleFilesFound(): void { $foundFiles = $this->locator->search('index', 'html'); @@ -195,14 +195,14 @@ public function testSearchWithMultipleFilesFound() $this->assertContains($expected, $foundFiles); } - public function testSearchForFileNotExist() + public function testSearchForFileNotExist(): void { $foundFiles = $this->locator->search('Views/Fake.html'); $this->assertArrayNotHasKey(0, $foundFiles); } - public function testSearchPrioritizeSystemOverApp() + public function testSearchPrioritizeSystemOverApp(): void { $foundFiles = $this->locator->search('Language/en/Validation.php', 'php', false); @@ -215,12 +215,12 @@ public function testSearchPrioritizeSystemOverApp() ); } - public function testListNamespaceFilesEmptyPrefixAndPath() + public function testListNamespaceFilesEmptyPrefixAndPath(): void { $this->assertEmpty($this->locator->listNamespaceFiles('', '')); } - public function testListFilesSimple() + public function testListFilesSimple(): void { $files = $this->locator->listFiles('Config/'); @@ -229,7 +229,7 @@ public function testListFilesSimple() $this->assertTrue(in_array($expectedWin, $files, true) || in_array($expectedLin, $files, true)); } - public function testListFilesDoesNotContainDirectories() + public function testListFilesDoesNotContainDirectories(): void { $files = $this->locator->listFiles('Config/'); @@ -241,14 +241,14 @@ public function testListFilesDoesNotContainDirectories() $this->assertNotContains($directory, $files); } - public function testListFilesWithFileAsInput() + public function testListFilesWithFileAsInput(): void { $files = $this->locator->listFiles('Config/App.php'); $this->assertEmpty($files); } - public function testListFilesFromMultipleDir() + public function testListFilesFromMultipleDir(): void { $files = $this->locator->listFiles('Filters/'); @@ -261,21 +261,21 @@ public function testListFilesFromMultipleDir() $this->assertTrue(in_array($expectedWin, $files, true) || in_array($expectedLin, $files, true)); } - public function testListFilesWithPathNotExist() + public function testListFilesWithPathNotExist(): void { $files = $this->locator->listFiles('Fake/'); $this->assertEmpty($files); } - public function testListFilesWithoutPath() + public function testListFilesWithoutPath(): void { $files = $this->locator->listFiles(''); $this->assertEmpty($files); } - public function testFindQNameFromPathSimple() + public function testFindQNameFromPathSimple(): void { $ClassName = $this->locator->findQualifiedNameFromPath(SYSTEMPATH . 'HTTP/Header.php'); $expected = '\\' . Header::class; @@ -283,21 +283,21 @@ public function testFindQNameFromPathSimple() $this->assertSame($expected, $ClassName); } - public function testFindQNameFromPathWithFileNotExist() + public function testFindQNameFromPathWithFileNotExist(): void { $ClassName = $this->locator->findQualifiedNameFromPath('modules/blog/Views/index.php'); $this->assertFalse($ClassName); } - public function testFindQNameFromPathWithoutCorrespondingNamespace() + public function testFindQNameFromPathWithoutCorrespondingNamespace(): void { $ClassName = $this->locator->findQualifiedNameFromPath('/etc/hosts'); $this->assertFalse($ClassName); } - public function testGetClassNameFromClassFile() + public function testGetClassNameFromClassFile(): void { $this->assertSame( self::class, @@ -305,7 +305,7 @@ public function testGetClassNameFromClassFile() ); } - public function testGetClassNameFromNonClassFile() + public function testGetClassNameFromNonClassFile(): void { $this->assertSame( '', diff --git a/tests/system/CLI/CLITest.php b/tests/system/CLI/CLITest.php index 3068328aa9a8..e02db8d97515 100644 --- a/tests/system/CLI/CLITest.php +++ b/tests/system/CLI/CLITest.php @@ -26,21 +26,21 @@ final class CLITest extends CIUnitTestCase { use StreamFilterTrait; - public function testNew() + public function testNew(): void { $actual = new CLI(); $this->assertInstanceOf(CLI::class, $actual); } - public function testBeep() + public function testBeep(): void { $this->expectOutputString("\x07"); CLI::beep(); } - public function testBeep4() + public function testBeep4(): void { $this->expectOutputString("\x07\x07\x07\x07"); @@ -53,7 +53,7 @@ public function testBeep4() * * @timeLimit 2.5 */ - public function testWait() + public function testWait(): void { $time = time(); CLI::wait(1, true); @@ -64,7 +64,7 @@ public function testWait() $this->assertCloseEnough(1, time() - $time); } - public function testWaitZero() + public function testWaitZero(): void { PhpStreamWrapper::register(); PhpStreamWrapper::setContent(' '); @@ -78,7 +78,7 @@ public function testWaitZero() PhpStreamWrapper::restore(); } - public function testPrompt() + public function testPrompt(): void { PhpStreamWrapper::register(); @@ -92,7 +92,7 @@ public function testPrompt() PhpStreamWrapper::restore(); } - public function testPromptByMultipleKeys() + public function testPromptByMultipleKeys(): void { PhpStreamWrapper::register(); @@ -112,14 +112,14 @@ public function testPromptByMultipleKeys() PhpStreamWrapper::restore(); } - public function testNewLine() + public function testNewLine(): void { $this->expectOutputString(''); CLI::newLine(); } - public function testColorExceptionForeground() + public function testColorExceptionForeground(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Invalid "foreground" color: "Foreground"'); @@ -127,7 +127,7 @@ public function testColorExceptionForeground() CLI::color('test', 'Foreground'); } - public function testColorExceptionBackground() + public function testColorExceptionBackground(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Invalid "background" color: "Background"'); @@ -135,7 +135,7 @@ public function testColorExceptionBackground() CLI::color('test', 'white', 'Background'); } - public function testColorSupportOnNoColor() + public function testColorSupportOnNoColor(): void { $nocolor = getenv('NO_COLOR'); putenv('NO_COLOR=1'); @@ -146,7 +146,7 @@ public function testColorSupportOnNoColor() putenv($nocolor ? "NO_COLOR={$nocolor}" : 'NO_COLOR'); } - public function testColorSupportOnHyperTerminals() + public function testColorSupportOnHyperTerminals(): void { $termProgram = getenv('TERM_PROGRAM'); putenv('TERM_PROGRAM=Hyper'); @@ -157,13 +157,13 @@ public function testColorSupportOnHyperTerminals() putenv($termProgram ? "TERM_PROGRAM={$termProgram}" : 'TERM_PROGRAM'); } - public function testStreamSupports() + public function testStreamSupports(): void { $this->assertTrue(CLI::streamSupports('stream_isatty', STDOUT)); $this->assertIsBool(CLI::streamSupports('sapi_windows_vt100_support', STDOUT)); } - public function testColor() + public function testColor(): void { // After the tests on NO_COLOR and TERM_PROGRAM above, // the $isColored variable is rigged. So we reset this. @@ -175,7 +175,7 @@ public function testColor() ); } - public function testColorEmtpyString() + public function testColorEmtpyString(): void { $this->assertSame( '', @@ -183,7 +183,7 @@ public function testColorEmtpyString() ); } - public function testPrint() + public function testPrint(): void { CLI::print('test'); @@ -191,7 +191,7 @@ public function testPrint() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testPrintForeground() + public function testPrintForeground(): void { CLI::print('test', 'red'); @@ -199,7 +199,7 @@ public function testPrintForeground() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testPrintBackground() + public function testPrintBackground(): void { CLI::print('test', 'red', 'green'); @@ -207,7 +207,7 @@ public function testPrintBackground() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testWrite() + public function testWrite(): void { CLI::write('test'); @@ -215,7 +215,7 @@ public function testWrite() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testWriteForeground() + public function testWriteForeground(): void { CLI::write('test', 'red'); @@ -223,7 +223,7 @@ public function testWriteForeground() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testWriteForegroundWithColorBefore() + public function testWriteForegroundWithColorBefore(): void { CLI::write(CLI::color('green', 'green') . ' red', 'red'); @@ -231,7 +231,7 @@ public function testWriteForegroundWithColorBefore() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testWriteForegroundWithColorAfter() + public function testWriteForegroundWithColorAfter(): void { CLI::write('red ' . CLI::color('green', 'green'), 'red'); @@ -242,7 +242,7 @@ public function testWriteForegroundWithColorAfter() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/5892 */ - public function testWriteForegroundWithColorTwice() + public function testWriteForegroundWithColorTwice(): void { CLI::write( CLI::color('green', 'green') . ' red ' . CLI::color('green', 'green'), @@ -253,7 +253,7 @@ public function testWriteForegroundWithColorTwice() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testWriteBackground() + public function testWriteBackground(): void { CLI::write('test', 'red', 'green'); @@ -261,7 +261,7 @@ public function testWriteBackground() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testError() + public function testError(): void { CLI::error('test'); @@ -270,7 +270,7 @@ public function testError() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testErrorForeground() + public function testErrorForeground(): void { CLI::error('test', 'purple'); @@ -278,7 +278,7 @@ public function testErrorForeground() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testErrorBackground() + public function testErrorBackground(): void { CLI::error('test', 'purple', 'green'); @@ -286,7 +286,7 @@ public function testErrorBackground() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testShowProgress() + public function testShowProgress(): void { CLI::write('first.'); CLI::showProgress(1, 20); @@ -312,7 +312,7 @@ public function testShowProgress() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testShowProgressWithoutBar() + public function testShowProgressWithoutBar(): void { CLI::write('first.'); CLI::showProgress(false, 20); @@ -323,7 +323,7 @@ public function testShowProgressWithoutBar() $this->assertSame($expected, $this->getStreamFilterBuffer()); } - public function testWrap() + public function testWrap(): void { $this->assertSame('', CLI::wrap('')); $this->assertSame( @@ -340,7 +340,7 @@ public function testWrap() ); } - public function testParseCommand() + public function testParseCommand(): void { $_SERVER['argv'] = [ 'ignored', @@ -359,7 +359,7 @@ public function testParseCommand() $this->assertSame(['b', 'c'], CLI::getSegments()); } - public function testParseCommandMixed() + public function testParseCommandMixed(): void { $_SERVER['argv'] = [ 'ignored', @@ -388,7 +388,7 @@ public function testParseCommandMixed() $this->assertSame('--parm pvalue --fix --opt-in sure', CLI::getOptionString(true, true)); } - public function testParseCommandOption() + public function testParseCommandOption(): void { $_SERVER['argv'] = [ 'ignored', @@ -410,7 +410,7 @@ public function testParseCommandOption() $this->assertSame(['b', 'c', 'd'], CLI::getSegments()); } - public function testParseCommandMultipleOptions() + public function testParseCommandMultipleOptions(): void { $_SERVER['argv'] = [ 'ignored', @@ -434,7 +434,7 @@ public function testParseCommandMultipleOptions() $this->assertSame(['b', 'c', 'd'], CLI::getSegments()); } - public function testWindow() + public function testWindow(): void { $height = new ReflectionProperty(CLI::class, 'height'); $height->setAccessible(true); @@ -456,7 +456,7 @@ public function testWindow() * @param array $thead * @param array $expected */ - public function testTable($tbody, $thead, $expected) + public function testTable($tbody, $thead, $expected): void { CLI::table($tbody, $thead); @@ -548,7 +548,7 @@ public function tableProvider(): iterable ]; } - public function testStrlen() + public function testStrlen(): void { $this->assertSame(18, mb_strlen(CLI::color('success', 'green'))); $this->assertSame(7, CLI::strlen(CLI::color('success', 'green'))); diff --git a/tests/system/CLI/ConsoleTest.php b/tests/system/CLI/ConsoleTest.php index ec1198287906..78bc5415b8ed 100644 --- a/tests/system/CLI/ConsoleTest.php +++ b/tests/system/CLI/ConsoleTest.php @@ -45,7 +45,7 @@ protected function setUp(): void $this->app->initialize(); } - public function testHeader() + public function testHeader(): void { $console = new Console(); $console->showHeader(); @@ -58,14 +58,14 @@ public function testHeader() ); } - public function testNoHeader() + public function testNoHeader(): void { $console = new Console(); $console->showHeader(true); $this->assertSame('', $this->getStreamFilterBuffer()); } - public function testRun() + public function testRun(): void { $this->initCLI(); @@ -77,7 +77,7 @@ public function testRun() $this->assertStringContainsString('Displays basic usage information.', $this->getStreamFilterBuffer()); } - public function testBadCommand() + public function testBadCommand(): void { $this->initCLI('bogus'); @@ -88,7 +88,7 @@ public function testBadCommand() $this->assertStringContainsString('Command "bogus" not found', $this->getStreamFilterBuffer()); } - public function testHelpCommandDetails() + public function testHelpCommandDetails(): void { $this->initCLI('help', 'session:migration'); @@ -101,7 +101,7 @@ public function testHelpCommandDetails() $this->assertStringContainsString('Options:', $this->getStreamFilterBuffer()); } - public function testHelpCommandUsingHelpOption() + public function testHelpCommandUsingHelpOption(): void { $this->initCLI('env', '--help'); @@ -114,7 +114,7 @@ public function testHelpCommandUsingHelpOption() ); } - public function testHelpOptionIsOnlyPassed() + public function testHelpOptionIsOnlyPassed(): void { $this->initCLI('--help'); @@ -125,7 +125,7 @@ public function testHelpOptionIsOnlyPassed() $this->assertStringContainsString('Lists the available commands.', $this->getStreamFilterBuffer()); } - public function testHelpArgumentAndHelpOptionCombined() + public function testHelpArgumentAndHelpOptionCombined(): void { $this->initCLI('help', '--help'); diff --git a/tests/system/Cache/CacheFactoryTest.php b/tests/system/Cache/CacheFactoryTest.php index 3b1288c157bd..1ca778b28faa 100644 --- a/tests/system/Cache/CacheFactoryTest.php +++ b/tests/system/Cache/CacheFactoryTest.php @@ -46,12 +46,12 @@ protected function tearDown(): void } } - public function testNew() + public function testNew(): void { $this->assertInstanceOf(CacheFactory::class, $this->cacheFactory); } - public function testGetHandlerExceptionCacheInvalidHandlers() + public function testGetHandlerExceptionCacheInvalidHandlers(): void { $this->expectException(CacheException::class); $this->expectExceptionMessage('Cache config must have an array of $validHandlers.'); @@ -61,7 +61,7 @@ public function testGetHandlerExceptionCacheInvalidHandlers() $this->cacheFactory->getHandler($this->config); } - public function testGetHandlerExceptionCacheHandlerNotFound() + public function testGetHandlerExceptionCacheHandlerNotFound(): void { $this->expectException(CacheException::class); $this->expectExceptionMessage('Cache config has an invalid handler or backup handler specified.'); @@ -71,7 +71,7 @@ public function testGetHandlerExceptionCacheHandlerNotFound() $this->cacheFactory->getHandler($this->config); } - public function testGetDummyHandler() + public function testGetDummyHandler(): void { if (! is_dir($this->config->storePath)) { mkdir($this->config->storePath, 0555, true); @@ -86,7 +86,7 @@ public function testGetDummyHandler() $this->config->storePath .= self::$directory; } - public function testHandlesBadHandler() + public function testHandlesBadHandler(): void { if (! is_dir($this->config->storePath)) { mkdir($this->config->storePath, 0555, true); diff --git a/tests/system/Cache/CacheMockTest.php b/tests/system/Cache/CacheMockTest.php index 492bef9264b8..72a901aa36aa 100644 --- a/tests/system/Cache/CacheMockTest.php +++ b/tests/system/Cache/CacheMockTest.php @@ -22,7 +22,7 @@ */ final class CacheMockTest extends CIUnitTestCase { - public function testMockReturnsMockCacheClass() + public function testMockReturnsMockCacheClass(): void { $this->assertInstanceOf(BaseHandler::class, service('cache')); @@ -31,7 +31,7 @@ public function testMockReturnsMockCacheClass() $this->assertInstanceOf(MockCache::class, service('cache')); } - public function testMockCaching() + public function testMockCaching(): void { $mock = mock(CacheFactory::class); diff --git a/tests/system/Cache/Handlers/AbstractHandlerTest.php b/tests/system/Cache/Handlers/AbstractHandlerTest.php index e426e02eb3c5..fbb27971628e 100644 --- a/tests/system/Cache/Handlers/AbstractHandlerTest.php +++ b/tests/system/Cache/Handlers/AbstractHandlerTest.php @@ -25,12 +25,12 @@ abstract class AbstractHandlerTest extends CIUnitTestCase protected static $key3 = 'key3'; protected static $dummy = 'dymmy'; - public function testGetMetaDataMiss() + public function testGetMetaDataMiss(): void { $this->assertNull($this->handler->getMetaData(self::$dummy)); } - public function testGetMetaData() + public function testGetMetaData(): void { $time = Time::now()->getTimestamp(); $this->handler->save(self::$key1, 'value'); diff --git a/tests/system/Cache/Handlers/BaseHandlerTest.php b/tests/system/Cache/Handlers/BaseHandlerTest.php index ba1dd0b2491f..2e835760e9e4 100644 --- a/tests/system/Cache/Handlers/BaseHandlerTest.php +++ b/tests/system/Cache/Handlers/BaseHandlerTest.php @@ -27,7 +27,7 @@ final class BaseHandlerTest extends CIUnitTestCase * * @param mixed $input */ - public function testValidateKeyInvalidType($input) + public function testValidateKeyInvalidType($input): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage('Cache key must be a string'); @@ -46,7 +46,7 @@ public function invalidTypeProvider(): iterable ]; } - public function testValidateKeyUsesConfig() + public function testValidateKeyUsesConfig(): void { config('Cache')->reservedCharacters = 'b'; @@ -56,7 +56,7 @@ public function testValidateKeyUsesConfig() BaseHandler::validateKey('banana'); } - public function testValidateKeySuccess() + public function testValidateKeySuccess(): void { $string = 'banana'; $result = BaseHandler::validateKey($string); @@ -64,7 +64,7 @@ public function testValidateKeySuccess() $this->assertSame($string, $result); } - public function testValidateKeySuccessWithPrefix() + public function testValidateKeySuccessWithPrefix(): void { $string = 'banana'; $result = BaseHandler::validateKey($string, 'prefix'); @@ -72,7 +72,7 @@ public function testValidateKeySuccessWithPrefix() $this->assertSame('prefix' . $string, $result); } - public function testValidateExcessiveLength() + public function testValidateExcessiveLength(): void { $string = 'MoreThanTenCharacters'; $expected = md5($string); @@ -82,7 +82,7 @@ public function testValidateExcessiveLength() $this->assertSame($expected, $result); } - public function testValidateExcessiveLengthWithPrefix() + public function testValidateExcessiveLengthWithPrefix(): void { $string = 'MoreThanTenCharacters'; $expected = 'prefix' . md5($string); diff --git a/tests/system/Cache/Handlers/DummyHandlerTest.php b/tests/system/Cache/Handlers/DummyHandlerTest.php index 71ca66a907d0..79dfda094acf 100644 --- a/tests/system/Cache/Handlers/DummyHandlerTest.php +++ b/tests/system/Cache/Handlers/DummyHandlerTest.php @@ -28,64 +28,64 @@ protected function setUp(): void $this->handler->initialize(); } - public function testNew() + public function testNew(): void { $this->assertInstanceOf(DummyHandler::class, $this->handler); } - public function testGet() + public function testGet(): void { $this->assertNull($this->handler->get('key')); } - public function testRemember() + public function testRemember(): void { $dummyHandler = $this->handler->remember('key', 2, static fn () => 'value'); $this->assertNull($dummyHandler); } - public function testSave() + public function testSave(): void { $this->assertTrue($this->handler->save('key', 'value')); } - public function testDelete() + public function testDelete(): void { $this->assertTrue($this->handler->delete('key')); } - public function testDeleteMatching() + public function testDeleteMatching(): void { $this->assertSame(0, $this->handler->deleteMatching('key*')); } - public function testIncrement() + public function testIncrement(): void { $this->assertTrue($this->handler->increment('key')); } - public function testDecrement() + public function testDecrement(): void { $this->assertTrue($this->handler->decrement('key')); } - public function testClean() + public function testClean(): void { $this->assertTrue($this->handler->clean()); } - public function testGetCacheInfo() + public function testGetCacheInfo(): void { $this->assertNull($this->handler->getCacheInfo()); } - public function testGetMetaData() + public function testGetMetaData(): void { $this->assertNull($this->handler->getMetaData('key')); } - public function testIsSupported() + public function testIsSupported(): void { $this->assertTrue($this->handler->isSupported()); } diff --git a/tests/system/Cache/Handlers/FileHandlerTest.php b/tests/system/Cache/Handlers/FileHandlerTest.php index 6f5e6b82f8c5..db8387b8c9cf 100644 --- a/tests/system/Cache/Handlers/FileHandlerTest.php +++ b/tests/system/Cache/Handlers/FileHandlerTest.php @@ -73,7 +73,7 @@ protected function tearDown(): void } } - public function testNew() + public function testNew(): void { $this->assertInstanceOf(FileHandler::class, $this->handler); } @@ -83,7 +83,7 @@ public function testNew() * * @requires OS Linux|Darwin */ - public function testNewWithNonWritablePath() + public function testNewWithNonWritablePath(): void { $this->expectException(CacheException::class); @@ -91,7 +91,7 @@ public function testNewWithNonWritablePath() new FileHandler($this->config); } - public function testSetDefaultPath() + public function testSetDefaultPath(): void { // Initialize path $config = new Cache(); @@ -109,7 +109,7 @@ public function testSetDefaultPath() * * @timeLimit 3.5 */ - public function testGet() + public function testGet(): void { $this->handler->save(self::$key1, 'value', 2); @@ -126,7 +126,7 @@ public function testGet() * * @timeLimit 3.5 */ - public function testRemember() + public function testRemember(): void { $this->handler->remember(self::$key1, 2, static fn () => 'value'); @@ -142,7 +142,7 @@ public function testRemember() * * @requires OS Linux|Darwin */ - public function testSave() + public function testSave(): void { $this->assertTrue($this->handler->save(self::$key1, 'value')); @@ -150,7 +150,7 @@ public function testSave() $this->assertFalse($this->handler->save(self::$key2, 'value')); } - public function testSaveExcessiveKeyLength() + public function testSaveExcessiveKeyLength(): void { $key = str_repeat('a', 260); $file = $this->config->file['storePath'] . DIRECTORY_SEPARATOR . md5($key); @@ -161,7 +161,7 @@ public function testSaveExcessiveKeyLength() unlink($file); } - public function testSavePermanent() + public function testSavePermanent(): void { $this->assertTrue($this->handler->save(self::$key1, 'value', 0)); $metaData = $this->handler->getMetaData(self::$key1); @@ -173,7 +173,7 @@ public function testSavePermanent() $this->assertTrue($this->handler->delete(self::$key1)); } - public function testDelete() + public function testDelete(): void { $this->handler->save(self::$key1, 'value'); @@ -181,7 +181,7 @@ public function testDelete() $this->assertFalse($this->handler->delete(self::$dummy)); } - public function testDeleteMatchingPrefix() + public function testDeleteMatchingPrefix(): void { // Save 101 items to match on for ($i = 1; $i <= 101; $i++) { @@ -202,7 +202,7 @@ public function testDeleteMatchingPrefix() $this->handler->clean(); } - public function testDeleteMatchingSuffix() + public function testDeleteMatchingSuffix(): void { // Save 101 items to match on for ($i = 1; $i <= 101; $i++) { @@ -223,7 +223,7 @@ public function testDeleteMatchingSuffix() $this->handler->clean(); } - public function testIncrement() + public function testIncrement(): void { $this->handler->save(self::$key1, 1); $this->handler->save(self::$key2, 'value'); @@ -233,7 +233,7 @@ public function testIncrement() $this->assertSame(10, $this->handler->increment(self::$key3, 10)); } - public function testDecrement() + public function testDecrement(): void { $this->handler->save(self::$key1, 10); $this->handler->save(self::$key2, 'value'); @@ -246,7 +246,7 @@ public function testDecrement() $this->assertSame(-1, $this->handler->decrement(self::$key3, 1)); } - public function testClean() + public function testClean(): void { $this->handler->save(self::$key1, 1); $this->handler->save(self::$key2, 'value'); @@ -257,7 +257,7 @@ public function testClean() $this->handler->save(self::$key2, 'value'); } - public function testGetCacheInfo() + public function testGetCacheInfo(): void { $this->handler->save(self::$key1, 'value'); @@ -267,7 +267,7 @@ public function testGetCacheInfo() $this->assertArrayHasKey('server_path', $actual[self::$key1]); } - public function testIsSupported() + public function testIsSupported(): void { $this->assertTrue($this->handler->isSupported()); } @@ -318,7 +318,7 @@ public function modeProvider(): iterable ]; } - public function testFileHandler() + public function testFileHandler(): void { $fileHandler = new BaseTestFileHandler(); @@ -333,7 +333,7 @@ public function testFileHandler() $this->assertArrayHasKey('fileperms', $actual); } - public function testGetMetaDataMiss() + public function testGetMetaDataMiss(): void { $this->assertFalse($this->handler->getMetaData(self::$dummy)); } diff --git a/tests/system/Cache/Handlers/MemcachedHandlerTest.php b/tests/system/Cache/Handlers/MemcachedHandlerTest.php index 24465af9e7de..986507d3e180 100644 --- a/tests/system/Cache/Handlers/MemcachedHandlerTest.php +++ b/tests/system/Cache/Handlers/MemcachedHandlerTest.php @@ -56,7 +56,7 @@ protected function tearDown(): void } } - public function testNew() + public function testNew(): void { $this->assertInstanceOf(MemcachedHandler::class, $this->handler); } @@ -67,7 +67,7 @@ public function testNew() * * @timeLimit 3.5 */ - public function testGet() + public function testGet(): void { $this->handler->save(self::$key1, 'value', 2); @@ -84,7 +84,7 @@ public function testGet() * * @timeLimit 3.5 */ - public function testRemember() + public function testRemember(): void { $this->handler->remember(self::$key1, 2, static fn () => 'value'); @@ -95,12 +95,12 @@ public function testRemember() $this->assertNull($this->handler->get(self::$key1)); } - public function testSave() + public function testSave(): void { $this->assertTrue($this->handler->save(self::$key1, 'value')); } - public function testSavePermanent() + public function testSavePermanent(): void { $this->assertTrue($this->handler->save(self::$key1, 'value', 0)); $metaData = $this->handler->getMetaData(self::$key1); @@ -112,7 +112,7 @@ public function testSavePermanent() $this->assertTrue($this->handler->delete(self::$key1)); } - public function testDelete() + public function testDelete(): void { $this->handler->save(self::$key1, 'value'); @@ -120,7 +120,7 @@ public function testDelete() $this->assertFalse($this->handler->delete(self::$dummy)); } - public function testDeleteMatching() + public function testDeleteMatching(): void { // Not implemented for Memcached, should throw an exception $this->expectException(Exception::class); @@ -128,7 +128,7 @@ public function testDeleteMatching() $this->handler->deleteMatching('key*'); } - public function testIncrement() + public function testIncrement(): void { $this->handler->save(self::$key1, 1); @@ -147,7 +147,7 @@ public function testIncrement() $this->assertSame(10, $memcachedHandler->increment(self::$key3, 10)); } - public function testDecrement() + public function testDecrement(): void { $this->handler->save(self::$key1, 10); @@ -166,7 +166,7 @@ public function testDecrement() $this->assertSame(1, $memcachedHandler->decrement(self::$key3, 1)); } - public function testClean() + public function testClean(): void { $this->handler->save(self::$key1, 1); $this->handler->save(self::$key2, 'value'); @@ -174,19 +174,19 @@ public function testClean() $this->assertTrue($this->handler->clean()); } - public function testGetCacheInfo() + public function testGetCacheInfo(): void { $this->handler->save(self::$key1, 'value'); $this->assertIsArray($this->handler->getCacheInfo()); } - public function testIsSupported() + public function testIsSupported(): void { $this->assertTrue($this->handler->isSupported()); } - public function testGetMetaDataMiss() + public function testGetMetaDataMiss(): void { $this->assertFalse($this->handler->getMetaData(self::$dummy)); } diff --git a/tests/system/Cache/Handlers/PredisHandlerTest.php b/tests/system/Cache/Handlers/PredisHandlerTest.php index 17a43e36263f..e1677ba6a1b0 100644 --- a/tests/system/Cache/Handlers/PredisHandlerTest.php +++ b/tests/system/Cache/Handlers/PredisHandlerTest.php @@ -51,12 +51,12 @@ protected function tearDown(): void } } - public function testNew() + public function testNew(): void { $this->assertInstanceOf(PredisHandler::class, $this->handler); } - public function testDestruct() + public function testDestruct(): void { $this->handler = new PredisHandler($this->config); $this->handler->initialize(); @@ -70,7 +70,7 @@ public function testDestruct() * * @timeLimit 3.5 */ - public function testGet() + public function testGet(): void { $this->handler->save(self::$key1, 'value', 2); @@ -87,7 +87,7 @@ public function testGet() * * @timeLimit 3.5 */ - public function testRemember() + public function testRemember(): void { $this->handler->remember(self::$key1, 2, static fn () => 'value'); @@ -98,12 +98,12 @@ public function testRemember() $this->assertNull($this->handler->get(self::$key1)); } - public function testSave() + public function testSave(): void { $this->assertTrue($this->handler->save(self::$key1, 'value')); } - public function testSavePermanent() + public function testSavePermanent(): void { $this->assertTrue($this->handler->save(self::$key1, 'value', 0)); $metaData = $this->handler->getMetaData(self::$key1); @@ -115,7 +115,7 @@ public function testSavePermanent() $this->assertTrue($this->handler->delete(self::$key1)); } - public function testDelete() + public function testDelete(): void { $this->handler->save(self::$key1, 'value'); @@ -123,7 +123,7 @@ public function testDelete() $this->assertFalse($this->handler->delete(self::$dummy)); } - public function testDeleteMatchingPrefix() + public function testDeleteMatchingPrefix(): void { // Save 101 items to match on for ($i = 1; $i <= 101; $i++) { @@ -141,7 +141,7 @@ public function testDeleteMatchingPrefix() $this->assertSame('88', $this->handler->getCacheInfo()['Keyspace']['db0']['keys']); } - public function testDeleteMatchingSuffix() + public function testDeleteMatchingSuffix(): void { // Save 101 items to match on for ($i = 1; $i <= 101; $i++) { @@ -159,7 +159,7 @@ public function testDeleteMatchingSuffix() $this->assertSame('90', $this->handler->getCacheInfo()['Keyspace']['db0']['keys']); } - public function testClean() + public function testClean(): void { $this->handler->save(self::$key1, 1); $this->handler->save(self::$key2, 'value'); @@ -167,14 +167,14 @@ public function testClean() $this->assertTrue($this->handler->clean()); } - public function testGetCacheInfo() + public function testGetCacheInfo(): void { $this->handler->save(self::$key1, 'value'); $this->assertIsArray($this->handler->getCacheInfo()); } - public function testIsSupported() + public function testIsSupported(): void { $this->assertTrue($this->handler->isSupported()); } diff --git a/tests/system/Cache/Handlers/RedisHandlerTest.php b/tests/system/Cache/Handlers/RedisHandlerTest.php index 83a30a0de362..45f35df3f718 100644 --- a/tests/system/Cache/Handlers/RedisHandlerTest.php +++ b/tests/system/Cache/Handlers/RedisHandlerTest.php @@ -55,12 +55,12 @@ protected function tearDown(): void } } - public function testNew() + public function testNew(): void { $this->assertInstanceOf(RedisHandler::class, $this->handler); } - public function testDestruct() + public function testDestruct(): void { $this->handler = new RedisHandler($this->config); $this->handler->initialize(); @@ -74,7 +74,7 @@ public function testDestruct() * * @timeLimit 3.5 */ - public function testGet() + public function testGet(): void { $this->handler->save(self::$key1, 'value', 2); @@ -91,7 +91,7 @@ public function testGet() * * @timeLimit 3.5 */ - public function testRemember() + public function testRemember(): void { $this->handler->remember(self::$key1, 2, static fn () => 'value'); @@ -102,12 +102,12 @@ public function testRemember() $this->assertNull($this->handler->get(self::$key1)); } - public function testSave() + public function testSave(): void { $this->assertTrue($this->handler->save(self::$key1, 'value')); } - public function testSavePermanent() + public function testSavePermanent(): void { $this->assertTrue($this->handler->save(self::$key1, 'value', 0)); $metaData = $this->handler->getMetaData(self::$key1); @@ -119,7 +119,7 @@ public function testSavePermanent() $this->assertTrue($this->handler->delete(self::$key1)); } - public function testDelete() + public function testDelete(): void { $this->handler->save(self::$key1, 'value'); @@ -127,7 +127,7 @@ public function testDelete() $this->assertFalse($this->handler->delete(self::$dummy)); } - public function testDeleteMatchingPrefix() + public function testDeleteMatchingPrefix(): void { // Save 101 items to match on for ($i = 1; $i <= 101; $i++) { @@ -147,7 +147,7 @@ public function testDeleteMatchingPrefix() $this->assertSame('keys=88', $dbInfo[0]); } - public function testDeleteMatchingSuffix() + public function testDeleteMatchingSuffix(): void { // Save 101 items to match on for ($i = 1; $i <= 101; $i++) { @@ -167,7 +167,7 @@ public function testDeleteMatchingSuffix() $this->assertSame('keys=90', $dbInfo[0]); } - public function testIncrementAndDecrement() + public function testIncrementAndDecrement(): void { $this->handler->save('counter', 100); @@ -184,14 +184,14 @@ public function testIncrementAndDecrement() $this->assertSame(140, $this->handler->get('counter')); } - public function testClean() + public function testClean(): void { $this->handler->save(self::$key1, 1); $this->assertTrue($this->handler->clean()); } - public function testGetCacheInfo() + public function testGetCacheInfo(): void { $this->handler->save(self::$key1, 'value'); @@ -208,7 +208,7 @@ public function testGetMetadataNotNull(): void $this->assertIsArray($metadata); } - public function testIsSupported() + public function testIsSupported(): void { $this->assertTrue($this->handler->isSupported()); } diff --git a/tests/system/CodeIgniterTest.php b/tests/system/CodeIgniterTest.php index ae88e6f2f3a1..a593fb279db3 100644 --- a/tests/system/CodeIgniterTest.php +++ b/tests/system/CodeIgniterTest.php @@ -59,7 +59,7 @@ protected function tearDown(): void $this->resetServices(); } - public function testRunEmptyDefaultRoute() + public function testRunEmptyDefaultRoute(): void { $_SERVER['argv'] = ['index.php']; $_SERVER['argc'] = 1; @@ -71,7 +71,7 @@ public function testRunEmptyDefaultRoute() $this->assertStringContainsString('Welcome to CodeIgniter', $output); } - public function testRunEmptyDefaultRouteReturnResponse() + public function testRunEmptyDefaultRouteReturnResponse(): void { $_SERVER['argv'] = ['index.php']; $_SERVER['argc'] = 1; @@ -81,7 +81,7 @@ public function testRunEmptyDefaultRouteReturnResponse() $this->assertStringContainsString('Welcome to CodeIgniter', $response->getBody()); } - public function testRunClosureRoute() + public function testRunClosureRoute(): void { $_SERVER['argv'] = ['index.php', 'pages/about']; $_SERVER['argc'] = 2; @@ -90,7 +90,7 @@ public function testRunClosureRoute() // Inject mock router. $routes = Services::routes(); - $routes->add('pages/(:segment)', static function ($segment) { + $routes->add('pages/(:segment)', static function ($segment): void { echo 'You want to see "' . esc($segment) . '" page.'; }); $router = Services::router($routes, Services::incomingrequest()); @@ -103,7 +103,7 @@ public function testRunClosureRoute() $this->assertStringContainsString('You want to see "about" page.', $output); } - public function testRun404Override() + public function testRun404Override(): void { $_SERVER['argv'] = ['index.php', '/']; $_SERVER['argc'] = 2; @@ -122,7 +122,7 @@ public function testRun404Override() $this->assertStringContainsString('Hello', $output); } - public function testRun404OverrideControllerReturnsResponse() + public function testRun404OverrideControllerReturnsResponse(): void { $_SERVER['argv'] = ['index.php', '/']; $_SERVER['argc'] = 2; @@ -141,7 +141,7 @@ public function testRun404OverrideControllerReturnsResponse() $this->assertStringContainsString('Oops', $output); } - public function testRun404OverrideReturnResponse() + public function testRun404OverrideReturnResponse(): void { $_SERVER['argv'] = ['index.php', '/']; $_SERVER['argc'] = 2; @@ -158,7 +158,7 @@ public function testRun404OverrideReturnResponse() $this->assertStringContainsString('Oops', $response->getBody()); } - public function testRun404OverrideByClosure() + public function testRun404OverrideByClosure(): void { $_SERVER['argv'] = ['index.php', '/']; $_SERVER['argc'] = 2; @@ -166,7 +166,7 @@ public function testRun404OverrideByClosure() // Inject mock router. $routes = new RouteCollection(Services::locator(), new Modules()); $routes->setAutoRoute(false); - $routes->set404Override(static function () { + $routes->set404Override(static function (): void { echo '404 Override by Closure.'; }); $router = Services::router($routes, Services::incomingrequest()); @@ -179,7 +179,7 @@ public function testRun404OverrideByClosure() $this->assertStringContainsString('404 Override by Closure.', $output); } - public function testControllersCanReturnString() + public function testControllersCanReturnString(): void { $_SERVER['argv'] = ['index.php', 'pages/about']; $_SERVER['argc'] = 2; @@ -199,7 +199,7 @@ public function testControllersCanReturnString() $this->assertStringContainsString('You want to see "about" page.', $output); } - public function testControllersCanReturnResponseObject() + public function testControllersCanReturnResponseObject(): void { $_SERVER['argv'] = ['index.php', 'pages/about']; $_SERVER['argc'] = 2; @@ -227,7 +227,7 @@ public function testControllersCanReturnResponseObject() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/6358 */ - public function testControllersCanReturnDownloadResponseObject() + public function testControllersCanReturnDownloadResponseObject(): void { $_SERVER['argv'] = ['index.php', 'pages/about']; $_SERVER['argc'] = 2; @@ -251,7 +251,7 @@ public function testControllersCanReturnDownloadResponseObject() $this->assertSame('some text', $output); } - public function testControllersRunFilterByClassName() + public function testControllersRunFilterByClassName(): void { $_SERVER['argv'] = ['index.php', 'pages/about']; $_SERVER['argc'] = 2; @@ -274,7 +274,7 @@ public function testControllersRunFilterByClassName() $this->resetServices(); } - public function testDisableControllerFilters() + public function testDisableControllerFilters(): void { $_SERVER['argv'] = ['index.php', 'pages/about']; $_SERVER['argc'] = 2; @@ -301,7 +301,7 @@ public function testDisableControllerFilters() $this->resetServices(); } - public function testResponseConfigEmpty() + public function testResponseConfigEmpty(): void { $_SERVER['argv'] = ['index.php', '/']; $_SERVER['argc'] = 2; @@ -311,7 +311,7 @@ public function testResponseConfigEmpty() $this->assertInstanceOf(Response::class, $response); } - public function testRoutesIsEmpty() + public function testRoutesIsEmpty(): void { $_SERVER['argv'] = ['index.php', '/']; $_SERVER['argc'] = 2; @@ -327,7 +327,7 @@ public function testRoutesIsEmpty() $this->assertStringContainsString('Welcome to CodeIgniter', $output); } - public function testTransfersCorrectHTTPVersion() + public function testTransfersCorrectHTTPVersion(): void { $_SERVER['argv'] = ['index.php', '/']; $_SERVER['argc'] = 2; @@ -343,7 +343,7 @@ public function testTransfersCorrectHTTPVersion() $this->assertSame('2.0', $response->getProtocolVersion()); } - public function testSupportsHttp3() + public function testSupportsHttp3(): void { $_SERVER['argv'] = ['index.php', '/']; $_SERVER['argc'] = 2; @@ -359,7 +359,7 @@ public function testSupportsHttp3() $this->assertSame('3.0', $response->getProtocolVersion()); } - public function testIgnoringErrorSuppressedByAt() + public function testIgnoringErrorSuppressedByAt(): void { $_SERVER['argv'] = ['index.php', '/']; $_SERVER['argc'] = 2; @@ -372,7 +372,7 @@ public function testIgnoringErrorSuppressedByAt() $this->assertStringContainsString('Welcome to CodeIgniter', $output); } - public function testRunForceSecure() + public function testRunForceSecure(): void { $_SERVER['argv'] = ['index.php', '/']; $_SERVER['argc'] = 2; @@ -397,7 +397,7 @@ public function testRunForceSecure() $this->assertSame('https://example.com/', $response->header('Location')->getValue()); } - public function testRunRedirectionWithNamed() + public function testRunRedirectionWithNamed(): void { $_SERVER['argv'] = ['index.php', 'example']; $_SERVER['argc'] = 2; @@ -406,7 +406,7 @@ public function testRunRedirectionWithNamed() // Inject mock router. $routes = Services::routes(); - $routes->add('pages/named', static function () { + $routes->add('pages/named', static function (): void { }, ['as' => 'name']); $routes->addRedirect('example', 'name'); @@ -420,7 +420,7 @@ public function testRunRedirectionWithNamed() $this->assertSame('http://example.com/pages/named', $response->header('Location')->getValue()); } - public function testRunRedirectionWithURI() + public function testRunRedirectionWithURI(): void { $_SERVER['argv'] = ['index.php', 'example']; $_SERVER['argc'] = 2; @@ -429,7 +429,7 @@ public function testRunRedirectionWithURI() // Inject mock router. $routes = Services::routes(); - $routes->add('pages/uri', static function () { + $routes->add('pages/uri', static function (): void { }); $routes->addRedirect('example', 'pages/uri'); @@ -446,7 +446,7 @@ public function testRunRedirectionWithURI() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/3041 */ - public function testRunRedirectionWithGET() + public function testRunRedirectionWithGET(): void { $_SERVER['argv'] = ['index.php', 'example']; $_SERVER['argc'] = 2; @@ -472,7 +472,7 @@ public function testRunRedirectionWithGET() $this->assertSame(302, $response->getStatusCode()); } - public function testRunRedirectionWithGETAndHTTPCode301() + public function testRunRedirectionWithGETAndHTTPCode301(): void { $_SERVER['argv'] = ['index.php', 'example']; $_SERVER['argc'] = 2; @@ -496,7 +496,7 @@ public function testRunRedirectionWithGETAndHTTPCode301() $this->assertSame(301, $response->getStatusCode()); } - public function testRunRedirectionWithPOSTAndHTTPCode301() + public function testRunRedirectionWithPOSTAndHTTPCode301(): void { $_SERVER['argv'] = ['index.php', 'example']; $_SERVER['argc'] = 2; @@ -520,7 +520,7 @@ public function testRunRedirectionWithPOSTAndHTTPCode301() $this->assertSame(301, $response->getStatusCode()); } - public function testStoresPreviousURL() + public function testStoresPreviousURL(): void { $_SERVER['argv'] = ['index.php', '/']; $_SERVER['argc'] = 2; @@ -537,7 +537,7 @@ public function testStoresPreviousURL() $this->assertSame('http://example.com/index.php', $_SESSION['_ci_previous_url']); } - public function testNotStoresPreviousURL() + public function testNotStoresPreviousURL(): void { $_SERVER['argv'] = ['index.php', 'example']; $_SERVER['argc'] = 2; @@ -560,7 +560,7 @@ public function testNotStoresPreviousURL() $this->assertArrayNotHasKey('_ci_previous_url', $_SESSION); } - public function testNotStoresPreviousURLByCheckingContentType() + public function testNotStoresPreviousURLByCheckingContentType(): void { $_SERVER['argv'] = ['index.php', 'image']; $_SERVER['argc'] = 2; @@ -589,7 +589,7 @@ public function testNotStoresPreviousURLByCheckingContentType() * Can't use static::tearDownAfterClass. This will cause a buffer exception * need improve */ - public function testRunDefaultRoute() + public function testRunDefaultRoute(): void { $_SERVER['argv'] = ['index.php', '/']; $_SERVER['argc'] = 2; @@ -601,7 +601,7 @@ public function testRunDefaultRoute() $this->assertStringContainsString('Welcome to CodeIgniter', $output); } - public function testRunCLIRoute() + public function testRunCLIRoute(): void { $_SERVER['argv'] = ['index.php', 'cli']; $_SERVER['argc'] = 2; @@ -620,7 +620,7 @@ public function testRunCLIRoute() $this->assertStringContainsString('Method Not Allowed', $output); } - public function testSpoofRequestMethodCanUsePUT() + public function testSpoofRequestMethodCanUsePUT(): void { $_SERVER['argv'] = ['index.php']; $_SERVER['argc'] = 1; @@ -644,7 +644,7 @@ public function testSpoofRequestMethodCanUsePUT() $this->assertSame('put', Services::incomingrequest()->getMethod()); } - public function testSpoofRequestMethodCannotUseGET() + public function testSpoofRequestMethodCannotUseGET(): void { $_SERVER['argv'] = ['index.php']; $_SERVER['argc'] = 1; @@ -671,7 +671,7 @@ public function testSpoofRequestMethodCannotUseGET() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/6281 */ - public function testPageCacheSendSecureHeaders() + public function testPageCacheSendSecureHeaders(): void { // Suppress command() output CITestStreamFilter::registration(); @@ -735,7 +735,7 @@ public function testPageCacheSendSecureHeaders() * * @see https://github.com/codeigniter4/CodeIgniter4/pull/6410 */ - public function testPageCacheWithCacheQueryString($cacheQueryStringValue, int $expectedPagesInCache, array $testingUrls) + public function testPageCacheWithCacheQueryString($cacheQueryStringValue, int $expectedPagesInCache, array $testingUrls): void { // Suppress command() output CITestStreamFilter::registration(); diff --git a/tests/system/Commands/BaseCommandTest.php b/tests/system/Commands/BaseCommandTest.php index 068a8d832924..c486edb55679 100644 --- a/tests/system/Commands/BaseCommandTest.php +++ b/tests/system/Commands/BaseCommandTest.php @@ -31,28 +31,28 @@ protected function setUp(): void $this->logger = Services::logger(); } - public function testMagicIssetTrue() + public function testMagicIssetTrue(): void { $command = new AppInfo($this->logger, service('commands')); $this->assertTrue(isset($command->group)); } - public function testMagicIssetFalse() + public function testMagicIssetFalse(): void { $command = new AppInfo($this->logger, service('commands')); $this->assertFalse(isset($command->foobar)); } - public function testMagicGet() + public function testMagicGet(): void { $command = new AppInfo($this->logger, service('commands')); $this->assertSame('demo', $command->group); } - public function testMagicGetMissing() + public function testMagicGetMissing(): void { $command = new AppInfo($this->logger, service('commands')); diff --git a/tests/system/Commands/ClearCacheTest.php b/tests/system/Commands/ClearCacheTest.php index 1ada8b55f3ca..52afbfabd4d1 100644 --- a/tests/system/Commands/ClearCacheTest.php +++ b/tests/system/Commands/ClearCacheTest.php @@ -33,14 +33,14 @@ protected function setUp(): void Services::injectMock('cache', CacheFactory::getHandler(config('Cache'))); } - public function testClearCacheInvalidHandler() + public function testClearCacheInvalidHandler(): void { command('cache:clear junk'); $this->assertStringContainsString('junk is not a valid cache handler.', $this->getStreamFilterBuffer()); } - public function testClearCacheWorks() + public function testClearCacheWorks(): void { cache()->save('foo', 'bar'); $this->assertSame('bar', cache('foo')); diff --git a/tests/system/Commands/ClearDebugbarTest.php b/tests/system/Commands/ClearDebugbarTest.php index 4a398e4f4016..b8f6fa13e535 100644 --- a/tests/system/Commands/ClearDebugbarTest.php +++ b/tests/system/Commands/ClearDebugbarTest.php @@ -32,7 +32,7 @@ protected function setUp(): void $this->time = time(); } - protected function createDummyDebugbarJson() + protected function createDummyDebugbarJson(): void { $time = $this->time; $path = WRITEPATH . 'debugbar' . DIRECTORY_SEPARATOR . "debugbar_{$time}.json"; @@ -46,7 +46,7 @@ protected function createDummyDebugbarJson() } } - public function testClearDebugbarWorks() + public function testClearDebugbarWorks(): void { // test clean debugbar dir $this->assertFileDoesNotExist(WRITEPATH . 'debugbar' . DIRECTORY_SEPARATOR . "debugbar_{$this->time}.json"); diff --git a/tests/system/Commands/ClearLogsTest.php b/tests/system/Commands/ClearLogsTest.php index daeb0461acec..406393020343 100644 --- a/tests/system/Commands/ClearLogsTest.php +++ b/tests/system/Commands/ClearLogsTest.php @@ -34,7 +34,7 @@ protected function setUp(): void $this->date = date('Y-m-d', strtotime('+1 year')); } - protected function createDummyLogFiles() + protected function createDummyLogFiles(): void { $date = $this->date; $path = WRITEPATH . 'logs' . DIRECTORY_SEPARATOR . "log-{$date}.log"; @@ -49,7 +49,7 @@ protected function createDummyLogFiles() } } - public function testClearLogsWorks() + public function testClearLogsWorks(): void { // test clean logs dir $this->assertFileDoesNotExist(WRITEPATH . 'logs' . DIRECTORY_SEPARATOR . "log-{$this->date}.log"); diff --git a/tests/system/Commands/CommandGeneratorTest.php b/tests/system/Commands/CommandGeneratorTest.php index d72ba1b36aab..64ab5a21d2d9 100644 --- a/tests/system/Commands/CommandGeneratorTest.php +++ b/tests/system/Commands/CommandGeneratorTest.php @@ -46,7 +46,7 @@ protected function getFileContents(string $filepath): string return file_get_contents($filepath) ?: ''; } - public function testGenerateCommand() + public function testGenerateCommand(): void { command('make:command deliver'); $file = APPPATH . 'Commands/Deliver.php'; @@ -56,7 +56,7 @@ public function testGenerateCommand() $this->assertStringContainsString('protected $name = \'command:name\';', $contents); } - public function testGenerateCommandWithOptionCommand() + public function testGenerateCommandWithOptionCommand(): void { command('make:command deliver -command clear:sessions'); $file = APPPATH . 'Commands/Deliver.php'; @@ -66,7 +66,7 @@ public function testGenerateCommandWithOptionCommand() $this->assertStringContainsString('protected $usage = \'clear:sessions [arguments] [options]\';', $contents); } - public function testGenerateCommandWithOptionTypeBasic() + public function testGenerateCommandWithOptionTypeBasic(): void { command('make:command deliver -type basic'); $file = APPPATH . 'Commands/Deliver.php'; @@ -76,7 +76,7 @@ public function testGenerateCommandWithOptionTypeBasic() $this->assertStringContainsString('protected $name = \'command:name\';', $contents); } - public function testGenerateCommandWithOptionTypeGenerator() + public function testGenerateCommandWithOptionTypeGenerator(): void { command('make:command deliver -type generator'); $file = APPPATH . 'Commands/Deliver.php'; @@ -86,7 +86,7 @@ public function testGenerateCommandWithOptionTypeGenerator() $this->assertStringContainsString('protected $name = \'command:name\';', $contents); } - public function testGenerateCommandWithOptionGroup() + public function testGenerateCommandWithOptionGroup(): void { command('make:command deliver -group Deliverables'); $file = APPPATH . 'Commands/Deliver.php'; @@ -97,7 +97,7 @@ public function testGenerateCommandWithOptionGroup() $this->assertStringContainsString('protected $group = \'Deliverables\';', $contents); } - public function testGenerateCommandWithOptionSuffix() + public function testGenerateCommandWithOptionSuffix(): void { command('make:command publish -suffix'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); diff --git a/tests/system/Commands/CommandTest.php b/tests/system/Commands/CommandTest.php index 1101e08ef5b6..90da337c11a0 100644 --- a/tests/system/Commands/CommandTest.php +++ b/tests/system/Commands/CommandTest.php @@ -45,7 +45,7 @@ protected function getBuffer() return $this->getStreamFilterBuffer(); } - public function testListCommands() + public function testListCommands(): void { command('list'); @@ -54,7 +54,7 @@ public function testListCommands() $this->assertStringContainsString('Displays basic usage information.', $this->getBuffer()); } - public function testListCommandsSimple() + public function testListCommandsSimple(): void { command('list --simple'); @@ -62,13 +62,13 @@ public function testListCommandsSimple() $this->assertStringNotContainsString('Lists the available commands.', $this->getBuffer()); } - public function testCustomCommand() + public function testCustomCommand(): void { command('app:info'); $this->assertStringContainsString('CI Version:', $this->getBuffer()); } - public function testShowError() + public function testShowError(): void { command('app:info'); $commands = $this->commands->getCommands(); @@ -78,7 +78,7 @@ public function testShowError() $this->assertStringContainsString('Displays basic usage information.', $this->getBuffer()); } - public function testCommandCall() + public function testCommandCall(): void { command('app:info'); $commands = $this->commands->getCommands(); @@ -88,13 +88,13 @@ public function testCommandCall() $this->assertStringContainsString('Invalid "background" color:', $this->getBuffer()); } - public function testAbstractCommand() + public function testAbstractCommand(): void { command('app:pablo'); $this->assertStringContainsString('not found', $this->getBuffer()); } - public function testNamespacesCommand() + public function testNamespacesCommand(): void { command('namespaces'); @@ -103,13 +103,13 @@ public function testNamespacesCommand() $this->assertStringContainsString('| Yes', $this->getBuffer()); } - public function testInexistentCommandWithNoAlternatives() + public function testInexistentCommandWithNoAlternatives(): void { command('app:oops'); $this->assertStringContainsString('Command "app:oops" not found', $this->getBuffer()); } - public function testInexistentCommandsButWithOneAlternative() + public function testInexistentCommandsButWithOneAlternative(): void { command('namespace'); @@ -118,7 +118,7 @@ public function testInexistentCommandsButWithOneAlternative() $this->assertStringContainsString('namespaces', $this->getBuffer()); } - public function testInexistentCommandsButWithManyAlternatives() + public function testInexistentCommandsButWithManyAlternatives(): void { command('clear'); @@ -130,7 +130,7 @@ public function testInexistentCommandsButWithManyAlternatives() /** * @dataProvider commandArgsProvider */ - public function testCommandParsesArgsCorrectly(string $input, array $expected) + public function testCommandParsesArgsCorrectly(string $input, array $expected): void { ParamsReveal::$args = null; command($input); diff --git a/tests/system/Commands/ConfigGeneratorTest.php b/tests/system/Commands/ConfigGeneratorTest.php index 08ad58a25d9c..f4036a24e65e 100644 --- a/tests/system/Commands/ConfigGeneratorTest.php +++ b/tests/system/Commands/ConfigGeneratorTest.php @@ -32,13 +32,13 @@ protected function tearDown(): void } } - public function testGenerateConfig() + public function testGenerateConfig(): void { command('make:config auth'); $this->assertFileExists(APPPATH . 'Config/Auth.php'); } - public function testGenerateConfigWithOptionSuffix() + public function testGenerateConfigWithOptionSuffix(): void { command('make:config auth -suffix'); $this->assertFileExists(APPPATH . 'Config/AuthConfig.php'); diff --git a/tests/system/Commands/ConfigurableSortImportsTest.php b/tests/system/Commands/ConfigurableSortImportsTest.php index 6e98a73cd62c..0bc5b9498c17 100644 --- a/tests/system/Commands/ConfigurableSortImportsTest.php +++ b/tests/system/Commands/ConfigurableSortImportsTest.php @@ -23,7 +23,7 @@ final class ConfigurableSortImportsTest extends CIUnitTestCase { use StreamFilterTrait; - public function testPublishLanguageWithoutOptions() + public function testPublishLanguageWithoutOptions(): void { command('publish:language'); @@ -36,7 +36,7 @@ public function testPublishLanguageWithoutOptions() } } - public function testEnabledSortImportsWillDisruptLanguageFilePublish() + public function testEnabledSortImportsWillDisruptLanguageFilePublish(): void { command('publish:language --lang es'); @@ -53,7 +53,7 @@ public function testEnabledSortImportsWillDisruptLanguageFilePublish() } } - public function testDisabledSortImportsWillNotAffectLanguageFilesPublish() + public function testDisabledSortImportsWillNotAffectLanguageFilesPublish(): void { command('publish:language --lang ar --sort off'); diff --git a/tests/system/Commands/ControllerGeneratorTest.php b/tests/system/Commands/ControllerGeneratorTest.php index 9ff4d027b45c..9567280f1d34 100644 --- a/tests/system/Commands/ControllerGeneratorTest.php +++ b/tests/system/Commands/ControllerGeneratorTest.php @@ -41,7 +41,7 @@ protected function getFileContents(string $filepath): string return file_get_contents($filepath) ?: ''; } - public function testGenerateController() + public function testGenerateController(): void { command('make:controller user'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -50,7 +50,7 @@ public function testGenerateController() $this->assertStringContainsString('extends BaseController', $this->getFileContents($file)); } - public function testGenerateControllerWithOptionBare() + public function testGenerateControllerWithOptionBare(): void { command('make:controller blog -bare'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -59,7 +59,7 @@ public function testGenerateControllerWithOptionBare() $this->assertStringContainsString('extends Controller', $this->getFileContents($file)); } - public function testGenerateControllerWithOptionRestful() + public function testGenerateControllerWithOptionRestful(): void { command('make:controller order -restful'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -68,7 +68,7 @@ public function testGenerateControllerWithOptionRestful() $this->assertStringContainsString('extends ResourceController', $this->getFileContents($file)); } - public function testGenerateControllerWithOptionRestfulPresenter() + public function testGenerateControllerWithOptionRestfulPresenter(): void { command('make:controller pay -restful presenter'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -77,7 +77,7 @@ public function testGenerateControllerWithOptionRestfulPresenter() $this->assertStringContainsString('extends ResourcePresenter', $this->getFileContents($file)); } - public function testGenerateControllerWithOptionSuffix() + public function testGenerateControllerWithOptionSuffix(): void { command('make:controller dashboard -suffix'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); diff --git a/tests/system/Commands/CreateDatabaseTest.php b/tests/system/Commands/CreateDatabaseTest.php index 7ee07a2d936d..a1468f1184dc 100644 --- a/tests/system/Commands/CreateDatabaseTest.php +++ b/tests/system/Commands/CreateDatabaseTest.php @@ -67,7 +67,7 @@ protected function getBuffer() return $this->getStreamFilterBuffer(); } - public function testCreateDatabase() + public function testCreateDatabase(): void { if ($this->connection instanceof OCI8Connection) { $this->markTestSkipped('Needs to run on non-OCI8 drivers.'); @@ -77,7 +77,7 @@ public function testCreateDatabase() $this->assertStringContainsString('successfully created.', $this->getBuffer()); } - public function testSqliteDatabaseDuplicated() + public function testSqliteDatabaseDuplicated(): void { if (! $this->connection instanceof SQLite3Connection) { $this->markTestSkipped('Needs to run on SQLite3.'); @@ -90,7 +90,7 @@ public function testSqliteDatabaseDuplicated() $this->assertStringContainsString('already exists.', $this->getBuffer()); } - public function testOtherDriverDuplicatedDatabase() + public function testOtherDriverDuplicatedDatabase(): void { if ($this->connection instanceof SQLite3Connection || $this->connection instanceof OCI8Connection) { $this->markTestSkipped('Needs to run on non-SQLite3 and non-OCI8 drivers.'); diff --git a/tests/system/Commands/DatabaseCommandsTest.php b/tests/system/Commands/DatabaseCommandsTest.php index 9d025d38517b..f0832f429efd 100644 --- a/tests/system/Commands/DatabaseCommandsTest.php +++ b/tests/system/Commands/DatabaseCommandsTest.php @@ -40,7 +40,7 @@ protected function clearBuffer(): void $this->resetStreamFilterBuffer(); } - public function testMigrate() + public function testMigrate(): void { command('migrate --all'); $this->assertStringContainsString('Migrations complete.', $this->getBuffer()); @@ -51,7 +51,7 @@ public function testMigrate() $this->assertStringContainsString('Migrations complete.', $this->getBuffer()); } - public function testMigrateRollback() + public function testMigrateRollback(): void { command('migrate --all -g tests'); $this->clearBuffer(); @@ -60,7 +60,7 @@ public function testMigrateRollback() $this->assertStringContainsString('Done rolling back migrations.', $this->getBuffer()); } - public function testMigrateRefresh() + public function testMigrateRefresh(): void { command('migrate --all'); $this->clearBuffer(); @@ -69,7 +69,7 @@ public function testMigrateRefresh() $this->assertStringContainsString('Migrations complete.', $this->getBuffer()); } - public function testMigrateStatus() + public function testMigrateStatus(): void { command('migrate --all'); $this->clearBuffer(); @@ -80,7 +80,7 @@ public function testMigrateStatus() $this->assertStringContainsString('Filename', $this->getBuffer()); } - public function testSeed() + public function testSeed(): void { command('migrate --all'); $this->clearBuffer(); diff --git a/tests/system/Commands/EntityGeneratorTest.php b/tests/system/Commands/EntityGeneratorTest.php index 5d14ddfeaf06..47146b027056 100644 --- a/tests/system/Commands/EntityGeneratorTest.php +++ b/tests/system/Commands/EntityGeneratorTest.php @@ -36,13 +36,13 @@ protected function tearDown(): void } } - public function testGenerateEntity() + public function testGenerateEntity(): void { command('make:entity user'); $this->assertFileExists(APPPATH . 'Entities/User.php'); } - public function testGenerateEntityWithOptionSuffix() + public function testGenerateEntityWithOptionSuffix(): void { command('make:entity user -suffix'); $this->assertFileExists(APPPATH . 'Entities/UserEntity.php'); diff --git a/tests/system/Commands/EnvironmentCommandTest.php b/tests/system/Commands/EnvironmentCommandTest.php index 84c796ecb669..4b7a4a473dfa 100644 --- a/tests/system/Commands/EnvironmentCommandTest.php +++ b/tests/system/Commands/EnvironmentCommandTest.php @@ -72,7 +72,7 @@ public function testProvidingUnknownEnvGivesErrorMessage(): void $this->assertStringContainsString('Invalid environment type "foobar".', $this->getStreamFilterBuffer()); } - public function testDefaultShippedEnvIsMissing() + public function testDefaultShippedEnvIsMissing(): void { rename(ROOTPATH . 'env', ROOTPATH . 'lostenv'); command('env development'); diff --git a/tests/system/Commands/FilterCheckTest.php b/tests/system/Commands/FilterCheckTest.php index 4959afb0826c..a0b74099f818 100644 --- a/tests/system/Commands/FilterCheckTest.php +++ b/tests/system/Commands/FilterCheckTest.php @@ -40,7 +40,7 @@ protected function getBuffer() return $this->getStreamFilterBuffer(); } - public function testFilterCheckDefinedRoute() + public function testFilterCheckDefinedRoute(): void { command('filter:check get /'); @@ -50,7 +50,7 @@ public function testFilterCheckDefinedRoute() ); } - public function testFilterCheckInvalidRoute() + public function testFilterCheckInvalidRoute(): void { command('filter:check put product/123'); diff --git a/tests/system/Commands/FilterGeneratorTest.php b/tests/system/Commands/FilterGeneratorTest.php index 148c7031ce3e..7f697e21c9dc 100644 --- a/tests/system/Commands/FilterGeneratorTest.php +++ b/tests/system/Commands/FilterGeneratorTest.php @@ -32,13 +32,13 @@ protected function tearDown(): void } } - public function testGenerateFilter() + public function testGenerateFilter(): void { command('make:filter admin'); $this->assertFileExists(APPPATH . 'Filters/Admin.php'); } - public function testGenerateFilterWithOptionSuffix() + public function testGenerateFilterWithOptionSuffix(): void { command('make:filter admin -suffix'); $this->assertFileExists(APPPATH . 'Filters/AdminFilter.php'); diff --git a/tests/system/Commands/GenerateKeyTest.php b/tests/system/Commands/GenerateKeyTest.php index 6c313e648cff..dd0f8bc91f0a 100644 --- a/tests/system/Commands/GenerateKeyTest.php +++ b/tests/system/Commands/GenerateKeyTest.php @@ -62,13 +62,13 @@ protected function getBuffer(): string return $this->getStreamFilterBuffer(); } - protected function resetEnvironment() + protected function resetEnvironment(): void { putenv('encryption.key'); unset($_ENV['encryption.key'], $_SERVER['encryption.key']); } - public function testGenerateKeyShowsEncodedKey() + public function testGenerateKeyShowsEncodedKey(): void { command('key:generate --show'); $this->assertStringContainsString('hex2bin:', $this->getBuffer()); @@ -84,7 +84,7 @@ public function testGenerateKeyShowsEncodedKey() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testGenerateKeyCreatesNewKey() + public function testGenerateKeyCreatesNewKey(): void { command('key:generate'); $this->assertStringContainsString('successfully set.', $this->getBuffer()); @@ -102,7 +102,7 @@ public function testGenerateKeyCreatesNewKey() $this->assertStringContainsString('hex2bin:', file_get_contents($this->envPath)); } - public function testDefaultShippedEnvIsMissing() + public function testDefaultShippedEnvIsMissing(): void { rename(ROOTPATH . 'env', ROOTPATH . 'lostenv'); command('key:generate'); @@ -115,7 +115,7 @@ public function testDefaultShippedEnvIsMissing() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/6838 */ - public function testKeyGenerateWhenKeyIsMissingInDotEnvFile() + public function testKeyGenerateWhenKeyIsMissingInDotEnvFile(): void { file_put_contents($this->envPath, ''); @@ -125,7 +125,7 @@ public function testKeyGenerateWhenKeyIsMissingInDotEnvFile() $this->assertSame("\nencryption.key = " . env('encryption.key'), file_get_contents($this->envPath)); } - public function testKeyGenerateWhenNewHexKeyIsSubsequentlyCommentedOut() + public function testKeyGenerateWhenNewHexKeyIsSubsequentlyCommentedOut(): void { command('key:generate'); $key = env('encryption.key', ''); @@ -143,7 +143,7 @@ public function testKeyGenerateWhenNewHexKeyIsSubsequentlyCommentedOut() $this->assertNotSame($key, env('encryption.key', $key), 'Failed replacing the commented out key.'); } - public function testKeyGenerateWhenNewBase64KeyIsSubsequentlyCommentedOut() + public function testKeyGenerateWhenNewBase64KeyIsSubsequentlyCommentedOut(): void { command('key:generate --prefix base64'); $key = env('encryption.key', ''); diff --git a/tests/system/Commands/GeneratorsTest.php b/tests/system/Commands/GeneratorsTest.php index d02fd2eea78b..2e5162b074a8 100644 --- a/tests/system/Commands/GeneratorsTest.php +++ b/tests/system/Commands/GeneratorsTest.php @@ -23,7 +23,7 @@ final class GeneratorsTest extends CIUnitTestCase { use StreamFilterTrait; - public function testGenerateFileCreated() + public function testGenerateFileCreated(): void { command('make:seeder categories'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -33,7 +33,7 @@ public function testGenerateFileCreated() } } - public function testGenerateFileExists() + public function testGenerateFileExists(): void { command('make:filter items'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -46,7 +46,7 @@ public function testGenerateFileExists() } } - public function testGenerateFileOverwritten() + public function testGenerateFileOverwritten(): void { command('make:controller products'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -59,7 +59,7 @@ public function testGenerateFileOverwritten() } } - public function testGenerateFileFailsOnUnwritableDirectory() + public function testGenerateFileFailsOnUnwritableDirectory(): void { if (is_windows()) { $this->markTestSkipped('chmod does not work as expected on Windows'); @@ -73,13 +73,13 @@ public function testGenerateFileFailsOnUnwritableDirectory() chmod(APPPATH . 'Filters', 0755); } - public function testGenerateFailsOnUndefinedNamespace() + public function testGenerateFailsOnUndefinedNamespace(): void { command('make:model cars -namespace CodeIgnite'); $this->assertStringContainsString('Namespace "CodeIgnite" is not defined.', $this->getStreamFilterBuffer()); } - public function testGenerateFileInSubfolders() + public function testGenerateFileInSubfolders(): void { command('make:controller admin/user'); $file = APPPATH . 'Controllers/Admin/User.php'; diff --git a/tests/system/Commands/HelpCommandTest.php b/tests/system/Commands/HelpCommandTest.php index 3b56b3c92130..c51a286e5bbf 100644 --- a/tests/system/Commands/HelpCommandTest.php +++ b/tests/system/Commands/HelpCommandTest.php @@ -28,7 +28,7 @@ protected function getBuffer() return $this->getStreamFilterBuffer(); } - public function testHelpCommand() + public function testHelpCommand(): void { command('help'); @@ -37,25 +37,25 @@ public function testHelpCommand() $this->assertStringContainsString('command_name', $this->getBuffer()); } - public function testHelpCommandWithMissingUsage() + public function testHelpCommandWithMissingUsage(): void { command('help app:info'); $this->assertStringContainsString('app:info [arguments]', $this->getBuffer()); } - public function testHelpCommandOnSpecificCommand() + public function testHelpCommandOnSpecificCommand(): void { command('help cache:clear'); $this->assertStringContainsString('Clears the current system caches.', $this->getBuffer()); } - public function testHelpCommandOnInexistentCommand() + public function testHelpCommandOnInexistentCommand(): void { command('help fixme'); $this->assertStringContainsString('Command "fixme" not found', $this->getBuffer()); } - public function testHelpCommandOnInexistentCommandButWithAlternatives() + public function testHelpCommandOnInexistentCommandButWithAlternatives(): void { command('help clear'); $this->assertStringContainsString('Command "clear" not found.', $this->getBuffer()); diff --git a/tests/system/Commands/InfoCacheTest.php b/tests/system/Commands/InfoCacheTest.php index 91312a6e36cd..fc0337087b3a 100644 --- a/tests/system/Commands/InfoCacheTest.php +++ b/tests/system/Commands/InfoCacheTest.php @@ -44,7 +44,7 @@ protected function getBuffer() return $this->getStreamFilterBuffer(); } - public function testInfoCacheErrorsOnInvalidHandler() + public function testInfoCacheErrorsOnInvalidHandler(): void { config('Cache')->handler = 'redis'; cache()->save('foo', 'bar'); @@ -53,7 +53,7 @@ public function testInfoCacheErrorsOnInvalidHandler() $this->assertStringContainsString('This command only supports the file cache handler.', $this->getBuffer()); } - public function testInfoCacheCanSeeFoo() + public function testInfoCacheCanSeeFoo(): void { cache()->save('foo', 'bar'); command('cache:info'); @@ -61,7 +61,7 @@ public function testInfoCacheCanSeeFoo() $this->assertStringContainsString('foo', $this->getBuffer()); } - public function testInfoCacheCanSeeTable() + public function testInfoCacheCanSeeTable(): void { command('cache:info'); @@ -71,7 +71,7 @@ public function testInfoCacheCanSeeTable() $this->assertStringContainsString('Date', $this->getBuffer()); } - public function testInfoCacheCannotSeeFoo() + public function testInfoCacheCannotSeeFoo(): void { cache()->delete('foo'); command('cache:info'); diff --git a/tests/system/Commands/MigrationGeneratorTest.php b/tests/system/Commands/MigrationGeneratorTest.php index b07c69726791..890c36c56fe7 100644 --- a/tests/system/Commands/MigrationGeneratorTest.php +++ b/tests/system/Commands/MigrationGeneratorTest.php @@ -32,25 +32,25 @@ protected function tearDown(): void } } - public function testGenerateMigration() + public function testGenerateMigration(): void { command('make:migration database'); $this->assertStringContainsString('_Database.php', $this->getStreamFilterBuffer()); } - public function testGenerateMigrationWithOptionSession() + public function testGenerateMigrationWithOptionSession(): void { command('make:migration -session'); $this->assertStringContainsString('_CreateCiSessionsTable.php', $this->getStreamFilterBuffer()); } - public function testGenerateMigrationWithOptionTable() + public function testGenerateMigrationWithOptionTable(): void { command('make:migration -session -table logger'); $this->assertStringContainsString('_CreateLoggerTable.php', $this->getStreamFilterBuffer()); } - public function testGenerateMigrationWithOptionSuffix() + public function testGenerateMigrationWithOptionSuffix(): void { command('make:migration database -suffix'); $this->assertStringContainsString('_DatabaseMigration.php', $this->getStreamFilterBuffer()); diff --git a/tests/system/Commands/ModelGeneratorTest.php b/tests/system/Commands/ModelGeneratorTest.php index 0e193d62702c..e6ca050d553b 100644 --- a/tests/system/Commands/ModelGeneratorTest.php +++ b/tests/system/Commands/ModelGeneratorTest.php @@ -44,7 +44,7 @@ private function getFileContent(string $filepath): string return file_get_contents($filepath) ?: ''; } - public function testGenerateModel() + public function testGenerateModel(): void { command('make:model user --table users'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -56,7 +56,7 @@ public function testGenerateModel() $this->assertStringContainsString('protected $returnType = \'array\';', $this->getFileContent($file)); } - public function testGenerateModelWithOptionTable() + public function testGenerateModelWithOptionTable(): void { command('make:model cars -table utilisateur'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -65,7 +65,7 @@ public function testGenerateModelWithOptionTable() $this->assertStringContainsString('protected $table = \'utilisateur\';', $this->getFileContent($file)); } - public function testGenerateModelWithOptionDBGroup() + public function testGenerateModelWithOptionDBGroup(): void { command('make:model user -dbgroup testing'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -74,7 +74,7 @@ public function testGenerateModelWithOptionDBGroup() $this->assertStringContainsString('protected $DBGroup = \'testing\';', $this->getFileContent($file)); } - public function testGenerateModelWithOptionReturnArray() + public function testGenerateModelWithOptionReturnArray(): void { command('make:model user --return array'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -83,7 +83,7 @@ public function testGenerateModelWithOptionReturnArray() $this->assertStringContainsString('protected $returnType = \'array\';', $this->getFileContent($file)); } - public function testGenerateModelWithOptionReturnObject() + public function testGenerateModelWithOptionReturnObject(): void { command('make:model user --return object'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -92,7 +92,7 @@ public function testGenerateModelWithOptionReturnObject() $this->assertStringContainsString('protected $returnType = \'object\';', $this->getFileContent($file)); } - public function testGenerateModelWithOptionReturnEntity() + public function testGenerateModelWithOptionReturnEntity(): void { command('make:model user --return entity'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -118,7 +118,7 @@ public function testGenerateModelWithOptionReturnEntity() } } - public function testGenerateModelWithOptionSuffix() + public function testGenerateModelWithOptionSuffix(): void { command('make:model user --suffix --return entity'); @@ -136,7 +136,7 @@ public function testGenerateModelWithOptionSuffix() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/5050 */ - public function testGenerateModelWithSuffixAndMixedPascalCasedName() + public function testGenerateModelWithSuffixAndMixedPascalCasedName(): void { command('make:model MyTable --suffix --return entity'); diff --git a/tests/system/Commands/PublishCommandTest.php b/tests/system/Commands/PublishCommandTest.php index a56e7661505a..b176a03c42c5 100644 --- a/tests/system/Commands/PublishCommandTest.php +++ b/tests/system/Commands/PublishCommandTest.php @@ -31,7 +31,7 @@ protected function tearDown(): void TestPublisher::setResult(true); } - public function testDefault() + public function testDefault(): void { command('publish'); @@ -42,7 +42,7 @@ public function testDefault() ]), $this->getStreamFilterBuffer()); } - public function testFailure() + public function testFailure(): void { TestPublisher::setResult(false); diff --git a/tests/system/Commands/RoutesTest.php b/tests/system/Commands/RoutesTest.php index bb89d35bb96d..d1625dcfc1bc 100644 --- a/tests/system/Commands/RoutesTest.php +++ b/tests/system/Commands/RoutesTest.php @@ -51,7 +51,7 @@ private function getCleanRoutes(): RouteCollection return $routes; } - public function testRoutesCommand() + public function testRoutesCommand(): void { $this->getCleanRoutes(); @@ -77,7 +77,7 @@ public function testRoutesCommand() $this->assertStringContainsString($expected, $this->getBuffer()); } - public function testRoutesCommandSortByHandler() + public function testRoutesCommandSortByHandler(): void { $this->getCleanRoutes(); @@ -103,7 +103,7 @@ public function testRoutesCommandSortByHandler() $this->assertStringContainsString($expected, $this->getBuffer()); } - public function testRoutesCommandAutoRouteImproved() + public function testRoutesCommandAutoRouteImproved(): void { $routes = $this->getCleanRoutes(); @@ -136,7 +136,7 @@ public function testRoutesCommandAutoRouteImproved() $this->assertStringContainsString($expected, $this->getBuffer()); } - public function testRoutesCommandRouteLegacy() + public function testRoutesCommandRouteLegacy(): void { $routes = $this->getCleanRoutes(); diff --git a/tests/system/Commands/ScaffoldGeneratorTest.php b/tests/system/Commands/ScaffoldGeneratorTest.php index 113710725143..4caa26fd123f 100644 --- a/tests/system/Commands/ScaffoldGeneratorTest.php +++ b/tests/system/Commands/ScaffoldGeneratorTest.php @@ -43,7 +43,7 @@ protected function getFileContents(string $filepath): string return file_get_contents($filepath) ?: ''; } - public function testCreateComponentProducesManyFiles() + public function testCreateComponentProducesManyFiles(): void { command('make:scaffold people'); @@ -66,7 +66,7 @@ public function testCreateComponentProducesManyFiles() unlink(APPPATH . 'Database/Seeds/People.php'); } - public function testCreateComponentWithManyOptions() + public function testCreateComponentWithManyOptions(): void { command('make:scaffold user -restful -return entity'); @@ -95,7 +95,7 @@ public function testCreateComponentWithManyOptions() unlink(APPPATH . 'Models/User.php'); } - public function testCreateComponentWithOptionSuffix() + public function testCreateComponentWithOptionSuffix(): void { command('make:scaffold order -suffix'); @@ -118,7 +118,7 @@ public function testCreateComponentWithOptionSuffix() unlink(APPPATH . 'Models/OrderModel.php'); } - public function testCreateComponentWithOptionForce() + public function testCreateComponentWithOptionForce(): void { command('make:controller fixer'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); @@ -151,7 +151,7 @@ public function testCreateComponentWithOptionForce() unlink(APPPATH . 'Models/Fixer.php'); } - public function testCreateComponentWithOptionNamespace() + public function testCreateComponentWithOptionNamespace(): void { command('make:scaffold product -namespace App'); diff --git a/tests/system/Commands/SeederGeneratorTest.php b/tests/system/Commands/SeederGeneratorTest.php index 57586084f402..035168759f52 100644 --- a/tests/system/Commands/SeederGeneratorTest.php +++ b/tests/system/Commands/SeederGeneratorTest.php @@ -34,14 +34,14 @@ protected function tearDown(): void } } - public function testGenerateSeeder() + public function testGenerateSeeder(): void { command('make:seeder cars'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); $this->assertFileExists(APPPATH . 'Database/Seeds/Cars.php'); } - public function testGenerateSeederWithOptionSuffix() + public function testGenerateSeederWithOptionSuffix(): void { command('make:seeder cars -suffix'); $this->assertStringContainsString('File created: ', $this->getStreamFilterBuffer()); diff --git a/tests/system/Commands/Utilities/NamespacesTest.php b/tests/system/Commands/Utilities/NamespacesTest.php index 26eabd32895f..755dd70f7cc6 100644 --- a/tests/system/Commands/Utilities/NamespacesTest.php +++ b/tests/system/Commands/Utilities/NamespacesTest.php @@ -47,7 +47,7 @@ protected function getBuffer() }, str_replace(PHP_EOL, "\n", $this->getStreamFilterBuffer())); } - public function testNamespacesCommandCodeIgniterOnly() + public function testNamespacesCommandCodeIgniterOnly(): void { command('namespaces -c'); @@ -65,7 +65,7 @@ public function testNamespacesCommandCodeIgniterOnly() $this->assertStringContainsString($expected, $this->getBuffer()); } - public function testNamespacesCommandAllNamespaces() + public function testNamespacesCommandAllNamespaces(): void { command('namespaces'); diff --git a/tests/system/Commands/Utilities/Routes/AutoRouteCollectorTest.php b/tests/system/Commands/Utilities/Routes/AutoRouteCollectorTest.php index 9279bd47b70c..2db5a603fb95 100644 --- a/tests/system/Commands/Utilities/Routes/AutoRouteCollectorTest.php +++ b/tests/system/Commands/Utilities/Routes/AutoRouteCollectorTest.php @@ -20,7 +20,7 @@ */ final class AutoRouteCollectorTest extends CIUnitTestCase { - public function testGet() + public function testGet(): void { $namespace = 'Tests\Support\Controllers'; $collector = new AutoRouteCollector( diff --git a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php index 4b99de7dbb07..d9dfee3e98ad 100644 --- a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php +++ b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollectorTest.php @@ -52,7 +52,7 @@ private function createAutoRouteCollector(array $filterConfigFilters): AutoRoute ); } - public function testGetFilterMatches() + public function testGetFilterMatches(): void { $filterConfigFilters = ['honeypot' => ['before' => ['newautorouting/save*']]]; $collector = $this->createAutoRouteCollector($filterConfigFilters); @@ -80,7 +80,7 @@ public function testGetFilterMatches() $this->assertSame($expected, $routes); } - public function testGetFilterDoesNotMatch() + public function testGetFilterDoesNotMatch(): void { $filterConfigFilters = ['honeypot' => ['before' => ['newautorouting/save/*/*']]]; $collector = $this->createAutoRouteCollector($filterConfigFilters); diff --git a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReaderTest.php b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReaderTest.php index 5df8c4f8ff0d..e3e23c29dc7a 100644 --- a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReaderTest.php +++ b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReaderTest.php @@ -34,7 +34,7 @@ private function createControllerMethodReader( return new ControllerMethodReader($namespace, $methods); } - public function testRead() + public function testRead(): void { $reader = $this->createControllerMethodReader(); @@ -64,7 +64,7 @@ public function testRead() $this->assertSame($expected, $routes); } - public function testReadDefaultController() + public function testReadDefaultController(): void { $reader = $this->createControllerMethodReader( 'CodeIgniter\Commands\Utilities\Routes\AutoRouterImproved\Controllers' @@ -99,7 +99,7 @@ public function testReadDefaultController() $this->assertSame($expected, $routes); } - public function testReadControllerWithRemap() + public function testReadControllerWithRemap(): void { $reader = $this->createControllerMethodReader(); diff --git a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/Controllers/Home.php b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/Controllers/Home.php index 4666a709a07b..f4836ffc7f6a 100644 --- a/tests/system/Commands/Utilities/Routes/AutoRouterImproved/Controllers/Home.php +++ b/tests/system/Commands/Utilities/Routes/AutoRouterImproved/Controllers/Home.php @@ -18,18 +18,18 @@ */ class Home extends Controller { - public function getIndex() + public function getIndex(): void { } - public function postIndex() + public function postIndex(): void { } /** * This method cannot be accessible. */ - public function getFoo() + public function getFoo(): void { } } diff --git a/tests/system/Commands/Utilities/Routes/ControllerFinderTest.php b/tests/system/Commands/Utilities/Routes/ControllerFinderTest.php index 32a2bd54ab1c..fecc080d8705 100644 --- a/tests/system/Commands/Utilities/Routes/ControllerFinderTest.php +++ b/tests/system/Commands/Utilities/Routes/ControllerFinderTest.php @@ -21,7 +21,7 @@ */ final class ControllerFinderTest extends CIUnitTestCase { - public function testFind() + public function testFind(): void { $namespace = 'Tests\Support\Controllers'; $finder = new ControllerFinder($namespace); diff --git a/tests/system/Commands/Utilities/Routes/ControllerMethodReaderTest.php b/tests/system/Commands/Utilities/Routes/ControllerMethodReaderTest.php index ee315135304d..349d814b23c7 100644 --- a/tests/system/Commands/Utilities/Routes/ControllerMethodReaderTest.php +++ b/tests/system/Commands/Utilities/Routes/ControllerMethodReaderTest.php @@ -22,7 +22,7 @@ */ final class ControllerMethodReaderTest extends CIUnitTestCase { - public function testRead() + public function testRead(): void { $namespace = 'Tests\Support\Controllers'; $reader = new ControllerMethodReader($namespace); @@ -90,7 +90,7 @@ public function testRead() $this->assertSame($expected, $routes); } - public function testReadControllerWithRemap() + public function testReadControllerWithRemap(): void { $namespace = 'Tests\Support\Controllers'; $reader = new ControllerMethodReader($namespace); diff --git a/tests/system/Commands/Utilities/Routes/FilterCollectorTest.php b/tests/system/Commands/Utilities/Routes/FilterCollectorTest.php index ff4df4090c4c..1363d468a49d 100644 --- a/tests/system/Commands/Utilities/Routes/FilterCollectorTest.php +++ b/tests/system/Commands/Utilities/Routes/FilterCollectorTest.php @@ -21,7 +21,7 @@ */ final class FilterCollectorTest extends CIUnitTestCase { - public function testGet() + public function testGet(): void { $routes = Services::routes(); $routes->resetRoutes(); diff --git a/tests/system/Commands/Utilities/Routes/FilterFinderTest.php b/tests/system/Commands/Utilities/Routes/FilterFinderTest.php index ace71d9d7e2d..15b970cd4351 100644 --- a/tests/system/Commands/Utilities/Routes/FilterFinderTest.php +++ b/tests/system/Commands/Utilities/Routes/FilterFinderTest.php @@ -96,7 +96,7 @@ private function createFilters(array $config = []): Filters return new Filters($filtersConfig, $this->request, $this->response, $this->moduleConfig); } - public function testFindGlobalsFilters() + public function testFindGlobalsFilters(): void { $collection = $this->createRouteCollection(); $router = $this->createRouter($collection); @@ -113,7 +113,7 @@ public function testFindGlobalsFilters() $this->assertSame($expected, $filters); } - public function testFindGlobalsFiltersWithRedirectRoute() + public function testFindGlobalsFiltersWithRedirectRoute(): void { $collection = $this->createRouteCollection(); $collection->addRedirect('users/about', 'profile'); @@ -132,7 +132,7 @@ public function testFindGlobalsFiltersWithRedirectRoute() $this->assertSame($expected, $filters); } - public function testFindGlobalsAndRouteFilters() + public function testFindGlobalsAndRouteFilters(): void { $collection = $this->createRouteCollection(); $collection->get('admin', ' AdminController::index', ['filter' => 'honeypot']); @@ -150,7 +150,7 @@ public function testFindGlobalsAndRouteFilters() $this->assertSame($expected, $filters); } - public function testFindGlobalsAndRouteClassnameFilters() + public function testFindGlobalsAndRouteClassnameFilters(): void { $collection = $this->createRouteCollection(); $collection->get('admin', ' AdminController::index', ['filter' => InvalidChars::class]); @@ -168,7 +168,7 @@ public function testFindGlobalsAndRouteClassnameFilters() $this->assertSame($expected, $filters); } - public function testFindGlobalsAndRouteMultipleFilters() + public function testFindGlobalsAndRouteMultipleFilters(): void { config('Feature')->multipleFilters = true; diff --git a/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php b/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php index fe7bf12613a7..ec4acc47259e 100644 --- a/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php +++ b/tests/system/Commands/Utilities/Routes/SampleURIGeneratorTest.php @@ -24,7 +24,7 @@ final class SampleURIGeneratorTest extends CIUnitTestCase /** * @dataProvider routeKeyProvider */ - public function testGet(string $routeKey, string $expected) + public function testGet(string $routeKey, string $expected): void { $generator = new SampleURIGenerator(); @@ -44,7 +44,7 @@ public function routeKeyProvider(): iterable ]; } - public function testGetFromPlaceholderCustomPlaceholder() + public function testGetFromPlaceholderCustomPlaceholder(): void { $routes = Services::routes(); $routes->addPlaceholder( diff --git a/tests/system/Commands/ValidationGeneratorTest.php b/tests/system/Commands/ValidationGeneratorTest.php index 39c3fd833a5f..ec208179be79 100644 --- a/tests/system/Commands/ValidationGeneratorTest.php +++ b/tests/system/Commands/ValidationGeneratorTest.php @@ -38,13 +38,13 @@ protected function tearDown(): void } } - public function testGenerateValidation() + public function testGenerateValidation(): void { command('make:validation user'); $this->assertFileExists(APPPATH . 'Validation/User.php'); } - public function testGenerateValidationWithOptionSuffix() + public function testGenerateValidationWithOptionSuffix(): void { command('make:validation admin -suffix'); $this->assertFileExists(APPPATH . 'Validation/AdminValidation.php'); diff --git a/tests/system/CommonFunctionsSendTest.php b/tests/system/CommonFunctionsSendTest.php index 365049315778..a580366277fb 100644 --- a/tests/system/CommonFunctionsSendTest.php +++ b/tests/system/CommonFunctionsSendTest.php @@ -34,7 +34,7 @@ protected function setUp(): void * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testRedirectResponseCookiesSent() + public function testRedirectResponseCookiesSent(): void { $loginTime = time(); diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index b304eeab69eb..8d4f7199d0e1 100644 --- a/tests/system/CommonFunctionsTest.php +++ b/tests/system/CommonFunctionsTest.php @@ -56,7 +56,7 @@ protected function setUp(): void parent::setUp(); } - public function testStringifyAttributes() + public function testStringifyAttributes(): void { $this->assertSame(' class="foo" id="bar"', stringify_attributes(['class' => 'foo', 'id' => 'bar'])); @@ -73,7 +73,7 @@ public function testStringifyAttributes() $this->assertSame('', stringify_attributes([])); } - public function testStringifyJsAttributes() + public function testStringifyJsAttributes(): void { $this->assertSame('width=800,height=600', stringify_attributes(['width' => '800', 'height' => '600'], true)); @@ -83,26 +83,26 @@ public function testStringifyJsAttributes() $this->assertSame('width=800,height=600', stringify_attributes($atts, true)); } - public function testEnvReturnsDefault() + public function testEnvReturnsDefault(): void { $this->assertSame('baz', env('foo', 'baz')); } - public function testEnvGetsFromSERVER() + public function testEnvGetsFromSERVER(): void { $_SERVER['foo'] = 'bar'; $this->assertSame('bar', env('foo', 'baz')); } - public function testEnvGetsFromENV() + public function testEnvGetsFromENV(): void { $_ENV['foo'] = 'bar'; $this->assertSame('bar', env('foo', 'baz')); } - public function testEnvBooleans() + public function testEnvBooleans(): void { $_ENV['p1'] = 'true'; $_ENV['p2'] = 'false'; @@ -115,7 +115,7 @@ public function testEnvBooleans() $this->assertNull(env('p4')); } - public function testRedirectReturnsRedirectResponse() + public function testRedirectReturnsRedirectResponse(): void { $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -133,12 +133,12 @@ public function testRedirectReturnsRedirectResponse() $this->assertInstanceOf(RedirectResponse::class, redirect('base')); } - public function testRedirectDefault() + public function testRedirectDefault(): void { $this->assertInstanceOf(RedirectResponse::class, redirect()); } - public function testRequestIncomingRequest() + public function testRequestIncomingRequest(): void { Services::createRequest(new App()); @@ -147,7 +147,7 @@ public function testRequestIncomingRequest() $this->assertInstanceOf(IncomingRequest::class, $request); } - public function testRequestCLIRequest() + public function testRequestCLIRequest(): void { Services::createRequest(new App(), true); @@ -156,19 +156,19 @@ public function testRequestCLIRequest() $this->assertInstanceOf(CLIRequest::class, $request); } - public function testResponse() + public function testResponse(): void { $response = response(); $this->assertInstanceOf(Response::class, $response); } - public function testSolidusElement() + public function testSolidusElement(): void { $this->assertSame('', _solidus()); } - public function testSolidusElementXHTML() + public function testSolidusElementXHTML(): void { $doctypes = config('DocTypes'); $default = $doctypes->html5; @@ -180,7 +180,7 @@ public function testSolidusElementXHTML() $doctypes->html5 = $default; } - public function testView() + public function testView(): void { $data = [ 'testString' => 'bar', @@ -190,7 +190,7 @@ public function testView() $this->assertStringContainsString($expected, view('\Tests\Support\View\Views\simple', $data)); } - public function testViewSavedData() + public function testViewSavedData(): void { $data = [ 'testString' => 'bar', @@ -201,26 +201,26 @@ public function testViewSavedData() $this->assertStringContainsString($expected, view('\Tests\Support\View\Views\simple')); } - public function testViewCell() + public function testViewCell(): void { $expected = 'Hello'; $this->assertSame($expected, view_cell('\Tests\Support\View\SampleClass::hello')); } - public function testEscapeWithDifferentEncodings() + public function testEscapeWithDifferentEncodings(): void { $this->assertSame('<x', esc('assertSame('<x', esc('assertSame('<x', esc('expectException('InvalidArgumentException'); esc(['width' => '800', 'height' => '600'], 'bogus'); } - public function testEscapeBadContextZero() + public function testEscapeBadContextZero(): void { $this->expectException('InvalidArgumentException'); esc('', 'http://example.com'); @@ -337,7 +337,7 @@ public function testRequestMethodGetsSanitized() $this->assertSame('CUSTOM', $options[CURLOPT_CUSTOMREQUEST]); } - public function testRequestSetsBasicCurlOptions() + public function testRequestSetsBasicCurlOptions(): void { $this->request->request('get', 'http://example.com'); @@ -362,7 +362,7 @@ public function testRequestSetsBasicCurlOptions() $this->assertSame(150000.0, $options[CURLOPT_CONNECTTIMEOUT_MS]); } - public function testAuthBasicOption() + public function testAuthBasicOption(): void { $this->request->request('get', 'http://example.com', [ 'auth' => [ @@ -380,7 +380,7 @@ public function testAuthBasicOption() $this->assertSame(CURLAUTH_BASIC, $options[CURLOPT_HTTPAUTH]); } - public function testAuthBasicOptionExplicit() + public function testAuthBasicOptionExplicit(): void { $this->request->request('get', 'http://example.com', [ 'auth' => [ @@ -399,7 +399,7 @@ public function testAuthBasicOptionExplicit() $this->assertSame(CURLAUTH_BASIC, $options[CURLOPT_HTTPAUTH]); } - public function testAuthDigestOption() + public function testAuthDigestOption(): void { $output = "HTTP/1.1 401 Unauthorized Server: ddos-guard @@ -439,7 +439,7 @@ public function testAuthDigestOption() $this->assertSame(CURLAUTH_DIGEST, $options[CURLOPT_HTTPAUTH]); } - public function testSetAuthBasic() + public function testSetAuthBasic(): void { $this->request->setAuth('username', 'password')->get('http://example.com'); @@ -452,7 +452,7 @@ public function testSetAuthBasic() $this->assertSame(CURLAUTH_BASIC, $options[CURLOPT_HTTPAUTH]); } - public function testSetAuthDigest() + public function testSetAuthDigest(): void { $output = "HTTP/1.1 401 Unauthorized Server: ddos-guard @@ -486,7 +486,7 @@ public function testSetAuthDigest() $this->assertSame(CURLAUTH_DIGEST, $options[CURLOPT_HTTPAUTH]); } - public function testCertOption() + public function testCertOption(): void { $file = __FILE__; @@ -500,7 +500,7 @@ public function testCertOption() $this->assertSame($file, $options[CURLOPT_SSLCERT]); } - public function testCertOptionWithPassword() + public function testCertOptionWithPassword(): void { $file = __FILE__; @@ -520,7 +520,7 @@ public function testCertOptionWithPassword() $this->assertSame('password', $options[CURLOPT_SSLCERTPASSWD]); } - public function testMissingCertOption() + public function testMissingCertOption(): void { $file = 'something_obviously_bogus'; $this->expectException(HTTPException::class); @@ -530,7 +530,7 @@ public function testMissingCertOption() ]); } - public function testSSLVerification() + public function testSSLVerification(): void { $file = __FILE__; @@ -548,7 +548,7 @@ public function testSSLVerification() $this->assertSame(1, $options[CURLOPT_SSL_VERIFYPEER]); } - public function testSSLWithBadKey() + public function testSSLWithBadKey(): void { $file = 'something_obviously_bogus'; $this->expectException(HTTPException::class); @@ -559,7 +559,7 @@ public function testSSLWithBadKey() ]); } - public function testDebugOptionTrue() + public function testDebugOptionTrue(): void { $this->request->request('get', 'http://example.com', [ 'debug' => true, @@ -574,7 +574,7 @@ public function testDebugOptionTrue() $this->assertIsResource($options[CURLOPT_STDERR]); } - public function testDebugOptionFalse() + public function testDebugOptionFalse(): void { $this->request->request('get', 'http://example.com', [ 'debug' => false, @@ -586,7 +586,7 @@ public function testDebugOptionFalse() $this->assertArrayNotHasKey(CURLOPT_STDERR, $options); } - public function testDebugOptionFile() + public function testDebugOptionFile(): void { $file = SUPPORTPATH . 'Files/baker/banana.php'; @@ -603,7 +603,7 @@ public function testDebugOptionFile() $this->assertIsResource($options[CURLOPT_STDERR]); } - public function testDecodeContent() + public function testDecodeContent(): void { $this->request->setHeader('Accept-Encoding', 'cobol'); $this->request->request('get', 'http://example.com', [ @@ -616,7 +616,7 @@ public function testDecodeContent() $this->assertSame('cobol', $options[CURLOPT_ENCODING]); } - public function testDecodeContentWithoutAccept() + public function testDecodeContentWithoutAccept(): void { // $this->request->setHeader('Accept-Encoding', 'cobol'); $this->request->request('get', 'http://example.com', [ @@ -631,7 +631,7 @@ public function testDecodeContentWithoutAccept() $this->assertSame('Accept-Encoding', $options[CURLOPT_HTTPHEADER]); } - public function testAllowRedirectsOptionFalse() + public function testAllowRedirectsOptionFalse(): void { $this->request->request('get', 'http://example.com', [ 'allow_redirects' => false, @@ -646,7 +646,7 @@ public function testAllowRedirectsOptionFalse() $this->assertArrayNotHasKey(CURLOPT_REDIR_PROTOCOLS, $options); } - public function testAllowRedirectsOptionTrue() + public function testAllowRedirectsOptionTrue(): void { $this->request->request('get', 'http://example.com', [ 'allow_redirects' => true, @@ -663,7 +663,7 @@ public function testAllowRedirectsOptionTrue() $this->assertSame(CURLPROTO_HTTP | CURLPROTO_HTTPS, $options[CURLOPT_REDIR_PROTOCOLS]); } - public function testAllowRedirectsOptionDefaults() + public function testAllowRedirectsOptionDefaults(): void { $this->request->request('get', 'http://example.com', [ 'allow_redirects' => true, @@ -678,7 +678,7 @@ public function testAllowRedirectsOptionDefaults() $this->assertArrayHasKey(CURLOPT_REDIR_PROTOCOLS, $options); } - public function testAllowRedirectsArray() + public function testAllowRedirectsArray(): void { $this->request->request('get', 'http://example.com', [ 'allow_redirects' => ['max' => 2], @@ -693,7 +693,7 @@ public function testAllowRedirectsArray() $this->assertSame(2, $options[CURLOPT_MAXREDIRS]); } - public function testSendWithQuery() + public function testSendWithQuery(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -710,7 +710,7 @@ public function testSendWithQuery() $this->assertSame('http://www.foo.com/api/v1/products?name=Henry&d.t=value', $options[CURLOPT_URL]); } - public function testSendWithDelay() + public function testSendWithDelay(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -723,7 +723,7 @@ public function testSendWithDelay() $this->assertSame(0.1, $request->getDelay()); } - public function testSendContinued() + public function testSendContinued(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -738,7 +738,7 @@ public function testSendContinued() /** * See: https://github.com/codeigniter4/CodeIgniter4/issues/3261 */ - public function testSendContinuedWithManyHeaders() + public function testSendContinuedWithManyHeaders(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -785,7 +785,7 @@ public function testSendContinuedWithManyHeaders() /** * See: https://github.com/codeigniter4/CodeIgniter4/issues/7394 */ - public function testResponseHeadersWithMultipleRequests() + public function testResponseHeadersWithMultipleRequests(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -838,7 +838,7 @@ public function testResponseHeadersWithMultipleRequests() $this->assertSame(200, $response->getStatusCode()); } - public function testSplitResponse() + public function testSplitResponse(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -850,7 +850,7 @@ public function testSplitResponse() $this->assertSame('Hi there', $response->getBody()); } - public function testApplyBody() + public function testApplyBody(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -865,7 +865,7 @@ public function testApplyBody() $this->assertSame('name=George', $request->curl_options[CURLOPT_POSTFIELDS]); } - public function testApplyBodyByOptions() + public function testApplyBodyByOptions(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -881,7 +881,7 @@ public function testApplyBodyByOptions() $this->assertSame('name=George', $request->curl_options[CURLOPT_POSTFIELDS]); } - public function testBodyIsResetOnSecondRequest() + public function testBodyIsResetOnSecondRequest(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -896,7 +896,7 @@ public function testBodyIsResetOnSecondRequest() $this->assertArrayNotHasKey(CURLOPT_POSTFIELDS, $request->curl_options); } - public function testResponseHeaders() + public function testResponseHeaders(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -910,7 +910,7 @@ public function testResponseHeaders() $this->assertSame(234, $response->getStatusCode()); } - public function testResponseHeadersShortProtocol() + public function testResponseHeadersShortProtocol(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -924,7 +924,7 @@ public function testResponseHeadersShortProtocol() $this->assertSame(235, $response->getStatusCode()); } - public function testPostFormEncoded() + public function testPostFormEncoded(): void { $params = [ 'foo' => 'bar', @@ -946,7 +946,7 @@ public function testPostFormEncoded() $this->assertSame($expected, $options[CURLOPT_POSTFIELDS]); } - public function testPostFormMultipart() + public function testPostFormMultipart(): void { $params = [ 'foo' => 'bar', @@ -968,7 +968,7 @@ public function testPostFormMultipart() $this->assertSame($params, $options[CURLOPT_POSTFIELDS]); } - public function testSetForm() + public function testSetForm(): void { $params = [ 'foo' => 'bar', @@ -995,7 +995,7 @@ public function testSetForm() ); } - public function testJSONData() + public function testJSONData(): void { $params = [ 'foo' => 'bar', @@ -1017,7 +1017,7 @@ public function testJSONData() ); } - public function testSetJSON() + public function testSetJSON(): void { $params = [ 'foo' => 'bar', @@ -1040,7 +1040,7 @@ public function testSetJSON() ); } - public function testHTTPv1() + public function testHTTPv1(): void { $this->request->request('POST', '/post', [ 'version' => 1.0, @@ -1052,7 +1052,7 @@ public function testHTTPv1() $this->assertSame(CURL_HTTP_VERSION_1_0, $options[CURLOPT_HTTP_VERSION]); } - public function testHTTPv11() + public function testHTTPv11(): void { $this->request->request('POST', '/post', [ 'version' => 1.1, @@ -1064,7 +1064,7 @@ public function testHTTPv11() $this->assertSame(CURL_HTTP_VERSION_1_1, $options[CURLOPT_HTTP_VERSION]); } - public function testCookieOption() + public function testCookieOption(): void { $holder = SUPPORTPATH . 'HTTP/Files/CookiesHolder.txt'; $this->request->request('POST', '/post', [ @@ -1079,7 +1079,7 @@ public function testCookieOption() $this->assertSame($holder, $options[CURLOPT_COOKIEFILE]); } - public function testUserAgentOption() + public function testUserAgentOption(): void { $agent = 'CodeIgniter Framework'; diff --git a/tests/system/HTTP/CURLRequestTest.php b/tests/system/HTTP/CURLRequestTest.php index d90b8847cbb6..415032d19628 100644 --- a/tests/system/HTTP/CURLRequestTest.php +++ b/tests/system/HTTP/CURLRequestTest.php @@ -52,7 +52,7 @@ protected function getRequest(array $options = []) /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/4707 */ - public function testPrepareURLIgnoresAppConfig() + public function testPrepareURLIgnoresAppConfig(): void { config('App')->baseURL = 'http://example.com/fruit/'; @@ -66,7 +66,7 @@ public function testPrepareURLIgnoresAppConfig() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/1029 */ - public function testGetRemembersBaseURI() + public function testGetRemembersBaseURI(): void { $request = $this->getRequest(['base_uri' => 'http://www.foo.com/api/v1/']); @@ -80,7 +80,7 @@ public function testGetRemembersBaseURI() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/1029 */ - public function testGetRemembersBaseURIWithHelperMethod() + public function testGetRemembersBaseURIWithHelperMethod(): void { $request = Services::curlrequest(['base_uri' => 'http://www.foo.com/api/v1/']); @@ -89,7 +89,7 @@ public function testGetRemembersBaseURIWithHelperMethod() $this->assertSame('/api/v1/', $uri->getPath()); } - public function testSendReturnsResponse() + public function testSendReturnsResponse(): void { $output = 'Howdy Stranger.'; @@ -99,7 +99,7 @@ public function testSendReturnsResponse() $this->assertSame($output, $response->getBody()); } - public function testGetSetsCorrectMethod() + public function testGetSetsCorrectMethod(): void { $this->request->get('http://example.com'); @@ -111,7 +111,7 @@ public function testGetSetsCorrectMethod() $this->assertSame('GET', $options[CURLOPT_CUSTOMREQUEST]); } - public function testDeleteSetsCorrectMethod() + public function testDeleteSetsCorrectMethod(): void { $this->request->delete('http://example.com'); @@ -123,7 +123,7 @@ public function testDeleteSetsCorrectMethod() $this->assertSame('DELETE', $options[CURLOPT_CUSTOMREQUEST]); } - public function testHeadSetsCorrectMethod() + public function testHeadSetsCorrectMethod(): void { $this->request->head('http://example.com'); @@ -135,7 +135,7 @@ public function testHeadSetsCorrectMethod() $this->assertSame('HEAD', $options[CURLOPT_CUSTOMREQUEST]); } - public function testOptionsSetsCorrectMethod() + public function testOptionsSetsCorrectMethod(): void { $this->request->options('http://example.com'); @@ -147,7 +147,7 @@ public function testOptionsSetsCorrectMethod() $this->assertSame('OPTIONS', $options[CURLOPT_CUSTOMREQUEST]); } - public function testOptionsBaseURIOption() + public function testOptionsBaseURIOption(): void { $options = ['base_uri' => 'http://www.foo.com/api/v1/']; $request = $this->getRequest($options); @@ -155,7 +155,7 @@ public function testOptionsBaseURIOption() $this->assertSame('http://www.foo.com/api/v1/', $request->getBaseURI()->__toString()); } - public function testOptionsBaseURIOverride() + public function testOptionsBaseURIOverride(): void { $options = [ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -166,7 +166,7 @@ public function testOptionsBaseURIOverride() $this->assertSame('http://bogus/com', $request->getBaseURI()->__toString()); } - public function testOptionsHeaders() + public function testOptionsHeaders(): void { $options = [ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -182,7 +182,7 @@ public function testOptionsHeaders() /** * @backupGlobals enabled */ - public function testOptionsHeadersNotUsingPopulate() + public function testOptionsHeadersNotUsingPopulate(): void { $_SERVER['HTTP_HOST'] = 'site1.com'; $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en-US'; @@ -203,7 +203,7 @@ public function testOptionsHeadersNotUsingPopulate() $this->assertSame('', $request->header('Accept-Encoding')->getValue()); } - public function testOptionsAreSharedBetweenRequests() + public function testOptionsAreSharedBetweenRequests(): void { $options = [ 'form_params' => ['studio' => 1], @@ -227,7 +227,7 @@ public function testOptionsAreSharedBetweenRequests() /** * @backupGlobals enabled */ - public function testHeaderContentLengthNotSharedBetweenClients() + public function testHeaderContentLengthNotSharedBetweenClients(): void { $_SERVER['HTTP_CONTENT_LENGTH'] = '10'; @@ -247,7 +247,7 @@ public function testHeaderContentLengthNotSharedBetweenClients() $this->assertNull($request->header('Content-Length')); } - public function testOptionsDelay() + public function testOptionsDelay(): void { $request = $this->getRequest(); $this->assertSame(0.0, $request->getDelay()); @@ -260,7 +260,7 @@ public function testOptionsDelay() $this->assertSame(2.0, $request->getDelay()); } - public function testPatchSetsCorrectMethod() + public function testPatchSetsCorrectMethod(): void { $this->request->patch('http://example.com'); @@ -272,7 +272,7 @@ public function testPatchSetsCorrectMethod() $this->assertSame('PATCH', $options[CURLOPT_CUSTOMREQUEST]); } - public function testPostSetsCorrectMethod() + public function testPostSetsCorrectMethod(): void { $this->request->post('http://example.com'); @@ -284,7 +284,7 @@ public function testPostSetsCorrectMethod() $this->assertSame('POST', $options[CURLOPT_CUSTOMREQUEST]); } - public function testPutSetsCorrectMethod() + public function testPutSetsCorrectMethod(): void { $this->request->put('http://example.com'); @@ -296,7 +296,7 @@ public function testPutSetsCorrectMethod() $this->assertSame('PUT', $options[CURLOPT_CUSTOMREQUEST]); } - public function testCustomMethodSetsCorrectMethod() + public function testCustomMethodSetsCorrectMethod(): void { $this->request->request('custom', 'http://example.com'); @@ -308,7 +308,7 @@ public function testCustomMethodSetsCorrectMethod() $this->assertSame('CUSTOM', $options[CURLOPT_CUSTOMREQUEST]); } - public function testRequestMethodGetsSanitized() + public function testRequestMethodGetsSanitized(): void { $this->request->request('', 'http://example.com'); @@ -320,7 +320,7 @@ public function testRequestMethodGetsSanitized() $this->assertSame('CUSTOM', $options[CURLOPT_CUSTOMREQUEST]); } - public function testRequestSetsBasicCurlOptions() + public function testRequestSetsBasicCurlOptions(): void { $this->request->request('get', 'http://example.com'); @@ -345,7 +345,7 @@ public function testRequestSetsBasicCurlOptions() $this->assertSame(150000.0, $options[CURLOPT_CONNECTTIMEOUT_MS]); } - public function testAuthBasicOption() + public function testAuthBasicOption(): void { $this->request->request('get', 'http://example.com', [ 'auth' => [ @@ -363,7 +363,7 @@ public function testAuthBasicOption() $this->assertSame(CURLAUTH_BASIC, $options[CURLOPT_HTTPAUTH]); } - public function testAuthBasicOptionExplicit() + public function testAuthBasicOptionExplicit(): void { $this->request->request('get', 'http://example.com', [ 'auth' => [ @@ -382,7 +382,7 @@ public function testAuthBasicOptionExplicit() $this->assertSame(CURLAUTH_BASIC, $options[CURLOPT_HTTPAUTH]); } - public function testAuthDigestOption() + public function testAuthDigestOption(): void { $output = "HTTP/1.1 401 Unauthorized Server: ddos-guard @@ -422,7 +422,7 @@ public function testAuthDigestOption() $this->assertSame(CURLAUTH_DIGEST, $options[CURLOPT_HTTPAUTH]); } - public function testSetAuthBasic() + public function testSetAuthBasic(): void { $this->request->setAuth('username', 'password')->get('http://example.com'); @@ -435,7 +435,7 @@ public function testSetAuthBasic() $this->assertSame(CURLAUTH_BASIC, $options[CURLOPT_HTTPAUTH]); } - public function testSetAuthDigest() + public function testSetAuthDigest(): void { $output = "HTTP/1.1 401 Unauthorized Server: ddos-guard @@ -469,7 +469,7 @@ public function testSetAuthDigest() $this->assertSame(CURLAUTH_DIGEST, $options[CURLOPT_HTTPAUTH]); } - public function testCertOption() + public function testCertOption(): void { $file = __FILE__; @@ -483,7 +483,7 @@ public function testCertOption() $this->assertSame($file, $options[CURLOPT_SSLCERT]); } - public function testCertOptionWithPassword() + public function testCertOptionWithPassword(): void { $file = __FILE__; @@ -503,7 +503,7 @@ public function testCertOptionWithPassword() $this->assertSame('password', $options[CURLOPT_SSLCERTPASSWD]); } - public function testMissingCertOption() + public function testMissingCertOption(): void { $file = 'something_obviously_bogus'; $this->expectException(HTTPException::class); @@ -513,7 +513,7 @@ public function testMissingCertOption() ]); } - public function testSSLVerification() + public function testSSLVerification(): void { $file = __FILE__; @@ -531,7 +531,7 @@ public function testSSLVerification() $this->assertSame(1, $options[CURLOPT_SSL_VERIFYPEER]); } - public function testSSLWithBadKey() + public function testSSLWithBadKey(): void { $file = 'something_obviously_bogus'; $this->expectException(HTTPException::class); @@ -542,7 +542,7 @@ public function testSSLWithBadKey() ]); } - public function testDebugOptionTrue() + public function testDebugOptionTrue(): void { $this->request->request('get', 'http://example.com', [ 'debug' => true, @@ -557,7 +557,7 @@ public function testDebugOptionTrue() $this->assertIsResource($options[CURLOPT_STDERR]); } - public function testDebugOptionFalse() + public function testDebugOptionFalse(): void { $this->request->request('get', 'http://example.com', [ 'debug' => false, @@ -569,7 +569,7 @@ public function testDebugOptionFalse() $this->assertArrayNotHasKey(CURLOPT_STDERR, $options); } - public function testDebugOptionFile() + public function testDebugOptionFile(): void { $file = SUPPORTPATH . 'Files/baker/banana.php'; @@ -586,7 +586,7 @@ public function testDebugOptionFile() $this->assertIsResource($options[CURLOPT_STDERR]); } - public function testDecodeContent() + public function testDecodeContent(): void { $this->request->setHeader('Accept-Encoding', 'cobol'); $this->request->request('get', 'http://example.com', [ @@ -599,7 +599,7 @@ public function testDecodeContent() $this->assertSame('cobol', $options[CURLOPT_ENCODING]); } - public function testDecodeContentWithoutAccept() + public function testDecodeContentWithoutAccept(): void { // $this->request->setHeader('Accept-Encoding', 'cobol'); $this->request->request('get', 'http://example.com', [ @@ -614,7 +614,7 @@ public function testDecodeContentWithoutAccept() $this->assertSame('Accept-Encoding', $options[CURLOPT_HTTPHEADER]); } - public function testAllowRedirectsOptionFalse() + public function testAllowRedirectsOptionFalse(): void { $this->request->request('get', 'http://example.com', [ 'allow_redirects' => false, @@ -629,7 +629,7 @@ public function testAllowRedirectsOptionFalse() $this->assertArrayNotHasKey(CURLOPT_REDIR_PROTOCOLS, $options); } - public function testAllowRedirectsOptionTrue() + public function testAllowRedirectsOptionTrue(): void { $this->request->request('get', 'http://example.com', [ 'allow_redirects' => true, @@ -646,7 +646,7 @@ public function testAllowRedirectsOptionTrue() $this->assertSame(CURLPROTO_HTTP | CURLPROTO_HTTPS, $options[CURLOPT_REDIR_PROTOCOLS]); } - public function testAllowRedirectsOptionDefaults() + public function testAllowRedirectsOptionDefaults(): void { $this->request->request('get', 'http://example.com', [ 'allow_redirects' => true, @@ -661,7 +661,7 @@ public function testAllowRedirectsOptionDefaults() $this->assertArrayHasKey(CURLOPT_REDIR_PROTOCOLS, $options); } - public function testAllowRedirectsArray() + public function testAllowRedirectsArray(): void { $this->request->request('get', 'http://example.com', [ 'allow_redirects' => ['max' => 2], @@ -676,7 +676,7 @@ public function testAllowRedirectsArray() $this->assertSame(2, $options[CURLOPT_MAXREDIRS]); } - public function testSendWithQuery() + public function testSendWithQuery(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -693,7 +693,7 @@ public function testSendWithQuery() $this->assertSame('http://www.foo.com/api/v1/products?name=Henry&d.t=value', $options[CURLOPT_URL]); } - public function testSendWithDelay() + public function testSendWithDelay(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -706,7 +706,7 @@ public function testSendWithDelay() $this->assertSame(0.1, $request->getDelay()); } - public function testSendContinued() + public function testSendContinued(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -721,7 +721,7 @@ public function testSendContinued() /** * See: https://github.com/codeigniter4/CodeIgniter4/issues/3261 */ - public function testSendContinuedWithManyHeaders() + public function testSendContinuedWithManyHeaders(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -765,7 +765,7 @@ public function testSendContinuedWithManyHeaders() $this->assertSame(200, $response->getStatusCode()); } - public function testSendProxied() + public function testSendProxied(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -783,7 +783,7 @@ public function testSendProxied() /** * See: https://github.com/codeigniter4/CodeIgniter4/issues/7394 */ - public function testResponseHeadersWithMultipleRequests() + public function testResponseHeadersWithMultipleRequests(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -836,7 +836,7 @@ public function testResponseHeadersWithMultipleRequests() $this->assertSame(200, $response->getStatusCode()); } - public function testSplitResponse() + public function testSplitResponse(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -848,7 +848,7 @@ public function testSplitResponse() $this->assertSame('Hi there', $response->getBody()); } - public function testApplyBody() + public function testApplyBody(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -863,7 +863,7 @@ public function testApplyBody() $this->assertSame('name=George', $request->curl_options[CURLOPT_POSTFIELDS]); } - public function testApplyBodyByOptions() + public function testApplyBodyByOptions(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -879,7 +879,7 @@ public function testApplyBodyByOptions() $this->assertSame('name=George', $request->curl_options[CURLOPT_POSTFIELDS]); } - public function testResponseHeaders() + public function testResponseHeaders(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -893,7 +893,7 @@ public function testResponseHeaders() $this->assertSame(234, $response->getStatusCode()); } - public function testResponseHeadersShortProtocol() + public function testResponseHeadersShortProtocol(): void { $request = $this->getRequest([ 'base_uri' => 'http://www.foo.com/api/v1/', @@ -907,7 +907,7 @@ public function testResponseHeadersShortProtocol() $this->assertSame(235, $response->getStatusCode()); } - public function testPostFormEncoded() + public function testPostFormEncoded(): void { $params = [ 'foo' => 'bar', @@ -929,7 +929,7 @@ public function testPostFormEncoded() $this->assertSame($expected, $options[CURLOPT_POSTFIELDS]); } - public function testPostFormMultipart() + public function testPostFormMultipart(): void { $params = [ 'foo' => 'bar', @@ -951,7 +951,7 @@ public function testPostFormMultipart() $this->assertSame($params, $options[CURLOPT_POSTFIELDS]); } - public function testSetForm() + public function testSetForm(): void { $params = [ 'foo' => 'bar', @@ -978,7 +978,7 @@ public function testSetForm() ); } - public function testJSONData() + public function testJSONData(): void { $params = [ 'foo' => 'bar', @@ -997,7 +997,7 @@ public function testJSONData() $this->assertSame($expected, $this->request->getBody()); } - public function testSetJSON() + public function testSetJSON(): void { $params = [ 'foo' => 'bar', @@ -1015,7 +1015,7 @@ public function testSetJSON() ); } - public function testHTTPv1() + public function testHTTPv1(): void { $this->request->request('POST', '/post', [ 'version' => 1.0, @@ -1027,7 +1027,7 @@ public function testHTTPv1() $this->assertSame(CURL_HTTP_VERSION_1_0, $options[CURLOPT_HTTP_VERSION]); } - public function testHTTPv11() + public function testHTTPv11(): void { $this->request->request('POST', '/post', [ 'version' => 1.1, @@ -1039,7 +1039,7 @@ public function testHTTPv11() $this->assertSame(CURL_HTTP_VERSION_1_1, $options[CURLOPT_HTTP_VERSION]); } - public function testHTTPv2() + public function testHTTPv2(): void { $this->request->request('POST', '/post', [ 'version' => 2.0, @@ -1051,7 +1051,7 @@ public function testHTTPv2() $this->assertSame(CURL_HTTP_VERSION_2_0, $options[CURLOPT_HTTP_VERSION]); } - public function testCookieOption() + public function testCookieOption(): void { $holder = SUPPORTPATH . 'HTTP/Files/CookiesHolder.txt'; $this->request->request('POST', '/post', [ @@ -1066,7 +1066,7 @@ public function testCookieOption() $this->assertSame($holder, $options[CURLOPT_COOKIEFILE]); } - public function testUserAgentOption() + public function testUserAgentOption(): void { $agent = 'CodeIgniter Framework'; diff --git a/tests/system/HTTP/ContentSecurityPolicyTest.php b/tests/system/HTTP/ContentSecurityPolicyTest.php index 4b4d7a1a4975..81fd2d998602 100644 --- a/tests/system/HTTP/ContentSecurityPolicyTest.php +++ b/tests/system/HTTP/ContentSecurityPolicyTest.php @@ -32,7 +32,7 @@ final class ContentSecurityPolicyTest extends CIUnitTestCase private ?ContentSecurityPolicy $csp = null; // Having this method as setUp() doesn't work - can't find Config\App !? - protected function prepare(bool $CSPEnabled = true) + protected function prepare(bool $CSPEnabled = true): void { $this->resetServices(); @@ -63,7 +63,7 @@ protected function work(string $parm = 'Hello') * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testExistence() + public function testExistence(): void { $this->prepare(); $this->work(); @@ -75,7 +75,7 @@ public function testExistence() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testReportOnly() + public function testReportOnly(): void { $this->prepare(); $this->csp->reportOnly(false); @@ -88,7 +88,7 @@ public function testReportOnly() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testDefaults() + public function testDefaults(): void { $this->prepare(); @@ -107,7 +107,7 @@ public function testDefaults() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testChildSrc() + public function testChildSrc(): void { $this->prepare(); $this->csp->addChildSrc('evil.com', true); @@ -124,7 +124,7 @@ public function testChildSrc() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testConnectSrc() + public function testConnectSrc(): void { $this->prepare(); $this->csp->reportOnly(true); @@ -140,7 +140,7 @@ public function testConnectSrc() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testFontSrc() + public function testFontSrc(): void { $this->prepare(); $this->csp->reportOnly(true); @@ -158,7 +158,7 @@ public function testFontSrc() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testFormAction() + public function testFormAction(): void { $this->prepare(); $this->csp->reportOnly(true); @@ -176,7 +176,7 @@ public function testFormAction() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testFrameAncestor() + public function testFrameAncestor(): void { $this->prepare(); $this->csp->addFrameAncestor('self'); @@ -193,7 +193,7 @@ public function testFrameAncestor() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testFrameSrc() + public function testFrameSrc(): void { $this->prepare(); $this->csp->addFrameSrc('self'); @@ -210,7 +210,7 @@ public function testFrameSrc() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testImageSrc() + public function testImageSrc(): void { $this->prepare(); $this->csp->addImageSrc('cdn.cloudy.com'); @@ -227,7 +227,7 @@ public function testImageSrc() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testMediaSrc() + public function testMediaSrc(): void { $this->prepare(); $this->csp->addMediaSrc('self'); @@ -244,7 +244,7 @@ public function testMediaSrc() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testManifestSrc() + public function testManifestSrc(): void { $this->prepare(); $this->csp->addManifestSrc('cdn.cloudy.com'); @@ -261,7 +261,7 @@ public function testManifestSrc() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testPluginType() + public function testPluginType(): void { $this->prepare(); $this->csp->addPluginType('self'); @@ -278,7 +278,7 @@ public function testPluginType() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testPluginArray() + public function testPluginArray(): void { $this->prepare(); $this->csp->addPluginType('application/x-shockwave-flash'); @@ -293,7 +293,7 @@ public function testPluginArray() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testObjectSrc() + public function testObjectSrc(): void { $this->prepare(); $this->csp->addObjectSrc('cdn.cloudy.com'); @@ -310,7 +310,7 @@ public function testObjectSrc() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testScriptSrc() + public function testScriptSrc(): void { $this->prepare(); $this->csp->addScriptSrc('cdn.cloudy.com'); @@ -327,7 +327,7 @@ public function testScriptSrc() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testStyleSrc() + public function testStyleSrc(): void { $this->prepare(); $this->csp->addStyleSrc('cdn.cloudy.com'); @@ -344,7 +344,7 @@ public function testStyleSrc() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testBaseURIDefault() + public function testBaseURIDefault(): void { $this->prepare(); $result = $this->work(); @@ -357,7 +357,7 @@ public function testBaseURIDefault() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testBaseURI() + public function testBaseURI(): void { $this->prepare(); $this->csp->addBaseURI('example.com'); @@ -371,7 +371,7 @@ public function testBaseURI() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testBaseURIRich() + public function testBaseURIRich(): void { $this->prepare(); $this->csp->addBaseURI(['self', 'example.com']); @@ -385,7 +385,7 @@ public function testBaseURIRich() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testDefaultSrc() + public function testDefaultSrc(): void { $this->prepare(); $this->csp->reportOnly(false); @@ -401,7 +401,7 @@ public function testDefaultSrc() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testReportURI() + public function testReportURI(): void { $this->prepare(); $this->csp->reportOnly(false); @@ -416,7 +416,7 @@ public function testReportURI() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testSandboxFlags() + public function testSandboxFlags(): void { $this->prepare(); $this->csp->reportOnly(false); @@ -432,7 +432,7 @@ public function testSandboxFlags() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testUpgradeInsecureRequests() + public function testUpgradeInsecureRequests(): void { $this->prepare(); $this->csp->upgradeInsecureRequests(); @@ -446,7 +446,7 @@ public function testUpgradeInsecureRequests() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testBodyEmpty() + public function testBodyEmpty(): void { $this->prepare(); $body = ''; @@ -459,7 +459,7 @@ public function testBodyEmpty() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testBodyScriptNonce() + public function testBodyScriptNonce(): void { $this->prepare(); $body = 'Blah blah {csp-script-nonce} blah blah'; @@ -478,7 +478,7 @@ public function testBodyScriptNonce() $this->assertSame([], $nonceStyle); } - public function testBodyScriptNonceCustomScriptTag() + public function testBodyScriptNonceCustomScriptTag(): void { $config = new CSPConfig(); $config->scriptNonceTag = '{custom-script-nonce-tag}'; @@ -494,7 +494,7 @@ public function testBodyScriptNonceCustomScriptTag() $this->assertStringContainsString('nonce=', $response->getBody()); } - public function testBodyScriptNonceDisableAutoNonce() + public function testBodyScriptNonceDisableAutoNonce(): void { $config = new CSPConfig(); $config->autoNonce = false; @@ -513,7 +513,7 @@ public function testBodyScriptNonceDisableAutoNonce() $result->assertHeader('Content-Security-Policy'); } - public function testBodyStyleNonceDisableAutoNonce() + public function testBodyStyleNonceDisableAutoNonce(): void { $config = new CSPConfig(); $config->autoNonce = false; @@ -536,7 +536,7 @@ public function testBodyStyleNonceDisableAutoNonce() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testBodyStyleNonce() + public function testBodyStyleNonce(): void { $this->prepare(); $body = 'Blah blah {csp-style-nonce} blah blah'; @@ -555,7 +555,7 @@ public function testBodyStyleNonce() $this->assertSame([], $nonceScript); } - public function testBodyStyleNonceCustomStyleTag() + public function testBodyStyleNonceCustomStyleTag(): void { $config = new CSPConfig(); $config->styleNonceTag = '{custom-style-nonce-tag}'; @@ -575,7 +575,7 @@ public function testBodyStyleNonceCustomStyleTag() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testHeaderWrongCaseNotFound() + public function testHeaderWrongCaseNotFound(): void { $this->prepare(); $result = $this->work(); @@ -588,7 +588,7 @@ public function testHeaderWrongCaseNotFound() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testHeaderIgnoreCase() + public function testHeaderIgnoreCase(): void { $this->prepare(); $result = $this->work(); @@ -601,7 +601,7 @@ public function testHeaderIgnoreCase() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testCSPDisabled() + public function testCSPDisabled(): void { $this->prepare(false); $this->work(); @@ -610,7 +610,7 @@ public function testCSPDisabled() $this->assertHeaderNotEmitted('content-security-policy', true); } - public function testGetScriptNonce() + public function testGetScriptNonce(): void { $this->prepare(); @@ -619,7 +619,7 @@ public function testGetScriptNonce() $this->assertMatchesRegularExpression('/\A[0-9a-z]{24}\z/', $nonce); } - public function testGetStyleNonce() + public function testGetStyleNonce(): void { $this->prepare(); @@ -632,7 +632,7 @@ public function testGetStyleNonce() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testHeaderScriptNonceEmittedOnceGetScriptNonceCalled() + public function testHeaderScriptNonceEmittedOnceGetScriptNonceCalled(): void { $this->prepare(); diff --git a/tests/system/HTTP/DownloadResponseTest.php b/tests/system/HTTP/DownloadResponseTest.php index fe320705b290..6bd699375a63 100644 --- a/tests/system/HTTP/DownloadResponseTest.php +++ b/tests/system/HTTP/DownloadResponseTest.php @@ -31,14 +31,14 @@ protected function tearDown(): void } } - public function testCanGetStatusCode() + public function testCanGetStatusCode(): void { $response = new DownloadResponse('unit-test.txt', true); $this->assertSame(200, $response->getStatusCode()); } - public function testCantSetStatusCode() + public function testCantSetStatusCode(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -46,7 +46,7 @@ public function testCantSetStatusCode() $response->setStatusCode(200); } - public function testSetDateRemembersDateInUTC() + public function testSetDateRemembersDateInUTC(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -61,7 +61,7 @@ public function testSetDateRemembersDateInUTC() $this->assertSame($date->format('D, d M Y H:i:s') . ' GMT', $header); } - public function testSetLastModifiedWithDateTimeObject() + public function testSetLastModifiedWithDateTimeObject(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -75,7 +75,7 @@ public function testSetLastModifiedWithDateTimeObject() $this->assertSame($date->format('D, d M Y H:i:s') . ' GMT', $header); } - public function testSetLastModifiedWithString() + public function testSetLastModifiedWithString(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -86,14 +86,14 @@ public function testSetLastModifiedWithString() $this->assertSame('2000-03-10 10:23:45', $header); } - public function testsentMethodSouldReturnRedirectResponse() + public function testsentMethodSouldReturnRedirectResponse(): void { $response = new DownloadResponse('unit-test.txt', true); $this->assertInstanceOf(DownloadResponse::class, $response); } - public function testSetContentType() + public function testSetContentType(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -102,7 +102,7 @@ public function testSetContentType() $this->assertSame('text/json; charset=UTF-8', $response->getHeaderLine('Content-Type')); } - public function testSetContentTypeNoCharSet() + public function testSetContentTypeNoCharSet(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -111,7 +111,7 @@ public function testSetContentTypeNoCharSet() $this->assertSame('application/octet-stream', $response->getHeaderLine('Content-Type')); } - public function testSetFileName() + public function testSetFileName(): void { $response = new DownloadResponse('unit-test.txt', true); $response->setFileName('myFile.txt'); @@ -120,7 +120,7 @@ public function testSetFileName() $this->assertSame('attachment; filename="myFile.txt"; filename*=UTF-8\'\'myFile.txt', $response->getHeaderLine('Content-Disposition')); } - public function testNoCache() + public function testNoCache(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -129,7 +129,7 @@ public function testNoCache() $this->assertSame('private, no-transform, no-store, must-revalidate', $response->getHeaderLine('Cache-control')); } - public function testCantSetCache() + public function testCantSetCache(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -137,7 +137,7 @@ public function testCantSetCache() $response->setCache(); } - public function testWhenFilepathIsSetBinaryCanNotBeSet() + public function testWhenFilepathIsSetBinaryCanNotBeSet(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -146,7 +146,7 @@ public function testWhenFilepathIsSetBinaryCanNotBeSet() $response->setBinary('test'); } - public function testWhenBinaryIsSetFilepathCanNotBeSet() + public function testWhenBinaryIsSetFilepathCanNotBeSet(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -155,7 +155,7 @@ public function testWhenBinaryIsSetFilepathCanNotBeSet() $response->setFilePath(__FILE__); } - public function testCanNotSetNoFilepath() + public function testCanNotSetNoFilepath(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -163,7 +163,7 @@ public function testCanNotSetNoFilepath() $response->setFilePath('unit test'); } - public function testCanGetContentLength() + public function testCanGetContentLength(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -181,7 +181,7 @@ public function testCanGetContentLength() $this->assertSame($size, $response->getContentLength()); } - public function testIsSetDownloadableHeadlersFromBinary() + public function testIsSetDownloadableHeadlersFromBinary(): void { $response = new DownloadResponse('unit test.txt', false); @@ -195,7 +195,7 @@ public function testIsSetDownloadableHeadlersFromBinary() $this->assertSame('4', $response->getHeaderLine('Content-Length')); } - public function testIsSetDownloadableHeadlersFromFile() + public function testIsSetDownloadableHeadlersFromFile(): void { $response = new DownloadResponse('unit-test.php', false); @@ -209,7 +209,7 @@ public function testIsSetDownloadableHeadlersFromFile() $this->assertSame(filesize(__FILE__), (int) $response->getHeaderLine('Content-Length')); } - public function testIfTheCharacterCodeIsOtherThanUtf8ReplaceItWithUtf8AndRawurlencode() + public function testIfTheCharacterCodeIsOtherThanUtf8ReplaceItWithUtf8AndRawurlencode(): void { $response = new DownloadResponse(mb_convert_encoding('テスト.php', 'Shift-JIS', 'UTF-8'), false); @@ -220,7 +220,7 @@ public function testIfTheCharacterCodeIsOtherThanUtf8ReplaceItWithUtf8AndRawurle $this->assertSame('attachment; filename="' . mb_convert_encoding('テスト.php', 'Shift-JIS', 'UTF-8') . '"; filename*=UTF-8\'\'%E3%83%86%E3%82%B9%E3%83%88.php', $response->getHeaderLine('Content-Disposition')); } - public function testFileExtensionIsUpperCaseWhenAndroidOSIs2() + public function testFileExtensionIsUpperCaseWhenAndroidOSIs2(): void { $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Linux; U; Android 2.0.3; ja-jp; SC-02C Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'; $response = new DownloadResponse('unit-test.php', false); @@ -231,7 +231,7 @@ public function testFileExtensionIsUpperCaseWhenAndroidOSIs2() $this->assertSame('attachment; filename="unit-test.PHP"; filename*=UTF-8\'\'unit-test.PHP', $response->getHeaderLine('Content-Disposition')); } - public function testIsSetContentTypeFromFilename() + public function testIsSetContentTypeFromFilename(): void { $response = new DownloadResponse('unit-test.txt', true); @@ -241,7 +241,7 @@ public function testIsSetContentTypeFromFilename() $this->assertSame('text/plain; charset=UTF-8', $response->getHeaderLine('Content-Type')); } - public function testCanOutputFileBodyFromBinary() + public function testCanOutputFileBodyFromBinary(): void { $response = new DownloadResponse('unit-test.txt', false); @@ -255,7 +255,7 @@ public function testCanOutputFileBodyFromBinary() $this->assertSame('test', $actual); } - public function testCanOutputFileBodyFromFile() + public function testCanOutputFileBodyFromFile(): void { $response = new DownloadResponse('unit-test.php', false); @@ -269,7 +269,7 @@ public function testCanOutputFileBodyFromFile() $this->assertSame(file_get_contents(__FILE__), $actual); } - public function testThrowExceptionWhenNoSetDownloadSource() + public function testThrowExceptionWhenNoSetDownloadSource(): void { $response = new DownloadResponse('unit-test.php', false); @@ -277,13 +277,13 @@ public function testThrowExceptionWhenNoSetDownloadSource() $response->sendBody(); } - public function testGetReason() + public function testGetReason(): void { $response = new DownloadResponse('unit-test.php', false); $this->assertSame('OK', $response->getReasonPhrase()); } - public function testPretendOutput() + public function testPretendOutput(): void { $response = new DownloadResponse('unit-test.php', false); $response->pretend(true); @@ -302,7 +302,7 @@ public function testPretendOutput() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testRealOutput() + public function testRealOutput(): void { $response = new DownloadResponse('unit-test.php', false); $response->pretend(false); diff --git a/tests/system/HTTP/Files/FileCollectionTest.php b/tests/system/HTTP/Files/FileCollectionTest.php index c9d2c0123acf..6c9983effb84 100644 --- a/tests/system/HTTP/Files/FileCollectionTest.php +++ b/tests/system/HTTP/Files/FileCollectionTest.php @@ -27,14 +27,14 @@ protected function setUp(): void $_FILES = []; } - public function testAllReturnsArrayWithNoFiles() + public function testAllReturnsArrayWithNoFiles(): void { $files = new FileCollection(); $this->assertSame([], $files->all()); } - public function testAllReturnsValidSingleFile() + public function testAllReturnsValidSingleFile(): void { $_FILES = [ 'userfile' => [ @@ -57,7 +57,7 @@ public function testAllReturnsValidSingleFile() $this->assertSame(124, $file->getSize()); } - public function testAllReturnsValidMultipleFilesSameName() + public function testAllReturnsValidMultipleFilesSameName(): void { $_FILES = [ 'userfile' => [ @@ -99,7 +99,7 @@ public function testAllReturnsValidMultipleFilesSameName() $this->assertSame(124, $file->getSize()); } - public function testAllReturnsValidMultipleFilesDifferentName() + public function testAllReturnsValidMultipleFilesDifferentName(): void { $_FILES = [ 'userfile1' => [ @@ -144,7 +144,7 @@ public function testAllReturnsValidMultipleFilesDifferentName() $this->assertSame(248, $file->getSize()); } - public function testExtensionGuessing() + public function testExtensionGuessing(): void { $_FILES = [ 'userfile1' => [ @@ -218,7 +218,7 @@ public function testExtensionGuessing() $this->assertSame('zip', $file->guessExtension()); } - public function testAllReturnsValidSingleFileNestedName() + public function testAllReturnsValidSingleFileNestedName(): void { $_FILES = [ 'userfile' => [ @@ -263,7 +263,7 @@ public function testAllReturnsValidSingleFileNestedName() $this->assertSame(124, $file->getSize()); } - public function testHasFileWithSingleFile() + public function testHasFileWithSingleFile(): void { $_FILES = [ 'userfile' => [ @@ -281,7 +281,7 @@ public function testHasFileWithSingleFile() $this->assertFalse($collection->hasFile('foo')); } - public function testHasFileWithMultipleFilesWithDifferentNames() + public function testHasFileWithMultipleFilesWithDifferentNames(): void { $_FILES = [ 'userfile1' => [ @@ -306,7 +306,7 @@ public function testHasFileWithMultipleFilesWithDifferentNames() $this->assertTrue($collection->hasFile('userfile2')); } - public function testHasFileWithSingleFileNestedName() + public function testHasFileWithSingleFileNestedName(): void { $_FILES = [ 'userfile' => [ @@ -341,7 +341,7 @@ public function testHasFileWithSingleFileNestedName() $this->assertTrue($collection->hasFile('userfile.foo.bar')); } - public function testErrorString() + public function testErrorString(): void { $_FILES = [ 'userfile' => [ @@ -361,7 +361,7 @@ public function testErrorString() $this->assertSame($expected, $file->getErrorString()); } - public function testErrorStringWithUnknownError() + public function testErrorStringWithUnknownError(): void { $_FILES = [ 'userfile' => [ @@ -381,7 +381,7 @@ public function testErrorStringWithUnknownError() $this->assertSame($expected, $file->getErrorString()); } - public function testErrorStringWithNoError() + public function testErrorStringWithNoError(): void { $_FILES = [ 'userfile' => [ @@ -400,7 +400,7 @@ public function testErrorStringWithNoError() $this->assertSame($expected, $file->getErrorString()); } - public function testError() + public function testError(): void { $_FILES = [ 'userfile' => [ @@ -418,7 +418,7 @@ public function testError() $this->assertSame(UPLOAD_ERR_INI_SIZE, $file->getError()); } - public function testErrorWithUnknownError() + public function testErrorWithUnknownError(): void { $_FILES = [ 'userfile' => [ @@ -435,7 +435,7 @@ public function testErrorWithUnknownError() $this->assertSame(0, $file->getError()); } - public function testErrorWithNoError() + public function testErrorWithNoError(): void { $_FILES = [ 'userfile' => [ @@ -453,7 +453,7 @@ public function testErrorWithNoError() $this->assertSame(UPLOAD_ERR_OK, $file->getError()); } - public function testFileReturnsValidSingleFile() + public function testFileReturnsValidSingleFile(): void { $_FILES = [ 'userfile' => [ @@ -473,7 +473,7 @@ public function testFileReturnsValidSingleFile() $this->assertSame(124, $file->getSize()); } - public function testFileNoExistSingleFile() + public function testFileNoExistSingleFile(): void { $_FILES = [ 'userfile' => [ @@ -490,7 +490,7 @@ public function testFileNoExistSingleFile() $this->AssertNull($file); } - public function testFileReturnValidMultipleFiles() + public function testFileReturnValidMultipleFiles(): void { $_FILES = [ 'userfile' => [ @@ -533,7 +533,7 @@ public function testFileReturnValidMultipleFiles() $this->assertSame(248, $file2->getSize()); } - public function testFileWithMultipleFilesNestedName() + public function testFileWithMultipleFilesNestedName(): void { $_FILES = [ 'my-form' => [ @@ -599,7 +599,7 @@ public function testFileWithMultipleFilesNestedName() $this->assertSame(243, $file2->getSize()); } - public function testDoesntHaveFile() + public function testDoesntHaveFile(): void { $_FILES = [ 'my-form' => [ @@ -652,7 +652,7 @@ public function testDoesntHaveFile() $this->assertNull($collection->getFile('my-form.detailz.avatars.0')); } - public function testGetFileMultipleHasNoFile() + public function testGetFileMultipleHasNoFile(): void { $_FILES = [ 'userfile' => [ @@ -683,7 +683,7 @@ public function testGetFileMultipleHasNoFile() $this->assertNull($files); } - public function testGetFileMultipleReturnValidDotNotationSyntax() + public function testGetFileMultipleReturnValidDotNotationSyntax(): void { $_FILES = [ 'my-form' => [ @@ -751,7 +751,7 @@ public function testGetFileMultipleReturnValidDotNotationSyntax() $this->assertSame(243, $files[1]->getSize()); } - public function testGetFileMultipleReturnInvalidDotNotationSyntax() + public function testGetFileMultipleReturnInvalidDotNotationSyntax(): void { $_FILES = [ 'my-form' => [ @@ -789,7 +789,7 @@ public function testGetFileMultipleReturnInvalidDotNotationSyntax() $this->assertNull($files); } - public function testGetFileMultipleReturnValidMultipleFiles() + public function testGetFileMultipleReturnValidMultipleFiles(): void { $_FILES = [ 'userfile' => [ @@ -834,7 +834,7 @@ public function testGetFileMultipleReturnValidMultipleFiles() $this->assertSame('text/csv', $files[1]->getClientMimeType()); } - public function testGetFileMultipleReturnInvalidSingleFile() + public function testGetFileMultipleReturnInvalidSingleFile(): void { $_FILES = [ 'userfile' => [ diff --git a/tests/system/HTTP/Files/FileMovingTest.php b/tests/system/HTTP/Files/FileMovingTest.php index 2362d64296b7..5ec79796e136 100644 --- a/tests/system/HTTP/Files/FileMovingTest.php +++ b/tests/system/HTTP/Files/FileMovingTest.php @@ -60,7 +60,7 @@ protected function tearDown(): void } } - public function testMove() + public function testMove(): void { $finalFilename = 'fileA'; $_FILES = [ @@ -100,7 +100,7 @@ public function testMove() $this->assertTrue($this->root->hasChild('destination/' . $finalFilename . '_1.txt')); } - public function testMoveOverwriting() + public function testMoveOverwriting(): void { $finalFilename = 'file_with_delimiters_underscore'; $_FILES = [ @@ -150,7 +150,7 @@ public function testMoveOverwriting() $this->assertFileExists($destination . '/' . $finalFilename . '.txt'); } - public function testMoved() + public function testMoved(): void { $finalFilename = 'fileA'; $_FILES = [ @@ -183,7 +183,7 @@ public function testMoved() $this->assertTrue($file->hasMoved()); } - public function testStore() + public function testStore(): void { $finalFilename = 'fileA'; $_FILES = [ @@ -215,7 +215,7 @@ public function testStore() $this->assertSame($destination . '/fileA.txt', $path); } - public function testAlreadyMoved() + public function testAlreadyMoved(): void { $finalFilename = 'fileA'; $_FILES = [ @@ -246,7 +246,7 @@ public function testAlreadyMoved() } } - public function testInvalidFile() + public function testInvalidFile(): void { $_FILES = [ 'userfile' => [ @@ -267,7 +267,7 @@ public function testInvalidFile() $file->move($destination, $file->getName(), false); } - public function testFailedMoveBecauseOfWarning() + public function testFailedMoveBecauseOfWarning(): void { $_FILES = [ 'userfile' => [ @@ -293,7 +293,7 @@ public function testFailedMoveBecauseOfWarning() $file->move($destination, $file->getName(), false); } - public function testFailedMoveBecauseOfFalseReturned() + public function testFailedMoveBecauseOfFalseReturned(): void { $_FILES = [ 'userfile1' => [ @@ -363,7 +363,7 @@ function move_uploaded_file($filename, $destination, ?bool $setReturnValue = nul return $return; } -function rrmdir($src) +function rrmdir($src): void { $dir = opendir($src); diff --git a/tests/system/HTTP/HeaderTest.php b/tests/system/HTTP/HeaderTest.php index 43ccf91b3c26..34d6190ef2a6 100644 --- a/tests/system/HTTP/HeaderTest.php +++ b/tests/system/HTTP/HeaderTest.php @@ -22,7 +22,7 @@ */ final class HeaderTest extends CIUnitTestCase { - public function testHeaderStoresBasics() + public function testHeaderStoresBasics(): void { $name = 'foo'; $value = 'bar'; @@ -33,7 +33,7 @@ public function testHeaderStoresBasics() $this->assertSame($value, $header->getValue()); } - public function testHeaderStoresBasicsWithNull() + public function testHeaderStoresBasicsWithNull(): void { $name = 'foo'; $value = null; @@ -44,7 +44,7 @@ public function testHeaderStoresBasicsWithNull() $this->assertSame('', $header->getValue()); } - public function testHeaderStoresBasicWithInt() + public function testHeaderStoresBasicWithInt(): void { $name = 'foo'; $value = 123; @@ -55,7 +55,7 @@ public function testHeaderStoresBasicWithInt() $this->assertSame((string) $value, $header->getValue()); } - public function testHeaderStoresBasicWithObject() + public function testHeaderStoresBasicWithObject(): void { $this->expectException(Error::class); $this->expectExceptionMessage('Object of class stdClass could not be converted to string'); @@ -66,7 +66,7 @@ public function testHeaderStoresBasicWithObject() new Header($name, $value); } - public function testHeaderStoresArrayValues() + public function testHeaderStoresArrayValues(): void { $name = 'foo'; $value = [ @@ -80,7 +80,7 @@ public function testHeaderStoresArrayValues() $this->assertSame($value, $header->getValue()); } - public function testHeaderStoresArrayKeyValue() + public function testHeaderStoresArrayKeyValue(): void { $name = 'foo'; $value = [ @@ -94,7 +94,7 @@ public function testHeaderStoresArrayKeyValue() $this->assertSame('key=val', $header->getValueLine()); } - public function testHeaderSetters() + public function testHeaderSetters(): void { $name = 'foo'; $value = [ @@ -114,7 +114,7 @@ public function testHeaderSetters() $this->assertSame($name . ': bar, 123', (string) $header); } - public function testHeaderAppendsValueSkippedForNull() + public function testHeaderAppendsValueSkippedForNull(): void { $name = 'foo'; $value = 'bar'; @@ -128,7 +128,7 @@ public function testHeaderAppendsValueSkippedForNull() $this->assertSame($expected, $header->getValue()); } - public function testHeaderConvertsSingleToArray() + public function testHeaderConvertsSingleToArray(): void { $name = 'foo'; $value = 'bar'; @@ -146,7 +146,7 @@ public function testHeaderConvertsSingleToArray() $this->assertSame($expected, $header->getValue()); } - public function testHeaderPrependsValueSkippedForNull() + public function testHeaderPrependsValueSkippedForNull(): void { $name = 'foo'; $value = 'bar'; @@ -160,7 +160,7 @@ public function testHeaderPrependsValueSkippedForNull() $this->assertSame($expected, $header->getValue()); } - public function testHeaderPrependsValue() + public function testHeaderPrependsValue(): void { $name = 'foo'; $value = 'bar'; @@ -178,7 +178,7 @@ public function testHeaderPrependsValue() $this->assertSame($expected, $header->getValue()); } - public function testHeaderLineSimple() + public function testHeaderLineSimple(): void { $name = 'foo'; $value = [ @@ -194,7 +194,7 @@ public function testHeaderLineSimple() $this->assertSame($expected, $header->getValueLine()); } - public function testHeaderSetValueWithNullWillMarkAsEmptyString() + public function testHeaderSetValueWithNullWillMarkAsEmptyString(): void { $name = 'foo'; $expected = ''; @@ -206,7 +206,7 @@ public function testHeaderSetValueWithNullWillMarkAsEmptyString() $this->assertSame($expected, $header->getValueLine()); } - public function testHeaderLineWithArrayValues() + public function testHeaderLineWithArrayValues(): void { $name = 'foo'; @@ -220,7 +220,7 @@ public function testHeaderLineWithArrayValues() $this->assertSame($expected, $header->getValueLine()); } - public function testHeaderToStringShowsEntireHeader() + public function testHeaderToStringShowsEntireHeader(): void { $name = 'foo'; diff --git a/tests/system/HTTP/IncomingRequestDetectingTest.php b/tests/system/HTTP/IncomingRequestDetectingTest.php index cd220cbe0987..481821dd922b 100644 --- a/tests/system/HTTP/IncomingRequestDetectingTest.php +++ b/tests/system/HTTP/IncomingRequestDetectingTest.php @@ -36,7 +36,7 @@ protected function setUp(): void $this->request = new IncomingRequest(new App(), new URI($origin), null, new UserAgent()); } - public function testPathDefault() + public function testPathDefault(): void { // /index.php/woot?code=good#pos $_SERVER['REQUEST_URI'] = '/index.php/woot'; @@ -46,7 +46,7 @@ public function testPathDefault() $this->assertSame($expected, $this->request->detectPath()); } - public function testPathDefaultEmpty() + public function testPathDefaultEmpty(): void { // / $_SERVER['REQUEST_URI'] = '/'; @@ -56,7 +56,7 @@ public function testPathDefaultEmpty() $this->assertSame($expected, $this->request->detectPath()); } - public function testPathRequestURI() + public function testPathRequestURI(): void { // /index.php/woot?code=good#pos $_SERVER['REQUEST_URI'] = '/index.php/woot'; @@ -66,7 +66,7 @@ public function testPathRequestURI() $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } - public function testPathRequestURINested() + public function testPathRequestURINested(): void { // I'm not sure but this is a case of Apache config making such SERVER // values? @@ -84,7 +84,7 @@ public function testPathRequestURINested() $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } - public function testPathRequestURISubfolder() + public function testPathRequestURISubfolder(): void { // /ci/index.php/popcorn/woot?code=good#pos $_SERVER['REQUEST_URI'] = '/ci/index.php/popcorn/woot'; @@ -94,7 +94,7 @@ public function testPathRequestURISubfolder() $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } - public function testPathRequestURINoIndex() + public function testPathRequestURINoIndex(): void { // /sub/example $_SERVER['REQUEST_URI'] = '/sub/example'; @@ -104,7 +104,7 @@ public function testPathRequestURINoIndex() $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } - public function testPathRequestURINginx() + public function testPathRequestURINginx(): void { // /ci/index.php/woot?code=good#pos $_SERVER['REQUEST_URI'] = '/index.php/woot?code=good'; @@ -114,7 +114,7 @@ public function testPathRequestURINginx() $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } - public function testPathRequestURINginxRedirecting() + public function testPathRequestURINginxRedirecting(): void { // /?/ci/index.php/woot $_SERVER['REQUEST_URI'] = '/?/ci/woot'; @@ -124,7 +124,7 @@ public function testPathRequestURINginxRedirecting() $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } - public function testPathRequestURISuppressed() + public function testPathRequestURISuppressed(): void { // /woot?code=good#pos $_SERVER['REQUEST_URI'] = '/woot'; @@ -134,7 +134,7 @@ public function testPathRequestURISuppressed() $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } - public function testPathQueryString() + public function testPathQueryString(): void { // /index.php?/ci/woot $_SERVER['REQUEST_URI'] = '/index.php?/ci/woot'; @@ -145,7 +145,7 @@ public function testPathQueryString() $this->assertSame($expected, $this->request->detectPath('QUERY_STRING')); } - public function testPathQueryStringWithQueryString() + public function testPathQueryStringWithQueryString(): void { // /index.php?/ci/woot?code=good#pos $_SERVER['REQUEST_URI'] = '/index.php?/ci/woot?code=good'; @@ -156,7 +156,7 @@ public function testPathQueryStringWithQueryString() $this->assertSame($expected, $this->request->detectPath('QUERY_STRING')); } - public function testPathQueryStringEmpty() + public function testPathQueryStringEmpty(): void { // /index.php? $_SERVER['REQUEST_URI'] = '/index.php?'; @@ -167,7 +167,7 @@ public function testPathQueryStringEmpty() $this->assertSame($expected, $this->request->detectPath('QUERY_STRING')); } - public function testPathPathInfo() + public function testPathPathInfo(): void { // /index.php/woot?code=good#pos $this->request->setGlobal('server', [ @@ -180,7 +180,7 @@ public function testPathPathInfo() $this->assertSame($expected, $this->request->detectPath('PATH_INFO')); } - public function testPathPathInfoGlobal() + public function testPathPathInfoGlobal(): void { // /index.php/woot?code=good#pos $this->request->setGlobal('server', [ diff --git a/tests/system/HTTP/IncomingRequestTest.php b/tests/system/HTTP/IncomingRequestTest.php index b4ab3606ed8b..b8015fab933e 100644 --- a/tests/system/HTTP/IncomingRequestTest.php +++ b/tests/system/HTTP/IncomingRequestTest.php @@ -39,7 +39,7 @@ protected function setUp(): void $_POST = $_GET = $_SERVER = $_REQUEST = $_ENV = $_COOKIE = $_SESSION = []; } - public function testCanGrabRequestVars() + public function testCanGrabRequestVars(): void { $_REQUEST['TEST'] = 5; @@ -47,7 +47,7 @@ public function testCanGrabRequestVars() $this->assertNull($this->request->getVar('TESTY')); } - public function testCanGrabGetVars() + public function testCanGrabGetVars(): void { $_GET['TEST'] = 5; @@ -55,7 +55,7 @@ public function testCanGrabGetVars() $this->assertNull($this->request->getGet('TESTY')); } - public function testCanGrabPostVars() + public function testCanGrabPostVars(): void { $_POST['TEST'] = 5; @@ -63,7 +63,7 @@ public function testCanGrabPostVars() $this->assertNull($this->request->getPost('TESTY')); } - public function testCanGrabPostBeforeGet() + public function testCanGrabPostBeforeGet(): void { $_POST['TEST'] = 5; $_GET['TEST'] = 3; @@ -72,12 +72,12 @@ public function testCanGrabPostBeforeGet() $this->assertSame('3', $this->request->getGetPost('TEST')); } - public function testNoOldInput() + public function testNoOldInput(): void { $this->assertNull($this->request->getOldInput('name')); } - public function testCanGetOldInput() + public function testCanGetOldInput(): void { $_SESSION['_ci_old_input'] = [ 'get' => ['one' => 'two'], @@ -88,7 +88,7 @@ public function testCanGetOldInput() $this->assertSame('two', $this->request->getOldInput('one')); } - public function testCanGetOldInputDotted() + public function testCanGetOldInputDotted(): void { $_SESSION['_ci_old_input'] = [ 'get' => ['apple' => ['name' => 'two']], @@ -99,7 +99,7 @@ public function testCanGetOldInputDotted() $this->assertSame('two', $this->request->getOldInput('apple.name')); } - public function testMissingOldInput() + public function testMissingOldInput(): void { $_SESSION['_ci_old_input'] = [ 'get' => ['apple' => ['name' => 'two']], @@ -112,7 +112,7 @@ public function testMissingOldInput() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/1492 */ - public function testCanGetOldInputArrayWithSESSION() + public function testCanGetOldInputArrayWithSESSION(): void { $_SESSION['_ci_old_input'] = [ 'get' => ['apple' => ['name' => 'two']], @@ -129,7 +129,7 @@ public function testCanGetOldInputArrayWithSESSION() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testCanGetOldInputArrayWithSessionService() + public function testCanGetOldInputArrayWithSessionService(): void { $locations = [ 'AB' => 'Alberta', @@ -142,7 +142,7 @@ public function testCanGetOldInputArrayWithSessionService() $this->assertSame($locations, $this->request->getOldInput('location')); } - public function testCanGrabServerVars() + public function testCanGrabServerVars(): void { $server = $this->getPrivateProperty($this->request, 'globals'); $server['server']['TEST'] = 5; @@ -152,7 +152,7 @@ public function testCanGrabServerVars() $this->assertNull($this->request->getServer('TESTY')); } - public function testCanGrabEnvVars() + public function testCanGrabEnvVars(): void { $server = $this->getPrivateProperty($this->request, 'globals'); $server['env']['TEST'] = 5; @@ -162,7 +162,7 @@ public function testCanGrabEnvVars() $this->assertNull($this->request->getEnv('TESTY')); } - public function testCanGrabCookieVars() + public function testCanGrabCookieVars(): void { $_COOKIE['TEST'] = 5; @@ -170,7 +170,7 @@ public function testCanGrabCookieVars() $this->assertNull($this->request->getCookie('TESTY')); } - public function testStoresDefaultLocale() + public function testStoresDefaultLocale(): void { $config = new App(); @@ -178,7 +178,7 @@ public function testStoresDefaultLocale() $this->assertSame($config->defaultLocale, $this->request->getLocale()); } - public function testSetLocaleSaves() + public function testSetLocaleSaves(): void { $config = new App(); $config->supportedLocales = ['en', 'es']; @@ -191,7 +191,7 @@ public function testSetLocaleSaves() $this->assertSame('en', $request->getLocale()); } - public function testSetBadLocale() + public function testSetBadLocale(): void { $config = new App(); $config->supportedLocales = ['en', 'es']; @@ -207,7 +207,7 @@ public function testSetBadLocale() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/2774 */ - public function testNegotiatesLocale() + public function testNegotiatesLocale(): void { $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'fr-FR; q=1.0, en; q=0.5'; @@ -222,7 +222,7 @@ public function testNegotiatesLocale() $this->assertSame('fr', $request->getLocale()); } - public function testNegotiatesLocaleOnlyBroad() + public function testNegotiatesLocaleOnlyBroad(): void { $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'fr; q=1.0, en; q=0.5'; @@ -241,7 +241,7 @@ public function testNegotiatesLocaleOnlyBroad() // that is up to the NegotiateTest. These are only to make sure that the requests // flow through to the negotiator - public function testNegotiatesNot() + public function testNegotiatesNot(): void { $this->request->setHeader('Accept-Charset', 'iso-8859-5, unicode-1-1;q=0.8'); @@ -249,7 +249,7 @@ public function testNegotiatesNot() $this->request->negotiate('something bogus', ['iso-8859-5', 'unicode-1-1']); } - public function testNegotiatesCharset() + public function testNegotiatesCharset(): void { // $_SERVER['HTTP_ACCEPT_CHARSET'] = 'iso-8859-5, unicode-1-1;q=0.8'; $this->request->setHeader('Accept-Charset', 'iso-8859-5, unicode-1-1;q=0.8'); @@ -260,7 +260,7 @@ public function testNegotiatesCharset() ); } - public function testNegotiatesMedia() + public function testNegotiatesMedia(): void { $this->request->setHeader('Accept', 'text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c'); $this->assertSame( @@ -269,19 +269,19 @@ public function testNegotiatesMedia() ); } - public function testNegotiatesEncoding() + public function testNegotiatesEncoding(): void { $this->request->setHeader('Accept-Encoding', 'gzip;q=1.0, identity; q=0.4, compress;q=0.5'); $this->assertSame('gzip', $this->request->negotiate('encoding', ['gzip', 'compress'])); } - public function testNegotiatesLanguage() + public function testNegotiatesLanguage(): void { $this->request->setHeader('Accept-Language', 'da, en-gb;q=0.8, en;q=0.7'); $this->assertSame('en', $this->request->negotiate('language', ['en', 'da'])); } - public function testCanGrabGetRawJSON() + public function testCanGrabGetRawJSON(): void { $json = '{"code":1, "message":"ok"}'; @@ -295,7 +295,7 @@ public function testCanGrabGetRawJSON() $this->assertSame($expected, $request->getJSON(true)); } - public function testCanGetAVariableFromJson() + public function testCanGetAVariableFromJson(): void { $jsonObj = [ 'foo' => 'bar', @@ -327,7 +327,7 @@ public function testCanGetAVariableFromJson() $this->assertNull($request->getJsonVar('null')); } - public function testGetJsonVarAsArray() + public function testGetJsonVarAsArray(): void { $jsonObj = [ 'baz' => [ @@ -358,7 +358,7 @@ public function testGetJsonVarAsArray() $this->assertNull($jsonVar['null']); } - public function testGetJsonVarCanFilter() + public function testGetJsonVarCanFilter(): void { $json = json_encode(['foo' => 'bar']); @@ -370,7 +370,7 @@ public function testGetJsonVarCanFilter() $this->assertFalse($request->getJsonVar('foo', false, FILTER_VALIDATE_INT)); } - public function testGetJsonVarCanFilterArray() + public function testGetJsonVarCanFilterArray(): void { $json = json_encode([ 'string' => 'hello123world', @@ -423,7 +423,7 @@ public function testGetJsonVarCanFilterArray() ); } - public function testGetVarWorksWithJson() + public function testGetVarWorksWithJson(): void { $json = json_encode(['foo' => 'bar', 'fizz' => 'buzz']); @@ -448,7 +448,7 @@ public function testGetVarWorksWithJson() $this->assertSame('buzz', $all->fizz); } - public function testGetVarWorksWithJsonAndGetParams() + public function testGetVarWorksWithJsonAndGetParams(): void { $config = new App(); $config->baseURL = 'http://example.com/'; @@ -480,7 +480,7 @@ public function testGetVarWorksWithJsonAndGetParams() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/5391 */ - public function testGetJsonVarReturnsNullFromNullBody() + public function testGetJsonVarReturnsNullFromNullBody(): void { $config = new App(); $config->baseURL = 'http://example.com/'; @@ -490,7 +490,7 @@ public function testGetJsonVarReturnsNullFromNullBody() $this->assertNull($request->getJsonVar('myKey')); } - public function testgetJSONReturnsNullFromNullBody() + public function testgetJSONReturnsNullFromNullBody(): void { $config = new App(); $config->baseURL = 'http://example.com/'; @@ -500,7 +500,7 @@ public function testgetJSONReturnsNullFromNullBody() $this->assertNull($request->getJSON()); } - public function testCanGrabGetRawInput() + public function testCanGrabGetRawInput(): void { $rawstring = 'username=admin001&role=administrator&usepass=0'; @@ -606,7 +606,7 @@ public function provideRawInputVarChecks(): iterable * @param mixed $filter * @param mixed $flag */ - public function testCanGrabGetRawInputVar($rawstring, $var, $expected, $filter, $flag) + public function testCanGrabGetRawInputVar($rawstring, $var, $expected, $filter, $flag): void { $config = new App(); $config->baseURL = 'http://example.com/'; @@ -619,7 +619,7 @@ public function testCanGrabGetRawInputVar($rawstring, $var, $expected, $filter, /** * @dataProvider provideIsHTTPMethods */ - public function testIsHTTPMethodLowerCase(string $value) + public function testIsHTTPMethodLowerCase(string $value): void { $request = $this->request->withMethod($value); @@ -642,14 +642,14 @@ public function provideIsHTTPMethods(): iterable /** * @dataProvider provideIsHTTPMethods */ - public function testIsHTTPMethodUpperCase(string $value) + public function testIsHTTPMethodUpperCase(string $value): void { $request = $this->request->withMethod($value); $this->assertTrue($request->is($value)); } - public function testIsInvalidValue() + public function testIsInvalidValue(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Unknown type: invalid'); @@ -659,50 +659,50 @@ public function testIsInvalidValue() $request->is('invalid'); } - public function testIsJson() + public function testIsJson(): void { $request = $this->request->setHeader('Content-Type', 'application/json'); $this->assertTrue($request->is('json')); } - public function testIsWithAjax() + public function testIsWithAjax(): void { $request = $this->request->setHeader('X-Requested-With', 'XMLHttpRequest'); $this->assertTrue($request->is('ajax')); } - public function testIsCLI() + public function testIsCLI(): void { $this->assertFalse($this->request->isCLI()); } - public function testIsAJAX() + public function testIsAJAX(): void { $this->request->appendHeader('X-Requested-With', 'XMLHttpRequest'); $this->assertTrue($this->request->isAJAX()); } - public function testIsSecure() + public function testIsSecure(): void { $_SERVER['HTTPS'] = 'on'; $this->assertTrue($this->request->isSecure()); } - public function testIsSecureFrontEnd() + public function testIsSecureFrontEnd(): void { $this->request->appendHeader('Front-End-Https', 'on'); $this->assertTrue($this->request->isSecure()); } - public function testIsSecureForwarded() + public function testIsSecureForwarded(): void { $this->request->appendHeader('X-Forwarded-Proto', 'https'); $this->assertTrue($this->request->isSecure()); } - public function testUserAgent() + public function testUserAgent(): void { $_SERVER['HTTP_USER_AGENT'] = 'Mozilla'; @@ -712,7 +712,7 @@ public function testUserAgent() $this->assertSame('Mozilla', $request->getUserAgent()->__toString()); } - public function testFileCollectionFactory() + public function testFileCollectionFactory(): void { $_FILES = [ 'userfile' => [ @@ -734,7 +734,7 @@ public function testFileCollectionFactory() $this->assertSame(124, $file->getSize()); } - public function testGetFileMultiple() + public function testGetFileMultiple(): void { $_FILES = [ 'userfile' => [ @@ -766,7 +766,7 @@ public function testGetFileMultiple() $this->assertSame(125, $gotit[1]->getSize()); } - public function testGetFile() + public function testGetFile(): void { $_FILES = [ 'userfile' => [ @@ -782,7 +782,7 @@ public function testGetFile() $this->assertSame(124, $gotit->getSize()); } - public function testSpoofing() + public function testSpoofing(): void { $this->request->setMethod('WINK'); $this->assertSame('wink', $this->request->getMethod()); @@ -791,7 +791,7 @@ public function testSpoofing() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/2839 */ - public function testGetPostEmpty() + public function testGetPostEmpty(): void { $_POST['TEST'] = '5'; $_GET['TEST'] = '3'; @@ -799,19 +799,19 @@ public function testGetPostEmpty() $this->assertSame($_GET, $this->request->getGetPost()); } - public function testPostGetSecondStream() + public function testPostGetSecondStream(): void { $_GET['get'] = '3'; $this->assertSame($_GET, $this->request->getPostGet()); } - public function testGetPostSecondStream() + public function testGetPostSecondStream(): void { $_POST['post'] = '5'; $this->assertSame($_POST, $this->request->getGetPost()); } - public function testGetPostSecondStreams() + public function testGetPostSecondStreams(): void { $_GET['get'] = '3'; $_POST['post'] = '5'; @@ -819,7 +819,7 @@ public function testGetPostSecondStreams() $this->assertSame(array_merge($_POST, $_GET), $this->request->getGetPost()); } - public function testWithFalseBody() + public function testWithFalseBody(): void { // Use `false` here to simulate file_get_contents returning a false value $request = new IncomingRequest(new App(), new URI(), false, new UserAgent()); @@ -831,7 +831,7 @@ public function testWithFalseBody() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/3020 */ - public function testGetPostIndexNotExists() + public function testGetPostIndexNotExists(): void { $_POST['TEST'] = 5; $_GET['TEST'] = 3; @@ -859,7 +859,7 @@ public function providePathChecks(): iterable * @param mixed $path * @param mixed $detectPath */ - public function testExtensionPHP($path, $detectPath) + public function testExtensionPHP($path, $detectPath): void { $config = new App(); $config->baseURL = 'http://example.com/'; @@ -870,7 +870,7 @@ public function testExtensionPHP($path, $detectPath) $this->assertSame($detectPath, $request->detectPath()); } - public function testGetPath() + public function testGetPath(): void { $_SERVER['REQUEST_URI'] = '/index.php/fruits/banana'; $_SERVER['SCRIPT_NAME'] = '/index.php'; @@ -880,7 +880,7 @@ public function testGetPath() $this->assertSame('fruits/banana', $request->getPath()); } - public function testGetPathIsRelative() + public function testGetPathIsRelative(): void { $_SERVER['REQUEST_URI'] = '/sub/folder/index.php/fruits/banana'; $_SERVER['SCRIPT_NAME'] = '/sub/folder/index.php'; @@ -890,7 +890,7 @@ public function testGetPathIsRelative() $this->assertSame('fruits/banana', $request->getPath()); } - public function testGetPathStoresDetectedValue() + public function testGetPathStoresDetectedValue(): void { $_SERVER['REQUEST_URI'] = '/fruits/banana'; $_SERVER['SCRIPT_NAME'] = '/index.php'; @@ -902,7 +902,7 @@ public function testGetPathStoresDetectedValue() $this->assertSame('fruits/banana', $request->getPath()); } - public function testGetPathIsRediscovered() + public function testGetPathIsRediscovered(): void { $_SERVER['REQUEST_URI'] = '/fruits/banana'; $_SERVER['SCRIPT_NAME'] = '/index.php'; @@ -915,7 +915,7 @@ public function testGetPathIsRediscovered() $this->assertSame('candy/snickers', $request->getPath()); } - public function testSetPath() + public function testSetPath(): void { $request = new IncomingRequest(new App(), new URI(), null, new UserAgent()); $this->assertSame('', $request->getPath()); @@ -924,7 +924,7 @@ public function testSetPath() $this->assertSame('foobar', $request->getPath()); } - public function testSetPathUpdatesURI() + public function testSetPathUpdatesURI(): void { $request = new IncomingRequest(new App(), new URI(), null, new UserAgent()); @@ -933,7 +933,7 @@ public function testSetPathUpdatesURI() $this->assertSame('apples', $request->getUri()->getPath()); } - public function testGetIPAddressNormal() + public function testGetIPAddressNormal(): void { $expected = '123.123.123.123'; $_SERVER['REMOTE_ADDR'] = $expected; @@ -946,7 +946,7 @@ public function testGetIPAddressNormal() $this->assertSame($expected, $this->request->getIPAddress()); } - public function testGetIPAddressThruProxy() + public function testGetIPAddressThruProxy(): void { $expected = '123.123.123.123'; $_SERVER['HTTP_X_FORWARDED_FOR'] = $expected; @@ -964,7 +964,7 @@ public function testGetIPAddressThruProxy() $this->assertSame($expected, $this->request->getIPAddress()); } - public function testGetIPAddressThruProxyIPv6() + public function testGetIPAddressThruProxyIPv6(): void { $expected = '123.123.123.123'; $_SERVER['HTTP_X_FORWARDED_FOR'] = $expected; @@ -981,7 +981,7 @@ public function testGetIPAddressThruProxyIPv6() $this->assertSame($expected, $this->request->getIPAddress()); } - public function testGetIPAddressThruProxyInvalidIPAddress() + public function testGetIPAddressThruProxyInvalidIPAddress(): void { $_SERVER['HTTP_X_FORWARDED_FOR'] = '123.456.23.123'; $expected = '10.0.1.200'; @@ -999,7 +999,7 @@ public function testGetIPAddressThruProxyInvalidIPAddress() $this->assertSame($expected, $this->request->getIPAddress()); } - public function testGetIPAddressThruProxyInvalidIPAddressIPv6() + public function testGetIPAddressThruProxyInvalidIPAddressIPv6(): void { $_SERVER['HTTP_X_FORWARDED_FOR'] = '2001:xyz::1'; $expected = '2001:db8::2:1'; @@ -1016,7 +1016,7 @@ public function testGetIPAddressThruProxyInvalidIPAddressIPv6() $this->assertSame($expected, $this->request->getIPAddress()); } - public function testGetIPAddressThruProxyNotWhitelisted() + public function testGetIPAddressThruProxyNotWhitelisted(): void { $expected = '10.10.1.200'; $_SERVER['REMOTE_ADDR'] = $expected; @@ -1034,7 +1034,7 @@ public function testGetIPAddressThruProxyNotWhitelisted() $this->assertSame($expected, $this->request->getIPAddress()); } - public function testGetIPAddressThruProxyNotWhitelistedIPv6() + public function testGetIPAddressThruProxyNotWhitelistedIPv6(): void { $expected = '2001:db8::2:2'; $_SERVER['REMOTE_ADDR'] = $expected; @@ -1051,7 +1051,7 @@ public function testGetIPAddressThruProxyNotWhitelistedIPv6() $this->assertSame($expected, $this->request->getIPAddress()); } - public function testGetIPAddressThruProxySubnet() + public function testGetIPAddressThruProxySubnet(): void { $expected = '123.123.123.123'; $_SERVER['HTTP_X_FORWARDED_FOR'] = $expected; @@ -1066,7 +1066,7 @@ public function testGetIPAddressThruProxySubnet() $this->assertSame($expected, $this->request->getIPAddress()); } - public function testGetIPAddressThruProxySubnetIPv6() + public function testGetIPAddressThruProxySubnetIPv6(): void { $expected = '123.123.123.123'; $_SERVER['HTTP_X_FORWARDED_FOR'] = $expected; @@ -1081,7 +1081,7 @@ public function testGetIPAddressThruProxySubnetIPv6() $this->assertSame($expected, $this->request->getIPAddress()); } - public function testGetIPAddressThruProxyOutOfSubnet() + public function testGetIPAddressThruProxyOutOfSubnet(): void { $expected = '192.168.5.21'; $_SERVER['REMOTE_ADDR'] = $expected; @@ -1096,7 +1096,7 @@ public function testGetIPAddressThruProxyOutOfSubnet() $this->assertSame($expected, $this->request->getIPAddress()); } - public function testGetIPAddressThruProxyOutOfSubnetIPv6() + public function testGetIPAddressThruProxyOutOfSubnetIPv6(): void { $expected = '2001:db8:1235:ffff:ffff:ffff:ffff:ffff'; $_SERVER['REMOTE_ADDR'] = $expected; @@ -1111,7 +1111,7 @@ public function testGetIPAddressThruProxyOutOfSubnetIPv6() $this->assertSame($expected, $this->request->getIPAddress()); } - public function testGetIPAddressThruProxyBothIPv4AndIPv6() + public function testGetIPAddressThruProxyBothIPv4AndIPv6(): void { $expected = '2001:db8:1235:ffff:ffff:ffff:ffff:ffff'; $_SERVER['REMOTE_ADDR'] = $expected; @@ -1129,7 +1129,7 @@ public function testGetIPAddressThruProxyBothIPv4AndIPv6() $this->assertSame($expected, $this->request->getIPAddress()); } - public function testGetIPAddressThruProxyInvalidConfigString() + public function testGetIPAddressThruProxyInvalidConfigString(): void { $this->expectException(TypeError::class); @@ -1141,7 +1141,7 @@ public function testGetIPAddressThruProxyInvalidConfigString() $this->request->getIPAddress(); } - public function testGetIPAddressThruProxyInvalidConfigArray() + public function testGetIPAddressThruProxyInvalidConfigArray(): void { $this->expectException(ConfigException::class); $this->expectExceptionMessage( diff --git a/tests/system/HTTP/MessageTest.php b/tests/system/HTTP/MessageTest.php index 86e870d3b073..67768aa7ea2c 100644 --- a/tests/system/HTTP/MessageTest.php +++ b/tests/system/HTTP/MessageTest.php @@ -32,7 +32,7 @@ protected function setUp(): void // We can only test the headers retrieved from $_SERVER // This test might fail under apache. - public function testHeadersRetrievesHeaders() + public function testHeadersRetrievesHeaders(): void { $this->message->setHeader('Host', 'daisyduke.com'); $this->message->setHeader('Referer', 'RoscoePekoTrain.com'); @@ -46,7 +46,7 @@ public function testHeadersRetrievesHeaders() $this->assertSame('RoscoePekoTrain.com', $headers['Referer']->getValue()); } - public function testCanGrabSingleHeader() + public function testCanGrabSingleHeader(): void { $this->message->setHeader('Host', 'daisyduke.com'); @@ -56,7 +56,7 @@ public function testCanGrabSingleHeader() $this->assertSame('daisyduke.com', $header->getValue()); } - public function testCaseInsensitiveheader() + public function testCaseInsensitiveheader(): void { $this->message->setHeader('Host', 'daisyduke.com'); @@ -64,7 +64,7 @@ public function testCaseInsensitiveheader() $this->assertSame('daisyduke.com', $this->message->header('HOST')->getValue()); } - public function testCanSetHeaders() + public function testCanSetHeaders(): void { $this->message->setHeader('first', 'kiss'); $this->message->setHeader('second', ['black', 'book']); @@ -73,7 +73,7 @@ public function testCanSetHeaders() $this->assertSame(['black', 'book'], $this->message->header('Second')->getValue()); } - public function testSetHeaderOverwritesPrevious() + public function testSetHeaderOverwritesPrevious(): void { $this->message->setHeader('Pragma', 'cache'); $this->message->setHeader('Pragma', 'no-cache'); @@ -81,7 +81,7 @@ public function testSetHeaderOverwritesPrevious() $this->assertSame('no-cache', $this->message->header('Pragma')->getValue()); } - public function testHeaderLineIsReadable() + public function testHeaderLineIsReadable(): void { $this->message->setHeader('Accept', ['json', 'html']); $this->message->setHeader('Host', 'daisyduke.com'); @@ -90,7 +90,7 @@ public function testHeaderLineIsReadable() $this->assertSame('daisyduke.com', $this->message->header('Host')->getValueLine()); } - public function testCanRemoveHeader() + public function testCanRemoveHeader(): void { $this->message->setHeader('Host', 'daisyduke.com'); @@ -99,7 +99,7 @@ public function testCanRemoveHeader() $this->assertNull($this->message->header('host')); } - public function testCanAppendHeader() + public function testCanAppendHeader(): void { $this->message->setHeader('accept', ['json', 'html']); @@ -108,7 +108,7 @@ public function testCanAppendHeader() $this->assertSame(['json', 'html', 'xml'], $this->message->header('accept')->getValue()); } - public function testCanPrependHeader() + public function testCanPrependHeader(): void { $this->message->setHeader('accept', ['json', 'html']); @@ -117,27 +117,27 @@ public function testCanPrependHeader() $this->assertSame(['xml', 'json', 'html'], $this->message->header('accept')->getValue()); } - public function testSetProtocolWorks() + public function testSetProtocolWorks(): void { $this->message->setProtocolVersion('1.1'); $this->assertSame('1.1', $this->message->getProtocolVersion()); } - public function testSetProtocolWorksWithNonNumericVersion() + public function testSetProtocolWorksWithNonNumericVersion(): void { $this->message->setProtocolVersion('HTTP/1.1'); $this->assertSame('1.1', $this->message->getProtocolVersion()); } - public function testSetProtocolThrowsExceptionWithInvalidProtocol() + public function testSetProtocolThrowsExceptionWithInvalidProtocol(): void { $this->expectException(HTTPException::class); $this->message->setProtocolVersion('1.2'); } - public function testBodyBasics() + public function testBodyBasics(): void { $body = 'a strange little fellow.'; @@ -146,7 +146,7 @@ public function testBodyBasics() $this->assertSame($body, $this->message->getBody()); } - public function testAppendBody() + public function testAppendBody(): void { $this->message->setBody('moo'); @@ -155,14 +155,14 @@ public function testAppendBody() $this->assertSame("moo\n", $this->message->getBody()); } - public function testSetHeaderReplacingHeader() + public function testSetHeaderReplacingHeader(): void { $this->message->setHeader('Accept', 'json'); $this->assertSame('json', $this->message->getHeaderLine('Accept')); } - public function testSetHeaderDuplicateSettings() + public function testSetHeaderDuplicateSettings(): void { $this->message->setHeader('Accept', 'json'); $this->message->setHeader('Accept', 'xml'); @@ -170,7 +170,7 @@ public function testSetHeaderDuplicateSettings() $this->assertSame('xml', $this->message->getHeaderLine('Accept')); } - public function testSetHeaderDuplicateSettingsInsensitive() + public function testSetHeaderDuplicateSettingsInsensitive(): void { $this->message->setHeader('Accept', 'json'); $this->message->setHeader('accept', 'xml'); @@ -178,7 +178,7 @@ public function testSetHeaderDuplicateSettingsInsensitive() $this->assertSame('xml', $this->message->getHeaderLine('Accept')); } - public function testSetHeaderArrayValues() + public function testSetHeaderArrayValues(): void { $this->message->setHeader('Accept', ['json', 'html', 'xml']); @@ -209,7 +209,7 @@ public function provideArrayHeaderValue(): iterable * * @param mixed $arrayHeaderValue */ - public function testSetHeaderWithExistingArrayValuesAppendStringValue($arrayHeaderValue) + public function testSetHeaderWithExistingArrayValuesAppendStringValue($arrayHeaderValue): void { $this->message->setHeader('Accept', $arrayHeaderValue); $this->message->setHeader('Accept', 'xml'); @@ -222,7 +222,7 @@ public function testSetHeaderWithExistingArrayValuesAppendStringValue($arrayHead * * @param mixed $arrayHeaderValue */ - public function testSetHeaderWithExistingArrayValuesAppendArrayValue($arrayHeaderValue) + public function testSetHeaderWithExistingArrayValuesAppendArrayValue($arrayHeaderValue): void { $this->message->setHeader('Accept', $arrayHeaderValue); $this->message->setHeader('Accept', ['xml']); @@ -230,7 +230,7 @@ public function testSetHeaderWithExistingArrayValuesAppendArrayValue($arrayHeade $this->assertSame('json, html, xml', $this->message->getHeaderLine('Accept')); } - public function testSetHeaderWithExistingArrayValuesAppendNullValue() + public function testSetHeaderWithExistingArrayValuesAppendNullValue(): void { $this->message->setHeader('Accept', ['json', 'html', 'xml']); $this->message->setHeader('Accept', null); @@ -238,7 +238,7 @@ public function testSetHeaderWithExistingArrayValuesAppendNullValue() $this->assertSame('json, html, xml', $this->message->getHeaderLine('Accept')); } - public function testPopulateHeadersWithoutContentType() + public function testPopulateHeadersWithoutContentType(): void { $original = $_SERVER; $originalEnv = getenv('CONTENT_TYPE'); @@ -255,7 +255,7 @@ public function testPopulateHeadersWithoutContentType() $_SERVER = $original; // restore so code coverage doesn't break } - public function testPopulateHeadersWithoutHTTP() + public function testPopulateHeadersWithoutHTTP(): void { // fail path, if argument doesn't have the HTTP_* $original = $_SERVER; @@ -272,7 +272,7 @@ public function testPopulateHeadersWithoutHTTP() $_SERVER = $original; // restore so code coverage doesn't break } - public function testPopulateHeadersKeyNotExists() + public function testPopulateHeadersKeyNotExists(): void { // Success path, if array key is not exists, assign empty string to it's value $original = $_SERVER; @@ -288,7 +288,7 @@ public function testPopulateHeadersKeyNotExists() $_SERVER = $original; // restore so code coverage doesn't break } - public function testPopulateHeaders() + public function testPopulateHeaders(): void { // success path $original = $_SERVER; diff --git a/tests/system/HTTP/NegotiateTest.php b/tests/system/HTTP/NegotiateTest.php index 547b50ca8039..4323e80c2b42 100644 --- a/tests/system/HTTP/NegotiateTest.php +++ b/tests/system/HTTP/NegotiateTest.php @@ -33,7 +33,7 @@ protected function setUp(): void $this->negotiate = new Negotiate($this->request); } - public function testNegotiateMediaFindsHighestMatch() + public function testNegotiateMediaFindsHighestMatch(): void { $this->request->setHeader('Accept', 'text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c'); $this->negotiate->setRequest($this->request); @@ -47,7 +47,7 @@ public function testNegotiateMediaFindsHighestMatch() $this->assertSame('text/md', $this->negotiate->media(['text/md'])); } - public function testParseHeaderDeterminesCorrectPrecedence() + public function testParseHeaderDeterminesCorrectPrecedence(): void { $header = $this->negotiate->parseHeader('text/*, text/plain, text/plain;format=flowed, */*'); @@ -57,14 +57,14 @@ public function testParseHeaderDeterminesCorrectPrecedence() $this->assertSame('*/*', $header[3]['value']); } - public function testNegotiateMediaReturnsSupportedMatchWhenAsterisksInAvailable() + public function testNegotiateMediaReturnsSupportedMatchWhenAsterisksInAvailable(): void { $this->request->setHeader('Accept', 'image/*, text/*'); $this->assertSame('text/plain', $this->negotiate->media(['text/plain'])); } - public function testNegotiateMediaRecognizesMediaTypes() + public function testNegotiateMediaRecognizesMediaTypes(): void { // Image has a higher specificity, but is the wrong type... $this->request->setHeader('Accept', 'text/*, image/jpeg'); @@ -72,7 +72,7 @@ public function testNegotiateMediaRecognizesMediaTypes() $this->assertSame('text/plain', $this->negotiate->media(['text/plain'])); } - public function testNegotiateMediaSupportsStrictMatching() + public function testNegotiateMediaSupportsStrictMatching(): void { // Image has a higher specificity, but is the wrong type... $this->request->setHeader('Accept', 'text/md, image/jpeg'); @@ -81,7 +81,7 @@ public function testNegotiateMediaSupportsStrictMatching() $this->assertSame('', $this->negotiate->media(['text/plain'], true)); } - public function testAcceptCharsetMatchesBasics() + public function testAcceptCharsetMatchesBasics(): void { $this->request->setHeader('Accept-Charset', 'iso-8859-5, unicode-1-1;q=0.8'); @@ -92,12 +92,12 @@ public function testAcceptCharsetMatchesBasics() $this->assertSame('utf-8', $this->negotiate->charset(['iso-8859', 'unicode-1-2'])); } - public function testNegotiateEncodingReturnsFirstIfNoAcceptHeaderExists() + public function testNegotiateEncodingReturnsFirstIfNoAcceptHeaderExists(): void { $this->assertSame('compress', $this->negotiate->encoding(['compress', 'gzip'])); } - public function testNegotiatesEncodingBasics() + public function testNegotiatesEncodingBasics(): void { $this->request->setHeader('Accept-Encoding', 'gzip;q=1.0, identity; q=0.4, compress;q=0.5'); @@ -106,7 +106,7 @@ public function testNegotiatesEncodingBasics() $this->assertSame('identity', $this->negotiate->encoding()); } - public function testAcceptLanguageBasics() + public function testAcceptLanguageBasics(): void { $this->request->setHeader('Accept-Language', 'da, en-gb;q=0.8, en;q=0.7'); @@ -118,47 +118,47 @@ public function testAcceptLanguageBasics() /** * @see https://github.com/codeigniter4/CodeIgniter4/issues/2774 */ - public function testAcceptLanguageMatchesBroadly() + public function testAcceptLanguageMatchesBroadly(): void { $this->request->setHeader('Accept-Language', 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7'); $this->assertSame('fr', $this->negotiate->language(['fr', 'en'])); } - public function testBestMatchEmpty() + public function testBestMatchEmpty(): void { $this->expectException(HTTPException::class); $this->negotiate->media([]); } - public function testBestMatchNoHeader() + public function testBestMatchNoHeader(): void { $this->request->setHeader('Accept', ''); $this->assertSame('', $this->negotiate->media(['apple', 'banana'], true)); $this->assertSame('apple/mac', $this->negotiate->media(['apple/mac', 'banana/yellow'], false)); } - public function testBestMatchNotAcceptable() + public function testBestMatchNotAcceptable(): void { $this->request->setHeader('Accept', 'popcorn/cheddar'); $this->assertSame('apple/mac', $this->negotiate->media(['apple/mac', 'banana/yellow'], false)); $this->assertSame('banana/yellow', $this->negotiate->media(['banana/yellow', 'apple/mac'], false)); } - public function testBestMatchFirstSupported() + public function testBestMatchFirstSupported(): void { $this->request->setHeader('Accept', 'popcorn/cheddar, */*'); $this->assertSame('apple/mac', $this->negotiate->media(['apple/mac', 'banana/yellow'], false)); } - public function testBestMatchLowQuality() + public function testBestMatchLowQuality(): void { $this->request->setHeader('Accept', 'popcorn/cheddar;q=0, apple/mac, */*'); $this->assertSame('apple/mac', $this->negotiate->media(['apple/mac', 'popcorn/cheddar'], false)); $this->assertSame('apple/mac', $this->negotiate->media(['popcorn/cheddar', 'apple/mac'], false)); } - public function testBestMatchOnlyLowQuality() + public function testBestMatchOnlyLowQuality(): void { $this->request->setHeader('Accept', 'popcorn/cheddar;q=0'); // the first supported should be returned, since nothing will make us happy @@ -166,7 +166,7 @@ public function testBestMatchOnlyLowQuality() $this->assertSame('popcorn/cheddar', $this->negotiate->media(['popcorn/cheddar', 'apple/mac'], false)); } - public function testParameterMatching() + public function testParameterMatching(): void { $this->request->setHeader('Accept', 'popcorn/cheddar;a=0;b=1'); $this->assertSame('popcorn/cheddar;a=2', $this->negotiate->media(['popcorn/cheddar;a=2'], false)); diff --git a/tests/system/HTTP/OutgoingRequestTest.php b/tests/system/HTTP/OutgoingRequestTest.php index 8a6690772fa4..51b2bab6a3fe 100644 --- a/tests/system/HTTP/OutgoingRequestTest.php +++ b/tests/system/HTTP/OutgoingRequestTest.php @@ -20,7 +20,7 @@ */ final class OutgoingRequestTest extends CIUnitTestCase { - public function testCreateWithHeader() + public function testCreateWithHeader(): void { $uri = new URI('https://example.com/'); $headers = ['User-Agent' => 'Mozilla/5.0']; @@ -29,7 +29,7 @@ public function testCreateWithHeader() $this->assertSame('Mozilla/5.0', $request->header('User-Agent')->getValue()); } - public function testGetUri() + public function testGetUri(): void { $uri = new URI('https://example.com/'); $request = new OutgoingRequest('GET', $uri); @@ -37,7 +37,7 @@ public function testGetUri() $this->assertSame($uri, $request->getUri()); } - public function testWithMethod() + public function testWithMethod(): void { $uri = new URI('https://example.com/'); $request = new OutgoingRequest('GET', $uri); @@ -48,7 +48,7 @@ public function testWithMethod() $this->assertSame('POST', strtoupper($newRequest->getMethod())); } - public function testWithUri() + public function testWithUri(): void { $uri = new URI('https://example.com/'); $request = new OutgoingRequest('GET', $uri); @@ -65,7 +65,7 @@ public function testWithUri() * request. * https://www.php-fig.org/psr/psr-7/#32-psrhttpmessagerequestinterface */ - public function testWithUriPreserveHostHostHeaderIsMissingAndNewUriContainsHost() + public function testWithUriPreserveHostHostHeaderIsMissingAndNewUriContainsHost(): void { $uri = new URI(); $request = new OutgoingRequest('GET', $uri); @@ -82,7 +82,7 @@ public function testWithUriPreserveHostHostHeaderIsMissingAndNewUriContainsHost( * request. * https://www.php-fig.org/psr/psr-7/#32-psrhttpmessagerequestinterface */ - public function testWithUriPreserveHostHostHeaderIsMissingAndNewUriDoesNotContainsHost() + public function testWithUriPreserveHostHostHeaderIsMissingAndNewUriDoesNotContainsHost(): void { $uri = new URI(); $request = new OutgoingRequest('GET', $uri); @@ -98,7 +98,7 @@ public function testWithUriPreserveHostHostHeaderIsMissingAndNewUriDoesNotContai * the Host header in the returned request. * https://www.php-fig.org/psr/psr-7/#32-psrhttpmessagerequestinterface */ - public function testWithUriPreserveHostHostHostIsNonEmpty() + public function testWithUriPreserveHostHostHostIsNonEmpty(): void { $uri = new URI('https://example.com/'); $request = new OutgoingRequest('GET', $uri); diff --git a/tests/system/HTTP/RedirectResponseTest.php b/tests/system/HTTP/RedirectResponseTest.php index 5f95b307d8cf..c775da828865 100644 --- a/tests/system/HTTP/RedirectResponseTest.php +++ b/tests/system/HTTP/RedirectResponseTest.php @@ -59,7 +59,7 @@ protected function setUp(): void Services::injectMock('request', $this->request); } - public function testRedirectToFullURI() + public function testRedirectToFullURI(): void { $response = new RedirectResponse(new App()); @@ -69,7 +69,7 @@ public function testRedirectToFullURI() $this->assertSame('http://example.com/foo', $response->getHeaderLine('Location')); } - public function testRedirectRoute() + public function testRedirectRoute(): void { $response = new RedirectResponse(new App()); @@ -88,7 +88,7 @@ public function testRedirectRoute() $this->assertSame('http://example.com/index.php/exampleRoute2', $response->getHeaderLine('Location')); } - public function testRedirectRouteBadNamedRoute() + public function testRedirectRouteBadNamedRoute(): void { $this->expectException(HTTPException::class); $this->expectExceptionMessage('The route for "differentRoute" cannot be found.'); @@ -100,7 +100,7 @@ public function testRedirectRouteBadNamedRoute() $response->route('differentRoute'); } - public function testRedirectRouteBadControllerMethod() + public function testRedirectRouteBadControllerMethod(): void { $this->expectException(HTTPException::class); $this->expectExceptionMessage('The route for "Bad::badMethod" cannot be found.'); @@ -112,7 +112,7 @@ public function testRedirectRouteBadControllerMethod() $response->route('Bad::badMethod'); } - public function testRedirectRelativeConvertsToFullURI() + public function testRedirectRelativeConvertsToFullURI(): void { $response = new RedirectResponse($this->config); @@ -126,7 +126,7 @@ public function testRedirectRelativeConvertsToFullURI() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testWithInput() + public function testWithInput(): void { $_SESSION = []; $_GET = ['foo' => 'bar']; @@ -146,7 +146,7 @@ public function testWithInput() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testWithValidationErrors() + public function testWithValidationErrors(): void { $_SESSION = []; @@ -166,7 +166,7 @@ public function testWithValidationErrors() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testWith() + public function testWith(): void { $_SESSION = []; @@ -182,7 +182,7 @@ public function testWith() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testRedirectBack() + public function testRedirectBack(): void { $_SERVER['HTTP_REFERER'] = 'http://somewhere.com'; $this->request = new MockIncomingRequest($this->config, new URI('http://somewhere.com'), null, new UserAgent()); @@ -198,7 +198,7 @@ public function testRedirectBack() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testRedirectBackMissing() + public function testRedirectBackMissing(): void { $_SESSION = []; @@ -215,7 +215,7 @@ public function testRedirectBackMissing() * * @see https://github.com/codeigniter4/CodeIgniter4/issues/2119 */ - public function testRedirectRouteBaseUrl() + public function testRedirectRouteBaseUrl(): void { $config = new App(); $config->baseURL = 'http://example.com/test/'; @@ -236,7 +236,7 @@ public function testRedirectRouteBaseUrl() Factories::reset('config'); } - public function testWithCookies() + public function testWithCookies(): void { $_SESSION = []; @@ -254,7 +254,7 @@ public function testWithCookies() * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testWithCookiesWithEmptyCookies() + public function testWithCookiesWithEmptyCookies(): void { $_SESSION = []; @@ -264,7 +264,7 @@ public function testWithCookiesWithEmptyCookies() $this->assertEmpty($response->getCookies()); } - public function testWithHeaders() + public function testWithHeaders(): void { $_SESSION = []; @@ -282,7 +282,7 @@ public function testWithHeaders() } } - public function testWithHeadersWithEmptyHeaders() + public function testWithHeadersWithEmptyHeaders(): void { $_SESSION = []; diff --git a/tests/system/HTTP/RequestTest.php b/tests/system/HTTP/RequestTest.php index ab19f05adfac..3eaea59ed1c2 100644 --- a/tests/system/HTTP/RequestTest.php +++ b/tests/system/HTTP/RequestTest.php @@ -35,7 +35,7 @@ protected function setUp(): void $_GET = []; } - public function testFetchGlobalsSingleValue() + public function testFetchGlobalsSingleValue(): void { $_POST['foo'] = 'bar'; $_GET['bar'] = 'baz'; @@ -44,12 +44,12 @@ public function testFetchGlobalsSingleValue() $this->assertSame('baz', $this->request->fetchGlobal('get', 'bar')); } - public function testFetchGlobalsReturnsNullWhenNotFound() + public function testFetchGlobalsReturnsNullWhenNotFound(): void { $this->assertNull($this->request->fetchGlobal('post', 'foo')); } - public function testFetchGlobalsFiltersValues() + public function testFetchGlobalsFiltersValues(): void { $this->request->setGlobal('post', [ 'foo' => 'bar'; $this->assertSame($expected, script_tag($target)); } - public function testScriptTagWithoutProtocol() + public function testScriptTagWithoutProtocol(): void { $target = 'js/mystyles.js'; $expected = ''; $this->assertSame($expected, script_tag($target)); } - public function testScriptTagWithIndexpage() + public function testScriptTagWithIndexpage(): void { $target = 'js/mystyles.js'; $expected = ''; $this->assertSame($expected, script_tag($target, true)); } - public function testScriptTagWithSrc() + public function testScriptTagWithSrc(): void { $target = ['src' => 'http://site.com/js/mystyles.js']; $expected = ''; $this->assertSame($expected, script_tag($target)); } - public function testScriptTagWithSrcWithoutProtocol() + public function testScriptTagWithSrcWithoutProtocol(): void { $target = ['src' => 'js/mystyles.js']; $expected = ''; $this->assertSame($expected, script_tag($target)); } - public function testScriptTagWithSrcAndAttributes() + public function testScriptTagWithSrcAndAttributes(): void { $target = ['src' => 'js/mystyles.js', 'charset' => 'UTF-8', 'defer' => '', 'async' => null]; $expected = ''; $this->assertSame($expected, script_tag($target)); } - public function testScriptTagWithCsp() + public function testScriptTagWithCsp(): void { // Reset CSP object $this->resetServices(); @@ -338,20 +338,20 @@ public function testScriptTagWithCsp() * This test has probably no real-world value but may help detecting * a change in the default behaviour. */ - public function testScriptTagWithoutAnyArg() + public function testScriptTagWithoutAnyArg(): void { $expected = ''; $this->assertSame($expected, script_tag()); } - public function testLinkTag() + public function testLinkTag(): void { $target = 'css/mystyles.css'; $expected = ''; $this->assertSame($expected, link_tag($target)); } - public function testLinkTagXHTML() + public function testLinkTagXHTML(): void { $doctypes = config('DocTypes'); $default = $doctypes->html5; @@ -365,7 +365,7 @@ public function testLinkTagXHTML() $doctypes->html5 = $default; } - public function testLinkTagMedia() + public function testLinkTagMedia(): void { $target = 'https://styles.com/css/mystyles.css'; $tag = link_tag($target, 'stylesheet', 'text/css', '', 'print'); @@ -374,7 +374,7 @@ public function testLinkTagMedia() $this->assertSame($expected, $tag); } - public function testLinkTagTitle() + public function testLinkTagTitle(): void { $tag = link_tag('default.css', 'stylesheet', 'text/css', 'Default Style'); @@ -382,7 +382,7 @@ public function testLinkTagTitle() $this->assertSame($expected, $tag); } - public function testLinkTagFavicon() + public function testLinkTagFavicon(): void { $tag = link_tag('favicon.ico', 'shortcut icon', 'image/ico'); @@ -390,7 +390,7 @@ public function testLinkTagFavicon() $this->assertSame($expected, $tag); } - public function testLinkTagRss() + public function testLinkTagRss(): void { $tag = link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed'); @@ -398,7 +398,7 @@ public function testLinkTagRss() $this->assertSame($expected, $tag); } - public function testLinkTagAlternate() + public function testLinkTagAlternate(): void { $tag = link_tag( 'http://sp.example.com/', @@ -412,7 +412,7 @@ public function testLinkTagAlternate() $this->assertSame($expected, $tag); } - public function testLinkTagArrayAlternate() + public function testLinkTagArrayAlternate(): void { $tag = link_tag([ 'href' => 'http://sp.example.com/', @@ -424,7 +424,7 @@ public function testLinkTagArrayAlternate() $this->assertSame($expected, $tag); } - public function testLinkTagCanonical() + public function testLinkTagCanonical(): void { $tag = link_tag('http://www.example.com/', 'canonical'); @@ -432,7 +432,7 @@ public function testLinkTagCanonical() $this->assertSame($expected, $tag); } - public function testLinkTagArray() + public function testLinkTagArray(): void { $parms = [ 'href' => 'css/mystyles.css', @@ -442,7 +442,7 @@ public function testLinkTagArray() $this->assertSame($expected, link_tag($parms)); } - public function testLinkTagArrayHreflang() + public function testLinkTagArrayHreflang(): void { $tag = link_tag([ 'href' => 'https://example.com/en', @@ -454,26 +454,26 @@ public function testLinkTagArrayHreflang() $this->assertSame($expected, $tag); } - public function testDocType() + public function testDocType(): void { $target = 'html4-strict'; $expected = ''; $this->assertSame($expected, doctype($target)); } - public function testDocTypeDefault() + public function testDocTypeDefault(): void { $expected = ''; $this->assertSame($expected, doctype()); } - public function testDocTypeInvalid() + public function testDocTypeInvalid(): void { $target = 'good-guess'; $this->assertEmpty(doctype($target)); } - public function testVideo() + public function testVideo(): void { $expected = <<<'EOH'