Completed
Push — develop ( 32afc4...f78f16 )
by Bartko
03:00
created

getTreeAdapter()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 25
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 25
rs 8.8571
cc 2
eloc 15
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 NestedSetWithDoctrine2DbAdapterTest
9
    extends AbstractTest
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',
27
            'idColumnName' => 'tree_traversal_id',
28
        ));
29
30
        if ('pgsql' == TEST_STEFANO_DB_ADAPTER) {
31
            $options->setSequenceName('tree_traversal_tree_traversal_id_seq');
32
        }
33
34
        return new TreeAdapter(new Doctrine2DBALAdapter($options, $connection));
35
    }
36
}
37