|
18 | 18 |
|
19 | 19 | class DoctrineModule extends Module
|
20 | 20 | {
|
| 21 | + /** |
| 22 | + * @var string |
| 23 | + */ |
| 24 | + private $path; |
| 25 | + |
| 26 | + public function _beforeSuite($settings = []) |
| 27 | + { |
| 28 | + $this->path = $settings['path']; |
| 29 | + } |
| 30 | + |
21 | 31 | public function _before(TestInterface $test)
|
22 | 32 | {
|
23 |
| - if ($this->config['dump']) { |
| 33 | + if ($this->config['loadFiles']) { |
24 | 34 | $em = $this->getModule(NetteDIModule::class)->grabService(EntityManagerInterface::class);
|
25 | 35 | $connection = $em->getConnection();
|
26 |
| - $generator = $this->load(file_get_contents($this->config['dump'])); |
27 | 36 |
|
28 |
| - try { |
29 |
| - foreach ($generator as $command) { |
30 |
| - $stmt = $connection->prepare($command); |
31 |
| - if (!$stmt->execute()) { |
32 |
| - $error = $stmt->errorInfo(); |
33 |
| - throw new ModuleConfigException(__CLASS__, $error[2]); |
| 37 | + foreach ((array) $this->config['loadFiles'] as $file) { |
| 38 | + $generator = $this->load(file_get_contents($this->path.'/'.$file)); |
| 39 | + |
| 40 | + try { |
| 41 | + foreach ($generator as $command) { |
| 42 | + $stmt = $connection->prepare($command); |
| 43 | + if (!$stmt->execute()) { |
| 44 | + $error = $stmt->errorInfo(); |
| 45 | + throw new ModuleConfigException(__CLASS__, $error[2]); |
| 46 | + } |
| 47 | + $stmt->closeCursor(); |
34 | 48 | }
|
35 |
| - $stmt->closeCursor(); |
| 49 | + } catch (PDOException $e) { |
| 50 | + throw new ModuleConfigException(__CLASS__, $e->getMessage(), $e); |
36 | 51 | }
|
37 |
| - } catch (PDOException $e) { |
38 |
| - throw new ModuleConfigException(__CLASS__, $e->getMessage(), $e); |
39 | 52 | }
|
40 | 53 | }
|
41 | 54 | }
|
|
0 commit comments