Passed
Push — master ( b649b5...b34030 )
by Sebastian
04:07
created

ComposerIOTest::testIsDebug()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace CaptainHook\Console\IO;
4
5
class ComposerIOTest extends \PHPUnit_Framework_TestCase
6
{
7
    /**
8
     * @var \CaptainHook\Console\IO;
9
     */
10
    private $io;
11
12
    /**
13
     * Test setup
14
     */
15
    public function setUp()
16
    {
17
        $mock = $this->getMockBuilder('\\Composer\\IO\\IOInterface')
18
                     ->disableOriginalConstructor()
19
                     ->getMock();
20
        $mock->method('isInteractive')->willReturn(false);
21
        $mock->method('isDebug')->willReturn(false);
22
        $mock->method('isVerbose')->willReturn(false);
23
        $mock->method('isVeryVerbose')->willReturn(false);
24
        $mock->method('ask')->willReturn('bar');
25
        $mock->method('askConfirmation')->willReturn(true);
26
        $mock->method('askAndValidate')->willReturn(true);
27
        $this->io = new ComposerIO($mock);
28
    }
29
30
    /**
31
     * Test tear down
32
     */
33
    public function tearDown()
34
    {
35
        $this->io = null;
36
    }
37
38
    /**
39
     * Tests ComposerIO::isInteractive
40
     */
41
    public function testIsInteractive()
42
    {
43
        $this->assertFalse($this->io->isInteractive());
44
    }
45
46
    /**
47
     * Tests ComposerIO::isDebug
48
     */
49
    public function testIsDebug()
50
    {
51
        $this->assertFalse($this->io->isDebug());
52
53
    }
54
55
    /**
56
     * Tests ComposerIO::isVerbose
57
     */
58
    public function testIsVerbose()
59
    {
60
        $this->assertFalse($this->io->isVerbose());
61
    }
62
63
    /**
64
     * Tests ComposerIO::isVeryVerbose
65
     */
66
    public function testIsVeryVerbose()
67
    {
68
        $this->assertFalse($this->io->isVeryVerbose());
69
    }
70
71
    /**
72
     * Tests ComposerIO::write
73
     */
74
    public function testWrite()
75
    {
76
        $this->io->write('foo');
77
    }
78
79
    /**
80
     * Tests ComposerIO::writeError
81
     */
82
    public function testWriteError()
83
    {
84
        $this->io->writeError('foo');
85
    }
86
87
    /**
88
     * Tests ComposerIO::ask
89
     */
90
    public function testAsk()
91
    {
92
        $this->assertEquals('bar', $this->io->ask('foo', 'bar'));
93
    }
94
95
    /**
96
     * Tests ComposerIO::askConfirmation
97
     */
98
    public function testAskConfirmation()
99
    {
100
        $this->assertEquals(true, $this->io->askConfirmation('foo', true));
101
    }
102
103
    /**
104
     * Tests ComposerIO::askAbdValidate
105
     */
106
    public function testAskAndValidate()
107
    {
108
        $this->assertEquals(true, $this->io->askAndValidate('foo', function() { return true; }, false, true));
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a integer|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
109
    }
110
}
111