2 namespace TYPO3\CMS\Form\Tests\Unit\Validation
;
4 /***************************************************************
7 * (c) 2012 Andreas Lappe <a.lappe@kuehlhaus.com>, kuehlhaus AG
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
29 * Test case for class \TYPO3\CMS\Form\System\Validation\AlphabeticValidator.
31 * @author Andreas Lappe <a.lappe@kuehlhaus.com>
35 class AlphabeticValidatorTest
extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase
{
37 * @var \TYPO3\CMS\Form\Tests\Unit\Validation\Helper
42 * @var \TYPO3\CMS\Form\Validation\AlphabeticValidator
46 public function setUp() {
47 $this->helper
= new \TYPO3\CMS\Form\Tests\Unit\Validation\
Helper();
48 $this->fixture
= new \TYPO3\CMS\Form\Validation\
AlphabeticValidator();
51 public function tearDown() {
52 unset($this->helper
, $this->fixture
);
55 public function validDataProviderWithoutWhitespace() {
57 'ascii without spaces' => array('thisismyinput'),
58 'accents without spaces' => array('éóéàèò'),
59 'umlauts without spaces' => array('üöä'),
60 'empty string' => array('')
64 public function validDataProviderWithWhitespace() {
66 'ascii with spaces' => array('This is my input'),
67 'accents with spaces' => array('Sigur Rós'),
68 'umlauts with spaces' => array('Hürriyet Daily News'),
69 'space' => array(' '),
70 'empty string' => array('')
74 public function invalidDataProviderWithoutWhitespace() {
76 'ascii with dash' => array('my-name'),
77 'accents with underscore' => array('Sigur_Rós'),
78 'umlauts with periods' => array('Hürriyet.Daily.News'),
79 'space' => array(' '),
83 public function invalidDataProviderWithWhitespace() {
85 'ascii with spaces and dashes' => array('This is my-name'),
86 'accents with spaces and underscores' => array('Listen to Sigur_Rós_Band'),
87 'umlauts with spaces and periods' => array('Go get the Hürriyet.Daily.News')
93 * @dataProvider validDataProviderWithoutWhitespace
95 public function isValidForValidInputWithoutAllowedWhitespaceReturnsTrue($input) {
96 $requestHandlerMock = $this->helper
->getRequestHandler(array(
100 $this->fixture
->setFieldName('name');
101 $this->fixture
->injectRequestHandler($requestHandlerMock);
104 $this->fixture
->isValid()
110 * @dataProvider validDataProviderWithWhitespace
112 public function isValidForValidInputWithWhitespaceAllowedReturnsTrue($input) {
113 $requestHandlerMock = $this->helper
->getRequestHandler(array(
117 $this->fixture
->setAllowWhiteSpace(TRUE);
118 $this->fixture
->setFieldName('name');
119 $this->fixture
->injectRequestHandler($requestHandlerMock);
122 $this->fixture
->isValid()
128 * @dataProvider invalidDataProviderWithoutWhitespace
130 public function isValidForInvalidInputWithoutAllowedWhitespaceReturnsFalse($input) {
131 $requestHandlerMock = $this->helper
->getRequestHandler(array(
135 $this->fixture
->setFieldName('name');
136 $this->fixture
->injectRequestHandler($requestHandlerMock);
139 $this->fixture
->isValid()
145 * @dataProvider invalidDataProviderWithWhitespace
147 public function isValidForInvalidInputWithWhitespaceAllowedReturnsFalse($input) {
148 $requestHandlerMock = $this->helper
->getRequestHandler(array(
152 $this->fixture
->setAllowWhiteSpace(TRUE);
153 $this->fixture
->setFieldName('name');
154 $this->fixture
->injectRequestHandler($requestHandlerMock);
157 $this->fixture
->isValid()