Completed
Push — master ( 0d4b62...49eab6 )
by Adrien
07:35
created

LimitedAccessSubQuery::testGetAccessibleSubQuery()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 2
dl 0
loc 13
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApplicationTest\Traits;
6
7
use Application\Model\User;
8
9
/**
10
 * Trait to test limited access sub queries
11
 */
12
trait LimitedAccessSubQuery
13
{
14
    /**
15
     * @dataProvider providerGetAccessibleSubQuery
16
     *
17
     * @param null|string $login
18
     * @param array $expected
19
     */
20
    public function testGetAccessibleSubQuery(?string $login, array $expected): void
21
    {
22
        $user = _em()->getRepository(User::class)->getByLogin($login);
23
        $subQuery = $this->repository->getAccessibleSubQuery($user);
24
        if ($subQuery === '-1') {
25
            $ids = [];
26
        } else {
27
            $ids = _em()->getConnection()->executeQuery($subQuery)->fetchAll(\PDO::FETCH_COLUMN);
28
        }
29
30
        sort($ids);
31
32
        self::assertEquals($expected, $ids);
33
    }
34
}
35