Completed
Push — master ( 2e5d0e...583994 )
by Bartko
06:02
created

getTreeAdapter()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 26
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 26
rs 8.8571
cc 2
eloc 16
nc 2
nop 0
1
<?php
2
namespace StefanoTreeTest\Integration;
3
4
use StefanoTree\NestedSet as TreeAdapter;
5
use StefanoTree\NestedSet\Adapter\Doctrine2DBALAdapter;
6
use StefanoTree\NestedSet\Options;
7
8
class NestedSetWithDoctrine2DbAdapterAndScopeTest
9
    extends AbstractScopeTest
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
10
{
11
    protected function getTreeAdapter()
12
    {
13
        $config = new \Doctrine\DBAL\Configuration();
14
15
        $connectionParams = array(
16
            'dbname' => TEST_STEFANO_DB_DB_NAME,
17
            'user' => TEST_STEFANO_DB_USER,
18
            'password' => TEST_STEFANO_DB_PASSWORD,
19
            'host' => TEST_STEFANO_DB_HOSTNAME,
20
            'driver' => 'pdo_' . strtolower(TEST_STEFANO_DB_ADAPTER),
21
        );
22
23
        $connection = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
24
25
        $options = new Options(array(
26
            'tableName' => 'tree_traversal_with_scope',
27
            'idColumnName' => 'tree_traversal_id',
28
            'scopeColumnName' => 'scope',
29
        ));
30
31
        if ('pgsql' == TEST_STEFANO_DB_ADAPTER) {
32
            $options->setSequenceName('tree_traversal_with_scope_tree_traversal_id_seq');
33
        }
34
35
        return new TreeAdapter(new Doctrine2DBALAdapter($options, $connection));
36
    }
37
}
38