Make WordPress Core


Ignore:
Timestamp:
01/12/2015 02:23:43 AM (11 years ago)
Author:
jeremyfelt
Message:

Check for existence of data from get_blogaddress_by_id() before returning a URL

  • Prevent a notice when an invalid ID is used with get_blogaddres_by_id().
  • Return a falsy empty string rather than the previous "http://".
  • Add unit tests for get_blogaddress_by_id().

Props nerrad.

Fixes #30566.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/site.php

    r31155 r31157  
    333333        $this->assertFalse( $result );
    334334    }
    335    
     335
    336336    function test_update_blog_details() {
    337337        $blog_id = $this->factory->blog->create();
     
    14621462        remove_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 );
    14631463    }
     1464
     1465    /**
     1466     * Tests returning an address for a given valid id.
     1467     */
     1468    function test_get_blogaddress_by_id_with_valid_id() {
     1469        $blogaddress = get_blogaddress_by_id( 1 );
     1470        $this->assertEquals( 'http://example.org/', $blogaddress );
     1471    }
     1472
     1473    /**
     1474     * Tests returning the appropriate response for a invalid id given.
     1475     */
     1476    function test_get_blogaddress_by_id_with_invalid_id() {
     1477        $blogaddress = get_blogaddress_by_id( 42 );
     1478        $this->assertEquals( '', $blogaddress );
     1479    }
    14641480}
    14651481
Note: See TracChangeset for help on using the changeset viewer.