Completed
Push — master ( 9a7fc1...319399 )
by Peter
01:58
created

PhpTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 32.26 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 5
c 2
b 1
f 0
lcom 1
cbo 3
dl 20
loc 62
rs 10

5 Methods

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