Jelajahi Sumber

Fixes tests.

Benjamin Michalski 10 tahun lalu
induk
melakukan
0426ccc9bb
1 mengubah file dengan 13 tambahan dan 11 penghapusan
  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');
         $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:database:create --env=test');
         $this->executeCommand($kernelRootDir . '/console doctrine:schema:create --env=test');
         $this->executeCommand($kernelRootDir . '/console doctrine:schema:create --env=test');
         $this->executeCommand($kernelRootDir . '/console redis:flushall --env=test -n');
         $this->executeCommand($kernelRootDir . '/console redis:flushall --env=test -n');
@@ -270,14 +270,6 @@ class WebControllerTest extends WebTestCase
             $orderBysQryStrPart = '';
             $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 = new Package();
 
 
         $twigPackage->setName('twig/twig');
         $twigPackage->setName('twig/twig');
@@ -303,6 +295,14 @@ class WebControllerTest extends WebTestCase
 
 
         $this->executeCommand($kernelRootDir . '/console packagist:index --env=test --force');
         $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);
         return json_decode($content, true);
     }
     }
 
 
@@ -387,11 +387,13 @@ class WebControllerTest extends WebTestCase
      * Executes a given command.
      * Executes a given command.
      *
      *
      * @param string $command a command to execute
      * @param string $command a command to execute
+     * @param bool $errorHandling
      *
      *
      * @throws Exception when the return code is not 0.
      * @throws Exception when the return code is not 0.
      */
      */
     protected function executeCommand(
     protected function executeCommand(
-        $command
+        $command,
+        $errorHandling = true
     ) {
     ) {
         $output = array();
         $output = array();
 
 
@@ -399,7 +401,7 @@ class WebControllerTest extends WebTestCase
 
 
         exec($command, $output, $returnCode);
         exec($command, $output, $returnCode);
 
 
-        if ($returnCode !== 0) {
+        if ($errorHandling && $returnCode !== 0) {
             throw new Exception(
             throw new Exception(
                 sprintf(
                 sprintf(
                     'Error executing command "%s", return code was "%s".',
                     'Error executing command "%s", return code was "%s".',