Completed
Push — master ( 45aa1e...841b62 )
by Thomas
19:35
created

AttachmentDownloadResponseTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 25
loc 25
rs 10
c 0
b 0
f 0

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * @author Christoph Wurst <[email protected]>
5
 * @author Thomas Müller <[email protected]>
6
 *
7
 * Mail
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
namespace OCA\Mail\Tests\Http;
23
24
25
use OCA\Mail\Http\AttachmentDownloadResponse;
26
27
class AttachmentDownloadResponseTest extends \PHPUnit_Framework_TestCase {
28
29
	/**
30
	 * @dataProvider providesResponseData
31
	 * @param $content
32
	 * @param $filename
33
	 * @param $contentType
34
	 */
35
	public function testIt($content, $filename, $contentType) {
36
		$resp = new AttachmentDownloadResponse($content, $filename, $contentType);
37
		$headers = $resp->getHeaders();
38
		$this->assertEquals($content, $resp->render());
39
		$this->assertArrayHasKey('Content-Type', $headers);
40
		$this->assertEquals($contentType, $headers['Content-Type']);
41
		$this->assertArrayHasKey('Content-Disposition', $headers);
42
		$pos = strpos($headers['Content-Disposition'], $filename);
43
		$this->assertTrue($pos > 0);
44
    }
45
46
	public function providesResponseData() {
47
		return [
48
			['1234567890', 'test.txt', 'text/plain']
49
		];
50
	}
51
}
52