‪TYPO3CMS  10.4
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 
28 class ‪ValidatorResolverServiceTest extends UnitTestCase
29 {
33  protected ‪$subject;
34 
39  {
40  $result = $this->subject->resolve([]);
41 
42  self::assertEmpty($result->current());
43  }
44 
50  public function ‪resolveShouldReturnValidators(array $config): void
51  {
52  $validators = $this->subject->resolve($config);
53 
54  foreach ($validators as $key => ‪$validator) {
55  $className = is_string($config[$key]) ? $config[$key] : $config[$key]['className'];
56 
57  self::assertInstanceOf($className, ‪$validator);
58  }
59  }
60 
61  public function ‪validatorConfigDataProvider(): \Generator
62  {
63  return [
64  yield 'simple className' => ['config' => [NotEmptyValidator::class]],
65  yield 'with options' => [
66  'config' => [['className' => StringLengthValidator::class, 'options' => ['minimum' => 3]]],
67  ],
68  yield 'complex with both options and simple class names' => [
69  'config' => [NotEmptyValidator::class, ['className' => StringLengthValidator::class, 'options' => ['minimum' => 3]]],
70  ],
71  ];
72  }
73 
74  protected function ‪setUp(): void
75  {
76  $this->subject = new ‪ValidatorResolverService();
77 
78  parent::setUp();
79  }
80 }
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service\ValidatorResolverServiceTest\$subject
‪ValidatorResolverService $subject
Definition: ValidatorResolverServiceTest.php:32
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service\ValidatorResolverServiceTest\setUp
‪setUp()
Definition: ValidatorResolverServiceTest.php:73
‪TYPO3\CMS\Extbase\Validation\Validator\StringLengthValidator
Definition: StringLengthValidator.php:24
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service\ValidatorResolverServiceTest\resolveShouldReturnValidators
‪resolveShouldReturnValidators(array $config)
Definition: ValidatorResolverServiceTest.php:49
‪$validator
‪if(isset($args['d'])) $validator
Definition: validateRstFiles.php:218
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service\ValidatorResolverServiceTest
Definition: ValidatorResolverServiceTest.php:29
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service\ValidatorResolverServiceTest\resolveShouldReturnEmptyArrayIfEmptyConfigurationIsPassed
‪resolveShouldReturnEmptyArrayIfEmptyConfigurationIsPassed()
Definition: ValidatorResolverServiceTest.php:37
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service
Definition: RecoveryServiceTest.php:18
‪TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator
Definition: NotEmptyValidator.php:22
‪TYPO3\CMS\FrontendLogin\Service\ValidatorResolverService
Definition: ValidatorResolverService.php:28
‪TYPO3\CMS\FrontendLogin\Tests\Unit\Service\ValidatorResolverServiceTest\validatorConfigDataProvider
‪validatorConfigDataProvider()
Definition: ValidatorResolverServiceTest.php:60