Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

翻訳のテストを修正 #4

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 20 additions & 61 deletions tests/test-load-textdomain.php
Original file line number Diff line number Diff line change
@@ -1,73 +1,32 @@
<?php
/**
* Class TestLoadTextdomain
*/

class Test_LoadTextdomain extends WP_UnitTestCase {
protected static $user_id;
class Test_Translation extends WP_UnitTestCase {

public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
self::$user_id = $factory->user->create(
array(
'role' => 'administrator',
'locale' => 'ja',
)
);
}

/**
* @covers ::geolonia_gis_load_textdomain
*/
public function test_load_textdomain() {
public function set_up() {
parent::set_up();

add_filter('locale', function() {
return 'ja';
});
$this->assertTrue( geolonia_gis_load_textdomain() );
}

/**
* @covers ::geolonia_gis_load_textdomain
*/
public function test_load_textdomain_by_plugin_locale() {
add_filter('plugin_locale', function() {
return 'ja';
});
$this->assertTrue( geolonia_gis_load_textdomain() );
}

/**
* @covers ::geolonia_gis_load_textdomain
*/
public function test_load_textdomain_when_locale_is_english() {
add_filter('locale', function() {
return 'en_US';
});
$this->assertFalse( geolonia_gis_load_textdomain() );
load_plugin_textdomain( 'geolonia-open-gis', false, dirname(dirname( plugin_basename( __FILE__ ) )). '/languages' );
}

/**
* @covers ::geolonia_gis_load_textdomain
*/
public function test_load_textdomain_plugin_locale_is_english() {
add_filter('plugin_locale', function() {
return 'en_US';
});
$this->assertFalse( geolonia_gis_load_textdomain() );
}

/**
* @covers ::geolonia_gis_load_textdomain
*/
public function test_load_textdomain_user_locale_is_japanese() {

add_filter('locale', function() {
return 'en_US';
});

set_current_screen( 'dashboard' );
wp_set_current_user( self::$user_id );

$this->assertTrue( geolonia_gis_load_textdomain() );
public function test_translation() {

$domain = 'geolonia-open-gis';

$this->assertSame( 'GeoJSON をアップロードしてください', __( 'Upload GeoJSON', $domain ) );
$this->assertSame( '座標', __( 'Coordinates', $domain ) );
$this->assertSame( '現在の座標を使用する', __( 'Use the current coordinates', $domain ) );
$this->assertSame( 'ズーム', __( 'Zoom', $domain ) );
$this->assertSame( '現在のズームレベルを使用する', __( 'Use the current zoom level', $domain ) );
$this->assertSame( 'スタイル', __( 'Style', $domain ) );
$this->assertSame( '地物の数: <span id="num-of-features"></span>', __( 'Number of features: <span id="num-of-features"></span>', $domain ) );
$this->assertSame( '標準', __( 'Standard', $domain ) );
$this->assertSame( '地理院地図', __( 'GSI', $domain ) );
$this->assertSame( '白地図', __( 'Blank Map', $domain ) );
$this->assertSame( '地図', __( 'Map', $domain ) );
$this->assertSame( '株式会社 Geolonia', __( 'Geolonia Inc.', $domain ) );
}
}
94 changes: 0 additions & 94 deletions tests/test-register_post_type_maps.php

This file was deleted.