1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use AspectMock\Test as test; |
|
|
|
|
4
|
|
|
|
5
|
|
|
class HgTest extends \Codeception\TestCase\Test |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var \AspectMock\Proxy\ClassProxy |
9
|
|
|
*/ |
10
|
|
|
protected $hg; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var \Robo\Task\Vcs\HgStack |
14
|
|
|
*/ |
15
|
|
|
protected $hgStack; |
16
|
|
|
|
17
|
|
|
protected function _before() |
18
|
|
|
{ |
19
|
|
|
$this->hg = Test::double('Robo\Task\Vcs\HgStack', [ |
20
|
|
|
'executeCommand' => new \AspectMock\Proxy\Anything(), |
21
|
|
|
'output' => new \Symfony\Component\Console\Output\NullOutput(), |
22
|
|
|
'logger' => new \Psr\Log\NullLogger(), |
23
|
|
|
]); |
24
|
|
|
$this->hgStack = (new \Robo\Task\Vcs\HgStack('hg')); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
// tests |
28
|
|
|
public function testHgStackRun() |
29
|
|
|
{ |
30
|
|
|
$this->hgStack->stopOnFail()->add()->pull()->run(); |
31
|
|
|
$this->hg->verifyInvoked('executeCommand', ['hg add']); |
32
|
|
|
$this->hg->verifyInvoked('executeCommand', ['hg pull']); |
33
|
|
|
|
34
|
|
|
(new \Robo\Task\Vcs\HgStack('hg'))->add()->pull()->run(); |
35
|
|
|
$this->hg->verifyInvoked('executeCommand', ['hg add && hg pull']); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testHgStackPull() |
39
|
|
|
{ |
40
|
|
|
$this->assertEquals( |
41
|
|
|
'hg pull', |
42
|
|
|
$this->hgStack |
43
|
|
|
->pull() |
44
|
|
|
->getCommand() |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testHgStackAddFiles() |
49
|
|
|
{ |
50
|
|
|
$this->assertEquals( |
51
|
|
|
'hg add -I *.php -X *.css', |
52
|
|
|
$this->hgStack |
53
|
|
|
->add('*.php', '*.css') |
54
|
|
|
->getCommand() |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
View Code Duplication |
public function testHgStackCommands() |
59
|
|
|
{ |
60
|
|
|
$this->assertEquals( |
61
|
|
|
"hg clone https://bitbucket.org/durin42/hgsubversion && hg pull && hg add && hg commit -m 'changed' && hg push && hg tag 0.6.0 && hg push -b '0.6.0'", |
62
|
|
|
$this->hgStack |
63
|
|
|
->cloneRepo('https://bitbucket.org/durin42/hgsubversion') |
64
|
|
|
->pull() |
65
|
|
|
->add() |
66
|
|
|
->commit('changed') |
67
|
|
|
->push() |
68
|
|
|
->tag('0.6.0') |
69
|
|
|
->push('0.6.0') |
70
|
|
|
->getCommand() |
71
|
|
|
); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
View Code Duplication |
public function testHgStackCommandsWithTagMessage() |
75
|
|
|
{ |
76
|
|
|
$this->assertEquals( |
77
|
|
|
"hg clone https://bitbucket.org/durin42/hgsubversion && hg pull && hg add && hg commit -m 'changed' && hg push && hg tag -m 'message' 0.6.0 && hg push -b '0.6.0'", |
78
|
|
|
$this->hgStack |
79
|
|
|
->cloneRepo('https://bitbucket.org/durin42/hgsubversion') |
80
|
|
|
->pull() |
81
|
|
|
->add() |
82
|
|
|
->commit('changed') |
83
|
|
|
->push() |
84
|
|
|
->tag('0.6.0', 'message') |
85
|
|
|
->push('0.6.0') |
86
|
|
|
->getCommand() |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: