Passed
Push — master ( 69d06b...aefa73 )
by Gabriel
06:27 queued 12s
created

DiscoverProviderTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 25
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_discover() 0 11 1
A test_discover_once() 0 10 1
1
<?php
2
3
namespace ByTIC\EventDispatcher\Tests\Discovery;
4
5
use ByTIC\EventDispatcher\Discovery\RegisterDiscoveredEvents;
6
use ByTIC\EventDispatcher\Tests\AbstractTest;
7
use ByTIC\EventDispatcher\Tests\Fixtures\Events\Event;
8
use Mockery;
0 ignored issues
show
Bug introduced by
The type Mockery 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...
9
use Mockery\Mock;
0 ignored issues
show
Bug introduced by
The type Mockery\Mock 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...
10
11
/**
12
 * Class DiscoverProviderTest
13
 * @package ByTIC\EventDispatcher\Tests\Discovery
14
 */
15
class DiscoverProviderTest extends AbstractTest
16
{
17
    public function test_discover()
18
    {
19
        $dispatcher = $this->newMockDispatcher();
20
21
        $provider = new RegisterDiscoveredEvents($dispatcher);
22
        $provider->addDiscoveryPath(TEST_FIXTURE_PATH . '/Listeners');
23
        $provider->register();
24
25
        $listeners = $dispatcher->getListeners(get_class(new Event()));
26
27
        self::assertGreaterThanOrEqual(2, count($listeners));
28
    }
29
30
    public function test_discover_once()
31
    {
32
        /** @var Mock|RegisterDiscoveredEvents $provider */
33
        $provider = Mockery::mock(RegisterDiscoveredEvents::class)->shouldAllowMockingProtectedMethods()->makePartial();
34
        $provider->shouldReceive('doDiscovery')->once();
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not exist on ByTIC\EventDispatcher\Di...egisterDiscoveredEvents. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        $provider->/** @scrutinizer ignore-call */ 
35
                   shouldReceive('doDiscovery')->once();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
        $provider->addDiscoveryPath(TEST_FIXTURE_PATH . '/Listeners');
36
37
        $provider->register();
38
        $provider->register();
39
        $provider->register();
40
    }
41
}
42