|
17 | 17 | use ReflectionClass; |
18 | 18 | use SebastianBergmann\CodeCoverage\CodeCoverage; |
19 | 19 | use SebastianBergmann\CodeCoverage\Driver\Driver; |
| 20 | +use SebastianBergmann\CodeCoverage\Driver\Granularity; |
20 | 21 | use SebastianBergmann\CodeCoverage\Driver\Selector; |
21 | 22 | use SebastianBergmann\CodeCoverage\Driver\Xdebug2NotEnabledException; |
22 | 23 | use SebastianBergmann\CodeCoverage\Driver\Xdebug3NotEnabledException; |
23 | 24 | use SebastianBergmann\CodeCoverage\Filter; |
24 | 25 | use SebastianBergmann\CodeCoverage\NoCodeCoverageDriverAvailableException; |
| 26 | +use SebastianBergmann\CodeCoverage\NoSupportedDriverAvailableException; |
25 | 27 | use Symfony\Component\Config\Definition\NodeInterface; |
26 | 28 | use Symfony\Component\Console\Input\InputInterface; |
27 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
|
30 | 32 |
|
31 | 33 | use function dirname; |
32 | 34 | use function sys_get_temp_dir; |
| 35 | +use function class_exists; |
33 | 36 |
|
34 | 37 | class ExtensionTest extends TestCase |
35 | 38 | { |
@@ -73,7 +76,7 @@ public function testContainerBuildsIncludingCoveredFiles(): void |
73 | 76 | try { |
74 | 77 | $selector = new Selector(); |
75 | 78 | $selector->forLineCoverage(new Filter()); |
76 | | - } catch (NoCodeCoverageDriverAvailableException|Xdebug2NotEnabledException|Xdebug3NotEnabledException $e) { |
| 79 | + } catch (NoSupportedDriverAvailableException|NoCodeCoverageDriverAvailableException|Xdebug2NotEnabledException|Xdebug3NotEnabledException $e) { |
77 | 80 | $this->markTestSkipped('Requires code coverage enabled'); |
78 | 81 | } |
79 | 82 |
|
@@ -129,7 +132,7 @@ public function testContainerBuildsExcludingCoveredFiles(): void |
129 | 132 | try { |
130 | 133 | $selector = new Selector(); |
131 | 134 | $selector->forLineCoverage(new Filter()); |
132 | | - } catch (NoCodeCoverageDriverAvailableException|Xdebug2NotEnabledException|Xdebug3NotEnabledException $e) { |
| 135 | + } catch (NoSupportedDriverAvailableException|NoCodeCoverageDriverAvailableException|Xdebug2NotEnabledException|Xdebug3NotEnabledException $e) { |
133 | 136 | $this->markTestSkipped('Requires code coverage enabled'); |
134 | 137 | } |
135 | 138 |
|
@@ -279,7 +282,11 @@ public function testContainerBuildsWithCoverageUnavailable(): void |
279 | 282 | ); |
280 | 283 |
|
281 | 284 | $extension = $this->createPartialMock(Extension::class, ['initCodeCoverage']); |
282 | | - $extension->method('initCodeCoverage')->willThrowException(new NoCodeCoverageDriverAvailableException()); |
| 285 | + if (class_exists(NoSupportedDriverAvailableException::class)) { |
| 286 | + $extension->method('initCodeCoverage')->willThrowException(new NoSupportedDriverAvailableException(Granularity::Line)); |
| 287 | + } else { |
| 288 | + $extension->method('initCodeCoverage')->willThrowException(new NoCodeCoverageDriverAvailableException()); |
| 289 | + } |
283 | 290 |
|
284 | 291 | $extension->process($container); |
285 | 292 |
|
|
0 commit comments