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
|
|
|
|
10
|
|
|
class Doctrine2DBALWithScopeTest |
11
|
|
|
extends AdapterWithScopeTestAbstract |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @return TreeAdapterInterface |
15
|
|
|
*/ |
16
|
|
|
protected function getAdapter() |
17
|
|
|
{ |
18
|
|
|
$config = new DBAL\Configuration(); |
19
|
|
|
$connectionParams = array( |
20
|
|
|
'dbname' => TEST_STEFANO_DB_DB_NAME, |
21
|
|
|
'user' => TEST_STEFANO_DB_USER, |
22
|
|
|
'password' => TEST_STEFANO_DB_PASSWORD, |
23
|
|
|
'host' => TEST_STEFANO_DB_HOSTNAME, |
24
|
|
|
'driver' => 'pdo_' . strtolower(TEST_STEFANO_DB_ADAPTER), |
25
|
|
|
); |
26
|
|
|
|
27
|
|
|
$connection = DBAL\DriverManager::getConnection($connectionParams, $config); |
28
|
|
|
|
29
|
|
|
$options = new Options(array( |
30
|
|
|
'tableName' => 'tree_traversal_with_scope', |
31
|
|
|
'idColumnName' => 'tree_traversal_id', |
32
|
|
|
'scopeColumnName' => 'scope', |
33
|
|
|
)); |
34
|
|
|
|
35
|
|
|
if ('pgsql' == TEST_STEFANO_DB_ADAPTER) { |
36
|
|
|
$options->setSequenceName('tree_traversal_with_scope_tree_traversal_id_seq'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
return new NestedSetAdapter($options, $connection); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|