Skip to content

Commit 6e979f5

Browse files
committed
Use shorthand instantiation for typed textcontent types
1 parent 3ffc27d commit 6e979f5

File tree

72 files changed

+197
-616
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+197
-616
lines changed

tests/SAML2/XML/ecp/RelayStateTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPUnit\Framework\Attributes\CoversClass;
88
use PHPUnit\Framework\Attributes\Group;
99
use PHPUnit\Framework\TestCase;
10-
use SimpleSAML\SAML2\Type\SAMLStringValue;
1110
use SimpleSAML\SAML2\XML\ecp\AbstractEcpElement;
1211
use SimpleSAML\SAML2\XML\ecp\RelayState;
1312
use SimpleSAML\SOAP11\Constants as SOAP;
@@ -47,9 +46,7 @@ public static function setUpBeforeClass(): void
4746
*/
4847
public function testMarshalling(): void
4948
{
50-
$relayState = new RelayState(
51-
SAMLStringValue::fromString('AGDY854379dskssda'),
52-
);
49+
$relayState = RelayState::fromString('AGDY854379dskssda');
5350

5451
$this->assertEquals(
5552
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),

tests/SAML2/XML/ecp/RequestTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ public function testMarshalling(): void
7171
SAMLStringValue::fromString('testName2'),
7272
SAMLAnyURIValue::fromString('urn:test:testLoc2'),
7373
);
74-
$getComplete = new GetComplete(
75-
SAMLAnyURIValue::fromString('https://some/location'),
76-
);
74+
$getComplete = GetComplete::fromString('https://some/location');
7775
$idpList = new IDPList([$entry1, $entry2], $getComplete);
7876

