i18n tools: Add a test for the add-textdomain.php script.

git-svn-id: https://develop.svn.wordpress.org/trunk@36389 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood 2016-01-24 15:25:11 +00:00
parent b07466c2bf
commit 1e1ac57375
3 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,24 @@
<?php
/**
* Tests for add-textdomain.php
*
* @package wordpress-i18n
* @subpackage tools
*/
error_reporting( E_ALL );
require_once dirname( dirname( __FILE__ ) ) . '/add-textdomain.php';
class AddTextDomainTest extends PHPUnit_Framework_TestCase {
function __construct() {
$this->atd = new AddTextdomain;
}
function test_add() {
# 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' );
}
}

View File

@ -0,0 +1,17 @@
<?php
function call_some_i18n_methods() {
__( 'Hello World' , 'test-domain');
_e( 'Hello World' , 'test-domain');
_n( 'Single', 'Plural', 1 , 'test-domain');
_n_noop( 'Single Noop', 'Plural Noop', 1 , 'test-domain');
_x( 'Hello World', 'Testing' , 'test-domain');
_ex( 'Hello World', 'Testing' , 'test-domain');
_nx( 'Hello World', 'Testing' , 'test-domain');
_nx_noop( 'Hello World Noop', 'Testing' , 'test-domain');
esc_attr__( 'Attribute' , 'test-domain');
esc_html__( 'HTML' , 'test-domain');
esc_attr_e( 'Attribute' , 'test-domain');
esc_html_e( 'HTML' , 'test-domain');
esc_attr_x( 'Attribute', 'Testing' , 'test-domain');
esc_html_x( 'HTML', 'Testing' , 'test-domain');
}

View File

@ -0,0 +1,17 @@
<?php
function call_some_i18n_methods() {
__( 'Hello World' );
_e( 'Hello World' );
_n( 'Single', 'Plural', 1 );
_n_noop( 'Single Noop', 'Plural Noop', 1 );
_x( 'Hello World', 'Testing' );
_ex( 'Hello World', 'Testing' );
_nx( 'Hello World', 'Testing' );
_nx_noop( 'Hello World Noop', 'Testing' );
esc_attr__( 'Attribute' );
esc_html__( 'HTML' );
esc_attr_e( 'Attribute' );
esc_html_e( 'HTML' );
esc_attr_x( 'Attribute', 'Testing' );
esc_html_x( 'HTML', 'Testing' );
}