Skip to content

Commit dcc835b

Browse files
committed
Use shorthand instantiation for typed textcontent types
1 parent a31db0f commit dcc835b

12 files changed

Lines changed: 31 additions & 47 deletions

tests/Federation/XML/auth/ClaimTypeTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public function testMarshalling(): void
6666
$claimType = new ClaimType(
6767
AnyURIValue::fromString(C::NAMESPACE),
6868
BooleanValue::fromBoolean(true),
69-
new DisplayName(StringValue::fromString('someDisplayName')),
70-
new Description(StringValue::fromString('someDescription')),
71-
new DisplayValue(StringValue::fromString('someDisplayValue')),
72-
new Value(StringValue::fromString('someValue')),
69+
DisplayName::fromString('someDisplayName'),
70+
Description::fromString('someDescription'),
71+
DisplayValue::fromString('someDisplayValue'),
72+
Value::fromString('someValue'),
7373
[$attr],
7474
);
7575

@@ -88,10 +88,10 @@ public function testMarshallingElementOrdering(): void
8888
$claimType = new ClaimType(
8989
AnyURIValue::fromString(C::NAMESPACE),
9090
BooleanValue::fromBoolean(true),
91-
new DisplayName(StringValue::fromString('someDisplayName')),
92-
new Description(StringValue::fromString('someDescription')),
93-
new DisplayValue(StringValue::fromString('someDisplayValue')),
94-
new Value(StringValue::fromString('someValue')),
91+
DisplayName::fromString('someDisplayName'),
92+
Description::fromString('someDescription'),
93+
DisplayValue::fromString('someDisplayValue'),
94+
Value::fromString('someValue'),
9595
[$attr],
9696
);
9797
$claimTypeElement = $claimType->toXML();

tests/Federation/XML/auth/ConstrainedSingleValueTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function testMarshallingIllegalCombination(string $class): void
7272
[$attr1],
7373
);
7474

75-
$value = new Value(StringValue::fromString('MyValue'));
75+
$value = Value::fromString('MyValue');
7676

7777
$this->expectException(AssertionFailedException::class);
7878
new $class($value, $structuredValue);

tests/Federation/XML/auth/ContextItemTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testMarshalling(): void
6060
$contextItem = new ContextItem(
6161
AnyURIValue::fromString(C::NAMESPACE),
6262
AnyURIValue::fromString('urn:x-simplesamlphp:scope'),
63-
new Value(StringValue::fromString('someValue')),
63+
Value::fromString('someValue'),
6464
null,
6565
[$attr1],
6666
);

