1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the ONGR package. |
5
|
|
|
* |
6
|
|
|
* (c) NFQ Technologies UAB <[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
|
|
|
namespace ONGR\SettingsBundle\Tests\Unit\DependencyInjection\Compiler; |
13
|
|
|
|
14
|
|
|
use ONGR\SettingsBundle\DependencyInjection\Compiler\ProviderPass; |
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
16
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
17
|
|
|
|
18
|
|
View Code Duplication |
class ProviderPassTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Test for process. |
22
|
|
|
*/ |
23
|
|
|
public function testProcess() |
24
|
|
|
{ |
25
|
|
|
$container = new ContainerBuilder(); |
26
|
|
|
$container->setDefinition('ongr_settings.settings_container', new Definition()); |
27
|
|
|
$container->setParameter('ongr_settings.settings_container.profiles', ['default', 'custom']); |
28
|
|
|
$container->setParameter('ongr_settings.connection.repository', 'es.manager.default.setting'); |
29
|
|
|
|
30
|
|
|
$definition = new Definition(); |
31
|
|
|
$definition->addTag('ongr_settings.settings_provider', ['profile' => 'custom', 'priority' => 9]); |
32
|
|
|
$container->setDefinition('ongr_settings.custom_settings_provider', $definition); |
33
|
|
|
|
34
|
|
|
$definition = new Definition(); |
35
|
|
|
$definition->addTag('ongr_settings.settings_provider'); |
36
|
|
|
$container->setDefinition('ongr_settings.unregistered_settings_provider', $definition); |
37
|
|
|
|
38
|
|
|
$pass = new ProviderPass(); |
39
|
|
|
$pass->process($container); |
40
|
|
|
|
41
|
|
|
$methodCalls = $container->getDefinition('ongr_settings.settings_container')->getMethodCalls(); |
42
|
|
|
$this->assertCount(3, $methodCalls); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
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.