|
1
|
|
|
<?php |
|
2
|
|
|
namespace StefanoTreeTest\Integration\Adapter; |
|
3
|
|
|
|
|
4
|
|
|
use StefanoDb\Adapter\Adapter as DbAdapter; |
|
5
|
|
|
use StefanoTree\NestedSet\Adapter\AdapterInterface as TreeAdapterInterface; |
|
6
|
|
|
use StefanoTree\NestedSet\Adapter\StefanoDb as NestedSetAdapter; |
|
7
|
|
|
use StefanoTree\NestedSet\Options; |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
class StefanoDbTest |
|
11
|
|
|
extends AdapterTestAbstract |
|
|
|
|
|
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @return TreeAdapterInterface |
|
15
|
|
|
*/ |
|
16
|
|
|
protected function getAdapter() |
|
17
|
|
|
{ |
|
18
|
|
|
$dbAdapter = new DbAdapter(array( |
|
19
|
|
|
'driver' => 'Pdo_' . ucfirst(TEST_STEFANO_DB_ADAPTER), |
|
20
|
|
|
'hostname' => TEST_STEFANO_DB_HOSTNAME, |
|
21
|
|
|
'database' => TEST_STEFANO_DB_DB_NAME, |
|
22
|
|
|
'username' => TEST_STEFANO_DB_USER, |
|
23
|
|
|
'password' => TEST_STEFANO_DB_PASSWORD |
|
24
|
|
|
)); |
|
25
|
|
|
|
|
26
|
|
|
$options = new Options(array( |
|
27
|
|
|
'tableName' => 'tree_traversal', |
|
28
|
|
|
'idColumnName' => 'tree_traversal_id', |
|
29
|
|
|
)); |
|
30
|
|
|
|
|
31
|
|
|
if ('pgsql' == TEST_STEFANO_DB_ADAPTER) { |
|
32
|
|
|
$options->setSequenceName('tree_traversal_tree_traversal_id_seq'); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
return new NestedSetAdapter($options, $dbAdapter); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testNestedTransactionCannotFail() { |
|
39
|
|
|
$adapter = $this->getAdapter(); |
|
40
|
|
|
$adapter->beginTransaction(); |
|
41
|
|
|
$adapter->beginTransaction(); |
|
42
|
|
|
$adapter->commitTransaction(); |
|
43
|
|
|
$adapter->commitTransaction(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testNestedTransactionCannotFail2() { |
|
47
|
|
|
$adapter = $this->getAdapter(); |
|
48
|
|
|
$adapter->beginTransaction(); |
|
49
|
|
|
$adapter->beginTransaction(); |
|
50
|
|
|
$adapter->rollbackTransaction(); |
|
51
|
|
|
$adapter->rollbackTransaction(); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|