mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
i18n-tools: Respect the coding standards when adding textdomains with add-textdomain.php.
Props GaryJ, groovecoder. Fixes #21616. git-svn-id: https://develop.svn.wordpress.org/trunk@36603 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -10,15 +10,37 @@ require_once dirname( dirname( __FILE__ ) ) . '/add-textdomain.php';
|
||||
|
||||
class AddTextDomainTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
function __construct() {
|
||||
$this->atd = new AddTextdomain;
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->atd = new AddTextdomain();
|
||||
}
|
||||
|
||||
function test_add() {
|
||||
# copy to a new file, so that we don't corrupt the old one
|
||||
// Copy to a new file, so that we don't corrupt the old one.
|
||||
copy( 'data/add-textdomain-0.php', 'data/add-textdomain-0-work.php' );
|
||||
$this->atd->process_file( 'test-domain', 'data/add-textdomain-0-work.php', true );
|
||||
$this->assertEquals( file_get_contents( 'data/add-textdomain-0-result.php' ), file_get_contents( 'data/add-textdomain-0-work.php' ) );
|
||||
unlink( 'data/add-textdomain-0-work.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_textdomain_sources
|
||||
*/
|
||||
function test_basic_add_textdomain( $source, $expected ) {
|
||||
$tokens = token_get_all( $source );
|
||||
$result = $this->atd->process_tokens( 'foo', $tokens );
|
||||
$this->assertEquals( $expected, $result );
|
||||
}
|
||||
|
||||
function data_textdomain_sources() {
|
||||
return array(
|
||||
array( "<?php __('string'); ?>", "<?php __('string', 'foo'); ?>" ), // Simple single quotes
|
||||
array( '<?php __("string"); ?>', "<?php __(\"string\", 'foo'); ?>" ), // Simple double quotes
|
||||
array( "<?php __( 'string' ); ?>", "<?php __( 'string', 'foo' ); ?>" ), // Simple single quotes CS
|
||||
array( '<?php __( "string" ); ?>', "<?php __( \"string\", 'foo' ); ?>" ), // Simple double quotes CS
|
||||
array( "<?php __( 'string', 'string2' ); ?>", "<?php __( 'string', 'string2', 'foo' ); ?>" ), // Multiple string args
|
||||
array( '<?php __( \'string\', $var ); ?>', '<?php __( \'string\', $var, \'foo\' ); ?>' ), // Multiple string / var args
|
||||
array( "<?php __( 'string', 'foo' ); ?>", "<?php __( 'string', 'foo' ); ?>" ), // Existing textdomain
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user