2013-02-28 17:53:20 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* PHPMailer - language file tests
|
2013-12-16 14:28:57 +01:00
|
|
|
*
|
2016-04-07 11:04:03 +02:00
|
|
|
* PHP version 5.5
|
2013-02-28 17:53:20 +01:00
|
|
|
* @package PHPMailer
|
2013-12-16 14:28:57 +01:00
|
|
|
* @author Marcus Bointon <phpmailer@synchromedia.co.uk>
|
2015-11-10 14:44:16 +01:00
|
|
|
* @author Andy Prevost
|
2016-04-07 11:04:03 +02:00
|
|
|
* @copyright 2010 - 2016 Marcus Bointon
|
2013-02-28 17:53:20 +01:00
|
|
|
* @copyright 2004 - 2009 Andy Prevost
|
|
|
|
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
|
|
|
*/
|
|
|
|
|
2015-11-09 19:09:13 +01:00
|
|
|
namespace PHPMailer\PHPMailer;
|
|
|
|
|
2013-02-28 17:53:20 +01:00
|
|
|
/**
|
|
|
|
* PHPMailer - PHP email transport unit test class
|
|
|
|
* Performs authentication tests
|
|
|
|
*/
|
2015-11-09 19:09:13 +01:00
|
|
|
class PHPMailerLangTest extends \PHPUnit_Framework_TestCase
|
2013-02-28 17:53:20 +01:00
|
|
|
{
|
|
|
|
/**
|
2015-11-09 19:09:13 +01:00
|
|
|
* Holds a PHPMailer instance.
|
2013-02-28 17:53:20 +01:00
|
|
|
* @private
|
|
|
|
* @var PHPMailer
|
|
|
|
*/
|
|
|
|
public $Mail;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string Default include path
|
|
|
|
*/
|
|
|
|
public $INCLUDE_DIR = '../';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run before each test is started.
|
|
|
|
*/
|
2013-07-09 13:46:44 +02:00
|
|
|
public function setUp()
|
2013-02-28 17:53:20 +01:00
|
|
|
{
|
|
|
|
$this->Mail = new PHPMailer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test language files for missing and excess translations
|
|
|
|
* All languages are compared with English
|
2013-12-16 14:28:57 +01:00
|
|
|
* @group languages
|
2013-02-28 17:53:20 +01:00
|
|
|
*/
|
2013-07-09 13:46:44 +02:00
|
|
|
public function testTranslations()
|
2013-02-28 17:53:20 +01:00
|
|
|
{
|
2013-07-09 13:46:44 +02:00
|
|
|
$this->Mail->setLanguage('en');
|
|
|
|
$definedStrings = $this->Mail->getTranslations();
|
2013-02-28 17:53:20 +01:00
|
|
|
$err = '';
|
2015-11-09 19:09:13 +01:00
|
|
|
foreach (new \DirectoryIterator('../language') as $fileInfo) {
|
2013-02-28 17:53:20 +01:00
|
|
|
if ($fileInfo->isDot()) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-11-10 13:45:13 +01:00
|
|
|
$matches = [];
|
2013-02-28 17:53:20 +01:00
|
|
|
//Only look at language files, ignore anything else in there
|
|
|
|
if (preg_match('/^phpmailer\.lang-([a-z_]{2,})\.php$/', $fileInfo->getFilename(), $matches)) {
|
|
|
|
$lang = $matches[1]; //Extract language code
|
2015-11-10 13:45:13 +01:00
|
|
|
$PHPMAILER_LANG = []; //Language strings get put in here
|
2013-02-28 17:53:20 +01:00
|
|
|
include $fileInfo->getPathname(); //Get language strings
|
|
|
|
$missing = array_diff(array_keys($definedStrings), array_keys($PHPMAILER_LANG));
|
|
|
|
$extra = array_diff(array_keys($PHPMAILER_LANG), array_keys($definedStrings));
|
|
|
|
if (!empty($missing)) {
|
|
|
|
$err .= "\nMissing translations in $lang: " . implode(', ', $missing);
|
|
|
|
}
|
|
|
|
if (!empty($extra)) {
|
|
|
|
$err .= "\nExtra translations in $lang: " . implode(', ', $extra);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->assertEmpty($err, $err);
|
|
|
|
}
|
|
|
|
}
|