‪TYPO3CMS  10.4
AbstractValidatorTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
25 class ‪AbstractValidatorTest extends UnitTestCase
26 {
30  public function ‪validatorAcceptsSupportedOptions(): void
31  {
32  $inputOptions = [
33  'requiredOption' => 666,
34  'demoOption' => 42
35  ];
36  $expectedOptions = $inputOptions;
37  ‪$validator = new ‪AbstractValidatorClass($inputOptions);
38  self::assertSame($expectedOptions, ‪$validator->getOptions());
39  }
40 
44  public function ‪validatorHasDefaultOptions(): void
45  {
46  $inputOptions = ['requiredOption' => 666];
47  $expectedOptions = [
48  'requiredOption' => 666,
49  'demoOption' => PHP_INT_MAX
50  ];
51  ‪$validator = new ‪AbstractValidatorClass($inputOptions);
52  self::assertSame($expectedOptions, ‪$validator->getOptions());
53  }
54 
59  {
60  $inputOptions = ['invalidoption' => 42];
61  $this->expectException(InvalidValidationOptionsException::class);
62  $this->expectExceptionCode(1379981890);
63  new ‪AbstractValidatorClass($inputOptions);
64  }
65 
70  {
71  $inputOptions = [];
72  $this->expectException(InvalidValidationOptionsException::class);
73  $this->expectExceptionCode(1379981891);
74  new ‪AbstractValidatorClass($inputOptions);
75  }
76 }
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\Fixture\AbstractValidatorClass
Definition: AbstractValidatorClass.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\AbstractValidatorTest\validatorThrowsExceptionOnNotSupportedOptions
‪validatorThrowsExceptionOnNotSupportedOptions()
Definition: AbstractValidatorTest.php:58
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\AbstractValidatorTest
Definition: AbstractValidatorTest.php:26
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\AbstractValidatorTest\validatorHasDefaultOptions
‪validatorHasDefaultOptions()
Definition: AbstractValidatorTest.php:44
‪$validator
‪if(isset($args['d'])) $validator
Definition: validateRstFiles.php:218
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\AbstractValidatorTest\validatorAcceptsSupportedOptions
‪validatorAcceptsSupportedOptions()
Definition: AbstractValidatorTest.php:30
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator
Definition: AbstractCompositeValidatorTest.php:16
‪TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\AbstractValidatorTest\validatorThrowsExceptionOnMissingRequiredOptions
‪validatorThrowsExceptionOnMissingRequiredOptions()
Definition: AbstractValidatorTest.php:69
‪TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException
Definition: InvalidValidationOptionsException.php:26