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'); |
|
|
|
|
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
|
|
|
|
This checks looks for assignemnts to variables using the
list(...)
function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$a
and$c
are used. There was no need to assign$b
.Instead, the list call could have been.