Make WordPress Core

Ticket #37406: 37406.2.test.patch

File 37406.2.test.patch, 1.1 KB (added by birgire, 7 years ago)
  • tests/phpunit/tests/admin/includesPost.php

    diff --git tests/phpunit/tests/admin/includesPost.php tests/phpunit/tests/admin/includesPost.php
    index f2df065..f9fc502 100644
    class Tests_Admin_Includes_Post extends WP_UnitTestCase { 
    658658                $this->assertSame( $p, post_exists( $title, $content, $date ) );
    659659        }
    660660
     661        /**
     662         * @ticket 37406
     663         */
     664        public function test_post_exists_should_support_post_type() {
     665                $title = 'Foo Bar';
     666                $post_type = 'page';
     667                $post_id = self::factory()->post->create( array(
     668                        'post_title'    => $title,
     669                        'post_type'     => $post_type,
     670                ) );
     671
     672                $this->assertSame( $post_id, post_exists( $title, null, null, $post_type ) );
     673        }
     674
     675        /**
     676         * @ticket 37406
     677         */
     678        public function test_post_exists_should_not_match_a_page_for_post() {
     679                $title = 'Foo Bar';
     680                $post_type = 'page';
     681                $post_id = self::factory()->post->create( array(
     682                        'post_title'    => $title,
     683                        'post_type'     => $post_type,
     684                ) );
     685
     686                $this->assertNotSame( $post_id, post_exists( $title, null, null, 'post' ) );
     687        }
    661688}