Passed
Pull Request — master (#99)
by Sebastian
01:56
created

IOUtilTest::testFormatHeadlineLong()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of CaptainHook
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Console;
13
14
use PHPUnit\Framework\TestCase;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
class IOUtilTest extends TestCase
18
{
19
    /**
20
     * Tests IOUtil::mapConfigVerbosity
21
     */
22
    public function testMapConfigVerbosity(): void
23
    {
24
        $this->assertEquals(OutputInterface::VERBOSITY_QUIET, IOUtil::mapConfigVerbosity('quiet'));
25
        $this->assertEquals(OutputInterface::VERBOSITY_NORMAL, IOUtil::mapConfigVerbosity('normal'));
26
        $this->assertEquals(OutputInterface::VERBOSITY_VERBOSE, IOUtil::mapConfigVerbosity('verbose'));
27
        $this->assertEquals(OutputInterface::VERBOSITY_DEBUG, IOUtil::mapConfigVerbosity('debug'));
28
    }
29
30
    /**
31
     * Tests IOUtil::mapConfigVerbosity
32
     */
33
    public function testMapConfigVerbosityNotFound(): void
34
    {
35
        $this->assertEquals(OutputInterface::VERBOSITY_NORMAL, IOUtil::mapConfigVerbosity('foobar'));
36
    }
37
38
    /**
39
     * Tests IOUtil::answerToBool
40
     */
41
    public function testAnswerToBool(): void
42
    {
43
        $this->assertTrue(IOUtil::answerToBool('y'));
44
        $this->assertTrue(IOUtil::answerToBool('yes'));
45
        $this->assertTrue(IOUtil::answerToBool('ok'));
46
        $this->assertFalse(IOUtil::answerToBool('foo'));
47
    }
48
49
    /**
50
     * Tests IOUtil::formatHeadline
51
     */
52
    public function testFormatHeadlineLong(): void
53
    {
54
        $long     = str_repeat('x', 90);
55
        $headline = IOUtil::formatHeadline($long, 80);
56
57
        $this->assertEquals($long, $headline);
58
    }
59
}
60