ConsoleTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 5 1
A testCli() 0 19 1
A testTemplate() 0 15 1
A testInvalid() 0 14 1
1
<?php
2
namespace Redaxscript\Tests\Console;
3
4
use Redaxscript\Console;
5
use Redaxscript\Tests\TestCaseAbstract;
6
7
/**
8
 * ConsoleTest
9
 *
10
 * @since 3.0.0
11
 *
12
 * @package Redaxscript
13
 * @category Tests
14
 * @author Henry Ruhs
15
 *
16
 * @covers Redaxscript\Console\Console
17
 * @covers Redaxscript\Console\ConsoleAbstract
18
 */
19
20
class ConsoleTest extends TestCaseAbstract
21
{
22
	/**
23
	 * tearDown
24
	 *
25
	 * @since 3.0.0
26
	 */
27
28
	public function tearDown() : void
29
	{
30
		$this->_request->setServer('argv', null);
31
		$this->_request->setPost('argv', null);
32
	}
33
34
	/**
35
	 * testCli
36
	 *
37
	 * @since 3.0.0
38
	 */
39
40
	public function testCli() : void
41
	{
42
		/* setup */
43
44
		$this->_request->setServer('argv',
45
		[
46
			'console.php',
47
			'help'
48
		]);
49
		$console = new Console\Console($this->_registry, $this->_request, $this->_language, $this->_config);
50
51
		/* actual */
52
53
		$actual = $console->init('cli');
54
55
		/* compare */
56
57
		$this->assertIsString($actual);
58
	}
59
60
	/**
61
	 * testTemplate
62
	 *
63
	 * @since 3.0.0
64
	 */
65
66
	public function testTemplate() : void
67
	{
68
		/* setup */
69
70
		$this->_request->setPost('argv', 'help');
71
		$console = new Console\Console($this->_registry, $this->_request, $this->_language, $this->_config);
72
73
		/* actual */
74
75
		$actual = $console->init('template');
76
77
		/* compare */
78
79
		$this->assertIsString($actual);
80
	}
81
82
	/**
83
	 * testInvalid
84
	 *
85
	 * @since 3.0.0
86
	 */
87
88
	public function testInvalid() : void
89
	{
90
		/* setup */
91
92
		$console = new Console\Console($this->_registry, $this->_request, $this->_language, $this->_config);
93
94
		/* actual */
95
96
		$actual = $console->init();
97
98
		/* compare */
99
100
		$this->assertNull($actual);
101
	}
102
}
103