WorkspaceNewPlaceholderRemovalTest.php 3.26 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php

declare(strict_types=1);

/*
 * 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!
 */

namespace TYPO3\CMS\Install\Tests\Functional\Updates\RowUpdater;

use PHPUnit\Framework\MockObject\MockObject;
21
use TYPO3\CMS\Core\Utility\GeneralUtility;
22
23
use TYPO3\CMS\Install\Updates\DatabaseRowsUpdateWizard;
use TYPO3\CMS\Install\Updates\RowUpdater\WorkspaceNewPlaceholderRemovalMigration;
24
25
use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\ActionService;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
26

27
class WorkspaceNewPlaceholderRemovalTest extends FunctionalTestCase
28
{
29
    protected $coreExtensionsToLoad = ['workspaces'];
30
31
32
33
34

    /**
     * @var array
     */
    protected $testExtensionsToLoad = [
35
        'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_foreignfield',
36
        'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_csv',
37
38
39
40
41
42
43
44
45
46
    ];

    /**
     * @var MockObject|DatabaseRowsUpdateWizard|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
     */
    protected $subject;

    protected function setUp(): void
    {
        parent::setUp();
47
        $this->actionService = GeneralUtility::makeInstance(ActionService::class);
48
49
50
51
52
53
54
55
56
57
58
        // Register only WorkspaceNewPlaceholderRemovalMigration in the row updater wizard
        $this->subject = $this->getAccessibleMock(DatabaseRowsUpdateWizard::class, ['dummy']);
        $this->subject->_set('rowUpdater', [WorkspaceNewPlaceholderRemovalMigration::class]);
    }

    /**
     * @test
     */
    public function workspaceRecordsUpdatedWithIrreCsv(): void
    {
        // Data set inspired by workspaces IRRE/CSV/Modify/DataSet/copyPage.csv
59
        $this->importCSVDataSet(__DIR__ . '/Fixtures/WorkspaceNewPlaceholderRemovalIrreCsvImport.csv');
60
        $this->subject->executeUpdate();
61
        $this->assertCSVDataSet('typo3/sysext/install/Tests/Functional/Updates/RowUpdater/Fixtures/WorkspaceNewPlaceholderRemovalIrreCsvResult.csv');
62
63
64
65
66
67
68
69
    }

    /**
     * @test
     */
    public function workspaceRecordsUpdatedWithIrreForeignField(): void
    {
        // Data set inspired by workspaces IRRE/ForeignField/Modify/DataSet/copyPage.csv
70
        $this->importCSVDataSet(__DIR__ . '/Fixtures/WorkspaceNewPlaceholderRemovalIrreForeignFieldImport.csv');
71
        $this->subject->executeUpdate();
72
        $this->assertCSVDataSet('typo3/sysext/install/Tests/Functional/Updates/RowUpdater/Fixtures/WorkspaceNewPlaceholderRemovalIrreForeignFieldResult.csv');
73
74
75
76
77
78
79
80
    }

    /**
     * @test
     */
    public function workspaceRecordsUpdatedWithManyToMany(): void
    {
        // Data set inspired by workspaces ManyToMany/Modify/DataSet/copyPage.csv
81
        $this->importCSVDataSet(__DIR__ . '/Fixtures/WorkspaceNewPlaceholderRemovalManyToManyImport.csv');
82
        $this->subject->executeUpdate();
83
        $this->assertCSVDataSet('typo3/sysext/install/Tests/Functional/Updates/RowUpdater/Fixtures/WorkspaceNewPlaceholderRemovalManyToManyResult.csv');
84
85
    }
}