diff --git a/tests/SigningTestCase.php b/tests/SigningTestCase.php index ea8b8fc51f54802b1a2b0dbe7d35bba5bfc32f59..3c93d2714333f1febdd166e390396284ec147b61 100644 --- a/tests/SigningTestCase.php +++ b/tests/SigningTestCase.php @@ -177,7 +177,7 @@ NOWDOC; /** * @return array */ - public function getCertDirContent() + public function getCertDirContent(): array { return [ self::CA_PRIVATE_KEY => $this->ca_private_key, @@ -229,7 +229,7 @@ NOWDOC; * @param mixed|null $value * @return void */ - protected function clearInstance(Configuration $service, $className, $value = null) + protected function clearInstance(Configuration $service, string $className, $value = null): void { $reflectedClass = new ReflectionClass($className); $reflectedInstance = $reflectedClass->getProperty('instance'); diff --git a/tests/Utils/ClearStateTestCase.php b/tests/Utils/ClearStateTestCase.php index aeed53ab74a7aca6d5c7c122620de3f94b8db6a7..f6cb2f4cb8fda1b801aa1be729116d3def657772 100644 --- a/tests/Utils/ClearStateTestCase.php +++ b/tests/Utils/ClearStateTestCase.php @@ -52,7 +52,7 @@ class ClearStateTestCase extends TestCase * Clear any SSP global state to reduce spill over between tests. * @return void */ - public static function clearState() + public static function clearState(): void { self::$stateClearer->clearGlobals(); self::$stateClearer->clearSSPState(); diff --git a/tests/Utils/ExitTestException.php b/tests/Utils/ExitTestException.php index b319ca84d03c9811880943da19bff07fd2b83408..973b9d833b0d0d516590a84073f02cd1ec06bee3 100644 --- a/tests/Utils/ExitTestException.php +++ b/tests/Utils/ExitTestException.php @@ -27,7 +27,7 @@ class ExitTestException extends \Exception /** * @return array */ - public function getTestResult() + public function getTestResult(): array { return $this->testResult; } diff --git a/tests/Utils/ReduceSpillOverTest.php b/tests/Utils/ReduceSpillOverTest.php index dbbbf5da490d0adb0a3f0ff60d26c50eace51b07..d276f893ce0bda5f48e8600898dc4bf6b71642f8 100644 --- a/tests/Utils/ReduceSpillOverTest.php +++ b/tests/Utils/ReduceSpillOverTest.php @@ -14,7 +14,7 @@ class ReduceSpillOverTest extends ClearStateTestCase * Set some global state * @return void */ - public function testSetState() + public function testSetState(): void { $_SERVER['QUERY_STRING'] = 'a=b'; \SimpleSAML\Configuration::loadFromArray(['a' => 'b'], '[ARRAY]', 'simplesaml'); @@ -28,7 +28,7 @@ class ReduceSpillOverTest extends ClearStateTestCase * @return void * @throws \SimpleSAML\Error\ConfigurationError */ - public function testStateRemoved() + public function testStateRemoved(): void { $this->assertArrayNotHasKey('QUERY_STRING', $_SERVER); /** @var false $env */ diff --git a/tests/Utils/StateClearer.php b/tests/Utils/StateClearer.php index ed9ec5cce898537487f892fb9c3bf8e64c12a03a..ba453a4a2e8942bddaceeb7170a3a480de2a8223 100644 --- a/tests/Utils/StateClearer.php +++ b/tests/Utils/StateClearer.php @@ -36,7 +36,7 @@ class StateClearer /** * @return void */ - public function backupGlobals() + public function backupGlobals(): void { // Backup any state that is needed as part of processing, so we can restore it later. // TODO: phpunit's backupGlobals = false, yet we are trying to do a similar thing here. Is that an issue? @@ -56,7 +56,7 @@ class StateClearer * Clear any global state. * @return void */ - public function clearGlobals() + public function clearGlobals(): void { if (!empty($this->backups)) { $_COOKIE = $this->backups['$_COOKIE']; @@ -77,7 +77,7 @@ class StateClearer * Clear any SSP specific state, such as SSP enviormental variables or cached internals. * @return void */ - public function clearSSPState() + public function clearSSPState(): void { foreach ($this->clearableState as $var) { $var::clearInternalState(); diff --git a/tests/_autoload_modules.php b/tests/_autoload_modules.php index d70960f2650e67bbfe27552668de3bcf3d28ad8d..8da8c9eb6f6c0d8288da9ef0475d875162e32830 100644 --- a/tests/_autoload_modules.php +++ b/tests/_autoload_modules.php @@ -13,7 +13,7 @@ declare(strict_types=1); * @param string $className Name of the class. * @return void */ -function sspmodTestClassAutoloadPSR4($className) +function sspmodTestClassAutoloadPSR4(string $className): void { $elements = explode('\\', $className); if ($elements[0] === '') { diff --git a/tests/lib/SimpleSAML/Auth/SimpleTest.php b/tests/lib/SimpleSAML/Auth/SimpleTest.php index 3bdad09779e250ac3023f0ce292b735272e173e4..0d41f205223c14fd49d3f698875e5241154251f8 100644 --- a/tests/lib/SimpleSAML/Auth/SimpleTest.php +++ b/tests/lib/SimpleSAML/Auth/SimpleTest.php @@ -16,7 +16,7 @@ class SimpleTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * @test * @return void */ - public function testGetProcessedURL() + public function testGetProcessedURL(): void { $class = new \ReflectionClass(Auth\Simple::class); $method = $class->getMethod('getProcessedURL'); diff --git a/tests/lib/SimpleSAML/Auth/SourceTest.php b/tests/lib/SimpleSAML/Auth/SourceTest.php index c243c77b615615951940f3604fbe504bcd0ec050..0fa611cd2bcaf958820207b739f4bff9885e93a1 100644 --- a/tests/lib/SimpleSAML/Auth/SourceTest.php +++ b/tests/lib/SimpleSAML/Auth/SourceTest.php @@ -16,7 +16,7 @@ class SourceTest extends ClearStateTestCase /** * @return void */ - public function testParseAuthSource() + public function testParseAuthSource(): void { $class = new \ReflectionClass(\SimpleSAML\Auth\Source::class); $method = $class->getMethod('parseAuthSource'); diff --git a/tests/lib/SimpleSAML/Auth/StateTest.php b/tests/lib/SimpleSAML/Auth/StateTest.php index 3463fc2faa778b28b5bba99d6a433fba6fabefe0..dda7f439d24b4a0e933dabc8ac8720a2fec6cb38 100644 --- a/tests/lib/SimpleSAML/Auth/StateTest.php +++ b/tests/lib/SimpleSAML/Auth/StateTest.php @@ -15,7 +15,7 @@ class StateTest extends TestCase * Test the getPersistentAuthData() function. * @return void */ - public function testGetPersistentAuthData() + public function testGetPersistentAuthData(): void { $mandatory = [ 'Attributes' => [], diff --git a/tests/lib/SimpleSAML/ConfigurationTest.php b/tests/lib/SimpleSAML/ConfigurationTest.php index 6a7f36d75b7e3318f96982e8c36eb7f37f17d10b..c9577161c37a2e17a6274f69086822923197d583 100644 --- a/tests/lib/SimpleSAML/ConfigurationTest.php +++ b/tests/lib/SimpleSAML/ConfigurationTest.php @@ -16,7 +16,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getVersion() * @return void */ - public function testGetVersion() + public function testGetVersion(): void { $c = Configuration::getOptionalConfig(); $this->assertEquals($c->getVersion(), Configuration::VERSION); @@ -27,7 +27,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test that the default instance fails to load even if we previously loaded another instance. * @return void */ - public function testLoadDefaultInstance() + public function testLoadDefaultInstance(): void { $this->expectException(CriticalConfigurationError::class); Configuration::loadFromArray(['key' => 'value'], '', 'dummy'); @@ -40,7 +40,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * is loaded. * @return void */ - public function testCriticalConfigurationError() + public function testCriticalConfigurationError(): void { try { Configuration::getInstance(); @@ -61,7 +61,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getValue() * @return void */ - public function testGetValue() + public function testGetValue(): void { $c = Configuration::loadFromArray([ 'exists_true' => true, @@ -82,7 +82,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getValue(), REQUIRED_OPTION flag. * @return void */ - public function testGetValueRequired() + public function testGetValueRequired(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([]); @@ -94,7 +94,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::hasValue() * @return void */ - public function testHasValue() + public function testHasValue(): void { $c = Configuration::loadFromArray([ 'exists_true' => true, @@ -110,7 +110,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::hasValue() * @return void */ - public function testHasValueOneOf() + public function testHasValueOneOf(): void { $c = Configuration::loadFromArray([ 'exists_true' => true, @@ -131,7 +131,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getBasePath() * @return void */ - public function testGetBasePath() + public function testGetBasePath(): void { $c = Configuration::loadFromArray([]); $this->assertEquals($c->getBasePath(), '/simplesaml/'); @@ -190,7 +190,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::resolvePath() * @return void */ - public function testResolvePath() + public function testResolvePath(): void { $c = Configuration::loadFromArray([ 'basedir' => '/basedir/', @@ -212,7 +212,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getPathValue() * @return void */ - public function testGetPathValue() + public function testGetPathValue(): void { $c = Configuration::loadFromArray([ 'basedir' => '/basedir/', @@ -230,7 +230,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getBaseDir() * @return void */ - public function testGetBaseDir() + public function testGetBaseDir(): void { $c = Configuration::loadFromArray([]); $this->assertEquals($c->getBaseDir(), dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR); @@ -251,7 +251,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getBoolean() * @return void */ - public function testGetBoolean() + public function testGetBoolean(): void { $c = Configuration::loadFromArray([ 'true_opt' => true, @@ -267,7 +267,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getBoolean() missing option * @return void */ - public function testGetBooleanMissing() + public function testGetBooleanMissing(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([]); @@ -279,7 +279,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getBoolean() wrong option * @return void */ - public function testGetBooleanWrong() + public function testGetBooleanWrong(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([ @@ -293,7 +293,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getString() * @return void */ - public function testGetString() + public function testGetString(): void { $c = Configuration::loadFromArray([ 'str_opt' => 'Hello World!', @@ -307,7 +307,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getString() missing option * @return void */ - public function testGetStringMissing() + public function testGetStringMissing(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([]); @@ -319,7 +319,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getString() wrong option * @return void */ - public function testGetStringWrong() + public function testGetStringWrong(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([ @@ -333,7 +333,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getInteger() * @return void */ - public function testGetInteger() + public function testGetInteger(): void { $c = Configuration::loadFromArray([ 'int_opt' => 42, @@ -347,7 +347,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getInteger() missing option * @return void */ - public function testGetIntegerMissing() + public function testGetIntegerMissing(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([]); @@ -359,7 +359,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getInteger() wrong option * @return void */ - public function testGetIntegerWrong() + public function testGetIntegerWrong(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([ @@ -373,7 +373,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getIntegerRange() * @return void */ - public function testGetIntegerRange() + public function testGetIntegerRange(): void { $c = Configuration::loadFromArray([ 'int_opt' => 42, @@ -387,7 +387,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getIntegerRange() below limit * @return void */ - public function testGetIntegerRangeBelow() + public function testGetIntegerRangeBelow(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([ @@ -401,7 +401,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getIntegerRange() above limit * @return void */ - public function testGetIntegerRangeAbove() + public function testGetIntegerRangeAbove(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([ @@ -415,7 +415,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getValueValidate() * @return void */ - public function testGetValueValidate() + public function testGetValueValidate(): void { $c = Configuration::loadFromArray([ 'opt' => 'b', @@ -429,7 +429,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getValueValidate() wrong option * @return void */ - public function testGetValueValidateWrong() + public function testGetValueValidateWrong(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([ @@ -443,7 +443,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getArray() * @return void */ - public function testGetArray() + public function testGetArray(): void { $c = Configuration::loadFromArray([ 'opt' => ['a', 'b', 'c'], @@ -457,7 +457,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getArray() wrong option * @return void */ - public function testGetArrayWrong() + public function testGetArrayWrong(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([ @@ -471,7 +471,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getArrayize() * @return void */ - public function testGetArrayize() + public function testGetArrayize(): void { $c = Configuration::loadFromArray([ 'opt' => ['a', 'b', 'c'], @@ -489,7 +489,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getArrayizeString() * @return void */ - public function testGetArrayizeString() + public function testGetArrayizeString(): void { $c = Configuration::loadFromArray([ 'opt' => ['a', 'b', 'c'], @@ -506,7 +506,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * with an array that contains something that isn't a string. * @return void */ - public function testGetArrayizeStringWrongValue() + public function testGetArrayizeStringWrongValue(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([ @@ -520,7 +520,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getConfigItem() * @return void */ - public function testGetConfigItem() + public function testGetConfigItem(): void { $c = Configuration::loadFromArray([ 'opt' => ['a' => 42], @@ -538,7 +538,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getConfigItem() wrong option * @return void */ - public function testGetConfigItemWrong() + public function testGetConfigItemWrong(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([ @@ -606,7 +606,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getOptions() * @return void */ - public function testGetOptions() + public function testGetOptions(): void { $c = Configuration::loadFromArray([ 'a' => true, @@ -620,7 +620,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::toArray() * @return void */ - public function testToArray() + public function testToArray(): void { $c = Configuration::loadFromArray([ 'a' => true, @@ -636,7 +636,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Iterate over all different valid definitions of endpoints and check if the expected output is produced. * @return void */ - public function testGetDefaultEndpoint() + public function testGetDefaultEndpoint(): void { /* * First we run the full set of tests covering all possible configurations for indexed endpoint types, @@ -852,7 +852,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getEndpoints(). * @return void */ - public function testGetEndpoints() + public function testGetEndpoints(): void { // test response location for old-style configurations $c = Configuration::loadFromArray([ @@ -957,7 +957,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getLocalizedString() * @return void */ - public function testGetLocalizedString() + public function testGetLocalizedString(): void { $c = Configuration::loadFromArray([ 'str_opt' => 'Hello World!', @@ -976,7 +976,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getLocalizedString() not array nor simple string * @return void */ - public function testGetLocalizedStringNotArray() + public function testGetLocalizedStringNotArray(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([ @@ -990,7 +990,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getLocalizedString() not string key * @return void */ - public function testGetLocalizedStringNotStringKey() + public function testGetLocalizedStringNotStringKey(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([ @@ -1004,7 +1004,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getLocalizedString() not string value * @return void */ - public function testGetLocalizedStringNotStringValue() + public function testGetLocalizedStringNotStringValue(): void { $this->expectException(\Exception::class); $c = Configuration::loadFromArray([ @@ -1018,7 +1018,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getConfig() nonexistent file * @return void */ - public function testGetConfigNonexistentFile() + public function testGetConfigNonexistentFile(): void { $this->expectException(\Exception::class); Configuration::getConfig('nonexistent-nopreload.php'); @@ -1029,7 +1029,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getConfig() preloaded nonexistent file * @return void */ - public function testGetConfigNonexistentFilePreload() + public function testGetConfigNonexistentFilePreload(): void { $c = Configuration::loadFromArray([ 'key' => 'value' @@ -1047,7 +1047,7 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase * ATTENTION: this test must be kept the last. * @return void */ - public function testLoadInstanceFromArray() + public function testLoadInstanceFromArray(): void { $c = [ 'key' => 'value' diff --git a/tests/lib/SimpleSAML/DatabaseTest.php b/tests/lib/SimpleSAML/DatabaseTest.php index 47c253b60eb0d3ca3930d04f07e66ecdeb71aef0..0dc4fd16b44a3b1797e318e0c504491cd05d9264 100644 --- a/tests/lib/SimpleSAML/DatabaseTest.php +++ b/tests/lib/SimpleSAML/DatabaseTest.php @@ -87,7 +87,7 @@ class DatabaseTest extends TestCase * @test * @return void */ - public function connectionFailure() + public function connectionFailure(): void { $this->expectException(\Exception::class); $config = [ @@ -112,7 +112,7 @@ class DatabaseTest extends TestCase * @test * @return void */ - public function instances() + public function instances(): void { $config = [ 'database.dsn' => 'sqlite::memory:', @@ -182,7 +182,7 @@ class DatabaseTest extends TestCase * @test * @return void */ - public function slaves() + public function slaves(): void { $getSlave = self::getMethod('getSlave'); @@ -225,7 +225,7 @@ class DatabaseTest extends TestCase * @test * @return void */ - public function prefix() + public function prefix(): void { $prefix = $this->config->getString('database.prefix'); $table = "saml20_idp_hosted"; @@ -243,7 +243,7 @@ class DatabaseTest extends TestCase * @test * @return void */ - public function querying() + public function querying(): void { $table = $this->db->applyPrefix("sspdbt"); $this->assertEquals($this->config->getString('database.prefix') . "sspdbt", $table); @@ -277,7 +277,7 @@ class DatabaseTest extends TestCase * @test * @return void */ - public function readFailure() + public function readFailure(): void { $this->expectException(\Exception::class); $table = $this->db->applyPrefix("sspdbt"); @@ -293,7 +293,7 @@ class DatabaseTest extends TestCase * @test * @return void */ - public function noSuchTable() + public function noSuchTable(): void { $this->expectException(\Exception::class); $this->db->write("DROP TABLE phpunit_nonexistent"); diff --git a/tests/lib/SimpleSAML/Locale/LanguageTest.php b/tests/lib/SimpleSAML/Locale/LanguageTest.php index 03c978a04b4012e9aa46019257e2e4c07c88a6f2..677f95c6fafea4f7abf64113e723c337bd8458c5 100644 --- a/tests/lib/SimpleSAML/Locale/LanguageTest.php +++ b/tests/lib/SimpleSAML/Locale/LanguageTest.php @@ -14,7 +14,7 @@ class LanguageTest extends TestCase * Test SimpleSAML\Locale\Language::getDefaultLanguage(). * @return void */ - public function testGetDefaultLanguage() + public function testGetDefaultLanguage(): void { // test default $c = Configuration::loadFromArray([]); @@ -35,7 +35,7 @@ class LanguageTest extends TestCase * Test SimpleSAML\Locale\Language::getLanguageCookie(). * @return void */ - public function testGetLanguageCookie() + public function testGetLanguageCookie(): void { // test it works when no cookie is set Configuration::loadFromArray([], '', 'simplesaml'); @@ -60,7 +60,7 @@ class LanguageTest extends TestCase * Test SimpleSAML\Locale\Language::getLanguageList(). * @return void */ - public function testGetLanguageListNoConfig() + public function testGetLanguageListNoConfig(): void { // test default $c = Configuration::loadFromArray([], '', 'simplesaml'); @@ -74,7 +74,7 @@ class LanguageTest extends TestCase * Test SimpleSAML\Locale\Language::getLanguageList(). * @return void */ - public function testGetLanguageListCorrectConfig() + public function testGetLanguageListCorrectConfig(): void { // test langs from from language_names $c = Configuration::loadFromArray([ @@ -94,7 +94,7 @@ class LanguageTest extends TestCase * Test SimpleSAML\Locale\Language::getLanguageList(). * @return void */ - public function testGetLanguageListIncorrectConfig() + public function testGetLanguageListIncorrectConfig(): void { // test non-existent langs $c = Configuration::loadFromArray([ @@ -110,7 +110,7 @@ class LanguageTest extends TestCase * Test SimpleSAML\Locale\Language::getLanguageParameterName(). * @return void */ - public function testGetLanguageParameterName() + public function testGetLanguageParameterName(): void { // test for default configuration $c = Configuration::loadFromArray([], '', 'simplesaml'); @@ -130,7 +130,7 @@ class LanguageTest extends TestCase * Test SimpleSAML\Locale\Language::isLanguageRTL(). * @return void */ - public function testIsLanguageRTL() + public function testIsLanguageRTL(): void { // test defaults $c = Configuration::loadFromArray([], '', 'simplesaml'); @@ -161,7 +161,7 @@ class LanguageTest extends TestCase * Test SimpleSAML\Locale\Language::setLanguage(). * @return void */ - public function testSetLanguage() + public function testSetLanguage(): void { // test with valid configuration, no cookies set $c = Configuration::loadFromArray([ diff --git a/tests/lib/SimpleSAML/Locale/LocalizationTest.php b/tests/lib/SimpleSAML/Locale/LocalizationTest.php index 12b036eaeaf5b9ed29dbcde9ce03f8b57d6754d4..bf983d2bc07f1a2472630ea2a0b11c41f6115430 100644 --- a/tests/lib/SimpleSAML/Locale/LocalizationTest.php +++ b/tests/lib/SimpleSAML/Locale/LocalizationTest.php @@ -24,7 +24,7 @@ class LocalizationTest extends TestCase * Test SimpleSAML\Locale\Localization(). * @return void */ - public function testLocalization() + public function testLocalization(): void { // The constructor should activate the default domain $c = Configuration::loadFromArray( @@ -40,7 +40,7 @@ class LocalizationTest extends TestCase * Test SimpleSAML\Locale\Localization::activateDomain(). * @return void */ - public function testAddDomain() + public function testAddDomain(): void { $c = Configuration::loadFromArray( ['usenewui' => true] diff --git a/tests/lib/SimpleSAML/Locale/TranslateTest.php b/tests/lib/SimpleSAML/Locale/TranslateTest.php index 1e6cef3c3a5246fb2992bbe0a6e3d07d62ddd108..a617700423568e05016073ee97b14b320aec7803 100644 --- a/tests/lib/SimpleSAML/Locale/TranslateTest.php +++ b/tests/lib/SimpleSAML/Locale/TranslateTest.php @@ -13,7 +13,7 @@ class TranslateTest extends TestCase * Test SimpleSAML\Locale\Translate::noop(). * @return void */ - public function testNoop() + public function testNoop(): void { // test default $c = \SimpleSAML\Configuration::loadFromArray([]); diff --git a/tests/lib/SimpleSAML/Metadata/MetaDataStorageHandlerTest.php b/tests/lib/SimpleSAML/Metadata/MetaDataStorageHandlerTest.php index 47e837ce4cd76e7d3a6bcfa1e14beaba46416deb..9abc2a59b0e2eb5901ef1da0d073c94fd18d0c3e 100644 --- a/tests/lib/SimpleSAML/Metadata/MetaDataStorageHandlerTest.php +++ b/tests/lib/SimpleSAML/Metadata/MetaDataStorageHandlerTest.php @@ -14,7 +14,7 @@ class MetaDataStorageHandlerTest extends ClearStateTestCase * Test that loading specific entities works, and that metadata source precedence is followed * @return void */ - public function testLoadEntities() + public function testLoadEntities(): void { $c = [ 'metadata.sources' => [ diff --git a/tests/lib/SimpleSAML/Metadata/MetaDataStorageSourceTest.php b/tests/lib/SimpleSAML/Metadata/MetaDataStorageSourceTest.php index d7c39a3237b697aef4eb8e34bdac1638f72e02b7..75c8724cbf99773d0ad8d60e1cd7d2647e796230 100644 --- a/tests/lib/SimpleSAML/Metadata/MetaDataStorageSourceTest.php +++ b/tests/lib/SimpleSAML/Metadata/MetaDataStorageSourceTest.php @@ -16,7 +16,7 @@ class MetaDataStorageSourceTest extends \PHPUnit\Framework\TestCase * Test \SimpleSAML\Metadata\MetaDataStorageSourceTest::getConfig XML bad source * @return void */ - public function testBadXMLSource() + public function testBadXMLSource(): void { $this->expectException(\Exception::class); \SimpleSAML\Metadata\MetaDataStorageSource::getSource(["type" => "xml", "foo" => "baa"]); @@ -27,7 +27,7 @@ class MetaDataStorageSourceTest extends \PHPUnit\Framework\TestCase * Test \SimpleSAML\Metadata\MetaDataStorageSourceTest::getConfig invalid static XML source * @return void */ - public function testInvalidStaticXMLSource() + public function testInvalidStaticXMLSource(): void { $this->expectException(\Exception::class); $strTestXML = " @@ -42,7 +42,7 @@ class MetaDataStorageSourceTest extends \PHPUnit\Framework\TestCase * Test \SimpleSAML\Metadata\MetaDataStorageSourceTest::getConfig XML static XML source * @return void */ - public function testStaticXMLSource() + public function testStaticXMLSource(): void { $testEntityId = "https://saml.idp/entityid"; $strTestXML = self::generateIdpMetadataXml($testEntityId); @@ -66,7 +66,7 @@ class MetaDataStorageSourceTest extends \PHPUnit\Framework\TestCase * Test loading multiple entities * @return void */ - public function testLoadEntitiesStaticXMLSource() + public function testLoadEntitiesStaticXMLSource(): void { $c = [ 'key' => 'value' @@ -102,7 +102,7 @@ class MetaDataStorageSourceTest extends \PHPUnit\Framework\TestCase * @param string $entityId * @return string */ - public static function generateIdpMetadataXml($entityId) + public static function generateIdpMetadataXml(string $entityId): string { return " <EntityDescriptor ID=\"_12345678-90ab-cdef-1234-567890abcdef\" entityID=\"$entityId\" xmlns=\"urn:oasis:names:tc:SAML:2.0:metadata\"> diff --git a/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php b/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php index fe5e3fcb39f47f191119030055f5128ae9e47171..d3d4d25e286b232fd574881d4bf6d8091805c923 100644 --- a/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php +++ b/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php @@ -17,7 +17,7 @@ class SAMLBuilderTest extends TestCase * Test the requested attributes are valued correctly. * @return void */ - public function testAttributes() + public function testAttributes(): void { $entityId = 'https://entity.example.com/id'; @@ -167,7 +167,7 @@ class SAMLBuilderTest extends TestCase * Test the working of the isDefault config option * @return void */ - public function testAttributeConsumingServiceDefault() + public function testAttributeConsumingServiceDefault(): void { $entityId = 'https://entity.example.com/id'; $set = 'saml20-sp-remote'; @@ -223,7 +223,7 @@ class SAMLBuilderTest extends TestCase * Test the index option is used correctly. * @return void */ - public function testAttributeConsumingServiceIndex() + public function testAttributeConsumingServiceIndex(): void { $entityId = 'https://entity.example.com/id'; $set = 'saml20-sp-remote'; @@ -268,7 +268,7 @@ class SAMLBuilderTest extends TestCase * Test the required protocolSupportEnumeration in AttributeAuthorityDescriptor * @return void */ - public function testProtocolSupportEnumeration() + public function testProtocolSupportEnumeration(): void { $entityId = 'https://entity.example.com/id'; $set = 'attributeauthority-remote'; diff --git a/tests/lib/SimpleSAML/Metadata/SAMLParserTest.php b/tests/lib/SimpleSAML/Metadata/SAMLParserTest.php index b538cafde63581e50f86d1ae8bfc1375539c794f..919c88897e866a5e2b521cb70a4dd7db2b406589 100644 --- a/tests/lib/SimpleSAML/Metadata/SAMLParserTest.php +++ b/tests/lib/SimpleSAML/Metadata/SAMLParserTest.php @@ -18,7 +18,7 @@ class SAMLParserTest extends \SimpleSAML\Test\SigningTestCase * Test Registration Info is parsed * @return void */ - public function testRegistrationInfo() + public function testRegistrationInfo(): void { $expected = [ 'registrationAuthority' => 'https://incommon.org', @@ -52,7 +52,7 @@ XML * According to the spec overriding RegistrationInfo is not valid. We ignore attempts to override * @return void */ - public function testRegistrationInfoInheritance() + public function testRegistrationInfoInheritance(): void { $expected = [ 'registrationAuthority' => 'https://incommon.org', @@ -104,7 +104,7 @@ XML * Test AttributeConsumingService is parsed * @return void */ - public function testAttributeConsumingServiceParsing() + public function testAttributeConsumingServiceParsing(): void { $document = \SAML2\DOMDocumentFactory::fromString( <<<XML @@ -153,7 +153,7 @@ XML /** * @return \DOMDocument */ - public function makeTestDocument() + public function makeTestDocument(): \DOMDocument { $doc = new \DOMDocument(); $doc->loadXML( @@ -276,7 +276,7 @@ XML * Test RoleDescriptor/Extensions is parsed * @return void */ - public function testRoleDescriptorExtensions() + public function testRoleDescriptorExtensions(): void { $expected = [ 'scope' => [ diff --git a/tests/lib/SimpleSAML/ModuleTest.php b/tests/lib/SimpleSAML/ModuleTest.php index ae482b0bef9a135e8160bc8f4c9b89e83ec2db6e..b52e49f3f6ee4097d33b9333737bb84a54fe3dd3 100644 --- a/tests/lib/SimpleSAML/ModuleTest.php +++ b/tests/lib/SimpleSAML/ModuleTest.php @@ -13,7 +13,7 @@ class ModuleTest extends TestCase * Test for SimpleSAML\Module::isModuleEnabled(). * @return void */ - public function testIsModuleEnabled() + public function testIsModuleEnabled(): void { // test for the most basic functionality $this->assertTrue(Module::isModuleEnabled('core')); @@ -24,7 +24,7 @@ class ModuleTest extends TestCase * Test for SimpleSAML\Module::getModuleDir(). * @return void */ - public function testGetModuleDir() + public function testGetModuleDir(): void { // test for the most basic functionality $this->assertEquals( @@ -38,7 +38,7 @@ class ModuleTest extends TestCase * Test for SimpleSAML\Module::getModuleURL(). * @return void */ - public function testGetModuleURL() + public function testGetModuleURL(): void { \SimpleSAML\Configuration::loadFromArray([ 'baseurlpath' => 'https://example.com/simplesaml/' @@ -61,7 +61,7 @@ class ModuleTest extends TestCase * Test for SimpleSAML\Module::getModules(). * @return void */ - public function testGetModules() + public function testGetModules(): void { $this->assertGreaterThan(0, count(Module::getModules())); } @@ -73,7 +73,7 @@ class ModuleTest extends TestCase * class). * @return void */ - public function testResolveClassNoModule() + public function testResolveClassNoModule(): void { $this->expectException(\Exception::class); Module::resolveClass('nomodule', ''); @@ -85,7 +85,7 @@ class ModuleTest extends TestCase * asking for cannot be found. * @return void */ - public function testResolveClassNotFound() + public function testResolveClassNotFound(): void { $this->expectException(\Exception::class); Module::resolveClass('core:Missing', ''); @@ -97,7 +97,7 @@ class ModuleTest extends TestCase * asking for can be resolved, but does not extend a given class. * @return void */ - public function testResolveClassNotSubclass() + public function testResolveClassNotSubclass(): void { $this->expectException(\Exception::class); Module::resolveClass('core:PHP', 'Auth_Process', '\Exception'); @@ -108,7 +108,7 @@ class ModuleTest extends TestCase * Test for SimpleSAML\Module::resolveClass(). It covers all the valid use cases. * @return void */ - public function testResolveClass() + public function testResolveClass(): void { // most basic test $this->assertEquals('SimpleSAML\Module\cron\Cron', Module::resolveClass('cron:Cron', '')); diff --git a/tests/lib/SimpleSAML/SessionHandlerPHPTest.php b/tests/lib/SimpleSAML/SessionHandlerPHPTest.php index c0b71a489ee7923d407736bf781fd20369837bfe..21bde126cb2f32a46886f06f6c9b9d48faeb4db4 100644 --- a/tests/lib/SimpleSAML/SessionHandlerPHPTest.php +++ b/tests/lib/SimpleSAML/SessionHandlerPHPTest.php @@ -54,7 +54,7 @@ class SessionHandlerPHPTest extends ClearStateTestCase * @covers SimpleSAML\SessionHandler::getSessionHandler() * @return void */ - public function testGetSessionHandler() + public function testGetSessionHandler(): void { Configuration::loadFromArray($this->sessionConfig, '[ARRAY]', 'simplesaml'); $sh = SessionHandlerPHP::getSessionHandler(); @@ -68,7 +68,7 @@ class SessionHandlerPHPTest extends ClearStateTestCase * @requires extension xdebug * @return void */ - public function testSetCookie() + public function testSetCookie(): void { Configuration::loadFromArray($this->sessionConfig, '[ARRAY]', 'simplesaml'); $sh = SessionHandlerPHP::getSessionHandler(); @@ -90,7 +90,7 @@ class SessionHandlerPHPTest extends ClearStateTestCase * @requires extension xdebug * @return void */ - public function testSetCookieSameSiteNone() + public function testSetCookieSameSiteNone(): void { Configuration::loadFromArray( array_merge($this->sessionConfig, ['session.cookie.samesite' => 'None']), @@ -112,7 +112,7 @@ class SessionHandlerPHPTest extends ClearStateTestCase * @requires extension xdebug * @return void */ - public function testSetCookieSameSiteLax() + public function testSetCookieSameSiteLax(): void { Configuration::loadFromArray( array_merge($this->sessionConfig, ['session.cookie.samesite' => 'Lax']), @@ -134,7 +134,7 @@ class SessionHandlerPHPTest extends ClearStateTestCase * @requires extension xdebug * @return void */ - public function testSetCookieSameSiteStrict() + public function testSetCookieSameSiteStrict(): void { Configuration::loadFromArray( array_merge($this->sessionConfig, ['session.cookie.samesite' => 'Strict']), @@ -156,7 +156,7 @@ class SessionHandlerPHPTest extends ClearStateTestCase * @requires extension xdebug * @return void */ - public function testRestorePrevious() + public function testRestorePrevious(): void { session_name('PHPSESSID'); $sid = session_id(); @@ -180,7 +180,7 @@ class SessionHandlerPHPTest extends ClearStateTestCase * @covers SimpleSAML\SessionHandlerPHP::newSessionId() * @return void */ - public function testNewSessionId() + public function testNewSessionId(): void { Configuration::loadFromArray($this->sessionConfig, '[ARRAY]', 'simplesaml'); $sh = SessionHandlerPHP::getSessionHandler(); diff --git a/tests/lib/SimpleSAML/Store/RedisTest.php b/tests/lib/SimpleSAML/Store/RedisTest.php index 46811c186743f76940a198be1e4b68eb82db8a6e..dd748b2f666f9b24bdae53b6245d9690ec359c00 100644 --- a/tests/lib/SimpleSAML/Store/RedisTest.php +++ b/tests/lib/SimpleSAML/Store/RedisTest.php @@ -73,9 +73,9 @@ class RedisTest extends TestCase /** * @param string $key - * @return \Predis\Client|null + * @return string|null */ - public function getMocked(string $key) + public function getMocked(string $key): ?string { return array_key_exists($key, $this->config) ? $this->config[$key] : null; } @@ -86,7 +86,7 @@ class RedisTest extends TestCase * @param mixed $value * @return void */ - public function setMocked($key, $value) + public function setMocked(string $key, $value): void { $this->config[$key] = $value; } @@ -98,7 +98,7 @@ class RedisTest extends TestCase * @param mixed $value * @return void */ - public function setexMocked($key, $expire, $value) + public function setexMocked(string $key, int $expire, $value): void { // Testing expiring data is more trouble than it's worth for now $this->setMocked($key, $value); @@ -109,7 +109,7 @@ class RedisTest extends TestCase * @param string $key * @return void */ - public function delMocked($key) + public function delMocked(string $key): void { unset($this->config[$key]); } @@ -121,7 +121,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testRedisInstance() + public function testRedisInstance(): void { $config = Configuration::loadFromArray([ 'store.type' => 'redis', @@ -144,7 +144,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testRedisInstanceWithPassword() + public function testRedisInstanceWithPassword(): void { $config = Configuration::loadFromArray([ 'store.type' => 'redis', @@ -168,7 +168,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testInsertData() + public function testInsertData(): void { $value = 'TEST'; @@ -186,7 +186,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testInsertExpiringData() + public function testInsertExpiringData(): void { $value = 'TEST'; @@ -203,7 +203,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testGetEmptyData() + public function testGetEmptyData(): void { $res = $this->redis->get('test', 'key'); @@ -217,7 +217,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testOverwriteData() + public function testOverwriteData(): void { $value1 = 'TEST1'; $value2 = 'TEST2'; @@ -238,7 +238,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testDeleteData() + public function testDeleteData(): void { $this->redis->set('test', 'key', 'TEST'); $this->redis->delete('test', 'key'); @@ -253,7 +253,7 @@ class RedisTest extends TestCase * @param class-string $className * @return void */ - protected function clearInstance($service, $className) + protected function clearInstance($service, string $className): void { $reflectedClass = new ReflectionClass($className); $reflectedInstance = $reflectedClass->getProperty('instance'); diff --git a/tests/lib/SimpleSAML/Store/SQLTest.php b/tests/lib/SimpleSAML/Store/SQLTest.php index a2ebb848e540f7136132e59d28ca0f4ebadfa4dc..f38fa70b218aae3a7e47302f1de85514a1890665 100644 --- a/tests/lib/SimpleSAML/Store/SQLTest.php +++ b/tests/lib/SimpleSAML/Store/SQLTest.php @@ -39,7 +39,7 @@ class SQLTest extends TestCase * @test * @return void */ - public function SQLInstance() + public function SQLInstance(): void { $store = Store::getInstance(); @@ -53,7 +53,7 @@ class SQLTest extends TestCase * @test * @return void */ - public function kvstoreTableVersion() + public function kvstoreTableVersion(): void { /** @var \SimpleSAML\Store\SQL $store */ $store = Store::getInstance(); @@ -69,7 +69,7 @@ class SQLTest extends TestCase * @test * @return void */ - public function newTableVersion() + public function newTableVersion(): void { /** @var \SimpleSAML\Store\SQL $store */ $store = Store::getInstance(); @@ -86,7 +86,7 @@ class SQLTest extends TestCase * @test * @return void */ - public function testSetTableVersion() + public function testSetTableVersion(): void { /** @var \SimpleSAML\Store\SQL $store */ $store = Store::getInstance(); @@ -103,7 +103,7 @@ class SQLTest extends TestCase * @test * @return void */ - public function testGetEmptyData() + public function testGetEmptyData(): void { /** @var \SimpleSAML\Store\SQL $store */ $store = Store::getInstance(); @@ -121,7 +121,7 @@ class SQLTest extends TestCase * @test * @return void */ - public function testInsertData() + public function testInsertData(): void { /** @var \SimpleSAML\Store\SQL $store */ $store = Store::getInstance(); @@ -140,7 +140,7 @@ class SQLTest extends TestCase * @test * @return void */ - public function testOverwriteData() + public function testOverwriteData(): void { /** @var \SimpleSAML\Store\SQL $store */ $store = Store::getInstance(); @@ -161,7 +161,7 @@ class SQLTest extends TestCase * @test * @return void */ - public function testDeleteData() + public function testDeleteData(): void { /** @var \SimpleSAML\Store\SQL $store */ $store = Store::getInstance(); @@ -182,7 +182,7 @@ class SQLTest extends TestCase * @test * @return void */ - public function testVeryLongKey() + public function testVeryLongKey(): void { /** @var \SimpleSAML\Store\SQL $store */ $store = Store::getInstance(); @@ -216,7 +216,7 @@ class SQLTest extends TestCase * @param class-string $className * @return void */ - protected function clearInstance($service, $className) + protected function clearInstance($service, string $className): void { $reflectedClass = new ReflectionClass($className); $reflectedInstance = $reflectedClass->getProperty('instance'); diff --git a/tests/lib/SimpleSAML/StoreTest.php b/tests/lib/SimpleSAML/StoreTest.php index 672b4b20536583490cc6f51af65661dc663b0ad5..3b6922ed2c9cf244dc25eae0c5f683fd097d195d 100644 --- a/tests/lib/SimpleSAML/StoreTest.php +++ b/tests/lib/SimpleSAML/StoreTest.php @@ -26,7 +26,7 @@ class StoreTest extends TestCase * @test * @return void */ - public function defaultStore() + public function defaultStore(): void { Configuration::loadFromArray([], '[ARRAY]', 'simplesaml'); @@ -42,7 +42,7 @@ class StoreTest extends TestCase * @test * @return void */ - public function phpSessionStore() + public function phpSessionStore(): void { Configuration::loadFromArray([], '[ARRAY]', 'simplesaml'); @@ -58,7 +58,7 @@ class StoreTest extends TestCase * @test * @return void */ - public function memcacheStore() + public function memcacheStore(): void { Configuration::loadFromArray([ 'store.type' => 'memcache', @@ -75,7 +75,7 @@ class StoreTest extends TestCase * @test * @return void */ - public function sqlStore() + public function sqlStore(): void { Configuration::loadFromArray([ 'store.type' => 'sql', @@ -94,7 +94,7 @@ class StoreTest extends TestCase * @test * @return void */ - public function pathStore() + public function pathStore(): void { Configuration::loadFromArray([ 'store.type' => '\SimpleSAML\Store\SQL', @@ -113,7 +113,7 @@ class StoreTest extends TestCase * @test * @return void */ - public function notFoundStoreException() + public function notFoundStoreException(): void { $this->expectException(CriticalConfigurationError::class); Configuration::loadFromArray([ @@ -145,7 +145,7 @@ class StoreTest extends TestCase * @param class-string $className * @return void */ - protected function clearInstance($service, $className) + protected function clearInstance($service, string $className): void { $reflectedClass = new ReflectionClass($className); $reflectedInstance = $reflectedClass->getProperty('instance'); diff --git a/tests/lib/SimpleSAML/Utils/ArraysTest.php b/tests/lib/SimpleSAML/Utils/ArraysTest.php index 8bfe6bccc960166f284ff71c3bfd63972dae8504..fcfa2eca7a58d983c79f59a9c02bc3225cb465d0 100644 --- a/tests/lib/SimpleSAML/Utils/ArraysTest.php +++ b/tests/lib/SimpleSAML/Utils/ArraysTest.php @@ -16,7 +16,7 @@ class ArraysTest extends TestCase * Test the arrayize() function. * @return void */ - public function testArrayize() + public function testArrayize(): void { // check with empty array as input $array = []; @@ -44,7 +44,7 @@ class ArraysTest extends TestCase * Test the transpose() function. * @return void */ - public function testTranspose() + public function testTranspose(): void { // check not array /** @psalm-suppress InvalidArgument Can be removed as soon as the codebase is fully typehinted */ diff --git a/tests/lib/SimpleSAML/Utils/AttributesTest.php b/tests/lib/SimpleSAML/Utils/AttributesTest.php index 42ae15c35789ab3c12a12e7e15b881b86c5e9c22..d70a47fded738d8c28d9c3b473204d528ed96451 100644 --- a/tests/lib/SimpleSAML/Utils/AttributesTest.php +++ b/tests/lib/SimpleSAML/Utils/AttributesTest.php @@ -57,7 +57,7 @@ class AttributesTest extends TestCase * Test the getExpectedAttributeMethod() method with a non-normalized attributes array. * @return void */ - public function testGetExpectedAttributeNonNormalizedArray() + public function testGetExpectedAttributeNonNormalizedArray(): void { // check with non-normalized attributes array $attributes = [ @@ -76,7 +76,7 @@ class AttributesTest extends TestCase * Test the getExpectedAttribute() method with valid input but missing expected attribute. * @return void */ - public function testGetExpectedAttributeMissingAttribute() + public function testGetExpectedAttributeMissingAttribute(): void { // check missing attribute $attributes = [ @@ -93,7 +93,7 @@ class AttributesTest extends TestCase * Test the getExpectedAttribute() method with an empty attribute. * @return void */ - public function testGetExpectedAttributeEmptyAttribute() + public function testGetExpectedAttributeEmptyAttribute(): void { // check empty attribute $attributes = [ @@ -110,7 +110,7 @@ class AttributesTest extends TestCase * Test the getExpectedAttributeMethod() method with multiple values (not being allowed). * @return void */ - public function testGetExpectedAttributeMultipleValues() + public function testGetExpectedAttributeMultipleValues(): void { // check attribute with more than value, that being not allowed $attributes = [ @@ -132,7 +132,7 @@ class AttributesTest extends TestCase * Test that the getExpectedAttribute() method successfully obtains values from the attributes array. * @return void */ - public function testGetExpectedAttribute() + public function testGetExpectedAttribute(): void { // check one value $value = 'value'; @@ -169,7 +169,7 @@ class AttributesTest extends TestCase * Test the normalizeAttributesArray() function with an array with non-string attribute names. * @return void */ - public function testNormalizeAttributesArrayBadKeys() + public function testNormalizeAttributesArrayBadKeys(): void { $this->expectException(InvalidArgumentException::class); Attributes::normalizeAttributesArray(['attr1' => 'value1', 1 => 'value2']); @@ -180,7 +180,7 @@ class AttributesTest extends TestCase * Test the normalizeAttributesArray() function with an array with non-string attribute values. * @return void */ - public function testNormalizeAttributesArrayBadValues() + public function testNormalizeAttributesArrayBadValues(): void { $this->expectException(InvalidArgumentException::class); Attributes::normalizeAttributesArray(['attr1' => 'value1', 'attr2' => 0]); @@ -191,7 +191,7 @@ class AttributesTest extends TestCase * Test the normalizeAttributesArray() function. * @return void */ - public function testNormalizeAttributesArray() + public function testNormalizeAttributesArray(): void { $attributes = [ 'key1' => 'value1', @@ -215,7 +215,7 @@ class AttributesTest extends TestCase * Test the getAttributeNamespace() function. * @return void */ - public function testNamespacedAttributes() + public function testNamespacedAttributes(): void { // test for only the name $this->assertEquals( diff --git a/tests/lib/SimpleSAML/Utils/Config/MetadataTest.php b/tests/lib/SimpleSAML/Utils/Config/MetadataTest.php index d5ef54e2ff99b5e3e894e03cf57dfa2786b57c26..bac7d0b9d7be96fddd52e37537fe5753188d1c7a 100644 --- a/tests/lib/SimpleSAML/Utils/Config/MetadataTest.php +++ b/tests/lib/SimpleSAML/Utils/Config/MetadataTest.php @@ -18,7 +18,7 @@ class MetadataTest extends TestCase * Test contact configuration parsing and sanitizing. * @return void */ - public function testGetContact() + public function testGetContact(): void { // test invalid argument try { @@ -234,7 +234,7 @@ class MetadataTest extends TestCase * Test \SimpleSAML\Utils\Config\Metadata::isHiddenFromDiscovery(). * @return void */ - public function testIsHiddenFromDiscovery() + public function testIsHiddenFromDiscovery(): void { // test for success $metadata = [ @@ -275,7 +275,7 @@ class MetadataTest extends TestCase * Test \SimpleSAML\Utils\Config\Metadata::parseNameIdPolicy(). * @return void */ - public function testParseNameIdPolicy() + public function testParseNameIdPolicy(): void { // Test null or unset $nameIdPolicy = null; diff --git a/tests/lib/SimpleSAML/Utils/ConfigTest.php b/tests/lib/SimpleSAML/Utils/ConfigTest.php index ae9660548099b9091ce1a99caf34af1c9e0200f4..bc7585a27c72c709f63ba87c08b254dcd4a33da2 100644 --- a/tests/lib/SimpleSAML/Utils/ConfigTest.php +++ b/tests/lib/SimpleSAML/Utils/ConfigTest.php @@ -17,7 +17,7 @@ class ConfigTest extends TestCase * Test default config dir with not environment variable * @return void */ - public function testDefaultConfigDir() + public function testDefaultConfigDir(): void { // clear env var putenv('SIMPLESAMLPHP_CONFIG_DIR'); @@ -31,7 +31,7 @@ class ConfigTest extends TestCase * Test valid dir specified by env var overrides default config dir * @return void */ - public function testEnvVariableConfigDir() + public function testEnvVariableConfigDir(): void { putenv('SIMPLESAMLPHP_CONFIG_DIR=' . __DIR__); $configDir = Config::getConfigDir(); @@ -43,7 +43,7 @@ class ConfigTest extends TestCase * Test valid dir specified by env redirect var overrides default config dir * @return void */ - public function testEnvRedirectVariableConfigDir() + public function testEnvRedirectVariableConfigDir(): void { putenv('REDIRECT_SIMPLESAMLPHP_CONFIG_DIR=' . __DIR__); $configDir = Config::getConfigDir(); @@ -56,7 +56,7 @@ class ConfigTest extends TestCase * Test which directory takes precedence * @return void */ - public function testEnvRedirectPriorityVariableConfigDir() + public function testEnvRedirectPriorityVariableConfigDir(): void { putenv('SIMPLESAMLPHP_CONFIG_DIR=' . dirname(__DIR__)); putenv('REDIRECT_SIMPLESAMLPHP_CONFIG_DIR=' . __DIR__); @@ -70,7 +70,7 @@ class ConfigTest extends TestCase * Test invalid dir specified by env var results in a thrown exception * @return void */ - public function testInvalidEnvVariableConfigDirThrowsException() + public function testInvalidEnvVariableConfigDirThrowsException(): void { // I used a random hash to ensure this test directory is always invalid $invalidDir = __DIR__ . '/e9826ad19cbc4f5bf20c0913ffcd2ce6'; diff --git a/tests/lib/SimpleSAML/Utils/CryptoTest.php b/tests/lib/SimpleSAML/Utils/CryptoTest.php index 8cd12bdc0ca24c73fcc252603dfbd8f4c9032049..f68f22f7fe3c30c0f4f465fe912133fb41a03546 100644 --- a/tests/lib/SimpleSAML/Utils/CryptoTest.php +++ b/tests/lib/SimpleSAML/Utils/CryptoTest.php @@ -52,7 +52,7 @@ class CryptoTest extends TestCase * @covers \SimpleSAML\Utils\Crypto::aesDecrypt * @return void */ - public function testAesDecrypt() + public function testAesDecrypt(): void { if (!extension_loaded('openssl')) { $this->expectException(\SimpleSAML\Error\Exception::class); @@ -76,7 +76,7 @@ class CryptoTest extends TestCase * @covers \SimpleSAML\Utils\Crypto::aesEncrypt * @return void */ - public function testAesEncrypt() + public function testAesEncrypt(): void { if (!extension_loaded('openssl')) { $this->expectException(\SimpleSAML\Error\Exception::class); @@ -102,7 +102,7 @@ class CryptoTest extends TestCase * @covers \SimpleSAML\Utils\Crypto::pem2der * @return void */ - public function testFormatConversion() + public function testFormatConversion(): void { $pem = <<<PHP -----BEGIN CERTIFICATE----- @@ -149,7 +149,7 @@ PHP; * @deprecated To be removed for 2.0 * @return void */ - public function testGoodPwHash() + public function testGoodPwHash(): void { $pw = "password"; $algorithm = "SHA1"; @@ -171,7 +171,7 @@ PHP; * @deprecated To be removed for 2.0 * @return void */ - public function testGoodSaltedPwHash() + public function testGoodSaltedPwHash(): void { $pw = "password"; $algorithm = "SSHA1"; @@ -195,7 +195,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::pwHash * @return void */ - public function testBadHashAlgorithm() + public function testBadHashAlgorithm(): void { $this->expectException(\SimpleSAML\Error\Exception::class); $pw = "password"; @@ -209,7 +209,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::pwValid * @return void */ - public function testGoodPwValid() + public function testGoodPwValid(): void { $pw = "password"; @@ -224,7 +224,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::pwValid * @return void */ - public function testBadPwInvalid() + public function testBadPwInvalid(): void { $pw = "password"; $pw2 = "password2"; @@ -291,7 +291,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::secureCompare * @return void */ - public function testSecureCompareEqual() + public function testSecureCompareEqual(): void { $res = Crypto::secureCompare("string", "string"); @@ -303,7 +303,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::secureCompare * @return void */ - public function testSecureCompareNotEqual() + public function testSecureCompareNotEqual(): void { $res = Crypto::secureCompare("string1", "string2"); @@ -315,7 +315,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPrivateKey * @return void */ - public function testLoadPrivateKeyRequiredMetadataMissing() + public function testLoadPrivateKeyRequiredMetadataMissing(): void { $this->expectException(\SimpleSAML\Error\Exception::class); $config = new Configuration([], 'test'); @@ -329,7 +329,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPrivateKey * @return void */ - public function testLoadPrivateKeyNotRequiredMetadataMissing() + public function testLoadPrivateKeyNotRequiredMetadataMissing(): void { $config = new Configuration([], 'test'); $required = false; @@ -344,7 +344,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPrivateKey * @return void */ - public function testLoadPrivateKeyMissingFile() + public function testLoadPrivateKeyMissingFile(): void { $this->expectException(\SimpleSAML\Error\Exception::class); $config = new Configuration(['privatekey' => 'nonexistant'], 'test'); @@ -357,7 +357,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPrivateKey * @return void */ - public function testLoadPrivateKeyBasic() + public function testLoadPrivateKeyBasic(): void { $filename = $this->certdir . DIRECTORY_SEPARATOR . 'key'; $data = 'data'; @@ -377,7 +377,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPrivateKey * @return void */ - public function testLoadPrivateKeyPassword() + public function testLoadPrivateKeyPassword(): void { $password = 'password'; $filename = $this->certdir . DIRECTORY_SEPARATOR . 'key'; @@ -404,7 +404,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPrivateKey * @return void */ - public function testLoadPrivateKeyPrefix() + public function testLoadPrivateKeyPrefix(): void { $prefix = 'prefix'; $password = 'password'; @@ -432,7 +432,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPublicKey * @return void */ - public function testLoadPublicKeyRequiredMetadataMissing() + public function testLoadPublicKeyRequiredMetadataMissing(): void { $this->expectException(\SimpleSAML\Error\Exception::class); $config = new Configuration([], 'test'); @@ -446,7 +446,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPublicKey * @return void */ - public function testLoadPublicKeyNotRequiredMetadataMissing() + public function testLoadPublicKeyNotRequiredMetadataMissing(): void { $config = new Configuration([], 'test'); $required = false; @@ -534,7 +534,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPublicKey * @return void */ - public function testLoadPublicKeyNotX509Certificate() + public function testLoadPublicKeyNotX509Certificate(): void { $config = new Configuration( [ @@ -559,7 +559,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPublicKey * @return void */ - public function testLoadPublicKeyNotSigning() + public function testLoadPublicKeyNotSigning(): void { $config = new Configuration( [ @@ -584,7 +584,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPublicKey * @return void */ - public function testLoadPublicKeyBasic() + public function testLoadPublicKeyBasic(): void { $x509certificate = 'x509certificate'; $config = new Configuration( diff --git a/tests/lib/SimpleSAML/Utils/EMailTest.php b/tests/lib/SimpleSAML/Utils/EMailTest.php index a7762655a7ab828a831401785c789074133b17d1..94f4c8497d1e63219a163a3b01db72001403c7a8 100644 --- a/tests/lib/SimpleSAML/Utils/EMailTest.php +++ b/tests/lib/SimpleSAML/Utils/EMailTest.php @@ -32,7 +32,7 @@ class EMailTest extends ClearStateTestCase * and no custom from address is specified. * @return void */ - public function testMailFromDefaultConfigurationException() + public function testMailFromDefaultConfigurationException(): void { $this->expectException(\Exception::class); new EMail('test', null, 'phpunit@simplesamlphp.org'); @@ -43,7 +43,7 @@ class EMailTest extends ClearStateTestCase * Test that an exception is thrown if using an invalid "From"-address * @return void */ - public function testInvalidFromAddressException() + public function testInvalidFromAddressException(): void { $this->expectException(\Exception::class); new EMail('test', "phpunit@simplesamlphp.org\nLorem Ipsum", 'phpunit@simplesamlphp.org'); @@ -54,7 +54,7 @@ class EMailTest extends ClearStateTestCase * Test that an exception is thrown if using an invalid "To"-address * @return void */ - public function testInvalidToAddressException() + public function testInvalidToAddressException(): void { $this->expectException(\Exception::class); new EMail('test', 'phpunit@simplesamlphp.org', "phpunit@simplesamlphp.org\nLorem Ipsum"); @@ -67,7 +67,7 @@ class EMailTest extends ClearStateTestCase * @param string $template * @return void */ - public function testMailContents($template) + public function testMailContents($template): void { $mail = new EMail( 'subject-subject-subject-subject-subject-subject-subject', @@ -88,7 +88,7 @@ class EMailTest extends ClearStateTestCase * All templates that should be tested in #testMailContents($template) * @return array */ - public static function mailTemplates() + public static function mailTemplates(): array { return [['mailtxt.twig'], ['mailhtml.twig']]; } @@ -97,7 +97,7 @@ class EMailTest extends ClearStateTestCase /** * @return void */ - public function testInvalidTransportConfiguration() + public function testInvalidTransportConfiguration(): void { // preserve the original configuration $originalTestConfiguration = Configuration::getInstance()->toArray(); @@ -119,7 +119,7 @@ class EMailTest extends ClearStateTestCase /** * @return void */ - public function testInvalidSMTPConfiguration() + public function testInvalidSMTPConfiguration(): void { // setup a new email $email = new Email('Test', 'phpunit@simplesamlphp.org', 'phpunit@simplesamlphp.org'); @@ -136,7 +136,7 @@ class EMailTest extends ClearStateTestCase * * @return void */ - public function testGetDefaultMailAddress() + public function testGetDefaultMailAddress(): void { Configuration::loadFromArray([ 'technicalcontact_email' => 'gamaarna@example.org', diff --git a/tests/lib/SimpleSAML/Utils/HTTPTest.php b/tests/lib/SimpleSAML/Utils/HTTPTest.php index 6c1f31307df216b6c39bb225324248ba473bd4de..7e9552ff765d3046850328a2635380c05e715b57 100644 --- a/tests/lib/SimpleSAML/Utils/HTTPTest.php +++ b/tests/lib/SimpleSAML/Utils/HTTPTest.php @@ -18,7 +18,7 @@ class HTTPTest extends ClearStateTestCase * @param string $url The URL to use as the current one. * @return void */ - private function setupEnvFromURL(string $url) + private function setupEnvFromURL(string $url): void { $scheme = parse_url($url, PHP_URL_SCHEME); $host = parse_url($url, PHP_URL_HOST); @@ -73,7 +73,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::addURLParameters(). * @return void */ - public function testAddURLParameters() + public function testAddURLParameters(): void { $url = 'http://example.com/'; $params = [ @@ -101,7 +101,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::guessBasePath(). * @return void */ - public function testGuessBasePath() + public function testGuessBasePath(): void { $original = $_SERVER; @@ -145,7 +145,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::getSelfHost() with and without custom port. * @return void */ - public function testGetSelfHost() + public function testGetSelfHost(): void { $original = $_SERVER; @@ -165,7 +165,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::getSelfHostWithPort(), with and without custom port. * @return void */ - public function testGetSelfHostWithPort() + public function testGetSelfHostWithPort(): void { $original = $_SERVER; @@ -194,7 +194,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::getSelfURL(). * @return void */ - public function testGetSelfURLMethods() + public function testGetSelfURLMethods(): void { $original = $_SERVER; @@ -321,7 +321,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::checkURLAllowed(), without regex. * @return void */ - public function testCheckURLAllowedWithoutRegex() + public function testCheckURLAllowedWithoutRegex(): void { $original = $_SERVER; @@ -353,7 +353,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::checkURLAllowed(), with regex. * @return void */ - public function testCheckURLAllowedWithRegex() + public function testCheckURLAllowedWithRegex(): void { $original = $_SERVER; @@ -387,7 +387,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::getServerPort(). * @return void */ - public function testGetServerPort() + public function testGetServerPort(): void { $original = $_SERVER; @@ -434,7 +434,7 @@ class HTTPTest extends ClearStateTestCase * subdomain of an evil domain. * @return void */ - public function testCheckURLAllowedWithRegexWithoutDelimiters() + public function testCheckURLAllowedWithRegexWithoutDelimiters(): void { $original = $_SERVER; @@ -456,7 +456,7 @@ class HTTPTest extends ClearStateTestCase * @covers SimpleSAML\Utils\HTTP::getFirstPathElement() * @return void */ - public function testGetFirstPathElement() + public function testGetFirstPathElement(): void { $original = $_SERVER; $_SERVER['SCRIPT_NAME'] = '/test/tmp.php'; @@ -465,13 +465,14 @@ class HTTPTest extends ClearStateTestCase $_SERVER = $original; } + /** * @covers SimpleSAML\Utils\HTTP::setCookie() * @runInSeparateProcess * @requires extension xdebug * @return void */ - public function testSetCookie() + public function testSetCookie(): void { $original = $_SERVER; Configuration::loadFromArray([ @@ -522,11 +523,12 @@ class HTTPTest extends ClearStateTestCase $_SERVER = $original; } + /** * @covers SimpleSAML\Utils\HTTP::setCookie() * @return void */ - public function testSetCookieInsecure() + public function testSetCookieInsecure(): void { $this->expectException(\SimpleSAML\Error\CannotSetCookie::class); @@ -542,13 +544,14 @@ class HTTPTest extends ClearStateTestCase $_SERVER = $original; } + /** * @covers SimpleSAML\Utils\HTTP::setCookie() * @runInSeparateProcess * @requires extension xdebug * @return void */ - public function testSetCookieSameSite() + public function testSetCookieSameSite(): void { HTTP::setCookie('SSNull', 'value', ['samesite' => null]); HTTP::setCookie('SSNone', 'value', ['samesite' => 'None']); diff --git a/tests/lib/SimpleSAML/Utils/NetTest.php b/tests/lib/SimpleSAML/Utils/NetTest.php index 06f1b960e8bc239474b947bf2c32167c598d0aaf..fcacbc18f524df21209da10e3bea8f6442cb4208 100644 --- a/tests/lib/SimpleSAML/Utils/NetTest.php +++ b/tests/lib/SimpleSAML/Utils/NetTest.php @@ -18,7 +18,7 @@ class NetTest extends TestCase * @covers SimpleSAML\Utils\Net::ipCIDRcheck * @return void */ - public function testIpCIDRcheck() + public function testIpCIDRcheck(): void { // check CIDR w/o mask $this->assertFalse(Net::ipCIDRcheck('127.0.0.0', '127.0.0.1')); @@ -54,7 +54,7 @@ class NetTest extends TestCase * @covers SimpleSAML\Utils\Net::ipCIDRcheck * @return void */ - public function testIpv6CIDRcheck() + public function testIpv6CIDRcheck(): void { // check CIDR w/o mask $this->assertFalse(Net::ipCIDRcheck('2001:0DB8::', '2001:0DB8::1')); diff --git a/tests/lib/SimpleSAML/Utils/RandomTest.php b/tests/lib/SimpleSAML/Utils/RandomTest.php index 38ee88fe307e5d158196e321f649aba8b322c37f..d059e5cf8315bb5922988787594f311350c86f52 100644 --- a/tests/lib/SimpleSAML/Utils/RandomTest.php +++ b/tests/lib/SimpleSAML/Utils/RandomTest.php @@ -18,7 +18,7 @@ class RandomTest extends TestCase * @covers SimpleSAML\Utils\Random::generateID * @return void */ - public function testGenerateID() + public function testGenerateID(): void { // check that it always starts with an underscore $this->assertStringStartsWith('_', Random::generateID()); diff --git a/tests/lib/SimpleSAML/Utils/SystemTest.php b/tests/lib/SimpleSAML/Utils/SystemTest.php index ad1c44456487663b91a2e2da5ab3e20418860f9f..8da6c3f605388afcc58c601f4fc485bf3be37b2a 100644 --- a/tests/lib/SimpleSAML/Utils/SystemTest.php +++ b/tests/lib/SimpleSAML/Utils/SystemTest.php @@ -48,7 +48,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testGetOSBasic() + public function testGetOSBasic(): void { $res = System::getOS(); @@ -61,7 +61,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testResolvePathRemoveTrailingSlashes() + public function testResolvePathRemoveTrailingSlashes(): void { $base = "/base////"; $path = "test"; @@ -78,7 +78,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testResolvePathPreferAbsolutePathToBase() + public function testResolvePathPreferAbsolutePathToBase(): void { $base = "/base/"; $path = "/test"; @@ -95,7 +95,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testResolvePathCurDirPath() + public function testResolvePathCurDirPath(): void { $base = "/base/"; $path = "/test/."; @@ -112,7 +112,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testResolvePathParentPath() + public function testResolvePathParentPath(): void { $base = "/base/"; $path = "/test/child/.."; @@ -129,7 +129,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testResolvePathAllowsStreamWrappers() + public function testResolvePathAllowsStreamWrappers(): void { $base = '/base/'; $path = 'vfs://simplesaml'; @@ -146,7 +146,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testResolvePathAllowsAwsS3StreamWrappers() + public function testResolvePathAllowsAwsS3StreamWrappers(): void { $base = '/base/'; $path = 's3://bucket-name/key-name'; @@ -178,7 +178,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testWriteFileBasic() + public function testWriteFileBasic(): void { $tempdir = $this->root_directory . DIRECTORY_SEPARATOR . self::DEFAULTTEMPDIR; $config = $this->setConfigurationTempDir($tempdir); @@ -198,7 +198,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testWriteFileContents() + public function testWriteFileContents(): void { $tempdir = $this->root_directory . DIRECTORY_SEPARATOR . self::DEFAULTTEMPDIR; $config = $this->setConfigurationTempDir($tempdir); @@ -222,7 +222,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testWriteFileMode() + public function testWriteFileMode(): void { $tempdir = $this->root_directory . DIRECTORY_SEPARATOR . self::DEFAULTTEMPDIR; $config = $this->setConfigurationTempDir($tempdir); @@ -246,7 +246,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testGetTempDirBasic() + public function testGetTempDirBasic(): void { $tempdir = $this->root_directory . DIRECTORY_SEPARATOR . self::DEFAULTTEMPDIR; $config = $this->setConfigurationTempDir($tempdir); @@ -266,7 +266,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testGetTempDirNonExistant() + public function testGetTempDirNonExistant(): void { $tempdir = $this->root_directory . DIRECTORY_SEPARATOR . 'nonexistant'; $config = $this->setConfigurationTempDir($tempdir); @@ -286,7 +286,7 @@ class SystemTest extends TestCase * @test * @return void */ - public function testGetTempDirBadPermissions() + public function testGetTempDirBadPermissions(): void { $tempdir = $this->root_directory . DIRECTORY_SEPARATOR . self::DEFAULTTEMPDIR; $config = $this->setConfigurationTempDir($tempdir); @@ -319,7 +319,7 @@ class SystemTest extends TestCase * @param class-string $className * @return void */ - protected function clearInstance(Configuration $service, $className) + protected function clearInstance(Configuration $service, string $className): void { $reflectedClass = new ReflectionClass($className); $reflectedInstance = $reflectedClass->getProperty('instance'); diff --git a/tests/lib/SimpleSAML/Utils/TimeTest.php b/tests/lib/SimpleSAML/Utils/TimeTest.php index 03f4e72a5793cb1d949b4ae3a1e1dd09d615b9d9..66f1b71d7509c77b8a010db4fa9c088addd1b5d6 100644 --- a/tests/lib/SimpleSAML/Utils/TimeTest.php +++ b/tests/lib/SimpleSAML/Utils/TimeTest.php @@ -15,7 +15,7 @@ class TimeTest extends TestCase * @covers SimpleSAML\Utils\Time::generateTimestamp * @return void */ - public function testGenerateTimestamp() + public function testGenerateTimestamp(): void { // make sure passed timestamps are used $this->assertEquals('2016-03-03T14:48:05Z', Time::generateTimestamp(1457016485)); @@ -31,7 +31,7 @@ class TimeTest extends TestCase * @covers SimpleSAML\Utils\Time::initTimezone * @return void */ - public function testInitTimezone() + public function testInitTimezone(): void { $tz = 'UTC'; $os = @date_default_timezone_get(); @@ -76,7 +76,7 @@ class TimeTest extends TestCase * @covers SimpleSAML\Utils\Time::parseDuration * @return void */ - public function testParseDuration() + public function testParseDuration(): void { // set up base date and time, and fixed durations from there $base = gmmktime(0, 0, 0, 1, 1, 2000); diff --git a/tests/lib/SimpleSAML/Utils/XMLTest.php b/tests/lib/SimpleSAML/Utils/XMLTest.php index f4446fb74fc060bd9e844e70b417e0d518742a3a..bb21981108c79273369575af91545b4950014c06 100644 --- a/tests/lib/SimpleSAML/Utils/XMLTest.php +++ b/tests/lib/SimpleSAML/Utils/XMLTest.php @@ -20,7 +20,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testIsDomNodeOfTypeBasic() + public function testIsDomNodeOfTypeBasic(): void { $name = 'name'; $namespace_uri = 'ns'; @@ -37,7 +37,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testIsDomNodeOfTypeMissingNamespace() + public function testIsDomNodeOfTypeMissingNamespace(): void { $this->expectException(\InvalidArgumentException::class); $name = 'name'; @@ -53,7 +53,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testIsDomNodeOfTypeEmpty() + public function testIsDomNodeOfTypeEmpty(): void { $name = 'name'; $namespace_uri = ''; @@ -70,7 +70,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testIsDomNodeOfTypeShortcut() + public function testIsDomNodeOfTypeShortcut(): void { $name = 'name'; $namespace_uri = 'urn:oasis:names:tc:SAML:2.0:metadata'; @@ -88,7 +88,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testIsDomNodeOfTypeIncorrectName() + public function testIsDomNodeOfTypeIncorrectName(): void { $name = 'name'; $bad_name = 'bad name'; @@ -106,7 +106,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testIsDomNodeOfTypeIncorrectNamespace() + public function testIsDomNodeOfTypeIncorrectNamespace(): void { $name = 'name'; $namespace_uri = 'ns'; @@ -124,7 +124,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testGetDomTextBasic() + public function testGetDomTextBasic(): void { $data = 'root value'; $dom = new \DOMDocument(); @@ -143,7 +143,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testGetDomTextMulti() + public function testGetDomTextMulti(): void { $data1 = 'root value 1'; $data2 = 'root value 2'; @@ -164,7 +164,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testGetDomTextIncorrectType() + public function testGetDomTextIncorrectType(): void { $this->expectException(\SimpleSAML\Error\Exception::class); $dom = new \DOMDocument(); @@ -180,7 +180,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testGetDomChildrenBasic() + public function testGetDomChildrenBasic(): void { $name = 'name'; $namespace_uri = 'ns'; @@ -200,7 +200,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testGetDomChildrenIncorrectType() + public function testGetDomChildrenIncorrectType(): void { $dom = new \DOMDocument(); $text = new \DOMText('text'); @@ -219,7 +219,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testGetDomChildrenIncorrectName() + public function testGetDomChildrenIncorrectName(): void { $name = 'name'; $bad_name = 'bad name'; @@ -239,7 +239,7 @@ class XMLTest extends TestCase * @test * @return void */ - public function testFormatDomElementBasic() + public function testFormatDomElementBasic(): void { $dom = new \DOMDocument(); $root = new \DOMElement('root'); @@ -263,7 +263,7 @@ NOWDOC; * @test * @return void */ - public function testFormatDomElementNested() + public function testFormatDomElementNested(): void { $dom = new \DOMDocument(); $root = new \DOMElement('root'); @@ -291,7 +291,7 @@ NOWDOC; * @test * @return void */ - public function testFormatDomElementIndentBase() + public function testFormatDomElementIndentBase(): void { $indent_base = 'base'; $dom = new \DOMDocument(); @@ -320,7 +320,7 @@ HEREDOC; * @test * @return void */ - public function testFormatDomElementTextAndChild() + public function testFormatDomElementTextAndChild(): void { $dom = new \DOMDocument(); $root = new \DOMElement('root'); @@ -345,7 +345,7 @@ HEREDOC; * @test * @return void */ - public function testFormatXmlStringBasic() + public function testFormatXmlStringBasic(): void { $xml = '<root><nested>text</nested></root>'; @@ -365,7 +365,7 @@ NOWDOC; * @test * @return void */ - public function testFormatXmlStringMalformedXml() + public function testFormatXmlStringMalformedXml(): void { $this->expectException(\DOMException::class); $xml = '<root><nested>text'; @@ -379,13 +379,12 @@ NOWDOC; * @test * @return void */ - public function testIsValidMalformedXml() + public function testIsValidMalformedXml(): void { $xml = '<root><nested>text'; $res = XML::isValid($xml, 'unused'); - $expected = 'Failed to parse XML string for schema validation'; - + $this->assertIsString($res); $this->assertContains($expected, $res); } @@ -394,7 +393,7 @@ NOWDOC; * @covers \SimpleSAML\Utils\XML::isValid * @return void */ - public function testIsValidMetadata() + public function testIsValidMetadata(): void { $schema = 'saml-schema-metadata-2.0.xsd'; $xml = file_get_contents(self::FRAMEWORK . '/metadata/xml/valid-metadata-selfsigned.xml'); @@ -410,7 +409,7 @@ NOWDOC; * @covers \SimpleSAML\Utils\XML::checkSAMLMessage() * @return void */ - public function testCheckSAMLMessageInvalidType() + public function testCheckSAMLMessageInvalidType(): void { $this->expectException(\InvalidArgumentException::class); XML::checkSAMLMessage('<test></test>', 'blub'); diff --git a/tests/lib/SimpleSAML/XML/ErrorsTest.php b/tests/lib/SimpleSAML/XML/ErrorsTest.php index 23e33c550587b7a135e1c957c1dad2eb901214b4..6eb306febf70d0fa4437772aaa6bb6d0a82f2d99 100644 --- a/tests/lib/SimpleSAML/XML/ErrorsTest.php +++ b/tests/lib/SimpleSAML/XML/ErrorsTest.php @@ -25,7 +25,7 @@ class ErrorsTest extends TestCase * @test * @return void */ - public function loggingErrors() + public function loggingErrors(): void { Errors::begin(); $xmlstr = "<Test>Test</test>"; @@ -46,7 +46,7 @@ class ErrorsTest extends TestCase * @test * @return void */ - public function formatErrors() + public function formatErrors(): void { $error = new \LibXMLError(); $error->level = 3; diff --git a/tests/lib/SimpleSAML/XML/ParserTest.php b/tests/lib/SimpleSAML/XML/ParserTest.php index 2c1767c2b14e7f56581c09e67059d4fa00fc9aa5..8203386ccf9d02eb3b951c96897a0989007d9d4d 100644 --- a/tests/lib/SimpleSAML/XML/ParserTest.php +++ b/tests/lib/SimpleSAML/XML/ParserTest.php @@ -43,7 +43,7 @@ XML; * @test * @return void */ - public function getValue() + public function getValue(): void { $result = $this->xml->getValue('/Root/Value', true); $this->assertEquals( @@ -59,7 +59,7 @@ XML; * @test * @return void */ - public function getEmptyValue() + public function getEmptyValue(): void { $result = $this->xml->getValue('/Root/Foo', false); $this->assertEquals( @@ -75,7 +75,7 @@ XML; * @test * @return void */ - public function getValueException() + public function getValueException(): void { $this->expectException(\Exception::class); $this->xml->getValue('/Root/Foo', true); @@ -88,7 +88,7 @@ XML; * @test * @return void */ - public function getDefaultValue() + public function getDefaultValue(): void { $result = $this->xml->getValueDefault('/Root/Other', 'Hello'); $this->assertEquals( @@ -104,7 +104,7 @@ XML; * @test * @return void */ - public function getValueAlternatives() + public function getValueAlternatives(): void { $result = $this ->xml @@ -127,7 +127,7 @@ XML; * @test * @return void */ - public function getEmptyValueAlternatives() + public function getEmptyValueAlternatives(): void { $result = $this ->xml @@ -150,7 +150,7 @@ XML; * @test * @return void */ - public function getValueAlternativesException() + public function getValueAlternativesException(): void { $this->expectException(\Exception::class); $this->xml->getValueAlternatives( diff --git a/tests/lib/SimpleSAML/XML/SignerTest.php b/tests/lib/SimpleSAML/XML/SignerTest.php index a0c20a4bfb78dab80a1289424fdcd415d7cd8130..11bdd158aa1d3a9735147dee2fab2fe5f658200f 100644 --- a/tests/lib/SimpleSAML/XML/SignerTest.php +++ b/tests/lib/SimpleSAML/XML/SignerTest.php @@ -54,7 +54,7 @@ NOWDOC; /** * @return array */ - public function getCertDirContent() + public function getCertDirContent(): array { return [ self::GOOD_PRIVATE_KEY => $this->good_private_key, @@ -67,7 +67,7 @@ NOWDOC; /** * @return void */ - public function testSignerBasic() + public function testSignerBasic(): void { $res = new Signer([]); @@ -78,7 +78,7 @@ NOWDOC; /** * @return void */ - public function testSignBasic() + public function testSignBasic(): void { $node = new DOMDocument(); $node->loadXML('<?xml version="1.0"?><node>value</node>'); @@ -104,7 +104,7 @@ NOWDOC; * @param string $certificate * @return string */ - private static function getCertificateValue($certificate) + private static function getCertificateValue(string $certificate): string { $replacements = [ "-----BEGIN CERTIFICATE-----", @@ -119,7 +119,7 @@ NOWDOC; /** * @return void */ - public function testSignWithCertificate() + public function testSignWithCertificate(): void { $node = new DOMDocument(); $node->loadXML('<?xml version="1.0"?><node>value</node>'); @@ -147,7 +147,7 @@ NOWDOC; /** * @return void */ - public function testSignWithMultiCertificate() + public function testSignWithMultiCertificate(): void { $this->other_certificate_file = $this->certdir . DIRECTORY_SEPARATOR . self::OTHER_CERTIFICATE; @@ -180,7 +180,7 @@ NOWDOC; /** * @return void */ - public function testSignMissingPrivateKey() + public function testSignMissingPrivateKey(): void { $node = new DOMDocument(); $node->loadXML('<?xml version="1.0"?><node>value</node>'); @@ -204,7 +204,7 @@ NOWDOC; * @param mixed|null $value * @return void */ - protected function clearInstance(Configuration $service, $className, $value = null) + protected function clearInstance(Configuration $service, string $className, $value = null): void { $reflectedClass = new ReflectionClass($className); $reflectedInstance = $reflectedClass->getProperty('instance'); diff --git a/tests/lib/SimpleSAML/XML/ValidatorTest.php b/tests/lib/SimpleSAML/XML/ValidatorTest.php index 67a71d2374508349b219aba3024738cec38db742..da02a40ea405866fbc2c52b76e8bd384f04c8149 100644 --- a/tests/lib/SimpleSAML/XML/ValidatorTest.php +++ b/tests/lib/SimpleSAML/XML/ValidatorTest.php @@ -20,7 +20,7 @@ class ValidatorTest extends SigningTestCase /** * @return void */ - public function testValidatorMissingSignature() + public function testValidatorMissingSignature(): void { $doc = new \DOMDocument(); $doc->loadXML('<?xml version="1.0"?><node>value</node>'); @@ -33,7 +33,7 @@ class ValidatorTest extends SigningTestCase /** * @return void */ - public function testGetX509Certificate() + public function testGetX509Certificate(): void { $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0"?><node>value</node>'); @@ -62,7 +62,7 @@ class ValidatorTest extends SigningTestCase /** * @return void */ - public function testCertFingerprintSuccess() + public function testCertFingerprintSuccess(): void { $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0"?><node>value</node>'); @@ -92,7 +92,7 @@ class ValidatorTest extends SigningTestCase /** * @return void */ - public function testCertFingerprintFailure() + public function testCertFingerprintFailure(): void { $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0"?><node>value</node>'); @@ -115,7 +115,7 @@ class ValidatorTest extends SigningTestCase /** * @return void */ - public function testValidateFingerprintSuccess() + public function testValidateFingerprintSuccess(): void { $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0"?><node>value</node>'); @@ -142,7 +142,7 @@ class ValidatorTest extends SigningTestCase /** * @return void */ - public function testValidateFingerprintFailure() + public function testValidateFingerprintFailure(): void { $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0"?><node>value</node>'); @@ -169,7 +169,7 @@ class ValidatorTest extends SigningTestCase /** * @return void */ - public function testIsNodeValidatedSuccess() + public function testIsNodeValidatedSuccess(): void { $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0"?><node>value</node>'); @@ -198,7 +198,7 @@ class ValidatorTest extends SigningTestCase /** * @return void */ - public function testIsNodeValidatedFailure() + public function testIsNodeValidatedFailure(): void { $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0"?><parent><node1>value1</node1><node2>value2</node2></parent>'); diff --git a/tests/modules/core/lib/Auth/Process/AttributeAddTest.php b/tests/modules/core/lib/Auth/Process/AttributeAddTest.php index 486f8a3da14905efee0ad1acf7a361cfdb8fe28e..e285d6a6a846d8a8937fa2c7b76b3eb96e49fc1a 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeAddTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeAddTest.php @@ -18,7 +18,7 @@ class AttributeAddTest extends TestCase * @param array $request The request state. * @return array The state array after processing. */ - private static function processFilter(array $config, array $request) + private static function processFilter(array $config, array $request): array { $filter = new \SimpleSAML\Module\core\Auth\Process\AttributeAdd($config, null); $filter->process($request); @@ -30,7 +30,7 @@ class AttributeAddTest extends TestCase * Test the most basic functionality. * @return void */ - public function testBasic() + public function testBasic(): void { $config = [ 'test' => ['value1', 'value2'], @@ -49,7 +49,7 @@ class AttributeAddTest extends TestCase * Test that existing attributes are left unmodified. * @return void */ - public function testExistingNotModified() + public function testExistingNotModified(): void { $config = [ 'test' => ['value1', 'value2'], @@ -75,7 +75,7 @@ class AttributeAddTest extends TestCase * Test single string as attribute value. * @return void */ - public function testStringValue() + public function testStringValue(): void { $config = [ 'test' => 'value', @@ -94,7 +94,7 @@ class AttributeAddTest extends TestCase * Test adding multiple attributes in one config. * @return void */ - public function testAddMultiple() + public function testAddMultiple(): void { $config = [ 'test1' => ['value1'], @@ -116,7 +116,7 @@ class AttributeAddTest extends TestCase * Test behavior when appending attribute values. * @return void */ - public function testAppend() + public function testAppend(): void { $config = [ 'test' => ['value2'], @@ -136,7 +136,7 @@ class AttributeAddTest extends TestCase * Test replacing attribute values. * @return void */ - public function testReplace() + public function testReplace(): void { $config = [ '%replace', @@ -157,7 +157,7 @@ class AttributeAddTest extends TestCase * Test wrong usage generates exceptions * @return void */ - public function testWrongFlag() + public function testWrongFlag(): void { $this->expectException(\Exception::class); $config = [ @@ -177,7 +177,7 @@ class AttributeAddTest extends TestCase * Test wrong attribute value * @return void */ - public function testWrongAttributeValue() + public function testWrongAttributeValue(): void { $this->expectException(\Exception::class); $config = [ diff --git a/tests/modules/core/lib/Auth/Process/AttributeAlterTest.php b/tests/modules/core/lib/Auth/Process/AttributeAlterTest.php index 19078037d81d35efaa98b9e57b0c082c8b76b653..2edb6f90d3370d0d1de3c60d72f5971717ac2542 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeAlterTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeAlterTest.php @@ -18,7 +18,7 @@ class AttributeAlterTest extends TestCase * @param array $request The request state. * @return array The state array after processing. */ - private static function processFilter(array $config, array $request) + private static function processFilter(array $config, array $request): array { $filter = new \SimpleSAML\Module\core\Auth\Process\AttributeAlter($config, null); $filter->process($request); @@ -30,7 +30,7 @@ class AttributeAlterTest extends TestCase * Test the most basic functionality. * @return void */ - public function testBasic() + public function testBasic(): void { $config = [ 'subject' => 'test', @@ -55,7 +55,7 @@ class AttributeAlterTest extends TestCase * Test the most basic functionality. * @return void */ - public function testWithTarget() + public function testWithTarget(): void { $config = [ 'subject' => 'test', @@ -83,7 +83,7 @@ class AttributeAlterTest extends TestCase * Module is a no op if subject attribute is not present. * @return void */ - public function testNomatch() + public function testNomatch(): void { $config = [ 'subject' => 'test', @@ -112,7 +112,7 @@ class AttributeAlterTest extends TestCase * Test replacing attribute value. * @return void */ - public function testReplaceMatch() + public function testReplaceMatch(): void { $config = [ 'subject' => 'source', @@ -135,7 +135,7 @@ class AttributeAlterTest extends TestCase * Test replacing attribute value. * @return void */ - public function testReplaceMatchWithTarget() + public function testReplaceMatchWithTarget(): void { $config = [ 'subject' => 'source', @@ -160,7 +160,7 @@ class AttributeAlterTest extends TestCase * Test replacing attribute values. * @return void */ - public function testReplaceNoMatch() + public function testReplaceNoMatch(): void { $config = [ 'subject' => 'test', @@ -187,7 +187,7 @@ class AttributeAlterTest extends TestCase * Also ensure unrelated attributes are not touched. * @return void */ - public function testRemoveMatch() + public function testRemoveMatch(): void { $config = [ 'subject' => 'eduPersonAffiliation', @@ -211,7 +211,7 @@ class AttributeAlterTest extends TestCase * Test removing attribute values, resulting in an empty attribute. * @return void */ - public function testRemoveMatchAll() + public function testRemoveMatchAll(): void { $config = [ 'subject' => 'eduPersonAffiliation', @@ -234,7 +234,7 @@ class AttributeAlterTest extends TestCase * Test for exception with illegal config. * @return void */ - public function testWrongConfig() + public function testWrongConfig(): void { $this->expectException(\Exception::class); $config = [ @@ -255,7 +255,7 @@ class AttributeAlterTest extends TestCase * Test for exception with illegal config. * @return void */ - public function testIncompleteConfig() + public function testIncompleteConfig(): void { $this->expectException(\Exception::class); $config = [ @@ -274,7 +274,7 @@ class AttributeAlterTest extends TestCase * Test for exception with illegal config. * @return void */ - public function testIncompleteConfig2() + public function testIncompleteConfig2(): void { $this->expectException(\Exception::class); $config = [ @@ -295,7 +295,7 @@ class AttributeAlterTest extends TestCase * Test for exception with illegal config. * @return void */ - public function testIncompleteConfig3() + public function testIncompleteConfig3(): void { $this->expectException(\Exception::class); $config = [ @@ -318,7 +318,7 @@ class AttributeAlterTest extends TestCase * Test for exception with illegal config. * @return void */ - public function testIncompleteConfig4() + public function testIncompleteConfig4(): void { $this->expectException(\Exception::class); $config = [ @@ -341,7 +341,7 @@ class AttributeAlterTest extends TestCase * Test for exception with illegal config. * @return void */ - public function testIncompleteConfig5() + public function testIncompleteConfig5(): void { $this->expectException(\Exception::class); $config = [ diff --git a/tests/modules/core/lib/Auth/Process/AttributeCopyTest.php b/tests/modules/core/lib/Auth/Process/AttributeCopyTest.php index cd3ef69ec92857810fcda9a44a63a152eff8e02d..a8428c4e98afe562450254ce3c5d0e467f913b57 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeCopyTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeCopyTest.php @@ -18,7 +18,7 @@ class AttributeCopyTest extends TestCase * @param array $request The request state. * @return array The state array after processing. */ - private static function processFilter(array $config, array $request) + private static function processFilter(array $config, array $request): array { $filter = new \SimpleSAML\Module\core\Auth\Process\AttributeCopy($config, null); $filter->process($request); @@ -30,7 +30,7 @@ class AttributeCopyTest extends TestCase * Test the most basic functionality. * @return void */ - public function testBasic() + public function testBasic(): void { $config = [ 'test' => 'testnew', @@ -50,7 +50,7 @@ class AttributeCopyTest extends TestCase * Test the most basic functionality. * @return void */ - public function testArray() + public function testArray(): void { $config = [ 'test' => ['new1', 'new2'], @@ -72,7 +72,7 @@ class AttributeCopyTest extends TestCase * Test that existing attributes are left unmodified. * @return void */ - public function testExistingNotModified() + public function testExistingNotModified(): void { $config = [ 'test' => 'testnew', @@ -99,7 +99,7 @@ class AttributeCopyTest extends TestCase * Test copying multiple attributes * @return void */ - public function testCopyMultiple() + public function testCopyMultiple(): void { $config = [ 'test1' => 'new1', @@ -121,7 +121,7 @@ class AttributeCopyTest extends TestCase * Test behaviour when target attribute exists (should be replaced). * @return void */ - public function testCopyClash() + public function testCopyClash(): void { $config = [ 'test' => 'new1', @@ -142,7 +142,7 @@ class AttributeCopyTest extends TestCase * Test wrong attribute name * @return void */ - public function testWrongAttributeName() + public function testWrongAttributeName(): void { $this->expectException(\Exception::class); $config = [ @@ -161,7 +161,7 @@ class AttributeCopyTest extends TestCase * Test wrong attribute value * @return void */ - public function testWrongAttributeValue() + public function testWrongAttributeValue(): void { $this->expectException(\Exception::class); $config = [ diff --git a/tests/modules/core/lib/Auth/Process/AttributeLimitTest.php b/tests/modules/core/lib/Auth/Process/AttributeLimitTest.php index b79b7131a69a9f4e6f5f81d9e590815a474b0cde..581c2c87d51a393222c53e6034c9338f5c430a04 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeLimitTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeLimitTest.php @@ -25,7 +25,7 @@ class AttributeLimitTest extends TestCase * @param array $request The request state. * @return array The state array after processing. */ - private static function processFilter(array $config, array $request) + private static function processFilter(array $config, array $request): array { $filter = new \SimpleSAML\Module\core\Auth\Process\AttributeLimit($config, null); $filter->process($request); @@ -37,7 +37,7 @@ class AttributeLimitTest extends TestCase * Test reading IdP Attributes. * @return void */ - public function testIdPAttrs() + public function testIdPAttrs(): void { $config = [ 'cn', 'mail' @@ -84,7 +84,7 @@ class AttributeLimitTest extends TestCase * Tests when no attributes are in metadata. * @return void */ - public function testNULLMetadataAttrs() + public function testNULLMetadataAttrs(): void { $config = [ 'cn', 'mail' @@ -162,7 +162,7 @@ class AttributeLimitTest extends TestCase * Test the most basic functionality. * @return void */ - public function testBasic() + public function testBasic(): void { $config = [ 'cn', 'mail' @@ -180,7 +180,7 @@ class AttributeLimitTest extends TestCase * Test defaults with metadata available. * @return void */ - public function testDefaultWithMetadata() + public function testDefaultWithMetadata(): void { $config = [ 'default' => true, @@ -198,7 +198,7 @@ class AttributeLimitTest extends TestCase * Test defaults with attributes and metadata * @return void */ - public function testDefaultWithAttrs() + public function testDefaultWithAttrs(): void { $config = [ 'default' => true, @@ -219,7 +219,7 @@ class AttributeLimitTest extends TestCase * Test for exception with illegal config. * @return void */ - public function testInvalidConfig() + public function testInvalidConfig(): void { $this->expectException(\Exception::class); $config = [ @@ -234,7 +234,7 @@ class AttributeLimitTest extends TestCase * Test for invalid attribute name * @return void */ - public function testInvalidAttributeName() + public function testInvalidAttributeName(): void { $this->expectException(\Exception::class); $config = [ @@ -249,7 +249,7 @@ class AttributeLimitTest extends TestCase * Test for attribute value matching * @return void */ - public function testMatchAttributeValues() + public function testMatchAttributeValues(): void { $config = [ 'eduPersonAffiliation' => ['member'] @@ -290,7 +290,7 @@ class AttributeLimitTest extends TestCase /** * @return void */ - public function testBadOptionsNotTreatedAsValidValues() + public function testBadOptionsNotTreatedAsValidValues(): void { // Ensure really misconfigured ignoreCase and regex options are not interpretted as valid valus $config = [ @@ -308,7 +308,7 @@ class AttributeLimitTest extends TestCase * php and matched against an attribute value of '1' * @return void */ - public function testThatIgnoreCaseOptionNotMatchBooleanAsStringValue() + public function testThatIgnoreCaseOptionNotMatchBooleanAsStringValue(): void { $config = [ 'someAttribute' => ['ignoreCase' => true, 'someValue'] @@ -330,7 +330,7 @@ class AttributeLimitTest extends TestCase * Test for attribute value matching ignore case * @return void */ - public function testMatchAttributeValuesIgnoreCase() + public function testMatchAttributeValuesIgnoreCase(): void { $config = [ 'eduPersonAffiliation' => ['ignoreCase' => true, 'meMber'] @@ -372,7 +372,7 @@ class AttributeLimitTest extends TestCase * Test for attribute value matching * @return void */ - public function testMatchAttributeValuesRegex() + public function testMatchAttributeValuesRegex(): void { // SSP Logger requires a configuration to be set. \SimpleSAML\Configuration::loadFromArray([], '[ARRAY]', 'simplesaml'); @@ -474,7 +474,7 @@ class AttributeLimitTest extends TestCase * Cannot be generated via config options. * @return void */ - public function testMatchAttributeValuesNotArray() + public function testMatchAttributeValuesNotArray(): void { $this->expectException(\Exception::class); $config = [ @@ -504,7 +504,7 @@ class AttributeLimitTest extends TestCase * Test attributes not intersecting * @return void */ - public function testNoIntersection() + public function testNoIntersection(): void { $config = [ 'default' => true, diff --git a/tests/modules/core/lib/Auth/Process/AttributeMapTest.php b/tests/modules/core/lib/Auth/Process/AttributeMapTest.php index cbd33af7152a7a20db6479546a1ba717e51d059a..682de2c6c6af7efd0cdee7b63f7b250e28324cc4 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeMapTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeMapTest.php @@ -18,7 +18,7 @@ class AttributeMapTest extends TestCase * @param array $request The request state. * @return array The state array after processing. */ - private static function processFilter(array $config, array $request) + private static function processFilter(array $config, array $request): array { $filter = new \SimpleSAML\Module\core\Auth\Process\AttributeMap($config, null); $filter->process($request); @@ -29,7 +29,7 @@ class AttributeMapTest extends TestCase /** * @return void */ - public function testBasic() + public function testBasic(): void { $config = [ 'attribute1' => 'attribute2', @@ -53,7 +53,7 @@ class AttributeMapTest extends TestCase /** * @return void */ - public function testDuplicate() + public function testDuplicate(): void { $config = [ 'attribute1' => 'attribute2', @@ -79,7 +79,7 @@ class AttributeMapTest extends TestCase /** * @return void */ - public function testMultiple() + public function testMultiple(): void { $config = [ 'attribute1' => ['attribute2', 'attribute3'], @@ -104,7 +104,7 @@ class AttributeMapTest extends TestCase /** * @return void */ - public function testMultipleDuplicate() + public function testMultipleDuplicate(): void { $config = [ 'attribute1' => ['attribute2', 'attribute3'], @@ -131,7 +131,7 @@ class AttributeMapTest extends TestCase /** * @return void */ - public function testCircular() + public function testCircular(): void { $config = [ 'attribute1' => 'attribute1', @@ -158,7 +158,7 @@ class AttributeMapTest extends TestCase /** * @return void */ - public function testMissingMap() + public function testMissingMap(): void { $config = [ 'attribute1' => 'attribute3', @@ -184,7 +184,7 @@ class AttributeMapTest extends TestCase /** * @return void */ - public function testInvalidOriginalAttributeType() + public function testInvalidOriginalAttributeType(): void { $config = [ 10 => 'attribute2', @@ -203,7 +203,7 @@ class AttributeMapTest extends TestCase /** * @return void */ - public function testInvalidMappedAttributeType() + public function testInvalidMappedAttributeType(): void { $config = [ 'attribute1' => 10, @@ -222,7 +222,7 @@ class AttributeMapTest extends TestCase /** * @return void */ - public function testMissingMapFile() + public function testMissingMapFile(): void { $config = [ 'non_existant_mapfile', @@ -241,7 +241,7 @@ class AttributeMapTest extends TestCase /** * @return void */ - public function testOverwrite() + public function testOverwrite(): void { $config = [ 'attribute1' => 'attribute2', @@ -266,7 +266,7 @@ class AttributeMapTest extends TestCase /** * @return void */ - public function testOverwriteReversed() + public function testOverwriteReversed(): void { $config = [ 'attribute1' => 'attribute2', diff --git a/tests/modules/core/lib/Auth/Process/AttributeValueMapTest.php b/tests/modules/core/lib/Auth/Process/AttributeValueMapTest.php index d79e31ee0fbdbc2e67622341ae7ee9a3936600d0..7842b2e6f56eece8301551e53564dc6d72b69c53 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeValueMapTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeValueMapTest.php @@ -19,7 +19,7 @@ class AttributeValueMapTest extends TestCase * @param array $request The request state. * @return array The state array after processing. */ - private static function processFilter(array $config, array $request) + private static function processFilter(array $config, array $request): array { $filter = new AttributeValueMap($config, null); $filter->process($request); @@ -34,7 +34,7 @@ class AttributeValueMapTest extends TestCase * @covers SimpleSAML\Module\core\Auth\Process\AttributeValueMap::process * @return void */ - public function testBasic() + public function testBasic(): void { $config = [ 'sourceattribute' => 'memberOf', @@ -66,7 +66,7 @@ class AttributeValueMapTest extends TestCase * @covers SimpleSAML\Module\core\Auth\Process\AttributeValueMap::process * @return void */ - public function testNoDuplicates() + public function testNoDuplicates(): void { $config = [ 'sourceattribute' => 'memberOf', @@ -99,7 +99,7 @@ class AttributeValueMapTest extends TestCase * @covers SimpleSAML\Module\core\Auth\Process\AttributeValueMap::process * @return void */ - public function testReplace() + public function testReplace(): void { $config = [ 'sourceattribute' => 'memberOf', @@ -133,7 +133,7 @@ class AttributeValueMapTest extends TestCase * @covers SimpleSAML\Module\core\Auth\Process\AttributeValueMap::process * @return void */ - public function testKeep() + public function testKeep(): void { $config = [ 'sourceattribute' => 'memberOf', @@ -167,7 +167,7 @@ class AttributeValueMapTest extends TestCase * @covers SimpleSAML\Module\core\Auth\Process\AttributeValueMap::process * @return void */ - public function testUnknownFlag() + public function testUnknownFlag(): void { $config = [ '%test', @@ -198,7 +198,7 @@ class AttributeValueMapTest extends TestCase * @covers SimpleSAML\Module\core\Auth\Process\AttributeValueMap::process * @return void */ - public function testMissingSourceAttribute() + public function testMissingSourceAttribute(): void { $this->expectException(\Exception::class); $config = [ @@ -225,7 +225,7 @@ class AttributeValueMapTest extends TestCase * @covers SimpleSAML\Module\core\Auth\Process\AttributeValueMap::process * @return void */ - public function testMissingTargetAttribute() + public function testMissingTargetAttribute(): void { $this->expectException(\Exception::class); $config = [ diff --git a/tests/modules/core/lib/Auth/Process/CardinalitySingleTest.php b/tests/modules/core/lib/Auth/Process/CardinalitySingleTest.php index 62de2e872976cc7006d4031d09f32c31b08f2105..3f54f2a47088dcdefbcad31380aaac8abb9e1410 100644 --- a/tests/modules/core/lib/Auth/Process/CardinalitySingleTest.php +++ b/tests/modules/core/lib/Auth/Process/CardinalitySingleTest.php @@ -52,7 +52,7 @@ class CardinalitySingleTest extends \PHPUnit\Framework\TestCase * Test singleValued * @return void */ - public function testSingleValuedUnchanged() + public function testSingleValuedUnchanged(): void { $config = [ 'singleValued' => ['eduPersonPrincipalName'] @@ -73,7 +73,7 @@ class CardinalitySingleTest extends \PHPUnit\Framework\TestCase * Test first value extraction * @return void */ - public function testFirstValue() + public function testFirstValue(): void { $config = [ 'firstValue' => ['eduPersonPrincipalName'] @@ -93,7 +93,7 @@ class CardinalitySingleTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function testFirstValueUnchanged() + public function testFirstValueUnchanged(): void { $config = [ 'firstValue' => ['eduPersonPrincipalName'] @@ -114,7 +114,7 @@ class CardinalitySingleTest extends \PHPUnit\Framework\TestCase * Test flattening * @return void */ - public function testFlatten() + public function testFlatten(): void { $config = [ 'flatten' => ['eduPersonPrincipalName'], @@ -135,7 +135,7 @@ class CardinalitySingleTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function testFlattenUnchanged() + public function testFlattenUnchanged(): void { $config = [ 'flatten' => ['eduPersonPrincipalName'], @@ -157,7 +157,7 @@ class CardinalitySingleTest extends \PHPUnit\Framework\TestCase * Test abort * @return void */ - public function testAbort() + public function testAbort(): void { $config = [ 'singleValued' => ['eduPersonPrincipalName'], diff --git a/tests/modules/core/lib/Auth/Process/CardinalityTest.php b/tests/modules/core/lib/Auth/Process/CardinalityTest.php index 03cb6aab3688b595c6358689dd59f3941c5fa936..be1e2495dc54187ef5e4fc5666c5c1a18a02386e 100644 --- a/tests/modules/core/lib/Auth/Process/CardinalityTest.php +++ b/tests/modules/core/lib/Auth/Process/CardinalityTest.php @@ -53,7 +53,7 @@ class CardinalityTest extends \PHPUnit\Framework\TestCase * Test where a minimum is set but no maximum * @return void */ - public function testMinNoMax() + public function testMinNoMax(): void { $config = [ 'mail' => ['min' => 1], @@ -74,7 +74,7 @@ class CardinalityTest extends \PHPUnit\Framework\TestCase * Test where a maximum is set but no minimum * @return void */ - public function testMaxNoMin() + public function testMaxNoMin(): void { $config = [ 'mail' => ['max' => 2], @@ -95,7 +95,7 @@ class CardinalityTest extends \PHPUnit\Framework\TestCase * Test in bounds within a maximum an minimum * @return void */ - public function testMaxMin() + public function testMaxMin(): void { $config = [ 'mail' => ['min' => 1, 'max' => 2], @@ -116,7 +116,7 @@ class CardinalityTest extends \PHPUnit\Framework\TestCase * Test maximum is out of bounds results in redirect * @return void */ - public function testMaxOutOfBounds() + public function testMaxOutOfBounds(): void { $config = [ 'mail' => ['max' => 2], @@ -139,7 +139,7 @@ class CardinalityTest extends \PHPUnit\Framework\TestCase * Test minimum is out of bounds results in redirect * @return void */ - public function testMinOutOfBounds() + public function testMinOutOfBounds(): void { $config = [ 'mail' => ['min' => 3], @@ -162,7 +162,7 @@ class CardinalityTest extends \PHPUnit\Framework\TestCase * Test missing attribute results in redirect * @return void */ - public function testMissingAttribute() + public function testMissingAttribute(): void { $config = [ 'mail' => ['min' => 1], @@ -188,7 +188,7 @@ class CardinalityTest extends \PHPUnit\Framework\TestCase * Test invalid minimum values * @return void */ - public function testMinInvalid() + public function testMinInvalid(): void { $this->expectException(SspException::class); $this->expectExceptionMessageRegExp('/Minimum/'); @@ -208,7 +208,7 @@ class CardinalityTest extends \PHPUnit\Framework\TestCase * Test invalid minimum values * @return void */ - public function testMinNegative() + public function testMinNegative(): void { $this->expectException(SspException::class); $this->expectExceptionMessageRegExp('/Minimum/'); @@ -228,7 +228,7 @@ class CardinalityTest extends \PHPUnit\Framework\TestCase * Test invalid maximum values * @return void */ - public function testMaxInvalid() + public function testMaxInvalid(): void { $this->expectException(SspException::class); $this->expectExceptionMessageRegExp('/Maximum/'); @@ -248,7 +248,7 @@ class CardinalityTest extends \PHPUnit\Framework\TestCase * Test maximum < minimum * @return void */ - public function testMinGreaterThanMax() + public function testMinGreaterThanMax(): void { $this->expectException(SspException::class); $this->expectExceptionMessageRegExp('/less than/'); @@ -268,7 +268,7 @@ class CardinalityTest extends \PHPUnit\Framework\TestCase * Test invalid attribute name * @return void */ - public function testInvalidAttributeName() + public function testInvalidAttributeName(): void { $this->expectException(SspException::class); $this->expectExceptionMessageRegExp('/Invalid attribute/'); diff --git a/tests/modules/core/lib/Auth/Process/PHPTest.php b/tests/modules/core/lib/Auth/Process/PHPTest.php index 78815548858b45f472a77e05eaa0b07ebfd991cf..0377dfafb1cf1418a6c63853030f841fd89c432e 100644 --- a/tests/modules/core/lib/Auth/Process/PHPTest.php +++ b/tests/modules/core/lib/Auth/Process/PHPTest.php @@ -20,7 +20,7 @@ class PHPTest extends TestCase * * @return array The state array after processing. */ - private static function processFilter(array $config, array $request) + private static function processFilter(array $config, array $request): array { $filter = new \SimpleSAML\Module\core\Auth\Process\PHP($config, null); @$filter->process($request); @@ -32,7 +32,7 @@ class PHPTest extends TestCase * Test the configuration of the filter. * @return void */ - public function testInvalidConfiguration() + public function testInvalidConfiguration(): void { $config = []; $this->expectException(\SimpleSAML\Error\Exception::class); @@ -47,7 +47,7 @@ class PHPTest extends TestCase * Check that defining the code works as expected. * @return void */ - public function testCodeDefined() + public function testCodeDefined(): void { $config = [ 'code' => ' @@ -69,7 +69,7 @@ class PHPTest extends TestCase * Check that the incoming attributes are also available after processing * @return void */ - public function testPreserveIncomingAttributes() + public function testPreserveIncomingAttributes(): void { $config = [ 'code' => ' @@ -100,7 +100,7 @@ class PHPTest extends TestCase * filter (a documented use case) works. * @return void */ - public function testThrowExceptionFromFilter() + public function testThrowExceptionFromFilter(): void { $config = [ 'code' => ' @@ -126,7 +126,7 @@ class PHPTest extends TestCase * Check that the entire state can be adjusted. * @return void */ - public function testStateCanBeModified() + public function testStateCanBeModified(): void { $config = [ diff --git a/tests/modules/core/lib/Auth/Process/ScopeAttributeTest.php b/tests/modules/core/lib/Auth/Process/ScopeAttributeTest.php index 6c2c833d629daef34422a8da086fa4a84ecc5a75..72fe7c3d9626e87d3c761d90b71250a7ccb66ac5 100644 --- a/tests/modules/core/lib/Auth/Process/ScopeAttributeTest.php +++ b/tests/modules/core/lib/Auth/Process/ScopeAttributeTest.php @@ -18,7 +18,7 @@ class ScopeAttributeTest extends TestCase * @param array $request The request state. * @return array The state array after processing. */ - private static function processFilter(array $config, array $request) + private static function processFilter(array $config, array $request): array { $filter = new \SimpleSAML\Module\core\Auth\Process\ScopeAttribute($config, null); $filter->process($request); @@ -30,7 +30,7 @@ class ScopeAttributeTest extends TestCase * Test the most basic functionality. * @return void */ - public function testBasic() + public function testBasic(): void { $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', @@ -54,7 +54,7 @@ class ScopeAttributeTest extends TestCase * If target attribute already set, module must add, not overwrite. * @return void */ - public function testNoOverwrite() + public function testNoOverwrite(): void { $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', @@ -81,7 +81,7 @@ class ScopeAttributeTest extends TestCase * If same scope already set, module must do nothing, not duplicate value. * @return void */ - public function testNoDuplication() + public function testNoDuplication(): void { $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', @@ -105,7 +105,7 @@ class ScopeAttributeTest extends TestCase * If source attribute not set, nothing happens * @return void */ - public function testNoSourceAttribute() + public function testNoSourceAttribute(): void { $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', @@ -128,7 +128,7 @@ class ScopeAttributeTest extends TestCase * If scope attribute not set, nothing happens * @return void */ - public function testNoScopeAttribute() + public function testNoScopeAttribute(): void { $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', @@ -151,7 +151,7 @@ class ScopeAttributeTest extends TestCase * When multiple @ signs in attribute, will use the first one. * @return void */ - public function testMultiAt() + public function testMultiAt(): void { $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', @@ -174,7 +174,7 @@ class ScopeAttributeTest extends TestCase * When multiple values in source attribute, should render multiple targets. * @return void */ - public function testMultivaluedSource() + public function testMultivaluedSource(): void { $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', @@ -200,7 +200,7 @@ class ScopeAttributeTest extends TestCase * When the source attribute doesn't have a scope, the entire value is used. * @return void */ - public function testNoAt() + public function testNoAt(): void { $config = [ 'scopeAttribute' => 'schacHomeOrganization', @@ -223,7 +223,7 @@ class ScopeAttributeTest extends TestCase * When the target attribute exists and onlyIfEmpty is set * @return void */ - public function testOnlyIfEmpty() + public function testOnlyIfEmpty(): void { $config = [ 'scopeAttribute' => 'schacHomeOrganization', diff --git a/tests/modules/core/lib/Auth/Process/ScopeFromAttributeTest.php b/tests/modules/core/lib/Auth/Process/ScopeFromAttributeTest.php index 0e45a1ee5f6f3f95ae188f79de208fe14aa2c481..8aa26159ae3e171991568f028df919b7804dd1aa 100644 --- a/tests/modules/core/lib/Auth/Process/ScopeFromAttributeTest.php +++ b/tests/modules/core/lib/Auth/Process/ScopeFromAttributeTest.php @@ -18,7 +18,7 @@ class ScopeFromAttributeTest extends TestCase * @param array $request The request state. * @return array The state array after processing. */ - private static function processFilter(array $config, array $request) + private static function processFilter(array $config, array $request): array { $filter = new \SimpleSAML\Module\core\Auth\Process\ScopeFromAttribute($config, null); $filter->process($request); @@ -30,7 +30,7 @@ class ScopeFromAttributeTest extends TestCase * Test the most basic functionality. * @return void */ - public function testBasic() + public function testBasic(): void { $config = [ 'sourceAttribute' => 'eduPersonPrincipalName', @@ -52,7 +52,7 @@ class ScopeFromAttributeTest extends TestCase * If scope already set, module must not overwrite. * @return void */ - public function testNoOverwrite() + public function testNoOverwrite(): void { $config = [ 'sourceAttribute' => 'eduPersonPrincipalName', @@ -74,7 +74,7 @@ class ScopeFromAttributeTest extends TestCase * If source attribute not set, nothing happens * @return void */ - public function testNoSourceAttribute() + public function testNoSourceAttribute(): void { $config = [ 'sourceAttribute' => 'eduPersonPrincipalName', @@ -95,7 +95,7 @@ class ScopeFromAttributeTest extends TestCase * When multiple @ signs in attribute, should use last one. * @return void */ - public function testMultiAt() + public function testMultiAt(): void { $config = [ 'sourceAttribute' => 'eduPersonPrincipalName', @@ -116,7 +116,7 @@ class ScopeFromAttributeTest extends TestCase * When the source attribute doesn't have a scope, a warning is emitted * @return void */ - public function testNoAt() + public function testNoAt(): void { $config = [ 'sourceAttribute' => 'eduPersonPrincipalName', diff --git a/tests/modules/core/lib/Auth/Process/TargetedIDTest.php b/tests/modules/core/lib/Auth/Process/TargetedIDTest.php index 4811bc53765a156baff99b69c8256c2de507ef12..59357bc29916a3046c48cf7ff22bbc8f1082cbe6 100644 --- a/tests/modules/core/lib/Auth/Process/TargetedIDTest.php +++ b/tests/modules/core/lib/Auth/Process/TargetedIDTest.php @@ -18,7 +18,7 @@ class TargetedIDTest extends TestCase * @param array $request The request state. * @return array The state array after processing. */ - private static function processFilter(array $config, array $request) + private static function processFilter(array $config, array $request): array { $filter = new \SimpleSAML\Module\core\Auth\Process\TargetedID($config, null); $filter->process($request); @@ -179,7 +179,7 @@ class TargetedIDTest extends TestCase * Test no userid set * @return void */ - public function testNoUserID() + public function testNoUserID(): void { $this->expectException(\Exception::class); $config = []; @@ -194,7 +194,7 @@ class TargetedIDTest extends TestCase * Test with specified attribute not set * @return void */ - public function testAttributeNotExists() + public function testAttributeNotExists(): void { $this->expectException(\Exception::class); $config = [ @@ -213,7 +213,7 @@ class TargetedIDTest extends TestCase * Test with configuration error 1 * @return void */ - public function testConfigInvalidAttributeName() + public function testConfigInvalidAttributeName(): void { $this->expectException(\Exception::class); $config = [ @@ -232,7 +232,7 @@ class TargetedIDTest extends TestCase * Test with configuration error 2 * @return void */ - public function testConfigInvalidNameId() + public function testConfigInvalidNameId(): void { $this->expectException(\Exception::class); $config = [ diff --git a/tests/modules/core/lib/Auth/UserPassBaseTest.php b/tests/modules/core/lib/Auth/UserPassBaseTest.php index 465d86e1eb30dd73f1a931776d380004fdb2b516..33c1455a79d3cb3614ad5aff35fa71b5657fc188 100644 --- a/tests/modules/core/lib/Auth/UserPassBaseTest.php +++ b/tests/modules/core/lib/Auth/UserPassBaseTest.php @@ -13,7 +13,7 @@ class UserPassBaseTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function testAuthenticateECPCallsLoginAndSetsAttributes() + public function testAuthenticateECPCallsLoginAndSetsAttributes(): void { $state = [ 'saml:Binding' => Constants::BINDING_PAOS, @@ -43,7 +43,7 @@ class UserPassBaseTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function testAuthenticateECPMissingUsername() + public function testAuthenticateECPMissingUsername(): void { $this->expectException(SspError::class); $this->expectExceptionMessage('WRONGUSERPASS'); @@ -67,7 +67,7 @@ class UserPassBaseTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function testAuthenticateECPMissingPassword() + public function testAuthenticateECPMissingPassword(): void { $this->expectException(SspError::class); $this->expectExceptionMessage('WRONGUSERPASS'); @@ -91,7 +91,7 @@ class UserPassBaseTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function testAuthenticateECPCallsLoginWithForcedUsername() + public function testAuthenticateECPCallsLoginWithForcedUsername(): void { $state = [ 'saml:Binding' => Constants::BINDING_PAOS, diff --git a/tests/modules/core/lib/Auth/UserPassOrgBaseTest.php b/tests/modules/core/lib/Auth/UserPassOrgBaseTest.php index 6fe765fddccf19f549092fe11b9d8396a583a8aa..fe6e8d657f289e1539104ab05f2d4078b7dbe451 100644 --- a/tests/modules/core/lib/Auth/UserPassOrgBaseTest.php +++ b/tests/modules/core/lib/Auth/UserPassOrgBaseTest.php @@ -11,7 +11,7 @@ class UserPassOrgBaseTest extends \PHPUnit\Framework\TestCase /** * @return void */ - public function testRememberOrganizationEnabled() + public function testRememberOrganizationEnabled(): void { $config = [ 'ldap:LDAPMulti', diff --git a/tests/modules/core/lib/Controller/LoginTest.php b/tests/modules/core/lib/Controller/LoginTest.php index 7f83a8cead4335e9f5446fd1107d5d63e94c962f..1f813b4f2bc950a2d49fb92548dfca0c0a96788a 100644 --- a/tests/modules/core/lib/Controller/LoginTest.php +++ b/tests/modules/core/lib/Controller/LoginTest.php @@ -72,7 +72,7 @@ class LoginTest extends ClearStateTestCase * source configured. * @return void */ - public function testAutomaticLoginWhenOnlyOneSource() + public function testAutomaticLoginWhenOnlyOneSource(): void { $asConfig = Configuration::loadFromArray($this->authSources); Configuration::setPreLoadedConfig($asConfig, 'authsources.php'); @@ -98,7 +98,7 @@ class LoginTest extends ClearStateTestCase * Test that the user can choose what auth source to use when there are multiple defined (admin excluded). * @return void */ - public function testMultipleAuthSources() + public function testMultipleAuthSources(): void { $_SERVER['REQUEST_URI'] = '/'; $asConfig = Configuration::loadFromArray( @@ -134,7 +134,7 @@ class LoginTest extends ClearStateTestCase * Test that specifying an invalid auth source while trying to login raises an exception. * @return void */ - public function testLoginWithInvalidAuthSource() + public function testLoginWithInvalidAuthSource(): void { $asConfig = Configuration::loadFromArray($this->authSources); Configuration::setPreLoadedConfig($asConfig, 'authsources.php'); @@ -152,7 +152,7 @@ class LoginTest extends ClearStateTestCase * authenticated. * @return void */ - public function testLoginWhenAlreadyAuthenticated() + public function testLoginWhenAlreadyAuthenticated(): void { $asConfig = Configuration::loadFromArray($this->authSources); Configuration::setPreLoadedConfig($asConfig, 'authsources.php'); @@ -191,7 +191,7 @@ class LoginTest extends ClearStateTestCase * Test that triggering the logout controller actually proceeds to log out from the specified source. * @return void */ - public function testLogout() + public function testLogout(): void { $asConfig = Configuration::loadFromArray($this->authSources); Configuration::setPreLoadedConfig($asConfig, 'authsources.php'); @@ -213,7 +213,7 @@ class LoginTest extends ClearStateTestCase * endpoint. * @return void */ - public function testNotAuthenticated() + public function testNotAuthenticated(): void { $asConfig = Configuration::loadFromArray($this->authSources); Configuration::setPreLoadedConfig($asConfig, 'authsources.php'); @@ -234,7 +234,7 @@ class LoginTest extends ClearStateTestCase * Test that we are presented with a regular page if we are authenticated and try to access the "account" endpoint. * @return void */ - public function testAuthenticated() + public function testAuthenticated(): void { $asConfig = Configuration::loadFromArray($this->authSources); Configuration::setPreLoadedConfig($asConfig, 'authsources.php'); diff --git a/tests/modules/core/lib/Storage/SQLPermanentStorageTest.php b/tests/modules/core/lib/Storage/SQLPermanentStorageTest.php index 1f19058f8f21d9407bf2ee09848b601358968345..fa77d714c880f413cf7ff3acb19b4360c4930ee5 100644 --- a/tests/modules/core/lib/Storage/SQLPermanentStorageTest.php +++ b/tests/modules/core/lib/Storage/SQLPermanentStorageTest.php @@ -41,7 +41,7 @@ class SQLPermanentStorageTest extends TestCase /** * @return void */ - public function testSet() + public function testSet(): void { // Set a new value self::$sql->set('testtype', 'testkey1', 'testkey2', 'testvalue', 2); @@ -56,7 +56,7 @@ class SQLPermanentStorageTest extends TestCase /** * @return void */ - public function testSetOverwrite() + public function testSetOverwrite(): void { // Overwrite existing value self::$sql->set('testtype', 'testkey1', 'testkey2', 'testvaluemodified', 2); @@ -74,7 +74,7 @@ class SQLPermanentStorageTest extends TestCase /** * @return void */ - public function testNonexistentKey() + public function testNonexistentKey(): void { // Test that getting some non-existing key will return null / empty array $result = self::$sql->getValue('testtype_nonexistent', 'testkey1_nonexistent', 'testkey2_nonexistent'); @@ -89,7 +89,7 @@ class SQLPermanentStorageTest extends TestCase /** * @return void */ - public function testExpiration() + public function testExpiration(): void { // Make sure the earlier created entry has expired now sleep(3); @@ -111,7 +111,7 @@ class SQLPermanentStorageTest extends TestCase /** * @return void */ - public function testRemove() + public function testRemove(): void { // Now remove the nonexpiring entry and make sure it's gone self::$sql->remove('testtype', 'testkey1_nonexpiring', 'testkey2_nonexpiring'); diff --git a/tests/modules/multiauth/lib/Auth/Source/MultiAuthTest.php b/tests/modules/multiauth/lib/Auth/Source/MultiAuthTest.php index 635633037c1d86b6979d2cead36a2eb2ca37d0c1..b92ed82b4cdceb5c2485cd9b5b13ea41b1c854a1 100644 --- a/tests/modules/multiauth/lib/Auth/Source/MultiAuthTest.php +++ b/tests/modules/multiauth/lib/Auth/Source/MultiAuthTest.php @@ -72,7 +72,7 @@ class MultiAuthTest extends \SimpleSAML\Test\Utils\ClearStateTestCase /** * @return void */ - public function testSourcesMustBePresent() + public function testSourcesMustBePresent(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('The required "sources" config option was not found'); @@ -91,7 +91,7 @@ class MultiAuthTest extends \SimpleSAML\Test\Utils\ClearStateTestCase /** * @return void */ - public function testPreselectMustBeValid() + public function testPreselectMustBeValid(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('The optional "preselect" config option must be present in "sources"'); @@ -140,7 +140,7 @@ class MultiAuthTest extends \SimpleSAML\Test\Utils\ClearStateTestCase /** * @return void */ - public function testPreselectIsOptional() + public function testPreselectIsOptional(): void { $sourceConfig = Configuration::loadFromArray(array( 'example-multi' => array( @@ -196,7 +196,7 @@ class MultiAuthTest extends \SimpleSAML\Test\Utils\ClearStateTestCase /** * @return void */ - public function testPreselectCanBeConfigured() + public function testPreselectCanBeConfigured(): void { $state = []; @@ -215,7 +215,7 @@ class MultiAuthTest extends \SimpleSAML\Test\Utils\ClearStateTestCase /** * @return void */ - public function testStatePreselectHasPriority() + public function testStatePreselectHasPriority(): void { $state = ['multiauth:preselect' => 'example-admin']; diff --git a/tests/modules/saml/lib/Auth/Process/FilterScopesTest.php b/tests/modules/saml/lib/Auth/Process/FilterScopesTest.php index b51b850954e09f9c228b96f443b980d2590353a9..1c5c30bdec3b75b983508c304673ef8cbb6fa06b 100644 --- a/tests/modules/saml/lib/Auth/Process/FilterScopesTest.php +++ b/tests/modules/saml/lib/Auth/Process/FilterScopesTest.php @@ -33,7 +33,7 @@ class FilterScopesTest extends TestCase * Test valid scopes. * @return void */ - public function testValidScopes() + public function testValidScopes(): void { // test declared scopes $config = []; @@ -95,7 +95,7 @@ class FilterScopesTest extends TestCase * Test invalid scopes. * @return void */ - public function testInvalidScopes() + public function testInvalidScopes(): void { // test scope not matching anything, empty attribute $config = []; diff --git a/tests/modules/saml/lib/Auth/Process/NameIDAttributeTest.php b/tests/modules/saml/lib/Auth/Process/NameIDAttributeTest.php index d16ba4cc54fc2a613c11ce1eb570518ec3a1590a..91909565514df0d71260b4412df810cc88b3cf37 100644 --- a/tests/modules/saml/lib/Auth/Process/NameIDAttributeTest.php +++ b/tests/modules/saml/lib/Auth/Process/NameIDAttributeTest.php @@ -37,7 +37,7 @@ class NameIDAttributeTest extends TestCase * Test minimal configuration. * @return void */ - public function testMinimalConfig() + public function testMinimalConfig(): void { $config = []; $spId = 'eugeneSP'; @@ -68,7 +68,7 @@ class NameIDAttributeTest extends TestCase * Test custom attribute name. * @return void */ - public function testCustomAttributeName() + public function testCustomAttributeName(): void { $attributeName = 'eugeneNameIDAttribute'; $config = ['attribute' => $attributeName]; @@ -100,7 +100,7 @@ class NameIDAttributeTest extends TestCase * Test custom format. * @return void */ - public function testFormat() + public function testFormat(): void { $config = ['format' => '%V!%%']; $spId = 'eugeneSP'; @@ -185,7 +185,7 @@ class NameIDAttributeTest extends TestCase * Test custom attribute name with format. * @return void */ - public function testCustomAttributeNameAndFormat() + public function testCustomAttributeNameAndFormat(): void { $attributeName = 'eugeneNameIDAttribute'; $config = ['attribute' => $attributeName, 'format' => '%V']; diff --git a/tests/modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php b/tests/modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php index f9604be608b901843a991d6402ccbdd13e090caf..69f30e99cfb6a24c5e1dcbce8d15d5fed6122834 100644 --- a/tests/modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php +++ b/tests/modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php @@ -98,7 +98,7 @@ class SPTest extends ClearStateTestCase * * @return \SAML2\AuthnRequest The AuthnRequest generated. */ - private function createAuthnRequest($state = []) + private function createAuthnRequest(array $state = []): AuthnRequest { $info = ['AuthId' => 'default-sp']; $config = []; @@ -122,7 +122,7 @@ class SPTest extends ClearStateTestCase * @test * @return void */ - public function testAuthnRequest() + public function testAuthnRequest(): void { /** @var \SAML2\AuthnRequest $ar */ $ar = $this->createAuthnRequest(); @@ -151,7 +151,7 @@ class SPTest extends ClearStateTestCase * @test * @return void */ - public function testNameID() + public function testNameID(): void { $state = [ 'saml:NameID' => ['Value' => 'user@example.org', 'Format' => \SAML2\Constants::NAMEID_UNSPECIFIED] @@ -188,7 +188,7 @@ class SPTest extends ClearStateTestCase * @test * @return void */ - public function testAuthnContextClassRef() + public function testAuthnContextClassRef(): void { $state = [ 'saml:AuthnContextClassRef' => 'http://example.com/myAuthnContextClassRef' @@ -220,7 +220,7 @@ class SPTest extends ClearStateTestCase * @test * @return void */ - public function testForcedAuthn() + public function testForcedAuthn(): void { /** @var bool $state['ForceAuthn'] */ $state = [ @@ -251,7 +251,7 @@ class SPTest extends ClearStateTestCase * Test specifying an IDPList where no metadata found for those idps is an error * @return void */ - public function testIdpListWithNoMatchingMetadata() + public function testIdpListWithNoMatchingMetadata(): void { $this->expectException(NoSupportedIDP::class); $state = [ @@ -269,7 +269,7 @@ class SPTest extends ClearStateTestCase * Test specifying an IDPList where the list does not overlap with the Idp specified in SP config is an error * @return void */ - public function testIdpListWithExplicitIdpNotMatch() + public function testIdpListWithExplicitIdpNotMatch(): void { $this->expectException(NoAvailableIDP::class); $entityId = "https://example.com"; @@ -297,7 +297,7 @@ class SPTest extends ClearStateTestCase * Test that IDPList overlaps with the IDP specified in SP config results in AuthnRequest * @return void */ - public function testIdpListWithExplicitIdpMatch() + public function testIdpListWithExplicitIdpMatch(): void { $entityId = "https://example.com"; $xml = MetaDataStorageSourceTest::generateIdpMetadataXml($entityId); @@ -339,7 +339,7 @@ class SPTest extends ClearStateTestCase * Test that IDPList with a single valid idp and no SP config idp results in AuthnRequest to that idp * @return void */ - public function testIdpListWithSingleMatch() + public function testIdpListWithSingleMatch(): void { $entityId = "https://example.com"; $xml = MetaDataStorageSourceTest::generateIdpMetadataXml($entityId); @@ -379,7 +379,7 @@ class SPTest extends ClearStateTestCase * Test that IDPList with multiple valid idp and no SP config idp results in discovery redirect * @return void */ - public function testIdpListWithMultipleMatch() + public function testIdpListWithMultipleMatch(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid URL: smtp://invalidurl'); diff --git a/tests/modules/saml/lib/IdP/SAML2Test.php b/tests/modules/saml/lib/IdP/SAML2Test.php index b2bcd5ab558feb2d3104c3be657450d841ebc929..2536f28e1d6208108b50d5505de2e9c21e89fbf2 100644 --- a/tests/modules/saml/lib/IdP/SAML2Test.php +++ b/tests/modules/saml/lib/IdP/SAML2Test.php @@ -38,7 +38,7 @@ class SAML2Test extends ClearStateTestCase * Test that invoking the idp initiated endpoint with the minimum necessary parameters works. * @return void */ - public function testIdPInitiatedLoginMinimumParams() + public function testIdPInitiatedLoginMinimumParams(): void { $state = $this->idpInitiatedHelper(['spentityid' => 'https://some-sp-entity-id']); $this->assertEquals('https://some-sp-entity-id', $state['SPMetadata']['entityid']); @@ -63,7 +63,7 @@ class SAML2Test extends ClearStateTestCase * Test that invoking the idp initiated endpoint with the optional parameters works. * @return void */ - public function testIdPInitiatedLoginOptionalParams() + public function testIdPInitiatedLoginOptionalParams(): void { $state = $this->idpInitiatedHelper([ 'spentityid' => 'https://some-sp-entity-id', @@ -98,7 +98,7 @@ class SAML2Test extends ClearStateTestCase * Test that invoking the idp initiated endpoint using minimum shib params works * @return void */ - public function testIdPInitShibCompatyMinimumParams() + public function testIdPInitShibCompatyMinimumParams(): void { //https://wiki.shibboleth.net/confluence/display/IDP30/UnsolicitedSSOConfiguration // Shib uses the param providerId instead of spentityid @@ -125,7 +125,7 @@ class SAML2Test extends ClearStateTestCase * Test that invoking the idp initiated endpoint using minimum shib params works * @return void */ - public function testIdPInitShibCompatOptionalParams() + public function testIdPInitShibCompatOptionalParams(): void { $state = $this->idpInitiatedHelper([ 'providerId' => 'https://some-sp-entity-id', diff --git a/tests/modules/saml/lib/IdP/SQLNameIDTest.php b/tests/modules/saml/lib/IdP/SQLNameIDTest.php index 1cac60f4cca907e22cd93f475c6fab33cc109382..aa6513e1e16c96c7624df1dbd0928dc67844609d 100644 --- a/tests/modules/saml/lib/IdP/SQLNameIDTest.php +++ b/tests/modules/saml/lib/IdP/SQLNameIDTest.php @@ -22,7 +22,7 @@ class SQLNameIDTest extends TestCase * @param array $config * @return void */ - private function addGetDelete(array $config = []) + private function addGetDelete(array $config = []): void { SQLNameID::add('idp', 'sp', 'user', 'value', $config); $this->assertEquals('value', SQLNameID::get('idp', 'sp', 'user', $config)); @@ -30,12 +30,13 @@ class SQLNameIDTest extends TestCase $this->assertNull(SQLNameID::get('idp', 'sp', 'user', $config)); } + /** * Test Store. * @test * @return void */ - public function testSQLStore() + public function testSQLStore(): void { Configuration::loadFromArray([ 'store.type' => 'sql', @@ -50,12 +51,13 @@ class SQLNameIDTest extends TestCase $this->clearInstance($store, Store::class); } + /** * Test incompatible Store. * @test * @return void */ - public function testIncompatibleStore() + public function testIncompatibleStore(): void { Configuration::loadFromArray([ 'store.type' => 'memcache', @@ -71,12 +73,13 @@ class SQLNameIDTest extends TestCase $this->clearInstance($store, Store::class); } + /** * Test Database. * @test * @return void */ - public function testDatabase() + public function testDatabase(): void { $config = [ 'database.dsn' => 'sqlite::memory:', @@ -95,12 +98,13 @@ class SQLNameIDTest extends TestCase $this->addGetDelete($config); } + /** * @param \SimpleSAML\Configuration|\SimpleSAML\Store $service * @param class-string $className * @return void */ - protected function clearInstance($service, $className) + protected function clearInstance($service, string $className): void { $reflectedClass = new \ReflectionClass($className); $reflectedInstance = $reflectedClass->getProperty('instance');