You are here

function TypogrifyClassTestCase::testAmpersandWrapping in Typogrify 6

Same name and namespace in other branches
  1. 7 tests/typogrify.class.test \TypogrifyClassTestCase::testAmpersandWrapping()

File

tests/typogrify.class.test, line 28
typogrify.class.test Unit tests for the basic typogrify functionality.

Class

TypogrifyClassTestCase
@file typogrify.class.test Unit tests for the basic typogrify functionality.

Code

function testAmpersandWrapping() {
  $before = 'John & Robert.';
  $after = 'John <span class="amp">&amp;</span> Robert.';
  $this
    ->assertEqual(Typogrify::amp($before), $after, t('Basic ampersand wrapping'));
  $before = 'P&T';
  $after = 'P&T';
  $this
    ->assertEqual(Typogrify::amp($before), $after, t("Don't mess with ampersands in words"));
  $before = 'advanced robotics &&nbsp;computing...';
  $after = 'advanced robotics <span class="amp">&amp;</span>&nbsp;computing...';
  $this
    ->assertEqual(Typogrify::amp($before), $after, t("One space as HTML entitiy."));
  $before = 'advanced robotics &amp; computing...';
  $after = 'advanced robotics <span class="amp">&amp;</span> computing...';
  $this
    ->assertEqual(Typogrify::amp($before), $after, t("Ampersand as HTML entitiy."));
  $before = 'advanced robotics&nbsp;&amp;&nbsp;computing...';
  $after = 'advanced robotics&nbsp;<span class="amp">&amp;</span>&nbsp;computing...';
  $this
    ->assertEqual(Typogrify::amp($before), $after, t("Both spaces and ampersand as HTML entities."));
  $before = 'P&amp;T had many clients, of which DD&T &amp; Cronhammar, Kronhammer & Hjort were the largest';
  $after = 'P&amp;T had many clients, of which DD&T <span class="amp">&amp;</span> Cronhammar, Kronhammer <span class="amp">&amp;</span> Hjort were the largest';
  $this
    ->assertEqual(Typogrify::amp($before), $after, t("Both spaces and ampersand as HTML entities."));
}