public function CtoolsModuleTestCase::testBreakPhrase in Chaos Tool Suite (ctools) 7
Test that the break phrase function behaves as expected.
File
- tests/
ctools.test, line 35 - Test classes for code in the CTools module file.
Class
- CtoolsModuleTestCase
- Test menu links depending on user permissions.
Code
public function testBreakPhrase() {
$tests = array(
NULL => array(
'value' => array(),
),
'' => array(
'value' => array(),
),
'1' => array(
'operator' => 'and',
'value' => array(
1,
),
),
'99' => array(
'operator' => 'and',
'value' => array(
99,
),
),
'+1' => array(
'invalid_input' => TRUE,
'value' => array(
-1,
),
),
' 1' => array(
'invalid_input' => TRUE,
'value' => array(
-1,
),
),
'1 ' => array(
'invalid_input' => TRUE,
'value' => array(
-1,
),
),
'-1' => array(
'invalid_input' => TRUE,
'value' => array(
-1,
),
),
'-99' => array(
'invalid_input' => TRUE,
'value' => array(
-1,
),
),
'1,2' => array(
'operator' => 'and',
'value' => array(
1,
2,
),
),
'1 2' => array(
'operator' => 'or',
'value' => array(
1,
2,
),
),
'1+2' => array(
'operator' => 'or',
'value' => array(
1,
2,
),
),
'1,2,3' => array(
'operator' => 'and',
'value' => array(
1,
2,
3,
),
),
'1 2 3' => array(
'operator' => 'or',
'value' => array(
1,
2,
3,
),
),
'1+2+3' => array(
'operator' => 'or',
'value' => array(
1,
2,
3,
),
),
'1 , 2 , 3' => array(
'invalid_input' => TRUE,
'value' => array(
-1,
),
),
'1 + 2 + 3' => array(
'invalid_input' => TRUE,
'value' => array(
-1,
),
),
'1,2,3,4,5,6,7,8,9' => array(
'operator' => 'and',
'value' => array(
1,
2,
3,
4,
5,
6,
7,
8,
9,
),
),
'1 2,3,4 5 6 7 8 9' => array(
'invalid_input' => TRUE,
'value' => array(
-1,
),
),
);
foreach ($tests as $string => $expected) {
$result = ctools_break_phrase($string);
$expected = (object) $expected;
$this
->assertEqual($result, $expected, 'Break Phrase test patterns: ' . $string);
}
}