Completed
Push — ezp-30616 ( 9239a0...7bf8e8 )
by
unknown
57:53 queued 37:56
created

SignalSlotPassTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 56
loc 56
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 5 5 1
A registerCompilerPass() 4 4 1
A testAttachSignal() 16 16 1
A testAttachSignalNoAlias() 16 16 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
/**
4
 * File containing the SignalSlotPassTest class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Base\Tests\Container\Compiler\Search;
10
11
use eZ\Publish\Core\Base\Container\Compiler\Search\SignalSlotPass;
12
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\DependencyInjection\Definition;
15
use Symfony\Component\DependencyInjection\Reference;
16
17 View Code Duplication
class SignalSlotPassTest extends AbstractCompilerPassTestCase
0 ignored issues
show
Duplication introduced by
This class 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...
18
{
19
    protected function setUp()
20
    {
21
        parent::setUp();
22
        $this->setDefinition('ezpublish.signalslot.signal_dispatcher', new Definition());
23
    }
24
25
    /**
26
     * Register the compiler pass under test, just like you would do inside a bundle's load()
27
     * method:.
28
     *
29
     *   $container->addCompilerPass(new MyCompilerPass());
30
     */
31
    protected function registerCompilerPass(ContainerBuilder $container)
32
    {
33
        $container->addCompilerPass(new SignalSlotPass());
0 ignored issues
show
Deprecated Code introduced by
The class eZ\Publish\Core\Base\Con...r\Search\SignalSlotPass has been deprecated with message: Use {@see \eZ\Publish\Core\Base\Container\Compiler\Search\SearchEngineSignalSlotPass}

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
34
    }
35
36
    public function testAttachSignal()
37
    {
38
        $signal = 'signal_identifier';
39
        $serviceId = 'service_id';
40
        $def = new Definition();
41
        $def->addTag('ezpublish.search.slot', array('signal' => $signal));
42
        $this->setDefinition($serviceId, $def);
43
44
        $this->compile();
45
46
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
47
            'ezpublish.signalslot.signal_dispatcher',
48
            'attach',
49
            array($signal, new Reference($serviceId))
50
        );
51
    }
52
53
    /**
54
     * @expectedException \LogicException
55
     */
56
    public function testAttachSignalNoAlias()
57
    {
58
        $signal = 'signal_identifier';
59
        $serviceId = 'service_id';
60
        $def = new Definition();
61
        $def->addTag('ezpublish.search.slot');
62
        $this->setDefinition($serviceId, $def);
63
64
        $this->compile();
65
66
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
67
            'ezpublish.signalslot.signal_dispatcher',
68
            'attach',
69
            array($signal, new Reference($serviceId))
70
        );
71
    }
72
}
73