From 7783b944cba8000c19be704862e8ff1c164da11e Mon Sep 17 00:00:00 2001 From: Martin Eiber Date: Fri, 22 Nov 2024 11:43:42 +0100 Subject: [PATCH 1/2] Trim Filter Value. --- .../Filter/SimpleColumnFilter.php | 4 ++ .../Filter/SimpleColumnFilterTest.php | 37 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/Unit/MappedParameter/Filter/SimpleColumnFilterTest.php diff --git a/src/MappedParameter/Filter/SimpleColumnFilter.php b/src/MappedParameter/Filter/SimpleColumnFilter.php index 05ceea10..1d16435c 100644 --- a/src/MappedParameter/Filter/SimpleColumnFilter.php +++ b/src/MappedParameter/Filter/SimpleColumnFilter.php @@ -34,6 +34,10 @@ public function getType(): string public function getFilterValue(): mixed { + if (is_string($this->filterValue)) { + return trim($this->filterValue); + } + return $this->filterValue; } } diff --git a/tests/Unit/MappedParameter/Filter/SimpleColumnFilterTest.php b/tests/Unit/MappedParameter/Filter/SimpleColumnFilterTest.php new file mode 100644 index 00000000..733d8e6e --- /dev/null +++ b/tests/Unit/MappedParameter/Filter/SimpleColumnFilterTest.php @@ -0,0 +1,37 @@ +assertSame('value', $filter->getFilterValue()); + } + + public function testGetFilterValue(): void + { + $filter = new SimpleColumnFilter('type', ['value']); + + $this->assertSame(['value'], $filter->getFilterValue()); + } +} \ No newline at end of file From 2574784970bdb9af9fd11286c00adb4802c13fb9 Mon Sep 17 00:00:00 2001 From: martineiber Date: Fri, 22 Nov 2024 10:44:46 +0000 Subject: [PATCH 2/2] Apply php-cs-fixer changes --- src/MappedParameter/Filter/SimpleColumnFilter.php | 2 ++ .../MappedParameter/Filter/SimpleColumnFilterTest.php | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/MappedParameter/Filter/SimpleColumnFilter.php b/src/MappedParameter/Filter/SimpleColumnFilter.php index 1d16435c..ecaac76c 100644 --- a/src/MappedParameter/Filter/SimpleColumnFilter.php +++ b/src/MappedParameter/Filter/SimpleColumnFilter.php @@ -16,6 +16,8 @@ namespace Pimcore\Bundle\StudioBackendBundle\MappedParameter\Filter; +use function is_string; + /** * @internal */ diff --git a/tests/Unit/MappedParameter/Filter/SimpleColumnFilterTest.php b/tests/Unit/MappedParameter/Filter/SimpleColumnFilterTest.php index 733d8e6e..00957b58 100644 --- a/tests/Unit/MappedParameter/Filter/SimpleColumnFilterTest.php +++ b/tests/Unit/MappedParameter/Filter/SimpleColumnFilterTest.php @@ -4,11 +4,14 @@ /** * Pimcore * - * This source file is available under following license: + * This source file is available under two different licenses: + * - GNU General Public License version 3 (GPLv3) * - Pimcore Commercial License (PCL) + * Full copyright and license information is available in + * LICENSE.md which is distributed with this source code. * - * @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) - * @license http://www.pimcore.org/license PCL + * @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) + * @license http://www.pimcore.org/license GPLv3 and PCL */ namespace Pimcore\Bundle\StudioBackendBundle\Tests\Unit\MappedParameter\Filter; @@ -34,4 +37,4 @@ public function testGetFilterValue(): void $this->assertSame(['value'], $filter->getFilterValue()); } -} \ No newline at end of file +}