Skip to content

Commit f0695bb

Browse files
VasekPurchartondrejmirtes
authored andcommitted
Test that UniqueConstraintViolationException from EntityManager::flush() is not marked as dead catch
1 parent 802cc56 commit f0695bb

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Rules\Exceptions;
4+
5+
use PHPStan\Rules\Rule;
6+
use PHPStan\Testing\RuleTestCase;
7+
8+
/**
9+
* @extends RuleTestCase<CatchWithUnthrownExceptionRule>
10+
*/
11+
class CatchWithUnthrownExceptionRuleTest extends RuleTestCase
12+
{
13+
14+
protected function getRule(): Rule
15+
{
16+
return self::getContainer()->getByType(CatchWithUnthrownExceptionRule::class);
17+
}
18+
19+
public function testRule(): void
20+
{
21+
$this->analyse([__DIR__ . '/data/unthrown-exception.php'], []);
22+
}
23+
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace UnthrownException;
4+
5+
class FooFacade
6+
{
7+
8+
/** @var \Doctrine\ORM\EntityManager */
9+
private $entityManager;
10+
11+
public function doFoo(): void
12+
{
13+
try {
14+
$this->entityManager->flush();
15+
} catch (\Doctrine\DBAL\Exception\UniqueConstraintViolationException $e) {
16+
// pass
17+
}
18+
}
19+
20+
}

0 commit comments

Comments
 (0)