Completed
Push — master ( 99dfa7...cc4116 )
by Aimeos
12:53
created

FlowTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 75
Duplicated Lines 18.67 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 8
c 3
b 0
f 2
lcom 1
cbo 1
dl 14
loc 75
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 12 2
A tearDown() 0 4 1
A testTransform() 0 4 1
A testGetBody() 7 7 1
A testGetClientAddress() 7 7 1
A testGetTarget() 0 4 1
A testGetUploadedFiles() 0 6 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
namespace Aimeos\MW\View\Helper\Request;
4
5
6
/**
7
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
8
 * @copyright Aimeos (aimeos.org), 2015
9
 */
10
class FlowTest extends \PHPUnit_Framework_TestCase
11
{
12
	private $object;
13
	private $mock;
14
15
16
	/**
17
	 * Sets up the fixture, for example, opens a network connection.
18
	 * This method is called before a test is executed.
19
	 *
20
	 * @access protected
21
	 */
22
	protected function setUp()
23
	{
24
		if( !class_exists( '\TYPO3\Flow\Http\Request' ) ) {
25
			$this->markTestSkipped( '\TYPO3\Flow\Http\Request is not available' );
26
		}
27
28
		$this->mock = $this->getMockBuilder( '\TYPO3\Flow\Http\Request' )
29
			->setConstructorArgs( array( array(), array(), array(), array() ) )->getMock();
30
31
		$view = new \Aimeos\MW\View\Standard();
32
		$this->object = new \Aimeos\MW\View\Helper\Request\Flow( $view, $this->mock, array() );
33
	}
34
35
36
	/**
37
	 * Tears down the fixture, for example, closes a network connection.
38
	 * This method is called after a test is executed.
39
	 *
40
	 * @access protected
41
	 */
42
	protected function tearDown()
43
	{
44
		unset( $this->object, $this->mock );
45
	}
46
47
48
	public function testTransform()
49
	{
50
		$this->assertInstanceOf( '\\Aimeos\\MW\\View\\Helper\\Request\\Flow', $this->object->transform() );
51
	}
52
53
54 View Code Duplication
	public function testGetBody()
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...
55
	{
56
		$this->mock->expects( $this->once() )->method( 'getContent' )
57
			->will( $this->returnValue( 'body' ) );
58
59
		$this->assertEquals( 'body', $this->object->transform()->getBody() );
60
	}
61
62
63 View Code Duplication
	public function testGetClientAddress()
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...
64
	{
65
		$this->mock->expects( $this->once() )->method( 'getClientIpAddress' )
66
			->will( $this->returnValue( '127.0.0.1' ) );
67
68
		$this->assertEquals( '127.0.0.1', $this->object->transform()->getClientAddress() );
69
	}
70
71
72
	public function testGetTarget()
73
	{
74
		$this->assertEquals( null, $this->object->transform()->getTarget() );
75
	}
76
77
78
	public function testGetUploadedFiles()
79
	{
80
		$files = $this->object->transform()->getUploadedFiles();
81
82
		$this->assertEquals( array(), $files );
83
	}
84
}
85