Make WordPress Core

Ticket #4969: 4969.3.tests.diff

File 4969.3.tests.diff, 3.1 KB (added by igmoweb, 10 years ago)

Unit tests

  • tests/phpunit/tests/functions/getArchives.php

     
    121121                $archives = wp_get_archives( array( 'echo' => false, 'post_type' => 'taco' ) );
    122122                $this->assertEquals( $expected, trim( $archives ) );
    123123        }
     124
     125        /**
     126         * @ticket 4969
     127         */
     128        function test_wp_get_archives_title() {
     129                $expected = "<h1>Archives Title</h1>\t<li><a href='$this->month_url'>" . date( 'F Y' ) . "</a></li>";
     130                $result = trim( wp_get_archives(
     131                        array(
     132                                'echo'  => false,
     133                                'title' => 'Archives Title',
     134                                'title_before' => '<h1>',
     135                                'title_after' => '</h1>',
     136                        )
     137                ) );
     138
     139                $this->assertEquals( $expected, $result );
     140        }
     141
     142        /**
     143         * @ticket 4969
     144         */
     145        function test_wp_get_archives_before_and_after_list() {
     146                $date = date( 'F Y' );
     147                $expected = <<<EOF
     148<ul>\t<li><a href='$this->month_url'>$date</a></li>
     149</ul>
     150EOF;
     151                $result = trim( wp_get_archives(
     152                        array(
     153                                'echo'  => false,
     154                                'list_before' => '<ul>',
     155                                'list_after' => '</ul>',
     156                        )
     157                ) );
     158
     159                $this->assertEquals( $expected, $result );
     160        }
    124161}
  • tests/phpunit/tests/post/listPages.php

     
    342342                $actual = wp_list_pages( $args );
    343343                $this->AssertEquals( $expected['exclude'], $actual );
    344344        }
     345
     346        /**
     347         * @ticket 4969
     348         */
     349        function test_wp_get_pages_before_and_after() {
     350                $expected = '<div>The Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a>
     351<ul class=\'children\'>
     352        <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a></li>
     353        <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a></li>
     354        <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a></li>
     355</ul>
     356</li>
     357<li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a>
     358<ul class=\'children\'>
     359        <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a></li>
     360        <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a></li>
     361        <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a></li>
     362</ul>
     363</li>
     364<li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a>
     365<ul class=\'children\'>
     366        <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a></li>
     367        <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a></li>
     368        <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a></li>
     369</ul>
     370</li>
     371</ul></div>';
     372
     373                $result = trim( wp_list_pages(
     374                        array(
     375                                'echo'  => false,
     376                                'before' => '<div>',
     377                                'after' => '</div>',
     378                                'title_li' => 'The Pages'
     379                        )
     380                ) );
     381
     382                $this->assertEquals( $expected, $result );
     383        }
    345384}