‪TYPO3CMS  ‪main
ValidatorResolverServiceTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
25 final class ‪ValidatorResolverServiceTest extends UnitTestCase
26 {
28 
33  {
34  $result = $this->subject->resolve([]);
35 
36  self::assertEmpty($result->current());
37  }
38 
43  public function ‪resolveShouldReturnValidators(array $config): void
44  {
45  $validators = $this->subject->resolve($config);
46 
47  foreach ($validators as $key => ‪$validator) {
48  $className = is_string($config[$key]) ? $config[$key] : $config[$key]['className'];
49 
50  self::assertInstanceOf($className, ‪$validator);
51  }
52  }
53 
54  public static function ‪validatorConfigDataProvider(): \Generator
55  {
56  return [
57  yield 'simple className' => ['config' => [NotEmptyValidator::class]],
58  yield 'with options' => [
59  'config' => [['className' => StringLengthValidator::class, 'options' => ['minimum' => 3]]],
60  ],
61  yield 'complex with both options and simple class names' => [
62  'config' => [NotEmptyValidator::class, ['className' => StringLengthValidator::class, 'options' => ['minimum' => 3]]],
63  ],
64  ];
65  }
66 
67  protected function ‪setUp(): void
68  {
69  $this->subject = new ‪ValidatorResolverService();
70 
71  parent::setUp();
72  }
73 }
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service\ValidatorResolverServiceTest\$subject
‪ValidatorResolverService $subject
Definition: ValidatorResolverServiceTest.php:27
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service\ValidatorResolverServiceTest\setUp
‪setUp()
Definition: ValidatorResolverServiceTest.php:67
‪TYPO3\CMS\Extbase\Validation\Validator\StringLengthValidator
Definition: StringLengthValidator.php:26
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service\ValidatorResolverServiceTest\validatorConfigDataProvider
‪static validatorConfigDataProvider()
Definition: ValidatorResolverServiceTest.php:54
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service\ValidatorResolverServiceTest\resolveShouldReturnValidators
‪resolveShouldReturnValidators(array $config)
Definition: ValidatorResolverServiceTest.php:43
‪$validator
‪if(isset($args['d'])) $validator
Definition: validateRstFiles.php:262
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service\ValidatorResolverServiceTest
Definition: ValidatorResolverServiceTest.php:26
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service\ValidatorResolverServiceTest\resolveShouldReturnEmptyArrayIfEmptyConfigurationIsPassed
‪resolveShouldReturnEmptyArrayIfEmptyConfigurationIsPassed()
Definition: ValidatorResolverServiceTest.php:32
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service
Definition: RecoveryServiceTest.php:18
‪TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator
Definition: NotEmptyValidator.php:24
‪TYPO3\CMS\FrontendLogin\Service\ValidatorResolverService
Definition: ValidatorResolverService.php:29