|
133 | 133 | return; |
134 | 134 | } |
135 | 135 |
|
136 | | -// Create and boot 'test' kernel |
137 | | -$kernel = new Kernel((string)getenv('APP_ENV'), (bool)getenv('APP_DEBUG')); |
138 | | -$kernel->boot(); |
| 136 | +function getApplication(): Application |
| 137 | +{ |
| 138 | + // Create and boot 'test' kernel |
| 139 | + $kernel = new Kernel((string)getenv('APP_ENV'), (bool)getenv('APP_DEBUG')); |
| 140 | + $kernel->boot(); |
| 141 | + |
| 142 | + // Create new application |
| 143 | + $application = new Application($kernel); |
| 144 | + $application->setAutoExit(false); |
| 145 | + return $application; |
| 146 | +} |
139 | 147 |
|
140 | | -// Create new application |
141 | | -$application = new Application($kernel); |
142 | | -$application->setAutoExit(false); |
| 148 | +$application = getApplication(); |
143 | 149 |
|
144 | 150 | // Add the doctrine:database:drop command to the application and run it |
145 | 151 | $dropDatabaseDoctrineCommand = static function () use ($application): void { |
|
177 | 183 | $application->run($input, new ConsoleOutput()); |
178 | 184 | }; |
179 | 185 |
|
180 | | -// Add the doctrine:fixtures:load command to the application and run it |
181 | | -$loadFixturesDoctrineCommand = static function () use ($application): void { |
182 | | - $input = new ArrayInput([ |
183 | | - 'command' => 'doctrine:fixtures:load', |
184 | | - '--no-interaction' => true, |
185 | | - ]); |
186 | | - |
187 | | - $input->setInteractive(false); |
188 | | - |
189 | | - $application->run($input, new ConsoleOutput()); |
190 | | -}; |
191 | | - |
192 | 186 | // Ensure that we have "clean" JWT auth cache file |
193 | 187 | $createJwtAuthCache = static function (): void { |
194 | 188 | // Specify used cache file |
|
221 | 215 | $dropDatabaseDoctrineCommand, |
222 | 216 | $createDatabaseDoctrineCommand, |
223 | 217 | $updateSchemaDoctrineCommand, |
224 | | - $loadFixturesDoctrineCommand, |
225 | 218 | $createJwtAuthCache, |
226 | 219 | $createDatabaseCreateCache, |
227 | 220 | ] |
228 | 221 | ); |
| 222 | + |
| 223 | + |
| 224 | +/** |
| 225 | + * For some reason we need to re-create application to get loading of |
| 226 | + * fixtures working correctly with ORM v3 |
| 227 | + * |
| 228 | + * Without this we get error like: |
| 229 | + * An exception occurred while executing a query: SQLSTATE[42000]: Syntax |
| 230 | + * error or access violation: 1305 SAVEPOINT DOCTRINE_8 does not exist |
| 231 | + */ |
| 232 | +$application = getApplication(); |
| 233 | + |
| 234 | +// Add the doctrine:fixtures:load command to the application and run it |
| 235 | +$loadFixturesDoctrineCommand = static function () use ($application): void { |
| 236 | + $input = new ArrayInput([ |
| 237 | + 'command' => 'doctrine:fixtures:load', |
| 238 | + '--no-interaction' => true, |
| 239 | + ]); |
| 240 | + |
| 241 | + $input->setInteractive(false); |
| 242 | + |
| 243 | + $application->run($input, new ConsoleOutput()); |
| 244 | +}; |
| 245 | + |
| 246 | +array_map( |
| 247 | + '\call_user_func', |
| 248 | + [ |
| 249 | + $loadFixturesDoctrineCommand, |
| 250 | + ] |
| 251 | +); |
0 commit comments