Skip to:
Content

BuddyPress.org

Ticket #4680: 4680.tests.1.2.diff

File 4680.tests.1.2.diff, 2.1 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..d4b1b71 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                $u1 = $this->create_user( array(
     530                        'user_login' => 'foobarbaz',
     531                        'user_nicename' => 'foobarbaz',
     532                        'user_email' => 'test@example.org',
     533                ) );
     534
     535                $u2 = $this->create_user( array(
     536                        'user_login' => 'test2@example.org',
     537                        'user_nicename' => 'foo-bar-baz',
     538                        'user_email' => 'test2@example.org',
     539                ) );
     540
     541                $user_mention_name = bp_activity_get_user_mentionname( $u1 );
     542                $user_domain = bp_core_get_user_domain( $u1 );
     543
     544                // mentions normal text should be replaced
     545                $at_name_in_text = sprintf( 'Hello @%s', $user_mention_name );
     546                $at_name_in_text_final = "<p>Hello <a href='" . $user_domain . "' rel='nofollow'>@$user_mention_name</a></p>\n";
     547                $this->assertEquals( $at_name_in_text_final, apply_filters( 'the_content', $at_name_in_text ) );
     548
     549                // non users shouldn't be linked
     550                $this->assertEquals( "<p>Content with @example.org shouldn&#8217;t link @example.org</p>\n", apply_filters( 'the_content', "Content with @example.org shouldn't link @example.org" ) );
     551
     552                // mentions inside links sholudn't be replaced
     553                $at_name_in_mailto = sprintf( "Send messages to <a href='mail@%s.com'>Foo Bar Baz</a>", $user_mention_name );
     554                $at_name_in_mailto_final = sprintf( "<p>Send messages to <a href='mail@%s.com'>Foo Bar Baz</a></p>\n", $user_mention_name );
     555                $this->assertEquals( $at_name_in_mailto_final, apply_filters( 'the_content', $at_name_in_mailto ) );
     556
     557                $at_name_in_link = sprintf( '<a href="https://twitter.com/%1$s">@%1$s</a>', $user_mention_name );
     558                $at_name_in_link_final = sprintf( '<p><a href="https://twitter.com/%1$s">@%1$s</a></p>' . "\n", $user_mention_name );
     559                $this->assertEquals( $at_name_in_link_final, apply_filters( 'the_content', $at_name_in_link ) );
     560        }
     561
    525562}