[TASK] Follow redirects in frontend tests 88/58088/3
authorOliver Hader <oliver@typo3.org>
Thu, 30 Aug 2018 13:36:32 +0000 (15:36 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Thu, 30 Aug 2018 13:59:40 +0000 (15:59 +0200)
Resolves: #86041
Releases: master
Change-Id: Id5802bc40a6070ddcd21c76e2417d438cefa9efd
Reviewed-on: https://review.typo3.org/58088
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
composer.json
composer.lock
typo3/sysext/core/composer.json
typo3/sysext/fluid/Tests/Functional/View/TemplatesPathsTest.php
typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/PlainScenario.yaml [new file with mode: 0644]
typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/scenario.yaml [deleted file]
typo3/sysext/frontend/Tests/Functional/SiteHandling/LinkGeneratorTest.php
typo3/sysext/frontend/Tests/Functional/SiteHandling/PlainRequestTest.php
typo3/sysext/frontend/Tests/Functional/SiteHandling/SiteRequestTest.php

index 056f7e3..04b5904 100644 (file)
@@ -69,7 +69,7 @@
                "fiunchinho/phpunit-randomizer": "^4.0",
                "friendsofphp/php-cs-fixer": "^2.12.2",
                "typo3/cms-styleguide": "~9.2.0",
-               "typo3/testing-framework": "~4.7.2"
+               "typo3/testing-framework": "~4.8.0"
        },
        "suggest": {
                "ext-gd": "GDlib/Freetype is required for building images with text (GIFBUILDER) and can also be used to scale images",
index ca97c3a..6de4c36 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "23130fa85b9e60141315739df703117b",
+    "content-hash": "59f10e6d8dc3b2a4b6241f91e633603f",
     "packages": [
         {
             "name": "cogpowered/finediff",
         },
         {
             "name": "typo3/testing-framework",
-            "version": "4.7.2",
+            "version": "4.8.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/TYPO3/testing-framework.git",
-                "reference": "6c13dfeb2d88cb34a065909192d6238b55ee6066"
+                "reference": "bdc0c1a4cd1b8d4739175f118f0812675327b2c5"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/6c13dfeb2d88cb34a065909192d6238b55ee6066",
-                "reference": "6c13dfeb2d88cb34a065909192d6238b55ee6066",
+                "url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/bdc0c1a4cd1b8d4739175f118f0812675327b2c5",
+                "reference": "bdc0c1a4cd1b8d4739175f118f0812675327b2c5",
                 "shasum": ""
             },
             "require": {
                 "tests",
                 "typo3"
             ],
-            "time": "2018-08-30T07:18:39+00:00"
+            "time": "2018-08-30T11:31:41+00:00"
         },
         {
             "name": "webmozart/assert",
index 545f8a3..17539ed 100644 (file)
@@ -51,7 +51,7 @@
                "fiunchinho/phpunit-randomizer": "^4.0",
                "friendsofphp/php-cs-fixer": "^2.12.2",
                "typo3/cms-styleguide": "~9.2.0",
-               "typo3/testing-framework": "~4.7.2"
+               "typo3/testing-framework": "~4.8.0"
        },
        "suggest": {
                "ext-fileinfo": "Used for proper file type detection in the file abstraction layer",
index d6b6dab..d8e766d 100644 (file)
@@ -295,9 +295,6 @@ class TemplatesPathsTest extends FunctionalTestCase
      */
     protected function fetchFrontendResponseBody(array $requestArguments): string
     {
-        (new InternalRequest())
-            ->withQueryParameters($requestArguments);
-
         $response = $this->executeFrontendRequest(
             (new InternalRequest())->withQueryParameters($requestArguments)
         );
diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/PlainScenario.yaml b/typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/PlainScenario.yaml
new file mode 100644 (file)
index 0000000..061f6cd
--- /dev/null
@@ -0,0 +1,139 @@
+__variables:
+  - &pageStandard 0
+  - &pageShortcut 4
+  - &pageMount 7
+  - &pageFolder 254
+  - &contentText 'text'
+  - &idAcmeRootPage 1000
+  - &idAcmeFirstPage 1100
+
+entitySettings:
+  '*':
+    nodeColumnName: 'pid'
+    columnNames: {id: 'uid', language: 'sys_language_uid'}
+    defaultValues: {pid: 0}
+  page:
+    isNode: true
+    tableName: 'pages'
+    parentColumnName: 'pid'
+    languageColumnNames: ['l10n_parent', 'l10n_source']
+    columnNames: {type: 'doktype', root: 'is_siteroot', mount: 'mount_pid', visitorGroups: 'fe_group'}
+    defaultValues: {hidden: 0, doktype: *pageStandard}
+    valueInstructions:
+      shortcut:
+        first: {shortcut: 0, shortcut_mode: 1}
+  content:
+    tableName: 'tt_content'
+    languageColumnNames: ['l18n_parent', 'l10n_source']
+    columnNames: {title: 'header', type: 'CType'}
+  domain:
+    tableName: 'sys_domain'
+  workspace:
+    tableName: 'sys_workspace'
+  language:
+    tableName: 'sys_language'
+    columnNames: {code: 'language_isocode'}
+  visitorGroup:
+    tableName: 'fe_groups'
+  visitor:
+    tableName: 'fe_users'
+    columnNames: {groups: 'usergroup'}
+  typoscript:
+    tableName: 'sys_template'
+    valueInstructions:
+      type:
+        site: {root: 1, clear: 1}
+
+entities:
+  workspace:
+    - self: {id: 1, title: 'Workspace'}
+  language:
+    - self: {id: 1, title: 'French', code: 'fr'}
+    - self: {id: 2, title: 'Franco-Canadian', code: 'fr'}
+  page:
+    - self: {id: *idAcmeRootPage, title: 'ACME Inc', type: *pageShortcut, shortcut: 'first', root: true, alias: 'acme-root'}
+      children:
+        - self: {id: *idAcmeFirstPage, title: 'EN: Welcome', alias: 'acme-first'}
+          languageVariants:
+            - self: {id: 1101, title: 'FR: Welcome', language: 1}
+            - self: {id: 1102, title: 'FR-CA: Welcome', language: 2}
+          versionVariants:
+            - version: {title: 'EN: Welcome to ACME Inc', workspace: 1}
+          entities:
+            content:
+              - self: {title: 'EN: Content Element #1', type: *contentText}
+                # @todo does not work due to a bug in DataHandler's remap stack for l10n_source
+                languageVariants:
+                  - self: {title: 'FR: Content Element #1', type: *contentText, language: 1}
+                    languageVariants:
+                      - self: {title: 'FR-CA: Content Element #1', type: *contentText, language: 2}
+              - self: {title: 'EN: Content Element #2', type: *contentText}
+        - self: {id: 1200, title: 'EN: Features'}
+          children:
+            - self: {id: 1210, title: 'EN: Frontend Editing'}
+        - self: {id: 1300, title: 'EN: Products', root: true}
+          children:
+            - self: {id: 1310, title: 'EN: Planets'}
+            - self: {id: 1320, title: 'EN: Spaceships'}
+            - self: {id: 1330, title: 'EN: Dark Matter'}
+        - self: {id: 1500, title: 'Internal'}
+          children:
+            - self: {id: 1510, title: 'Whitepapers', visitorGroups: -2, extendToSubpages: true}
+              children:
+                - self: {id: 1511, title: 'Products'}
+                - self: {id: 1512, title: 'Solutions', visitorGroups: 10}
+                - self: {id: 1515, title: 'Research', visitorGroups: 20}
+            - self: {id: 1520, title: 'Forecasts', visitorGroups: 20, extendToSubpages: true}
+              children:
+                - self: {id: 1521, title: 'Current Year'}
+                - self: {id: 1522, title: 'Next Year'}
+                - self: {id: 1523, title: 'Five Years'}
+        - self: {id: 1600, title: 'About us'}
+        - self: {id: 1700, title: 'Announcements & News', type: *pageMount, mount: 7100}
+        - self: {id: 404, title: 'Page not found'}
+          entities:
+            content:
+              - self: {title: 'EN: Page not found', type: *contentText}
+        - self: {id: 1930, title: 'Our Blog', type: *pageShortcut, shortcut: 2000}
+        - version: {id: 1950, title: 'EN: Goodbye', workspace: 1}
+        - self: {id: 1990, title: 'Storage', type: *pageFolder}
+          entities:
+            visitorGroup:
+              - self: {id: 10, title: 'Customers'}
+              - self: {id: 20, title: 'Partners'}
+            visitor:
+              - self: {id: 1, username: 'john@doe.local', groups: '10'}
+              - self: {id: 2, username: 'manager@other-inc.local', groups: '20'}
+              - self: {id: 3, username: 'big-boss@acme-inc.local', groups: '10,20'}
+    - self: {id: 2000, title: 'ACME Blog', type: *pageShortcut, shortcut: 'first', root: true, alias: 'blog-root'}
+      children:
+        - self: {id: 2100, title: 'Authors'}
+          children:
+            - self: {id: 2110, title: 'John Doe'}
+              children:
+                - self: {id: 2111, title: 'About'}
+            - self: {id: 2120, title: 'Jane Doe'}
+              children:
+                - self: {id: 2121, title: 'About'}
+        - self: {id: 2700, title: 'Announcements & News', type: *pageMount, mount: 7100}
+        - self: {id: 2930, title: 'ACME Inc', type: *pageShortcut, shortcut: 1000}
+    - self: {id: 3000, title: 'ACME Archive', type: *pageShortcut, shortcut: 'first', root: true}
+      children:
+        - self: {id: 3100, title: 'EN: Statistics'}
+          languageVariants:
+            - self: {id: 3101, title: 'FR: Statistics', language: 1}
+            - self: {id: 3102, title: 'FR-CA: Statistics', language: 2}
+          children:
+            - self: {id: 3110, title: 'EN: Markets'}
+            - self: {id: 3120, title: 'EN: Products'}
+            - self: {id: 3130, title: 'EN: Partners'}
+      entities:
+        domain:
+          - self: {domainName: 'archive.acme.com'}
+    - self: {id: 7000, title: 'Common Collection', type: *pageFolder}
+      children:
+        - self: {id: 7100, title: 'Announcements & News'}
+          children:
+            - self: {id: 7110, title: 'Markets'}
+            - self: {id: 7120, title: 'Products'}
+            - self: {id: 7130, title: 'Partners'}
diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/scenario.yaml b/typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/scenario.yaml
deleted file mode 100644 (file)
index 867672b..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-__variables:
-  - &pageStandard 0
-  - &pageShortcut 4
-  - &pageMount 7
-  - &pageFolder 254
-  - &contentText 'text'
-  - &idAcmeRootPage 1000
-  - &idAcmeFirstPage 1100
-
-entitySettings:
-  '*':
-    nodeColumnName: 'pid'
-    columnNames: {id: 'uid', language: 'sys_language_uid'}
-    defaultValues: {pid: 0}
-  page:
-    isNode: true
-    tableName: 'pages'
-    parentColumnName: 'pid'
-    languageColumnNames: ['l10n_parent', 'l10n_source']
-    columnNames: {type: 'doktype', root: 'is_siteroot', mount: 'mount_pid', visitorGroups: 'fe_group'}
-    defaultValues: {hidden: 0, doktype: *pageStandard}
-    valueInstructions:
-      shortcut:
-        first: {shortcut: 0, shortcut_mode: 1}
-  content:
-    tableName: 'tt_content'
-    languageColumnNames: ['l18n_parent', 'l10n_source']
-    columnNames: {title: 'header', type: 'CType'}
-  domain:
-    tableName: 'sys_domain'
-  workspace:
-    tableName: 'sys_workspace'
-  language:
-    tableName: 'sys_language'
-    columnNames: {code: 'language_isocode'}
-  visitorGroup:
-    tableName: 'fe_groups'
-  visitor:
-    tableName: 'fe_users'
-    columnNames: {groups: 'usergroup'}
-  typoscript:
-    tableName: 'sys_template'
-    valueInstructions:
-      type:
-        site: {root: 1, clear: 1}
-
-entities:
-  workspace:
-    - self: {id: 1, title: 'Workspace'}
-  language:
-    - self: {id: 1, title: 'French', code: 'fr'}
-    - self: {id: 2, title: 'Franco-Canadian', code: 'fr'}
-  page:
-    - self: {id: *idAcmeRootPage, title: 'ACME Inc', type: *pageShortcut, shortcut: 'first', root: true, alias: 'acme-root'}
-      children:
-        - self: {id: *idAcmeFirstPage, title: 'EN: Welcome', alias: 'acme-first'}
-          languageVariants:
-            - self: {id: 1101, title: 'FR: Welcome', language: 1}
-            - self: {id: 1102, title: 'FR-CA: Welcome', language: 2}
-          versionVariants:
-            - version: {title: 'EN: Welcome to ACME Inc', workspace: 1}
-          entities:
-            content:
-              - self: {title: 'EN: Content Element #1', type: *contentText}
-                # @todo does not work due to a bug in DataHandler's remap stack for l10n_source
-                languageVariants:
-                  - self: {title: 'FR: Content Element #1', type: *contentText, language: 1}
-                    languageVariants:
-                      - self: {title: 'FR-CA: Content Element #1', type: *contentText, language: 2}
-              - self: {title: 'EN: Content Element #2', type: *contentText}
-        - self: {id: 1200, title: 'EN: Features'}
-          children:
-            - self: {id: 1210, title: 'EN: Frontend Editing'}
-        - self: {id: 1300, title: 'EN: Products', root: true}
-          children:
-            - self: {id: 1310, title: 'EN: Planets'}
-            - self: {id: 1320, title: 'EN: Spaceships'}
-            - self: {id: 1330, title: 'EN: Dark Matter'}
-        - self: {id: 1500, title: 'Internal'}
-          children:
-            - self: {id: 1510, title: 'Whitepapers', visitorGroups: -2, extendToSubpages: true}
-              children:
-                - self: {id: 1511, title: 'Products'}
-                - self: {id: 1512, title: 'Solutions', visitorGroups: 10}
-                - self: {id: 1515, title: 'Research', visitorGroups: 20}
-            - self: {id: 1520, title: 'Forecasts', visitorGroups: 20, extendToSubpages: true}
-              children:
-                - self: {id: 1521, title: 'Current Year'}
-                - self: {id: 1522, title: 'Next Year'}
-                - self: {id: 1523, title: 'Five Years'}
-        - self: {id: 1600, title: 'About us'}
-        - self: {id: 1700, title: 'Announcements & News', type: *pageMount, mount: 7100}
-          entities:
-            content:
-              - self: {title: 'EN: Page not found', type: *contentText}
-        - self: {id: 404, title: 'Page not found'}
-        - self: {id: 1930, title: 'Our Blog', type: *pageShortcut, shortcut: 2000}
-        - version: {id: 1950, title: 'EN: Goodbye', workspace: 1}
-        - self: {id: 1990, title: 'Storage', type: *pageFolder}
-          entities:
-            visitorGroup:
-              - self: {id: 10, title: 'Customers'}
-              - self: {id: 20, title: 'Partners'}
-            visitor:
-              - self: {id: 1, username: 'john@doe.local', groups: '10'}
-              - self: {id: 2, username: 'manager@other-inc.local', groups: '20'}
-              - self: {id: 3, username: 'big-boss@acme-inc.local', groups: '10,20'}
-    - self: {id: 2000, title: 'ACME Blog', type: *pageShortcut, shortcut: 'first', root: true, alias: 'blog-root'}
-      children:
-        - self: {id: 2100, title: 'Authors'}
-          children:
-            - self: {id: 2110, title: 'John Doe'}
-              children:
-                - self: {id: 2111, title: 'About'}
-            - self: {id: 2120, title: 'Jane Doe'}
-              children:
-                - self: {id: 2121, title: 'About'}
-        - self: {id: 2700, title: 'Announcements & News', type: *pageMount, mount: 7100}
-        - self: {id: 2930, title: 'ACME Inc', type: *pageShortcut, shortcut: 1000}
-    - self: {id: 3000, title: 'ACME Archive', type: *pageShortcut, shortcut: 'first', root: true}
-      children:
-        - self: {id: 3100, title: 'EN: Statistics'}
-          languageVariants:
-            - self: {id: 3101, title: 'FR: Statistics', language: 1}
-            - self: {id: 3102, title: 'FR-CA: Statistics', language: 2}
-          children:
-            - self: {id: 3110, title: 'EN: Markets'}
-            - self: {id: 3120, title: 'EN: Products'}
-            - self: {id: 3130, title: 'EN: Partners'}
-      entities:
-        domain:
-          - self: {domainName: 'archive.acme.com'}
-    - self: {id: 7000, title: 'Common Collection', type: *pageFolder}
-      children:
-        - self: {id: 7100, title: 'Announcements & News'}
-          children:
-            - self: {id: 7110, title: 'Markets'}
-            - self: {id: 7120, title: 'Products'}
-            - self: {id: 7130, title: 'Partners'}
index 20f7092..2e34660 100644 (file)
@@ -97,7 +97,7 @@ class LinkGeneratorTest extends AbstractTestCase
         $backendUser = $this->setUpBackendUserFromFixture(1);
         Bootstrap::initializeLanguageObject();
 
-        $scenarioFile = __DIR__ . '/Fixtures/scenario.yaml';
+        $scenarioFile = __DIR__ . '/Fixtures/PlainScenario.yaml';
         $factory = DataHandlerFactory::fromYamlFile($scenarioFile);
         $writer = DataHandlerWriter::withBackendUser($backendUser);
         $writer->invokeFactory($factory);
@@ -121,7 +121,7 @@ class LinkGeneratorTest extends AbstractTestCase
                 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkGenerator.typoscript',
             ],
             [
-                'title' => 'ACME Root',
+                'title' => 'ACME Blog',
                 'sitetitle' => $this->siteTitle,
             ]
         );
index 6db23da..ff172b3 100644 (file)
@@ -68,7 +68,7 @@ class PlainRequestTest extends AbstractTestCase
         $backendUser = $this->setUpBackendUserFromFixture(1);
         Bootstrap::initializeLanguageObject();
 
-        $scenarioFile = __DIR__ . '/Fixtures/scenario.yaml';
+        $scenarioFile = __DIR__ . '/Fixtures/PlainScenario.yaml';
         $factory = DataHandlerFactory::fromYamlFile($scenarioFile);
         $writer = DataHandlerWriter::withBackendUser($backendUser);
         $writer->invokeFactory($factory);
@@ -109,7 +109,7 @@ class PlainRequestTest extends AbstractTestCase
     /**
      * @return array
      */
-    public function requestsAreRedirectedDataProvider(): array
+    public function shortcutsAreRedirectedDataProvider(): array
     {
         $domainPaths = [
             '/',
@@ -134,9 +134,9 @@ class PlainRequestTest extends AbstractTestCase
      * @param string $uri
      *
      * @test
-     * @dataProvider requestsAreRedirectedDataProvider
+     * @dataProvider shortcutsAreRedirectedDataProvider
      */
-    public function requestsAreRedirected(string $uri)
+    public function shortcutsAreRedirectedToFirstSubPage(string $uri)
     {
         $expectedStatusCode = 307;
         $expectedHeaders = ['location' => ['index.php?id=acme-first']];
@@ -150,6 +150,40 @@ class PlainRequestTest extends AbstractTestCase
     }
 
     /**
+     * @param string $uri
+     *
+     * @test
+     * @dataProvider shortcutsAreRedirectedDataProvider
+     */
+    public function shortcutsAreRedirectedAndRenderFirstSubPage(string $uri)
+    {
+        $expectedStatusCode = 200;
+        $expectedPageTitle = 'EN: Welcome';
+
+        $response = $this->executeFrontendRequest(
+            new InternalRequest($uri),
+            $this->internalRequestContext,
+            true
+        );
+        $responseStructure = ResponseContent::fromString(
+            (string)$response->getBody()
+        );
+
+        static::assertSame(
+            $expectedStatusCode,
+            $response->getStatusCode()
+        );
+        static::assertSame(
+            $this->siteTitle,
+            $responseStructure->getScopePath('template/sitetitle')
+        );
+        static::assertSame(
+            $expectedPageTitle,
+            $responseStructure->getScopePath('page/title')
+        );
+    }
+
+    /**
      * @return array
      */
     public function pageIsRenderedDataProvider(): array
index e486246..cd08761 100644 (file)
@@ -68,7 +68,7 @@ class SiteRequestTest extends AbstractTestCase
         $backendUser = $this->setUpBackendUserFromFixture(1);
         Bootstrap::initializeLanguageObject();
 
-        $scenarioFile = __DIR__ . '/Fixtures/scenario.yaml';
+        $scenarioFile = __DIR__ . '/Fixtures/PlainScenario.yaml';
         $factory = DataHandlerFactory::fromYamlFile($scenarioFile);
         $writer = DataHandlerWriter::withBackendUser($backendUser);
         $writer->invokeFactory($factory);
@@ -98,7 +98,7 @@ class SiteRequestTest extends AbstractTestCase
     /**
      * @return array
      */
-    public function requestsAreRedirectedDataProvider(): array
+    public function shortcutsAreRedirectedDataProvider(): array
     {
         $domainPaths = [
             '/',
@@ -123,9 +123,9 @@ class SiteRequestTest extends AbstractTestCase
      * @param string $uri
      *
      * @test
-     * @dataProvider requestsAreRedirectedDataProvider
+     * @dataProvider shortcutsAreRedirectedDataProvider
      */
-    public function requestsAreRedirected(string $uri)
+    public function shortcutsAreRedirectedToFirstSubPage(string $uri)
     {
         $this->writeSiteConfiguration(
             'website-local',
@@ -144,6 +144,45 @@ class SiteRequestTest extends AbstractTestCase
     }
 
     /**
+     * @param string $uri
+     *
+     * @test
+     * @dataProvider shortcutsAreRedirectedDataProvider
+     */
+    public function shortcutsAreRedirectedAndRenderFirstSubPage(string $uri)
+    {
+        $this->writeSiteConfiguration(
+            'website-local',
+            $this->buildSiteConfiguration(1000, 'https://website.local/')
+        );
+
+        $expectedStatusCode = 200;
+        $expectedPageTitle = 'EN: Welcome';
+
+        $response = $this->executeFrontendRequest(
+            new InternalRequest($uri),
+            $this->internalRequestContext,
+            true
+        );
+        $responseStructure = ResponseContent::fromString(
+            (string)$response->getBody()
+        );
+
+        static::assertSame(
+            $expectedStatusCode,
+            $response->getStatusCode()
+        );
+        static::assertSame(
+            $this->siteTitle,
+            $responseStructure->getScopePath('template/sitetitle')
+        );
+        static::assertSame(
+            $expectedPageTitle,
+            $responseStructure->getScopePath('page/title')
+        );
+    }
+
+    /**
      * @return array
      */
     public function pageIsRenderedWithPathsDataProvider(): array