Created
November 17, 2019 04:19
-
-
Save msaari/0acad41d687bb16c5f22c30ffafb34d9 to your computer and use it in GitHub Desktop.
Tests the relevanssi_no_image_attachments function and feature.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Tests the relevanssi_no_image_attachments function and feature. | |
*/ | |
public function test_no_image_attachments() { | |
$this->delete_all_posts(); | |
$image_attachment = array( | |
'post_title' => 'cat gif', | |
'post_mime_type' => 'image/gif', | |
'post_type' => 'attachment', | |
'post_status' => 'publish', | |
); | |
wp_insert_post( $image_attachment ); | |
$pdf_attachment = array( | |
'post_title' => 'cat pdf', | |
'post_mime_type' => 'application/pdf', | |
'post_type' => 'attachment', | |
'post_status' => 'publish', | |
); | |
wp_insert_post( $pdf_attachment ); | |
update_option( 'relevanssi_index_post_types', array( 'attachment' ) ); | |
update_option( 'relevanssi_index_image_files', 'off' ); | |
$return = relevanssi_build_index( false, null, null, true ); | |
$this->assertEquals( | |
1, | |
$return['indexed'], | |
"With image files excluded, the number of posts indexed isn't correct." | |
); | |
update_option( 'relevanssi_index_image_files', 'on' ); | |
$return = relevanssi_build_index( false, null, null, true ); | |
$this->assertEquals( | |
2, | |
$return['indexed'], | |
"With image files included, the number of posts indexed isn't correct." | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment