Make WordPress Core

Changeset 909 in tests for trunk/tests/term.php


Ignore:
Timestamp:
07/19/2012 01:52:37 AM (13 years ago)
Author:
nacin
Message:

Complete the renaming described in [904].

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/tests/term.php

    r903 r909  
    44 * @group taxonomy
    55 */
    6 class TestTaxonomy extends WP_UnitTestCase {
    7     function test_get_post_taxonomies() {
    8         $this->assertEquals(array('category', 'post_tag', 'post_format'), get_object_taxonomies('post'));
    9     }
    10 
    11     function test_get_link_taxonomies() {
    12         $this->assertEquals(array('link_category'), get_object_taxonomies('link'));
    13     }
    14 
    15     /**
    16      * @ticket 5417
    17      */
    18     function test_get_unknown_taxonomies() {
    19         // taxonomies for an unknown object type
    20         $this->assertEquals( array(), get_object_taxonomies(rand_str()) );
    21         $this->assertEquals( array(), get_object_taxonomies('') );
    22         $this->assertEquals( array(), get_object_taxonomies(0) );
    23         $this->assertEquals( array(), get_object_taxonomies(NULL) );
    24     }
    25 
    26     function test_get_post_taxonomy() {
    27         foreach ( get_object_taxonomies('post') as $taxonomy ) {
    28             $tax = get_taxonomy($taxonomy);
    29             // should return an object with the correct taxonomy object type
    30             $this->assertTrue( is_object( $tax ) );
    31             $this->assertTrue( is_array( $tax->object_type ) );
    32             $this->assertEquals( array( 'post' ), $tax->object_type );
    33         }
    34     }
    35 
    36     function test_get_link_taxonomy() {
    37         foreach ( get_object_taxonomies('link') as $taxonomy ) {
    38             $tax = get_taxonomy($taxonomy);
    39             // should return an object with the correct taxonomy object type
    40             $this->assertTrue( is_object($tax) );
    41             $this->assertTrue( is_array( $tax->object_type ) );
    42             $this->assertEquals( array( 'link' ), $tax->object_type );
    43         }
    44     }
    45 
    46     function test_taxonomy_exists_known() {
    47         $this->assertTrue( taxonomy_exists('category') );
    48         $this->assertTrue( taxonomy_exists('post_tag') );
    49         $this->assertTrue( taxonomy_exists('link_category') );
    50     }
    51 
    52     function test_taxonomy_exists_unknown() {
    53         $this->assertFalse( taxonomy_exists(rand_str()) );
    54         $this->assertFalse( taxonomy_exists('') );
    55         $this->assertFalse( taxonomy_exists(0) );
    56         $this->assertFalse( taxonomy_exists(NULL) );
    57     }
    58 
    59     function test_is_taxonomy_hierarchical() {
    60         $this->assertTrue( is_taxonomy_hierarchical('category') );
    61         $this->assertFalse( is_taxonomy_hierarchical('post_tag') );
    62         $this->assertFalse( is_taxonomy_hierarchical('link_category') );
    63     }
    64 
    65     function test_is_taxonomy_hierarchical_unknown() {
    66         $this->assertFalse( is_taxonomy_hierarchical(rand_str()) );
    67         $this->assertFalse( is_taxonomy_hierarchical('') );
    68         $this->assertFalse( is_taxonomy_hierarchical(0) );
    69         $this->assertFalse( is_taxonomy_hierarchical(NULL) );
    70     }
    71 
    72     function test_register_taxonomy() {
    73 
    74         // make up a new taxonomy name, and ensure it's unused
    75         $tax = rand_str();
    76         $this->assertFalse( taxonomy_exists($tax) );
    77 
    78         register_taxonomy( $tax, 'post' );
    79         $this->assertTrue( taxonomy_exists($tax) );
    80         $this->assertFalse( is_taxonomy_hierarchical($tax) );
    81 
    82         // clean up
    83         unset($GLOBALS['wp_taxonomies'][$tax]);
    84     }
    85 
    86     function test_register_hierarchical_taxonomy() {
    87 
    88         // make up a new taxonomy name, and ensure it's unused
    89         $tax = rand_str();
    90         $this->assertFalse( taxonomy_exists($tax) );
    91 
    92         register_taxonomy( $tax, 'post', array('hierarchical'=>true) );
    93         $this->assertTrue( taxonomy_exists($tax) );
    94         $this->assertTrue( is_taxonomy_hierarchical($tax) );
    95 
    96         // clean up
    97         unset($GLOBALS['wp_taxonomies'][$tax]);
    98     }
    99 }
    100 
    101 /**
    102  * @group taxonomy
    103  */
    104 class TestTermAPI extends WP_UnitTestCase {
     6class Tests_Term extends WP_UnitTestCase {
    1057    var $taxonomy = 'category';
    1068
Note: See TracChangeset for help on using the changeset viewer.