/**
  * Test format.
  *
  * @param string $text
  * @param string $language
  * @param string $mode
  * @param string $expectedText
  *
  * @dataProvider dataProvider
  */
 public function testFormat($text, $language, $mode, $expectedText)
 {
     $formatter = new CRM_Utils_QueryFormatter($mode);
     $actualText = $formatter->format($text, $language);
     $this->assertEquals($expectedText, $actualText);
 }
예제 #2
0
 /**
  * @param $text
  *
  * Ex: drush eval 'civicrm_initialize(); CRM_Utils_QueryFormatter::dumpExampleTable("firstword secondword");'
  */
 public static function dumpExampleTable($text)
 {
     $width = strlen($text) + 8;
     $buf = '';
     $buf .= sprintf("%-{$width}s", 'mode');
     foreach (self::getLanguages() as $lang) {
         $buf .= sprintf("%-{$width}s", $lang);
     }
     $buf .= "\n";
     foreach (self::getModes() as $mode) {
         $formatter = new CRM_Utils_QueryFormatter($mode);
         $buf .= sprintf("%-{$width}s", $mode);
         foreach (self::getLanguages() as $lang) {
             $buf .= sprintf("%-{$width}s", $formatter->format($text, $lang));
         }
         $buf .= "\n";
     }
     echo $buf;
 }