|
@@ 928-943 (lines=16) @@
|
| 925 |
|
$this->assertTrue($q->is_attachment); |
| 926 |
|
} |
| 927 |
|
|
| 928 |
|
function test_is_page() |
| 929 |
|
{ |
| 930 |
|
$post_id = self::factory()->post->create(array( 'post_type' => 'page' )); |
| 931 |
|
$this->go_to("/?page_id=$post_id"); |
| 932 |
|
|
| 933 |
|
$post = get_queried_object(); |
| 934 |
|
$q = $GLOBALS['wp_query']; |
| 935 |
|
|
| 936 |
|
$this->assertTrue(is_page()); |
| 937 |
|
$this->assertFalse($q->is_single); |
| 938 |
|
$this->assertTrue($q->is_page); |
| 939 |
|
$this->assertFalse($q->is_attachment); |
| 940 |
|
$this->assertTrue(is_page($post)); |
| 941 |
|
$this->assertTrue(is_page($post->ID)); |
| 942 |
|
$this->assertTrue(is_page($post->post_title)); |
| 943 |
|
$this->assertTrue(is_page($post->post_name)); |
| 944 |
|
} |
| 945 |
|
|
| 946 |
|
/** |
|
@@ 984-1000 (lines=17) @@
|
| 981 |
|
$this->assertFalse(is_page('foo')); |
| 982 |
|
} |
| 983 |
|
|
| 984 |
|
function test_is_attachment() |
| 985 |
|
{ |
| 986 |
|
$post_id = self::factory()->post->create(array( 'post_type' => 'attachment' )); |
| 987 |
|
$this->go_to("/?attachment_id=$post_id"); |
| 988 |
|
|
| 989 |
|
$post = get_queried_object(); |
| 990 |
|
$q = $GLOBALS['wp_query']; |
| 991 |
|
|
| 992 |
|
$this->assertTrue(is_attachment()); |
| 993 |
|
$this->assertTrue(is_single()); |
| 994 |
|
$this->assertTrue($q->is_attachment); |
| 995 |
|
$this->assertTrue($q->is_single); |
| 996 |
|
$this->assertFalse($q->is_page); |
| 997 |
|
$this->assertTrue(is_attachment($post)); |
| 998 |
|
$this->assertTrue(is_attachment($post->ID)); |
| 999 |
|
$this->assertTrue(is_attachment($post->post_title)); |
| 1000 |
|
$this->assertTrue(is_attachment($post->post_name)); |
| 1001 |
|
} |
| 1002 |
|
|
| 1003 |
|
/** |