diff --git a/lib/SimpleSAML/Locale/Translate.php b/lib/SimpleSAML/Locale/Translate.php index c9e7a223d62e59d4db53530b353dc9212618f695..2b577fdc56a326a11ac249ed2c510c45672d2b64 100644 --- a/lib/SimpleSAML/Locale/Translate.php +++ b/lib/SimpleSAML/Locale/Translate.php @@ -541,7 +541,7 @@ class Translate $priorities = $langcfg->getArray('priorities', []); } - if ( !empty($priorities[$context['currentLanguage']]) ) { + if (!empty($priorities[$context['currentLanguage']])) { foreach ($priorities[$context['currentLanguage']] as $lang) { if (isset($translations[$lang])) { return $translations[$lang]; diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php index 794e825430fef1ce3514e85cf1f4b0def117e642..51449f95f970297a48f2fe11bfe1278ac43a04f9 100644 --- a/lib/SimpleSAML/XHTML/IdPDisco.php +++ b/lib/SimpleSAML/XHTML/IdPDisco.php @@ -595,31 +595,34 @@ class IdPDisco $tryLanguages = [0 => $language, 1 => $defaultLanguage, 2 => $fallbackLanguage]; $newlist = []; - foreach($idpList as $entityid => $data) { + foreach ($idpList as $entityid => $data) { $newlist[$entityid]['entityid'] = $entityid; - foreach ( $tryLanguages as $lang ) { - if ( $name = $this->getEntityDisplayName($data, $lang) ) { + foreach ($tryLanguages as $lang) { + if ($name = $this->getEntityDisplayName($data, $lang)) { $newlist[$entityid]['name'] = $name; continue; } } - if ( empty($newlist[$entityid]['name']) ) { + if (empty($newlist[$entityid]['name'])) { $newlist[$entityid]['name'] = $entityid; } - foreach ( $tryLanguages as $lang ) { - if ( !empty($data['description'][$lang]) ) { + foreach ($tryLanguages as $lang) { + if (!empty($data['description'][$lang])) { $newlist[$entityid]['description'] = $data['description'][$lang]; continue; } } - if ( !empty($data['icon']) ) { + if (!empty($data['icon'])) { $newlist[$entityid]['icon'] = $data['icon']; $newlist[$entityid]['iconurl'] = \SimpleSAML\Utils\HTTP::resolveURL($data['icon']); } } - usort($newlist, function($idpentry1, $idpentry2) { - return strcasecmp($idpentry1['name'],$idpentry2['name']); - }); + usort( + $newlist, + function ($idpentry1, $idpentry2) { + return strcasecmp($idpentry1['name'], $idpentry2['name']); + } + ); $t->data['idplist'] = $newlist; $t->data['preferredidp'] = $preferredIdP; @@ -633,11 +636,11 @@ class IdPDisco private function getEntityDisplayName(array $idpData, $language) { - if(isset($idpData['UIInfo']['DisplayName'][$language]) ) { + if (isset($idpData['UIInfo']['DisplayName'][$language])) { return $idpData['UIInfo']['DisplayName'][$language]; - } elseif ( isset($idpData['name'][$language]) ) { + } elseif (isset($idpData['name'][$language])) { return $idpData['name'][$language]; - } elseif ( isset($idpData['OrganizationDisplayName'][$language]) ) { + } elseif (isset($idpData['OrganizationDisplayName'][$language])) { return $idpData['OrganizationDisplayName'][$language]; } return null; diff --git a/tests/BuiltInServer.php b/tests/BuiltInServer.php index e98a4a61c43341ebdd426d964d1596f8ffda7408..0695e8c7eed2d5a37ffbe53596881130a6f92ad0 100644 --- a/tests/BuiltInServer.php +++ b/tests/BuiltInServer.php @@ -9,7 +9,6 @@ namespace SimpleSAML\Test; - class BuiltInServer { diff --git a/tests/lib/SimpleSAML/Auth/StateTest.php b/tests/lib/SimpleSAML/Auth/StateTest.php index 210d7ddfc9e22354890a0cfdf8e41f4aae23e757..481105559880aa8a73f76887be4c5f348cd9946d 100644 --- a/tests/lib/SimpleSAML/Auth/StateTest.php +++ b/tests/lib/SimpleSAML/Auth/StateTest.php @@ -5,14 +5,13 @@ use PHPUnit\Framework\TestCase; /** * Tests for \SimpleSAML\Auth\State */ -class Auth_StateTest extends TestCase +class StateTest extends TestCase { /** * Test the getPersistentAuthData() function. */ public function testGetPersistentAuthData() { - $mandatory = [ 'Attributes' => [], 'Expire' => 1234, diff --git a/tests/lib/SimpleSAML/ConfigurationTest.php b/tests/lib/SimpleSAML/ConfigurationTest.php index 9f7d4dcd385d742bf94fa10e98280a7d7f38bc22..379612bd909d6dd5e943ed7ec51865d72ca7750f 100644 --- a/tests/lib/SimpleSAML/ConfigurationTest.php +++ b/tests/lib/SimpleSAML/ConfigurationTest.php @@ -5,7 +5,7 @@ use \SimpleSAML\Configuration; /** * Tests for \SimpleSAML\Configuration */ -class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase +class ConfigurationTest extends SimpleSAML\Test\Utils\ClearStateTestCase { /** * Test \SimpleSAML\Configuration::getVersion() @@ -364,7 +364,8 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase /** * Test \SimpleSAML\Configuration::getValueValidate() */ - public function testGetValueValidate() { + public function testGetValueValidate() + { $c = Configuration::loadFromArray([ 'opt' => 'b', ]); @@ -439,7 +440,8 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase } /** - * Test \SimpleSAML\Configuration::getArrayizeString() option with an array that contains something that isn't a string. + * Test \SimpleSAML\Configuration::getArrayizeString() option + * with an array that contains something that isn't a string. * @expectedException Exception */ public function testGetArrayizeStringWrongValue() diff --git a/tests/lib/SimpleSAML/Locale/LocalizationTest.php b/tests/lib/SimpleSAML/Locale/LocalizationTest.php index 0d67caa0ed42b785ec037f5204cd44d6187b9ff4..cc58f1ebe66632efcd6ffac4b9d4ce21e5391c8a 100644 --- a/tests/lib/SimpleSAML/Locale/LocalizationTest.php +++ b/tests/lib/SimpleSAML/Locale/LocalizationTest.php @@ -45,5 +45,4 @@ class LocalizationTest extends TestCase $this->assertArrayHasKey($newDomain, $registeredDomains); $this->assertEquals($registeredDomains[$newDomain], $newDomainLocaleDir); } - } diff --git a/tests/lib/SimpleSAML/Metadata/MetaDataStorageSourceTest.php b/tests/lib/SimpleSAML/Metadata/MetaDataStorageSourceTest.php index ce301db53d5c21324ebd4a9b7486810e54cddf3d..b2ae04291930248b5319a9196ed63782d19a7d90 100644 --- a/tests/lib/SimpleSAML/Metadata/MetaDataStorageSourceTest.php +++ b/tests/lib/SimpleSAML/Metadata/MetaDataStorageSourceTest.php @@ -10,7 +10,8 @@ class MetaDataStorageSourceTest extends PHPUnit_Framework_TestCase * Test \SimpleSAML\Metadata\MetaDataStorageSourceTest::getConfig XML bad source * @expectedException \Exception */ - public function testBadXMLSource() { + public function testBadXMLSource() + { \SimpleSAML\Metadata\MetaDataStorageSource::getSource(["type"=>"xml", "foo"=>"baa"]); } @@ -18,7 +19,8 @@ class MetaDataStorageSourceTest extends PHPUnit_Framework_TestCase * Test \SimpleSAML\Metadata\MetaDataStorageSourceTest::getConfig invalid static XML source * @expectedException Exception */ - public function testInvalidStaticXMLSource() { + public function testInvalidStaticXMLSource() + { $strTestXML = " <EntityDescriptor ID=\"_12345678-90ab-cdef-1234-567890abcdef\" entityID=\"https://saml.idp/entityid\" xmlns=\"urn:oasis:names:tc:SAML:2.0:metadata\"> </EntityDescriptor> @@ -29,7 +31,8 @@ class MetaDataStorageSourceTest extends PHPUnit_Framework_TestCase /** * Test \SimpleSAML\Metadata\MetaDataStorageSourceTest::getConfig XML static XML source */ - public function testStaticXMLSource() { + public function testStaticXMLSource() + { $testEntityId = "https://saml.idp/entityid"; $strTestXML = " <EntityDescriptor ID=\"_12345678-90ab-cdef-1234-567890abcdef\" entityID=\"$testEntityId\" xmlns=\"urn:oasis:names:tc:SAML:2.0:metadata\"> @@ -49,8 +52,8 @@ xmlns:fed=\"http://docs.oasis-open.org/wsfed/federation/200706\"> // As a secondary thing, check that the entity ID from the static source provided can be extracted $source = \SimpleSAML\Metadata\MetaDataStorageSource::getSource(["type"=>"xml", "xml"=>$strTestXML]); $idpSet = $source->getMetadataSet("saml20-idp-remote"); - $this->assertArrayHasKey($testEntityId, $idpSet, "Did not extract expected IdP entity ID from static XML source"); - // Finally verify that a different entity ID does not get loaded + $this->assertArrayHasKey($testEntityId, $idpSet, "Did not extract expected IdP entity ID from static XML source"); + // Finally verify that a different entity ID does not get loaded $this->assertCount(1, $idpSet, "Unexpectedly got metadata for an alternate entity than that defined"); } } diff --git a/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php b/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php index c06cb54672d07d53723fd2e24bb6b2e42a25a84a..04f88d1ec48967151a7a5423b21a5f4e5c7e14f4 100644 --- a/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php +++ b/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php @@ -160,26 +160,26 @@ class SAMLBuilderTest extends TestCase $spDesc = $samlBuilder->getEntityDescriptor(); $acs = $spDesc->getElementsByTagName("AttributeConsumingService"); - $acs1 = $acs->item(0); + $acs1 = $acs->item(0); $this->assertFalse($acs1->hasAttribute("isDefault")); - $metadata['attributes.isDefault'] = true; + $metadata['attributes.isDefault'] = true; $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $spDesc = $samlBuilder->getEntityDescriptor(); $acs = $spDesc->getElementsByTagName("AttributeConsumingService"); - $acs1 = $acs->item(0); + $acs1 = $acs->item(0); $this->assertTrue($acs1->hasAttribute("isDefault")); $this->assertEquals("true", $acs1->getAttribute("isDefault")); - $metadata['attributes.isDefault'] = false; + $metadata['attributes.isDefault'] = false; $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $spDesc = $samlBuilder->getEntityDescriptor(); $acs = $spDesc->getElementsByTagName("AttributeConsumingService"); - $acs1 = $acs->item(0); + $acs1 = $acs->item(0); $this->assertTrue($acs1->hasAttribute("isDefault")); $this->assertEquals("false", $acs1->getAttribute("isDefault")); } @@ -207,18 +207,18 @@ class SAMLBuilderTest extends TestCase $spDesc = $samlBuilder->getEntityDescriptor(); $acs = $spDesc->getElementsByTagName("AttributeConsumingService"); - $acs1 = $acs->item(0); + $acs1 = $acs->item(0); $this->assertTrue($acs1->hasAttribute("index")); $this->assertEquals("0", $acs1->getAttribute("index")); - $metadata['attributes.index'] = 15; + $metadata['attributes.index'] = 15; $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $spDesc = $samlBuilder->getEntityDescriptor(); $acs = $spDesc->getElementsByTagName("AttributeConsumingService"); - $acs1 = $acs->item(0); + $acs1 = $acs->item(0); $this->assertTrue($acs1->hasAttribute("index")); $this->assertEquals("15", $acs1->getAttribute("index")); } diff --git a/tests/lib/SimpleSAML/Metadata/SAMLParserTest.php b/tests/lib/SimpleSAML/Metadata/SAMLParserTest.php index cfed7b198546d7e3c0a79b9d1840062afc2f9eb0..9db79a1cf42ab2aa6fbc6d35e8e2a23459d96d43 100644 --- a/tests/lib/SimpleSAML/Metadata/SAMLParserTest.php +++ b/tests/lib/SimpleSAML/Metadata/SAMLParserTest.php @@ -9,7 +9,6 @@ use PHPUnit\Framework\TestCase; */ class SAMLParserTest extends TestCase { - /** * Test Registration Info is parsed */ @@ -38,7 +37,6 @@ XML // RegistrationInfo is accessible in the SP or IDP metadata accessors $metadata = $entities['theEntityID']->getMetadata20SP(); $this->assertEquals($expected, $metadata['RegistrationInfo']); - } /** @@ -125,11 +123,14 @@ XML $this->assertEquals("Example service", $metadata['name']['en']); $this->assertEquals("Dit is een voorbeeld voor de unittest.", $metadata['description']['nl']); - $expected_a = ["urn:mace:dir:attribute-def:eduPersonPrincipalName", "urn:mace:dir:attribute-def:mail", "urn:mace:dir:attribute-def:displayName"]; + $expected_a = [ + "urn:mace:dir:attribute-def:eduPersonPrincipalName", + "urn:mace:dir:attribute-def:mail", + "urn:mace:dir:attribute-def:displayName" + ]; $expected_r = ["urn:mace:dir:attribute-def:eduPersonPrincipalName"]; $this->assertEquals($expected_a, $metadata['attributes']); $this->assertEquals($expected_r, $metadata['attributes.required']); } - } diff --git a/tests/modules/consent/lib/Auth/Process/ConsentTest.php b/tests/modules/consent/lib/Auth/Process/ConsentTest.php index d6b4e8b7158c50feaf7e94ef26f5d7b9c549a2d5..1f0b07eab339f117204d3145950affe155f50a58 100644 --- a/tests/modules/consent/lib/Auth/Process/ConsentTest.php +++ b/tests/modules/consent/lib/Auth/Process/ConsentTest.php @@ -209,10 +209,12 @@ class ConsentTest extends TestCase $this->assertEquals($instanceVars['focus']->getValue($testcase), $config['focus']); $this->assertEquals($instanceVars['hiddenAttributes']->getValue($testcase), $config['hiddenAttributes']); $this->assertEquals($instanceVars['noconsentattributes']->getValue($testcase), $config['attributes.exclude']); - $this->assertEquals($instanceVars['showNoConsentAboutService']->getValue($testcase), $config['showNoConsentAboutService']); + $this->assertEquals( + $instanceVars['showNoConsentAboutService']->getValue($testcase), + $config['showNoConsentAboutService'] + ); $deprecated = $reflection->newInstance(['noconsentattributes' => $config['attributes.exclude'],], null); $this->assertEquals($instanceVars['noconsentattributes']->getValue($deprecated), $config['attributes.exclude']); - } } diff --git a/tests/modules/core/lib/Auth/Process/AttributeAddTest.php b/tests/modules/core/lib/Auth/Process/AttributeAddTest.php index c84fbc95e14e36bb95c2b05f2ea3c96b17354652..fc7117f0c1a348f519cc85194e6ca2402d2b6ef4 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeAddTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeAddTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; /** * Test for the core:AttributeAdd filter. */ -class Test_Core_Auth_Process_AttributeAdd extends TestCase +class AttributeAddTest extends TestCase { /** diff --git a/tests/modules/core/lib/Auth/Process/AttributeAlterTest.php b/tests/modules/core/lib/Auth/Process/AttributeAlterTest.php index 45421547057821896c038fe6a8e7ab001c42930c..fe82b93acf2dba14fbc01af370bef6ddf336f1e6 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeAlterTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeAlterTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; /** * Test for the core:AttributeAlter filter. */ -class Test_Core_Auth_Process_AttributeAlter extends TestCase +class AttributeAlterTest extends TestCase { /** @@ -91,9 +91,11 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes, + $this->assertEquals( + $attributes, ['something' => ['somevalue'], - 'somethingelse' => ['someothervalue']]); + 'somethingelse' => ['someothervalue']] + ); } /** diff --git a/tests/modules/core/lib/Auth/Process/AttributeCopyTest.php b/tests/modules/core/lib/Auth/Process/AttributeCopyTest.php index cedd9432219d948c7fc97d9d95b1475a21cccc8d..6e1d923a1c81d6617a3b79e3464b897bf72506b3 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeCopyTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeCopyTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; /** * Test for the core:AttributeCopy filter. */ -class Test_Core_Auth_Process_AttributeCopy extends TestCase +class AttributeCopyTest extends TestCase { /** @@ -17,7 +17,7 @@ class Test_Core_Auth_Process_AttributeCopy extends TestCase */ private static function processFilter(array $config, array $request) { - $filter = new \SimpleSAML\Module\core\Auth\Process\AttributeCopy($config, NULL); + $filter = new \SimpleSAML\Module\core\Auth\Process\AttributeCopy($config, null); $filter->process($request); return $request; } diff --git a/tests/modules/core/lib/Auth/Process/AttributeLimitTest.php b/tests/modules/core/lib/Auth/Process/AttributeLimitTest.php index 9bc2260cea3e266123abb56939417f0a8c83fd3c..019cbaf1ed7187be161a7c173b19102e28e6a00a 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeLimitTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeLimitTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; /** * Test for the core:AttributeLimit filter. */ -class Test_Core_Auth_Process_AttributeLimitTest extends TestCase +class AttributeLimitTest extends TestCase { /** * Helper function to run the filter with a given configuration. @@ -16,7 +16,7 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase */ private static function processFilter(array $config, array $request) { - $filter = new \SimpleSAML\Module\core\Auth\Process\AttributeLimit($config, NULL); + $filter = new \SimpleSAML\Module\core\Auth\Process\AttributeLimit($config, null); $filter->process($request); return $request; } @@ -54,7 +54,7 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase $config = [ 'cn', - 'default' => TRUE, + 'default' => true, ]; $result = self::processFilter($config, $request); @@ -64,8 +64,6 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase $this->assertArrayNotHasKey('eduPersonTargetedID', $attributes); $this->assertArrayNotHasKey('eduPersonAffiliation', $attributes); $this->assertCount(2, $attributes); - - } /** @@ -100,7 +98,7 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase $config = [ 'cn', - 'default' => TRUE, + 'default' => true, ]; $result = self::processFilter($config, $request); @@ -139,7 +137,7 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase 'mail' => ['user@example.org'], ], 'Destination' => [ - 'attributes' => ['cn','mail'], + 'attributes' => ['cn','mail'], ], 'Source' => [ ], @@ -168,7 +166,7 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase public function testDefaultWithMetadata() { $config = [ - 'default' => TRUE, + 'default' => true, ]; $result = self::processFilter($config, self::$request); @@ -184,7 +182,7 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase public function testDefaultWithAttrs() { $config = [ - 'default' => TRUE, + 'default' => true, 'eduPersonTargetedID', 'eduPersonAffiliation', ]; @@ -205,7 +203,7 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase public function testInvalidConfig() { $config = [ - 'invalidArg' => TRUE, + 'invalidArg' => true, ]; self::processFilter($config, self::$request); @@ -219,7 +217,7 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase public function testInvalidAttributeName() { $config = [ - null + null ]; self::processFilter($config, self::$request); @@ -232,7 +230,7 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase public function testMatchAttributeValues() { $config = [ - 'eduPersonAffiliation' => ['member'] + 'eduPersonAffiliation' => ['member'] ]; $result = self::processFilter($config, self::$request); @@ -242,7 +240,7 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase $this->assertEquals($attributes['eduPersonAffiliation'], ['member']); $config = [ - 'eduPersonAffiliation' => ['member','staff'] + 'eduPersonAffiliation' => ['member','staff'] ]; $result = self::processFilter($config, self::$request); @@ -252,22 +250,22 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase $this->assertEquals($attributes['eduPersonAffiliation'], ['member']); $config = [ - 'eduPersonAffiliation' => ['student'] + 'eduPersonAffiliation' => ['student'] ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; $this->assertCount(0, $attributes); $config = [ - 'eduPersonAffiliation' => ['student','staff'] + 'eduPersonAffiliation' => ['student','staff'] ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; $this->assertCount(0, $attributes); } - public function testBadOptionsNotTreatedAsValidValues() { - + public function testBadOptionsNotTreatedAsValidValues() + { // Ensure really misconfigured ignoreCase and regex options are not interpretted as valid valus $config = [ 'eduPersonAffiliation' => ['ignoreCase' => 'member', 'nomatch'], @@ -282,7 +280,8 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase * Verify that the true value for ignoreCase doesn't get converted into a string ('1') by * php and matched against an attribute value of '1' */ - public function testThatIgnoreCaseOptionNotMatchBooleanAsStringValue() { + public function testThatIgnoreCaseOptionNotMatchBooleanAsStringValue() + { $config = [ 'someAttribute' => ['ignoreCase' => true, 'someValue'] ]; @@ -473,7 +472,7 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase public function testNoIntersection() { $config = [ - 'default' => TRUE, + 'default' => true, ]; $request = [ diff --git a/tests/modules/core/lib/Auth/Process/AttributeMapTest.php b/tests/modules/core/lib/Auth/Process/AttributeMapTest.php index 5c50f59bd533ddad04c7299028717dae6ade71eb..35ca925262cd1cd0edefab685ccb3043e0695b50 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeMapTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeMapTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; /** * Test for the core:AttributeMap filter. */ -class Test_Core_Auth_Process_AttributeMap extends TestCase +class AttributeMapTest extends TestCase { /** * Helper function to run the filter with a given configuration. diff --git a/tests/modules/core/lib/Auth/Process/AttributeRealmTest.php b/tests/modules/core/lib/Auth/Process/AttributeRealmTest.php index 9821cf275432cb06f2089d83ed03b7e6d053bcd2..85d5a2b1cfa7d35f82f2fc89c89524376c880986 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeRealmTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeRealmTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; /** * Test for the core:AttributeRealm filter. */ -class Test_Core_Auth_Process_AttributeRealm extends TestCase +class AttributeRealmTest extends TestCase { /** @@ -17,7 +17,7 @@ class Test_Core_Auth_Process_AttributeRealm extends TestCase */ private static function processFilter(array $config, array $request) { - $filter = new \SimpleSAML\Module\core\Auth\Process\AttributeRealm($config, NULL); + $filter = new \SimpleSAML\Module\core\Auth\Process\AttributeRealm($config, null); $filter->process($request); return $request; } diff --git a/tests/modules/core/lib/Auth/Process/CardinalitySingleTest.php b/tests/modules/core/lib/Auth/Process/CardinalitySingleTest.php index ebf43b9c5c42779bc80c67c0defcf5b6ff4406c8..dcd105f47242cdef49c1c7b129e9a19a408be3e1 100644 --- a/tests/modules/core/lib/Auth/Process/CardinalitySingleTest.php +++ b/tests/modules/core/lib/Auth/Process/CardinalitySingleTest.php @@ -7,7 +7,7 @@ if (class_exists('\PHPUnit\Framework\TestCase', true) and !class_exists('\PHPUni /** * Test for the core:CardinalitySingle filter. */ -class Test_Core_Auth_Process_CardinalitySingleTest extends \PHPUnit_Framework_TestCase +class CardinalitySingleTest extends \PHPUnit_Framework_TestCase { private $http; diff --git a/tests/modules/core/lib/Auth/Process/CardinalityTest.php b/tests/modules/core/lib/Auth/Process/CardinalityTest.php index da6e2e30d47bdcb9a8ab91174e0e7c6a2b7b11cd..c9d1bc971cdca6228b380f5a98360201fd934060 100644 --- a/tests/modules/core/lib/Auth/Process/CardinalityTest.php +++ b/tests/modules/core/lib/Auth/Process/CardinalityTest.php @@ -8,7 +8,7 @@ if (class_exists('\PHPUnit\Framework\TestCase', true) and !class_exists('\PHPUni /** * Test for the core:Cardinality filter. */ -class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase +class CardinalityTest extends \PHPUnit_Framework_TestCase { private $http; diff --git a/tests/modules/core/lib/Auth/Process/PHPTest.php b/tests/modules/core/lib/Auth/Process/PHPTest.php index 67bf33b706d36cc24e6675e47957944d45700df4..9ca6ff262c60550168bc5141a68e0a920aff4121 100644 --- a/tests/modules/core/lib/Auth/Process/PHPTest.php +++ b/tests/modules/core/lib/Auth/Process/PHPTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; /** * Test for the core:PHP filter. */ -class Test_Core_Auth_Process_PHP extends TestCase +class PHPTest extends TestCase { /** * Helper function to run the filter with a given configuration. diff --git a/tests/modules/core/lib/Auth/Process/ScopeAttributeTest.php b/tests/modules/core/lib/Auth/Process/ScopeAttributeTest.php index 6bc4d276f90dc7be8e59b0bced8ea9ca2874c64c..9a91a00419dc6ceb2295d6d75d370886da25e400 100644 --- a/tests/modules/core/lib/Auth/Process/ScopeAttributeTest.php +++ b/tests/modules/core/lib/Auth/Process/ScopeAttributeTest.php @@ -5,9 +5,8 @@ use PHPUnit\Framework\TestCase; /** * Test for the core:ScopeAttribute filter. */ -class Test_Core_Auth_Process_ScopeAttribute extends TestCase +class ScopeAttributeTest extends TestCase { - /* * Helper function to run the filter with a given configuration. * @@ -17,7 +16,7 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase */ private static function processFilter(array $config, array $request) { - $filter = new \SimpleSAML\Module\core\Auth\Process\ScopeAttribute($config, NULL); + $filter = new \SimpleSAML\Module\core\Auth\Process\ScopeAttribute($config, null); $filter->process($request); return $request; } @@ -63,7 +62,10 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['eduPersonScopedAffiliation'], ['library-walk-in@example.edu', 'member@example.com']); + $this->assertEquals( + $attributes['eduPersonScopedAffiliation'], + ['library-walk-in@example.edu', 'member@example.com'] + ); } /* @@ -170,7 +172,10 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['eduPersonScopedAffiliation'], ['member@example.com','staff@example.com','faculty@example.com']); + $this->assertEquals( + $attributes['eduPersonScopedAffiliation'], + ['member@example.com','staff@example.com','faculty@example.com'] + ); } /* @@ -194,26 +199,26 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase $this->assertEquals($attributes['eduPersonScopedAffiliation'], ['student@example.org']); } - /* - * When the target attribute exists and onlyIfEmpty is set - */ - public function testOnlyIfEmpty() - { - $config = [ + /* + * When the target attribute exists and onlyIfEmpty is set + */ + public function testOnlyIfEmpty() + { + $config = [ 'scopeAttribute' => 'schacHomeOrganization', 'sourceAttribute' => 'eduPersonAffiliation', 'targetAttribute' => 'eduPersonScopedAffiliation', - 'onlyIfEmpty' => true, - ]; + 'onlyIfEmpty' => true, + ]; $request = [ 'Attributes' => [ 'schacHomeOrganization' => ['example.org'], 'eduPersonAffiliation' => ['student'], - 'eduPersonScopedAffiliation' => ['staff@example.org', 'member@example.org'], + 'eduPersonScopedAffiliation' => ['staff@example.org', 'member@example.org'], ] ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertEquals($attributes['eduPersonScopedAffiliation'], ['staff@example.org', 'member@example.org']); - } + } } diff --git a/tests/modules/core/lib/Auth/Process/ScopeFromAttributeTest.php b/tests/modules/core/lib/Auth/Process/ScopeFromAttributeTest.php index 0e5aace085379d0e6475324a8e04ee3841f1d247..fd2cd097fd10827008f069c36bdd0d19752d2299 100644 --- a/tests/modules/core/lib/Auth/Process/ScopeFromAttributeTest.php +++ b/tests/modules/core/lib/Auth/Process/ScopeFromAttributeTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; /** * Test for the core:ScopeFromAttribute filter. */ -class Test_Core_Auth_Process_ScopeFromAttribute extends TestCase +class ScopeFromAttributeTest extends TestCase { /* @@ -17,7 +17,7 @@ class Test_Core_Auth_Process_ScopeFromAttribute extends TestCase */ private static function processFilter(array $config, array $request) { - $filter = new \SimpleSAML\Module\core\Auth\Process\ScopeFromAttribute($config, NULL); + $filter = new \SimpleSAML\Module\core\Auth\Process\ScopeFromAttribute($config, null); $filter->process($request); return $request; } diff --git a/tests/modules/core/lib/Auth/Process/TargetedIDTest.php b/tests/modules/core/lib/Auth/Process/TargetedIDTest.php index 51f5c6b1da60f7f23e2776036db3e59eb917a77a..2649859f23f4f91f9b69aab58162671afe94b885 100644 --- a/tests/modules/core/lib/Auth/Process/TargetedIDTest.php +++ b/tests/modules/core/lib/Auth/Process/TargetedIDTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; /** * Test for the core:TargetedID filter. */ -class Test_Core_Auth_Process_TargetedID extends TestCase +class TargetedIDTest extends TestCase { /** * Helper function to run the filter with a given configuration. @@ -16,7 +16,7 @@ class Test_Core_Auth_Process_TargetedID extends TestCase */ private static function processFilter(array $config, array $request) { - $filter = new \SimpleSAML\Module\core\Auth\Process\TargetedID($config, NULL); + $filter = new \SimpleSAML\Module\core\Auth\Process\TargetedID($config, null); $filter->process($request); return $request; } @@ -26,12 +26,11 @@ class Test_Core_Auth_Process_TargetedID extends TestCase // */ // public function testBasic() // { -// $config = array( -// ); -// $request = array( +// $config = []; +// $request = [ // 'Attributes' => [], // 'UserID' => 'user2@example.org', -// ); +// ]; // $result = self::processFilter($config, $request); // $attributes = $result['Attributes']; // $this->assertArrayHasKey('eduPersonTargetedID', $attributes); @@ -44,22 +43,21 @@ class Test_Core_Auth_Process_TargetedID extends TestCase // */ // public function testWithSrcDst() // { -// $config = array( -// ); -// $request = array( -// 'Attributes' => array( +// $config = []; +// $request = [ +// 'Attributes' => [ // 'eduPersonTargetedID' => 'dummy', -// ), +// ], // 'UserID' => 'user2@example.org', -// 'Source' => array( +// 'Source' => [ // 'metadata-set' => 'saml20-idp-hosted', // 'entityid' => 'urn:example:src:id', -// ), -// 'Destination' => array( +// ], +// 'Destination' => [ // 'metadata-set' => 'saml20-sp-remote', // 'entityid' => 'joe', -// ), -// ); +// ], +// ]; // $result = self::processFilter($config, $request); // $attributes = $result['Attributes']; // $this->assertArrayHasKey('eduPersonTargetedID', $attributes); @@ -71,26 +69,28 @@ class Test_Core_Auth_Process_TargetedID extends TestCase // */ // public function testNameIdGeneration() // { -// $config = array( +// $config = [ // 'nameId' => true, -// ); +// ]; // $request = array( -// 'Attributes' => array( -// ), +// 'Attributes' => [], // 'UserID' => 'user2@example.org', -// 'Source' => array( +// 'Source' => [ // 'metadata-set' => 'saml20-idp-hosted', // 'entityid' => 'urn:example:src:id', -// ), -// 'Destination' => array( +// ], +// 'Destination' => [ // 'metadata-set' => 'saml20-sp-remote', // 'entityid' => 'joe', -// ), +// ], // ); // $result = self::processFilter($config, $request); // $attributes = $result['Attributes']; // $this->assertArrayHasKey('eduPersonTargetedID', $attributes); -// $this->assertRegExp('#^<saml:NameID xmlns:saml="urn:oasis:names:tc:SAML:2\.0:assertion" NameQualifier="urn:example:src:id" SPNameQualifier="joe" Format="urn:oasis:names:tc:SAML:2\.0:nameid-format:persistent">[0-9a-f]{40}</saml:NameID>$#', $attributes['eduPersonTargetedID'][0]); +// $this->assertRegExp( +// '#^<saml:NameID xmlns:saml="urn:oasis:names:tc:SAML:2\.0:assertion" NameQualifier="urn:example:src:id" SPNameQualifier="joe" Format="urn:oasis:names:tc:SAML:2\.0:nameid-format:persistent">[0-9a-f]{40}</saml:NameID>$#', +// $attributes['eduPersonTargetedID'][0] +// ); // } // // /** @@ -98,30 +98,29 @@ class Test_Core_Auth_Process_TargetedID extends TestCase // */ // public function testIdIsPersistent() // { -// $config = array( -// ); -// $request = array( -// 'Attributes' => array( +// $config = []; +// $request = [ +// 'Attributes' => [ // 'eduPersonTargetedID' => 'dummy', -// ), +// ], // 'UserID' => 'user2@example.org', -// 'Source' => array( +// 'Source' => [ // 'metadata-set' => 'saml20-idp-hosted', // 'entityid' => 'urn:example:src:id', -// ), -// 'Destination' => array( +// ], +// 'Destination' => [ // 'metadata-set' => 'saml20-sp-remote', // 'entityid' => 'joe', -// ), -// ); +// ], +// ]; // for ($i = 0; $i < 10; ++$i) { -// $result = self::processFilter($config, $request); -// $attributes = $result['Attributes']; -// $tid = $attributes['eduPersonTargetedID'][0]; -// if (isset($prevtid)) { -// $this->assertEquals($prevtid, $tid); -// $prevtid = $tid; -// } +// $result = self::processFilter($config, $request); +// $attributes = $result['Attributes']; +// $tid = $attributes['eduPersonTargetedID'][0]; +// if (isset($prevtid)) { +// $this->assertEquals($prevtid, $tid); +// $prevtid = $tid; +// } // } // } // @@ -130,33 +129,31 @@ class Test_Core_Auth_Process_TargetedID extends TestCase // */ // public function testIdIsUnique() // { -// $config = array( -// ); -// $request = array( -// 'Attributes' => array( -// ), +// $config = []; +// $request = [ +// 'Attributes' => [], // 'UserID' => 'user2@example.org', -// 'Source' => array( +// 'Source' => [ // 'metadata-set' => 'saml20-idp-hosted', // 'entityid' => 'urn:example:src:id', -// ), -// 'Destination' => array( +// ], +// 'Destination' => [ // 'metadata-set' => 'saml20-sp-remote', // 'entityid' => 'joe', -// ), -// ); -// $result = self::processFilter($config, $request); -// $tid1 = $result['Attributes']['eduPersonTargetedID'][0]; +// ], +// ]; +// $result = self::processFilter($config, $request); +// $tid1 = $result['Attributes']['eduPersonTargetedID'][0]; // // $request['UserID'] = 'user3@example.org'; -// $result = self::processFilter($config, $request); -// $tid2 = $result['Attributes']['eduPersonTargetedID'][0]; +// $result = self::processFilter($config, $request); +// $tid2 = $result['Attributes']['eduPersonTargetedID'][0]; // // $this->assertNotEquals($tid1, $tid2); // // $request['Destination']['entityid'] = 'urn:example.org:another-sp'; -// $result = self::processFilter($config, $request); -// $tid3 = $result['Attributes']['eduPersonTargetedID'][0]; +// $result = self::processFilter($config, $request); +// $tid3 = $result['Attributes']['eduPersonTargetedID'][0]; // // $this->assertNotEquals($tid2, $tid3); // } diff --git a/tests/modules/core/lib/Auth/UserPassOrgBaseTest.php b/tests/modules/core/lib/Auth/UserPassOrgBaseTest.php index 90816896b7b349274586d9743d8b4dcf06a6eb42..317301b321bf0170eb6fadaf185f6bd93c7bfc47 100644 --- a/tests/modules/core/lib/Auth/UserPassOrgBaseTest.php +++ b/tests/modules/core/lib/Auth/UserPassOrgBaseTest.php @@ -27,7 +27,8 @@ class UserPassOrgBaseTest extends \PHPUnit_Framework_TestCase // When PHP 5.4 support is dropped, replace with: // $mockUserPassOrgBase = $this->getMockBuilder(\SimpleSAML\Module\core\Auth\UserPassOrgBase::class) - $mockUserPassOrgBase = $this->getMockBuilder(get_parent_class(new \SimpleSAML\Module\ldap\Auth\Source\LDAPMulti(['AuthId' => 'my-org'], []))) + $multi = new \SimpleSAML\Module\ldap\Auth\Source\LDAPMulti(['AuthId' => 'my-org']); + $mockUserPassOrgBase = $this->getMockBuilder(get_parent_class($multi, [])) ->setConstructorArgs([['AuthId' => 'my-org'], &$config]) ->setMethods([]) ->getMockForAbstractClass(); diff --git a/tests/modules/core/lib/Storage/SQLPermanentStorageTest.php b/tests/modules/core/lib/Storage/SQLPermanentStorageTest.php index 49b17fd611d9180e7b33838f406e92a9a46bccf1..5e05404518e635c5161621db2bde716049ea662e 100644 --- a/tests/modules/core/lib/Storage/SQLPermanentStorageTest.php +++ b/tests/modules/core/lib/Storage/SQLPermanentStorageTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; /** * Test for the SQLPermanentStorage class. */ -class Test_Core_Storage_SQLPermanentStorage extends TestCase +class SQLPermanentStorageTest extends TestCase { private static $sql; diff --git a/tests/modules/ldap/lib/Auth/Process/BaseFilterTest.php b/tests/modules/ldap/lib/Auth/Process/BaseFilterTest.php index b7c502e4e1c335025859cd07150a54a2862a4912..ab9bf7dbdd05122204ae3f3293636df93da32728 100644 --- a/tests/modules/ldap/lib/Auth/Process/BaseFilterTest.php +++ b/tests/modules/ldap/lib/Auth/Process/BaseFilterTest.php @@ -2,7 +2,7 @@ use PHPUnit\Framework\TestCase; -class BaseFilter_Test extends TestCase +class BaseFilterTest extends TestCase { public function testVarExportHidesLdapPassword() { 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 f3634818d9bb5ffcde328ee09fecfa301248193b..c1310986c847bbca8c195bfdd4fab7e6e2de8367 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 @@ -32,7 +32,7 @@ class ExitTestException extends \Exception * - Use introspection to make startSSO2Test available * - Override sendSAML2AuthnRequest() to catch the AuthnRequest being sent */ -class SP_Tester extends \SimpleSAML\Module\saml\Auth\Source\SP +class SPTester extends \SimpleSAML\Module\saml\Auth\Source\SP { public function __construct($info, $config) @@ -68,7 +68,7 @@ class SP_Tester extends \SimpleSAML\Module\saml\Auth\Source\SP /** * Set of test cases for \SimpleSAML\Module\saml\Auth\Source\SP. */ -class SP_Test extends TestCase +class SPTest extends TestCase { private $idpMetadata = null; @@ -141,7 +141,7 @@ class SP_Test extends TestCase { $info = ['AuthId' => 'default-sp']; $config = []; - $as = new SP_Tester($info, $config); + $as = new SPTester($info, $config); /** @var \SAML2\AuthnRequest $ar */ $ar = null;