diff options
author | Jeremy <jeremy.benoist@gmail.com> | 2015-03-28 21:45:35 +0100 |
---|---|---|
committer | Jeremy <jeremy.benoist@gmail.com> | 2015-03-31 22:48:01 +0200 |
commit | 0ee043f745fc53d782528128c615aa24a6af1d24 (patch) | |
tree | 9ac6e40e10d078a0bbd87e69fb99a083fb29f2aa /src | |
parent | 371ac69a6bd6325929e4efee7958682a6b1666f7 (diff) | |
download | wallabag-0ee043f745fc53d782528128c615aa24a6af1d24.tar.gz wallabag-0ee043f745fc53d782528128c615aa24a6af1d24.tar.zst wallabag-0ee043f745fc53d782528128c615aa24a6af1d24.zip |
Update InstallCommand test
They are god damn too long to execute because it launch external command (mostly related to doctrine).
So I've added a PHPUnit @group (`command-doctrine`) so that we can avoid launching them on a regular basis, like that:
`phpunit --exclude-group command-doctrine`
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php | 15 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Mock/InstallCommandMock.php | 22 |
2 files changed, 33 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php index 64f6c329..f689b532 100644 --- a/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php +++ b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php | |||
@@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Tests\Command; | |||
4 | 4 | ||
5 | use Wallabag\CoreBundle\Tests\WallabagTestCase; | 5 | use Wallabag\CoreBundle\Tests\WallabagTestCase; |
6 | use Wallabag\CoreBundle\Command\InstallCommand; | 6 | use Wallabag\CoreBundle\Command\InstallCommand; |
7 | use Wallabag\CoreBundle\Tests\Mock\InstallCommandMock; | ||
7 | use Symfony\Bundle\FrameworkBundle\Console\Application; | 8 | use Symfony\Bundle\FrameworkBundle\Console\Application; |
8 | use Symfony\Component\Console\Tester\CommandTester; | 9 | use Symfony\Component\Console\Tester\CommandTester; |
9 | use Symfony\Component\Console\Input\ArrayInput; | 10 | use Symfony\Component\Console\Input\ArrayInput; |
@@ -30,7 +31,7 @@ class InstallCommandTest extends WallabagTestCase | |||
30 | $this->container = static::$kernel->getContainer(); | 31 | $this->container = static::$kernel->getContainer(); |
31 | 32 | ||
32 | $application = new Application(static::$kernel); | 33 | $application = new Application(static::$kernel); |
33 | $application->add(new InstallCommand()); | 34 | $application->add(new InstallCommandMock()); |
34 | 35 | ||
35 | $command = $application->find('wallabag:install'); | 36 | $command = $application->find('wallabag:install'); |
36 | 37 | ||
@@ -64,7 +65,7 @@ class InstallCommandTest extends WallabagTestCase | |||
64 | $this->container = static::$kernel->getContainer(); | 65 | $this->container = static::$kernel->getContainer(); |
65 | 66 | ||
66 | $application = new Application(static::$kernel); | 67 | $application = new Application(static::$kernel); |
67 | $application->add(new InstallCommand()); | 68 | $application->add(new InstallCommandMock()); |
68 | 69 | ||
69 | $command = $application->find('wallabag:install'); | 70 | $command = $application->find('wallabag:install'); |
70 | 71 | ||
@@ -97,6 +98,9 @@ class InstallCommandTest extends WallabagTestCase | |||
97 | $this->assertContains('Droping database, creating database and schema', $tester->getDisplay()); | 98 | $this->assertContains('Droping database, creating database and schema', $tester->getDisplay()); |
98 | } | 99 | } |
99 | 100 | ||
101 | /** | ||
102 | * @group command-doctrine | ||
103 | */ | ||
100 | public function testRunInstallCommandWithDatabaseRemoved() | 104 | public function testRunInstallCommandWithDatabaseRemoved() |
101 | { | 105 | { |
102 | $this->container = static::$kernel->getContainer(); | 106 | $this->container = static::$kernel->getContainer(); |
@@ -148,7 +152,7 @@ class InstallCommandTest extends WallabagTestCase | |||
148 | $this->container = static::$kernel->getContainer(); | 152 | $this->container = static::$kernel->getContainer(); |
149 | 153 | ||
150 | $application = new Application(static::$kernel); | 154 | $application = new Application(static::$kernel); |
151 | $application->add(new InstallCommand()); | 155 | $application->add(new InstallCommandMock()); |
152 | 156 | ||
153 | $command = $application->find('wallabag:install'); | 157 | $command = $application->find('wallabag:install'); |
154 | 158 | ||
@@ -181,6 +185,9 @@ class InstallCommandTest extends WallabagTestCase | |||
181 | $this->assertContains('Droping schema and creating schema', $tester->getDisplay()); | 185 | $this->assertContains('Droping schema and creating schema', $tester->getDisplay()); |
182 | } | 186 | } |
183 | 187 | ||
188 | /** | ||
189 | * @group command-doctrine | ||
190 | */ | ||
184 | public function testRunInstallCommandChooseNothing() | 191 | public function testRunInstallCommandChooseNothing() |
185 | { | 192 | { |
186 | $this->container = static::$kernel->getContainer(); | 193 | $this->container = static::$kernel->getContainer(); |
@@ -242,7 +249,7 @@ class InstallCommandTest extends WallabagTestCase | |||
242 | $this->container = static::$kernel->getContainer(); | 249 | $this->container = static::$kernel->getContainer(); |
243 | 250 | ||
244 | $application = new Application(static::$kernel); | 251 | $application = new Application(static::$kernel); |
245 | $application->add(new InstallCommand()); | 252 | $application->add(new InstallCommandMock()); |
246 | 253 | ||
247 | $command = $application->find('wallabag:install'); | 254 | $command = $application->find('wallabag:install'); |
248 | 255 | ||
diff --git a/src/Wallabag/CoreBundle/Tests/Mock/InstallCommandMock.php b/src/Wallabag/CoreBundle/Tests/Mock/InstallCommandMock.php new file mode 100644 index 00000000..69bc48e0 --- /dev/null +++ b/src/Wallabag/CoreBundle/Tests/Mock/InstallCommandMock.php | |||
@@ -0,0 +1,22 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Tests\Mock; | ||
4 | |||
5 | use Wallabag\CoreBundle\Command\InstallCommand; | ||
6 | |||
7 | /** | ||
8 | * This mock aims to speed the test of InstallCommand by avoid calling external command | ||
9 | * like all doctrine commands. | ||
10 | * | ||
11 | * This speed the test but as a downside, it doesn't allow to fully test the InstallCommand | ||
12 | * | ||
13 | * Launching tests to avoid doctrine command: | ||
14 | * phpunit --exclude-group command-doctrine | ||
15 | */ | ||
16 | class InstallCommandMock extends InstallCommand | ||
17 | { | ||
18 | protected function runCommand($command, $parameters = array()) | ||
19 | { | ||
20 | return $this; | ||
21 | } | ||
22 | } | ||