Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Add tests for DataHandler->applyFiltersToValues
This adds missing tests for the TCA "filter" option for group, select and inline. Resolves: #96339 Related: #36810 Releases: main, 11.5 Change-Id: I402edf4774f35c3b15aa53eb630d9d098f847e87 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72636 Tested-by: core-ci <typo3@b13.com> Tested-by: Stefan Bürk <stefan@buerk.tech> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Benni Mack <benni@typo3.org>
- Loading branch information
Showing
3 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
typo3/sysext/core/Tests/Unit/DataHandling/Fixtures/UserOddNumberFilter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace TYPO3\CMS\Core\Tests\Unit\DataHandling\Fixtures; | ||
|
||
use TYPO3\CMS\Core\DataHandling\DataHandler; | ||
|
||
class UserOddNumberFilter | ||
{ | ||
public function filter(array $parameters, DataHandler $dataHandler) | ||
{ | ||
if ($parameters['break'] ?? false) { | ||
return null; | ||
} | ||
$values = $parameters['values']; | ||
$values = array_filter($values, static fn ($number) => $number % 2 !== 0); | ||
if (isset($parameters['exclude'])) { | ||
$values = array_filter($values, static fn ($number) => $number !== $parameters['exclude']); | ||
} | ||
return $values; | ||
} | ||
} |