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

DatabaseTestCaseTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 30
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A startTransactionBefore() 0 5 1
A rollbackTransactionAfter() 0 5 1
A importFixtures() 0 6 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
}