1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Dontdrinkandroot\Gitki\WebBundle\Tests\Integration; |
5
|
|
|
|
6
|
|
|
use Doctrine\Common\DataFixtures\Executor\ORMExecutor; |
7
|
|
|
use Doctrine\Common\DataFixtures\ReferenceRepository; |
8
|
|
|
use GitWrapper\GitWrapper; |
9
|
|
|
use Liip\FunctionalTestBundle\Test\WebTestCase; |
10
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
11
|
|
|
|
12
|
|
|
abstract class BaseIntegrationTest extends WebTestCase |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
const GIT_REPOSITORY_PATH = '/tmp/gitkirepo/'; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var ReferenceRepository |
19
|
|
|
*/ |
20
|
|
|
protected $referenceRepository; |
21
|
|
|
|
22
|
|
|
protected function setUp() |
23
|
|
|
{ |
24
|
|
|
/** @var ORMExecutor $executor */ |
25
|
|
|
$executor = $this->loadFixtures($this->getFixtureClasses()); |
26
|
|
|
$this->referenceRepository = $executor->getReferenceRepository(); |
27
|
|
|
$this->setUpRepo(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function tearDown() |
31
|
|
|
{ |
32
|
|
|
$this->tearDownRepo(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param string $name |
37
|
|
|
* |
38
|
|
|
* @return object |
39
|
|
|
*/ |
40
|
|
|
protected function getReference($name) |
41
|
|
|
{ |
42
|
|
|
return $this->referenceRepository->getReference($name); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Init the git repository used for the tests. |
47
|
|
|
*/ |
48
|
|
|
protected function setUpRepo() |
49
|
|
|
{ |
50
|
|
|
$testRepoPath = realPath(__DIR__ . '/../../../../var/data/test/repo/'); |
51
|
|
|
|
52
|
|
|
$fileSystem = new Filesystem(); |
53
|
|
|
$fileSystem->remove(self::GIT_REPOSITORY_PATH); |
54
|
|
|
|
55
|
|
|
$fileSystem->mkdir(self::GIT_REPOSITORY_PATH); |
56
|
|
|
$fileSystem->mirror($testRepoPath, self::GIT_REPOSITORY_PATH); |
57
|
|
|
|
58
|
|
|
$git = new GitWrapper(); |
59
|
|
|
$workingCopy = $git->init(self::GIT_REPOSITORY_PATH); |
60
|
|
|
$workingCopy->add('', ['A' => '']); |
61
|
|
|
$workingCopy->commit('Initial commit'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Tear down the git repository used for the tests. |
66
|
|
|
*/ |
67
|
|
|
protected function tearDownRepo() |
68
|
|
|
{ |
69
|
|
|
$fileSystem = new Filesystem(); |
70
|
|
|
$fileSystem->remove(self::GIT_REPOSITORY_PATH); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return string[] |
75
|
|
|
*/ |
76
|
|
|
abstract protected function getFixtureClasses(); |
77
|
|
|
} |
78
|
|
|
|