1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-13 00:34:11 +02:00

type cast in startsWith && endsWith, test cases for this behavior

This commit is contained in:
Stanislav Dobrovolskiy
2015-01-05 00:59:10 +02:00
parent d661047fb3
commit 9da55d5d4f
2 changed files with 8 additions and 2 deletions

View File

@@ -637,7 +637,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
$startOfStr = mb_strtolower($startOfStr, $this->encoding);
}
return $substring === $startOfStr;
return (string) $substring === $startOfStr;
}
/**
@@ -662,7 +662,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
$endOfStr = mb_strtolower($endOfStr, $this->encoding);
}
return $substring === $endOfStr;
return (string) $substring === $endOfStr;
}
/**

View File

@@ -1,5 +1,7 @@
<?php
use Stringy\Stringy;
abstract class CommonTest extends PHPUnit_Framework_TestCase
{
/**
@@ -752,6 +754,8 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
array('bar', 'foo bar', 'foo '),
array('foo bar', 'foo bar', 'oo'),
array('foo bar', 'foo bar', 'oo bar'),
array('oo bar', 'foo bar', Stringy::create('foo bar')->first(1), 'UTF-8'),
array('oo bar', 'foo bar', Stringy::create('foo bar')->at(0), 'UTF-8'),
array('fòô bàř', 'fòô bàř', '', 'UTF-8'),
array('òô bàř', 'fòô bàř', 'f', 'UTF-8'),
array('bàř', 'fòô bàř', 'fòô ', 'UTF-8'),
@@ -768,6 +772,8 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
array('foo', 'foo bar', ' bar'),
array('foo bar', 'foo bar', 'ba'),
array('foo bar', 'foo bar', 'foo ba'),
array('foo ba', 'foo bar', Stringy::create('foo bar')->last(1), 'UTF-8'),
array('foo ba', 'foo bar', Stringy::create('foo bar')->at(6), 'UTF-8'),
array('fòô bàř', 'fòô bàř', '', 'UTF-8'),
array('fòô bà', 'fòô bàř', 'ř', 'UTF-8'),
array('fòô', 'fòô bàř', ' bàř', 'UTF-8'),