From c472d9a54fdce6e02abf58cb52875b1cb4800cf1 Mon Sep 17 00:00:00 2001 From: Marcus Bointon Date: Thu, 20 Nov 2008 22:21:44 +0000 Subject: [PATCH] Add test to check for missing translations (will often spot corrupt ones too) --- test/phpmailer_test.php | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/test/phpmailer_test.php b/test/phpmailer_test.php index 61456c47..45bc1f75 100644 --- a/test/phpmailer_test.php +++ b/test/phpmailer_test.php @@ -531,8 +531,41 @@ class phpmailerTest extends TestCase $this->assert(!$this->Mail->AddBCC('c@example.com'), 'BCC duplicate addressing failed'); $this->assert(!$this->Mail->AddBCC('a@example.com'), 'BCC duplicate Addressing failed (2)'); } -} - + + // Check that we are not missing any translations in any langauges + function test_Translations() { + //Extend this array as new strings are added + $expectedtranslations = array( + 'provide_address', + 'mailer_not_supported', + 'execute', + 'instantiate', + 'authenticate', + 'from_failed', + 'recipients_failed', + 'data_not_accepted', + 'connect_host', + 'file_access', + 'file_open', + 'encoding', + 'signing', + 'smtp_error' + ); + try { + foreach (new DirectoryIterator('../language') as $langfile) { + if (!preg_match('/^phpmailer\.lang-/', $langfile)) continue; //Skip non-language files + $PHPMAILER_LANG = array(); + include '../language/'.$langfile; + foreach($expectedtranslations as $string) { + $this->assert(isset($PHPMAILER_LANG[$string]), 'Translation missing; \''.$string.'\' in '.$langfile); + } + } + } + catch(Exception $e) { + $this->assert(false, 'No language files found!'); + } + } +} /** * Create and run test instance. */