[TASK] Streamline phpdoc annotations in EXT:extbase
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Validation / Validator / AbstractCompositeValidatorTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\Fixture\AbstractCompositeValidatorClass;
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19
20 /**
21 * Testcase for the abstract base-class of composite-validators
22 */
23 class AbstractCompositeValidatorTest extends UnitTestCase
24 {
25 /**
26 * @test
27 */
28 public function validatorAcceptsSupportedOptions()
29 {
30 $inputOptions = [
31 'requiredOption' => 666,
32 'demoOption' => 42
33 ];
34 $expectedOptions = $inputOptions;
35 $validator = $this->getAccessibleMock(AbstractCompositeValidatorClass::class, ['dummy'], [$inputOptions]);
36 $this->assertSame($expectedOptions, $validator->_get('options'));
37 }
38
39 /**
40 * @test
41 */
42 public function validatorHasDefaultOptions()
43 {
44 $inputOptions = ['requiredOption' => 666];
45 $expectedOptions = [
46 'requiredOption' => 666,
47 'demoOption' => PHP_INT_MAX
48 ];
49 $validator = $this->getAccessibleMock(AbstractCompositeValidatorClass::class, ['dummy'], [$inputOptions]);
50 $this->assertSame($expectedOptions, $validator->_get('options'));
51 }
52
53 /**
54 * @test
55 */
56 public function validatorThrowsExceptionOnNotSupportedOptions()
57 {
58 $inputOptions = ['invalidoption' => 42];
59 $this->expectException(\TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException::class);
60 $this->expectExceptionCode(1339079804);
61 $this->getAccessibleMock(AbstractCompositeValidatorClass::class, ['dummy'], [$inputOptions]);
62 }
63
64 /**
65 * @test
66 */
67 public function validatorThrowsExceptionOnMissingRequiredOptions()
68 {
69 $inputOptions = [];
70 $this->expectException(\TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException::class);
71 $this->expectExceptionCode(1339163922);
72 $this->getAccessibleMock(AbstractCompositeValidatorClass::class, ['dummy'], [$inputOptions]);
73 }
74 }