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
|
|
|
class ProductRepositoryTest extends AbstractRepositoryTest |
14
|
|
|
{ |
15
|
|
|
use LimitedAccessSubQuery; |
16
|
|
|
|
17
|
|
|
private ProductRepository $repository; |
18
|
|
|
|
19
|
|
|
protected function setUp(): void |
20
|
|
|
{ |
21
|
|
|
parent::setUp(); |
22
|
|
|
$this->repository = _em()->getRepository(Product::class); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function providerGetAccessibleSubQuery(): iterable |
26
|
|
|
{ |
27
|
|
|
$all = range(3000, 3011); |
28
|
|
|
$actives = array_values(array_diff($all, [3010])); |
29
|
|
|
yield ['anonymous', $actives]; |
30
|
|
|
yield ['member', $actives]; |
31
|
|
|
yield ['othermember', $actives]; |
32
|
|
|
yield ['facilitator', $all]; |
33
|
|
|
yield ['administrator', $all]; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function testGetSubscriptionLastReviewNumber(): void |
37
|
|
|
{ |
38
|
|
|
$user = $this->getEntityManager()->getReference(User::class, 1000); |
39
|
|
|
$actual = $this->repository->getSubscriptionLastReviewNumber($user); |
|
|
|
|
40
|
|
|
self::assertNull($actual); |
41
|
|
|
|
42
|
|
|
$user = $this->getEntityManager()->getReference(User::class, 1003); |
43
|
|
|
$actual = $this->repository->getSubscriptionLastReviewNumber($user); |
44
|
|
|
self::assertSame(62, $actual); |
45
|
|
|
|
46
|
|
|
$organization = $this->getEntityManager()->getReference(Organization::class, 50000); |
47
|
|
|
$actual = $this->repository->getSubscriptionLastReviewNumber($organization); |
48
|
|
|
self::assertSame(61, $actual); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|