Loading core/modules/views/src/Plugin/views/argument_validator/None.php +1 −1 Changes for core/modules/views/src/Plugin/views/argument_validator/None.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ public function validateArgument($argument) { return FALSE; } if (!empty($this->argument->definition['numeric']) && !isset($this->argument->options['break_phrase'])) { if (!empty($this->argument->definition['numeric']) && !isset($this->argument->options['break_phrase']) && !is_numeric($argument)) { return FALSE; } Loading core/modules/views/tests/src/Unit/Plugin/argument_validator/NoneTest.php 0 → 100644 +42 −0 Changes for core/modules/views/tests/src/Unit/Plugin/argument_validator/NoneTest.php: 42 added lines, 0 removed lines. Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\Tests\views\Unit\Plugin\argument_validator; use Drupal\Tests\UnitTestCase; use Drupal\views\Plugin\views\argument\Standard; use Drupal\views\Plugin\views\argument_validator\None; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\TestWith; /** * Tests the None argument validator. */ #[CoversClass(None::class)] #[Group('views')] class NoneTest extends UnitTestCase { /** * Tests validation of the None argument. */ #[TestWith([TRUE, 3, ['numeric' => TRUE], []], 'numeric value')] #[TestWith([FALSE, 'string', ['numeric' => TRUE], []], 'nonnumeric value')] #[TestWith([TRUE, 'string', ['numeric' => TRUE], ['break_phrase' => TRUE]], 'break phrase bypass')] #[TestWith([TRUE, 'string', ['numeric' => TRUE], ['break_phrase' => FALSE]], 'false break phrase bypass')] #[TestWith([FALSE, NULL, [], []], 'null argument')] #[TestWith([FALSE, '', [], []], 'empty argument')] #[TestWith([TRUE, NULL, [], ['must_not_be' => TRUE]], 'must not be with null')] #[TestWith([FALSE, '', [], ['must_not_be' => TRUE]], 'must not be with empty string')] public function testValidateNone(bool $expected, mixed $argument, array $definition, array $options): void { $argument_handler = new Standard([], 'standard', []); $argument_handler->definition = $definition; $argument_handler->options = $options; $validator = new None([], 'none_test', []); $validator->setArgument($argument_handler); $this->assertSame($expected, $validator->validateArgument($argument)); } } Loading
core/modules/views/src/Plugin/views/argument_validator/None.php +1 −1 Changes for core/modules/views/src/Plugin/views/argument_validator/None.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ public function validateArgument($argument) { return FALSE; } if (!empty($this->argument->definition['numeric']) && !isset($this->argument->options['break_phrase'])) { if (!empty($this->argument->definition['numeric']) && !isset($this->argument->options['break_phrase']) && !is_numeric($argument)) { return FALSE; } Loading
core/modules/views/tests/src/Unit/Plugin/argument_validator/NoneTest.php 0 → 100644 +42 −0 Changes for core/modules/views/tests/src/Unit/Plugin/argument_validator/NoneTest.php: 42 added lines, 0 removed lines. Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\Tests\views\Unit\Plugin\argument_validator; use Drupal\Tests\UnitTestCase; use Drupal\views\Plugin\views\argument\Standard; use Drupal\views\Plugin\views\argument_validator\None; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\TestWith; /** * Tests the None argument validator. */ #[CoversClass(None::class)] #[Group('views')] class NoneTest extends UnitTestCase { /** * Tests validation of the None argument. */ #[TestWith([TRUE, 3, ['numeric' => TRUE], []], 'numeric value')] #[TestWith([FALSE, 'string', ['numeric' => TRUE], []], 'nonnumeric value')] #[TestWith([TRUE, 'string', ['numeric' => TRUE], ['break_phrase' => TRUE]], 'break phrase bypass')] #[TestWith([TRUE, 'string', ['numeric' => TRUE], ['break_phrase' => FALSE]], 'false break phrase bypass')] #[TestWith([FALSE, NULL, [], []], 'null argument')] #[TestWith([FALSE, '', [], []], 'empty argument')] #[TestWith([TRUE, NULL, [], ['must_not_be' => TRUE]], 'must not be with null')] #[TestWith([FALSE, '', [], ['must_not_be' => TRUE]], 'must not be with empty string')] public function testValidateNone(bool $expected, mixed $argument, array $definition, array $options): void { $argument_handler = new Standard([], 'standard', []); $argument_handler->definition = $definition; $argument_handler->options = $options; $validator = new None([], 'none_test', []); $validator->setArgument($argument_handler); $this->assertSame($expected, $validator->validateArgument($argument)); } }