‪TYPO3CMS  ‪main
CountValidatorTest.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 
20 use PHPUnit\Framework\Attributes\Test;
26 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
27 
28 final class ‪CountValidatorTest extends FunctionalTestCase
29 {
30  protected function ‪setUp(): void
31  {
32  parent::setUp();
33  ‪$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default');
34  $request = (new ‪ServerRequest())->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_BE);
35  ‪$GLOBALS['TYPO3_REQUEST'] = $request;
36  }
37 
38  #[Test]
40  {
41  $options = ['minimum' => 1, 'maximum' => 2];
43  ‪$validator->setOptions($options);
44  $input = [
45  'klaus',
46  'steve',
47  ];
48  self::assertFalse(‪$validator->validate($input)->hasErrors());
49  }
50 
51  #[Test]
53  {
54  $options = ['minimum' => 2, 'maximum' => 3];
56  ‪$validator->setOptions($options);
57  $input = [
58  'klaus',
59  'steve',
60  ];
61  self::assertFalse(‪$validator->validate($input)->hasErrors());
62  }
63 
64  #[Test]
66  {
67  $options = ['minimum' => 2, 'maximum' => 2];
69  ‪$validator->setOptions($options);
70  $input = [
71  'klaus',
72  'steve',
73  ];
74  self::assertFalse(‪$validator->validate($input)->hasErrors());
75  }
76 
77  #[Test]
79  {
80  $options = ['minimum' => 1, 'maximum' => 2];
82  ‪$validator->setOptions($options);
83  $input = [
84  'klaus',
85  'steve',
86  'francine',
87  ];
88  self::assertTrue(‪$validator->validate($input)->hasErrors());
89  }
90 
91  #[Test]
93  {
94  $options = ['minimum' => 2, 'maximum' => 3];
96  ‪$validator->setOptions($options);
97  $input = [
98  'klaus',
99  ];
100  self::assertTrue(‪$validator->validate($input)->hasErrors());
101  }
102 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Form\Tests\Functional\Mvc\Validation
Definition: CountValidatorTest.php:18
‪TYPO3\CMS\Form\Tests\Functional\Mvc\Validation\CountValidatorTest\setUp
‪setUp()
Definition: CountValidatorTest.php:30
‪TYPO3\CMS\Form\Tests\Functional\Mvc\Validation\CountValidatorTest\CountValidatorReturnsTrueIfInputCountHasLessItemsAsMinimumValue
‪CountValidatorReturnsTrueIfInputCountHasLessItemsAsMinimumValue()
Definition: CountValidatorTest.php:92
‪TYPO3\CMS\Form\Tests\Functional\Mvc\Validation\CountValidatorTest\CountValidatorReturnsFalseIfInputItemsCountIsEqualToMinimumAndMaximum
‪CountValidatorReturnsFalseIfInputItemsCountIsEqualToMinimumAndMaximum()
Definition: CountValidatorTest.php:65
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_BE
‪const REQUESTTYPE_BE
Definition: SystemEnvironmentBuilder.php:45
‪TYPO3\CMS\Form\Tests\Functional\Mvc\Validation\CountValidatorTest\CountValidatorReturnsFalseIfInputItemsCountIsEqualToMinimum
‪CountValidatorReturnsFalseIfInputItemsCountIsEqualToMinimum()
Definition: CountValidatorTest.php:52
‪TYPO3\CMS\Form\Mvc\Validation\CountValidator
Definition: CountValidator.php:33
‪$validator
‪if(isset($args['d'])) $validator
Definition: validateRstFiles.php:262
‪TYPO3\CMS\Form\Tests\Functional\Mvc\Validation\CountValidatorTest\CountValidatorReturnsFalseIfInputItemsCountIsEqualToMaximum
‪CountValidatorReturnsFalseIfInputItemsCountIsEqualToMaximum()
Definition: CountValidatorTest.php:39
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:39
‪TYPO3\CMS\Form\Tests\Functional\Mvc\Validation\CountValidatorTest
Definition: CountValidatorTest.php:29
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Form\Tests\Functional\Mvc\Validation\CountValidatorTest\CountValidatorReturnsTrueIfInputCountHasMoreItemsAsMaximumValue
‪CountValidatorReturnsTrueIfInputCountHasMoreItemsAsMaximumValue()
Definition: CountValidatorTest.php:78
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52