How to properly setup TypoScript in a Functional Testcase for TYPO3 CMS 11?

92 Views Asked by At

I'm trying to load the TypoScript setup in a functional test into the TypoScriptFrontendController but failing on a lack of documentation / knowledge. How do you setup the TypoScript setup properly in a FunctionalTestCase so I can use it in the ContentObjectRenderer in TYPO3 CMS 11?

Best regards

1

There are 1 best solutions below

1
H.Solo On

To properly set up TypoScript in a Functional Testcase for TYPO3 CMS 11, you need to follow these steps:

  1. Load TypoScript files: You can load TypoScript files in your test case by extending the Load TypoScript files: You can load TypoScript files in your test case by extending the setUpFrontendRootPage method and providing the TypoScript file paths. For example: method and providing the TypoScript file paths. For example:

    protected function setUp(): void { parent::setUp(); $this->setUpBackendUserFromFixture(1); $this->setUpFrontendRootPage(1, ['EXT:your_extension/Configuration/TypoScript/YourTypoScriptFile.ts']); }

  2. Create a custom FunctionalTestCase: Extend the FunctionalTestCase and override the setUp method to include the loading of TypoScript files. Here's an example:

    use TYPO3\CMS\Backend\Domain\Repository\Localization\LocalizationRepository; use TYPO3\CMS\Core\Core\Bootstrap; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

    class YourTestCase extends FunctionalTestCase { protected $testExtensionsToLoad = [ 'typo3conf/ext/your_extension/Tests/Functional/Fixtures/Extensions/test_extension', 'typo3conf/ext/base_extension', ];

       protected function setUp(): void
       {
           parent::setUp();
           $this->setUpBackendUserFromFixture(1);
           $this->setUpFrontendRootPage(1, ['EXT:your_extension/Configuration/TypoScript/YourTypoScriptFile.ts']);
           $this->importCSVDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Domain/Repository/Localization/Fixtures/DefaultPagesAndContent.csv');
           $this->subject = new LocalizationRepository();
       }
    

    }

  3. Load additional files: If your system under test works with files, you can provide them by linking or copying them to the test instance. For example:

    /**

    • @var array */ protected $pathsToLinkInTestInstance = [ 'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg' => 'fileadmin/user_upload/typo3_image2.jpg', ];

By following these steps, you should be able to set up TypoScript in your Functional Testcase for TYPO3 CMS 11.

(I'm sorry stackoverflow didn't get the formatting right. I hope it helps anyway.)