66
77use FriendsOfPhpSpec \PhpSpec \CodeCoverage \Listener \CodeCoverageListener ;
88use PhpSpec \Console \ConsoleIO ;
9- use PhpSpec \Event \SuiteEvent ;
109use PhpSpec \ObjectBehavior ;
11- use Prophecy \Argument ;
1210use SebastianBergmann \CodeCoverage \CodeCoverage ;
11+ use SebastianBergmann \CodeCoverage \Driver \Driver ;
1312use SebastianBergmann \CodeCoverage \Filter ;
14- use SebastianBergmann \CodeCoverage \Report ;
13+ use SebastianBergmann \CodeCoverage \RawCodeCoverageData ;
1514
1615/**
16+ * Disabled due to tests breaking as php-code-coverage marked their classes
17+ * final and we cannot mock them. The tests should be converted into proper
18+ * functional (integration) tests instead. This file is left for reference.
19+ *
20+ * @see https://github.com/leanphp/phpspec-code-coverage/issues/19
21+ *
1722 * @author Henrik Bjornskov
1823 */
1924class CodeCoverageListenerSpec extends ObjectBehavior
@@ -25,174 +30,25 @@ public function it_is_initializable()
2530
2631 public function let (ConsoleIO $ io )
2732 {
28- $ this ->beConstructedWith ($ io , new CodeCoverage (), []);
33+ $ codeCoverage = new CodeCoverage (new DriverStub (), new Filter ());
34+
35+ $ this ->beConstructedWith ($ io , $ codeCoverage , []);
36+ }
37+ }
38+
39+ class DriverStub extends Driver
40+ {
41+ public function nameAndVersion (): string
42+ {
43+ return 'DriverStub ' ;
2944 }
3045
31- /**
32- * Disabled due to tests breaking as php-code-coverage marked their classes
33- * final and we cannot mock them. The tests should be converted into proper
34- * functional (integration) tests instead. This file is left for reference.
35- *
36- * @see https://github.com/leanphp/phpspec-code-coverage/issues/19
37- *
38- * function let(ConsoleIO $io, CodeCoverage $coverage)
39- * {
40- * $this->beConstructedWith($io, $coverage, array());
41- * }
42- *
43- * function it_is_initializable()
44- * {
45- * $this->shouldHaveType('LeanPHP\PhpSpec\CodeCoverage\Listener\CodeCoverageListener');
46- * }
47- *
48- * function it_should_run_all_reports(
49- * CodeCoverage $coverage,
50- * Report\Clover $clover,
51- * Report\PHP $php,
52- * SuiteEvent $event,
53- * ConsoleIO $io
54- * ) {
55- * $reports = array(
56- * 'clover' => $clover,
57- * 'php' => $php
58- * );
59- *
60- * $io->isVerbose()->willReturn(false);
61- *
62- * $this->beConstructedWith($io, $coverage, $reports);
63- * $this->setOptions(array(
64- * 'format' => array('clover', 'php'),
65- * 'output' => array(
66- * 'clover' => 'coverage.xml',
67- * 'php' => 'coverage.php'
68- * )
69- * ));
70- *
71- * $clover->process($coverage, 'coverage.xml')->shouldBeCalled();
72- * $php->process($coverage, 'coverage.php')->shouldBeCalled();
73- *
74- * $this->afterSuite($event);
75- * }
76- *
77- * function it_should_color_output_text_report_by_default(
78- * CodeCoverage $coverage,
79- * Report\Text $text,
80- * SuiteEvent $event,
81- * ConsoleIO $io
82- * ) {
83- * $reports = array(
84- * 'text' => $text
85- * );
86- *
87- * $this->beConstructedWith($io, $coverage, $reports);
88- * $this->setOptions(array(
89- * 'format' => 'text'
90- * ));
91- *
92- * $io->isVerbose()->willReturn(false);
93- * $io->isDecorated()->willReturn(true);
94- *
95- * $text->process($coverage, true)->willReturn('report');
96- * $io->writeln('report')->shouldBeCalled();
97- *
98- * $this->afterSuite($event);
99- * }
100- *
101- * function it_should_not_color_output_text_report_unless_specified(
102- * CodeCoverage $coverage,
103- * Report\Text $text,
104- * SuiteEvent $event,
105- * ConsoleIO $io
106- * ) {
107- * $reports = array(
108- * 'text' => $text
109- * );
110- *
111- * $this->beConstructedWith($io, $coverage, $reports);
112- * $this->setOptions(array(
113- * 'format' => 'text'
114- * ));
115- *
116- * $io->isVerbose()->willReturn(false);
117- * $io->isDecorated()->willReturn(false);
118- *
119- * $text->process($coverage, false)->willReturn('report');
120- * $io->writeln('report')->shouldBeCalled();
121- *
122- * $this->afterSuite($event);
123- * }
124- *
125- * function it_should_output_html_report(
126- * CodeCoverage $coverage,
127- * Report\Html\Facade $html,
128- * SuiteEvent $event,
129- * ConsoleIO $io
130- * ) {
131- * $reports = array(
132- * 'html' => $html
133- * );
134- *
135- * $this->beConstructedWith($io, $coverage, $reports);
136- * $this->setOptions(array(
137- * 'format' => 'html',
138- * 'output' => array('html' => 'coverage'),
139- * ));
140- *
141- * $io->isVerbose()->willReturn(false);
142- * $io->writeln(Argument::any())->shouldNotBeCalled();
143- *
144- * $html->process($coverage, 'coverage')->willReturn('report');
145- *
146- * $this->afterSuite($event);
147- * }
148- *
149- * function it_should_provide_extra_output_in_verbose_mode(
150- * CodeCoverage $coverage,
151- * Report\Html\Facade $html,
152- * SuiteEvent $event,
153- * ConsoleIO $io
154- * ) {
155- * $reports = array(
156- * 'html' => $html,
157- * );
158- *
159- * $this->beConstructedWith($io, $coverage, $reports);
160- * $this->setOptions(array(
161- * 'format' => 'html',
162- * 'output' => array('html' => 'coverage'),
163- * ));
164- *
165- * $io->isVerbose()->willReturn(true);
166- * $io->writeln('')->shouldBeCalled();
167- * $io->writeln('Generating code coverage report in html format ...')->shouldBeCalled();
168- *
169- * $this->afterSuite($event);
170- * }
171- *
172- * function it_should_correctly_handle_black_listed_files_and_directories(
173- * CodeCoverage $coverage,
174- * SuiteEvent $event,
175- * Filter $filter,
176- * ConsoleIO $io
177- * )
178- * {
179- * $this->beConstructedWith($io, $coverage, array());
180- *
181- * $coverage->filter()->willReturn($filter);
182- *
183- * $this->setOptions(array(
184- * 'whitelist' => array('src'),
185- * 'blacklist' => array('src/filter'),
186- * 'whitelist_files' => array('src/filter/whilelisted_file'),
187- * 'blacklist_files' => array('src/filtered_file')
188- * ));
189- *
190- * $filter->addDirectoryToWhitelist('src')->shouldBeCalled();
191- * $filter->removeDirectoryFromWhitelist('src/filter')->shouldBeCalled();
192- * $filter->addFileToWhitelist('src/filter/whilelisted_file')->shouldBeCalled();
193- * $filter->removeFileFromWhitelist('src/filtered_file')->shouldBeCalled();
194- *
195- * $this->beforeSuite($event);
196- * }
197- */
46+ public function start (bool $ determineUnusedAndDead = true ): void
47+ {
48+ }
49+
50+ public function stop (): RawCodeCoverageData
51+ {
52+ return RawCodeCoverageData::fromXdebugWithoutPathCoverage ([]);
53+ }
19854}
0 commit comments