Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/14/2016 04:48:29 AM (9 years ago)
Author:
boonebgorges
Message:

Default no_grav avatars should be thumb-sized when appropriate.

mystery-man-50.jpg should be served when:

  • A 'thumb' is requested, and the thumb width set in the config is 50 pixels or less, or
  • An avatar with a width of 50 or less is requested.

Props r0z.
Fixes #7056.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/avatars.php

    r10370 r10754  
    315315        return $types;
    316316    }
     317
     318    /**
     319     * @group BP7056
     320     */
     321    public function test_no_grav_default_should_respect_thumb_type() {
     322        $found = bp_core_fetch_avatar( array(
     323            'item_id' => 12345,
     324            'object' => 'user',
     325            'type' => 'thumb',
     326            'no_grav' => true,
     327            'html' => false,
     328        ) );
     329
     330        $this->assertContains( 'mystery-man-50.jpg', $found );
     331    }
     332
     333    /**
     334     * @group BP7056
     335     */
     336    public function test_no_grav_default_should_return_thumb_avatar_for_small_enough_width() {
     337        $found = bp_core_fetch_avatar( array(
     338            'item_id' => 12345,
     339            'object' => 'user',
     340            'type' => 'full',
     341            'width' => '50',
     342            'no_grav' => true,
     343            'html' => false,
     344        ) );
     345
     346        $this->assertContains( 'mystery-man-50.jpg', $found );
     347    }
     348
     349    /**
     350     * @group BP7056
     351     */
     352    public function test_no_grav_default_should_return_full_avatar_for_thumb_when_thumb_width_is_too_wide() {
     353        add_filter( 'bp_core_avatar_thumb_width', array( $this, 'filter_thumb_width' ) );
     354        $found = bp_core_fetch_avatar( array(
     355            'item_id' => 12345,
     356            'object' => 'user',
     357            'type' => 'thumb',
     358            'no_grav' => true,
     359            'html' => false,
     360        ) );
     361        remove_filter( 'bp_core_avatar_thumb_width', array( $this, 'filter_thumb_width' ) );
     362
     363        $this->assertContains( 'mystery-man.jpg', $found );
     364    }
     365
     366    public function filter_thumb_width() {
     367        return 51;
     368    }
    317369}
Note: See TracChangeset for help on using the changeset viewer.