Issues (142)

Spec/CodeCoverageSpec.php (2 issues)

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();
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();
64
        $subscriber->start(Argument::cetera())->shouldBeCalled();
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
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 ignore-call  annotation

77
            ->/** @scrutinizer ignore-call */ 
78
              stop(Argument::type(CoverageEvent::class), Argument::cetera())

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.

Loading history...
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
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 ignore-call  annotation

88
        $subscriber->/** @scrutinizer ignore-call */ 
89
                     complete(Argument::cetera())->shouldBeCalledOnce();

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.

Loading history...
89
        $this->complete()->shouldHaveType(CoverageEvent::class);
90
    }
91
}
92