Make WordPress Core

Ticket #31271: 31271-tests.patch

File 31271-tests.patch, 1.1 KB (added by tyxla, 10 years ago)

Adding a unit test for the is_page_template() array parameter case. Also, adding a unit test for the is_page_template() string parameter case.

  • tests/phpunit/tests/query/conditionals.php

     
    809809                $this->assertTrue( is_attachment( $post->post_title ) );
    810810                $this->assertTrue( is_attachment( $post->post_name ) );
    811811        }
     812
     813        function test_is_page_template() {
     814                $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
     815                update_post_meta($post_id, '_wp_page_template', 'example.php');
     816                $this->go_to( "/?page_id=$post_id" );
     817                $this->assertTrue( is_page_template('example.php') );
     818        }
     819
     820        /**
     821         * @ticket 31271
     822         */
     823        function test_is_page_template_array() {
     824                $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
     825                update_post_meta($post_id, '_wp_page_template', 'example.php');
     826                $this->go_to( "/?page_id=$post_id" );
     827                $this->assertTrue( is_page_template( array('test.php', 'example.php') ) );
     828                $this->assertFalse( is_page_template( array('test.php') ) );
     829        }
    812830}