Typography = new TypographyHelper(new View(null)); } /** * TearDown method * * @return void */ public function tearDown(): void { unset($this->Typography); parent::tearDown(); } /** * TestFormatCharacter method * * @return void */ public function testFormatCharacter() { $strs = [ '"double quotes"' => '“double quotes”', '"testing" in "theory" that is' => '“testing” in “theory” that is', "Here's what I'm" => 'Here’s what I’m', '&' => '&', '&' => '&', ' ' => ' ', '--' => '—', 'foo...' => 'foo…', 'foo..' => 'foo..', 'foo...bar.' => 'foo…bar.', 'test. new' => 'test. new', ]; foreach ($strs as $str => $expected) { $result = $this->Typography->formatCharacters($str); //debug($result); $this->assertEquals($expected, $result); } Configure::write('Typography.locale', 'low'); $strs = [ '"double quotes"' => '„double quotes‟', '"testing" in "theory" that is' => '„testing‟ in „theory‟ that is', "Here's what I'm" => 'Here’s what I’m', ]; foreach ($strs as $str => $expected) { $result = $this->Typography->formatCharacters($str); //echo pre($result); $this->assertEquals($expected, $result); } Configure::write('Typography.locale', 'angle'); $strs = [ '"double quotes"' => '«double quotes»', '"testing" in "theory" that is' => '«testing» in «theory» that is', "Here's what I'm" => 'Here’s what I’m', ]; foreach ($strs as $str => $expected) { $result = $this->Typography->formatCharacters($str); //echo debug($result); $this->assertEquals($expected, $result); } } /** * TestAutoTypography method * * @return void */ public function testAutoTypography() { $str = 'Some \'funny\' and "funky" test'; $result = $this->Typography->autoTypography($str); //echo pre($result); $expected = '
Some ‘funny’ and “funky” test
'; $this->assertEquals($expected, $result); Configure::write('App.language', 'deu'); $result = $this->Typography->autoTypography($str); //echo pre($result); $expected = 'Some ‚funny‛ and „funky‟ test
'; $this->assertEquals($expected, $result); Configure::write('App.language', 'fra'); $result = $this->Typography->autoTypography($str); //echo debug($result); $expected = 'Some ‹funny› and «funky» test
'; $this->assertEquals($expected, $result); } /** * TestNl2brExceptPre method * * @return void */ public function testNl2brExceptPre() { $str = <<I am inside a pre tag. Please don't mess with me. k?