Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions Classes/Core/Unit/UnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@ protected function tearDown(): void
$singletonInstances = GeneralUtility::getSingletonInstances();
// Reset singletons anyway to not let all further tests fail
GeneralUtility::resetSingletonInstances([]);
self::assertEmpty(
$singletonInstances,
'tearDown() integrity check found left over singleton instances in GeneralUtility::makeInstance()'
. ' instance list. The test should probably set \'$this->resetSingletonInstances = true;\' to'
. ' reset this framework state change. Found singletons: ' . implode(', ', array_keys($singletonInstances))
);
if (!empty($singletonInstances)) {
self::fail(
'tearDown() integrity check found left over singleton instances in GeneralUtility::makeInstance()'
. ' instance list. The test should probably set \'$this->resetSingletonInstances = true;\' to'
. ' reset this framework state change. Found singletons: ' . implode(', ', array_keys($singletonInstances))
);
}
}

// Delete registered test files and directories
Expand Down Expand Up @@ -175,18 +176,19 @@ protected function tearDown(): void
if (!empty($notCleanInstances)) {
// Reset instance list (including singletons & container) to not let all further tests fail
GeneralUtility::purgeInstances();
self::fail(
'tearDown() integrity check found left over instances in GeneralUtility::makeInstance() instance list.'
. ' Always consume instances added via GeneralUtility::addInstance() in your test by the test subject.'
. ' Found instances of these classes: ' . implode(', ', array_keys($notCleanInstances))
);
}
// Let the test fail if there were instances left and give some message on why it fails
self::assertEquals(
[],
$notCleanInstances,
'tearDown() integrity check found left over instances in GeneralUtility::makeInstance() instance list.'
. ' Always consume instances added via GeneralUtility::addInstance() in your test by the test subject.'
);

self::assertTrue($this->setUpMethodCallChainValid, 'tearDown() integrity check detected that setUp has a '
. 'broken parent call chain. Please check that setUp() methods properly calls parent::setUp(), starting from "'
. static::class . '"');
if ($this->setUpMethodCallChainValid === false) {
self::fail(
'tearDown() integrity check detected that setUp() has a broken parent call chain.'
. ' Please check that setUp() methods properly calls parent::setUp(), starting from "' . static::class . '"'
);
}

parent::tearDown();
}
Expand Down