[CLEANUP] Rework/simplify copyright header and remove @package
[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 /**
18 * Testcase for the abstract base-class of composite-validators
19 *
20 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
21 */
22 class AbstractCompositeValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
23
24 /**
25 * @test
26 */
27 public function validatorAcceptsSupportedOptions() {
28 $inputOptions = array(
29 'requiredOption' => 666,
30 'demoOption' => 42
31 );
32 $expectedOptions = $inputOptions;
33 $validator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractCompositeValidatorClass', array('dummy'), array($inputOptions));
34 $this->assertSame($expectedOptions, $validator->_get('options'));
35 }
36
37 /**
38 * @test
39 */
40 public function validatorHasDefaultOptions() {
41 $inputOptions = array('requiredOption' => 666);
42 $expectedOptions = array(
43 'requiredOption' => 666,
44 'demoOption' => PHP_INT_MAX
45 );
46 $validator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractCompositeValidatorClass', array('dummy'), array($inputOptions));
47 $this->assertSame($expectedOptions, $validator->_get('options'));
48 }
49
50 /**
51 * @test
52 */
53 public function validatorThrowsExceptionOnNotSupportedOptions() {
54 $inputOptions = array('invalidoption' => 42);
55 $this->setExpectedException('TYPO3\\CMS\\Extbase\\Validation\\Exception\\InvalidValidationOptionsException', '', 1339079804);
56 $validator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractCompositeValidatorClass', array('dummy'), array($inputOptions));
57 }
58
59
60 /**
61 * @test
62 */
63 public function validatorThrowsExceptionOnMissingRequiredOptions() {
64 $inputOptions = array();
65 $this->setExpectedException('TYPO3\\CMS\\Extbase\\Validation\\Exception\\InvalidValidationOptionsException', '', 1339163922);
66 $validator = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Validation\\Validator\\Fixture\\AbstractCompositeValidatorClass', array('dummy'), array($inputOptions));
67 }
68
69 }
70
71 ?>