1 | <?php |
||
16 | class RunParatestCommand extends ContainerAwareCommand |
||
17 | { |
||
18 | private $output; |
||
19 | private $process; |
||
20 | private $testDbPath; |
||
21 | private $phpunit; |
||
22 | |||
23 | /** |
||
24 | * Configuration of the command. |
||
25 | */ |
||
26 | 11 | protected function configure() |
|
35 | |||
36 | protected function prepare() |
||
37 | { |
||
38 | $this->phpunit = $this->getContainer()->getParameter('liip_functional_test.paratest.phpunit'); |
||
39 | $this->process = $this->getContainer()->getParameter('liip_functional_test.paratest.process'); |
||
40 | |||
41 | $this->testDbPath = $this->getContainer()->get('kernel')->getCacheDir(); |
||
42 | $this->output->writeln("Cleaning old dbs in $this->testDbPath ..."); |
||
43 | $createDirProcess = new Process('mkdir -p '.$this->testDbPath); |
||
44 | $createDirProcess->run(); |
||
45 | $cleanProcess = new Process("rm -fr $this->testDbPath/dbTest.db $this->testDbPath/dbTest*.db*"); |
||
46 | $cleanProcess->run(); |
||
47 | $this->output->writeln("Creating Schema in $this->testDbPath ..."); |
||
48 | $application = new Application($this->getContainer()->get('kernel')); |
||
49 | $input = new ArrayInput(array('doctrine:schema:create', '--env' => 'test')); |
||
50 | $application->run($input, $this->output); |
||
51 | |||
52 | $this->output->writeln('Initial schema created'); |
||
53 | $input = new ArrayInput(array( |
||
54 | 'doctrine:fixtures:load', |
||
55 | '-n' => '', |
||
56 | '--env' => 'test', |
||
57 | )); |
||
58 | $application->run($input, $this->output); |
||
59 | |||
60 | $this->output->writeln('Initial schema populated, duplicating....'); |
||
61 | for ($a = 0; $a < $this->process; ++$a) { |
||
62 | $test = new Process("cp $this->testDbPath/dbTest.db ".$this->testDbPath."/dbTest$a.db"); |
||
63 | $test->run(); |
||
64 | } |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Content of the command. |
||
69 | * |
||
70 | * @param InputInterface $input |
||
71 | * @param OutputInterface $output |
||
72 | */ |
||
73 | protected function execute(InputInterface $input, OutputInterface $output) |
||
93 | } |
||
94 |