Make WordPress Core

Changeset 34687


Ignore:
Timestamp:
09/29/2015 05:37:00 AM (11 years ago)
Author:
DrewAPicture
Message:

Tests: Consolidate author-template tests into a single, more logically-placed file, tests/user/author.php.

See #34070.

Location:
trunk/tests/phpunit/tests
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user/author.php

    r31098 r34687  
    22
    33/**
    4  * Test functions in wp-includes/author.php, author-template.php
     4 * Test functions in wp-includes/author-template.php
    55 *
    66 * @group author
    77 * @group user
    88 */
    9 class Tests_User_Author extends WP_UnitTestCase {
    10         protected $old_post_id = 0;
     9class Tests_User_Author_Template extends WP_UnitTestCase {
    1110        protected $author_id = 0;
    1211        protected $post_id = 0;
    1312
     13        private $permalink_structure;
     14
    1415        function setUp() {
    1516                parent::setUp();
     17
     18                global $wp_rewrite;
     19                $this->permalink_structure = get_option( 'permalink_structure' );
     20                $wp_rewrite->set_permalink_structure( '' );
     21                $wp_rewrite->flush_rules();
    1622
    1723                $this->author_id = $this->factory->user->create( array(
    … …  
    3743
    3844        function tearDown() {
     45                global $wp_rewrite;
     46                $wp_rewrite->set_permalink_structure( $this->permalink_structure );
     47                $wp_rewrite->flush_rules();
     48
    3949                wp_reset_postdata();
    4050                parent::tearDown();
    … …  
    100110                _unregister_post_type( 'wptests_pt' );
    101111        }
     112
     113        /**
     114         * @ticket 30355
     115         */
     116        public function test_get_the_author_posts_link_no_permalinks() {
     117                $author = $this->factory->user->create_and_get( array(
     118                        'display_name'  => 'Foo',
     119                        'user_nicename' => 'bar'
     120                ) );
     121
     122                $GLOBALS['authordata'] = $author->data;
     123
     124                $link = get_the_author_posts_link();
     125
     126                $url = sprintf( 'http://%1$s/?author=%2$s', WP_TESTS_DOMAIN, $author->ID );
     127
     128                $this->assertContains( $url, $link );
     129                $this->assertContains( 'Posts by Foo', $link );
     130                $this->assertContains( '>Foo</a>', $link );
     131
     132                unset( $GLOBALS['authordata'] );
     133        }
     134
     135        /**
     136         * @ticket 30355
     137         */
     138        public function test_get_the_author_posts_link_with_permalinks() {
     139                global $wp_rewrite;
     140                $wp_rewrite->init();
     141                $wp_rewrite->set_permalink_structure( '/%postname%/' );
     142                $wp_rewrite->flush_rules();
     143
     144                $author = $this->factory->user->create_and_get( array(
     145                        'display_name'  => 'Foo',
     146                        'user_nicename' => 'bar'
     147                ) );
     148
     149                $GLOBALS['authordata'] = $author;
     150
     151                $link = get_the_author_posts_link();
     152
     153                $url = sprintf( 'http://%1$s/author/%2$s/', WP_TESTS_DOMAIN, $author->user_nicename );
     154
     155                $this->assertContains( $url, $link );
     156                $this->assertContains( 'Posts by Foo', $link );
     157                $this->assertContains( '>Foo</a>', $link );
     158
     159                unset( $GLOBALS['authordata'] );
     160        }
     161
    102162}
Note: See TracChangeset for help on using the changeset viewer.