Completed
Pull Request — master (#694)
by Georg
19:18
created

StreamResponseTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 74.19 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 23
loc 31
rs 10
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testCallback() 11 11 1
A testCallbackRewind() 12 12 1

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
 * Calendar App
4
 *
5
 * @author Georg Ehrke
6
 * @copyright 2016 Georg Ehrke <[email protected]>
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
 * License as published by the Free Software Foundation; either
11
 * version 3 of the License, or any later version.
12
 *
13
 * This library 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
19
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
namespace OCA\Calendar\Http;
23
24
class StreamResponseTest extends \PHPUnit_Framework_TestCase {
25
26
	public function setUp() {
27
28
	}
29
30 View Code Duplication
	public function testCallback() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
		$stream = fopen('data://text/plain,test_data', 'r');
32
		$this->expectOutputString('test_data');
33
34
		$ioutput = $this->getMockBuilder('OCP\AppFramework\Http\IOutput')
35
			->disableOriginalConstructor()
36
			->getMock();
37
38
		$streamResponse = new StreamResponse($stream);
39
		$streamResponse->callback($ioutput);
40
	}
41
42 View Code Duplication
	public function testCallbackRewind() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
		$stream = fopen('data://text/plain,test_data', 'r');
44
		fseek($stream, 5);
45
		$this->expectOutputString('test_data');
46
47
		$ioutput = $this->getMockBuilder('OCP\AppFramework\Http\IOutput')
48
			->disableOriginalConstructor()
49
			->getMock();
50
51
		$streamResponse = new StreamResponse($stream);
52
		$streamResponse->callback($ioutput);
53
	}
54
}