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

GitAccessCommandTest::testSimpleDeleteCase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 19
Ratio 90.48 %

Importance

Changes 0
Metric Value
dl 19
loc 21
rs 9.584
c 0
b 0
f 0
cc 1
nc 1
nop 0
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