Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

AbstractTestSystem::initializeTestDatabase should not truncate tables that contain static data #105

Open
oliverklee opened this issue Nov 14, 2018 · 3 comments

Comments

@oliverklee
Copy link
Contributor

I'm currently working on an extension that imports static data using an ext_tables_static+adt.sql file, and that includes a functional repository test that tests that records can be loaded from the corresponding table, and that fields are mapped correctly for the model.

The first time one of those tests is run (when a new test system and a new DB is created), is passes. The second time, it fails because the database is truncated:

    public function setUp(
            // …
    ) {
        $this->registerNtfStreamWrapper();
        $this->setTypo3Context();
        if ($this->recentTestSystemExists()) {
            $this->includeAndStartCoreBootstrap();
            $this->initializeTestDatabase();
            $this->loadExtensionConfiguration();
        } else {
            // …
        }
    protected function initializeTestDatabase()
    {
        $this->bootstrap->initializeTypo3DbGlobal();
        /** @var DatabaseConnection $database */
        $database = $GLOBALS['TYPO3_DB'];
            // …
        foreach ($database->admin_get_tables() as $table) {
            $database->admin_query('TRUNCATE ' . $table['Name'] . ';');
        }
    }

This problem occurs with nimut/testing-framework 2.0.3, but the corresponding code in master does the same things.

May a configuration in the functional test case which tables should be kept would be an approach for this?

@oliverklee
Copy link
Contributor Author

For me personally, it's not important whether the table always is empty or filled with the static data. The test run results should be consistent between the first and the subsequent runs, though.

@oliverklee oliverklee changed the title AbstractTestSystem::initializeTestDatabase should not truncate tables with static data AbstractTestSystem::initializeTestDatabase should not truncate tables that contain static data Nov 15, 2018
@mbrodala
Copy link
Contributor

Alternatively the logic to import static data could be executed again after truncating all tables.

@lolli42
Copy link

lolli42 commented Jul 17, 2022

Note: https://github.com/TYPO3/testing-framework/ solved this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants