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

ProductRepositoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 42
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetSubscriptionLastReviewNumber() 0 13 1
A setUp() 0 4 1
A providerGetAccessibleSubQuery() 0 11 1
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