| 1077 | * @ticket 39211 |
| 1078 | */ |
| 1079 | function test_is_page_template_not_singular() { |
| 1080 | global $wpdb; |
| 1081 | |
| 1082 | // We need an non-post that shares an ID with a post assigned a template. |
| 1083 | $user_id = self::factory()->user->create(); |
| 1084 | if ( ! get_post( $user_id ) ) { |
| 1085 | $post_id = self::factory()->post->create( array( 'post_type' => 'post' ) ); |
| 1086 | $wpdb->update( $wpdb->posts, array( 'ID' => $user_id ), array( 'ID' => $post_id ), array( '%d' ) ); |
| 1087 | } |
| 1088 | |
| 1089 | update_post_meta( $user_id, '_wp_page_template', 'example.php' ); |
| 1090 | |
| 1091 | // Verify that the non-post with our ID does not report having a template. |
| 1092 | $this->go_to( get_post_permalink( $user_id ) ); |
| 1093 | $this->assertTrue( is_page_template( 'example.php' ) ); |
| 1094 | $this->go_to( get_author_posts_url( $user_id ) ); |
| 1095 | $this->assertInstanceOf( 'WP_User', get_queried_object() ); // and not something else that would return false, like a 404. |
| 1096 | $this->assertFalse( is_page_template( 'example.php' ) ); |
| 1097 | } |
| 1098 | |
| 1099 | /** |