Completed
Push — 1.0-composer-fixes ( df0dc6 )
by Kamil
49:36 queued 29:22
created

AbstractResource   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 7
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
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 Sylius\Bundle\ResourceBundle\Tests\DependencyInjection\Compiler;
15
16
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
17
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterResourcesPass;
18
use Sylius\Component\Resource\Model\ResourceInterface;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\DependencyInjection\Definition;
21
22
class RegisterResourcesPassTest extends AbstractCompilerPassTestCase
23
{
24
    /**
25
     * @test
26
     */
27
    public function it_adds_method_call_to_resource_registry_if_resources_exist()
28
    {
29
        $this->setDefinition('sylius.resource_registry', new Definition());
30
31
        $this->setParameter(
32
            'sylius.resources',
33
            [
34
                'app.book' => ['classes' => ['model' => BookClass::class]],
35
                'app.author' => ['classes' => ['model' => AuthorClass::class]],
36
            ]
37
        );
38
39
        $this->compile();
40
41
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
42
            'sylius.resource_registry',
43
            'addFromAliasAndConfiguration',
44
            ['app.book', ['classes' => ['model' => BookClass::class]]]
45
        );
46
47
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
48
            'sylius.resource_registry',
49
            'addFromAliasAndConfiguration',
50
            ['app.author', ['classes' => ['model' => AuthorClass::class]]]
51
        );
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    protected function registerCompilerPass(ContainerBuilder $container)
58
    {
59
        $container->addCompilerPass(new RegisterResourcesPass());
60
    }
61
}
62
63
class AbstractResource implements ResourceInterface
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
64
{
65
    public function getId()
66
    {
67
        return;
68
    }
69
}
70
class BookClass extends AbstractResource
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
71
{
72
}
73
class AuthorClass extends AbstractResource
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
74
{
75
}
76