URLs in unit tests need to be generated, not hard-coded.

See #28706.


git-svn-id: https://develop.svn.wordpress.org/trunk@28960 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2014-07-02 19:44:08 +00:00
parent 4a480146c0
commit 59b255c445

View File

@ -32,15 +32,19 @@ class Tests_Get_Archives extends WP_UnitTestCase {
function test_wp_get_archives_limit() {
$ids = array_slice( array_reverse( $this->post_ids ), 0, 5 );
$expected['limit'] = <<<EOF
<li><a href='http://{WP_TESTS_DOMAIN}/?p={$ids[0]}'>Post title 8</a></li>
<li><a href='http://{WP_TESTS_DOMAIN}/?p={$ids[1]}'>Post title 7</a></li>
<li><a href='http://{WP_TESTS_DOMAIN}/?p={$ids[2]}'>Post title 6</a></li>
<li><a href='http://{WP_TESTS_DOMAIN}/?p={$ids[3]}'>Post title 5</a></li>
<li><a href='http://{WP_TESTS_DOMAIN}/?p={$ids[4]}'>Post title 4</a></li>
EOF;
$expected['limit'] = str_replace( '{WP_TESTS_DOMAIN}', WP_TESTS_DOMAIN, $expected['limit'] );
$link1 = get_permalink( $ids[0] );
$link2 = get_permalink( $ids[1] );
$link3 = get_permalink( $ids[2] );
$link4 = get_permalink( $ids[3] );
$link5 = get_permalink( $ids[4] );
$expected['limit'] = <<<EOF
<li><a href='$link1'>Post title 8</a></li>
<li><a href='$link2'>Post title 7</a></li>
<li><a href='$link3'>Post title 6</a></li>
<li><a href='$link4'>Post title 5</a></li>
<li><a href='$link5'>Post title 4</a></li>
EOF;
$this->assertEquals( $expected['limit'], trim( wp_get_archives( array( 'echo' => false, 'type' => 'postbypost', 'limit' => 5 ) ) ) );
}