Make WordPress Core


Ignore:
Timestamp:
05/14/2014 10:28:08 PM (9 years ago)
Author:
wonderboymusic
Message:

Eliminate use of extract() in paginate_links(). Adds unit tests. Moves tests/general/template.php (which only had one method) to tests/general/paginateLinks.php.

See #22400.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/general/paginateLinks.php

    r28396 r28397  
    11<?php
    22
    3 class Tests_General_Template extends WP_UnitTestCase {
     3class Tests_Paginate_Links extends WP_UnitTestCase {
    44
    55    private $i18n_count = 0;
     6
     7    function test_defaults() {
     8        $expected =<<<EXPECTED
     9<a class='page-numbers' href=''>1</a>
     10<span class="page-numbers dots">&hellip;</span>
     11<a class='page-numbers' href='?page=50'>50</a>
     12EXPECTED;
     13
     14        $links = paginate_links( array( 'total' => 50 ) );
     15        $this->assertEquals( $expected, $links );
     16    }
     17
     18    function test_format() {
     19        $expected =<<<EXPECTED
     20<a class='page-numbers' href=''>1</a>
     21<span class="page-numbers dots">&hellip;</span>
     22<a class='page-numbers' href='/page/50/'>50</a>
     23EXPECTED;
     24
     25        $links = paginate_links( array( 'total' => 50, 'format' => '/page/%#%/' ) );
     26        $this->assertEquals( $expected, $links );
     27    }
     28
     29    function test_prev_next_false() {
     30        $expected =<<<EXPECTED
     31<a class='page-numbers' href=''>1</a>
     32<span class='page-numbers current'>2</span>
     33<a class='page-numbers' href='?page=3'>3</a>
     34<a class='page-numbers' href='?page=4'>4</a>
     35<span class="page-numbers dots">&hellip;</span>
     36<a class='page-numbers' href='?page=50'>50</a>
     37EXPECTED;
     38
     39        $links = paginate_links( array( 'total' => 50, 'prev_next' => false, 'current' => 2 ) );
     40        $this->assertEquals( $expected, $links );
     41    }
     42
     43    function test_prev_next_true() {
     44        $expected =<<<EXPECTED
     45<a class="prev page-numbers" href="">&laquo; Previous</a>
     46<a class='page-numbers' href=''>1</a>
     47<span class='page-numbers current'>2</span>
     48<a class='page-numbers' href='?page=3'>3</a>
     49<a class='page-numbers' href='?page=4'>4</a>
     50<span class="page-numbers dots">&hellip;</span>
     51<a class='page-numbers' href='?page=50'>50</a>
     52<a class="next page-numbers" href="?page=3">Next &raquo;</a>
     53EXPECTED;
     54
     55        $links = paginate_links( array( 'total' => 50, 'prev_next' => true, 'current' => 2 ) );
     56        $this->assertEquals( $expected, $links );
     57    }
    658
    759    function increment_i18n_count() {
     
    2880        remove_filter( 'number_format_i18n', array( $this, 'increment_i18n_count' ) );
    2981    }
    30 
    3182}
Note: See TracChangeset for help on using the changeset viewer.