Make WordPress Core

Changeset 25397


Ignore:
Timestamp:
09/12/2013 07:16:30 AM (13 years ago)
Author:
wonderboymusic
Message:
  • Fill in undefined var in Tests_Option_BlogOption
  • Add defined() check for BLOGSUPLOADDIR
  • Suppress deprecated function notices for is_blog_user() and get_dashboard_blog()
  • Check existence of $user in wpmu_log_new_registrations() before arbitrarily making a database query

Fixes all notices in multisite unit tests.

See #25282.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-functions.php

    r25229 r25397  
    14771477        global $wpdb;
    14781478        $user = get_userdata( (int) $user_id );
    1479         $wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
     1479        if ( $user )
     1480                $wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
    14801481}
    14811482
  • trunk/tests/phpunit/tests/ms.php

    r25197 r25397  
    1111
    1212        protected $plugin_hook_count = 0;
     13
     14        function setUp() {
     15                parent::setUp();
     16
     17                $_SERVER['REMOTE_ADDR'] = '';
     18                add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run_check' ) );
     19        }
     20
     21        function tearDown() {
     22                parent::tearDown();
     23                remove_action( 'deprecated_function_run', array( $this, 'deprecated_function_run_check' ) );
     24        }
     25
     26        function deprecated_function_run_check( $function ) {
     27                if ( in_array( $function, array( 'is_blog_user', 'get_dashboard_blog' ) ) )
     28                        add_filter( 'deprecated_function_trigger_error', array( $this, 'filter_deprecated_function_trigger_error' ) );
     29        }
     30
     31        function filter_deprecated_function_trigger_error() {
     32                remove_filter( 'deprecated_function_trigger_error', array( $this, 'filter_deprecated_function_trigger_error' ) );
     33                return false;
     34        }
    1335
    1436        function test_create_and_delete_blog() {
     
    309331                $this->assertTrue( is_upload_space_available() );
    310332
    311                 if ( ! file_exists( BLOGSUPLOADDIR ) )
     333                if ( defined( 'BLOGSUPLOADDIR' ) && ! file_exists( BLOGSUPLOADDIR ) )
    312334                        $this->markTestSkipped( 'This test is broken when blogs.dir does not exist. ');
    313335
     
    526548        /**
    527549         * Test fetching a blog that doesn't exist and again after it exists.
    528          * 
     550         *
    529551         * @ticket 23405
    530552         */
     
    10141036                ) );
    10151037                update_user_status( $spam_user_id, 'spam', '1' );
    1016                
     1038
    10171039                $this->assertTrue( is_user_spammy( $spam_username ) );
    10181040                $this->assertFalse( is_user_spammy( 'testuser1' ) );
  • trunk/tests/phpunit/tests/option/blogOption.php

    r25002 r25397  
    66 */
    77class Tests_Option_BlogOption extends WP_UnitTestCase {
     8        function setUp() {
     9                parent::setUp();
     10
     11                $_SERVER['REMOTE_ADDR'] = null;
     12        }
     13
    814        function test_from_same_site() {
    915                $key = rand_str();
     
    8288                global $current_site, $base;
    8389
     90                $title = 'Fooblog';
    8491                $domain = 'blogoptiontest';
    8592
Note: See TracChangeset for help on using the changeset viewer.