Make WordPress Core

Ticket #10663: 10663.diff

File 10663.diff, 2.5 KB (added by wonderboymusic, 9 years ago)
  • src/wp-includes/query.php

     
    38613861
    38623862                $category = (array) $category;
    38633863
    3864                 if ( in_array( $cat_obj->term_id, $category ) )
     3864                if ( in_array( $cat_obj->term_id, $category, true ) )
    38653865                        return true;
    38663866                elseif ( in_array( $cat_obj->name, $category ) )
    38673867                        return true;
     
    38933893
    38943894                $tag = (array) $tag;
    38953895
    3896                 if ( in_array( $tag_obj->term_id, $tag ) )
     3896                if ( in_array( $tag_obj->term_id, $tag, true ) )
    38973897                        return true;
    38983898                elseif ( in_array( $tag_obj->name, $tag ) )
    38993899                        return true;
  • tests/phpunit/tests/query/conditionals.php

     
    722722                $this->assertTrue( is_attachment( $post->post_title ) );
    723723                $this->assertTrue( is_attachment( $post->post_name ) );
    724724        }
     725
     726        /**
     727         * @ticket 10663
     728         */
     729        function test_is_category() {
     730                $post_id = $this->factory->post->create();
     731                $cat_id = $this->factory->category->create( array( 'name' => 'News' ) );
     732                wp_set_post_categories( $post_id, $cat_id );
     733
     734                $this->go_to( "/?cat=$cat_id" );
     735
     736                $this->assertQueryTrue( 'is_category', 'is_archive'  );
     737                $this->assertTrue( is_numeric( $cat_id ) );
     738                $this->assertTrue( is_category( $cat_id ) );
     739                $this->assertTrue( is_numeric( "$cat_id") );
     740                $this->assertTrue( is_category( "$cat_id" ) );
     741
     742                $this->assertFalse( is_numeric( "{$cat_id}eth release" ) );
     743                $this->assertFalse( is_category( "{$cat_id}eth release" ) );
     744                $this->assertFalse( is_category( "{$cat_id}eth" ) );
     745                $this->assertFalse( is_category( "{$cat_id} of a kind" ) );
     746        }
     747
     748        /**
     749         * @ticket 10663
     750         */
     751        function test_is_tag() {
     752                $post_id = $this->factory->post->create();
     753                $tag_id = $this->factory->tag->create( array( 'name' => 'News' ) );
     754                wp_set_post_tags( $post_id, $tag_id );
     755
     756                $this->go_to( "/?tag=$tag_id" );
     757
     758                $this->assertQueryTrue( 'is_tag', 'is_archive'  );
     759                $this->assertTrue( is_numeric( $tag_id ) );
     760                $this->assertTrue( is_tag( $tag_id ) );
     761                $this->assertTrue( is_numeric( "$tag_id") );
     762                $this->assertTrue( is_tag( "$tag_id" ) );
     763
     764                $this->assertFalse( is_numeric( "{$tag_id}eth release" ) );
     765                $this->assertFalse( is_tag( "{$tag_id}eth release" ) );
     766                $this->assertFalse( is_tag( "{$tag_id}eth" ) );
     767                $this->assertFalse( is_tag( "{$tag_id} of a kind" ) );
     768        }
    725769}