Commit 21821f8d authored by Christian Kuhn's avatar Christian Kuhn Committed by Andreas Fernandez
Browse files

[TASK] Drop two unit tests that heavily rely on environment

* The file permission related LocalDriverTest basically test
  getPermissions() that is a set of native PHP methods that
  are hard to mock properly and don't need to be tested in
  our application.

* The DateViewHelperTest relies on a working locale which
  fails on some environments and gives no error output if
  it fails.

Resolves: #93400
Releases: master, 10.4, 9.5
Change-Id: I9521e8275d6a6461a902f07caee0444a73da8927
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67616

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 3c52d828
......@@ -17,8 +17,6 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource\Driver;
*/
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamContent;
use org\bovigo\vfs\vfsStreamWrapper;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Resource\Driver\LocalDriver;
use TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException;
......@@ -1058,79 +1056,6 @@ class LocalDriverTest extends BaseTestCase
$this->assertEquals(['r' => false, 'w' => false], $result);
}
/**
* Dataprovider for getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser test
*
* @return array group, filemode and expected result
*/
public function getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser_dataProvider(): array
{
$data = [];
// On some OS, the posix_* functions do not exist
if (function_exists('posix_getgid')) {
$data = [
'current group, readable/writable' => [
posix_getgid(),
48,
['r' => true, 'w' => true]
],
'current group, readable/not writable' => [
posix_getgid(),
32,
['r' => true, 'w' => false]
],
'current group, not readable/not writable' => [
posix_getgid(),
0,
['r' => false, 'w' => false]
]
];
}
$data = array_merge_recursive($data, [
'arbitrary group, readable/writable' => [
vfsStream::GROUP_USER_1,
6,
['r' => true, 'w' => true]
],
'arbitrary group, readable/not writable' => [
vfsStream::GROUP_USER_1,
436,
['r' => true, 'w' => false]
],
'arbitrary group, not readable/not writable' => [
vfsStream::GROUP_USER_1,
432,
['r' => false, 'w' => false]
]
]);
return $data;
}
/**
* @test
* @dataProvider getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser_dataProvider
* @param int $group
* @param int $permissions
* @param array $expectedResult
*/
public function getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser(int $group, int $permissions, array $expectedResult): void
{
if (Environment::isWindows()) {
$this->markTestSkipped('Test skipped if run on Windows system');
}
$this->addToMount([
'testfile' => 'asdfg'
]);
$subject = $this->createDriver();
/** @var $fileObject vfsStreamContent */
$fileObject = vfsStreamWrapper::getRoot()->getChild($this->mountDir)->getChild('testfile');
// just use an "arbitrary" user here - it is only important that
$fileObject->chown(vfsStream::OWNER_USER_1);
$fileObject->chgrp($group);
$fileObject->chmod($permissions);
$this->assertEquals($expectedResult, $subject->getPermissions('/testfile'));
}
/**
* @test
*/
......
......@@ -432,53 +432,4 @@ class DateViewHelperTest extends ViewHelperBaseTestcase
$actualResult = $this->viewHelper->initializeArgumentsAndRender();
$this->assertEquals($expected, $actualResult);
}
/**
* Data provider for dateViewHelperFormatsDateLocalizedDataProvider
*
* @return array
*/
public function dateViewHelperFormatsDateLocalizedDataProvider()
{
return [
'de_DE.UTF-8' => [
'de_DE.UTF-8',
'03. Februar 2013'
],
'en_ZW.utf8' => [
'en_ZW.utf8',
'03. February 2013'
]
];
}
/**
* @dataProvider dateViewHelperFormatsDateLocalizedDataProvider
*
* @test
*/
public function dateViewHelperFormatsDateLocalized($locale, $expected)
{
$format = '%d. %B %Y';
// 2013-02-03 11:40 UTC
$timestamp = '@1359891658';
try {
$this->setLocale(LC_COLLATE, $locale);
$this->setLocale(LC_CTYPE, $locale);
$this->setLocale(LC_MONETARY, $locale);
$this->setLocale(LC_TIME, $locale);
} catch (\PHPUnit\Framework\Exception $e) {
$this->markTestSkipped('Locale ' . $locale . ' is not available.');
}
$this->setArgumentsUnderTest(
$this->viewHelper,
[
'date' => $timestamp,
'format' => $format
]
);
$actualResult = $this->viewHelper->initializeArgumentsAndRender();
$this->assertEquals($expected, $actualResult);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment