Completed
Push — master ( 2a6630...1a6e67 )
by Tomáš
02:50
created

FinalInterfaceSniffTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testDetection() 0 10 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
declare(strict_types = 1);
4
5
namespace Zenify\CodingStandard\Tests\Sniffs\Classes\FinalInterface;
6
7
use PHPUnit\Framework\TestCase;
8
use Zenify\CodingStandard\Tests\CodeSnifferRunner;
9
use ZenifyCodingStandard\Sniffs\Classes\FinalInterfaceSniff;
10
11
12
final class FinalInterfaceSniffTest extends TestCase
13
{
14
15
	public function testDetection()
16
	{
17
		$codeSnifferRunner = new CodeSnifferRunner(FinalInterfaceSniff::NAME);
18
19
		$this->assertSame(1, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/wrong.php'));
20
		$this->assertSame(0, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/correct.php'));
21
		$this->assertSame(0, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/correct2.php'));
22
		$this->assertSame(0, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/correct3.php'));
23
		$this->assertSame(0, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/correct4.php'));
24
	}
25
26
27
	public function testFixing()
28
	{
29
		$codeSnifferRunner = new CodeSnifferRunner(FinalInterfaceSniff::NAME);
30
31
		$fixedContent = $codeSnifferRunner->getFixedContent(__DIR__ . '/wrong.php');
32
33
		$this->assertSame(file_get_contents(__DIR__ . '/wrong-fixed.php'), $fixedContent);
34
	}
35
36
}
37