You are here

private function SmileyFilterWebTestCase::CheckSmileysWereReplaced in Smiley 7

Checks the $original_text converting to a $expected_text correctly.

1 call to SmileyFilterWebTestCase::CheckSmileysWereReplaced()
SmileyFilterWebTestCase::runTests in ./smiley.test

File

./smiley.test, line 45
Tests for Smiley module.

Class

SmileyFilterWebTestCase
Web test for smiley module to test the main regex expression for all possible situations to make sure it always works properly.

Code

private function CheckSmileysWereReplaced($original_text, $expected_text, $smileys) {

  // Small improvement to ease testing.
  $expected_text = str_replace("SMILE", "<img[^>]+>", preg_quote($expected_text));

  // Run the filter.
  $new_text = smiley_process_text($original_text, $smileys);

  // Find was all smiles was replaced on <img src=... />?
  $match = preg_match("#" . $expected_text . "#", $new_text);

  // Check it and display a message.
  $this
    ->assertTrue($match, t('All smileys were replaced correctly. Pattern: "@pattern"', array(
    '@pattern' => $original_text,
  )));
}