Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2024 06:58:50 PM (6 months ago)
Author:
espellcaste
Message:

Blogs: blog_id is accepted in the bp_get_blog_avatar, regardless if there is a blog in the current loop.

Props imath.

Closes https://github.com/buddypress/buddypress/pull/398
Fixes #9228

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/blogs/template.php

    r14026 r14072  
    444444    }
    445445
     446    /**
     447     * @BP9228
     448     * @group avatar
     449     * @group BP_Blogs_Template
     450     * @group bp_get_blog_avatar
     451     */
     452    public function test_bp_get_blog_default_avatar_inside_blogs_template() {
     453        $this->skipWithoutMultisite();
     454
     455        $b1 = self::factory()->blog->create();
     456        $b2 = self::factory()->blog->create();
     457
     458        // Fake the global
     459        global $blogs_template;
     460
     461        $blogs_template = new stdClass;
     462        $blogs_template->blog = new stdClass;
     463        $blogs_template->blog->blog_id = $b1;
     464
     465        $expected = buddypress()->plugin_url . "bp-core/images/mystery-blog.png";
     466
     467        // Get from global blog_id.
     468        $avatar = bp_get_blog_avatar();
     469        $this->assertTrue( str_contains( $avatar, "blog-{$b1}-avatar" ) );
     470        $this->assertTrue( str_contains( $avatar, $expected ) );
     471
     472        // Get from the blog_id passed in, instead of global.
     473        $avatar = bp_get_blog_avatar( array( 'blog_id' => $b2 ) );
     474        $this->assertTrue( str_contains( $avatar, "blog-{$b2}-avatar" ) );
     475        $this->assertTrue( str_contains( $avatar, $expected ) );
     476
     477        $blogs_template = null;
     478    }
     479
    446480    public function filter_blog_avatar() {
    447481        return BP_TESTS_DIR . 'assets/upside-down.jpg';
Note: See TracChangeset for help on using the changeset viewer.