TYPO3 CMS  TYPO3_6-2
StringUtilityTest.php
Go to the documentation of this file.
1 <?php
3 
23 
30  return array(
31  'match last part of string' => array('hello world', 'world'),
32  'match last char of string' => array('hellod world', 'd'),
33  'match whole string' => array('hello', 'hello'),
34  'integer is part of string with same number' => array('24', 24),
35  'string is part of integer with same number' => array(24, '24'),
36  'integer is part of string starting with same number' => array('please gimme beer, 24', 24)
37  );
38  }
39 
44  public function isLastPartOfStringReturnsTrueForMatchingFirstPart($string, $part) {
45  $this->assertTrue(\TYPO3\CMS\Core\Utility\StringUtility::isLastPartOfString($string, $part));
46  }
47 
54  return array(
55  'no string match' => array('hello', 'bye'),
56  'no case sensitive string match' => array('hello world', 'World'),
57  );
58  }
59 
65  $this->assertFalse(\TYPO3\CMS\Core\Utility\StringUtility::isLastPartOfString($string, $part));
66  }
67 
74  return array(
75  'array is not part of string' => array('string', array()),
76  'string is not part of array' => array(array(), 'string'),
77  'NULL is not part of string' => array('string', NULL),
78  'null is not part of array' => array(NULL, 'string'),
79  'NULL is not part of array' => array(array(), NULL),
80  'array is not part of null' => array(NULL, array()),
81  'NULL is not part of empty string' => array('', NULL),
82  'false is not part of empty string' => array('', FALSE),
83  'empty string is not part of NULL' => array(NULL, ''),
84  'empty string is not part of false' => array(FALSE, ''),
85  'empty string is not part of zero integer' => array(0, ''),
86  'zero integer is not part of NULL' => array(NULL, 0),
87  'zero integer is not part of empty string' => array('', 0),
88  'string is not part of object' => array(new \stdClass(), 'foo'),
89  'object is not part of string' => array('foo', new \stdClass()),
90  );
91  }
92 
99  $this->assertFalse(\TYPO3\CMS\Core\Utility\StringUtility::isLastPartOfString($string, $part));
100  }
101 }
static isLastPartOfString($haystack, $needle)