Make WordPress Core

Ticket #31270: 31270.ut.diff

File 31270.ut.diff, 1.5 KB (added by dd32, 11 years ago)
  • tests/phpunit/tests/term.php

     
    16831683                        'taxonomy' => 'wptests_tax',
    16841684                        'slug' => 'foo',
    16851685                ) );
    16861686
    16871687                wp_update_term( $t3, 'wptests_tax', array(
    16881688                        'parent' => $t1,
    16891689                ) );
    16901690
    16911691                $t3_term = get_term( $t3, 'wptests_tax' );
    16921692
    16931693                $this->assertSame( 'foo', $t3_term->slug );
    16941694
    16951695                _unregister_taxonomy( 'wptests_tax' );
    16961696        }
    16971697
     1698        /**
     1699         * @ticket 31270
     1700         */
     1701        public function test_31270() {
     1702                register_taxonomy( 'foo', 'post', array(
     1703                        'hierarchical' => true
     1704                ) );
     1705
     1706                $term_slugs = array();
     1707
     1708                $t1 = $this->factory->term->create( array(
     1709                        'taxonomy' => 'foo',
     1710                        'name' => 'Foo',
     1711                ) );
     1712                $term_slugs[ $t1 ] = get_term( $t1, 'foo' )->slug;
     1713
     1714                $t2 = $this->factory->term->create( array(
     1715                        'taxonomy' => 'foo',
     1716                        'name' => 'Bar',
     1717                        'slug' => 'foo-bar', // non-conflicting slug
     1718                        'parent' => $t1,
     1719                ) );
     1720                $term_slugs[ $t2 ] = get_term( $t2, 'foo' )->slug;
     1721
     1722                $t3 = $this->factory->term->create( array(
     1723                        'taxonomy' => 'foo',
     1724                        'name' => 'Bar',
     1725                ) );
     1726                $term_slugs[ $t3 ] = get_term( $t3, 'foo' )->slug;
     1727
     1728                _unregister_taxonomy( 'foo' );
     1729
     1730                $expected = array(
     1731                        $t1 => 'foo',
     1732                        $t2 => 'foo-bar',
     1733                        $t3 => 'bar',
     1734                );
     1735
     1736                $this->assertEquals( $expected, $term_slugs );
     1737        }
     1738
    16981739        /** Helpers **********************************************************/
    16991740
    17001741        public function _pre_insert_term_callback() {
    17011742                return new WP_Error( 'custom_error' );
    17021743        }
    17031744}