1 | <?php |
||
21 | abstract class DatabaseTestCase extends LumenTestCase |
||
22 | { |
||
23 | //<editor-fold desc="Fields"> |
||
24 | /** |
||
25 | * @var \Faker\Generator |
||
26 | */ |
||
27 | protected $faker; |
||
28 | |||
29 | /** |
||
30 | * @var bool |
||
31 | */ |
||
32 | private $clear; |
||
33 | //</editor-fold desc="Fields"> |
||
34 | |||
35 | //<editor-fold desc="Constructor"> |
||
36 | /** |
||
37 | * DatabaseTestCase constructor. |
||
38 | * @param string|null $name test name |
||
39 | * @param array $data test data |
||
40 | * @param string $dataName test data name |
||
41 | * @param bool $clear |
||
42 | */ |
||
43 | public function __construct($name = null, array $data = [], $dataName = '', $clear = false) |
||
50 | //</editor-fold desc="Constructor"> |
||
51 | |||
52 | //<editor-fold desc="Protected Methods"> |
||
53 | |||
54 | /** |
||
55 | * Clears the database by truncating all tables (very time consuming) |
||
56 | * @throws \Doctrine\DBAL\DBALException |
||
57 | */ |
||
58 | protected function clearDatabase() |
||
71 | |||
72 | /** |
||
73 | * Creates an array of players. |
||
74 | * @param int $number the number of players |
||
75 | * @return PlayerInterface[] the created player array |
||
76 | */ |
||
77 | protected function createPlayers(int $number = 1): array |
||
85 | |||
86 | /** |
||
87 | * Creates an array of teams with ranks and start numbers |
||
88 | * @param int $number the number of teams to create |
||
89 | * @param int $playerPerTeam the number of players per team |
||
90 | * @return TeamInterface[] the created team array |
||
91 | */ |
||
92 | protected function createTeams(int $number, $playerPerTeam = 1): array |
||
109 | |||
110 | /** |
||
111 | * Creates a new user |
||
112 | * @return array containing the password and the user object |
||
113 | */ |
||
114 | protected function createUser() |
||
126 | |||
127 | /** |
||
128 | * Adds additional attributes given to the create entity method |
||
129 | * @param mixed[] $attributes |
||
130 | */ |
||
131 | protected function addAdditionalNewUserAttributes(array &$attributes) |
||
134 | |||
135 | /** |
||
136 | * Uses faker to generate a new password |
||
137 | * @return string the new password |
||
138 | */ |
||
139 | protected function newPassword() |
||
143 | |||
144 | /** |
||
145 | * Boot the testing helper traits. |
||
146 | * |
||
147 | * @return void |
||
148 | * @throws \Doctrine\DBAL\DBALException |
||
149 | */ |
||
150 | protected function setUpTraits() |
||
175 | |||
176 | protected function workOnDatabaseDestroy() |
||
180 | |||
181 | protected function workOnDatabaseSetUp() |
||
185 | |||
186 | /** |
||
187 | * Resolve className according to fm-lib config |
||
188 | * @param string $className |
||
189 | * @return string |
||
190 | */ |
||
191 | protected final function resolveEntity(string $className): string |
||
205 | //</editor-fold desc="Protected Methods"> |
||
206 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.