DefaultControllerTest   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 56
Duplicated Lines 91.07 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 9
c 0
b 0
f 0
lcom 1
cbo 2
dl 51
loc 56
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testIndex() 17 17 2
A testArgument() 17 17 2
A testConstructor() 17 17 2

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
/*
4
 * This file is part of the Symfony-Util package.
5
 *
6
 * (c) Jean-Bernard Addor
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
13
14
class DefaultControllerTest extends WebTestCase
15
{
16 View Code Duplication
    public function testIndex()
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...
17
    {
18
        if ('3.4.0' <= Symfony\Component\HttpKernel\Kernel::VERSION) {
19
            $this->markTestIncomplete();
20
        } // Test does not work any more with Symfony 3.4
21
22
        $client = static::createClient();
23
24
        $crawler = $client->request('GET', '/');
0 ignored issues
show
Unused Code introduced by
$crawler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
25
26
        $this->assertSame(
27
            200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK,
28
            $client->getResponse()->getStatusCode()
29
        );
30
31
        $this->assertContains('Hello Component!', $client->getResponse()->getContent());
32
    }
33
34 View Code Duplication
    public function testArgument()
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...
35
    {
36
        if ('3.4.0' <= Symfony\Component\HttpKernel\Kernel::VERSION) {
37
            $this->markTestIncomplete();
38
        } // Test does not work any more with Symfony 3.4
39
40
        $client = static::createClient();
41
42
        $crawler = $client->request('GET', '/argument');
0 ignored issues
show
Unused Code introduced by
$crawler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
43
44
        $this->assertSame(
45
            200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK,
46
            $client->getResponse()->getStatusCode()
47
        );
48
49
        $this->assertContains('Hello Component!', $client->getResponse()->getContent());
50
    }
51
52 View Code Duplication
    public function testConstructor()
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...
53
    {
54
        if ('3.4.0' <= Symfony\Component\HttpKernel\Kernel::VERSION) {
55
            $this->markTestIncomplete();
56
        } // Test does not work any more with Symfony 3.4
57
58
        $client = static::createClient();
59
60
        $crawler = $client->request('GET', '/constructor');
0 ignored issues
show
Unused Code introduced by
$crawler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
61
62
        $this->assertSame(
63
            200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK,
64
            $client->getResponse()->getStatusCode()
65
        );
66
67
        $this->assertContains('Hello Component!', $client->getResponse()->getContent());
68
    }
69
}
70