diff options
author | Jeremy <jeremy.benoist@gmail.com> | 2015-02-22 14:35:36 +0100 |
---|---|---|
committer | Jeremy <jeremy.benoist@gmail.com> | 2015-02-22 14:35:36 +0100 |
commit | 0bf99bb144561525a34a50315b95efd6f543fe35 (patch) | |
tree | f438281ef6300e2373f049b1d4137a5475794641 /src/Wallabag/CoreBundle/Tests | |
parent | 0bd2cb1ecd2f9194735af77142390a94723d1b39 (diff) | |
download | wallabag-0bf99bb144561525a34a50315b95efd6f543fe35.tar.gz wallabag-0bf99bb144561525a34a50315b95efd6f543fe35.tar.zst wallabag-0bf99bb144561525a34a50315b95efd6f543fe35.zip |
Improve install command & add test
Also add fixtures for Config
InstallCommand now check if database, schema are here and ask the user what to do (keep or trash & re-create)
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php new file mode 100644 index 00000000..6bcc9707 --- /dev/null +++ b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php | |||
@@ -0,0 +1,61 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Tests\Command; | ||
4 | |||
5 | use Wallabag\CoreBundle\Tests\WallabagTestCase; | ||
6 | use Wallabag\CoreBundle\Command\InstallCommand; | ||
7 | use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
8 | use Symfony\Component\Console\Tester\CommandTester; | ||
9 | use Symfony\Component\Console\Input\ArrayInput; | ||
10 | use Symfony\Component\Console\Output\NullOutput; | ||
11 | |||
12 | class InstallCommandTest extends WallabagTestCase | ||
13 | { | ||
14 | public function tearDown() | ||
15 | { | ||
16 | parent::tearDown(); | ||
17 | |||
18 | $application = new Application(static::$kernel); | ||
19 | $application->setAutoExit(false); | ||
20 | |||
21 | $code = $application->run(new ArrayInput(array( | ||
22 | 'command' => 'doctrine:fixtures:load', | ||
23 | '--no-interaction' => true, | ||
24 | '--env' => 'test', | ||
25 | )), new NullOutput()); | ||
26 | } | ||
27 | |||
28 | public function testRunInstallCommand() | ||
29 | { | ||
30 | $this->container = static::$kernel->getContainer(); | ||
31 | |||
32 | $application = new Application(static::$kernel); | ||
33 | $application->add(new InstallCommand()); | ||
34 | |||
35 | $command = $application->find('wallabag:install'); | ||
36 | |||
37 | // We mock the DialogHelper | ||
38 | $dialog = $this->getMockBuilder('Symfony\Component\Console\Helper\DialogHelper') | ||
39 | ->disableOriginalConstructor() | ||
40 | ->getMock(); | ||
41 | $dialog->expects($this->any()) | ||
42 | ->method('ask') | ||
43 | ->will($this->returnValue('test')); | ||
44 | $dialog->expects($this->any()) | ||
45 | ->method('askConfirmation') | ||
46 | ->will($this->returnValue(true)); | ||
47 | |||
48 | // We override the standard helper with our mock | ||
49 | $command->getHelperSet()->set($dialog, 'dialog'); | ||
50 | |||
51 | $tester = new CommandTester($command); | ||
52 | $tester->execute(array( | ||
53 | 'command' => $command->getName() | ||
54 | )); | ||
55 | |||
56 | $this->assertContains('Step 1 of 4. Checking system requirements.', $tester->getDisplay()); | ||
57 | $this->assertContains('Step 2 of 4. Setting up database.', $tester->getDisplay()); | ||
58 | $this->assertContains('Step 3 of 4. Administration setup.', $tester->getDisplay()); | ||
59 | $this->assertContains('Step 4 of 4. Installing assets.', $tester->getDisplay()); | ||
60 | } | ||
61 | } | ||