Completed
Push — develop ( 0a2cdf...062ac6 )
by Bartko
03:22
created

Doctrine2DBALTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B getAdapter() 0 24 2
1
<?php
2
namespace StefanoTreeTest\Integration\Adapter;
3
4
use Doctrine\DBAL;
5
use StefanoTree\NestedSet\Adapter\AdapterInterface as TreeAdapterInterface;
6
use StefanoTree\NestedSet\Adapter\Doctrine2DBAL as NestedSetAdapter;
7
use StefanoTree\NestedSet\Options;
8
9
class Doctrine2DBALTest
10
    extends AdapterTestAbstract
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
11
{
12
    /**
13
     * @return TreeAdapterInterface
14
     */
15
    protected function getAdapter()
16
    {
17
        $config = new DBAL\Configuration();
18
        $connectionParams = array(
19
            'dbname' => TEST_STEFANO_DB_DB_NAME,
20
            'user' => TEST_STEFANO_DB_USER,
21
            'password' => TEST_STEFANO_DB_PASSWORD,
22
            'host' => TEST_STEFANO_DB_HOSTNAME,
23
            'driver' => 'pdo_' . strtolower(TEST_STEFANO_DB_ADAPTER),
24
        );
25
26
        $connection = DBAL\DriverManager::getConnection($connectionParams, $config);
27
28
        $options = new Options(array(
29
            'tableName' => 'tree_traversal',
30
            'idColumnName' => 'tree_traversal_id',
31
        ));
32
33
        if ('pgsql' == TEST_STEFANO_DB_ADAPTER) {
34
            $options->setSequenceName('tree_traversal_tree_traversal_id_seq');
35
        }
36
37
        return new NestedSetAdapter($options, $connection);
38
    }
39
}
40