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

ProjectCreateCommandTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
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 ProjectCreateCommandTest extends CommandTestCase
18
{
19
    protected $client;
20
    protected $repositoryPool;
21
    protected $hookInjector;
22
23
    protected function setUp(): void
24
    {
25
        $this->client = self::createClient();
26
        $this->repositoryPool = $this->getMockBuilder('Fabrica\Bundle\CoreBundle\Git\RepositoryPool')
27
            ->disableOriginalConstructor()
28
            ->getMock();
29
        $this->hookInjector = $this->getMockBuilder('Fabrica\Bundle\CoreBundle\Git\HookInjector')
30
            ->disableOriginalConstructor()
31
            ->getMock();
32
        $this->client->setRepositoryPool($this->repositoryPool);
33
        $this->client->setHookInjector($this->hookInjector);
34
35
        $this->client->startIsolation();
36
    }
37
38
    public function tearDown(): void
39
    {
40
        $this->client->stopIsolation();
41
    }
42
43
    public function testSimpleCase()
44
    {
45
        $this->repositoryPool
46
            ->expects($this->once())
47
            ->method('onProjectCreate');
48
        $this->hookInjector
49
            ->expects($this->once())
50
            ->method('onProjectCreate');
51
52
        list($statusCode ,$output) = $this->runCommand($this->client, 'fabrica:project-create "Sample name" sample-name');
0 ignored issues
show
Unused Code introduced by
The assignment to $statusCode is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
53
54
        $this->assertEquals("Project Sample name was created!\n", $output);
55
56
        $em = $this->client->getKernel()->getContainer()->get('doctrine')->getManager();
57
58
        $project = $em->getRepository('FabricaCoreBundle:Project')->findOneBy(
59
            array(
60
            'name' => 'Sample name',
61
            'slug' => 'sample-name'
62
            )
63
        );
64
65
        $this->assertNotEmpty($project);
66
    }
67
}
68