Skip to content

Commit 6ce451f

Browse files
committed
Use shorthand instantiation for typed textcontent types
1 parent eff78b3 commit 6ce451f

24 files changed

Lines changed: 115 additions & 379 deletions

tests/src/SAML11/XML/saml/AdviceTest.php

Lines changed: 17 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@
4242
use SimpleSAML\XML\DOMDocumentFactory;
4343
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
4444
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
45-
use SimpleSAML\XMLSchema\Type\Base64BinaryValue;
4645
use SimpleSAML\XMLSchema\Type\IDValue;
4746
use SimpleSAML\XMLSchema\Type\IntegerValue;
48-
use SimpleSAML\XMLSchema\Type\NCNameValue;
4947
use SimpleSAML\XMLSchema\Type\NonNegativeIntegerValue;
5048
use SimpleSAML\XMLSchema\Type\QNameValue;
51-
use SimpleSAML\XMLSchema\Type\StringValue;
5249
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
5350
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
5451
use SimpleSAML\XMLSecurity\XML\ds\KeyName;
@@ -192,9 +189,7 @@ public static function tearDownAfterClass(): void
192189
*/
193190
public function testMarshalling(): void
194191
{
195-
$assertionIDReference = new AssertionIDReference(
196-
NCNameValue::fromString('_Test'),
197-
);
192+
$assertionIDReference = AssertionIDReference::fromString('_Test');
198193

199194
// Create SubjectStatement
200195
$scd = new SubjectConfirmationData(
@@ -203,17 +198,11 @@ public function testMarshalling(): void
203198

204199
$keyInfo = new KeyInfo(
205200
[
206-
new KeyName(
207-
StringValue::fromString('testkey'),
208-
),
201+
KeyName::fromString('testkey'),
209202
new X509Data(
210203
[
211-
new X509Certificate(
212-
Base64BinaryValue::fromString(self::$certificate),
213-
),
214-
new X509SubjectName(
215-
StringValue::fromString(self::$certData['name']),
216-
),
204+
X509Certificate::fromString(self::$certificate),
205+
X509SubjectName::fromString(self::$certData['name']),
217206
],
218207
),
219208
new Chunk(DOMDocumentFactory::fromString(
@@ -225,12 +214,8 @@ public function testMarshalling(): void
225214

226215
$sc = new SubjectConfirmation(
227216
[
228-
new ConfirmationMethod(
229-
SAMLAnyURIValue::fromString('_Test1'),
230-
),
231-
new ConfirmationMethod(
232-
SAMLAnyURIValue::fromString('_Test2'),
233-
),
217+
ConfirmationMethod::fromString('_Test1'),
218+
ConfirmationMethod::fromString('_Test2'),
234219
],
235220
$scd,
236221
$keyInfo,
@@ -243,25 +228,17 @@ public function testMarshalling(): void
243228
);
244229

245230
$subject = new Subject($sc, $nameIdentifier);
246-
$audience = new Audience(
247-
SAMLAnyURIValue::fromString('urn:x-simplesamlphp:audience'),
248-
);
231+
$audience = Audience::fromString('urn:x-simplesamlphp:audience');
249232
$subjectStatement = new CustomSubjectStatement($subject, [$audience]);
250233

251234
// Create AuthenticationStatement
252235
$keyInfo = new KeyInfo(
253236
[
254-
new KeyName(
255-
StringValue::fromString('testkey'),
256-
),
237+
KeyName::fromString('testkey'),
257238
new X509Data(
258239
[
259-
new X509Certificate(
260-
Base64BinaryValue::fromString(self::$certificate),
261-
),
262-
new X509SubjectName(
263-
StringValue::fromString(self::$certData['name']),
264-
),
240+
X509Certificate::fromString(self::$certificate),
241+
X509SubjectName::fromString(self::$certData['name']),
265242
],
266243
),
267244
new Chunk(DOMDocumentFactory::fromString(
@@ -273,12 +250,8 @@ public function testMarshalling(): void
273250

274251
$sc = new SubjectConfirmation(
275252
[
276-
new ConfirmationMethod(
277-
SAMLAnyURIValue::fromString('_Test1'),
278-
),
279-
new ConfirmationMethod(
280-
SAMLAnyURIValue::fromString('_Test2'),
281-
),
253+
ConfirmationMethod::fromString('_Test1'),
254+
ConfirmationMethod::fromString('_Test2'),
282255
],
283256
$scd,
284257
$keyInfo,
@@ -307,17 +280,11 @@ public function testMarshalling(): void
307280
// Create AttributeStatement
308281
$keyInfo = new KeyInfo(
309282
[
310-
new KeyName(
311-
StringValue::fromString('testkey'),
312-
),
283+
KeyName::fromString('testkey'),
313284
new X509Data(
314285
[
315-
new X509Certificate(
316-
Base64BinaryValue::fromString(self::$certificate),
317-
),
318-
new X509SubjectName(
319-
StringValue::fromString(self::$certData['name']),
320-
),
286+
X509Certificate::fromString(self::$certificate),
287+
X509SubjectName::fromString(self::$certData['name']),
321288
],
322289
),
323290
new Chunk(DOMDocumentFactory::fromString(
@@ -329,12 +296,8 @@ public function testMarshalling(): void
329296

330297
$sc = new SubjectConfirmation(
331298
[
332-
new ConfirmationMethod(
333-
SAMLAnyURIValue::fromString('_Test1'),
334-
),
335-
new ConfirmationMethod(
336-
SAMLAnyURIValue::fromString('_Test2'),
337-
),
299+
ConfirmationMethod::fromString('_Test1'),
300+
ConfirmationMethod::fromString('_Test2'),
338301
],
339302
$scd,
340303
$keyInfo,

tests/src/SAML11/XML/saml/AssertionIDReferenceTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use SimpleSAML\XML\DOMDocumentFactory;
1313
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1414
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
15-
use SimpleSAML\XMLSchema\Type\IDValue;
1615

1716
use function dirname;
1817
use function strval;
@@ -47,9 +46,7 @@ public static function setUpBeforeClass(): void
4746
*/
4847
public function testMarshalling(): void
4948
{
50-
$assertionIDReference = new AssertionIDReference(
51-
IDValue::fromString('_Test'),
52-
);
49+
$assertionIDReference = AssertionIDReference::fromString('_Test');
5350

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

tests/src/SAML11/XML/saml/AssertionTest.php

Lines changed: 17 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@
4242
use SimpleSAML\XML\DOMDocumentFactory;
4343
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
4444
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
45-
use SimpleSAML\XMLSchema\Type\Base64BinaryValue;
4645
use SimpleSAML\XMLSchema\Type\IDValue;
4746
use SimpleSAML\XMLSchema\Type\IntegerValue;
48-
use SimpleSAML\XMLSchema\Type\NCNameValue;
4947
use SimpleSAML\XMLSchema\Type\NonNegativeIntegerValue;
5048
use SimpleSAML\XMLSchema\Type\QNameValue;
51-
use SimpleSAML\XMLSchema\Type\StringValue;
5249
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
5350
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
5451
use SimpleSAML\XMLSecurity\XML\ds\KeyName;
@@ -226,9 +223,7 @@ public function testMarshalling(): void
226223
);
227224

228225
// Create middle assertion
229-
$assertionIDReference = new AssertionIDReference(
230-
NCNameValue::fromString('_Test'),
231-
);
226+
$assertionIDReference = AssertionIDReference::fromString('_Test');
232227
$advice = new Advice(
233228
[$assertionIDReference],
234229
[$assertion],
@@ -329,17 +324,11 @@ private function createSubjectStatement(string $id): CustomSubjectStatement
329324

330325
$keyInfo = new KeyInfo(
331326
[
332-
new KeyName(
333-
StringValue::fromString('testkey'),
334-
),
327+
KeyName::fromString('testkey'),
335328
new X509Data(
336329
[
337-
new X509Certificate(
338-
Base64BinaryValue::fromString(self::$certificate),
339-
),
340-
new X509SubjectName(
341-
StringValue::fromString(self::$certData['name']),
342-
),
330+
X509Certificate::fromString(self::$certificate),
331+
X509SubjectName::fromString(self::$certData['name']),
343332
],
344333
),
345334
new Chunk(DOMDocumentFactory::fromString(
@@ -351,12 +340,8 @@ private function createSubjectStatement(string $id): CustomSubjectStatement
351340

352341
$sc = new SubjectConfirmation(
353342
[
354-
new ConfirmationMethod(
355-
SAMLAnyURIValue::fromString('_Test1'),
356-
),
357-
new ConfirmationMethod(
358-
SAMLAnyURIValue::fromString('_Test2'),
359-
),
343+
ConfirmationMethod::fromString('_Test1'),
344+
ConfirmationMethod::fromString('_Test2'),
360345
],
361346
$scd,
362347
$keyInfo,
@@ -369,9 +354,7 @@ private function createSubjectStatement(string $id): CustomSubjectStatement
369354
);
370355

371356
$subject = new Subject($sc, $nameIdentifier);
372-
$audience = new Audience(
373-
SAMLAnyURIValue::fromString('urn:x-simplesamlphp:audience'),
374-
);
357+
$audience = Audience::fromString('urn:x-simplesamlphp:audience');
375358

376359
return new CustomSubjectStatement($subject, [$audience]);
377360
}
@@ -389,17 +372,11 @@ private function createAuthenticationStatement(string $id): AuthenticationStatem
389372

390373
$keyInfo = new KeyInfo(
391374
[
392-
new KeyName(
393-
StringValue::fromString('testkey'),
394-
),
375+
KeyName::fromString('testkey'),
395376
new X509Data(
396377
[
397-
new X509Certificate(
398-
Base64BinaryValue::fromString(self::$certificate),
399-
),
400-
new X509SubjectName(
401-
StringValue::fromString(self::$certData['name']),
402-
),
378+
X509Certificate::fromString(self::$certificate),
379+
X509SubjectName::fromString(self::$certData['name']),
403380
],
404381
),
405382
new Chunk(DOMDocumentFactory::fromString(
@@ -411,12 +388,8 @@ private function createAuthenticationStatement(string $id): AuthenticationStatem
411388

412389
$sc = new SubjectConfirmation(
413390
[
414-
new ConfirmationMethod(
415-
SAMLAnyURIValue::fromString('_Test1'),
416-
),
417-
new ConfirmationMethod(
418-
SAMLAnyURIValue::fromString('_Test2'),
419-
),
391+
ConfirmationMethod::fromString('_Test1'),
392+
ConfirmationMethod::fromString('_Test2'),
420393
],
421394
$scd,
422395
$keyInfo,
@@ -463,17 +436,11 @@ private function createAttributeStatement(string $id): AttributeStatement
463436

464437
$keyInfo = new KeyInfo(
465438
[
466-
new KeyName(
467-
StringValue::fromString('testkey'),
468-
),
439+
KeyName::fromString('testkey'),
469440
new X509Data(
470441
[
471-
new X509Certificate(
472-
Base64BinaryValue::fromString(self::$certificate),
473-
),
474-
new X509SubjectName(
475-
StringValue::fromString(self::$certData['name']),
476-
),
442+
X509Certificate::fromString(self::$certificate),
443+
X509SubjectName::fromString(self::$certData['name']),
477444
],
478445
),
479446
new Chunk(DOMDocumentFactory::fromString(
@@ -485,12 +452,8 @@ private function createAttributeStatement(string $id): AttributeStatement
485452

486453
$sc = new SubjectConfirmation(
487454
[
488-
new ConfirmationMethod(
489-
SAMLAnyURIValue::fromString('_Test1'),
490-
),
491-
new ConfirmationMethod(
492-
SAMLAnyURIValue::fromString('_Test2'),
493-
),
455+
ConfirmationMethod::fromString('_Test1'),
456+
ConfirmationMethod::fromString('_Test2'),
494457
],
495458
$scd,
496459
$keyInfo,

tests/src/SAML11/XML/saml/AttributeStatementTest.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@
2424
use SimpleSAML\XML\DOMDocumentFactory;
2525
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
2626
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
27-
use SimpleSAML\XMLSchema\Type\Base64BinaryValue;
2827
use SimpleSAML\XMLSchema\Type\IDValue;
2928
use SimpleSAML\XMLSchema\Type\IntegerValue;
30-
use SimpleSAML\XMLSchema\Type\StringValue;
3129
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
3230
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
3331
use SimpleSAML\XMLSecurity\XML\ds\KeyName;
@@ -110,17 +108,11 @@ public function testMarshalling(): void
110108

111109
$keyInfo = new KeyInfo(
112110
[
113-
new KeyName(
114-
StringValue::fromString('testkey'),
115-
),
111+
KeyName::fromString('testkey'),
116112
new X509Data(
117113
[
118-
new X509Certificate(
119-
Base64BinaryValue::fromString(self::$certificate),
120-
),
121-
new X509SubjectName(
122-
StringValue::fromString(self::$certData['name']),
123-
),
114+
X509Certificate::fromString(self::$certificate),
115+
X509SubjectName::fromString(self::$certData['name']),
124116
],
125117
),
126118
new Chunk(DOMDocumentFactory::fromString(
@@ -132,12 +124,8 @@ public function testMarshalling(): void
132124

133125
$sc = new SubjectConfirmation(
134126
[
135-
new ConfirmationMethod(
136-
SAMLAnyURIValue::fromString('_Test1'),
137-
),
138-
new ConfirmationMethod(
139-
SAMLAnyURIValue::fromString('_Test2'),
140-
),
127+
ConfirmationMethod::fromString('_Test1'),
128+
ConfirmationMethod::fromString('_Test2'),
141129
],
142130
$scd,
143131
$keyInfo,

tests/src/SAML11/XML/saml/AudienceRestrictionConditionTest.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\SAML11\Type\SAMLAnyURIValue;
1110
use SimpleSAML\SAML11\XML\saml\AbstractAudienceRestrictionConditionType;
1211
use SimpleSAML\SAML11\XML\saml\AbstractSamlElement;
1312
use SimpleSAML\SAML11\XML\saml\Audience;
@@ -54,9 +53,7 @@ public static function setUpBeforeClass(): void
5453
*/
5554
public function testMarshalling(): void
5655
{
57-
$audience = new Audience(
58-
SAMLAnyURIValue::fromString('urn:x-simplesamlphp:audience'),
59-
);
56+
$audience = Audience::fromString('urn:x-simplesamlphp:audience');
6057
$audienceRestrictionCondition = new AudienceRestrictionCondition([$audience]);
6158

6259
$this->assertEquals(

tests/src/SAML11/XML/saml/AudienceTest.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\SAML11\Type\SAMLAnyURIValue;
1110
use SimpleSAML\SAML11\XML\saml\AbstractSamlElement;
1211
use SimpleSAML\SAML11\XML\saml\Audience;
1312
use SimpleSAML\XML\DOMDocumentFactory;
@@ -51,9 +50,7 @@ public static function setUpBeforeClass(): void
5150
*/
5251
public function testMarshalling(): void
5352
{
54-
$audience = new Audience(
55-
SAMLAnyURIValue::fromString('urn:x-simplesamlphp:audience'),
56-
);
53+
$audience = Audience::fromString('urn:x-simplesamlphp:audience');
5754

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

0 commit comments

Comments
 (0)