|
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
|
|
|
|