Issues (142)

Spec/CodeCoverageSpec.php (7 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;
0 ignored issues
show
The type PhpSpec\ObjectBehavior was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
use Prophecy\Argument;
0 ignored issues
show
The type Prophecy\Argument was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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
Are you sure the usage of $subscriber->refresh(Prophecy\Argument::cetera()) targeting Spec\Doyo\Bridge\CodeCov...stSubscriber::refresh() 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 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.

Loading history...
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 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.

Loading history...
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 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.

Loading history...
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 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.

Loading history...
77
            ->stop(Argument::type(CoverageEvent::class), Argument::cetera())
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 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.

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