BlockPropertyCommentSniffTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 36.36 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 8
loc 22
rs 10
c 0
b 0
f 0

2 Methods

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