7977
$request = new Request(

tests/SAML2/XML/emd/RepublishRequestTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPUnit\Framework\Attributes\CoversClass;
88
use PHPUnit\Framework\Attributes\Group;
99
use PHPUnit\Framework\TestCase;
10-
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1110
use SimpleSAML\SAML2\XML\emd\AbstractEmdElement;
1211
use SimpleSAML\SAML2\XML\emd\RepublishRequest;
1312
use SimpleSAML\SAML2\XML\emd\RepublishTarget;
@@ -56,9 +55,7 @@ public static function setUpBeforeClass(): void
5655
public function testMarshalling(): void
5756
{
5857
$republishRequest = new RepublishRequest(
59-
new RepublishTarget(
60-
SAMLAnyURIValue::fromString('http://edugain.org/'),
61-
),
58+
RepublishTarget::fromString('http://edugain.org/'),
6259
);
6360

6461
$this->assertEquals(

tests/SAML2/XML/emd/RepublishTargetTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PHPUnit\Framework\Attributes\Group;
99
use PHPUnit\Framework\TestCase;
1010
use SimpleSAML\Assert\AssertionFailedException;
11-
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1211
use SimpleSAML\SAML2\XML\emd\AbstractEmdElement;
1312
use SimpleSAML\SAML2\XML\emd\RepublishTarget;
1413
use SimpleSAML\XML\DOMDocumentFactory;
@@ -47,9 +46,7 @@ public static function setUpBeforeClass(): void
4746
*/
4847
public function testMarshalling(): void
4948
{
50-
$republishTarget = new RepublishTarget(
51-
SAMLAnyURIValue::fromString('http://edugain.org/'),
52-
);
49+
$republishTarget = RepublishTarget::fromString('http://edugain.org/');
5350

5451
$this->assertEquals(
5552
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
@@ -67,6 +64,6 @@ public function testMarshallingIncorrectValueThrowsException(): void
6764
'Expected a value identical to "http://edugain.org/". Got: "http://example.org/"',
6865
);
6966

70-
new RepublishTarget(SAMLAnyURIValue::fromString('http://example.org/'));
67+
RepublishTarget::fromString('http://example.org/');
7168
}
7269
}

tests/SAML2/XML/md/AffiliateMemberTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPUnit\Framework\Attributes\CoversClass;
88
use PHPUnit\Framework\Attributes\Group;
99
use PHPUnit\Framework\TestCase;
10-
use SimpleSAML\SAML2\Type\EntityIDValue;
1110
use SimpleSAML\SAML2\XML\md\AbstractMdElement;
1211
use SimpleSAML\SAML2\XML\md\AffiliateMember;
1312
use SimpleSAML\XML\DOMDocumentFactory;
@@ -51,9 +50,7 @@ public static function setUpBeforeClass(): void
5150
*/
5251
public function testMarshalling(): void
5352
{
54-
$affiliateMember = new AffiliateMember(
55-
EntityIDValue::fromString('https://some.entity.org/id'),
56-
);
53+
$affiliateMember = AffiliateMember::fromString('https://some.entity.org/id');
5754

5855
$this->assertEquals(
5956
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),

tests/SAML2/XML/md/AffiliationDescriptorTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,8 @@ public function testMarshalling(): void
7474
$affiliationDescriptor = new AffiliationDescriptor(
7575
affiliationOwnerId: EntityIDValue::fromString(C::ENTITY_IDP),
7676
affiliateMember: [
77-
new AffiliateMember(
78-
EntityIDValue::fromString(C::ENTITY_SP),
79-
),
80-
new AffiliateMember(
81-
EntityIDValue::fromString(C::ENTITY_OTHER),
82-
),
77+
AffiliateMember::fromString(C::ENTITY_SP),
78+
AffiliateMember::fromString(C::ENTITY_OTHER),
8379
],
8480
ID: IDValue::fromString('TheID'),
8581
validUntil: SAMLDateTimeValue::fromString('2009-02-13T23:31:30Z'),
@@ -88,9 +84,7 @@ public function testMarshalling(): void
8884
new KeyDescriptor(
8985
new KeyInfo(
9086
[
91-
new KeyName(
92-
SAMLStringValue::fromString('IdentityProvider.com SSO Key'),
93-
),
87+
KeyName::fromString('IdentityProvider.com SSO Key'),
9488
],
9589
),
9690
KeyTypesValue::fromEnum(KeyTypesEnum::SIGNING),

tests/SAML2/XML/md/AttributeAuthorityDescriptorTest.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,13 @@ public function testMarshalling(): void
114114
SAMLAnyURIListValue::fromString(C::NS_SAMLP),
115115
[self::$aidrs],
116116
[
117-
new NameIDFormat(
118-
SAMLAnyURIValue::fromString(C::NAMEID_X509_SUBJECT_NAME),
119-
),
120-
new NameIDFormat(
121-
SAMLAnyURIValue::fromString(C::NAMEID_PERSISTENT),
122-
),
123-
new NameIDFormat(
124-
SAMLAnyURIValue::fromString(C::NAMEID_TRANSIENT),
125-
),
117+
NameIDFormat::fromString(C::NAMEID_X509_SUBJECT_NAME),
118+
NameIDFormat::fromString(C::NAMEID_PERSISTENT),
119+
NameIDFormat::fromString(C::NAMEID_TRANSIENT),
126120
],
127121
[
128-
new AttributeProfile(
129-
SAMLAnyURIValue::fromString(C::PROFILE_1),
130-
),
131-
new AttributeProfile(
132-
SAMLAnyURIValue::fromString(C::PROFILE_2),
133-
),
122+
AttributeProfile::fromString(C::PROFILE_1),
123+
AttributeProfile::fromString(C::PROFILE_2),
134124
],
135125
[$attr1, $attr2],
136126
IDValue::fromString('phpunit'),

tests/SAML2/XML/md/AttributeProfileTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPUnit\Framework\Attributes\CoversClass;
88
use PHPUnit\Framework\Attributes\Group;
99
use PHPUnit\Framework\TestCase;
10-
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1110
use SimpleSAML\SAML2\XML\md\AbstractMdElement;
1211
use SimpleSAML\SAML2\XML\md\AttributeProfile;
1312
use SimpleSAML\Test\SAML2\Constants as C;
@@ -51,9 +50,7 @@ public static function setUpBeforeClass(): void
5150
*/
5251
public function testMarshalling(): void
5352
{
54-
$attributeProfile = new AttributeProfile(
55-
SAMLAnyURIValue::fromString(C::PROFILE_1),
56-
);
53+
$attributeProfile = AttributeProfile::fromString(C::PROFILE_1);
5754

5855
$this->assertEquals(
5956
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),

tests/SAML2/XML/md/AuthnAuthorityDescriptorTest.php

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,8 @@ public function testMarshalling(): void
9090
SAMLAnyURIListValue::fromArray([C::NS_SAMLP, C::PROTOCOL]),
9191
[self::$aidrs],
9292
[
93-
new NameIDFormat(
94-
SAMLAnyURIValue::fromString(C::NAMEID_PERSISTENT),
95-
),
96-
new NameIDFormat(
97-
SAMLAnyURIValue::fromString(C::NAMEID_TRANSIENT),
98-
),
93+
NameIDFormat::fromString(C::NAMEID_PERSISTENT),
94+
NameIDFormat::fromString(C::NAMEID_TRANSIENT),
9995
],
10096
IDValue::fromString('phpunit'),
10197
);
@@ -119,12 +115,8 @@ public function testMarshallingWithoutAuthnQueryServices(): void
119115
SAMLAnyURIListValue::fromArray([C::NS_SAMLP, C::PROTOCOL]),
120116
[self::$aidrs],
121117
[
122-
new NameIDFormat(
123-
SAMLAnyURIValue::fromString(C::NAMEID_PERSISTENT),
124-
),
125-
new NameIDFormat(
126-
SAMLAnyURIValue::fromString(C::NAMEID_TRANSIENT),
127-
),
118+
NameIDFormat::fromString(C::NAMEID_PERSISTENT),
119+
NameIDFormat::fromString(C::NAMEID_TRANSIENT),
128120
],
129121
);
130122
}
@@ -156,12 +148,8 @@ public function testMarshallingWithWrongAuthnQueryService(): void
156148
SAMLAnyURIListValue::fromArray([C::NS_SAMLP, C::PROTOCOL]),
157149
[self::$aidrs],
158150
[
159-
new NameIDFormat(
160-
SAMLAnyURIValue::fromString(C::NAMEID_PERSISTENT),
161-
),
162-
new NameIDFormat(
163-
SAMLAnyURIValue::fromString(C::NAMEID_TRANSIENT),
164-
),
151+
NameIDFormat::fromString(C::NAMEID_PERSISTENT),
152+
NameIDFormat::fromString(C::NAMEID_TRANSIENT),
165153
],
166154
);
167155
}
@@ -180,12 +168,8 @@ public function testMarshallingWithWrongAssertionIDRequestService(): void
180168
SAMLAnyURIListValue::fromArray([C::NS_SAMLP, C::PROTOCOL]),
181169
[self::$aidrs, ''],
182170
[
183-
new NameIDFormat(
184-
SAMLAnyURIValue::fromString(C::NAMEID_PERSISTENT),
185-
),
186-
new NameIDFormat(
187-
SAMLAnyURIValue::fromString(C::NAMEID_TRANSIENT),
188-
),
171+
NameIDFormat::fromString(C::NAMEID_PERSISTENT),
172+
NameIDFormat::fromString(C::NAMEID_TRANSIENT),
189173
],
190174
);
191175
}

tests/SAML2/XML/md/CompanyTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPUnit\Framework\Attributes\CoversClass;
88
use PHPUnit\Framework\Attributes\Group;
99
use PHPUnit\Framework\TestCase;
10-
use SimpleSAML\SAML2\Type\SAMLStringValue;
1110
use SimpleSAML\SAML2\XML\md\AbstractMdElement;
1211
use SimpleSAML\SAML2\XML\md\Company;
1312
use SimpleSAML\XML\DOMDocumentFactory;
@@ -51,9 +50,7 @@ public static function setUpBeforeClass(): void
5150
*/
5251
public function testMarshalling(): void
5352
{
54-
$name = new Company(
55-
SAMLStringValue::fromString('Company'),
56-
);
53+
$name = Company::fromString('Company');
5754

5855
$this->assertEquals(
5956
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),

0 commit comments

Comments
 (0)