Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request zendframework/zendframework#1451 from Maks3w/hotfi…
Browse files Browse the repository at this point in the history
…x/ZF2-170

[ZF2-170][Filter] Fix trim for cyrillic characters.
  • Loading branch information
Freeaqingme committed Jun 6, 2012
5 parents 84670b1 + cccfba9 + 2717653 + b4dd364 + 2be531c commit 6dbeef6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/StringTrim.php
Expand Up @@ -123,6 +123,6 @@ protected function _unicodeTrim($value, $charlist = '\\\\s')
);

$pattern = '^[' . $chars . ']*|[' . $chars . ']*$';
return preg_replace("/$pattern/usSD", '', $value);
return preg_replace("/$pattern/sSD", '', $value);
}
}
30 changes: 18 additions & 12 deletions test/StringTrimTest.php
Expand Up @@ -22,7 +22,7 @@
namespace ZendTest\Filter;

use stdClass;
use Zend\Filter\StringTrim as StringTrimFilter;
use Zend\Filter\StringTrim;

/**
* @category Zend
Expand All @@ -35,20 +35,18 @@
class StringTrimTest extends \PHPUnit_Framework_TestCase
{
/**
* Zend_Filter_StringTrim object
*
* @var Zend_Filter_StringTrim
* @var StringTrim
*/
protected $_filter;

/**
* Creates a new Zend_Filter_StringTrim object for each test method
* Creates a new Zend\Filter\StringTrim object for each test method
*
* @return void
*/
public function setUp()
{
$this->_filter = new StringTrimFilter();
$this->_filter = new StringTrim();
}

/**
Expand Down Expand Up @@ -103,7 +101,7 @@ public function testCharList()
}

/**
* @ZF-7183
* @group ZF-7183
*/
public function testZF7183()
{
Expand All @@ -112,7 +110,17 @@ public function testZF7183()
}

/**
* @ZF-7902
* @group ZF2-170
*/
public function testZF2170()
{
$filter = $this->_filter;
$this->assertEquals('Расчет', $filter('Расчет'));
}


/**
* @group ZF-7902
*/
public function testZF7902()
{
Expand All @@ -121,7 +129,7 @@ public function testZF7902()
}

/**
* @ZF-10891
* @group ZF-10891
*/
public function testZF10891()
{
Expand All @@ -131,10 +139,8 @@ public function testZF10891()
$this->assertEquals('Зенд', $filter(' Зенд'));

$trim_charlist = " \t\n\r\x0B・。";
$filter = new StringTrimFilter($trim_charlist);
$filter = new StringTrim($trim_charlist);
$this->assertEquals('Зенд', $filter->filter('。 Зенд 。'));


}

public function getNonStringValues()
Expand Down

0 comments on commit 6dbeef6

Please sign in to comment.