public function testDoesNotBreakEntities() { $sample = '<p>Foo > Bar</p>'; $length = 2; $result = Truncator::truncate($sample, $length); $expectedResult = '<p>Foo…</p>'; $this->assertSame($expectedResult, $result); }
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); }