ScriptHandlerTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 56
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 13 1
A testInvalidConfiguration() 0 10 1
A provideInvalidConfiguration() 0 21 1
1
<?php
2
3
namespace Incenteev\ParameterHandler\Tests;
4
5
use Incenteev\ParameterHandler\ScriptHandler;
6
7
class ScriptHandlerTest extends \PHPUnit_Framework_TestCase
8
{
9
    private $event;
10
    private $io;
11
    private $package;
12
13
    protected function setUp()
14
    {
15
        parent::setUp();
16
17
        $this->event = $this->prophesize('Composer\Script\Event');
18
        $this->io = $this->prophesize('Composer\IO\IOInterface');
19
        $this->package = $this->prophesize('Composer\Package\PackageInterface');
20
        $composer = $this->prophesize('Composer\Composer');
21
22
        $composer->getPackage()->willReturn($this->package);
23
        $this->event->getComposer()->willReturn($composer);
24
        $this->event->getIO()->willReturn($this->io);
25
    }
26
27
    /**
28
     * @dataProvider provideInvalidConfiguration
29
     */
30
    public function testInvalidConfiguration(array $extras, $exceptionMessage)
31
    {
32
        $this->package->getExtra()->willReturn($extras);
33
34
        chdir(__DIR__);
35
36
        $this->setExpectedException('InvalidArgumentException', $exceptionMessage);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

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

Loading history...
37
38
        ScriptHandler::buildParameters($this->event->reveal());
39
    }
40
41
    public function provideInvalidConfiguration()
42
    {
43
        return array(
44
            'no extra' => array(
45
                array(),
46
                'The parameter handler needs to be configured through the extra.incenteev-parameters setting.',
47
            ),
48
            'invalid type' => array(
49
                array('incenteev-parameters' => 'not an array'),
50
                'The extra.incenteev-parameters setting must be an array or a configuration object.',
51
            ),
52
            'invalid type for multiple file' => array(
53
                array('incenteev-parameters' => array('not an array')),
54
                'The extra.incenteev-parameters setting must be an array of configuration objects.',
55
            ),
56
            'no file' => array(
57
                array('incenteev-parameters' => array()),
58
                'The extra.incenteev-parameters.file setting is required to use this script handler.',
59
            ),
60
        );
61
    }
62
}
63