array( 'url' => 'https://example.org/users/username', 'name' => 'username', ), ); /** * @dataProvider the_content_provider */ public function test_the_content( $content, $content_with_mention ) { add_filter( 'pre_get_remote_metadata_by_actor', array( get_called_class(), 'pre_get_remote_metadata_by_actor' ), 10, 2 ); $content = \Activitypub\Mention::the_content( $content ); remove_filter( 'pre_get_remote_metadata_by_actor', array( get_called_class(), 'pre_get_remote_metadata_by_actor' ) ); $this->assertEquals( $content_with_mention, $content ); } public function the_content_provider() { $code = 'hallo @username@example.org test'; $pre = << Please don't mention @username@example.org here. ENDPRE; return array( array( 'hallo @username@example.org test', 'hallo @username test' ), array( 'hallo @pfefferle@notiz.blog test', 'hallo @pfefferle test' ), array( 'hallo @pfefferle@notiz.blog test', 'hallo @pfefferle@notiz.blog test' ), array( 'hallo @pfefferle@notiz.blog test', 'hallo @pfefferle@notiz.blog test' ), array( 'hallo @pfefferle@notiz.blog test', 'hallo @pfefferle@notiz.blog test' ), array( $code, $code ), array( $pre, $pre ), ); } public static function pre_get_remote_metadata_by_actor( $pre, $actor ) { $actor = ltrim( $actor, '@' ); if ( isset( self::$users[ $actor ] ) ) { return self::$users[ $actor ]; } return $pre; } }