Skip to content

Commit 11031a5

Browse files
committed
use try+catch+fail when expecting exceptions with properties
1 parent 59f527c commit 11031a5

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

tests/SymfonyCommandTaskIntegrationTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace VasekPurchart\Phing\SymfonyCommand;
66

7+
use PHPUnit\Framework\Assert;
78
use Project;
89
use VasekPurchart\Phing\PhingTester\PhingTester;
910

@@ -89,13 +90,17 @@ public function testCallCommandAndOverrideDefaults(): void
8990

9091
public function testMissingApp(): void
9192
{
92-
$tester = new PhingTester(__DIR__ . '/symfony-command-task-integration-test.xml');
93+
$buildFilePath = __DIR__ . '/symfony-command-task-integration-test.xml';
94+
$tester = new PhingTester($buildFilePath);
9395
$target = __FUNCTION__;
9496

95-
$this->expectException(\BuildException::class);
96-
$this->expectExceptionMessageMatches('~app.+required~');
97-
98-
$tester->executeTarget($target);
97+
try {
98+
$tester->executeTarget($target);
99+
Assert::fail('Exception expected');
100+
} catch (\BuildException $e) {
101+
Assert::assertStringStartsWith($buildFilePath, $e->getLocation()->toString());
102+
Assert::assertRegExp('~app.+required~', $e->getMessage());
103+
}
99104
}
100105

101106
}

0 commit comments

Comments
 (0)