Jelajahi Sumber

A few tweaks on the skeleton phpunit config and test class.

Frederic G. MARAND 6 tahun lalu
induk
melakukan
731bcf99b5

+ 14 - 0
.idea/php-test-framework.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="PhpTestFrameworkVersionCache">
+    <tools_cache>
+      <tool tool_name="PHPUnit">
+        <cache>
+          <versions>
+            <info id="Local" version="6.5.4" />
+          </versions>
+        </cache>
+      </tool>
+    </tools_cache>
+  </component>
+</project>

+ 1 - 1
.idea/php.xml

@@ -86,7 +86,7 @@
   <component name="PhpProjectSharedConfiguration" php_language_level="7" />
   <component name="PhpUnit">
     <phpunit_settings>
-      <PhpUnitSettings load_method="CUSTOM_LOADER" custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" />
+      <PhpUnitSettings load_method="CUSTOM_LOADER" configuration_file_path="$PROJECT_DIR$/phpunit.xml.dist" custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" phpunit_phar_path="" use_configuration_file="true" />
     </phpunit_settings>
   </component>
 </project>

+ 6 - 0
.idea/runConfigurations/Example_test.xml

@@ -0,0 +1,6 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="Example test" type="PHPUnitRunConfigurationType" factoryName="PHPUnit" singleton="true">
+    <TestRunner scope="XML" />
+    <method />
+  </configuration>
+</component>

+ 2 - 0
.idea/silex-book.iml

@@ -152,6 +152,7 @@
           <root url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
           <root url="file://$MODULE_DIR$/vendor/symfony/polyfill-php56" />
           <root url="file://$MODULE_DIR$/vendor/symfony/polyfill-php70" />
+          <root url="file://$MODULE_DIR$/vendor/symfony/polyfill-php72" />
           <root url="file://$MODULE_DIR$/vendor/symfony/polyfill-util" />
           <root url="file://$MODULE_DIR$/vendor/symfony/process" />
           <root url="file://$MODULE_DIR$/vendor/symfony/property-access" />
@@ -232,6 +233,7 @@
           <root url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
           <root url="file://$MODULE_DIR$/vendor/symfony/polyfill-php56" />
           <root url="file://$MODULE_DIR$/vendor/symfony/polyfill-php70" />
+          <root url="file://$MODULE_DIR$/vendor/symfony/polyfill-php72" />
           <root url="file://$MODULE_DIR$/vendor/symfony/polyfill-util" />
           <root url="file://$MODULE_DIR$/vendor/symfony/process" />
           <root url="file://$MODULE_DIR$/vendor/symfony/property-access" />

+ 2 - 2
phpunit.xml.dist

@@ -4,6 +4,7 @@
 <phpunit
     backupGlobals               = "false"
     backupStaticAttributes      = "false"
+    bootstrap                   = "vendor/autoload.php"
     colors                      = "true"
     convertErrorsToExceptions   = "true"
     convertNoticesToExceptions  = "true"
@@ -11,8 +12,7 @@
     processIsolation            = "false"
     stopOnFailure               = "false"
     syntaxCheck                 = "false"
-    bootstrap                   = "vendor/autoload.php">
-
+>
     <testsuites>
         <testsuite name="Test Suite">
             <directory>src/</directory>

+ 20 - 18
tests/controllersTest.php

@@ -2,25 +2,27 @@
 
 use Silex\WebTestCase;
 
-class controllersTest extends WebTestCase
-{
-    public function testGetHomepage()
-    {
-        $client = $this->createClient();
-        $client->followRedirects(true);
-        $crawler = $client->request('GET', '/');
+class controllersTest extends WebTestCase {
 
-        $this->assertTrue($client->getResponse()->isOk());
-        $this->assertContains('Welcome', $crawler->filter('body')->text());
-    }
+  public function testGetHomepage() {
+    $client = $this->createClient();
+    $client->followRedirects(TRUE);
+    $crawler = $client->request('GET', '/');
 
-    public function createApplication()
-    {
-        $app = require __DIR__.'/../src/app.php';
-        require __DIR__.'/../config/dev.php';
-        require __DIR__.'/../src/controllers.php';
-        $app['session.test'] = true;
+    $this->assertTrue($client->getResponse()->isOk());
+    // cf index.html.twig.
+    $this->assertContains('Welcome', $crawler->filter('body')->text());
+  }
 
-        return $this->app = $app;
-    }
+  public function createApplication() {
+    $app = require __DIR__ . '/../src/app.php';
+    require __DIR__ . '/../config/dev.php';
+    require __DIR__ . '/../src/controllers.php';
+    $app['session.test'] = TRUE;
+
+    // Get raw exceptions instead of HTML page responses.
+    // unset($app['exception_handler']);
+
+    return $this->app = $app;
+  }
 }