TYPO3 CMS  TYPO3_6-2
AlphabeticValidatorTest.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $helper;
26 
30  protected $subject;
31 
35  public function setUp() {
36  $this->helper = new \TYPO3\CMS\Form\Tests\Unit\Validation\Helper();
37  $this->subject = $this->getMock('TYPO3\\CMS\\Form\\Validation\\AlphabeticValidator', array('dummy'), array(), '', FALSE);
38  }
39 
44  return array(
45  'ascii without spaces' => array('thisismyinput'),
46  'accents without spaces' => array('éóéàèò'),
47  'umlauts without spaces' => array('üöä'),
48  'empty string' => array('')
49  );
50  }
51 
55  public function validDataProviderWithWhitespace() {
56  return array(
57  'ascii with spaces' => array('This is my input'),
58  'accents with spaces' => array('Sigur Rós'),
59  'umlauts with spaces' => array('Hürriyet Daily News'),
60  'space' => array(' '),
61  'empty string' => array('')
62  );
63  }
64 
69  return array(
70  'ascii with dash' => array('my-name'),
71  'accents with underscore' => array('Sigur_Rós'),
72  'umlauts with periods' => array('Hürriyet.Daily.News'),
73  'space' => array(' '),
74  );
75  }
76 
81  return array(
82  'ascii with spaces and dashes' => array('This is my-name'),
83  'accents with spaces and underscores' => array('Listen to Sigur_Rós_Band'),
84  'umlauts with spaces and periods' => array('Go get the Hürriyet.Daily.News')
85  );
86  }
87 
93  $requestHandlerMock = $this->helper->getRequestHandler(array(
94  'name' => $input
95  ));
96 
97  $this->subject->setFieldName('name');
98  $this->subject->injectRequestHandler($requestHandlerMock);
99 
100  $this->assertTrue(
101  $this->subject->isValid()
102  );
103  }
104 
110  $requestHandlerMock = $this->helper->getRequestHandler(array(
111  'name' => $input
112  ));
113 
114  $this->subject->setAllowWhiteSpace(TRUE);
115  $this->subject->setFieldName('name');
116  $this->subject->injectRequestHandler($requestHandlerMock);
117 
118  $this->assertTrue(
119  $this->subject->isValid()
120  );
121  }
122 
128  $requestHandlerMock = $this->helper->getRequestHandler(array(
129  'name' => $input
130  ));
131 
132  $this->subject->setFieldName('name');
133  $this->subject->injectRequestHandler($requestHandlerMock);
134 
135  $this->assertFalse(
136  $this->subject->isValid()
137  );
138  }
139 
145  $requestHandlerMock = $this->helper->getRequestHandler(array(
146  'name' => $input
147  ));
148 
149  $this->subject->setAllowWhiteSpace(TRUE);
150  $this->subject->setFieldName('name');
151  $this->subject->injectRequestHandler($requestHandlerMock);
152 
153  $this->assertFalse(
154  $this->subject->isValid()
155  );
156  }
157 }