Completed
Push — develop ( 66df04...390d88 )
by Bartko
03:53
created

StefanoDbTest::testNestedTransactionCannotFail2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
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
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
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