1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Kreta package. |
5
|
|
|
* |
6
|
|
|
* (c) Beñat Espiña <[email protected]> |
7
|
|
|
* (c) Gorka Laucirica <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace spec\Kreta\Distribution\Composer; |
14
|
|
|
|
15
|
|
|
use Composer\Composer; |
16
|
|
|
use Composer\Config; |
17
|
|
|
use Composer\Package\RootPackageInterface; |
18
|
|
|
use Composer\Script\Event; |
19
|
|
|
use PhpSpec\ObjectBehavior; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Spec of ScriptHandler class. |
23
|
|
|
* |
24
|
|
|
* @author Beñat Espiña <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class ScriptHandlerSpec extends ObjectBehavior |
27
|
|
|
{ |
28
|
|
|
function it_is_initializable() |
29
|
|
|
{ |
30
|
|
|
$this->shouldHaveType('Kreta\Distribution\Composer\ScriptHandler'); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
function it_throws_exception_if_npm_install_fails( |
34
|
|
|
Event $commandEvent, |
35
|
|
|
Composer $composer, |
36
|
|
|
RootPackageInterface $package, |
37
|
|
|
Config $config |
38
|
|
|
) { |
39
|
|
|
$commandEvent->getComposer()->shouldBeCalled()->willReturn($composer); |
40
|
|
|
$composer->getPackage()->shouldBeCalled()->willReturn($package); |
41
|
|
|
$package->getExtra()->shouldBeCalled()->willReturn([]); |
42
|
|
|
$composer->getConfig()->shouldBeCalled()->willReturn($config); |
43
|
|
|
$config->get('process-timeout')->shouldBeCalled()->willReturn(true); |
44
|
|
|
|
45
|
|
|
$this::shouldThrow( |
46
|
|
|
new \RuntimeException( |
47
|
|
|
"An error occurred when executing the 'cd vendor/kreta/kreta/src/Kreta/Bundle/WebBundle && ../../../../../../../bin/npm install ' command.\n sh: 1: cd: can't cd to vendor/kreta/kreta/src/Kreta/Bundle/WebBundle\n" |
|
|
|
|
48
|
|
|
))->during('npmInstall', [$commandEvent]); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
function it_throws_exception_if_webpack_fails() |
52
|
|
|
{ |
53
|
|
|
$this::shouldThrow( |
54
|
|
|
new \RuntimeException( |
55
|
|
|
"An error occurred when executing the 'cd vendor/kreta/kreta/src/Kreta/Bundle/WebBundle && ../../../../../../../bin/npm run prod:deploy' command.\n sh: 1: cd: can't cd to vendor/kreta/kreta/src/Kreta/Bundle/WebBundle\n" |
|
|
|
|
56
|
|
|
))->during('webpack', []); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.