Skip to content
Snippets Groups Projects
Commit 57d0ae78 authored by Christian Kuhn's avatar Christian Kuhn Committed by Tymoteusz Motylewski
Browse files

[TASK] Unit test DataHandler->clearPrefixFromValue()

Add a unit test to support the change from issue #83870.

Change-Id: Ic8a1006c56989a1aa2ef2734e1320447875f1138
Resolves: #83909
Related: #83870
Releases: master
Reviewed-on: https://review.typo3.org/55727


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarTymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: default avatarTymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: default avatarFrank Naegler <frank.naegler@typo3.org>
Tested-by: default avatarFrank Naegler <frank.naegler@typo3.org>
parent d6b54539
No related merge requests found
......@@ -908,4 +908,37 @@ class DataHandlerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
],
];
}
/**
* @return array
*/
public function clearPrefixFromValueRemovesPrefixDataProvider(): array
{
return [
'normal case' => ['Test (copy 42)', 'Test'],
// all cases below look fishy and indicate bugs
'with double spaces before' => ['Test (copy 42)', 'Test '],
'with three spaces before' => ['Test (copy 42)', 'Test '],
'with space after' => ['Test (copy 42) ', 'Test (copy 42) '],
'with double spaces after' => ['Test (copy 42) ', 'Test (copy 42) '],
'with three spaces after' => ['Test (copy 42) ', 'Test (copy 42) '],
'with double tab before' => ['Test' . chr(9) . '(copy 42)', 'Test'],
'with double tab after' => ['Test (copy 42)' . chr(9), 'Test (copy 42)' . chr(9)],
];
}
/**
* @test
* @dataProvider clearPrefixFromValueRemovesPrefixDataProvider
* @param string $input
* @param string $expected
*/
public function clearPrefixFromValueRemovesPrefix(string $input, string $expected)
{
$languageServiceProphecy = $this->prophesize(\TYPO3\CMS\Core\Localization\LanguageService::class);
$languageServiceProphecy->sL('testLabel')->willReturn('(copy %s)');
$GLOBALS['LANG'] = $languageServiceProphecy->reveal();
$GLOBALS['TCA']['testTable']['ctrl']['prependAtCopy'] = 'testLabel';
$this->assertEquals($expected, (new DataHandler())->clearPrefixFromValue('testTable', $input));
}
}
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