[TASK] Migrate CTypes text, image and textpic to textmedia
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / Unit / Updates / ContentTypesToTextMediaUpdateTest.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\Tests\Unit\Resource\BaseTestCase;
21 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
22 use TYPO3\CMS\Install\Updates\ContentTypesToTextMediaUpdate as UpdateWizard;
23 use TYPO3\CMS\Core\Package\PackageManager;
24
25 /**
26 * Test Class for ContentTypesToTextMediaUpdate
27 */
28 class ContentTypesToTextMediaUpdateTest 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(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() {
64 $this->packageManagerProphecy->isPackageActive('fluid_styled_content')->willReturn(TRUE);
65 $this->packageManagerProphecy->isPackageActive('css_styled_content')->willReturn(TRUE);
66
67 $description = '';
68 $this->assertFalse($this->updateWizard->checkForUpdate($description));
69 }
70
71 /**
72 * @test
73 * @return void
74 */
75 public function updateWizardDoesRunIfCssStyledContentIsNotInstalledAndDataToUpdate() {
76 $this->packageManagerProphecy->isPackageActive('fluid_styled_content')->willReturn(TRUE);
77 $this->packageManagerProphecy->isPackageActive('css_styled_content')->willReturn(FALSE);
78 $this->dbProphecy->exec_SELECTcountRows(Argument::cetera())->willReturn(1);
79
80 $description = '';
81 $this->assertTrue($this->updateWizard->checkForUpdate($description));
82 }
83
84 }