diff --git a/tests/SigningTestCase.php b/tests/SigningTestCase.php index c3d8d30431680b014b1be45a923695697fe9fac3..95714f23006c57476a4a420d2b142431833203cc 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 0abe90fa4f0581af0dcc2f6f98cf75c4b87cdf4e..000bf57df9b3e47cb67ccb53dad9861d2276bc12 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 474c39a37cb29dd470eab1ab95c53c82c65a1846..eb0bade19225f9f0965bf8f7b8fd8c9156ef97d9 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([ @@ -552,7 +552,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, @@ -566,7 +566,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, @@ -582,7 +582,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, @@ -776,7 +776,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([ @@ -881,7 +881,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!', @@ -900,7 +900,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([ @@ -914,7 +914,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([ @@ -928,7 +928,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([ @@ -942,7 +942,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'); @@ -953,7 +953,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' @@ -971,7 +971,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 95b4671e2056e6d51431c33ce3846b162f80a0a9..2a059c8c6ca277982b89b3ba0050b1413d1a6dfd 100644 --- a/tests/lib/SimpleSAML/DatabaseTest.php +++ b/tests/lib/SimpleSAML/DatabaseTest.php @@ -86,7 +86,7 @@ class DatabaseTest extends TestCase * @test * @return void */ - public function connectionFailure() + public function connectionFailure(): void { $this->expectException(\Exception::class); $config = [ @@ -111,7 +111,7 @@ class DatabaseTest extends TestCase * @test * @return void */ - public function instances() + public function instances(): void { $config = [ 'database.dsn' => 'sqlite::memory:', @@ -181,7 +181,7 @@ class DatabaseTest extends TestCase * @test * @return void */ - public function slaves() + public function slaves(): void { $ref = new ReflectionClass($this->db); $dbMaster = $ref->getProperty('dbMaster'); @@ -234,7 +234,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"; @@ -252,7 +252,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); @@ -284,7 +284,7 @@ class DatabaseTest extends TestCase * @test * @return void */ - public function readFailure() + public function readFailure(): void { $this->expectException(\Exception::class); $table = $this->db->applyPrefix("sspdbt"); @@ -300,7 +300,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 7a138d6bfc4ab27e403d36308f67dcf7ec8a3738..3ae4de9d79da7605c8a8761960800a872f39fada 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 { $c = Configuration::loadFromArray([]); $l = new Localization($c); @@ -36,7 +36,7 @@ class LocalizationTest extends TestCase * Test SimpleSAML\Locale\Localization::activateDomain(). * @return void */ - public function testAddDomain() + public function testAddDomain(): void { $c = Configuration::loadFromArray([]); $l = new Localization($c); diff --git a/tests/lib/SimpleSAML/Locale/TranslateTest.php b/tests/lib/SimpleSAML/Locale/TranslateTest.php index 3ff26ff0c2bd774f11a6aff790e318f90fbae074..534d2660bd23aa1dc713f64c4865ee2ff132bb05 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 2c9b74d9890e2bc85a957e33bc9e0a97bc0f103e..bdd1e90d11dede149f47eecd64d1e40cf1119ac6 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'; @@ -97,7 +97,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'; @@ -153,7 +153,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'; @@ -198,7 +198,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 279990d53c4fb4f114b890d480964a6e4e432f44..ac5187ce07556af692c392cd5ae3b29c81ea1926 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( @@ -182,7 +182,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 ff47cd55a7b8a8c3c183c0af9c491bd072fe22a9..a7c8e5ba099605b57ba9e8a860960941018ce29a 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 92b6dc53c0475dc8a07bc7a484d23ff516498db2..6041142c25a736f139d61e6c2581b33cc98aad15 100644 --- a/tests/lib/SimpleSAML/Store/RedisTest.php +++ b/tests/lib/SimpleSAML/Store/RedisTest.php @@ -68,9 +68,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; } @@ -81,7 +81,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; } @@ -93,7 +93,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); @@ -104,7 +104,7 @@ class RedisTest extends TestCase * @param string $key * @return void */ - public function delMocked($key) + public function delMocked(string $key): void { unset($this->config[$key]); } @@ -116,7 +116,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testRedisInstance() + public function testRedisInstance(): void { $config = Configuration::loadFromArray([ 'store.type' => 'redis', @@ -139,7 +139,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testRedisInstanceWithPassword() + public function testRedisInstanceWithPassword(): void { $config = Configuration::loadFromArray([ 'store.type' => 'redis', @@ -163,7 +163,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testInsertData() + public function testInsertData(): void { $value = 'TEST'; @@ -181,7 +181,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testInsertExpiringData() + public function testInsertExpiringData(): void { $value = 'TEST'; @@ -198,7 +198,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testGetEmptyData() + public function testGetEmptyData(): void { $res = $this->redis->get('test', 'key'); @@ -212,7 +212,7 @@ class RedisTest extends TestCase * @test * @return void */ - public function testOverwriteData() + public function testOverwriteData(): void { $value1 = 'TEST1'; $value2 = 'TEST2'; @@ -233,7 +233,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'); @@ -248,7 +248,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 485cd272986dd67442266dea1ed64fa277c5d1e7..8dd5f19e504c6a64c308c961b9f9fd567fe8e749 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 1b4cfd1e6d58185aa4f06fe082d961f63a7d0d77..7417b53b89ccd0fa8ed2bf7b934fafca2b702645 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 d99e2072932805820d0c778806ba085500885635..b565377001f812787f3b3cfaa9a842c5e0df0ecc 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 bad arrays $this->assertFalse( diff --git a/tests/lib/SimpleSAML/Utils/AttributesTest.php b/tests/lib/SimpleSAML/Utils/AttributesTest.php index c8221982974a3ad39400e81296009218f52e2d70..a3c8d5dd01225ed59f88379a2a525f806a70c142 100644 --- a/tests/lib/SimpleSAML/Utils/AttributesTest.php +++ b/tests/lib/SimpleSAML/Utils/AttributesTest.php @@ -19,7 +19,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 = [ @@ -38,7 +38,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 = [ @@ -55,7 +55,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 = [ @@ -72,7 +72,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 = [ @@ -94,7 +94,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'; @@ -118,7 +118,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']); @@ -129,7 +129,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]); @@ -140,7 +140,7 @@ class AttributesTest extends TestCase * Test the normalizeAttributesArray() function. * @return void */ - public function testNormalizeAttributesArray() + public function testNormalizeAttributesArray(): void { $attributes = [ 'key1' => 'value1', @@ -164,7 +164,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 7264c87a456eaf3dddfe6af09920f498bc3cf893..17cd4d361a95d7ed06348ad6b16e7860539e8fbb 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 missing type $contact = [ @@ -226,7 +226,7 @@ class MetadataTest extends TestCase * Test \SimpleSAML\Utils\Config\Metadata::isHiddenFromDiscovery(). * @return void */ - public function testIsHiddenFromDiscovery() + public function testIsHiddenFromDiscovery(): void { // test for success $metadata = [ @@ -267,7 +267,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 3cb9cbc3816dc0bc6dc478c8568704ed314194b6..3426d0aa15380aa4739cb014862d01112a45de96 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----- @@ -148,7 +148,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::pwValid * @return void */ - public function testGoodPwValid() + public function testGoodPwValid(): void { $pw = "password"; @@ -163,7 +163,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::pwValid * @return void */ - public function testBadPwInvalid() + public function testBadPwInvalid(): void { $pw = "password"; $pw2 = "password2"; @@ -179,7 +179,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::secureCompare * @return void */ - public function testSecureCompareEqual() + public function testSecureCompareEqual(): void { $res = Crypto::secureCompare("string", "string"); @@ -191,7 +191,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::secureCompare * @return void */ - public function testSecureCompareNotEqual() + public function testSecureCompareNotEqual(): void { $res = Crypto::secureCompare("string1", "string2"); @@ -203,7 +203,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'); @@ -217,7 +217,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPrivateKey * @return void */ - public function testLoadPrivateKeyNotRequiredMetadataMissing() + public function testLoadPrivateKeyNotRequiredMetadataMissing(): void { $config = new Configuration([], 'test'); $required = false; @@ -232,7 +232,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'); @@ -245,7 +245,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPrivateKey * @return void */ - public function testLoadPrivateKeyBasic() + public function testLoadPrivateKeyBasic(): void { $filename = $this->certdir . DIRECTORY_SEPARATOR . 'key'; $data = 'data'; @@ -265,7 +265,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPrivateKey * @return void */ - public function testLoadPrivateKeyPassword() + public function testLoadPrivateKeyPassword(): void { $password = 'password'; $filename = $this->certdir . DIRECTORY_SEPARATOR . 'key'; @@ -292,7 +292,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPrivateKey * @return void */ - public function testLoadPrivateKeyPrefix() + public function testLoadPrivateKeyPrefix(): void { $prefix = 'prefix'; $password = 'password'; @@ -320,7 +320,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'); @@ -334,7 +334,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPublicKey * @return void */ - public function testLoadPublicKeyNotRequiredMetadataMissing() + public function testLoadPublicKeyNotRequiredMetadataMissing(): void { $config = new Configuration([], 'test'); $required = false; @@ -349,7 +349,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPublicKey * @return void */ - public function testLoadPublicKeyNotX509Certificate() + public function testLoadPublicKeyNotX509Certificate(): void { $config = new Configuration( [ @@ -374,7 +374,7 @@ PHP; * @covers \SimpleSAML\Utils\Crypto::loadPublicKey * @return void */ - public function testLoadPublicKeyNotSigning() + public function testLoadPublicKeyNotSigning(): void { $config = new Configuration( [ @@ -399,7 +399,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 8dc6598b242bf1258487afac64a56d1353cbb42e..8bdcbb24b72d42f098b6ea36a71d0aabf82b2ba7 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 b5959b525ca626c4b22a92b63178ee2535f03ac7..ec02f02267ee333b0e1ed166a20ab2d49f2fe1ce 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); @@ -47,7 +47,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::addURLParameters(). * @return void */ - public function testAddURLParameters() + public function testAddURLParameters(): void { $url = 'http://example.com/'; $params = [ @@ -75,7 +75,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::guessBasePath(). * @return void */ - public function testGuessBasePath() + public function testGuessBasePath(): void { $original = $_SERVER; @@ -119,7 +119,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; @@ -139,7 +139,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; @@ -168,7 +168,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::getSelfURL(). * @return void */ - public function testGetSelfURLMethods() + public function testGetSelfURLMethods(): void { $original = $_SERVER; @@ -295,7 +295,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::checkURLAllowed(), without regex. * @return void */ - public function testCheckURLAllowedWithoutRegex() + public function testCheckURLAllowedWithoutRegex(): void { $original = $_SERVER; @@ -327,7 +327,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::checkURLAllowed(), with regex. * @return void */ - public function testCheckURLAllowedWithRegex() + public function testCheckURLAllowedWithRegex(): void { $original = $_SERVER; @@ -361,7 +361,7 @@ class HTTPTest extends ClearStateTestCase * Test SimpleSAML\Utils\HTTP::getServerPort(). * @return void */ - public function testGetServerPort() + public function testGetServerPort(): void { $original = $_SERVER; @@ -408,7 +408,7 @@ class HTTPTest extends ClearStateTestCase * subdomain of an evil domain. * @return void */ - public function testCheckURLAllowedWithRegexWithoutDelimiters() + public function testCheckURLAllowedWithRegexWithoutDelimiters(): void { $original = $_SERVER; @@ -430,7 +430,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'; @@ -439,13 +439,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([ @@ -496,11 +497,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); @@ -516,13 +518,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 9938ceaf480f8ae651798117a799113af57923da..ceb96534f6a47d7649ec93190cf63e7bfd586f1c 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'; @@ -163,7 +163,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); @@ -183,7 +183,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); @@ -207,7 +207,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); @@ -231,7 +231,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); @@ -251,7 +251,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); @@ -271,7 +271,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); @@ -304,7 +304,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 13817d424d84c5f23c13b882de53e48e9685c897..7319fe57bfe00e5c0beadaf175d775ca24e6d751 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 f2220edb9337792d28efadb66fef070f8d3aaaf7..2bafc5627f0933bdda49590a4c34b8ecbb6bda63 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,14 @@ 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); + $expected = 'Failed to parse XML string for schema validation'; $this->assertStringContainsString($expected, $res); } @@ -394,7 +395,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 +411,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 b86fdc0600ea7d36510b3de587593616623220d6..82ca0c1b6ea8dc887d8ddb6e1efd325fa141523d 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 a6fd021fac1b0548521386951ff2f6fe0f454fdd..57535821d3ee87404132dc9390bed826d60a9e72 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 c182cd88982e2632bf5329a48d76c2ee099fa725..afbcd2276403d0a16bea7f1f3576495c7b303547 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 testIsNodeValidatedSuccess() + public function testIsNodeValidatedSuccess(): void { $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0"?><node>value</node>'); @@ -91,7 +91,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 5b43c57359cfb987e3a254da91d549a1a0196b69..7a2155b3801e90c6bd95ba28deac496c2b7af823 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 8c56658eb3863f2bbba1af337857ebf20c012d44..b95978fa61f7944f1f12b3c6cc16a8ad6c6daf27 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 7716ef151f784a62f7ac4f85b2f059618420d687..ebeb8ed1a56744613d8ba57e12cae71043177de7 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->expectExceptionMessageMatches('/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->expectExceptionMessageMatches('/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->expectExceptionMessageMatches('/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->expectExceptionMessageMatches('/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->expectExceptionMessageMatches('/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 f92401820aa1c892dc44296b4bf8385fe8ee36b9..e3af95c1ba4b7ac68207db47fc9529d4e267c036 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'); @@ -90,7 +90,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 4862f5e1d929abe00c72827a92e5a55dd97e145a..d25d85d2fd595981e9bec868340ce88281dd7bc1 100644 --- a/tests/modules/core/lib/Controller/LoginTest.php +++ b/tests/modules/core/lib/Controller/LoginTest.php @@ -71,7 +71,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'); @@ -97,7 +97,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( @@ -133,7 +133,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'); @@ -151,7 +151,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'); @@ -190,7 +190,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'); @@ -212,7 +212,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'); @@ -233,7 +233,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 892c5b0397290a7eb4ecbc5406598a7a152ad154..493ce0a34f6e1bbbe0352d363b654252d916ff02 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 bbed662671adfebe93863c3d2a82ebe4776b912d..494fc40bc194a43207c86b74167475d87023580b 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 a09455bf20610e4c1727aba582e2f750c5e5c78e..793d4f85a0ff4ee92d165f4623b5ef0ea76af1c1 100644 --- a/tests/modules/saml/lib/Auth/Process/NameIDAttributeTest.php +++ b/tests/modules/saml/lib/Auth/Process/NameIDAttributeTest.php @@ -36,7 +36,7 @@ class NameIDAttributeTest extends TestCase * Test minimal configuration. * @return void */ - public function testMinimalConfig() + public function testMinimalConfig(): void { $config = []; $spId = 'eugeneSP'; @@ -67,7 +67,7 @@ class NameIDAttributeTest extends TestCase * Test custom attribute name. * @return void */ - public function testCustomAttributeName() + public function testCustomAttributeName(): void { $attributeName = 'eugeneNameIDAttribute'; $config = ['attribute' => $attributeName]; @@ -99,7 +99,7 @@ class NameIDAttributeTest extends TestCase * Test custom format. * @return void */ - public function testFormat() + public function testFormat(): void { $config = ['format' => '%V']; $spId = 'eugeneSP'; @@ -129,7 +129,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 2e8838611c3087687f3ec99f7cd01aa6057f18de..023a1be0c6115f82515c9c01539de555d3db1d12 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 { $ar = $this->createAuthnRequest(); @@ -148,7 +148,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] @@ -183,7 +183,7 @@ class SPTest extends ClearStateTestCase * @test * @return void */ - public function testAuthnContextClassRef() + public function testAuthnContextClassRef(): void { $state = [ 'saml:AuthnContextClassRef' => 'http://example.com/myAuthnContextClassRef' @@ -213,7 +213,7 @@ class SPTest extends ClearStateTestCase * @test * @return void */ - public function testForcedAuthn() + public function testForcedAuthn(): void { /** @var bool $state['ForceAuthn'] */ $state = [ @@ -242,7 +242,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 = [ @@ -260,7 +260,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"; @@ -288,7 +288,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); @@ -330,7 +330,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); @@ -370,7 +370,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 664373b9c94b6eb2ca5a892210713b8ec9bffb85..301c1c72ef977dbfeea49d2c80e1ac23fa598050 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'); diff --git a/tests/www/RouterTest.php b/tests/www/RouterTest.php index 50f8a4dad18ea5b9012dde7e47348f2e6b54d556..e552036b5644ae34f4cf523b2590701f684219d3 100644 --- a/tests/www/RouterTest.php +++ b/tests/www/RouterTest.php @@ -15,7 +15,7 @@ class RouterTest extends TestCase /** * @return void */ - public function testSyntax() + public function testSyntax(): void { $config = Configuration::loadFromArray([ 'module.enable' => array_fill_keys(Module::getModules(), true),