コード例 #1
0
 public function testDoesNotBreakEntities()
 {
     $sample = '<p>Foo &gt; Bar</p>';
     $length = 2;
     $result = Truncator::truncate($sample, $length);
     $expectedResult = '<p>Foo…</p>';
     $this->assertSame($expectedResult, $result);
 }
コード例 #2
0
 public function testUnicodeDoesntBreakUsingCharacterLimit()
 {
     $sample = '<p>Ячмень пивоваренный. Ячмень пивоваренный, Ячмень пивоваренный; Ячмень пивоваренный.</p>';
     $expectedResult = '<p>Ячмень…</p>';
     $length = 19;
     $result = Truncator::truncate($sample, $length, array('length_in_chars' => true));
     $this->assertSame($expectedResult, $result);
     $expectedResult = '<p>Ячмень пивоваренный…</p>';
     $length = 20;
     $result = Truncator::truncate($sample, $length, array('length_in_chars' => true));
     $this->assertSame($expectedResult, $result);
     $length = 22;
     $result = Truncator::truncate($sample, $length, array('length_in_chars' => true));
     $this->assertSame($expectedResult, $result);
 }