You are here

function TypogrifyClassTestCase::testWidont in Typogrify 7

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

Widont test.

File

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

Class

TypogrifyClassTestCase
@file Unit tests for the basic typogrify functionality.

Code

function testWidont() {
  $before = 'A very simple test';
  $after = 'A very simple test';
  $this
    ->assertEqual(Typogrify::widont($before), $after, t('Basic widont. Once sentance, no HTML.'));

  // Single word items shouldn't be changed.
  $before = 'Test';
  $after = 'Test';
  $this
    ->assertEqual(Typogrify::widont($before), $after, t('Single word test #1'));
  $before = ' Test';
  $after = ' Test';
  $this
    ->assertEqual(Typogrify::widont($before), $after, t('Single word test #2'));
  $before = '<ul><li>Test</p></li><ul>';
  $after = '<ul><li>Test</p></li><ul>';
  $this
    ->assertEqual(Typogrify::widont($before), $after, t('Single word test #3'));
  $before = '<ul><li> Test</p></li><ul>';
  $after = '<ul><li> Test</p></li><ul>';
  $this
    ->assertEqual(Typogrify::widont($before), $after, t('Single word test #4'));
  $before = '<p>In a couple of paragraphs</p><p>paragraph two</p>';
  $after = '<p>In a couple of&nbsp;paragraphs</p><p>paragraph&nbsp;two</p>';
  $this
    ->assertEqual(Typogrify::widont($before), $after, t('Two paragraphs'));
  $before = '<h1><a href="#">In a link inside a heading</i> </a></h1>';
  $after = '<h1><a href="#">In a link inside a&nbsp;heading</i> </a></h1>';
  $this
    ->assertEqual(Typogrify::widont($before), $after, t('In a link inside a heading'));
  $before = '<h1><a href="#">In a link</a> followed by other text</h1>';
  $after = '<h1><a href="#">In a link</a> followed by other&nbsp;text</h1>';
  $this
    ->assertEqual(Typogrify::widont($before), $after, t('In a link followed by other text'));
  $before = '<h1><a href="#"></a></h1>';
  $after = '<h1><a href="#"></a></h1>';
  $this
    ->assertEqual(Typogrify::widont($before), $after, t("Empty HTML tags shouldn't cause errors"));
  $before = '<div>Divs get no love!</div>';
  $after = '<div>Divs get no love!</div>';
  $this
    ->assertEqual(Typogrify::widont($before), $after, t('Divs get no love'));
  $before = '<pre>Neither do PREs</pre>';
  $after = '<pre>Neither do PREs</pre>';
  $this
    ->assertEqual(Typogrify::widont($before), $after, t('Neither do PREs'));
  $before = '<div><p>But divs with paragraphs do!</p></div>';
  $after = '<div><p>But divs with paragraphs&nbsp;do!</p></div>';
  $this
    ->assertEqual(Typogrify::widont($before), $after, t('But divs with paragraphs do!'));
}