1 | <?php |
||||||
2 | |||||||
3 | /* |
||||||
4 | * This file is part of the doyo/code-coverage project. |
||||||
5 | * |
||||||
6 | * (c) Anthonius Munthi <[email protected]> |
||||||
7 | * |
||||||
8 | * For the full copyright and license information, please view the LICENSE |
||||||
9 | * file that was distributed with this source code. |
||||||
10 | */ |
||||||
11 | |||||||
12 | declare(strict_types=1); |
||||||
13 | |||||||
14 | namespace Spec\Doyo\Bridge\CodeCoverage; |
||||||
15 | |||||||
16 | use Doyo\Bridge\CodeCoverage\CodeCoverage; |
||||||
17 | use Doyo\Bridge\CodeCoverage\Console\ConsoleIO; |
||||||
18 | use Doyo\Bridge\CodeCoverage\Environment\RuntimeInterface; |
||||||
19 | use Doyo\Bridge\CodeCoverage\Event\CoverageEvent; |
||||||
20 | use Doyo\Bridge\CodeCoverage\ProcessorInterface; |
||||||
21 | use Doyo\Bridge\CodeCoverage\TestCase; |
||||||
22 | use PhpSpec\ObjectBehavior; |
||||||
23 | use Prophecy\Argument; |
||||||
24 | |||||||
25 | /** |
||||||
26 | * Class CodeCoverageSpec. |
||||||
27 | * |
||||||
28 | * @covers \Doyo\Bridge\CodeCoverage\CodeCoverage |
||||||
29 | */ |
||||||
30 | class CodeCoverageSpec extends ObjectBehavior |
||||||
31 | { |
||||||
32 | public function let( |
||||||
33 | ProcessorInterface $processor, |
||||||
34 | ConsoleIO $consoleIO, |
||||||
35 | RuntimeInterface $runtime, |
||||||
36 | TestSubscriber $subscriber |
||||||
37 | ) { |
||||||
38 | $this->beConstructedWith($processor, $consoleIO, $runtime); |
||||||
39 | $runtime->canCollectCodeCoverage()->willReturn(true); |
||||||
40 | $this->addSubscriber($subscriber); |
||||||
41 | } |
||||||
42 | |||||||
43 | public function it_is_initializable() |
||||||
44 | { |
||||||
45 | $this->shouldHaveType(CodeCoverage::class); |
||||||
46 | } |
||||||
47 | |||||||
48 | public function it_should_dispatch_coverage_refresh_event( |
||||||
49 | ProcessorInterface $processor, |
||||||
50 | TestSubscriber $subscriber |
||||||
51 | ) { |
||||||
52 | $processor->clear()->shouldBeCalledOnce(); |
||||||
53 | $subscriber->refresh(Argument::cetera())->shouldBeCalledOnce(); |
||||||
0 ignored issues
–
show
|
|||||||
54 | |||||||
55 | $this->refresh(); |
||||||
56 | } |
||||||
57 | |||||||
58 | public function it_should_dispatch_coverage_event_start( |
||||||
59 | ProcessorInterface $processor, |
||||||
60 | TestCase $testCase, |
||||||
61 | TestSubscriber $subscriber |
||||||
62 | ) { |
||||||
63 | $subscriber->beforeStart(Argument::cetera())->shouldBeCalled(); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$subscriber->beforeStart...ecy\Argument::cetera()) targeting Spec\Doyo\Bridge\CodeCov...bscriber::beforeStart() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
64 | $subscriber->start(Argument::cetera())->shouldBeCalled(); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$subscriber->start(Prophecy\Argument::cetera()) targeting Spec\Doyo\Bridge\CodeCov...TestSubscriber::start() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
65 | |||||||
66 | $processor->start($testCase)->shouldBeCalled(); |
||||||
67 | |||||||
68 | $this->start($testCase); |
||||||
69 | } |
||||||
70 | |||||||
71 | public function it_should_dispatch_coverage_event_stop( |
||||||
72 | ProcessorInterface $processor, |
||||||
73 | TestSubscriber $subscriber |
||||||
74 | ) { |
||||||
75 | $processor->stop()->shouldBeCalledOnce(); |
||||||
76 | $subscriber |
||||||
0 ignored issues
–
show
Are you sure the usage of
$subscriber->stop(Prophe...ecy\Argument::cetera()) targeting Spec\Doyo\Bridge\CodeCov...\TestSubscriber::stop() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
77 | ->stop(Argument::type(CoverageEvent::class), Argument::cetera()) |
||||||
0 ignored issues
–
show
The call to
Spec\Doyo\Bridge\CodeCov...\TestSubscriber::stop() has too many arguments starting with Prophecy\Argument::cetera() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||
78 | ->shouldBeCalledOnce(); |
||||||
79 | |||||||
80 | $this->stop(); |
||||||
81 | } |
||||||
82 | |||||||
83 | public function it_should_dispatch_coverage_event_complete( |
||||||
84 | ProcessorInterface $processor, |
||||||
85 | TestSubscriber $subscriber |
||||||
86 | ) { |
||||||
87 | $processor->complete()->shouldBeCalledOnce(); |
||||||
88 | $subscriber->complete(Argument::cetera())->shouldBeCalledOnce(); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$subscriber->complete(Pr...ecy\Argument::cetera()) targeting Spec\Doyo\Bridge\CodeCov...tSubscriber::complete() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() The call to
Spec\Doyo\Bridge\CodeCov...tSubscriber::complete() has too many arguments starting with Prophecy\Argument::cetera() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||
89 | $this->complete()->shouldHaveType(CoverageEvent::class); |
||||||
90 | } |
||||||
91 | } |
||||||
92 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.