1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Zikula package. |
7
|
|
|
* |
8
|
|
|
* Copyright Zikula Foundation - https://ziku.la/ |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Zikula\UsersModule\Tests\Api\Fixtures; |
15
|
|
|
|
16
|
|
|
use DateTime; |
17
|
|
|
use Doctrine\Common\Collections\Criteria; |
18
|
|
|
use Doctrine\ORM\Internal\Hydration\IterableResult; |
19
|
|
|
use Zikula\UsersModule\Constant; |
20
|
|
|
use Zikula\UsersModule\Entity\RepositoryInterface\UserRepositoryInterface; |
21
|
|
|
use Zikula\UsersModule\Entity\UserEntity; |
22
|
|
|
|
23
|
|
|
class MockUserRepository implements UserRepositoryInterface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var array |
27
|
|
|
*/ |
28
|
|
|
private $users = []; |
29
|
|
|
|
30
|
|
|
public function __construct() |
31
|
|
|
{ |
32
|
|
|
$user = new UserEntity(); |
33
|
|
|
$user->setUid(Constant::USER_ID_ANONYMOUS); |
34
|
|
|
$user->setUname('guest'); |
35
|
|
|
$user->setActivated(Constant::ACTIVATED_ACTIVE); |
36
|
|
|
$this->users[Constant::USER_ID_ANONYMOUS] = $user; |
37
|
|
|
|
38
|
|
|
$user = new UserEntity(); |
39
|
|
|
$user->setUid(42); |
40
|
|
|
$user->setUname('FooName'); |
41
|
|
|
$user->setEmail('[email protected]'); |
42
|
|
|
$user->setActivated(Constant::ACTIVATED_ACTIVE); |
43
|
|
|
$user->setAttribute('legs', 2); |
44
|
|
|
$this->users[42] = $user; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function find($id) |
48
|
|
|
{ |
49
|
|
|
return isset($id) ? $this->users[$id] : null; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function findAll() |
53
|
|
|
{ |
54
|
|
|
return $this->users; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
58
|
|
|
{ |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function findOneBy(array $criteria) |
62
|
|
|
{ |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getClassName() |
66
|
|
|
{ |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function matching(Criteria $criteria) |
70
|
|
|
{ |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function findByUids(array $userIds = []): array |
74
|
|
|
{ |
75
|
|
|
return []; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function persistAndFlush(UserEntity $user): void |
79
|
|
|
{ |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function removeAndFlush(UserEntity $user): void |
83
|
|
|
{ |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function setApproved(UserEntity $user, DateTime $approvedOn, int $approvedBy = null): void |
87
|
|
|
{ |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function queryBySearchForm(array $formData = []) |
91
|
|
|
{ |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getSearchResults(array $words = []) |
95
|
|
|
{ |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function query( |
99
|
|
|
array $filter = [], |
100
|
|
|
array $sort = [], |
101
|
|
|
string $exprType = 'and' |
102
|
|
|
) { |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function paginatedQuery(array $filter = [], array $sort = [], string $exprType = 'and', int $page = 1, int $pageSize = 25) |
106
|
|
|
{ |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function count(array $filter = [], string $exprType = 'and'): int |
110
|
|
|
{ |
111
|
|
|
return 123; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function findAllAsIterable(): IterableResult |
115
|
|
|
{ |
116
|
|
|
} |
|
|
|
|
117
|
|
|
|
118
|
|
|
public function searchActiveUser(array $unameFilter = [], int $limit = 50) |
119
|
|
|
{ |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: