FeatureContext   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createDatabase() 0 11 3
1
<?php
2
3
4
use Doctrine\Common\Persistence\ObjectManager;
5
use Doctrine\ORM\EntityManagerInterface;
6
use Doctrine\ORM\Tools\SchemaTool;
7
use Knp\FriendlyContexts\Context\Context;
8
9
class FeatureContext extends Context
10
{
11
    /**
12
     * @BeforeScenario
13
     */
14
    public function createDatabase()
15
    {
16
        /** @var ObjectManager[] $managers */
17
        $managers = $this->get('doctrine')->getManagers();
18
19
        foreach ($managers as $manager) {
20
            if ($manager instanceof EntityManagerInterface) {
21
                $schemaTool = new SchemaTool($manager);
22
                $schemaTool->dropDatabase();
23
                $schemaTool->createSchema(
24
                    $manager->getMetadataFactory()->getAllMetadata()
25
                );
26
            }
27
        }
28
    }
29
30
}