CacheTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 161
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 161
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 4 1
A testNoArgument() 0 15 1
A testClear() 0 27 1
A testClearFailure() 0 22 1
A testClearInvalid() 0 27 1
A testClearInvalidFailure() 0 22 1
1
<?php
2
namespace Redaxscript\Tests\Console\Command;
3
4
use Redaxscript\Console\Command;
5
use Redaxscript\Tests\TestCaseAbstract;
6
7
/**
8
 * CacheTest
9
 *
10
 * @since 3.0.0
11
 *
12
 * @package Redaxscript
13
 * @category Tests
14
 * @author Henry Ruhs
15
 *
16
 * @covers Redaxscript\Console\Command\Cache
17
 * @covers Redaxscript\Console\Command\CommandAbstract
18
 */
19
20
class CacheTest 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
	}
32
33
	/**
34
	 * testNoArgument
35
	 *
36
	 * @since 3.0.0
37
	 */
38
39
	public function testNoArgument() : void
40
	{
41
		/* setup */
42
43
		$cacheCommand = new Command\Cache($this->_registry, $this->_request, $this->_language, $this->_config);
44
45
		/* expect and actual */
46
47
		$expect = $cacheCommand->getHelp();
48
		$actual = $cacheCommand->run('cli');
49
50
		/* compare */
51
52
		$this->assertEquals($expect, $actual);
53
	}
54
55
	/**
56
	 * testClear
57
	 *
58
	 * @since 3.0.0
59
	 */
60
61
	public function testClear() : void
62
	{
63
		/* setup */
64
65
		$this->_request->setServer('argv',
66
		[
67
			'console.php',
68
			'cache',
69
			'clear',
70
			'--directory',
71
			'cache',
72
			'--extension',
73
			'css',
74
			'--bundle',
75
			'base.min.css'
76
		]);
77
		$cacheCommand = new Command\Cache($this->_registry, $this->_request, $this->_language, $this->_config);
78
79
		/* expect and actual */
80
81
		$expect = $cacheCommand->success();
82
		$actual = $cacheCommand->run('cli');
83
84
		/* compare */
85
86
		$this->assertEquals($expect, $actual);
87
	}
88
89
	/**
90
	 * testClearFailure
91
	 *
92
	 * @since 3.0.0
93
	 */
94
95
	public function testClearFailure() : void
96
	{
97
		/* setup */
98
99
		$this->_request->setServer('argv',
100
		[
101
			'console.php',
102
			'cache',
103
			'clear',
104
			'--no-interaction'
105
		]);
106
		$cacheCommand = new Command\Cache($this->_registry, $this->_request, $this->_language, $this->_config);
107
108
		/* expect and actual */
109
110
		$expect = $cacheCommand->error();
111
		$actual = $cacheCommand->run('cli');
112
113
		/* compare */
114
115
		$this->assertEquals($expect, $actual);
116
	}
117
118
	/**
119
	 * testClearInvalid
120
	 *
121
	 * @since 3.0.0
122
	 */
123
124
	public function testClearInvalid() : void
125
	{
126
		/* setup */
127
128
		$this->_request->setServer('argv',
129
		[
130
			'console.php',
131
			'cache',
132
			'clear-invalid',
133
			'--directory',
134
			'cache',
135
			'--extension',
136
			'js',
137
			'--lifetime',
138
			'3600'
139
		]);
140
		$cacheCommand = new Command\Cache($this->_registry, $this->_request, $this->_language, $this->_config);
141
142
		/* expect and actual */
143
144
		$expect = $cacheCommand->success();
145
		$actual = $cacheCommand->run('cli');
146
147
		/* compare */
148
149
		$this->assertEquals($expect, $actual);
150
	}
151
152
	/**
153
	 * testClearInvalidFailure
154
	 *
155
	 * @since 3.0.0
156
	 */
157
158
	public function testClearInvalidFailure() : void
159
	{
160
		/* setup */
161
162
		$this->_request->setServer('argv',
163
		[
164
			'console.php',
165
			'cache',
166
			'clear-invalid',
167
			'--no-interaction'
168
		]);
169
		$cacheCommand = new Command\Cache($this->_registry, $this->_request, $this->_language, $this->_config);
170
171
		/* expect and actual */
172
173
		$expect = $cacheCommand->error();
174
		$actual = $cacheCommand->run('cli');
175
176
		/* compare */
177
178
		$this->assertEquals($expect, $actual);
179
	}
180
}
181