Skip to content

Commit

Permalink
[TASK] Ensure unit tests properly call parent::setUp()
Browse files Browse the repository at this point in the history
This change ensures that unit tests has a valid `setUp()`
parent call chain down to the testing-framework base
class and acts as a pre-patch to introduce tightend
safe-guard checks on testing-framework level afterwards.

Resolves: #98553
Releases: main, 11.5
Change-Id: I6ea1ddf5c979b6565b9dbfcb86776f224531fcdd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76008
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
sbuerk committed Oct 8, 2022
1 parent ccd255d commit 6962acf
Show file tree
Hide file tree
Showing 29 changed files with 29 additions and 0 deletions.
Expand Up @@ -42,6 +42,7 @@ class BackendUserConfigurationTest extends UnitTestCase
*/
protected function setUp(): void
{
parent::setUp();
$this->backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
$this->backendUser = $this->backendUserProphecy->reveal();
$this->backendUserConfiguration = new BackendUserConfiguration($this->backendUser);
Expand Down
Expand Up @@ -58,6 +58,7 @@ class FileControllerTest extends UnitTestCase
*/
protected function setUp(): void
{
parent::setUp();
$this->fileResourceMock = $this->getMockBuilder(File::class)
->onlyMethods(['toArray', 'getModificationTime', 'getExtension', 'getParentFolder'])
->disableOriginalConstructor()
Expand Down
Expand Up @@ -47,6 +47,7 @@ class ThumbnailControllerTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']
= '4408d27a916d51e624b69af3554f516dbab61037a9f7b9fd6f81b4d3bedeccb6';
$this->subject = $this->createPartialMock(
Expand Down
Expand Up @@ -57,6 +57,7 @@ class LoginControllerTest extends UnitTestCase
*/
protected function setUp(): void
{
parent::setUp();
$this->loginControllerMock = $this->getAccessibleMock(LoginController::class, ['dummy'], [], '', false);
}

Expand Down
Expand Up @@ -49,6 +49,7 @@ class InputDateTimeElementTest extends UnitTestCase
*/
protected function setUp(): void
{
parent::setUp();
$this->timezoneBackup = date_default_timezone_get();
}

Expand Down
Expand Up @@ -38,6 +38,7 @@ class FormDataCompilerTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->formDataGroupProphecy = $this->prophesize(FormDataGroupInterface::class);
$this->subject = new FormDataCompiler($this->formDataGroupProphecy->reveal());
}
Expand Down
Expand Up @@ -36,6 +36,7 @@ class FlexFormSegmentTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = new FlexFormSegment();
}

Expand Down
Expand Up @@ -35,6 +35,7 @@ class OnTheFlyTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = new OnTheFly();
}

Expand Down
Expand Up @@ -36,6 +36,7 @@ class SiteConfigurationDataGroupTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = new SiteConfigurationDataGroup();
}

Expand Down
Expand Up @@ -36,6 +36,7 @@ class TcaDatabaseRecordTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = new TcaDatabaseRecord();
}

Expand Down
Expand Up @@ -36,6 +36,7 @@ class TcaInputPlaceholderRecordTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = new TcaInputPlaceholderRecord();
}

Expand Down
Expand Up @@ -36,6 +36,7 @@ class TcaSelectTreeAjaxFieldDataTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = new TcaSelectTreeAjaxFieldData();
}

Expand Down
Expand Up @@ -33,6 +33,7 @@ class DatabaseDefaultLanguagePageRowTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'] = 'l10n_parent';
$this->subject = $this->getMockBuilder(DatabaseDefaultLanguagePageRow::class)
->onlyMethods(['getDatabaseRow'])
Expand Down
Expand Up @@ -35,6 +35,7 @@ class DatabaseEditRowTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = $this->getMockBuilder(DatabaseEditRow::class)
->onlyMethods(['getDatabaseRow'])
->getMock();
Expand Down
Expand Up @@ -29,6 +29,7 @@ class DatabaseEffectivePidTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = new DatabaseEffectivePid();
}

