Make WordPress Core


Ignore:
Timestamp:
10/17/2015 07:24:20 PM (11 years ago)
Author:
wonderboymusic
Message:

Unit Tests: WP_UnitTest_Generator_Sequence needs a static incrementer - otherwise, it assumes every test class is a reset, which it no longer is (it is now static).

While we're at it, remove unnecessary tearDown() code.

See #30017, #33968.

File:
1 edited

Legend:

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

    r35242 r35244  
    55 */
    66class Tests_User_ListAuthors extends WP_UnitTestCase {
    7         static $users = array();
     7        static $user_ids = array();
    88        static $fred_id;
    99        static $posts = array();
    … …  
    2525                */
    2626        public static function wpSetUpBeforeClass( $factory ) {
    27                 self::$users[] = $factory->user->create( array( 'user_login' => 'zack', 'display_name' => 'zack', 'role' => 'author', 'first_name' => 'zack', 'last_name' => 'moon' ) );
    28                 self::$users[] = $factory->user->create( array( 'user_login' => 'bob', 'display_name' => 'bob', 'role' => 'author', 'first_name' => 'bob', 'last_name' => 'reno' ) );
    29                 self::$users[] = $factory->user->create( array( 'user_login' => 'paul', 'display_name' => 'paul', 'role' => 'author', 'first_name' => 'paul', 'last_name' => 'norris' ) );
     27                self::$user_ids[] = $factory->user->create( array( 'user_login' => 'zack', 'display_name' => 'zack', 'role' => 'author', 'first_name' => 'zack', 'last_name' => 'moon' ) );
     28                self::$user_ids[] = $factory->user->create( array( 'user_login' => 'bob', 'display_name' => 'bob', 'role' => 'author', 'first_name' => 'bob', 'last_name' => 'reno' ) );
     29                self::$user_ids[] = $factory->user->create( array( 'user_login' => 'paul', 'display_name' => 'paul', 'role' => 'author', 'first_name' => 'paul', 'last_name' => 'norris' ) );
    3030                self::$fred_id = $factory->user->create( array( 'user_login' => 'fred', 'role' => 'author' ) );
    3131
    3232                $count = 0;
    33                 foreach ( self::$users as $userid ) {
     33                foreach ( self::$user_ids as $userid ) {
    3434                        $count = $count + 1;
    3535                        for ( $i = 0; $i < $count; $i++ ) {
    … …  
    4242
    4343        public static function wpTearDownAfterClass() {
    44                 foreach ( array_merge( self::$users, array( self::$fred_id ) ) as $user_id ) {
     44                self::$user_ids[] = self::$fred_id;
     45
     46                foreach ( self::$user_ids as $user_id ) {
    4547                        self::delete_user( $user_id );
    4648                }
    … …  
    9799
    98100        function test_wp_list_authors_feed() {
    99                 $url0 = get_author_feed_link( self::$users[0] );
    100                 $url1 = get_author_feed_link( self::$users[1] );
    101                 $url2 = get_author_feed_link( self::$users[2] );
     101                $url0 = get_author_feed_link( self::$user_ids[0] );
     102                $url1 = get_author_feed_link( self::$user_ids[1] );
     103                $url2 = get_author_feed_link( self::$user_ids[2] );
    102104                $expected['feed'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> (<a href="' . $url1 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> (<a href="' .  $url2 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> (<a href="' . $url0 . '">link to feed</a>)</li>';
    103105                $this->AssertEquals( $expected['feed'], wp_list_authors( array( 'echo' => false, 'feed' => 'link to feed' ) ) );
    … …  
    105107
    106108        function test_wp_list_authors_feed_image() {
    107                 $url0 = get_author_feed_link( self::$users[0] );
    108                 $url1 = get_author_feed_link( self::$users[1] );
    109                 $url2 = get_author_feed_link( self::$users[2] );
     109                $url0 = get_author_feed_link( self::$user_ids[0] );
     110                $url1 = get_author_feed_link( self::$user_ids[1] );
     111                $url2 = get_author_feed_link( self::$user_ids[2] );
    110112                $expected['feed_image'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> <a href="' . $url1 . '"><img src="http://' . WP_TESTS_DOMAIN . '/path/to/a/graphic.png" style="border: none;" /></a></li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> <a href="' .  $url2 . '"><img src="http://' . WP_TESTS_DOMAIN . '/path/to/a/graphic.png" style="border: none;" /></a></li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> <a href="' .  $url0 . '"><img src="http://' . WP_TESTS_DOMAIN . '/path/to/a/graphic.png" style="border: none;" /></a></li>';
    111113                $this->AssertEquals( $expected['feed_image'], wp_list_authors( array( 'echo' => false, 'feed_image' => WP_TESTS_DOMAIN . '/path/to/a/graphic.png' ) ) );
    … …  
    116118         */
    117119        function test_wp_list_authors_feed_type() {
    118                 $url0 = get_author_feed_link( self::$users[0], 'atom' );
    119                 $url1 = get_author_feed_link( self::$users[1], 'atom' );
    120                 $url2 = get_author_feed_link( self::$users[2], 'atom' );
     120                $url0 = get_author_feed_link( self::$user_ids[0], 'atom' );
     121                $url1 = get_author_feed_link( self::$user_ids[1], 'atom' );
     122                $url2 = get_author_feed_link( self::$user_ids[2], 'atom' );
    121123                $expected['feed_type'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a> (<a href="' . $url1 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a> (<a href="' . $url2 . '">link to feed</a>)</li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a> (<a href="' . $url0 . '">link to feed</a>)</li>';
    122124                $this->AssertEquals( $expected['feed_type'], wp_list_authors( array( 'echo' => false, 'feed' => 'link to feed', 'feed_type' => 'atom' ) ) );
Note: See TracChangeset for help on using the changeset viewer.