Skip to content

Commit

Permalink
Merge pull request #1095 from vektor-inc/fix/test-blog-card
Browse files Browse the repository at this point in the history
テスト内で非推奨関数の使用が原因でテストがコケるので修正
  • Loading branch information
kurudrive authored Nov 27, 2023
2 parents 19ff756 + aef0d77 commit 7cd6d10
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions _g3/tests/test-vk-wp-oembed-blog-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
* cd /app
* bash setup-phpunit.sh
* source ~/.bashrc
*
*
* cd $(wp theme path --dir lightning)
* あるいは
* cd wp-content/themes/lightning
*
*
* phpunit
*/

Expand All @@ -21,28 +21,28 @@
class BlogCardTest extends WP_UnitTestCase {

/**
* oembed_html 内部リンク、WordPressで作られたサイトのテスト
* oembed_html 内部リンク、WordPressで作られたサイトのテスト
* cache は 管理画面URLを貼り付けた時に自動で変換される文字列
*/
function test_vk_get_post_data_blog_card() {
// Create test post
$post = array(
'post_title' => 'test',
'post_content' => 'content',
'post_name' => 'test',
'post_status' => 'publish',
'post_title' => 'test',
'post_content' => 'content',
'post_name' => 'test',
'post_status' => 'publish',
);
$post_id = wp_insert_post( $post );

// the_contentのフィルターフックで自動に入るpタグを削除
remove_filter( 'the_content', 'wpautop' );
$test_array = array(
// WordPressで作られたサイト サイト内記事

array(
'url' => get_permalink( $post_id ),
'cache' => '[embed]' . get_permalink( $post_id ) .'[/embed]',
'correct' => apply_filters( 'the_content', '[embed]' . get_permalink( $post_id ) .'[/embed]' ),
'cache' => '[embed]' . get_permalink( $post_id ) . '[/embed]',
'correct' => apply_filters( 'the_content', '[embed]' . get_permalink( $post_id ) . '[/embed]' ),
),
// WordPressで作られたサイト トップページ
array(
Expand All @@ -65,9 +65,9 @@ function test_vk_get_post_data_blog_card() {
);
foreach ( $test_array as $key => $value ) {
$result = VK_WP_Oembed_Blog_Card::oembed_html( $value['cache'], $value['url'] );
if ( function_exists( 'wp_img_tag_add_decoding_attr') ) {
$result = wp_img_tag_add_decoding_attr( $result, 'custom' );
}
if ( function_exists( 'wp_img_tag_add_loading_optimization_attrs' ) ) {
$result = wp_img_tag_add_loading_optimization_attrs( $result, 'custom' );
}
$this->assertEquals( $value['correct'], $result );
}
// wpautopフィルターフックを戻す
Expand Down Expand Up @@ -99,15 +99,14 @@ function test_vk_get_blog_card() {
),
);
foreach ( $test_array as $key => $value ) {
$output = "";
$output = '';
$result = VK_WP_Oembed_Blog_Card::maybe_make_link( $output, $value['url'] );
if ( function_exists( 'wp_img_tag_add_decoding_attr') ) {
$result = wp_img_tag_add_decoding_attr( $result, 'custom' );
}
if ( function_exists( 'wp_img_tag_add_loading_optimization_attrs' ) ) {
$result = wp_img_tag_add_loading_optimization_attrs( $result, 'custom' );
}
$this->assertEquals( $value['correct'], $result );
}
// wpautopフィルターフックを戻す
add_filter( 'the_content', 'wpautop' );
}

}
}

0 comments on commit 7cd6d10

Please sign in to comment.