WordPress.org

Make WordPress Core

Ticket #42098: 42098.diff

File 42098.diff, 5.3 KB (added by birgire, 3 years ago)
  • tests/phpunit/tests/functions/getArchives.php

    diff --git tests/phpunit/tests/functions/getArchives.php tests/phpunit/tests/functions/getArchives.php
    index c90ab97..9b54c03 100644
    EOF; 
    7474        }
    7575
    7676        function test_wp_get_archives_echo() {
    77                 $expected['echo'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></li>';
    78                 ob_start();
     77                $expected['echo'] = "\t<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></li>' . "\n";
     78                $this->expectOutputString( $expected['echo'] );         
    7979                wp_get_archives( array( 'echo' => true ) );
    80                 $actual = ob_get_clean();
    81                 $this->assertEquals( $expected['echo'], trim( $actual ) );
    8280        }
    8381
    8482        function test_wp_get_archives_order() {
  • tests/phpunit/tests/post/listPages.php

    diff --git tests/phpunit/tests/post/listPages.php tests/phpunit/tests/post/listPages.php
    index a550c38..10d341d 100644
    class Tests_List_Pages extends WP_UnitTestCase { 
    193193                $args = array(
    194194                        'echo' => true,
    195195                        'depth' => 1
    196                 );
     196                )
     197;
    197198                $expected['echo'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a></li>
    198199<li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a></li>
    199200<li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a></li>
    200201</ul></li>';
    201                 ob_start();
     202                $this->expectOutputString( $expected['echo'] );
    202203                wp_list_pages( $args );
    203                 $actual = ob_get_clean();
    204                 $this->AssertEquals( $expected['echo'], $actual );
    205204        }
    206205
    207206        function test_wp_list_pages_authors() {
  • tests/phpunit/tests/post/thumbnails.php

    diff --git tests/phpunit/tests/post/thumbnails.php tests/phpunit/tests/post/thumbnails.php
    index 593bfe7..85f67a8 100644
    class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { 
    126126
    127127                set_post_thumbnail( $post_id, $attachment_id );
    128128
    129                 ob_start();
     129                $this->expectOutputString( $caption );
    130130                the_post_thumbnail_caption( $post_id );
    131 
    132                 $this->assertEquals( $caption, ob_get_clean() );
    133131        }
    134132
    135133        function test_get_the_post_thumbnail() {
    class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { 
    149147        }
    150148
    151149        function test_the_post_thumbnail() {
    152                 ob_start();
    153                 the_post_thumbnail();
    154                 $actual = ob_get_clean();
    155150
    156                 $this->assertEquals( '', $actual );
     151                $this->expectOutputString( '' );
     152                the_post_thumbnail();
    157153
    158154                $GLOBALS['post'] = self::$post;
    159155
    160                 ob_start();
     156                $this->expectOutputString( '' );
    161157                the_post_thumbnail();
    162                 $actual = ob_get_clean();
    163 
    164                 $this->assertEquals( '', $actual );
    165158
    166159                set_post_thumbnail( self::$post, self::$attachment_id );
    167160
    class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { 
    169162                        'class' => 'attachment-post-thumbnail size-post-thumbnail wp-post-image'
    170163                ) );
    171164
    172                 ob_start();
     165                $this->expectOutputString( $expected );
    173166                the_post_thumbnail();
    174                 $actual = ob_get_clean();
    175 
    176                 $this->assertEquals( $expected, $actual );
    177167        }
    178168
    179169        /**
    class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { 
    214204        function test_the_post_thumbnail_url() {
    215205                $GLOBALS['post'] = self::$post;
    216206
    217                 ob_start();
     207                $this->expectOutputString( '' );
    218208                the_post_thumbnail_url();
    219                 $actual = ob_get_clean();
    220 
    221                 $this->assertEmpty( $actual );
    222 
    223                 ob_start();
    224                 the_post_thumbnail_url();
    225                 $actual = ob_get_clean();
    226 
    227                 $this->assertEmpty( $actual );
    228209
    229210                set_post_thumbnail( self::$post, self::$attachment_id );
    230211
    231                 ob_start();
     212                $this->expectOutputString( wp_get_attachment_url( self::$attachment_id ) );
    232213                the_post_thumbnail_url();
    233                 $actual = ob_get_clean();
    234 
    235                 $this->assertEquals( wp_get_attachment_url( self::$attachment_id ), $actual );
    236214        }
    237215
    238216        /**
  • tests/phpunit/tests/taxonomy.php

    diff --git tests/phpunit/tests/taxonomy.php tests/phpunit/tests/taxonomy.php
    index b5fd536..9beb099 100644
    class Tests_Taxonomy extends WP_UnitTestCase { 
    6565
    6666        function test_the_taxonomies() {
    6767                $post_id = self::factory()->post->create();
    68 
    69                 ob_start();
     68                $this->expectOutputString( sprintf( 'Categories: <a href="%s">Uncategorized</a>.', get_category_link( 1 ) ) );
    7069                the_taxonomies( array( 'post' => $post_id ) );
    71                 $output = ob_get_clean();
    72 
    73                 $link = get_category_link( 1 );
    74                 $expected = 'Categories: <a href="' . $link . '">Uncategorized</a>.';
    75                 $this->assertEquals( $expected, $output );
    7670        }
    7771
    7872        /**
  • tests/phpunit/tests/user/listAuthors.php

    diff --git tests/phpunit/tests/user/listAuthors.php tests/phpunit/tests/user/listAuthors.php
    index 1a5ac36..367bbe1 100644
    class Tests_User_ListAuthors extends WP_UnitTestCase { 
    7979
    8080        function test_wp_list_authors_echo() {
    8181                $expected['echo'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>';
    82                 ob_start();
     82                $this->expectOutputString( $expected['echo'] );
    8383                wp_list_authors( array( 'echo' => true ) );
    84                 $actual = ob_get_clean();
    85                 $this->AssertEquals( $expected['echo'], $actual );
    8684        }
    8785
    8886        function test_wp_list_authors_feed() {