-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathScriptHandlerTest.php
More file actions
64 lines (53 loc) · 2.11 KB
/
ScriptHandlerTest.php
File metadata and controls
64 lines (53 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Incenteev\ParameterHandler\Tests;
use Incenteev\ParameterHandler\ScriptHandler;
use Prophecy\PhpUnit\ProphecyTestCase;
class ScriptHandlerTest extends ProphecyTestCase
{
private $event;
private $io;
private $package;
protected function setUp()
{
parent::setUp();
$this->event = $this->prophesize('Composer\Script\Event');
$this->io = $this->prophesize('Composer\IO\IOInterface');
$this->package = $this->prophesize('Composer\Package\PackageInterface');
$composer = $this->prophesize('Composer\Composer');
$composer->getPackage()->willReturn($this->package);
$this->event->getComposer()->willReturn($composer);
$this->event->getIO()->willReturn($this->io);
$this->event->isDevMode()->willReturn(true);
}
/**
* @dataProvider provideInvalidConfiguration
*/
public function testInvalidConfiguration(array $extras, $exceptionMessage)
{
$this->package->getExtra()->willReturn($extras);
chdir(__DIR__);
$this->setExpectedException('InvalidArgumentException', $exceptionMessage);
ScriptHandler::buildParameters($this->event->reveal());
}
public function provideInvalidConfiguration()
{
return array(
'no extra' => array(
array(),
'The parameter handler needs to be configured through the extra.incenteev-parameters setting.',
),
'invalid type' => array(
array('incenteev-parameters' => 'not an array'),
'The extra.incenteev-parameters setting must be an array or a configuration object.',
),
'invalid type for multiple file' => array(
array('incenteev-parameters' => array('not an array')),
'The extra.incenteev-parameters setting must be an array of configuration objects.',
),
'no file' => array(
array('incenteev-parameters' => array()),
'The extra.incenteev-parameters.file setting is required to use this script handler.',
),
);
}
}