[FEATURE] Move CE table options from flexform to tt_content
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / Unit / Updates / TableFlexFormToTtContentFieldsUpdateTest.php
1 <?php
2 namespace TYPO3\CMS\Install\Tests\Unit\Updates;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use Prophecy\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
19 use Prophecy\Prophet;
20 use TYPO3\CMS\Core\Package\PackageManager;
21 use TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase;
22 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
23 use TYPO3\CMS\Install\Updates\TableFlexFormToTtContentFieldsUpdate as UpdateWizard;
24
25 /**
26 * Test Class for TableFlexFormToTtContentFieldsUpdateTest
27 */
28 class TableFlexFormToTtContentFieldsUpdateTest extends BaseTestCase {
29
30 /**
31 * @var ObjectProphecy
32 */
33 protected $packageManagerProphecy;
34
35 /**
36 * @var ObjectProphecy
37 */
38 protected $dbProphecy;
39
40 /**
41 * @var ObjectProphecy
42 */
43 protected $updateWizard;
44
45 public function setUp() {
46 unset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']);
47 $prophet = new Prophet();
48 $this->packageManagerProphecy = $prophet->prophesize(\TYPO3\CMS\Core\Package\PackageManager::class);
49 $this->dbProphecy = $prophet->prophesize(\TYPO3\CMS\Core\Database\DatabaseConnection::class);
50 $GLOBALS['TYPO3_DB'] = $this->dbProphecy->reveal();
51 $this->updateWizard = new UpdateWizard();
52 ExtensionManagementUtility::setPackageManager($this->packageManagerProphecy->reveal());
53 }
54
55 public function tearDown() {
56 ExtensionManagementUtility::setPackageManager(new PackageManager());
57 }
58
59 /**
60 * @test
61 * @return void
62 */
63 public function updateWizardDoesNotRunIfCssStyledContentIsInstalled_withoutExistingFlexFormContent() {
64
65 $this->packageManagerProphecy->isPackageActive('css_styled_content')->willReturn(TRUE);
66 $this->dbProphecy->exec_SELECTcountRows(Argument::cetera())->willReturn(0);
67
68 $description = '';
69 $this->assertFalse($this->updateWizard->checkForUpdate($description));
70 }
71
72 /**
73 * @test
74 * @return void
75 */
76 public function updateWizardDoesNotRunIfCssStyledContentIsInstalled_withExistingFlexFormContent() {
77 $this->packageManagerProphecy->isPackageActive('css_styled_content')->willReturn(TRUE);
78 $this->dbProphecy->exec_SELECTcountRows(Argument::cetera())->willReturn(1);
79
80 $description = '';
81 $this->assertFalse($this->updateWizard->checkForUpdate($description));
82 }
83
84 /**
85 * @test
86 * @return void
87 */
88 public function updateWizardDoesRunIfCssStyledContentIsNotInstalledAndExistingFlexFormContent() {
89 $this->packageManagerProphecy->isPackageActive('css_styled_content')->willReturn(FALSE);
90 $this->dbProphecy->exec_SELECTcountRows(Argument::cetera())->willReturn(1);
91
92 $description = '';
93 $this->assertTrue($this->updateWizard->checkForUpdate($description));
94 }
95 }