Passed
Push — master ( fdf037...88d356 )
by Adrien
07:14
created

testGetSubscriptionLastReviewNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 9.9666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApplicationTest\Repository;
6
7
use Application\Model\Organization;
8
use Application\Model\Product;
9
use Application\Model\User;
10
use Application\Repository\ProductRepository;
11
use ApplicationTest\Traits\LimitedAccessSubQuery;
12
13
/**
14
 * @group Repository
15
 */
16
class ProductRepositoryTest extends AbstractRepositoryTest
17
{
18
    use LimitedAccessSubQuery;
19
20
    /**
21
     * @var ProductRepository
22
     */
23
    private $repository;
24
25
    protected function setUp(): void
26
    {
27
        parent::setUp();
28
        $this->repository = _em()->getRepository(Product::class);
29
    }
30
31
    public function providerGetAccessibleSubQuery(): array
32
    {
33
        $all = range(3000, 3011);
34
        $actives = array_values(array_diff($all, [3010]));
35
36
        return [
37
            ['anonymous', $actives],
38
            ['member', $actives],
39
            ['othermember', $actives],
40
            ['facilitator', $all],
41
            ['administrator', $all],
42
        ];
43
    }
44
45
    public function testGetSubscriptionLastReviewNumber(): void
46
    {
47
        $user = $this->getEntityManager()->getReference(User::class, 1000);
48
        $actual = $this->repository->getSubscriptionLastReviewNumber($user);
49
        self::assertNull($actual);
50
51
        $user = $this->getEntityManager()->getReference(User::class, 1003);
52
        $actual = $this->repository->getSubscriptionLastReviewNumber($user);
53
        self::assertSame(62, $actual);
54
55
        $organization = $this->getEntityManager()->getReference(Organization::class, 50000);
56
        $actual = $this->repository->getSubscriptionLastReviewNumber($organization);
57
        self::assertSame(61, $actual);
58
    }
59
}
60