Skip to content

Commit

Permalink
minor #37831 stop using deprecated PHPUnit APIs (xabbuh)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

stop using deprecated PHPUnit APIs

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Commits
-------

3d209c46e4 stop using deprecated PHPUnit APIs
  • Loading branch information
fabpot committed Aug 17, 2020
2 parents e65c7f8 + 5b924ef commit 50ad671
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Tests/Encoder/Base64EncoderTest.php
Expand Up @@ -65,17 +65,17 @@ public function testPadLength()
$encoder = new Base64Encoder();
for ($i = 0; $i < 30; ++$i) {
$input = pack('C', random_int(0, 255));
$this->assertRegExp('~^[a-zA-Z0-9/\+]{2}==$~', $encoder->encodeString($input), 'A single byte should have 2 bytes of padding');
$this->assertMatchesRegularExpression('~^[a-zA-Z0-9/\+]{2}==$~', $encoder->encodeString($input), 'A single byte should have 2 bytes of padding');
}

for ($i = 0; $i < 30; ++$i) {
$input = pack('C*', random_int(0, 255), random_int(0, 255));
$this->assertRegExp('~^[a-zA-Z0-9/\+]{3}=$~', $encoder->encodeString($input), 'Two bytes should have 1 byte of padding');
$this->assertMatchesRegularExpression('~^[a-zA-Z0-9/\+]{3}=$~', $encoder->encodeString($input), 'Two bytes should have 1 byte of padding');
}

for ($i = 0; $i < 30; ++$i) {
$input = pack('C*', random_int(0, 255), random_int(0, 255), random_int(0, 255));
$this->assertRegExp('~^[a-zA-Z0-9/\+]{4}$~', $encoder->encodeString($input), 'Three bytes should have no padding');
$this->assertMatchesRegularExpression('~^[a-zA-Z0-9/\+]{4}$~', $encoder->encodeString($input), 'Three bytes should have no padding');
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Encoder/QpMimeHeaderEncoderTest.php
Expand Up @@ -31,7 +31,7 @@ public function testSpaceAndTabNeverAppear()
*/

$encoder = new QpMimeHeaderEncoder();
$this->assertNotRegExp('~[ \t]~', $encoder->encodeString("a \t b"), 'encoded-words in headers cannot contain LWSP as per RFC 2047.');
$this->assertDoesNotMatchRegularExpression('~[ \t]~', $encoder->encodeString("a \t b"), 'encoded-words in headers cannot contain LWSP as per RFC 2047.');
}

public function testSpaceIsRepresentedByUnderscore()
Expand Down
4 changes: 2 additions & 2 deletions Tests/Encoder/Rfc2231EncoderTest.php
Expand Up @@ -38,7 +38,7 @@ public function testEncodingAsciiCharactersProducesValidToken()
$encoded = $encoder->encodeString($string);

foreach (explode("\r\n", $encoded) as $line) {
$this->assertRegExp($this->rfc2045Token, $line, 'Encoder should always return a valid RFC 2045 token.');
$this->assertMatchesRegularExpression($this->rfc2045Token, $line, 'Encoder should always return a valid RFC 2045 token.');
}
}

Expand All @@ -53,7 +53,7 @@ public function testEncodingNonAsciiCharactersProducesValidToken()
$encoded = $encoder->encodeString($string);

foreach (explode("\r\n", $encoded) as $line) {
$this->assertRegExp($this->rfc2045Token, $line, 'Encoder should always return a valid RFC 2045 token.');
$this->assertMatchesRegularExpression($this->rfc2045Token, $line, 'Encoder should always return a valid RFC 2045 token.');
}
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/Header/UnstructuredHeaderTest.php
Expand Up @@ -78,7 +78,7 @@ public function testPrintableAsciiOnlyAppearsInHeaders()

$nonAsciiChar = pack('C', 0x8F);
$header = new UnstructuredHeader('X-Test', $nonAsciiChar);
$this->assertRegExp('~^[^:\x00-\x20\x80-\xFF]+: [^\x80-\xFF\r\n]+$~s', $header->toString());
$this->assertMatchesRegularExpression('~^[^:\x00-\x20\x80-\xFF]+: [^\x80-\xFF\r\n]+$~s', $header->toString());
}

public function testEncodedWordsFollowGeneralStructure()
Expand All @@ -91,7 +91,7 @@ public function testEncodedWordsFollowGeneralStructure()

$nonAsciiChar = pack('C', 0x8F);
$header = new UnstructuredHeader('X-Test', $nonAsciiChar);
$this->assertRegExp('~^X-Test: \=?.*?\?.*?\?.*?\?=$~s', $header->toString());
$this->assertMatchesRegularExpression('~^X-Test: \=?.*?\?.*?\?.*?\?=$~s', $header->toString());
}

public function testEncodedWordIncludesCharsetAndEncodingMethodAndText()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Part/Multipart/FormDataPartTest.php
Expand Up @@ -98,7 +98,7 @@ public function testBoundaryContentTypeHeader()
'file' => new DataPart('data.csv', 'data.csv', 'text/csv'),
]);
$headers = $f->getPreparedHeaders()->toArray();
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/^Content-Type: multipart\/form-data; boundary=[a-zA-Z0-9\-_]{8}$/',
$headers[0]
);
Expand Down

0 comments on commit 50ad671

Please sign in to comment.