Skip to content

Commit 02042c2

Browse files
committed
no longer use the internal TestFailure class
1 parent 125b6f1 commit 02042c2

File tree

2 files changed

+12
-32
lines changed

2 files changed

+12
-32
lines changed

Tests/Test/Constraint/BrowserCookieValueSameTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\ExpectationFailedException;
1515
use PHPUnit\Framework\TestCase;
16-
use PHPUnit\Framework\TestFailure;
1716
use Symfony\Component\BrowserKit\AbstractBrowser;
1817
use Symfony\Component\BrowserKit\Cookie;
1918
use Symfony\Component\BrowserKit\CookieJar;
@@ -31,15 +30,10 @@ public function testConstraint()
3130
$constraint = new BrowserCookieValueSame('foo', 'babar', false, '/path');
3231
$this->assertFalse($constraint->evaluate($browser, '', true));
3332

34-
try {
35-
$constraint->evaluate($browser);
36-
} catch (ExpectationFailedException $e) {
37-
$this->assertEquals("Failed asserting that the Browser has cookie \"foo\" with path \"/path\" with value \"babar\".\n", TestFailure::exceptionToString($e));
33+
$this->expectException(ExpectationFailedException::class);
34+
$this->expectExceptionMessage('Failed asserting that the Browser has cookie "foo" with path "/path" with value "babar".');
3835

39-
return;
40-
}
41-
42-
$this->fail();
36+
$constraint->evaluate($browser);
4337
}
4438

4539
private function getBrowser(): AbstractBrowser

Tests/Test/Constraint/BrowserHasCookieTest.php

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\ExpectationFailedException;
1515
use PHPUnit\Framework\TestCase;
16-
use PHPUnit\Framework\TestFailure;
1716
use Symfony\Component\BrowserKit\AbstractBrowser;
1817
use Symfony\Component\BrowserKit\Cookie;
1918
use Symfony\Component\BrowserKit\CookieJar;
@@ -31,45 +30,32 @@ public function testConstraint()
3130
$constraint = new BrowserHasCookie('bar');
3231
$this->assertFalse($constraint->evaluate($browser, '', true));
3332

34-
try {
35-
$constraint->evaluate($browser);
36-
} catch (ExpectationFailedException $e) {
37-
$this->assertEquals("Failed asserting that the Browser has cookie \"bar\".\n", TestFailure::exceptionToString($e));
33+
$this->expectException(ExpectationFailedException::class);
34+
$this->expectExceptionMessage('Failed asserting that the Browser has cookie "bar".');
3835

39-
return;
40-
}
41-
42-
$this->fail();
36+
$constraint->evaluate($browser);
4337
}
4438

4539
public function testConstraintWithWrongPath()
4640
{
4741
$browser = $this->getBrowser();
4842
$constraint = new BrowserHasCookie('foo', '/other');
49-
try {
50-
$constraint->evaluate($browser);
51-
} catch (ExpectationFailedException $e) {
52-
$this->assertEquals("Failed asserting that the Browser has cookie \"foo\" with path \"/other\".\n", TestFailure::exceptionToString($e));
5343

54-
return;
55-
}
44+
$this->expectException(ExpectationFailedException::class);
45+
$this->expectExceptionMessage('Failed asserting that the Browser has cookie "foo" with path "/other".');
5646

57-
$this->fail();
47+
$constraint->evaluate($browser);
5848
}
5949

6050
public function testConstraintWithWrongDomain()
6151
{
6252
$browser = $this->getBrowser();
6353
$constraint = new BrowserHasCookie('foo', '/path', 'example.org');
64-
try {
65-
$constraint->evaluate($browser);
66-
} catch (ExpectationFailedException $e) {
67-
$this->assertEquals("Failed asserting that the Browser has cookie \"foo\" with path \"/path\" for domain \"example.org\".\n", TestFailure::exceptionToString($e));
6854

69-
return;
70-
}
55+
$this->expectException(ExpectationFailedException::class);
56+
$this->expectExceptionMessage('Failed asserting that the Browser has cookie "foo" with path "/path" for domain "example.org".');
7157

72-
$this->fail();
58+
$constraint->evaluate($browser);
7359
}
7460

7561
private function getBrowser(): AbstractBrowser

0 commit comments

Comments
 (0)