public function TypogrifyClassTest::testAmpersandWrapping in Typogrify 8
Tests ampersand-wrapping.
File
- tests/
src/ Unit/ TypogrifyClassTest.php, line 23
Class
- TypogrifyClassTest
- Testing all methods on the Typogrify class and their interaction.
Namespace
Drupal\Tests\typogrify\UnitCode
public function testAmpersandWrapping() {
$before = 'John & Robert.';
$after = 'John <span class="amp">&</span> Robert.';
$this
->assertSame(Typogrify::amp($before), $after, 'Basic ampersand wrapping');
$before = 'P&T';
$after = 'P&T';
$this
->assertSame(Typogrify::amp($before), $after, "Don't mess with ampersands in words");
$before = 'advanced robotics & computing...';
$after = 'advanced robotics <span class="amp">&</span> computing...';
$this
->assertSame(Typogrify::amp($before), $after, 'One space as HTML entity.');
$before = 'advanced robotics & computing...';
$after = 'advanced robotics <span class="amp">&</span> computing...';
$this
->assertSame(Typogrify::amp($before), $after, 'Ampersand as HTML entity.');
$before = 'advanced robotics & computing...';
$after = 'advanced robotics <span class="amp">&</span> computing...';
$this
->assertSame(Typogrify::amp($before), $after, 'Both spaces and ampersand as HTML entities.');
$before = 'P&T had many clients, of which DD&T & Cronhammar, Kronhammer & Hjort were the largest';
$after = 'P&T had many clients, of which DD&T <span class="amp">&</span> Cronhammar, Kronhammer <span class="amp">&</span> Hjort were the largest';
$this
->assertSame(Typogrify::amp($before), $after, 'Both spaces and ampersand as HTML entities.');
}