-
Notifications
You must be signed in to change notification settings - Fork 639
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Add UnitTest for Compatibility7ExtractionUpdate
Change-Id: I2450313e4fb470a62f9bb4e371e0200c720bb4b5 Resolves: #83950 Releases: master, 8.7 Reviewed-on: https://review.typo3.org/55771 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de> Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
- Loading branch information
Showing
1 changed file
with
128 additions
and
0 deletions.
There are no files selected for viewing
128 changes: 128 additions & 0 deletions
128
typo3/sysext/install/Tests/Unit/Updates/Compatibility7ExtractionUpdateTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
namespace TYPO3\CMS\Install\Tests\Unit\Updates; | ||
|
||
/* | ||
* 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! | ||
*/ | ||
|
||
use TYPO3\CMS\Core\Registry; | ||
use TYPO3\CMS\Core\SingletonInterface; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Extbase\Object\ObjectManager; | ||
use TYPO3\CMS\Extensionmanager\Utility\InstallUtility; | ||
use TYPO3\CMS\Extensionmanager\Utility\ListUtility; | ||
use TYPO3\CMS\Install\Updates\Compatibility7ExtractionUpdate; | ||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase; | ||
|
||
/** | ||
* Class Compatibility7ExtractionUpdateTest | ||
*/ | ||
class Compatibility7ExtractionUpdateTest extends UnitTestCase | ||
{ | ||
/** | ||
* @var Registry | ||
*/ | ||
protected $registry; | ||
|
||
/** | ||
* @var SingletonInterface[] | ||
*/ | ||
protected $singletonInstances; | ||
|
||
protected function setUp() | ||
{ | ||
$this->singletonInstances = GeneralUtility::getSingletonInstances(); | ||
$this->registry = $this->prophesize(Registry::class); | ||
GeneralUtility::setSingletonInstance(Registry::class, $this->registry->reveal()); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
GeneralUtility::purgeInstances(); | ||
GeneralUtility::resetSingletonInstances($this->singletonInstances); | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function checkForUpdateReturnsTrueIfWizardIsNotMarkedAsDoneYet() | ||
{ | ||
$this->registry->get('installUpdate', Compatibility7ExtractionUpdate::class, false)->willReturn(false); | ||
$subject = new Compatibility7ExtractionUpdate(); | ||
$description = ''; | ||
$this->assertTrue($subject->checkForUpdate($description)); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function checkForUpdateReturnsFalseIfWizardIsMarkedAsDone() | ||
{ | ||
$this->registry->get('installUpdate', Compatibility7ExtractionUpdate::class, false)->willReturn(true); | ||
$subject = new Compatibility7ExtractionUpdate(); | ||
$description = ''; | ||
$this->assertFalse($subject->checkForUpdate($description)); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function performUpdateReturnsFalseIfNoUserInputWasFound() | ||
{ | ||
$_GET['install'] = []; | ||
$subject = new Compatibility7ExtractionUpdate(); | ||
$databaseQueries = []; | ||
$customMessage = ''; | ||
$this->assertFalse($subject->performUpdate($databaseQueries, $customMessage)); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function performUpdateReturnsTrueIfUserDeclinesInstallAndMarksWizardDone() | ||
{ | ||
$_GET['install']['values']['compatibility7Extension']['install'] = 0; | ||
$subject = new Compatibility7ExtractionUpdate(); | ||
$databaseQueries = []; | ||
$customMessage = ''; | ||
$this->assertTrue($subject->performUpdate($databaseQueries, $customMessage)); | ||
$this->registry->set('installUpdate', Compatibility7ExtractionUpdate::class, 1)->shouldHaveBeenCalled(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function performUpdateInstallsExtensionUponRequestAndMarksWizardDone() | ||
{ | ||
$_GET['install']['values']['compatibility7Extension']['install'] = 1; | ||
|
||
$objectManager = $this->prophesize(ObjectManager::class); | ||
GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager->reveal()); | ||
|
||
$listUtility = $this->prophesize(ListUtility::class); | ||
$installUtility = $this->prophesize(InstallUtility::class); | ||
$objectManager->get(InstallUtility::class)->willReturn($installUtility->reveal()); | ||
$objectManager->get(ListUtility::class)->willReturn($listUtility->reveal()); | ||
$extensionList = ['compatibility7' => []]; | ||
$listUtility->getAvailableExtensions()->willReturn($extensionList); | ||
$listUtility->getAvailableAndInstalledExtensions($extensionList)->willReturn($extensionList); | ||
$installUtility->install('compatibility7')->shouldBeCalled(); | ||
|
||
$subject = new Compatibility7ExtractionUpdate(); | ||
$databaseQueries = []; | ||
$customMessage = ''; | ||
$this->assertTrue($subject->performUpdate($databaseQueries, $customMessage)); | ||
$this->registry->set('installUpdate', Compatibility7ExtractionUpdate::class, 1)->shouldHaveBeenCalled(); | ||
} | ||
} |