Expand Down
Expand Up @@ -44,6 +44,7 @@ class DatabaseLanguageRowsTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->beUserProphecy = $this->prophesize(BackendUserAuthentication::class);
$GLOBALS['BE_USER'] = $this->beUserProphecy;

Expand Down
Expand Up @@ -33,6 +33,7 @@ class DatabasePageLanguageOverlayRowsTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = $this->getMockBuilder(DatabasePageLanguageOverlayRows::class)
->onlyMethods(['getDatabaseRows'])
->getMock();
Expand Down
Expand Up @@ -33,6 +33,7 @@ class DatabaseParentPageRowTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = $this->getMockBuilder(DatabaseParentPageRow::class)
->onlyMethods(['getDatabaseRow'])
->getMock();
Expand Down
Expand Up @@ -29,6 +29,7 @@ class DatabaseRecordOverrideValuesTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = new DatabaseRecordOverrideValues();
}

Expand Down
Expand Up @@ -33,6 +33,7 @@ class DatabaseRecordTypeValueTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = $this->getMockBuilder(DatabaseRecordTypeValue::class)
->onlyMethods(['getDatabaseRow'])
->getMock();
Expand Down
Expand Up @@ -39,6 +39,7 @@ class ApcuBackendTest extends UnitTestCase
*/
protected function setUp(): void
{
parent::setUp();
// APCu module is called apcu, but options are prefixed with apc
if (!extension_loaded('apcu') || !(bool)ini_get('apc.enabled') || !(bool)ini_get('apc.enable_cli')) {
self::markTestSkipped('APCu extension was not available, or it was disabled for CLI.');
Expand Down
Expand Up @@ -40,6 +40,7 @@ class ServiceProviderRegistryTest extends UnitTestCase
*/
protected function setUp(): void
{
parent::setUp();
$this->packageManagerProphecy = $this->prophesize(PackageManager::class);
$this->packageManagerProphecy->isPackageActive(Argument::any())->willReturn(false);
$this->packageManagerProphecy->getActivePackages()->willReturn([]);
Expand Down
Expand Up @@ -34,6 +34,7 @@ class DashboardPresetRegistryTest extends UnitTestCase

public function setUp(): void
{
parent::setUp();
$this->subject = GeneralUtility::makeInstance(
DashboardPresetRegistry::class
);
Expand Down
Expand Up @@ -34,6 +34,7 @@ class WidgetGroupRegistryTest extends UnitTestCase

public function setUp(): void
{
parent::setUp();
$this->subject = GeneralUtility::makeInstance(
WidgetGroupRegistry::class
);
Expand Down
1 change: 1 addition & 0 deletions typo3/sysext/dashboard/Tests/Unit/WidgetRegistryTest.php
Expand Up @@ -45,6 +45,7 @@ class WidgetRegistryTest extends UnitTestCase

public function setUp(): void
{
parent::setUp();
$this->beUserProphecy = $this->prophesize(BackendUserAuthentication::class);
$this->containerProphecy = $this->prophesize(ContainerInterface::class);

Expand Down
Expand Up @@ -53,6 +53,7 @@ class RecoveryServiceTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->userRepository = $this->prophesize(FrontendUserRepository::class);
$this->recoveryConfiguration = $this->prophesize(RecoveryConfiguration::class);
$this->templatePathsProphecy = $this->prophesize(TemplatePaths::class);
Expand Down
Expand Up @@ -44,6 +44,7 @@ class ProductionExceptionHandlerTest extends UnitTestCase
*/
protected function setUp(): void
{
parent::setUp();
$this->subject = new ProductionExceptionHandler(new Context(), new Random(), new NullLogger());
}

Expand Down
Expand Up @@ -31,6 +31,7 @@ class AddonRegistryTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = new AddonRegistry();
$this->registerAddons();
}
Expand Down
Expand Up @@ -31,6 +31,7 @@ class ModeRegistryTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->subject = new ModeRegistry();
}

Expand Down

0 comments on commit 6962acf

Please sign in to comment.