Completed
Push — master ( 377183...c084b0 )
by Ricardo
03:56
created

ProjectCreateCommandTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 53
rs 10
c 0
b 0
f 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: void
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected ':', expecting ';' or '{'
Loading history...
24
    {
25
        $this->client = self::createClient();
26
        $this->repositoryPool = $this->getMockBuilder('Fabrica\Bundle\CoreBundle\Git\RepositoryPool')
27
            ->disableOriginalConstructor()
28
            ->getMock()
29
        ;
30
        $this->hookInjector = $this->getMockBuilder('Fabrica\Bundle\CoreBundle\Git\HookInjector')
31
            ->disableOriginalConstructor()
32
            ->getMock()
33
        ;
34
        $this->client->setRepositoryPool($this->repositoryPool);
35
        $this->client->setHookInjector($this->hookInjector);
36
37
        $this->client->startIsolation();
38
    }
39
40
    public function tearDown(): void
41
    {
42
        $this->client->stopIsolation();
43
    }
44
45
    public function testSimpleCase()
46
    {
47
        $this->repositoryPool
48
            ->expects($this->once())
49
            ->method('onProjectCreate')
50
        ;
51
        $this->hookInjector
52
            ->expects($this->once())
53
            ->method('onProjectCreate')
54
        ;
55
56
        list($statusCode ,$output) = $this->runCommand($this->client, 'fabrica:project-create "Sample name" sample-name');
57
58
        $this->assertEquals("Project Sample name was created!\n", $output);
59
60
        $em = $this->client->getKernel()->getContainer()->get('doctrine')->getManager();
61
62
        $project = $em->getRepository('FabricaCoreBundle:Project')->findOneBy(array(
63
            'name' => 'Sample name',
64
            'slug' => 'sample-name'
65
        ));
66
67
        $this->assertNotEmpty($project);
68
    }
69
}
70