-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathCreateCommandTest.php
More file actions
61 lines (47 loc) · 1.62 KB
/
CreateCommandTest.php
File metadata and controls
61 lines (47 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Created by PhpStorm.
* User: aguidet
* Date: 01/03/15
* Time: 02:15
*/
namespace Migrate\Command;
use Migrate\Test\Command\AbstractCommandTester;
use Migrate\Utils\InputStreamUtil;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Tester\CommandTester;
define('PHPUNIT', true);
class CreateCommandTest extends AbstractCommandTester
{
public function setUp()
{
$this->cleanEnv();
$this->createEnv();
$this->initEnv();
}
public function tearDown()
{
$this->cleanEnv();
}
public function testExecute()
{
$application = new Application();
$application->add(new CreateCommand());
$command = $application->find('migrate:create');
$commandTester = new CommandTester($command);
/* @var $question QuestionHelper */
$question = $command->getHelper('question');
$question->setInputStream(InputStreamUtil::type("je suis une super migration &&&ééé\n\n:x\n"));
$commandTester->execute(array('command' => $command->getName()));
$matches = array();
preg_match('/.*: (.*) created/', $commandTester->getDisplay(), $matches);
$fileName = $matches[1];
$this->assertFileExists($fileName);
$content = file_get_contents($fileName);
$expected =<<<EXPECTED
-- // je suis une super migration &&&ééé\n-- @ENVIRONMENTS [ANY]\n-- Migration SQL that makes the change goes here.\n\n-- @UNDO\n-- SQL to undo the change goes here.\n
EXPECTED;
$this->assertEquals($expected, $content);
}
}