Completed
Push — master ( aa5a0d...109f75 )
by Peter
05:58
created

PhpTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 20 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 10
loc 50
wmc 4
lcom 1
cbo 2
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testIfWillPassVariableToView() 10 10 1
A testIfWillForwardMethodToOwner() 0 8 1
A testIfWillForwardPropertyToOwner() 0 8 1
A getValue() 0 4 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 Renderers;
4
5
use Maslosoft\MiniView\MiniView;
6
use UnitTester;
7
8
class PhpTest extends \Codeception\TestCase\Test
9
{
10
11
	/**
12
	 * @var UnitTester
13
	 */
14
	protected $tester;
15
16
	/**
17
	 * NOTE: Do not remove, part of test
18
	 * @var string
19
	 */
20
	public $value = 'property value';
21
22
	// tests
23 View Code Duplication
	public function testIfWillPassVariableToView()
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...
24
	{
25
		$var = 'New Variable';
26
27
		$view = new MiniView($this);
28
29
		$result = $view->render('passVariable', ['var' => $var], true);
30
31
		$this->assertSame($var, $result);
32
	}
33
34
	public function testIfWillForwardMethodToOwner()
35
	{
36
		$view = new MiniView($this);
37
38
		$result = $view->render('forwardMethod', [], true);
39
40
		$this->assertSame($this->getValue(), $result);
41
	}
42
43
	public function testIfWillForwardPropertyToOwner()
44
	{
45
		$view = new MiniView($this);
46
47
		$result = $view->render('forwardProperty', [], true);
48
49
		$this->assertSame($this->value, $result);
50
	}
51
52
	public function getValue()
53
	{
54
		return 'my value from method';
55
	}
56
57
}
58