tests/Federation/XML/auth/EncryptedValueTest.php

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use SimpleSAML\XML\DOMDocumentFactory;
1414
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
1515
use SimpleSAML\XMLSchema\Type\AnyURIValue;
16-
use SimpleSAML\XMLSchema\Type\Base64BinaryValue;
1716
use SimpleSAML\XMLSchema\Type\IDValue;
1817
use SimpleSAML\XMLSchema\Type\StringValue;
1918
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
@@ -62,9 +61,7 @@ public function testMarshalling(): void
6261
{
6362
$encryptedData = new EncryptedData(
6463
new CipherData(
65-
new CipherValue(
66-
Base64BinaryValue::fromString('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='),
67-
),
64+
CipherValue::fromString('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='),
6865
),
6966
IDValue::fromString('MyID'),
7067
AnyURIValue::fromString('http://www.w3.org/2001/04/xmlenc#Element'),
@@ -76,18 +73,10 @@ public function testMarshalling(): void
7673
new KeyInfo(
7774
[
7875
new EncryptedKey(
79-
new CipherData(
80-
new CipherValue(
81-
Base64BinaryValue::fromString('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='),
82-
),
76+
cipherData: new CipherData(
77+
CipherValue::fromString('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='),
8378
),
84-
null,
85-
null,
86-
null,
87-
null,
88-
null,
89-
null,
90-
new EncryptionMethod(
79+
encryptionMethod: new EncryptionMethod(
9180
AnyURIValue::fromString('http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'),
9281
),
9382
),

tests/Federation/XML/auth/ValueOneOfWithValuesTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use SimpleSAML\WebServices\Federation\XML\auth\ValueOneOf;
1414
use SimpleSAML\XML\DOMDocumentFactory;
1515
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
16-
use SimpleSAML\XMLSchema\Type\StringValue;
1716

1817
use function dirname;
1918
use function strval;
@@ -52,8 +51,8 @@ public static function setUpBeforeClass(): void
5251
*/
5352
public function testMarshalling(): void
5453
{
55-
$value1 = new Value(StringValue::fromString('MyValue'));
56-
$value2 = new Value(StringValue::fromString('MyOtherValue'));
54+
$value1 = Value::fromString('MyValue');
55+
$value2 = Value::fromString('MyOtherValue');
5756
$valueOneOf = new ValueOneOf([$value1, $value2]);
5857

5958
$this->assertEquals(

tests/Federation/XML/auth/ValueTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use SimpleSAML\WebServices\Federation\XML\auth\Value;
1212
use SimpleSAML\XML\DOMDocumentFactory;
1313
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
14-
use SimpleSAML\XMLSchema\Type\StringValue;
1514

1615
use function dirname;
1716
use function strval;
@@ -49,7 +48,7 @@ public static function setUpBeforeClass(): void
4948
*/
5049
public function testMarshalling(): void
5150
{
52-
$value = new Value(StringValue::fromString('MyValue'));
51+
$value = Value::fromString('MyValue');
5352

5453
$this->assertEquals(
5554
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),

tests/Federation/XML/fed/AutomaticPseudonymsTest.php

Lines changed: 1 addition & 2 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\BooleanValue;
1615

1716
use function dirname;
1817

@@ -50,7 +49,7 @@ public static function setUpBeforeClass(): void
5049
*/
5150
public function testMarshalling(): void
5251
{
53-
$automaticPseudonyms = new AutomaticPseudonyms(BooleanValue::fromBoolean(true));
52+
$automaticPseudonyms = AutomaticPseudonyms::fromString('true');
5453

5554
$this->assertEquals(
5655
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),

tests/Federation/XML/fed/ClaimTypesOfferedTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ public function testMarshalling(): void
6767
$claimType = new ClaimType(
6868
AnyURIValue::fromString(C::NAMESPACE),
6969
BooleanValue::fromBoolean(true),
70-
new DisplayName(StringValue::fromString('someDisplayName')),
71-
new Description(StringValue::fromString('someDescription')),
72-
new DisplayValue(StringValue::fromString('someDisplayValue')),
73-
new Value(StringValue::fromString('someValue')),
70+
DisplayName::fromString('someDisplayName'),
71+
Description::fromString('someDescription'),
72+
DisplayValue::fromString('someDisplayValue'),
73+
Value::fromString('someValue'),
7474
[$attr2],
7575
);
7676

tests/Federation/XML/fed/ClaimTypesRequestedTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ public function testMarshalling(): void
6767
$claimType = new ClaimType(
6868
AnyURIValue::fromString(C::NAMESPACE),
6969
BooleanValue::fromBoolean(true),
70-
new DisplayName(StringValue::fromString('someDisplayName')),
71-
new Description(StringValue::fromString('someDescription')),
72-
new DisplayValue(StringValue::fromString('someDisplayValue')),
73-
new Value(StringValue::fromString('someValue')),
70+
DisplayName::fromString('someDisplayName'),
71+
Description::fromString('someDescription'),
72+
DisplayValue::fromString('someDisplayValue'),
73+
Value::fromString('someValue'),
7474
[$attr2],
7575
);
7676

tests/Federation/XML/fed/EMailTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public static function setUpBeforeClass(): void
5454
public function testMarshalling(): void
5555
{
5656
$attr1 = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('testval1'));
57-
$EMail = new EMail(EmailAddressValue::fromString('example@simplesamlphp.org'), [$attr1]);
57+
$email = new EMail(EmailAddressValue::fromString('example@simplesamlphp.org'), [$attr1]);
5858

5959
$this->assertEquals(
6060
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
61-
strval($EMail),
61+
strval($email),
6262
);
6363
}
6464
}

0 commit comments

Comments
 (0)