Completed
Push — master ( fc7027...e72ab1 )
by Philip
24:06
created

src/Command/LoadFixturesCommand.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace App\Command;
4
5
use GitWrapper\GitWrapper;
6
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
7
use Symfony\Component\Console\Input\ArrayInput;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Symfony\Component\Console\Question\ConfirmationQuestion;
11
use Symfony\Component\Filesystem\Filesystem;
12
13
class LoadFixturesCommand extends ContainerAwareCommand
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Bundle\Framework...d\ContainerAwareCommand has been deprecated with message: since Symfony 4.2, use {@see Command} instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    protected function configure()
19
    {
20
        $this
21
            ->setName('gitki:fixtures:load')
22
            ->setDescription('Load fixtures as they are used in the tests');
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30
        $doctrineFixturesCommand = $this->getApplication()->find('doctrine:fixtures:load');
31
        $doctrineFixturesCommand->run(new ArrayInput([]), $output);
32
33
        $questionHelper = $this->getHelper('question');
34
        $question = new ConfirmationQuestion('Overwrite repository?', false);
35
        if (!$questionHelper->ask($input, $output, $question)) {
36
            return;
37
        }
38
39
        $repositoryPath = $this->getContainer()->getParameter('ddr_gitki.repository_path');
40
        $rootDir = $this->getContainer()->getParameter('kernel.root_dir');
41
        $testRepoPath = realpath($rootDir . '/../vendor/dontdrinkandroot/gitki-bundle/Tests/Data/repo/');
42
        dump($testRepoPath);
43
44
        $fileSystem = new Filesystem();
45
        $fileSystem->remove($repositoryPath);
46
47
        $fileSystem->mkdir($repositoryPath);
48
        $fileSystem->mirror($testRepoPath, $repositoryPath);
49
50
        $git = new GitWrapper();
51
        $workingCopy = $git->init($repositoryPath);
52
        $workingCopy->config('user.email', '[email protected]');
53
        $workingCopy->config('user.name', 'Gitki');
54
        $workingCopy->add('', ['A' => '']);
55
        $workingCopy->commit('Initial commit');
56
    }
57
}
58