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

Doctrine2DBALTest::getAdapter()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
cc 2
eloc 15
nc 2
nop 0
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