AspectKernelFactoryTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 77.27 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 34
loc 44
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A itCreatesKernelOnInvoke() 17 17 1
A itCreatesKernelOnCreateService() 17 17 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Go\Zend\Framework\Tests\Unit\Factory;
4
5
use Go\Core\AspectKernel;
6
use Go\Zend\Framework\Factory\AspectKernelFactory;
7
use Go\Zend\Framework\Module;
8
use PHPUnit\Framework\TestCase;
9
use Zend\ServiceManager\ServiceLocatorInterface;
10
11
/**
12
 * @package Go\Zend\Framework\Tests\Unit\Factory
13
 */
14
class AspectKernelFactoryTest extends TestCase
15
{
16
    /**
17
     * @test
18
     */
19 View Code Duplication
    public function itCreatesKernelOnInvoke()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
    {
21
        $serviceLocator = $this->prophesize(ServiceLocatorInterface::class);
22
        $serviceLocator->get('config')
23
            ->willReturn([Module::CONFIG_KEY => require __DIR__ . '/../../resources/goaop_module.php'])
24
            ->shouldBeCalled();
25
26
        $factory = new AspectKernelFactory();
27
28
        $instance = $factory($serviceLocator->reveal(), AspectKernel::class);
29
30
        $this->assertInstanceOf(
31
            AspectKernel::class,
32
            $instance,
33
            'factory should return an instance of ' . AspectKernel::class
34
        );
35
    }
36
37
    /**
38
     * @test
39
     */
40 View Code Duplication
    public function itCreatesKernelOnCreateService()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42
        $serviceLocator = $this->prophesize(ServiceLocatorInterface::class);
43
        $serviceLocator->get('config')
44
            ->willReturn([Module::CONFIG_KEY => require __DIR__ . '/../../resources/goaop_module.php'])
45
            ->shouldBeCalled();
46
47
        $factory = new AspectKernelFactory();
48
49
        $instance = $factory->createService($serviceLocator->reveal());
50
51
        $this->assertInstanceOf(
52
            AspectKernel::class,
53
            $instance,
54
            'factory should return an instance of ' . AspectKernel::class
55
        );
56
    }
57
}