From f5b13dd6ca2f2895c5a94db73c60fd120d93c893 Mon Sep 17 00:00:00 2001 From: naoki Date: Mon, 8 Jul 2024 13:48:17 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E7=BF=BB=E8=A8=B3=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88=E3=81=A8=E7=BF=BB?= =?UTF-8?q?=E8=A8=B3=E9=96=A2=E6=95=B0=E3=81=AE=E7=B5=90=E6=9E=9C=E3=82=92?= =?UTF-8?q?=E6=AF=94=E8=BC=83=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test-load-textdomain.php | 81 +++++++++------------------------- 1 file changed, 20 insertions(+), 61 deletions(-) diff --git a/tests/test-load-textdomain.php b/tests/test-load-textdomain.php index d2f524a..e0ea889 100644 --- a/tests/test-load-textdomain.php +++ b/tests/test-load-textdomain.php @@ -1,73 +1,32 @@ 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( '地物の数: ', __( 'Number of features: ', $domain ) ); + $this->assertSame( '標準', __( 'Standard', $domain ) ); + $this->assertSame( '地理院地図', __( 'GSI', $domain ) ); + $this->assertSame( '白地図', __( 'Blank Map', $domain ) ); + $this->assertSame( '地図', __( 'Map', $domain ) ); + $this->assertSame( '株式会社 Geolonia', __( 'Geolonia Inc.', $domain ) ); } } From 6e3dc2d8310453221f97e581a419ea26c98a8adf Mon Sep 17 00:00:00 2001 From: naoki Date: Mon, 8 Jul 2024 13:53:50 +0900 Subject: [PATCH 2/3] fix postype register test --- tests/test-register_post_type_maps.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test-register_post_type_maps.php b/tests/test-register_post_type_maps.php index d24fde9..a2ef6d8 100644 --- a/tests/test-register_post_type_maps.php +++ b/tests/test-register_post_type_maps.php @@ -5,7 +5,7 @@ class Test_Register_Post_Type_Maps extends WP_UnitTestCase { public function set_up() { parent::set_up(); - unregister_post_type( 'maps' ); + unregister_post_type( 'map' ); } /** @@ -13,14 +13,14 @@ public function set_up() { */ public function test_maps_post_type_registered() { - $this->assertNull( get_post_type_object( 'maps' ) ); + $this->assertNull( get_post_type_object( 'map' ) ); register_post_type_maps(); - $maps_object = get_post_type_object( 'maps' ); + $maps_object = get_post_type_object( 'map' ); $this->assertInstanceOf( 'WP_Post_Type', $maps_object ); - $this->assertSame( 'maps', $maps_object->name ); + $this->assertSame( 'map', $maps_object->name ); } /** @@ -28,14 +28,14 @@ public function test_maps_post_type_registered() { */ public function test_maps_post_type_options() { - $this->assertNull( get_post_type_object( 'maps' ) ); + $this->assertNull( get_post_type_object( 'map' ) ); register_post_type_maps(); - $maps_object = get_post_type_object( 'maps' ); + $maps_object = get_post_type_object( 'map' ); // labels の設定値を確認 - $this->assertSame( 'Map', $maps_object->label ); + $this->assertSame( '地図', $maps_object->label ); // public の設定値を確認 $this->assertTrue( $maps_object->public ); @@ -50,16 +50,16 @@ public function test_maps_post_type_options() { $this->assertTrue( $maps_object->show_in_nav_menus ); // カスタム投稿タイプの supports に title が含まれているか確認 - $this->assertTrue( post_type_supports( 'maps', 'title' ), 'Title support is enabled' ); + $this->assertTrue( post_type_supports( 'map', 'title' ), 'Title support is enabled' ); // カスタム投稿タイプの supports に editor が含まれているか確認 - $this->assertTrue( post_type_supports( 'maps', 'editor' ), 'Editor support is enabled' ); + $this->assertTrue( post_type_supports( 'map', 'editor' ), 'Editor support is enabled' ); // カスタム投稿タイプの supports に author が含まれているか確認 - $this->assertTrue( post_type_supports( 'maps', 'revisions' ), 'Revisions support is enabled' ); + $this->assertTrue( post_type_supports( 'map', 'revisions' ), 'Revisions support is enabled' ); // カスタム投稿タイプの supports に excerpt が含まれているか確認 - $this->assertTrue( post_type_supports( 'maps', 'excerpt' ), 'Excerpt support is enabled' ); + $this->assertTrue( post_type_supports( 'map', 'excerpt' ), 'Excerpt support is enabled' ); // archive の設定値を確認 $this->assertFalse( $maps_object->has_archive ); @@ -68,7 +68,7 @@ public function test_maps_post_type_options() { $this->assertSame( array('slug' => 'maps'), $maps_object->rewrite ); // query_var の設定値を確認 - $this->assertSame( 'maps', $maps_object->query_var ); + $this->assertSame( 'map', $maps_object->query_var ); // menu_icon の設定値を確認 $this->assertSame( 'dashicons-location', $maps_object->menu_icon ); From 32590987b708921529a6ea9e02b882110524f581 Mon Sep 17 00:00:00 2001 From: naoki Date: Mon, 8 Jul 2024 13:57:16 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=A0?= =?UTF-8?q?=E6=8A=95=E7=A8=BF=E3=82=BF=E3=82=A4=E3=83=97=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test-register_post_type_maps.php | 94 -------------------------- 1 file changed, 94 deletions(-) delete mode 100644 tests/test-register_post_type_maps.php diff --git a/tests/test-register_post_type_maps.php b/tests/test-register_post_type_maps.php deleted file mode 100644 index a2ef6d8..0000000 --- a/tests/test-register_post_type_maps.php +++ /dev/null @@ -1,94 +0,0 @@ -assertNull( get_post_type_object( 'map' ) ); - - register_post_type_maps(); - - $maps_object = get_post_type_object( 'map' ); - - $this->assertInstanceOf( 'WP_Post_Type', $maps_object ); - $this->assertSame( 'map', $maps_object->name ); - } - - /** - * @covers ::register_post_type_maps - */ - public function test_maps_post_type_options() { - - $this->assertNull( get_post_type_object( 'map' ) ); - - register_post_type_maps(); - - $maps_object = get_post_type_object( 'map' ); - - // labels の設定値を確認 - $this->assertSame( '地図', $maps_object->label ); - - // public の設定値を確認 - $this->assertTrue( $maps_object->public ); - - // hierarchical の設定値を確認 - $this->assertFalse( $maps_object->hierarchical ); - - // show_ui の設定値を確認 - $this->assertTrue( $maps_object->show_ui ); - - // show_in_menu の設定値を確認 - $this->assertTrue( $maps_object->show_in_nav_menus ); - - // カスタム投稿タイプの supports に title が含まれているか確認 - $this->assertTrue( post_type_supports( 'map', 'title' ), 'Title support is enabled' ); - - // カスタム投稿タイプの supports に editor が含まれているか確認 - $this->assertTrue( post_type_supports( 'map', 'editor' ), 'Editor support is enabled' ); - - // カスタム投稿タイプの supports に author が含まれているか確認 - $this->assertTrue( post_type_supports( 'map', 'revisions' ), 'Revisions support is enabled' ); - - // カスタム投稿タイプの supports に excerpt が含まれているか確認 - $this->assertTrue( post_type_supports( 'map', 'excerpt' ), 'Excerpt support is enabled' ); - - // archive の設定値を確認 - $this->assertFalse( $maps_object->has_archive ); - - // rewrite の設定値を確認 - $this->assertSame( array('slug' => 'maps'), $maps_object->rewrite ); - - // query_var の設定値を確認 - $this->assertSame( 'map', $maps_object->query_var ); - - // menu_icon の設定値を確認 - $this->assertSame( 'dashicons-location', $maps_object->menu_icon ); - - // show_in_rest の設定値を確認 - $this->assertTrue( $maps_object->show_in_rest ); - - // rest_base の設定値を確認 - $this->assertSame( GEOLONIA_GIS_POST_TYPE, $maps_object->rest_base ); - - // rest_controller_class の設定値を確認 - $this->assertSame( 'WP_REST_Posts_Controller', $maps_object->rest_controller_class ); - - // taxonomies の設定値を確認 - $this->assertSame( array( 'map_tag' ), $maps_object->taxonomies ); - - // capability_type の設定値を確認 - $this->assertSame( 'map', $maps_object->capability_type ); - - // map_meta_cap の設定値を確認 - $this->assertTrue( $maps_object->map_meta_cap ); - } -}