]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Update InstallCommand test
authorJeremy <jeremy.benoist@gmail.com>
Sat, 28 Mar 2015 20:45:35 +0000 (21:45 +0100)
committerJeremy <jeremy.benoist@gmail.com>
Tue, 31 Mar 2015 20:48:01 +0000 (22:48 +0200)
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`

.travis.yml
src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php
src/Wallabag/CoreBundle/Tests/Mock/InstallCommandMock.php [new file with mode: 0644]

index 6e9388263b6d3e3f0db688cadeb4aad22b07596a..3c97a9da46d15cff826e68c4b8353608ed931d42 100644 (file)
@@ -31,11 +31,11 @@ install:
 
 # build coverage only on one build, to speed up results feedbacks
 before_script:
-    - if [[ "$TRAVIS_PHP_VERSION" = "5.6" ]]; then PHPUNIT_FLAGS="--coverage-clover=coverage.clover"; fi;
+    - if [[ "$TRAVIS_PHP_VERSION" = "5.6" ]]; then PHPUNIT_FLAGS="--coverage-clover=coverage.clover"; else PHPUNIT_FLAGS=""; fi;
 
 script:
     - ant prepare
-    - phpunit $PHPUNIT_FLAGS
+    - phpunit --exclude-group command-doctrine $PHPUNIT_FLAGS
 
 after_script:
     - |
index 64f6c3290dbef63f1bbd0330e4bae943fbe7cb94..f689b5328318f510b95030f3f2d25c708b3d2fe8 100644 (file)
@@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Tests\Command;
 
 use Wallabag\CoreBundle\Tests\WallabagTestCase;
 use Wallabag\CoreBundle\Command\InstallCommand;
+use Wallabag\CoreBundle\Tests\Mock\InstallCommandMock;
 use Symfony\Bundle\FrameworkBundle\Console\Application;
 use Symfony\Component\Console\Tester\CommandTester;
 use Symfony\Component\Console\Input\ArrayInput;
@@ -30,7 +31,7 @@ class InstallCommandTest extends WallabagTestCase
         $this->container = static::$kernel->getContainer();
 
         $application = new Application(static::$kernel);
-        $application->add(new InstallCommand());
+        $application->add(new InstallCommandMock());
 
         $command = $application->find('wallabag:install');
 
@@ -64,7 +65,7 @@ class InstallCommandTest extends WallabagTestCase
         $this->container = static::$kernel->getContainer();
 
         $application = new Application(static::$kernel);
-        $application->add(new InstallCommand());
+        $application->add(new InstallCommandMock());
 
         $command = $application->find('wallabag:install');
 
@@ -97,6 +98,9 @@ class InstallCommandTest extends WallabagTestCase
         $this->assertContains('Droping database, creating database and schema', $tester->getDisplay());
     }
 
+    /**
+     * @group command-doctrine
+     */
     public function testRunInstallCommandWithDatabaseRemoved()
     {
         $this->container = static::$kernel->getContainer();
@@ -148,7 +152,7 @@ class InstallCommandTest extends WallabagTestCase
         $this->container = static::$kernel->getContainer();
 
         $application = new Application(static::$kernel);
-        $application->add(new InstallCommand());
+        $application->add(new InstallCommandMock());
 
         $command = $application->find('wallabag:install');
 
@@ -181,6 +185,9 @@ class InstallCommandTest extends WallabagTestCase
         $this->assertContains('Droping schema and creating schema', $tester->getDisplay());
     }
 
+    /**
+     * @group command-doctrine
+     */
     public function testRunInstallCommandChooseNothing()
     {
         $this->container = static::$kernel->getContainer();
@@ -242,7 +249,7 @@ class InstallCommandTest extends WallabagTestCase
         $this->container = static::$kernel->getContainer();
 
         $application = new Application(static::$kernel);
-        $application->add(new InstallCommand());
+        $application->add(new InstallCommandMock());
 
         $command = $application->find('wallabag:install');
 
diff --git a/src/Wallabag/CoreBundle/Tests/Mock/InstallCommandMock.php b/src/Wallabag/CoreBundle/Tests/Mock/InstallCommandMock.php
new file mode 100644 (file)
index 0000000..69bc48e
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+namespace Wallabag\CoreBundle\Tests\Mock;
+
+use Wallabag\CoreBundle\Command\InstallCommand;
+
+/**
+ * This mock aims to speed the test of InstallCommand by avoid calling external command
+ * like all doctrine commands.
+ *
+ * This speed the test but as a downside, it doesn't allow to fully test the InstallCommand
+ *
+ * Launching tests to avoid doctrine command:
+ *     phpunit --exclude-group command-doctrine
+ */
+class InstallCommandMock extends InstallCommand
+{
+    protected function runCommand($command, $parameters = array())
+    {
+        return $this;
+    }
+}