Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/06/2015 09:14:50 PM (10 years ago)
Author:
boonebgorges
Message:

Don't let bp_create_excerpt() truncate to empty strings.

When the first word of a string is longer than the $length param, the word
should be truncated mid-word, even if exact=false.

Fixes #6254.

File:
1 edited

Legend:

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

    r9523 r9707  
    4141        ) ) );
    4242    }
     43
     44    public function test_should_break_on_prior_word_boundary_when_exact_is_false() {
     45        $text = 'aaaaa aaaaaa';
     46        $expected = 'aaaaa';
     47        $this->assertSame( $expected, bp_create_excerpt( $text, 7, array(
     48            'exact' => false,
     49            'ending' => '',
     50        ) ) );
     51    }
     52
     53    /**
     54     * @ticket BP6254
     55     */
     56    public function test_should_trim_too_long_first_word_to_max_characters_even_when_exact_is_false() {
     57        $text = 'aaaaaaaaaaa';
     58        $expected = 'aaa';
     59        $this->assertSame( $expected, bp_create_excerpt( $text, 3, array(
     60            'exact' => false,
     61            'ending' => '',
     62        ) ) );
     63    }
    4364}
Note: See TracChangeset for help on using the changeset viewer.