Issues (34)

StefanoTreeTest/Integration/JoinTableTest.php (1 issue)

Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace StefanoTreeTest\Integration;
6
7
use StefanoTree\NestedSet as TreeAdapter;
8
use StefanoTree\NestedSet\Options;
9
use StefanoTreeTest\IntegrationTestCase;
10
use StefanoTreeTest\TestUtil;
11
12
/**
13
 * @internal
14
 */
15
class JoinTableTest extends IntegrationTestCase
16
{
17
    /**
18
     * @return TreeAdapter
19
     */
20
    protected function getTreeAdapter()
21
    {
22
        $options = new Options(array(
23
            'tableName' => 'tree_traversal_with_scope',
24
            'idColumnName' => 'tree_traversal_id',
25
            'scopeColumnName' => 'scope',
26
            'dbSelectBuilder' => function () {
27
                return 'SELECT tree_traversal_with_scope.*, ttm.name AS metadata FROM tree_traversal_with_scope'
28
                    .' LEFT JOIN tree_traversal_metadata AS ttm'
29
                    .' ON ttm.tree_traversal_id = tree_traversal_with_scope.tree_traversal_id';
30
            },
31
        ));
32
33
        if ('pgsql' == TEST_STEFANO_DB_VENDOR) {
0 ignored issues
show
The condition 'pgsql' == StefanoTreeTe...\TEST_STEFANO_DB_VENDOR is always false.
Loading history...
34
            $options->setSequenceName('tree_traversal_with_scope_tree_traversal_id_seq');
35
        }
36
37
        return new TreeAdapter($options, TestUtil::buildAdapter($options));
38
    }
39
40
    protected function getDataSet()
41
    {
42
        return $this->createArrayDataSet(include __DIR__.'/_files/NestedSet/with_scope/initDataSet.php');
43
    }
44
45
    public function testJoinTable()
46
    {
47
        $adapter = $this->getTreeAdapter();
48
        $result = $adapter->getDescendantsQueryBuilder()
49
            ->levelLimit(2)
50
            ->get(1);
51
52
        $expected = include __DIR__.'/_files/NestedSet/with_scope/testJoinTable.php';
53
54
        $this->assertEquals($expected, $result);
55
    }
56
}
57