[FOLLOWUP][TASK] Extract testing framework for TYPO3 35/51035/11
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 22 Dec 2016 21:55:00 +0000 (22:55 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Wed, 28 Dec 2016 06:55:27 +0000 (07:55 +0100)
Acceptance Tests are not found, path needs adjustment,
References need to be adjusted to the new paths.

Resolves: #79025
Releases: master
Change-Id: Id2fcfeb4e5171c89c421e0af75ddaa7e6acf6cf3
Reviewed-on: https://review.typo3.org/51035
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
26 files changed:
components/testing_framework/core/AcceptanceCoreEnvironment.php [new file with mode: 0644]
components/testing_framework/core/Build/AcceptanceTests.yml
typo3/sysext/core/Tests/Acceptance/Backend/BackendUser/ListUserCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Extensionmanager/GetExtensionsCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Extensionmanager/InstalledExtensionsCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Formhandler/CategoryTreeCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Formhandler/ElementsBasicCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Formhandler/ElementsGroupCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Formhandler/Inline1nCest.php
typo3/sysext/core/Tests/Acceptance/Backend/General/ModuleMenuCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Install/InstallModuleCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Language/LanguageCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Login/BackendLoginCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Page/AddPageInPageModuleCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Page/PageModuleCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Scheduler/TasksCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Template/TemplateCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Topbar/BookmarkCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Topbar/FlushCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Topbar/HelpCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Topbar/LogoCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Topbar/ModuleMenuButtonCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Topbar/NavigationComponentTreeCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Topbar/SearchCest.php
typo3/sysext/core/Tests/Acceptance/Backend/Topbar/UsernameOnAvatarCest.php
typo3/sysext/core/Tests/AcceptanceCoreEnvironment.php [deleted file]

diff --git a/components/testing_framework/core/AcceptanceCoreEnvironment.php b/components/testing_framework/core/AcceptanceCoreEnvironment.php
new file mode 100644 (file)
index 0000000..7bfe0f3
--- /dev/null
@@ -0,0 +1,299 @@
+<?php
+declare(strict_types=1);
+namespace TYPO3\CMS\Components\TestingFramework\Core;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use Codeception\Event\SuiteEvent;
+use Codeception\Events;
+use Codeception\Extension;
+use TYPO3\CMS\Core\Cache\Backend\NullBackend;
+use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Styleguide\TcaDataGenerator\Generator;
+
+/**
+ * This codeception extension creates a full TYPO3 instance within
+ * typo3temp. Own acceptance test suites may extend from this class
+ * and change the properties. This can be used to not copy the whole
+ * bootstrapTypo3Environment() method but reuse it instead.
+ */
+class AcceptanceCoreEnvironment extends Extension
+{
+    /**
+     * Additional core extensions to load.
+     *
+     * To be used in own acceptance test suites.
+     *
+     * If a test suite needs additional core extensions, for instance as a dependency of
+     * an extension that is tested, those core extension names can be noted here and will
+     * be loaded.
+     *
+     * @var array
+     */
+    protected $coreExtensionsToLoad = [];
+
+    /**
+     * Array of test/fixture extensions paths that should be loaded for a test.
+     *
+     * To be used in own acceptance test suites.
+     *
+     * Given path is expected to be relative to your document root, example:
+     *
+     * array(
+     *   'typo3conf/ext/some_extension/Tests/Functional/Fixtures/Extensions/test_extension',
+     *   'typo3conf/ext/base_extension',
+     * );
+     *
+     * Extensions in this array are linked to the test instance, loaded
+     * and their ext_tables.sql will be applied.
+     *
+     * @var array
+     */
+    protected $testExtensionsToLoad = [];
+
+    /**
+     * Array of test/fixture folder or file paths that should be linked for a test.
+     *
+     * To be used in own acceptance test suites.
+     *
+     * array(
+     *   'link-source' => 'link-destination'
+     * );
+     *
+     * Given paths are expected to be relative to the test instance root.
+     * The array keys are the source paths and the array values are the destination
+     * paths, example:
+     *
+     * array(
+     *   'typo3/sysext/impext/Tests/Functional/Fixtures/Folders/fileadmin/user_upload' =>
+     *   'fileadmin/user_upload',
+     *   'typo3conf/ext/my_own_ext/Tests/Functional/Fixtures/Folders/uploads/tx_myownext' =>
+     *   'uploads/tx_myownext'
+     * );
+     *
+     * To be able to link from my_own_ext the extension path needs also to be registered in
+     * property $testExtensionsToLoad
+     *
+     * @var array
+     */
+    protected $pathsToLinkInTestInstance = [];
+
+    /**
+     * This configuration array is merged with TYPO3_CONF_VARS
+     * that are set in default configuration and factory configuration
+     *
+     * To be used in own acceptance test suites.
+     *
+     * @var array
+     */
+    protected $configurationToUseInTestInstance = [];
+
+    /**
+     * Array of folders that should be created inside the test instance document root.
+     *
+     * To be used in own acceptance test suites.
+     *
+     * Per default the following folder are created
+     * /fileadmin
+     * /typo3temp
+     * /typo3conf
+     * /typo3conf/ext
+     * /uploads
+     *
+     * To create additional folders add the paths to this array. Given paths are expected to be
+     * relative to the test instance root and have to begin with a slash. Example:
+     *
+     * array(
+     *   'fileadmin/user_upload'
+     * );
+     *
+     * @var array
+     */
+    protected $additionalFoldersToCreate = [];
+
+    /**
+     * XML database fixtures to be loaded into database.
+     *
+     * Given paths are expected to be relative to your document root.
+     *
+     * @var array
+     */
+    protected $xmlDatabaseFixtures = [
+        'components/testing_framework/core/Acceptance/Fixtures/be_users.xml',
+        'components/testing_framework/core/Acceptance/Fixtures/be_sessions.xml',
+        'components/testing_framework/core/Acceptance/Fixtures/be_groups.xml',
+        'components/testing_framework/core/Acceptance/Fixtures/sys_category.xml',
+        'components/testing_framework/core/Acceptance/Fixtures/tx_extensionmanager_domain_model_extension.xml',
+        'components/testing_framework/core/Acceptance/Fixtures/tx_extensionmanager_domain_model_repository.xml',
+    ];
+
+    /**
+     * Events to listen to
+     */
+    public static $events = [
+        Events::SUITE_BEFORE => 'bootstrapTypo3Environment',
+        Events::TEST_AFTER => 'cleanupTypo3Environment'
+    ];
+
+    /**
+     * Handle SUITE_BEFORE event.
+     *
+     * Create a full standalone TYPO3 instance within typo3temp/var/tests/acceptance,
+     * create a database and create database schema.
+     *
+     * @param SuiteEvent $suiteEvent
+     * @throws Exception
+     */
+    public function bootstrapTypo3Environment(SuiteEvent $suiteEvent)
+    {
+        $testbase = new Testbase();
+        $testbase->enableDisplayErrors();
+        $testbase->defineBaseConstants();
+        $testbase->defineOriginalRootPath();
+        $testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/tests/acceptance');
+        $testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/transient');
+
+        $instancePath = ORIGINAL_ROOT . 'typo3temp/var/tests/acceptance';
+
+        $testbase->defineTypo3ModeBe();
+        $testbase->setTypo3TestingContext();
+        $testbase->removeOldInstanceIfExists($instancePath);
+        // Basic instance directory structure
+        $testbase->createDirectory($instancePath . '/fileadmin');
+        $testbase->createDirectory($instancePath . '/typo3temp/var/transient');
+        $testbase->createDirectory($instancePath . '/typo3temp/assets');
+        $testbase->createDirectory($instancePath . '/typo3conf/ext');
+        $testbase->createDirectory($instancePath . '/uploads');
+        // Additionally requested directories
+        foreach ($this->additionalFoldersToCreate as $directory) {
+            $testbase->createDirectory($instancePath . '/' . $directory);
+        }
+        $testbase->createLastRunTextfile($instancePath);
+        $testbase->setUpInstanceCoreLinks($instancePath);
+        // ext:styleguide is always loaded
+        $testExtensionsToLoad = array_merge(
+            [ 'typo3conf/ext/styleguide' ],
+            $this->testExtensionsToLoad
+        );
+        $testbase->linkTestExtensionsToInstance($instancePath, $testExtensionsToLoad);
+        $testbase->linkPathsInTestInstance($instancePath, $this->pathsToLinkInTestInstance);
+        $localConfiguration['DB'] = $testbase->getOriginalDatabaseSettingsFromEnvironmentOrLocalConfiguration();
+        $originalDatabaseName = $localConfiguration['DB']['Connections']['Default']['dbname'];
+        // Append the unique identifier to the base database name to end up with a single database per test case
+        $localConfiguration['DB']['Connections']['Default']['dbname'] = $originalDatabaseName . '_at';
+        $testbase->testDatabaseNameIsNotTooLong($originalDatabaseName, $localConfiguration);
+        // Set some hard coded base settings for the instance. Those could be overruled by
+        // $this->configurationToUseInTestInstance if needed again.
+        $localConfiguration['BE']['debug'] = true;
+        $localConfiguration['BE']['lockHashKeyWords'] = '';
+        $localConfiguration['BE']['installToolPassword'] = $this->getInstallToolPassword();
+        $localConfiguration['BE']['loginSecurityLevel'] = 'rsa';
+        $localConfiguration['SYS']['isInitialInstallationInProgress'] = false;
+        $localConfiguration['SYS']['isInitialDatabaseImportDone'] = true;
+        $localConfiguration['SYS']['displayErrors'] = false;
+        $localConfiguration['SYS']['debugExceptionHandler'] = '';
+        $localConfiguration['SYS']['trustedHostsPattern'] = 'localhost:8000';
+        $localConfiguration['SYS']['encryptionKey'] = 'iAmInvalid';
+        // @todo: This sql_mode should be enabled as soon as styleguide and dataHandler can cope with it
+        //$localConfiguration['SYS']['setDBinit'] = 'SET SESSION sql_mode = \'STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY\';';
+        $localConfiguration['SYS']['caching']['cacheConfigurations']['extbase_object']['backend'] = NullBackend::class;
+        $testbase->setUpLocalConfiguration($instancePath, $localConfiguration, $this->configurationToUseInTestInstance);
+        $defaultCoreExtensionsToLoad = [
+            'core',
+            'beuser',
+            'extbase',
+            'fluid',
+            'filelist',
+            'extensionmanager',
+            'lang',
+            'setup',
+            'rsaauth',
+            'saltedpasswords',
+            'backend',
+            'about',
+            'belog',
+            'install',
+            't3skin',
+            'frontend',
+            'recordlist',
+            'reports',
+            'sv',
+            'scheduler',
+            'tstemplate',
+        ];
+        $testbase->setUpPackageStates($instancePath, $defaultCoreExtensionsToLoad, $this->coreExtensionsToLoad, $testExtensionsToLoad);
+        $testbase->setUpBasicTypo3Bootstrap($instancePath);
+        $testbase->setUpTestDatabase($localConfiguration['DB']['Connections']['Default']['dbname'], $originalDatabaseName);
+        $testbase->loadExtensionTables();
+        $testbase->createDatabaseStructure();
+
+        // Unset a closure or phpunit kicks in with a 'serialization of \Closure is not allowed'
+        // Alternative solution:
+        // unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys']['extbase']);
+        $suite = $suiteEvent->getSuite();
+        $suite->setBackupGlobals(false);
+
+        foreach ($this->xmlDatabaseFixtures as $fixture) {
+            $testbase->importXmlDatabaseFixture(ORIGINAL_ROOT . $fixture);
+        }
+
+        // styleguide generator uses DataHandler for some parts. DataHandler needs an initialized BE user
+        // with admin right and the live workspace.
+        Bootstrap::getInstance()->initializeBackendUser();
+        $GLOBALS['BE_USER']->user['admin'] = 1;
+        $GLOBALS['BE_USER']->user['uid'] = 1;
+        $GLOBALS['BE_USER']->workspace = 0;
+        Bootstrap::getInstance()->initializeLanguageObject();
+
+        $styleguideGenerator = new Generator();
+        $styleguideGenerator->create();
+
+        // @todo: Find out why that is needed to execute the first test successfully
+        $this->cleanupTypo3Environment();
+    }
+
+    /**
+     * Method executed after each test
+     *
+     * @return void
+     */
+    public function cleanupTypo3Environment()
+    {
+        // Reset uc db field of be_user "admin" to null to reduce
+        // possible side effects between single tests.
+        GeneralUtility::makeInstance(ConnectionPool::class)
+            ->getConnectionForTable('be_users')
+            ->update('be_users', ['uc' => null], ['uid' => 1]);
+    }
+
+    /**
+     * Set install tool password. This is either a salted password
+     * of a given typo3InstallToolPassword environment variable, or
+     * a hardcoded value that does not allow login.
+     *
+     * @return string
+     */
+    protected function getInstallToolPassword(): string
+    {
+        $password = getenv('typo3InstallToolPassword');
+        if (!empty($password)) {
+            $saltFactory = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance(null, 'BE');
+            return $saltFactory->getHashedPassword($password);
+        } else {
+            return '$P$notnotnotnotnotnot.validvalidva';
+        }
+    }
+}
index a52860d..4bfaa24 100644 (file)
@@ -1,6 +1,7 @@
 actor: Tester
 paths:
-  tests: ../Tests
+# @todo clean up here: https://forge.typo3.org/issues/79097 
+  tests: ../../../../typo3/sysext/core/Tests
   log: ../../../../typo3temp/var/tests
   data: Configuration/Acceptance/Data
   support: Configuration/Acceptance/Support
@@ -12,4 +13,4 @@ extensions:
   enabled:
     - Codeception\Extension\RunFailed
     - Codeception\Extension\Recorder
-    - TYPO3\CMS\Core\Tests\AcceptanceCoreEnvironment
\ No newline at end of file
+    - TYPO3\CMS\Components\TestingFramework\Core\AcceptanceCoreEnvironment
index 2794d7d..11184c5 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\BackendUser;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * List User tests
index 54d938b..2193456 100644 (file)
@@ -15,7 +15,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Extensionmanager;
  */
 
 use Facebook\WebDriver\WebDriverKeys;
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * Tests for the "Get Extensions view" of the extension manager
index 551f7ed..73ee65a 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Extensionmanager;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * Tests for the "Install list view" of the extension manager
index a096409..aac54f3 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Formhandler;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * Category tree tests
index f3f329c..5140169 100644 (file)
@@ -14,10 +14,10 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Formhandler;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Formhandler;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\FormHandlerElementTestDataObject;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Page\PageTree;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Helper\Formhandler;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Helper\FormHandlerElementTestDataObject;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Page\PageTree;
 
 /**
  * Tests for basic element fields
index 7f3cee0..aa89797 100644 (file)
@@ -15,8 +15,8 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Formhandler;
  */
 
 use Facebook\WebDriver\Exception\NoSuchWindowException;
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Page\PageTree;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Page\PageTree;
 
 /**
  * Tests for ElementsGroupelement fields
index 1235d91..fa412eb 100644 (file)
@@ -15,10 +15,10 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Formhandler;
  */
 
 use Facebook\WebDriver\WebDriverKeys;
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Formhandler;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Page\PageTree;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Helper\Formhandler;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Helper\ModalDialog;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Page\PageTree;
 
 /**
  * Tests for inline 1n
index e64fc16..8b260df 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\General;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * Module Menu tests
index d98e1f7..3b24859 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Language;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * Install Module tests
index 4c4f47e..6c5fcaf 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Language;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * Language tests
index 4f52fd1..b7edb2a 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Login;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Topbar;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Helper\Topbar;
 
 /**
  * Various backend login related tests
index d77facf..53d37b9 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Page;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * Page and page tree related tests.
index 2773b03..5fe4d39 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Page;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * This testcase is used to check if the expected information is found when
index cb451bf..7355908 100644 (file)
@@ -14,8 +14,8 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Scheduler;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Helper\ModalDialog;
 
 /**
  * Scheduler task tests
index 68a8be2..755b2ca 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Template;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * Template tests
index 57f51a1..d3146ea 100644 (file)
@@ -15,9 +15,9 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Topbar;
  */
 
 use Codeception\Scenario;
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Topbar;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Helper\ModalDialog;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Helper\Topbar;
 
 /**
  * Test for the "Bookmark" functionality
index a14106a..29e72df 100644 (file)
@@ -14,8 +14,8 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Topbar;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Topbar;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Helper\Topbar;
 
 /**
  * Tests for the flush module in the topbar
index 1b8609a..816ea19 100644 (file)
@@ -14,8 +14,8 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Topbar;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Topbar;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Helper\Topbar;
 
 /**
  * Tests for the help module in the topbar
index 15b686e..f0a7618 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Topbar;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * Acceptance test for the TYPO3 logo in the topbar
index f51c470..9d80510 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\core\Tests\Acceptance\Backend\Topbar;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * Acceptance test for the menu button in the topbar
index 93e5cb1..ba6ab3b 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Topbar;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * Acceptance test for the Navigation Component Tree
index e89afa6..0b7564c 100644 (file)
@@ -14,8 +14,8 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Topbar;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
-use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Topbar;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Support\Helper\Topbar;
 
 /**
  * Test the search module in the top bar
index 7a106f1..f4b0d17 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Topbar;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
+use TYPO3\CMS\Components\TestingFramework\Core\Acceptance\Step\Backend\Admin;
 
 /**
  * Topbar username and avatar module tests.
diff --git a/typo3/sysext/core/Tests/AcceptanceCoreEnvironment.php b/typo3/sysext/core/Tests/AcceptanceCoreEnvironment.php
deleted file mode 100644 (file)
index 4a12fe1..0000000
+++ /dev/null
@@ -1,299 +0,0 @@
-<?php
-declare(strict_types=1);
-namespace TYPO3\CMS\Core\Tests;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use Codeception\Event\SuiteEvent;
-use Codeception\Events;
-use Codeception\Extension;
-use TYPO3\CMS\Core\Cache\Backend\NullBackend;
-use TYPO3\CMS\Core\Core\Bootstrap;
-use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Styleguide\TcaDataGenerator\Generator;
-
-/**
- * This codeception extension creates a full TYPO3 instance within
- * typo3temp. Own acceptance test suites may extend from this class
- * and change the properties. This can be used to not copy the whole
- * bootstrapTypo3Environment() method but reuse it instead.
- */
-class AcceptanceCoreEnvironment extends Extension
-{
-    /**
-     * Additional core extensions to load.
-     *
-     * To be used in own acceptance test suites.
-     *
-     * If a test suite needs additional core extensions, for instance as a dependency of
-     * an extension that is tested, those core extension names can be noted here and will
-     * be loaded.
-     *
-     * @var array
-     */
-    protected $coreExtensionsToLoad = [];
-
-    /**
-     * Array of test/fixture extensions paths that should be loaded for a test.
-     *
-     * To be used in own acceptance test suites.
-     *
-     * Given path is expected to be relative to your document root, example:
-     *
-     * array(
-     *   'typo3conf/ext/some_extension/Tests/Functional/Fixtures/Extensions/test_extension',
-     *   'typo3conf/ext/base_extension',
-     * );
-     *
-     * Extensions in this array are linked to the test instance, loaded
-     * and their ext_tables.sql will be applied.
-     *
-     * @var array
-     */
-    protected $testExtensionsToLoad = [];
-
-    /**
-     * Array of test/fixture folder or file paths that should be linked for a test.
-     *
-     * To be used in own acceptance test suites.
-     *
-     * array(
-     *   'link-source' => 'link-destination'
-     * );
-     *
-     * Given paths are expected to be relative to the test instance root.
-     * The array keys are the source paths and the array values are the destination
-     * paths, example:
-     *
-     * array(
-     *   'typo3/sysext/impext/Tests/Functional/Fixtures/Folders/fileadmin/user_upload' =>
-     *   'fileadmin/user_upload',
-     *   'typo3conf/ext/my_own_ext/Tests/Functional/Fixtures/Folders/uploads/tx_myownext' =>
-     *   'uploads/tx_myownext'
-     * );
-     *
-     * To be able to link from my_own_ext the extension path needs also to be registered in
-     * property $testExtensionsToLoad
-     *
-     * @var array
-     */
-    protected $pathsToLinkInTestInstance = [];
-
-    /**
-     * This configuration array is merged with TYPO3_CONF_VARS
-     * that are set in default configuration and factory configuration
-     *
-     * To be used in own acceptance test suites.
-     *
-     * @var array
-     */
-    protected $configurationToUseInTestInstance = [];
-
-    /**
-     * Array of folders that should be created inside the test instance document root.
-     *
-     * To be used in own acceptance test suites.
-     *
-     * Per default the following folder are created
-     * /fileadmin
-     * /typo3temp
-     * /typo3conf
-     * /typo3conf/ext
-     * /uploads
-     *
-     * To create additional folders add the paths to this array. Given paths are expected to be
-     * relative to the test instance root and have to begin with a slash. Example:
-     *
-     * array(
-     *   'fileadmin/user_upload'
-     * );
-     *
-     * @var array
-     */
-    protected $additionalFoldersToCreate = [];
-
-    /**
-     * XML database fixtures to be loaded into database.
-     *
-     * Given paths are expected to be relative to your document root.
-     *
-     * @var array
-     */
-    protected $xmlDatabaseFixtures = [
-        'components/testing_framework/core/Acceptance/Fixtures/be_users.xml',
-        'components/testing_framework/core/Acceptance/Fixtures/be_sessions.xml',
-        'components/testing_framework/core/Acceptance/Fixtures/be_groups.xml',
-        'components/testing_framework/core/Acceptance/Fixtures/sys_category.xml',
-        'components/testing_framework/core/Acceptance/Fixtures/tx_extensionmanager_domain_model_extension.xml',
-        'components/testing_framework/core/Acceptance/Fixtures/tx_extensionmanager_domain_model_repository.xml',
-    ];
-
-    /**
-     * Events to listen to
-     */
-    public static $events = [
-        Events::SUITE_BEFORE => 'bootstrapTypo3Environment',
-        Events::TEST_AFTER => 'cleanupTypo3Environment'
-    ];
-
-    /**
-     * Handle SUITE_BEFORE event.
-     *
-     * Create a full standalone TYPO3 instance within typo3temp/var/tests/acceptance,
-     * create a database and create database schema.
-     *
-     * @param SuiteEvent $suiteEvent
-     * @throws Exception
-     */
-    public function bootstrapTypo3Environment(SuiteEvent $suiteEvent)
-    {
-        $testbase = new Testbase();
-        $testbase->enableDisplayErrors();
-        $testbase->defineBaseConstants();
-        $testbase->defineOriginalRootPath();
-        $testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/tests/acceptance');
-        $testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/transient');
-
-        $instancePath = ORIGINAL_ROOT . 'typo3temp/var/tests/acceptance';
-
-        $testbase->defineTypo3ModeBe();
-        $testbase->setTypo3TestingContext();
-        $testbase->removeOldInstanceIfExists($instancePath);
-        // Basic instance directory structure
-        $testbase->createDirectory($instancePath . '/fileadmin');
-        $testbase->createDirectory($instancePath . '/typo3temp/var/transient');
-        $testbase->createDirectory($instancePath . '/typo3temp/assets');
-        $testbase->createDirectory($instancePath . '/typo3conf/ext');
-        $testbase->createDirectory($instancePath . '/uploads');
-        // Additionally requested directories
-        foreach ($this->additionalFoldersToCreate as $directory) {
-            $testbase->createDirectory($instancePath . '/' . $directory);
-        }
-        $testbase->createLastRunTextfile($instancePath);
-        $testbase->setUpInstanceCoreLinks($instancePath);
-        // ext:styleguide is always loaded
-        $testExtensionsToLoad = array_merge(
-            [ 'typo3conf/ext/styleguide' ],
-            $this->testExtensionsToLoad
-        );
-        $testbase->linkTestExtensionsToInstance($instancePath, $testExtensionsToLoad);
-        $testbase->linkPathsInTestInstance($instancePath, $this->pathsToLinkInTestInstance);
-        $localConfiguration['DB'] = $testbase->getOriginalDatabaseSettingsFromEnvironmentOrLocalConfiguration();
-        $originalDatabaseName = $localConfiguration['DB']['Connections']['Default']['dbname'];
-        // Append the unique identifier to the base database name to end up with a single database per test case
-        $localConfiguration['DB']['Connections']['Default']['dbname'] = $originalDatabaseName . '_at';
-        $testbase->testDatabaseNameIsNotTooLong($originalDatabaseName, $localConfiguration);
-        // Set some hard coded base settings for the instance. Those could be overruled by
-        // $this->configurationToUseInTestInstance if needed again.
-        $localConfiguration['BE']['debug'] = true;
-        $localConfiguration['BE']['lockHashKeyWords'] = '';
-        $localConfiguration['BE']['installToolPassword'] = $this->getInstallToolPassword();
-        $localConfiguration['BE']['loginSecurityLevel'] = 'rsa';
-        $localConfiguration['SYS']['isInitialInstallationInProgress'] = false;
-        $localConfiguration['SYS']['isInitialDatabaseImportDone'] = true;
-        $localConfiguration['SYS']['displayErrors'] = false;
-        $localConfiguration['SYS']['debugExceptionHandler'] = '';
-        $localConfiguration['SYS']['trustedHostsPattern'] = 'localhost:8000';
-        $localConfiguration['SYS']['encryptionKey'] = 'iAmInvalid';
-        // @todo: This sql_mode should be enabled as soon as styleguide and dataHandler can cope with it
-        //$localConfiguration['SYS']['setDBinit'] = 'SET SESSION sql_mode = \'STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY\';';
-        $localConfiguration['SYS']['caching']['cacheConfigurations']['extbase_object']['backend'] = NullBackend::class;
-        $testbase->setUpLocalConfiguration($instancePath, $localConfiguration, $this->configurationToUseInTestInstance);
-        $defaultCoreExtensionsToLoad = [
-            'core',
-            'beuser',
-            'extbase',
-            'fluid',
-            'filelist',
-            'extensionmanager',
-            'lang',
-            'setup',
-            'rsaauth',
-            'saltedpasswords',
-            'backend',
-            'about',
-            'belog',
-            'install',
-            't3skin',
-            'frontend',
-            'recordlist',
-            'reports',
-            'sv',
-            'scheduler',
-            'tstemplate',
-        ];
-        $testbase->setUpPackageStates($instancePath, $defaultCoreExtensionsToLoad, $this->coreExtensionsToLoad, $testExtensionsToLoad);
-        $testbase->setUpBasicTypo3Bootstrap($instancePath);
-        $testbase->setUpTestDatabase($localConfiguration['DB']['Connections']['Default']['dbname'], $originalDatabaseName);
-        $testbase->loadExtensionTables();
-        $testbase->createDatabaseStructure();
-
-        // Unset a closure or phpunit kicks in with a 'serialization of \Closure is not allowed'
-        // Alternative solution:
-        // unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys']['extbase']);
-        $suite = $suiteEvent->getSuite();
-        $suite->setBackupGlobals(false);
-
-        foreach ($this->xmlDatabaseFixtures as $fixture) {
-            $testbase->importXmlDatabaseFixture(ORIGINAL_ROOT . $fixture);
-        }
-
-        // styleguide generator uses DataHandler for some parts. DataHandler needs an initialized BE user
-        // with admin right and the live workspace.
-        Bootstrap::getInstance()->initializeBackendUser();
-        $GLOBALS['BE_USER']->user['admin'] = 1;
-        $GLOBALS['BE_USER']->user['uid'] = 1;
-        $GLOBALS['BE_USER']->workspace = 0;
-        Bootstrap::getInstance()->initializeLanguageObject();
-
-        $styleguideGenerator = new Generator();
-        $styleguideGenerator->create();
-
-        // @todo: Find out why that is needed to execute the first test successfully
-        $this->cleanupTypo3Environment();
-    }
-
-    /**
-     * Method executed after each test
-     *
-     * @return void
-     */
-    public function cleanupTypo3Environment()
-    {
-        // Reset uc db field of be_user "admin" to null to reduce
-        // possible side effects between single tests.
-        GeneralUtility::makeInstance(ConnectionPool::class)
-            ->getConnectionForTable('be_users')
-            ->update('be_users', ['uc' => null], ['uid' => 1]);
-    }
-
-    /**
-     * Set install tool password. This is either a salted password
-     * of a given typo3InstallToolPassword environment variable, or
-     * a hardcoded value that does not allow login.
-     *
-     * @return string
-     */
-    protected function getInstallToolPassword(): string
-    {
-        $password = getenv('typo3InstallToolPassword');
-        if (!empty($password)) {
-            $saltFactory = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance(null, 'BE');
-            return $saltFactory->getHashedPassword($password);
-        } else {
-            return '$P$notnotnotnotnotnot.validvalidva';
-        }
-    }
-}