wordpress-activitypub/tests/test-class-activitypub-hashtag.php

33 lines
1.5 KiB
PHP
Raw Normal View History

2019-08-18 22:08:58 +02:00
<?php
class Test_Activitypub_Hashtag extends WP_UnitTestCase {
/**
* @dataProvider the_content_provider
*/
public function test_the_content( $content, $content_with_hashtag ) {
$content = \Activitypub\Hashtag::the_content( $content );
$this->assertEquals( $content_with_hashtag, $content );
}
public function the_content_provider() {
2020-05-12 20:30:06 +02:00
\wp_create_term( 'object', 'post_tag' );
$object = \get_term_by( 'name', 'object', 'post_tag' );
$link = \get_term_link( $object, 'post_tag' );
2019-08-18 22:23:34 +02:00
2019-08-18 22:24:34 +02:00
return array(
array( 'test', 'test' ),
array( '#test', '#test' ),
array( 'hallo #test test', 'hallo #test test' ),
2019-08-18 22:34:28 +02:00
array( 'hallo #object test', 'hallo <a rel="tag" class="u-tag u-category" href="' . $link . '">#object</a> test' ),
2019-09-27 10:12:59 +02:00
array( '#object test', '<a rel="tag" class="u-tag u-category" href="' . $link . '">#object</a> test' ),
array( 'hallo <a href="http://test.test/#object">test</a> test', 'hallo <a href="http://test.test/#object">test</a> test' ),
array( 'hallo <a href="http://test.test/#object">#test</a> test', 'hallo <a href="http://test.test/#object">#test</a> test' ),
array( '<div>hallo #object test</div>', '<div>hallo <a rel="tag" class="u-tag u-category" href="' . $link . '">#object</a> test</div>' ),
array( '<div>hallo #object</div>', '<div>hallo <a rel="tag" class="u-tag u-category" href="' . $link . '">#object</a></div>' ),
array( '<div>#object</div>', '<div>#object</div>' ),
array( '<a>#object</a>', '<a>#object</a>' ),
array( '<div style="color: #ccc;">object</a>', '<div style="color: #ccc;">object</a>' ),
2019-08-18 22:24:34 +02:00
);
2019-08-18 22:08:58 +02:00
}
}