瀏覽代碼

Fixes tests.

Benjamin Michalski 10 年之前
父節點
當前提交
0426ccc9bb
共有 1 個文件被更改,包括 13 次插入11 次删除
  1. 13 11
      src/Packagist/WebBundle/Tests/Controller/WebControllerTest.php

+ 13 - 11
src/Packagist/WebBundle/Tests/Controller/WebControllerTest.php

@@ -249,7 +249,7 @@ class WebControllerTest extends WebTestCase
 
         $kernelRootDir = $container->getParameter('kernel.root_dir');
 
-        $this->executeCommand($kernelRootDir . '/console doctrine:database:drop --env=test --force');
+        $this->executeCommand($kernelRootDir . '/console doctrine:database:drop --env=test --force', false);
         $this->executeCommand($kernelRootDir . '/console doctrine:database:create --env=test');
         $this->executeCommand($kernelRootDir . '/console doctrine:schema:create --env=test');
         $this->executeCommand($kernelRootDir . '/console redis:flushall --env=test -n');
@@ -270,14 +270,6 @@ class WebControllerTest extends WebTestCase
             $orderBysQryStrPart = '';
         }
 
-        $client->request('GET', '/search.json?q=' . $orderBysQryStrPart);
-
-        $response = $client->getResponse();
-
-        $content = $client->getResponse()->getContent();
-
-        $this->assertSame(200, $response->getStatusCode(), $content);
-
         $twigPackage = new Package();
 
         $twigPackage->setName('twig/twig');
@@ -303,6 +295,14 @@ class WebControllerTest extends WebTestCase
 
         $this->executeCommand($kernelRootDir . '/console packagist:index --env=test --force');
 
+        $client->request('GET', '/search.json?q=' . $orderBysQryStrPart);
+
+        $response = $client->getResponse();
+
+        $content = $client->getResponse()->getContent();
+
+        $this->assertSame(200, $response->getStatusCode(), $content);
+
         return json_decode($content, true);
     }
 
@@ -387,11 +387,13 @@ class WebControllerTest extends WebTestCase
      * Executes a given command.
      *
      * @param string $command a command to execute
+     * @param bool $errorHandling
      *
      * @throws Exception when the return code is not 0.
      */
     protected function executeCommand(
-        $command
+        $command,
+        $errorHandling = true
     ) {
         $output = array();
 
@@ -399,7 +401,7 @@ class WebControllerTest extends WebTestCase
 
         exec($command, $output, $returnCode);
 
-        if ($returnCode !== 0) {
+        if ($errorHandling && $returnCode !== 0) {
             throw new Exception(
                 sprintf(
                     'Error executing command "%s", return code was "%s".',