Skip to content

Commit

Permalink
Avoiding errors in PHP 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdkei committed May 22, 2024
1 parent 3b316b7 commit 064f089
Showing 1 changed file with 34 additions and 31 deletions.
65 changes: 34 additions & 31 deletions tests/test-css-customize.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ class CssCustomizeTest extends WP_UnitTestCase {
* カスタマイズCSSのテスト
*/
function test_css_customize_get_the_css_min() {
$tests = array(
array(
'option' => 'div > h1 { color:red; }',
'correct' => 'div > h1 { color:red; }',
),
array(
'option' => 'div > h1 {
color:red;
}',
'correct' => 'div > h1 {color:red;}',
),
array(
'option' => '<script></script>div > h1 {color:red;}',
'correct' => 'div > h1 {color:red;}',
),
);
$tests = array(
array(
'option' => 'div > h1 { color:red; }',
'correct' => 'div > h1 { color:red; }',
),
array(
'option' => 'div > h1 {
color:red;
}',
'correct' => 'div > h1 {color:red;}',
),
array(
'option' => '<script></script>div > h1 {color:red;}',
'correct' => 'div > h1 {color:red;}',
),
);

print PHP_EOL;
print '------------------------------------' . PHP_EOL;
print 'veu_css_customize' . PHP_EOL;
print '------------------------------------' . PHP_EOL;
$before_option = get_option( 'vkExUnit_css_customize' );
print PHP_EOL;
print '------------------------------------' . PHP_EOL;
print 'veu_css_customize' . PHP_EOL;
print '------------------------------------' . PHP_EOL;
$before_option = get_option( 'vkExUnit_css_customize' );

foreach ( $tests as $key => $test_value ) {
update_option( 'vkExUnit_css_customize', $test_value['option'] );
Expand All @@ -44,9 +44,9 @@ function test_css_customize_get_the_css_min() {
print 'return :' . $return . PHP_EOL;
print 'correct :' . $test_value['correct'] . PHP_EOL;
$this->assertEquals( $test_value['correct'], $return );
} // foreach ( $tests as $key => $test_value ) {
$before_option = update_option( 'vkExUnit_css_customize', $before_option );
} // function test_css_customize_get_the_css_min() {
}
update_option( 'vkExUnit_css_customize', $before_option );
}

/* Singular page css */
function test_veu_get_the_custom_css_single() {
Expand All @@ -61,8 +61,8 @@ function test_veu_get_the_custom_css_single() {
array(
'post_title' => 'タイトル',
'post_meta' => 'div > h1 {
color:red;
}',
color:red;
}',
'correct' => 'div > h1 {color:red;}',
),
array(
Expand All @@ -80,7 +80,12 @@ function test_veu_get_the_custom_css_single() {
foreach ( $test_array as $key => $value ) {

// テスト用のデータを投稿する
$post_data['post_content'] = $value['post_title'];
$post_data = array(
'post_title' => $value['post_title'],
'post_content' => $value['post_title'],
'post_status' => 'publish',
'post_type' => 'post',
);

// 投稿が成功すると投稿IDが返ってくる
$post_id = wp_insert_post( $post_data );
Expand All @@ -103,8 +108,6 @@ function test_veu_get_the_custom_css_single() {
// テスト用データを消去
wp_delete_post( $post_id, true );

} // foreach ( $test_array as $key => $value ) {

} // function test_veu_get_the_custom_css_single() {

}
}
}

0 comments on commit 064f089

Please sign in to comment.