You are here

public function SmileyFilterWebTestCase::testImageSrc in Smiley 7

Make sure the <img> element contains the right src value.

File

./smiley.test, line 59
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

public function testImageSrc() {
  $smileys = array(
    (object) array(
      'sid' => '45',
      'uri' => 'kolobok/smile.gif',
      'status' => '1',
      'acronyms' => '*smile* :-) :) +) =) :smile:',
      'description' => 'Smile',
    ),
  );
  $packs_path = variable_get('smiley_path', drupal_get_path('module', 'smiley') . '/packs');
  $css_class = check_plain(variable_get('smiley_css_class', ''));
  if (!empty($css_class)) {
    $css_class = 'class="' . $css_class . '" ';
  }
  foreach ($smileys as $smiley) {
    foreach (explode(' ', $smiley->acronyms) as $acronym) {
      $expected_text = '<img src="' . file_create_url('smiley://' . $smiley->uri) . '" alt="' . $smiley->description . '" ' . $css_class . '/>';
      $new_text = smiley_process_text($acronym, $smileys);
      $this
        ->assertTrue($new_text == $expected_text, t('All smileys were replaced correctly. Pattern: "@pattern"', array(
        '@pattern' => $acronym,
      )));
    }
  }
}