浏览代码

add application testsuite

Olivier Massot 2 年之前
父节点
当前提交
009e785746

+ 2 - 1
.gitlab-ci.yml

@@ -26,7 +26,8 @@ unit:
   stage: test
 
   script:
-    - php bin/phpunit --configuration phpunit.xml.dist --colors=never --no-interaction
+    - php vendor/phpunit/phpunit/phpunit --configuration phpunit.xml.dist --colors=never --no-interaction --testsuite=unit
+    - php vendor/phpunit/phpunit/phpunit --configuration phpunit.xml.dist --colors=never --no-interaction --testsuite=application
 
   artifacts:
     paths:

+ 3 - 1
composer.json

@@ -62,7 +62,7 @@
         "twig/cssinliner-extra": "^3.4",
         "twig/extra-bundle": "^3.4",
         "twig/inky-extra": "^3.4",
-        "vincent/foselastica": "1.3",
+        "vincent/foselastica": "1.3.1",
         "webonyx/graphql-php": "^14.3",
         "xantios/mimey": "*"
     },
@@ -77,6 +77,8 @@
         "phpstan/phpstan-symfony": "^1.2",
         "phpunit/phpunit": "^9.6",
         "rector/rector": "^0.15.13",
+        "symfony/browser-kit": "6.2.*",
+        "symfony/css-selector": "6.2.*",
         "symfony/debug-bundle": "6.2.*",
         "symfony/maker-bundle": "^1.21",
         "symfony/phpunit-bridge": "^6.2",

+ 2 - 2
config/packages/framework.yaml

@@ -44,5 +44,5 @@ framework:
 when@test:
     framework:
         test: true
-        session:
-            storage_factory_id: session.storage.factory.mock_file
+#        session:
+#            storage_factory_id: session.storage.factory.mock_file

+ 2 - 2
config/packages/test/framework.yaml

@@ -1,4 +1,4 @@
 framework:
     test: true
-    session:
-        storage_factory_id: session.storage.mock_file
+#    session:
+#        storage_factory_id: session.storage.mock_file

+ 12 - 2
phpunit.xml.dist

@@ -1,6 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
-<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="tests/bootstrap.php">
+<phpunit
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
+        backupGlobals="false"
+        colors="true"
+        bootstrap="tests/bootstrap.php"
+        defaultTestSuite="unit"
+>
   <coverage includeUncoveredFiles="true">
     <include>
       <directory suffix=".php">src</directory>
@@ -19,9 +26,12 @@
     <server name="KERNEL_CLASS" value="App\Kernel" />
   </php>
   <testsuites>
-    <testsuite name="Project Test Suite">
+    <testsuite name="unit">
       <directory>tests/Unit</directory>
     </testsuite>
+    <testsuite name="application">
+      <directory>tests/Application</directory>
+    </testsuite>
   </testsuites>
   <listeners>
     <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>

+ 23 - 0
tests/Application/OtWebTestCase.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Tests\Application;
+
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\DomCrawler\Crawler;
+
+class OtWebTestCase extends \Symfony\Bundle\FrameworkBundle\Test\WebTestCase
+{
+    protected \Symfony\Bundle\FrameworkBundle\KernelBrowser $client;
+
+    public function setup(): void {
+        self::ensureKernelShutdown();
+        $this->client = static::createClient();
+    }
+
+    protected function get(string $route): Crawler {
+        return $this->client->request(
+            Request::METHOD_GET,
+            $route
+        );
+    }
+}

+ 15 - 0
tests/Application/Public/PublicEventsTest.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Tests\Application\Public;
+use App\Tests\Application\OtWebTestCase;
+
+class PublicEventsTest extends OtWebTestCase
+{
+
+    public function testEvents(): void
+    {
+        $this->get('/api/public/events');
+
+        $this->assertResponseIsSuccessful();
+    }
+}

+ 15 - 0
tests/Application/Public/PublicStructuresTest.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Tests\Application\Public;
+
+use App\Tests\Application\OtWebTestCase;
+
+class PublicStructuresTest extends OtWebTestCase
+{
+    public function testSomething(): void
+    {
+        $crawler = $this->get('/api/public/structures');
+
+        $this->assertResponseIsSuccessful();
+    }
+}