1616use SebastianBergmann \CodeCoverage \Driver \Driver ;
1717use SebastianBergmann \CodeCoverage \Driver \PHPDBG ;
1818use SebastianBergmann \CodeCoverage \Driver \Xdebug ;
19+ use SebastianBergmann \Environment \Runtime ;
1920
2021/**
2122 * @covers SebastianBergmann\CodeCoverage\CodeCoverage
@@ -29,54 +30,27 @@ class CodeCoverageTest extends TestCase
2930
3031 protected function setUp ()
3132 {
32- $ this ->coverage = new CodeCoverage ;
33- }
33+ $ runtime = new Runtime ;
3434
35- public function testCanBeConstructedForXdebugWithoutGivenFilterObject ()
36- {
37- if (PHP_SAPI == 'phpdbg ' ) {
38- $ this ->markTestSkipped ('Requires PHP CLI and Xdebug ' );
35+ if (!$ runtime ->canCollectCodeCoverage ()) {
36+ $ this ->markTestSkipped ('No code coverage driver available ' );
3937 }
4038
41- $ this ->assertAttributeInstanceOf (
42- Xdebug::class,
43- 'driver ' ,
44- $ this ->coverage
45- );
46-
47- $ this ->assertAttributeInstanceOf (
48- Filter::class,
49- 'filter ' ,
50- $ this ->coverage
51- );
39+ $ this ->coverage = new CodeCoverage ;
5240 }
5341
54- public function testCanBeConstructedForXdebugWithGivenFilterObject ()
42+ public function testCanBeConstructedWithoutGivenFilterObject ()
5543 {
56- if (PHP_SAPI == ' phpdbg ' ) {
57- $ this -> markTestSkipped ( ' Requires PHP CLI and Xdebug' ) ;
44+ if (extension_loaded ( ' xdebug ' ) ) {
45+ $ expectedClass = Xdebug::class ;
5846 }
5947
60- $ filter = new Filter ;
61- $ coverage = new CodeCoverage (null , $ filter );
62-
63- $ this ->assertAttributeInstanceOf (
64- Xdebug::class,
65- 'driver ' ,
66- $ coverage
67- );
68-
69- $ this ->assertSame ($ filter , $ coverage ->filter ());
70- }
71-
72- public function testCanBeConstructedForPhpdbgWithoutGivenFilterObject ()
73- {
74- if (PHP_SAPI != 'phpdbg ' ) {
75- $ this ->markTestSkipped ('Requires PHPDBG ' );
48+ if (PHP_SAPI === 'phpdbg ' ) {
49+ $ expectedClass = PHPDBG ::class;
7650 }
7751
7852 $ this ->assertAttributeInstanceOf (
79- PHPDBG ::class ,
53+ $ expectedClass ,
8054 'driver ' ,
8155 $ this ->coverage
8256 );
@@ -88,17 +62,13 @@ public function testCanBeConstructedForPhpdbgWithoutGivenFilterObject()
8862 );
8963 }
9064
91- public function testCanBeConstructedForPhpdbgWithGivenFilterObject ()
65+ public function testCanBeConstructedWithGivenFilterObject ()
9266 {
93- if (PHP_SAPI != 'phpdbg ' ) {
94- $ this ->markTestSkipped ('Requires PHPDBG ' );
95- }
96-
9767 $ filter = new Filter ;
9868 $ coverage = new CodeCoverage (null , $ filter );
9969
10070 $ this ->assertAttributeInstanceOf (
101- PHPDBG ::class,
71+ Xdebug ::class,
10272 'driver ' ,
10373 $ coverage
10474 );
0 commit comments