Skip to content

Commit

Permalink
[TASK] Strictify UnitTests part 7
Browse files Browse the repository at this point in the history
The following core extensions are handled:

* EXT:impexp
* EXT:indexed_search

Resolves: #94893
Releases: master
Change-Id: I257d8ea33e1b4b7b04825dd92c443d0fb134293b
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70602
Tested-by: core-ci <typo3@b13.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
  • Loading branch information
wouter90 authored and tmotyl committed Sep 2, 2021
1 parent d0fadc6 commit a7b5d21
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract class AbstractImportExportTestCase extends FunctionalTestCase
*
* @var array
*/
protected $testFilesToDelete = [];
protected array $testFilesToDelete = [];

/**
* Set up for set up the backend user, initialize the language object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@

class PagesAndTtContentWithRelationsAndSoftrefsTest extends AbstractImportExportTestCase
{
/**
* @var array
*/
protected $coreExtensionsToLoad = [
'impexp', 'form'
];

/**
* @var array
*/
Expand Down
10 changes: 5 additions & 5 deletions typo3/sysext/impexp/Tests/Functional/ExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ExportTest extends AbstractImportExportTestCase
/**
* @var array
*/
protected $recordTypesIncludeFields =
protected array $recordTypesIncludeFields =
[
'pages' => [
'title',
Expand Down Expand Up @@ -93,11 +93,11 @@ public function creationAndDeletionOfTemporaryFolderSucceeds(): void
$temporaryFolderName = $this->exportMock->getOrCreateTemporaryFolderName();
$temporaryFileName = $temporaryFolderName . '/export_file.txt';
file_put_contents($temporaryFileName, 'Hello TYPO3 World.');
self::assertTrue(is_dir($temporaryFolderName));
self::assertDirectoryExists($temporaryFolderName);
self::assertTrue(is_file($temporaryFileName));

$this->exportMock->removeTemporaryFolderName();
self::assertFalse(is_dir($temporaryFolderName));
self::assertDirectoryDoesNotExist($temporaryFolderName);
self::assertFalse(is_file($temporaryFileName));
}

Expand All @@ -109,11 +109,11 @@ public function creationAndDeletionOfDefaultImportExportFolderSucceeds(): void
$exportFolder = $this->exportMock->getOrCreateDefaultImportExportFolder();
$exportFileName = 'export_file.txt';
$exportFolder->createFile($exportFileName);
self::assertTrue(is_dir(Environment::getPublicPath() . '/' . $exportFolder->getPublicUrl()));
self::assertDirectoryExists(Environment::getPublicPath() . '/' . $exportFolder->getPublicUrl());
self::assertTrue(is_file(Environment::getPublicPath() . '/' . $exportFolder->getPublicUrl() . $exportFileName));

$this->exportMock->removeDefaultImportExportFolder();
self::assertFalse(is_dir(Environment::getPublicPath() . '/' . $exportFolder->getPublicUrl()));
self::assertDirectoryDoesNotExist(Environment::getPublicPath() . '/' . $exportFolder->getPublicUrl());
self::assertFalse(is_file(Environment::getPublicPath() . '/' . $exportFolder->getPublicUrl() . $exportFileName));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@

class PagesAndTtContentWithImagesInEmptyDatabaseTest extends AbstractImportExportTestCase
{
/**
* @var array
*/
protected $coreExtensionsToLoad = [
'impexp', 'form'
];

/**
* @test
*/
Expand Down
2 changes: 2 additions & 0 deletions typo3/sysext/impexp/Tests/Functional/ImportExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@

namespace TYPO3\CMS\Impexp\Tests\Functional;

use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Impexp\Export;
use TYPO3\CMS\Impexp\Import;
use TYPO3\TestingFramework\Core\AccessibleObjectInterface;

class ImportExportTest extends AbstractImportExportTestCase
{
Expand Down
2 changes: 2 additions & 0 deletions typo3/sysext/impexp/Tests/Functional/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@

namespace TYPO3\CMS\Impexp\Tests\Functional;

use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Impexp\Exception\LoadingFileFailedException;
use TYPO3\CMS\Impexp\Import;
use TYPO3\TestingFramework\Core\AccessibleObjectInterface;

class ImportTest extends AbstractImportExportTestCase
{
Expand Down
10 changes: 6 additions & 4 deletions typo3/sysext/impexp/Tests/Unit/ExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function removeRedundantSoftRefsInRelationsProcessesOriginalRelationsArra
'',
false
);
$resourceFactoryMock->expects(self::any())->method('retrieveFileOrFolderObject')
$resourceFactoryMock->method('retrieveFileOrFolderObject')
->willReturnCallback(function ($relFileName) {
$fakeFileUidDerivedFromFileName = hexdec(substr(md5($relFileName), 0, 6));
$fileMock = $this->getAccessibleMock(
Expand Down Expand Up @@ -338,8 +338,10 @@ public function exportAddFilesFromRelationsSucceedsDataProvider(): array
];
$fullExpected = $fullDat;
$fullExpected['records']['tt_content:8']['rels']['pi_flexform']['flexFormRels']['softrefs'][0]['keys'][0][0]['file_ID'] = 'e580c5887dcea669332e96e25900b20b';
unset($fullExpected['records']['tt_content:8']['rels']['pi_flexform']['flexFormRels']['file'][0][0]['ID_absFile']);
unset($fullExpected['records']['tt_content:8']['rels']['background_image_options']['newValueFiles'][0]['ID_absFile']);
unset(
$fullExpected['records']['tt_content:8']['rels']['pi_flexform']['flexFormRels']['file'][0][0]['ID_absFile'],
$fullExpected['records']['tt_content:8']['rels']['background_image_options']['newValueFiles'][0]['ID_absFile']
);

return [
'Empty $this->dat' => ['dat' => [], 'expected' => []],
Expand All @@ -364,7 +366,7 @@ public function exportAddFilesFromRelationsSucceeds(array $dat, array $expected)
'',
false
);
$exportMock->expects(self::any())->method('isSoftRefIncluded')->willReturn(true);
$exportMock->method('isSoftRefIncluded')->willReturn(true);

$exportMock->_set('dat', $dat);
$exportMock->_call('exportAddFilesFromRelations');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LikeWildcardTest extends FunctionalTestCase
* @param string $expected
* @dataProvider getLikeQueryPartDataProvider
*/
public function getLikeQueryPart($tableName, $fieldName, $likeValue, $wildcard, $expected)
public function getLikeQueryPart(string $tableName, string $fieldName, string $likeValue, int $wildcard, string $expected): void
{
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($tableName);
$subject = LikeWildcard::cast($wildcard);
Expand All @@ -61,7 +61,7 @@ public function getLikeQueryPart($tableName, $fieldName, $likeValue, $wildcard,
*
* @return array
*/
public function getLikeQueryPartDataProvider()
public function getLikeQueryPartDataProvider(): array
{
return [
'no placeholders and no wildcard mode' => [
Expand Down
16 changes: 8 additions & 8 deletions typo3/sysext/indexed_search/Tests/Unit/IndexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function setUp(): void
/**
* @test
*/
public function extractHyperLinksDoesNotReturnNonExistingLocalPath()
public function extractHyperLinksDoesNotReturnNonExistingLocalPath(): void
{
$html = 'test <a href="' . StringUtility::getUniqueId() . '">test</a> test';
$subject = $this->getMockBuilder(Indexer::class)->disableOriginalConstructor()->addMethods(['dummy'])->getMock();
Expand All @@ -59,7 +59,7 @@ public function extractHyperLinksDoesNotReturnNonExistingLocalPath()
/**
* @test
*/
public function extractHyperLinksReturnsCorrectPathWithBaseUrl()
public function extractHyperLinksReturnsCorrectPathWithBaseUrl(): void
{
$baseURL = $GLOBALS['TYPO3_REQUEST']->getAttribute('normalizedParams')->getSiteUrl();
$html = 'test <a href="' . $baseURL . 'index.php">test</a> test';
Expand All @@ -72,7 +72,7 @@ public function extractHyperLinksReturnsCorrectPathWithBaseUrl()
/**
* @test
*/
public function extractHyperLinksFindsCorrectPathWithAbsolutePath()
public function extractHyperLinksFindsCorrectPathWithAbsolutePath(): void
{
$html = 'test <a href="index.php">test</a> test';
$subject = $this->getMockBuilder(Indexer::class)->disableOriginalConstructor()->addMethods(['dummy'])->getMock();
Expand All @@ -84,7 +84,7 @@ public function extractHyperLinksFindsCorrectPathWithAbsolutePath()
/**
* @test
*/
public function extractHyperLinksFindsCorrectPathForPathWithinTypo3Directory()
public function extractHyperLinksFindsCorrectPathForPathWithinTypo3Directory(): void
{
$html = 'test <a href="typo3/index.php">test</a> test';
$subject = $this->getMockBuilder(Indexer::class)->disableOriginalConstructor()->addMethods(['dummy'])->getMock();
Expand All @@ -96,7 +96,7 @@ public function extractHyperLinksFindsCorrectPathForPathWithinTypo3Directory()
/**
* @test
*/
public function extractHyperLinksFindsCorrectPathUsingAbsRefPrefix()
public function extractHyperLinksFindsCorrectPathUsingAbsRefPrefix(): void
{
$absRefPrefix = '/' . StringUtility::getUniqueId();
$html = 'test <a href="' . $absRefPrefix . 'index.php">test</a> test';
Expand All @@ -116,7 +116,7 @@ public function extractHyperLinksFindsCorrectPathUsingAbsRefPrefix()
/**
* @test
*/
public function extractBaseHrefExtractsBaseHref()
public function extractBaseHrefExtractsBaseHref(): void
{
$baseHref = 'http://example.com/';
$html = '<html><head><Base Href="' . $baseHref . '" /></head></html>';
Expand All @@ -130,7 +130,7 @@ public function extractBaseHrefExtractsBaseHref()
*
* @test
*/
public function typoSearchTagsRemovesBodyContentOutsideMarkers()
public function typoSearchTagsRemovesBodyContentOutsideMarkers(): void
{
$body = <<<EOT
<html>
Expand Down Expand Up @@ -174,7 +174,7 @@ public function typoSearchTagsRemovesBodyContentOutsideMarkers()
*
* @test
*/
public function typoSearchTagsHandlesMultipleMarkerPairs()
public function typoSearchTagsHandlesMultipleMarkerPairs(): void
{
$body = <<<EOT
<html>
Expand Down

0 comments on commit a7b5d21

Please sign in to comment.