Completed
Push — master ( 3dfb16...ce0600 )
by Rafael
8s
created

LoadFixturesSubscriber   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 39
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 4 1
A loadFixtures() 0 6 1
A __construct() 0 4 1
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Behat\Fixtures;
12
13
use Behat\Behat\EventDispatcher\Event\ScenarioTested;
14
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15
use Symfony\Component\HttpKernel\KernelInterface;
16
use Ynlo\GraphQLBundle\Test\FixtureLoader\FixtureLoader;
17
18
class LoadFixturesSubscriber implements EventSubscriberInterface
19
{
20
    /**
21
     * @var KernelInterface
22
     */
23
    protected $kernel;
24
25
    /**
26
     * @var FixtureManager
27
     */
28
    protected $fixtureManager;
29
30
    /**
31
     * LoadFixturesSubscriber constructor.
32
     *
33
     * @param KernelInterface $kernel
34
     */
35
    public function __construct(KernelInterface $kernel, FixtureManager $fixtureManager)
36
    {
37
        $this->kernel = $kernel;
38
        $this->fixtureManager = $fixtureManager;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public static function getSubscribedEvents()
45
    {
46
        return [
47
            ScenarioTested::BEFORE => 'loadFixtures',
48
        ];
49
    }
50
51
    public function loadFixtures()
52
    {
53
        $container = $this->kernel->getContainer();
54
        $registry = $container->get('doctrine');
55
        $fixturesLoader = new FixtureLoader($container, $registry);
56
        $this->fixtureManager->setRepository($fixturesLoader->loadFixtures());
57
    }
58
}