How to create a test that calls is_front_page in phpunit?

The is_front_page() function calls wp_query::is_front_page(). If you scroll down to look at the source, you will see the code you’re looking to trigger:

elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) )
        return true;

To meet that condition, you’ll just need to do this in the code to set up for the test:

update_option( 'show_on_front', 'page' );
update_option( 'page_on_front', $post_id );

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)