Completed
Push — develop ( 82247e...95e034 )
by Victor
17:24 queued 10s
created

AdminControllerTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 71
Duplicated Lines 87.32 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testIndex() 8 8 1
A testArticles() 9 9 1
A testComments() 9 9 1
A testUsers() 9 9 1
A testUsersDelete() 9 9 1
A testRoles() 9 9 1
A testRolesDelete() 9 9 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
 * Created by PhpStorm.
4
 * User: victor
5
 * Date: 17.01.16
6
 * Time: 17:58
7
 */
8
9
namespace AppBundle\Tests\Controller;
10
11
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
12
13
class AdminControllerTest extends WebTestCase
14
{
15 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...
16
        $client = static::createClient();
17
18
        $crawler = $client->request('GET', '/admin/');
19
20
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
21
        $this->assertContains('Statistic', $crawler->filter('h2')->text());
22
    }
23
24 View Code Duplication
    public function testArticles(){
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
        $client = static::createClient();
26
27
        $crawler = $client->request('GET', '/admin/articles');
28
29
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
30
        $this->assertContains('Articles', $crawler->filter('h2')->text());
31
        $this->assertEquals(2, $crawler->filter('tr')->count());
32
    }
33
34 View Code Duplication
    public function testComments(){
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
        $client = static::createClient();
36
37
        $crawler = $client->request('GET', '/admin/comments');
38
39
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
40
        $this->assertContains('Comments', $crawler->filter('h2')->text());
41
        $this->assertEquals(3, $crawler->filter('tr')->count());
42
    }
43
44 View Code Duplication
    public function testUsers(){
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...
45
        $client = static::createClient();
46
47
        $crawler = $client->request('GET', '/admin/users');
48
49
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
50
        $this->assertContains('Users', $crawler->filter('h2')->text());
51
        $this->assertEquals(2, $crawler->filter('tr')->count());
52
    }
53
54 View Code Duplication
    public function testUsersDelete(){
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...
55
        $client = static::createClient();
56
57
        $crawler = $client->request('GET', '/admin/user/delete/1');
58
59
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
60
        $this->assertContains('You want to delete user "User name" (id: 1). Related records: articles (count: 1), comments (count: 1). You must to delete related records before.',
61
            $crawler->filter('.alert')->text());
62
    }
63
64 View Code Duplication
    public function testRoles(){
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...
65
        $client = static::createClient();
66
67
        $crawler = $client->request('GET', '/admin/roles');
68
69
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
70
        $this->assertContains('Roles', $crawler->filter('h2')->text());
71
        $this->assertEquals(2, $crawler->filter('tr')->count());
72
    }
73
74 View Code Duplication
    public function testRolesDelete(){
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...
75
        $client = static::createClient();
76
77
        $crawler = $client->request('GET', '/admin/role/delete/1');
78
79
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
80
        $this->assertContains('You want to delete role "admin" (id: 1). Related records: users (count: 1). You must to delete related records before.',
81
            $crawler->filter('.alert')->text());
82
    }
83
}