Skip to:
Content

BuddyPress.org

Ticket #4680: 4680.tests.diff

File 4680.tests.diff, 1.6 KB (added by ninnypants, 6 years ago)
  • tests/testcases/activity/functions.php

    diff --git tests/testcases/activity/functions.php tests/testcases/activity/functions.php
    index 1184247..7ff4f7d 100644
    Bar!'; 
    522522                remove_filter( 'bp_is_username_compatibility_mode', '__return_true' );
    523523        }
    524524
     525        /**
     526         * @group mentions
     527         */
     528        public function test_at_name_filter() {
     529                $u = $this->create_user( array(
     530                        'user_login' => 'foobarbaz',
     531                        'user_nicename' => 'foobarbaz',
     532                ) );
     533
     534                $user_mention_name = bp_activity_get_user_mentionname( $u );
     535                $user_domain = bp_core_get_user_domain( $u );
     536
     537                // mentions normal text should be replaced
     538                $at_name_in_text = sprintf( 'Hello @%s', $user_mention_name );
     539                $at_name_in_text_final = "<p>Hello <a href='" . $user_domain . "' rel='nofollow'>@$user_mention_name</a></p>\n";
     540                $this->assertEquals( $at_name_in_text_final, apply_filters( 'the_content', $at_name_in_text ) );
     541
     542                // mentions inside links sholudn't be replaced
     543                $at_name_in_mailto = sprintf( "Send messages to <a href='mail@%s.com'>Foo Bar Baz</a>", $user_mention_name );
     544                $at_name_in_mailto_final = sprintf( "<p>Send messages to <a href='mail@%s.com'>Foo Bar Baz</a></p>\n", $user_mention_name );
     545                $this->assertEquals( $at_name_in_mailto_final, apply_filters( 'the_content', $at_name_in_mailto ) );
     546
     547                $at_name_in_link = sprintf( '<a href="https://twitter.com/%1$s">@%1$s</a>', $user_mention_name );
     548                $at_name_in_link_final = sprintf( '<p><a href="https://twitter.com/%1$s">@%1$s</a></p>' . "\n", $user_mention_name );
     549                $this->assertEquals( $at_name_in_link_final, apply_filters( 'the_content', $at_name_in_link ) );
     550        }
     551
    525552}