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

LatteTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 65.71 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testIfWillPassVariableToView() 11 11 1
A testIfWillPassVariableToViewWithRendererDetection() 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
namespace Renderers;
4
5
use Maslosoft\MiniView\MiniView;
6
use Maslosoft\MiniView\Renderers\LatteRenderer;
7
use Maslosoft\MiniView\Renderers\PhpRenderer;
8
use UnitTester;
9
10
class LatteTest extends \Codeception\TestCase\Test
11
{
12
13
	/**
14
	 * @var UnitTester
15
	 */
16
	protected $tester;
17
18
	// tests
19 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...
20
	{
21
		$var = 'New Variable';
22
23
		$view = new MiniView($this);
24
		$view->setRenderer(new LatteRenderer());
25
26
		$result = $view->render('passVariable2', ['var' => $var], true);
27
28
		$this->assertSame($var, $result);
29
	}
30
31 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...
32
	{
33
		$var = 'New Variable';
34
35
		$view = new MiniView($this);
36
37
		$result = $view->render('passVariable2.latte', ['var' => $var], true);
38
39
		$this->assertInstanceOf(PhpRenderer::class, $view->getRenderer(), 'That renderer was reverted back to default renderer');
40
41
		$this->assertSame($var, $result);
42
	}
43
44
}
45