Completed
Pull Request — master (#335)
by Simon
07:27 queued 03:11
created

DatabaseTestCaseTrait::importFixtures()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace ShopwarePlugins\Connect\Tests;
4
5
use Doctrine\DBAL\Connection;
6
7
trait DatabaseTestCaseTrait
8
{
9
    /**
10
     * @before
11
     */
12
    protected function startTransactionBefore()
13
    {
14
        $connection = Shopware()->Container()->get('dbal_connection');
15
        $connection->beginTransaction();
16
    }
17
18
    /**
19
     * @after
20
     */
21
    protected function rollbackTransactionAfter()
22
    {
23
        $connection = Shopware()->Container()->get('dbal_connection');
24
        $connection->rollBack();
25
    }
26
27
    /**
28
     * @param string $file
29
     */
30
    public function importFixtures($file)
31
    {
32
        /** @var Connection $connection */
33
        $connection = Shopware()->Container()->get('dbal_connection');
34
        $connection->executeQuery(file_get_contents($file));
35
    }
36
}