Make WordPress Core

Ticket #21821: isVarious.php

File isVarious.php, 1.5 KB (added by devesine, 14 years ago)
Line 
1<?php
2
3/**
4 * @group post
5 */
6class Tests_Query_Is_Various extends WP_UnitTestCase {
7
8 function setUp() {
9 parent::setUp();
10
11 update_option( 'comments_per_page', 5 );
12 update_option( 'posts_per_page', 5 );
13
14 global $wp_rewrite;
15 update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' );
16 create_initial_taxonomies();
17 $GLOBALS['wp_rewrite']->init();
18 flush_rewrite_rules();
19 }
20
21 function tearDown() {
22 parent::tearDown();
23 $GLOBALS['wp_rewrite']->init();
24 }
25
26 function test_query_post_and_category() {
27 // Bug 21821
28 global $wp_query;
29 $this->assertNull( get_post_type_object( 'foo' ) );
30 register_post_type( 'foo', array( 'has_archive' => true ) );
31
32 $pobj = get_post_type_object( 'foo' );
33 $this->assertInstanceOf( 'stdClass', $pobj );
34 $this->assertEquals( 'foo', $pobj->name );
35 $this->assertEquals( true, $pobj->has_archive );
36
37 register_taxonomy_for_object_type( 'category', 'foo' );
38 $this->assertEquals( array( 'category' ), get_object_taxonomies( 'foo' ) );
39
40 $cat_a = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'cat-a' ) );
41
42 $this->factory->post->create( array( 'post_type' => 'foo', 'post_title' => 'foopost', 'post_date' => '2008-12-01 00:00:00', 'post_category' => array( $cat_a ) ) );
43
44 $this->go_to('/?post_type=foo&category_name=cat-a');
45
46 $this->assertEquals( true, is_category() );
47 $this->assertEquals( true, is_post_type_archive() );
48
49 $this->assertNotEquals( '', wp_title( '&raquo;', false ) );
50
51 $GLOBALS['wp_taxonomies']['category']->object_type = array( 'post' );
52 }
53}