mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Fix utils::EndsWith when needle bigger that value
This commit is contained in:
@@ -2097,6 +2097,11 @@ class utils
|
||||
* @return bool
|
||||
*/
|
||||
final public static function EndsWith($haystack, $needle) {
|
||||
if (strlen($needle) > strlen($haystack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,11 @@ class UtilsTest extends \Combodo\iTop\Test\UnitTest\ItopTestCase
|
||||
require_once(APPROOT.'application/utils.inc.php');
|
||||
}
|
||||
|
||||
public function testEndsWith()
|
||||
{
|
||||
$this->assertFalse(utils::EndsWith('a', 'bbbb'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider memoryLimitDataProvider
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user