Skip to content

Commit ebf6362

Browse files
committed
Fix concatenated calls to dirname
1 parent b95d855 commit ebf6362

56 files changed

Lines changed: 116 additions & 111 deletions

Some content is hidden

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

tests/Backend/OpenSSLTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use SimpleSAML\XMLSecurity\Key\PublicKey;
1212
use SimpleSAML\XMLSecurity\Key\SymmetricKey;
1313

14+
use dirname;
1415
use function bin2hex;
1516
use function hex2bin;
1617

@@ -40,10 +41,10 @@ final class OpenSSLTest extends TestCase
4041
protected function setUp(): void
4142
{
4243
$this->privKey = PrivateKey::fromFile(
43-
'file://' . dirname(dirname(dirname(__FILE__))) . '/tests/resources/keys/privkey.pem'
44+
'file://' . dirname(__FILE__, 2) . '/resources/keys/privkey.pem'
4445
);
45-
$this->pubKey = PublicKey::fromFile(dirname(
46-
'file://' . dirname(dirname(__FILE__))) . '/tests/resources/keys/pubkey.pem'
46+
$this->pubKey = PublicKey::fromFile(
47+
'file://' . dirname(__FILE__, 2) . '/resources/keys/pubkey.pem'
4748
);
4849
$this->sharedKey = new SymmetricKey(hex2bin('54c98b0ea7d98186c27a6c0c6f35ee1a'));
4950
$this->backend = new OpenSSL();

tests/CryptoEncoding/PEMBundleTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use SimpleSAML\XMLSecurity\Exception\IOException;
1313
use UnexpectedValueException;
1414

15+
use function dirname;
16+
1517
/**
1618
* @group pem
1719
*
@@ -26,7 +28,7 @@ class PEMBundleTest extends TestCase
2628
*/
2729
public function setUp(): void
2830
{
29-
$this->base_dir = dirname(dirname(__FILE__));
31+
$this->base_dir = dirname(__FILE__, 2);
3032
}
3133

3234

tests/CryptoEncoding/PEMTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use UnexpectedValueException;
1111

1212
use function base64_encode;
13+
use function dirname;
1314
use function file_get_contents;
1415

1516
/**
@@ -26,7 +27,7 @@ class PEMTest extends TestCase
2627
*/
2728
public function setUp(): void
2829
{
29-
$this->base_dir = dirname(dirname(__FILE__));
30+
$this->base_dir = dirname(__FILE__, 2);
3031
}
3132

3233

tests/TestUtils/PEMCertificatesMock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class PEMCertificatesMock
4848
*/
4949
private static function buildKeysPath(string $file): string
5050
{
51-
$base = dirname(dirname(__FILE__));
51+
$base = dirname(__FILE__, 2);
5252
return 'file://' . $base . DIRECTORY_SEPARATOR . self::KEYS_DIR . DIRECTORY_SEPARATOR . $file;
5353
}
5454

@@ -59,7 +59,7 @@ private static function buildKeysPath(string $file): string
5959
*/
6060
private static function buildCertsPath(string $file): string
6161
{
62-
$base = dirname(dirname(__FILE__));
62+
$base = dirname(__FILE__, 2);
6363
return 'file://' . $base . DIRECTORY_SEPARATOR . self::CERTS_DIR . DIRECTORY_SEPARATOR . $file;
6464
}
6565

tests/XML/EncryptedCustomTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use SimpleSAML\XMLSecurity\Key\SymmetricKey;
1616
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
1717

18+
use function dirname;
19+
1820
/**
1921
* Class \SimpleSAML\XMLSecurity\Test\XML\EncryptedCustomTest
2022
*
@@ -41,7 +43,7 @@ class EncryptedCustomTest extends TestCase
4143
public function setUp(): void
4244
{
4345
$this->signedDocument = DOMDocumentFactory::fromFile(
44-
dirname(dirname(__FILE__)) . '/resources/xml/custom_CustomSignableSigned.xml',
46+
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignableSigned.xml',
4547
)->documentElement;
4648

4749
$this->privKey = PEMCertificatesMock::getPrivateKey(PEMCertificatesMock::PRIVATE_KEY);

tests/XML/SignableElementTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public function setUp(): void
5454
$this->testedClass = CustomSignable::class;
5555

5656
$this->xmlRepresentation = DOMDocumentFactory::fromFile(
57-
dirname(dirname(__FILE__)) . '/resources/xml/custom_CustomSignable.xml',
57+
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignable.xml',
5858
);
5959

6060
$this->signed = DOMDocumentFactory::fromFile(
61-
dirname(dirname(__FILE__)) . '/resources/xml/custom_CustomSignableSigned.xml',
61+
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignableSigned.xml',
6262
);
6363

6464
$certificate = PEMCertificatesMock::loadPlainCertificateFile(PEMCertificatesMock::SELFSIGNED_CERTIFICATE);
@@ -124,7 +124,7 @@ public function testSigningElement(): void
124124

125125
$customSignable->sign($signer, C::C14N_EXCLUSIVE_WITHOUT_COMMENTS, $keyInfo);
126126
$signed = DOMDocumentFactory::fromFile(
127-
dirname(dirname(__FILE__)) . '/resources/xml/custom_CustomSignableSignedWithId.xml',
127+
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignableSignedWithId.xml',
128128
);
129129

130130
$this->assertEquals(
@@ -160,7 +160,7 @@ public function testSigningDocumentWithComments(): void
160160

161161
$customSignable->sign($signer, C::C14N_EXCLUSIVE_WITH_COMMENTS, $keyInfo);
162162
$signed = DOMDocumentFactory::fromFile(
163-
dirname(dirname(__FILE__)) . '/resources/xml/custom_CustomSignableSignedWithComments.xml',
163+
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignableSignedWithComments.xml',
164164
);
165165

166166
$this->assertEquals(
@@ -196,7 +196,7 @@ public function testSigningElementWithIdAndComments(): void
196196

197197
$customSignable->sign($signer, C::C14N_EXCLUSIVE_WITH_COMMENTS, $keyInfo);
198198
$signed = DOMDocumentFactory::fromFile(
199-
dirname(dirname(__FILE__)) . '/resources/xml/custom_CustomSignableSignedWithCommentsAndId.xml'
199+
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignableSignedWithCommentsAndId.xml'
200200
);
201201

202202
$this->assertEquals(

tests/XML/SignedElementTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ final class SignedElementTest extends TestCase
4848
public function setUp(): void
4949
{
5050
$this->signedDocumentWithComments = DOMDocumentFactory::fromFile(
51-
dirname(dirname(__FILE__)) . '/resources/xml/custom_CustomSignableSignedWithComments.xml',
51+
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignableSignedWithComments.xml',
5252
)->documentElement;
5353

5454
$this->signedDocument = DOMDocumentFactory::fromFile(
55-
dirname(dirname(__FILE__)) . '/resources/xml/custom_CustomSignableSigned.xml',
55+
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignableSigned.xml',
5656
)->documentElement;
5757

5858
$this->tamperedDocument = DOMDocumentFactory::fromFile(
59-
dirname(dirname(__FILE__)) . '/resources/xml/custom_CustomSignableSignedTampered.xml',
59+
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignableSignedTampered.xml',
6060
)->documentElement;
6161

6262
$this->certificate = PEM::fromString(

tests/XML/ds/CanonicalizationMethodTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ protected function setUp(): void
3333
{
3434
$this->testedClass = CanonicalizationMethod::class;
3535

36-
$this->schema = dirname(dirname(dirname(dirname(__FILE__)))) . '/schemas/xmldsig1-schema.xsd';
36+
$this->schema = dirname(__FILE__, 4) . '/schemas/xmldsig1-schema.xsd';
3737

3838
$this->xmlRepresentation = DOMDocumentFactory::fromFile(
39-
dirname(dirname(dirname(dirname(__FILE__)))) . '/tests/resources/xml/ds_CanonicalizationMethod.xml',
39+
dirname(__FILE__, 3) . '/resources/xml/ds_CanonicalizationMethod.xml',
4040
);
4141
}
4242

tests/XML/ds/DigestMethodTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ protected function setUp(): void
3535
{
3636
$this->testedClass = DigestMethod::class;
3737

38-
$this->schema = dirname(dirname(dirname(dirname(__FILE__)))) . '/schemas/xmldsig1-schema.xsd';
38+
$this->schema = dirname(__FILE__, 4) . '/schemas/xmldsig1-schema.xsd';
3939

4040
$this->xmlRepresentation = DOMDocumentFactory::fromFile(
41-
dirname(dirname(dirname(dirname(__FILE__)))) . '/tests/resources/xml/ds_DigestMethod.xml',
41+
dirname(__FILE__, 3) . '/resources/xml/ds_DigestMethod.xml',
4242
);
4343
}
4444

tests/XML/ds/DigestValueTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ protected function setUp(): void
3535
{
3636
$this->testedClass = DigestValue::class;
3737

38-
$this->schema = dirname(dirname(dirname(dirname(__FILE__)))) . '/schemas/xmldsig1-schema.xsd';
38+
$this->schema = dirname(__FILE__, 4) . '/schemas/xmldsig1-schema.xsd';
3939

4040
$this->xmlRepresentation = DOMDocumentFactory::fromFile(
41-
dirname(dirname(dirname(dirname(__FILE__)))) . '/tests/resources/xml/ds_DigestValue.xml',
41+
dirname(__FILE__, 3) . '/resources/xml/ds_DigestValue.xml',
4242
);
4343
}
4444

0 commit comments

Comments
 (0)