-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
feature/test-doublesTest Stubs and Mock ObjectsTest Stubs and Mock Objectstype/bugSomething is brokenSomething is broken
Description
Q | A |
---|---|
PHPUnit version | 8.2.x |
PHP version | 7.2.19 |
Installation Method | Composer |
I have an abstract class which may throws an exception within the constructor. The test case for this class calls expectException()
and then getMockForAbstractClass()
. The test result is error, because the (actually expected) exception is thrown.
This occurs with phpunit >8.2.0. With 8.1.6 everything was working as expected.
Here is a minimal example:
<?php
use PHPUnit\Framework\TestCase;
abstract class AbstractFooBar
{
public function __construct()
{
throw new InvalidArgumentException('test');
}
}
class AbstractFooBarTest extends TestCase
{
public function testConstructorException()
{
$this->expectException(InvalidArgumentException::class);
$this->getMockForAbstractClass(AbstractFooBar::class);
}
}
Metadata
Metadata
Assignees
Labels
feature/test-doublesTest Stubs and Mock ObjectsTest Stubs and Mock Objectstype/bugSomething is brokenSomething is broken