1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Zenstruck\Foundry\Tests\Unit; |
4
|
|
|
|
5
|
|
|
use Doctrine\Persistence\ObjectRepository; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
use Zenstruck\Foundry\RepositoryProxy; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @author Kevin Bond <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
final class RepositoryProxyTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @test |
16
|
|
|
* @dataProvider objectRepositoryWithoutFindOneByOrderBy |
17
|
|
|
*/ |
18
|
|
|
public function calling_find_one_by_with_order_by_when_wrapped_repo_does_not_have_throws_exception(ObjectRepository $inner): void |
19
|
|
|
{ |
20
|
|
|
$proxy = new RepositoryProxy($inner); |
21
|
|
|
|
22
|
|
|
$this->expectException(\RuntimeException::class); |
23
|
|
|
|
24
|
|
|
$proxy->findOneBy([], ['id' => 'DESC']); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public static function objectRepositoryWithoutFindOneByOrderBy(): iterable |
28
|
|
|
{ |
29
|
|
|
yield [new RepositoryProxy(new class() implements ObjectRepository { |
30
|
|
|
public function find($id) |
31
|
|
|
{ |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function findAll() |
35
|
|
|
{ |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) |
39
|
|
|
{ |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function findOneBy(array $criteria) |
43
|
|
|
{ |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getClassName() |
47
|
|
|
{ |
48
|
|
|
} |
49
|
|
|
})]; |
50
|
|
|
|
51
|
|
|
yield [new RepositoryProxy(new class() implements ObjectRepository { |
52
|
|
|
public function find($id) |
53
|
|
|
{ |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function findAll() |
57
|
|
|
{ |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) |
61
|
|
|
{ |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function findOneBy(array $criteria, ?array $foo = null) |
65
|
|
|
{ |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getClassName() |
69
|
|
|
{ |
70
|
|
|
} |
71
|
|
|
})]; |
72
|
|
|
|
73
|
|
|
yield [new RepositoryProxy(new class() implements ObjectRepository { |
74
|
|
|
public function find($id) |
75
|
|
|
{ |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function findAll() |
79
|
|
|
{ |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) |
83
|
|
|
{ |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function findOneBy(array $criteria, $orderBy = null) |
87
|
|
|
{ |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function getClassName() |
91
|
|
|
{ |
92
|
|
|
} |
93
|
|
|
})]; |
94
|
|
|
|
95
|
|
|
yield [new RepositoryProxy(new class() implements ObjectRepository { |
96
|
|
|
public function find($id) |
97
|
|
|
{ |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function findAll() |
101
|
|
|
{ |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) |
105
|
|
|
{ |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function findOneBy(array $criteria, ?string $orderBy = null) |
109
|
|
|
{ |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function getClassName() |
113
|
|
|
{ |
114
|
|
|
} |
115
|
|
|
})]; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|