Completed
Push — master ( a5a038...08ae9a )
by Ricardo
04:34
created

GitAccessCommandTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 64.41 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 38
loc 59
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A tearDown() 0 4 1
A testSimpleCreateCase() 19 21 1
A testSimpleDeleteCase() 19 21 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
/**
4
 * This file is part of Fabrica.
5
 *
6
 * (c) Alexandre Salomé <[email protected]>
7
 * (c) Julien DIDIER <[email protected]>
8
 *
9
 * This source file is subject to the GPL license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Fabrica\Bundle\CoreBundle\Tests\Command;
14
15
use Fabrica\Bundle\CoreBundle\Test\CommandTestCase;
16
17
class GitAccessCommandTest extends CommandTestCase
18
{
19
    protected $client;
20
21
    protected function setUp(): void
22
    {
23
        $this->client = self::createClient();
24
        $this->client->startIsolation();
25
    }
26
27
    public function tearDown(): void
28
    {
29
        $this->client->stopIsolation();
30
    }
31
32 View Code Duplication
    public function testSimpleCreateCase()
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...
33
    {
34
        list($statusCode ,$output) = $this->runCommand($this->client, 'fabrica:git-access create barbaz admin master 1 1');
35
36
        $this->assertEquals(0, $statusCode, 'statusCode is equal to 0');
37
        $this->assertEquals("The git-access was successfully created!\n", $output);
38
39
        $doctrine = $this->client->getKernel()->getContainer()->get('doctrine');
40
41
        $project   = $doctrine->getRepository('FabricaCoreBundle:Project')->findOneBySlug('barbaz');
42
        $role      = $doctrine->getRepository('FabricaCoreBundle:Role')->findOneBySlug('admin');
43
        $gitAccess = $doctrine->getRepository('FabricaCoreBundle:ProjectGitAccess')->findOneBy(
44
            array(
45
            'project'   => $project,
46
            'role'      => $role,
47
            'reference' => 'master',
48
            )
49
        );
50
51
        $this->assertNotNull($gitAccess);
52
    }
53
54 View Code Duplication
    public function testSimpleDeleteCase()
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
    {
56
        list($statusCode ,$output) = $this->runCommand($this->client, 'fabrica:git-access delete foobar visitor *');
57
58
        $this->assertEquals(0, $statusCode, 'statusCode is equal to 0');
59
        $this->assertEquals("The git-access was successfully deleted!\n", $output);
60
61
        $doctrine = $this->client->getKernel()->getContainer()->get('doctrine');
62
63
        $project   = $doctrine->getRepository('FabricaCoreBundle:Project')->findOneBySlug('foobar');
64
        $role      = $doctrine->getRepository('FabricaCoreBundle:Role')->findOneBySlug('visitor');
65
        $gitAccess = $doctrine->getRepository('FabricaCoreBundle:ProjectGitAccess')->findOneBy(
66
            array(
67
            'project'   => $project,
68
            'role'      => $role,
69
            'reference' => 'master',
70
            )
71
        );
72
73
        $this->assertNull($gitAccess);
74
    }
75
}
76