Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/10/2014 01:37:05 AM (10 years ago)
Author:
boonebgorges
Message:

Introduce 'latest_format' param for bp_get_blog_latest_post()

This param allows themers to omit BP's 'Latest post: %s' wrapper around the
link to the latest post.

Fixes #5392

Props lenasterg

File:
1 edited

Legend:

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

    r8407 r8408  
    6262        $this->assertEquals( __( 'Never active', 'buddypress' ), bp_get_blog_last_active() );
    6363    }
     64
     65    /**
     66     * @group bp_get_blog_latest_post
     67     */
     68    public function test_bp_get_blog_latest_post_default_params() {
     69        // Fake the global
     70        global $blogs_template;
     71
     72        $blogs_template = new stdClass;
     73        $blogs_template->blog = new stdClass;
     74        $blogs_template->blog->latest_post = new stdClass;
     75        $blogs_template->blog->latest_post->guid = 'foo';
     76        $blogs_template->blog->latest_post->post_title = 'bar';
     77
     78        $this->assertSame( sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="foo">bar</a>' ), bp_get_blog_latest_post() );
     79
     80        $blogs_template->blog = null;
     81    }
     82
     83    /**
     84     * @group bp_get_blog_latest_post
     85     */
     86    public function test_bp_get_blog_latest_post_latest_format_true() {
     87        // Fake the global
     88        global $blogs_template;
     89
     90        $blogs_template = new stdClass;
     91        $blogs_template->blog = new stdClass;
     92        $blogs_template->blog->latest_post = new stdClass;
     93        $blogs_template->blog->latest_post->guid = 'foo';
     94        $blogs_template->blog->latest_post->post_title = 'bar';
     95
     96        $this->assertSame( sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="foo">bar</a>' ), bp_get_blog_latest_post( array( 'latest_format' => true, ) ) );
     97
     98        $blogs_template->blog = null;
     99    }
     100
     101    /**
     102     * @group bp_get_blog_latest_post
     103     */
     104    public function test_bp_get_blog_latest_post_latest_format_false() {
     105        // Fake the global
     106        global $blogs_template;
     107
     108        $blogs_template = new stdClass;
     109        $blogs_template->blog = new stdClass;
     110        $blogs_template->blog->latest_post = new stdClass;
     111        $blogs_template->blog->latest_post->guid = 'foo';
     112        $blogs_template->blog->latest_post->post_title = 'bar';
     113
     114        $this->assertSame( '<a href="foo">bar</a>', bp_get_blog_latest_post( array( 'latest_format' => false, ) ) );
     115
     116        $blogs_template->blog = null;
     117    }
    64118}
Note: See TracChangeset for help on using the changeset viewer.