diff --git src/includes/users/functions.php src/includes/users/functions.php
index 569970b..6e5396f 100644
|
|
|
function bbp_current_author_ip() {
|
| 147 | 147 | // Check for remote address |
| 148 | 148 | $remote_address = ! empty( $_SERVER['REMOTE_ADDR'] ) |
| 149 | 149 | ? $_SERVER['REMOTE_ADDR'] |
| 150 | | : '0.0.0.0'; |
| | 150 | : '127.0.0.1'; |
| 151 | 151 | |
| 152 | 152 | // Remove any unsavory bits |
| 153 | 153 | $retval = preg_replace( '/[^0-9a-fA-F:., ]/', '', $remote_address ); |
diff --git tests/phpunit/includes/install.php tests/phpunit/includes/install.php
index 09a8a16..20ec273 100644
|
|
|
tests_add_filter( 'plugins_loaded', '_load_bbpress' );
|
| 31 | 31 | // Override some fussy global values |
| 32 | 32 | $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; |
| 33 | 33 | $_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN; |
| 34 | | $_SERVER['REMOTE_ADDR'] = '0.0.0.0'; |
| | 34 | $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; |
| 35 | 35 | |
| 36 | 36 | // Fix PHP identity crisis |
| 37 | 37 | $PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php'; |
diff --git tests/phpunit/includes/testcase.php tests/phpunit/includes/testcase.php
index 9935978..f6b64ba 100644
|
|
|
class BBP_UnitTestCase extends WP_UnitTestCase {
|
| 33 | 33 | if ( class_exists( 'BP_UnitTest_Factory' ) ) { |
| 34 | 34 | $this->bp_factory = new BP_UnitTest_Factory(); |
| 35 | 35 | } |
| | 36 | |
| | 37 | // Our default is ugly permalinks, so reset when needed. |
| | 38 | global $wp_rewrite; |
| | 39 | if ( $wp_rewrite->permalink_structure ) { |
| | 40 | $this->set_permalink_structure(); |
| | 41 | } |
| 36 | 42 | } |
| 37 | 43 | |
| 38 | 44 | function clean_up_global_scope() { |
| … |
… |
class BBP_UnitTestCase extends WP_UnitTestCase {
|
| 340 | 346 | global $wpdb; |
| 341 | 347 | $wpdb->query( 'COMMIT;' ); |
| 342 | 348 | } |
| | 349 | |
| | 350 | /** |
| | 351 | * Utility method that resets permalinks and flushes rewrites. |
| | 352 | * |
| | 353 | * @since 2.6.0 bbPress (rXXXX) |
| | 354 | * |
| | 355 | * @global WP_Rewrite $wp_rewrite |
| | 356 | * |
| | 357 | * @uses WP_UnitTestCase::set_permalink_structure() |
| | 358 | * |
| | 359 | * @param string $structure Optional. Permalink structure to set. Default empty. |
| | 360 | */ |
| | 361 | public function set_permalink_structure( $structure = '' ) { |
| | 362 | |
| | 363 | // Use WP 4.4+'s version if it exists. |
| | 364 | if ( method_exists( 'parent', 'set_permalink_structure' ) ) { |
| | 365 | parent::set_permalink_structure( $structure ); |
| | 366 | } else { |
| | 367 | global $wp_rewrite; |
| | 368 | |
| | 369 | $wp_rewrite->init(); |
| | 370 | $wp_rewrite->set_permalink_structure( $structure ); |
| | 371 | $wp_rewrite->flush_rules(); |
| | 372 | } |
| | 373 | } |
| 343 | 374 | } |
diff --git tests/phpunit/testcases/core/update.php tests/phpunit/testcases/core/update.php
index b4b848c..eebb360 100644
|
|
|
class BBP_Tests_Core_Update extends BBP_UnitTestCase {
|
| 131 | 131 | $this->assertSame( '1 day, 16 hours ago', bbp_get_forum_last_active_time( $forum_id ) ); |
| 132 | 132 | |
| 133 | 133 | // Topic meta |
| 134 | | $this->assertSame( '0.0.0.0', bbp_current_author_ip( $topic_id ) ); |
| | 134 | $this->assertSame( '127.0.0.1', bbp_current_author_ip( $topic_id ) ); |
| 135 | 135 | $this->assertSame( $forum_id, bbp_get_topic_forum_id( $topic_id ) ); |
| 136 | 136 | $this->assertSame( 1, bbp_get_topic_voice_count( $topic_id, true ) ); |
| 137 | 137 | $this->assertSame( 1, bbp_get_topic_reply_count( $topic_id, true ) ); |
| … |
… |
class BBP_Tests_Core_Update extends BBP_UnitTestCase {
|
| 141 | 141 | $this->assertSame( '1 day, 16 hours ago', bbp_get_topic_last_active_time( $topic_id ) ); |
| 142 | 142 | |
| 143 | 143 | // Reply Meta |
| 144 | | $this->assertSame( '0.0.0.0', bbp_current_author_ip( $reply_id ) ); |
| | 144 | $this->assertSame( '127.0.0.1', bbp_current_author_ip( $reply_id ) ); |
| 145 | 145 | $this->assertSame( $forum_id, bbp_get_reply_forum_id( $reply_id ) ); |
| 146 | 146 | $this->assertSame( $topic_id, bbp_get_reply_topic_id( $reply_id ) ); |
| 147 | 147 | } |
diff --git tests/phpunit/testcases/forums/functions/forum.php tests/phpunit/testcases/forums/functions/forum.php
index 3c3b25d..0d9d917 100644
|
|
|
class BBP_Tests_Forums_Functions_Forum extends BBP_UnitTestCase {
|
| 15 | 15 | */ |
| 16 | 16 | public function test_bbp_insert_forum() { |
| 17 | 17 | |
| 18 | | $f = $this->factory->forum->create(); |
| | 18 | $f = $this->factory->forum->create( array( |
| | 19 | 'post_title' => 'Forum 1', |
| | 20 | 'post_content' => 'Content of Forum 1', |
| | 21 | ) ); |
| 19 | 22 | |
| 20 | 23 | $now = time(); |
| 21 | 24 | $post_date = date( 'Y-m-d H:i:s', $now - 60 * 60 * 100 ); |
diff --git tests/phpunit/testcases/forums/functions/query.php tests/phpunit/testcases/forums/functions/query.php
index e711291..bbc0eb0 100644
|
|
|
class BBP_Tests_Forums_Functions_Query extends BBP_UnitTestCase {
|
| 47 | 47 | ), |
| 48 | 48 | ) ); |
| 49 | 49 | |
| 50 | | $this->assertEquals( array( $t1, $t2, $t3 ), bbp_forum_query_topic_ids( $f ) ); |
| | 50 | $this->assertEqualSets( array( $t1, $t2, $t3 ), bbp_forum_query_topic_ids( $f ) ); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| … |
… |
class BBP_Tests_Forums_Functions_Query extends BBP_UnitTestCase {
|
| 64 | 64 | 'post_parent' => $f1, |
| 65 | 65 | ) ); |
| 66 | 66 | |
| 67 | | $this->assertEquals( array( $f2, $f3 ), bbp_forum_query_subforum_ids( $f1 ) ); |
| | 67 | $this->assertEqualSets( array( $f2, $f3 ), bbp_forum_query_subforum_ids( $f1 ) ); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
diff --git tests/phpunit/testcases/forums/template/feeds.php tests/phpunit/testcases/forums/template/feeds.php
index c51e351..acf06ab 100644
|
|
|
class BBP_Tests_Forums_Template_Feeds extends BBP_UnitTestCase {
|
| 19 | 19 | $this->markTestSkipped( 'Skipping URL tests in multiste for now.' ); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | | $f = $this->factory->forum->create(); |
| | 22 | $f = $this->factory->forum->create( array( |
| | 23 | 'post_title' => 'Forum 1', |
| | 24 | ) ); |
| 23 | 25 | |
| 24 | 26 | $feed_link = bbp_get_forum_topics_feed_link( $f ); |
| 25 | 27 | $this->expectOutputString( $feed_link ); |
| … |
… |
class BBP_Tests_Forums_Template_Feeds extends BBP_UnitTestCase {
|
| 39 | 41 | $this->markTestSkipped( 'Skipping URL tests in multiste for now.' ); |
| 40 | 42 | } |
| 41 | 43 | |
| 42 | | $f = $this->factory->forum->create(); |
| | 44 | $f = $this->factory->forum->create( array( |
| | 45 | 'post_title' => 'Forum 1', |
| | 46 | ) ); |
| 43 | 47 | |
| 44 | 48 | $feed_link = bbp_get_forum_replies_feed_link( $f ); |
| 45 | 49 | $this->expectOutputString( $feed_link ); |
diff --git tests/phpunit/testcases/forums/template/forum.php tests/phpunit/testcases/forums/template/forum.php
index 5b6982f..79f6ccf 100644
|
|
|
class BBP_Tests_Forums_Template_Forum extends BBP_UnitTestCase {
|
| 41 | 41 | $this->markTestSkipped( 'Skipping URL tests in multiste for now.' ); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | | $f = $this->factory->forum->create(); |
| | 44 | $f = $this->factory->forum->create( array( |
| | 45 | 'post_title' => 'Forum 1', |
| | 46 | ) ); |
| 45 | 47 | |
| 46 | 48 | $forum_permalink = bbp_get_forum_permalink( $f ); |
| 47 | 49 | $this->expectOutputString( $forum_permalink ); |
| … |
… |
class BBP_Tests_Forums_Template_Forum extends BBP_UnitTestCase {
|
| 56 | 58 | * @covers ::bbp_get_forum_title |
| 57 | 59 | */ |
| 58 | 60 | public function test_bbp_get_forum_title() { |
| 59 | | $f = $this->factory->forum->create(); |
| | 61 | $f = $this->factory->forum->create( array( |
| | 62 | 'post_title' => 'Forum 1', |
| | 63 | ) ); |
| 60 | 64 | |
| 61 | 65 | $forum = bbp_get_forum_title( $f ); |
| 62 | 66 | $this->assertSame( 'Forum 1', $forum ); |
| … |
… |
class BBP_Tests_Forums_Template_Forum extends BBP_UnitTestCase {
|
| 80 | 84 | * @covers ::bbp_get_forum_content |
| 81 | 85 | */ |
| 82 | 86 | public function test_bbp_get_forum_content() { |
| 83 | | $f = $this->factory->forum->create(); |
| | 87 | $f = $this->factory->forum->create( array( |
| | 88 | 'post_content' => 'Content of Forum 1', |
| | 89 | ) ); |
| 84 | 90 | |
| 85 | 91 | $forum = bbp_get_forum_content( $f ); |
| 86 | 92 | $this->assertSame( 'Content of Forum 1', $forum ); |
| … |
… |
class BBP_Tests_Forums_Template_Forum extends BBP_UnitTestCase {
|
| 105 | 111 | $this->assertSame( 'No Topics', $fresh_link ); |
| 106 | 112 | |
| 107 | 113 | $t = $this->factory->topic->create( array( |
| | 114 | 'post_title' => 'Topic 1', |
| 108 | 115 | 'post_parent' => $f, |
| 109 | 116 | 'post_date' => $post_date, |
| 110 | 117 | 'topic_meta' => array( |
| … |
… |
class BBP_Tests_Forums_Template_Forum extends BBP_UnitTestCase {
|
| 138 | 145 | $this->assertSame( 'No Topics', $link ); |
| 139 | 146 | |
| 140 | 147 | $t1 = $this->factory->topic->create( array( |
| | 148 | 'post_title' => 'Topic 1', |
| 141 | 149 | 'post_parent' => $f, |
| 142 | 150 | 'post_date' => $post_date_t1, |
| 143 | 151 | 'topic_meta' => array( |
| … |
… |
class BBP_Tests_Forums_Template_Forum extends BBP_UnitTestCase {
|
| 149 | 157 | $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1" title="Topic 1">18 hours ago</a>', $link ); |
| 150 | 158 | |
| 151 | 159 | $t2 = $this->factory->topic->create( array( |
| | 160 | 'post_title' => 'Topic 2', |
| 152 | 161 | 'post_parent' => $f, |
| 153 | 162 | 'post_date' => $post_date_t2, |
| 154 | 163 | 'topic_meta' => array( |
| … |
… |
class BBP_Tests_Forums_Template_Forum extends BBP_UnitTestCase {
|
| 165 | 174 | $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1" title="Topic 1">18 hours ago</a>', $link ); |
| 166 | 175 | |
| 167 | 176 | $t3 = $this->factory->topic->create( array( |
| | 177 | 'post_title' => 'Topic 3', |
| 168 | 178 | 'post_parent' => $f, |
| 169 | 179 | 'post_date' => $post_date_t3, |
| 170 | 180 | 'topic_meta' => array( |
| … |
… |
class BBP_Tests_Forums_Template_Forum extends BBP_UnitTestCase {
|
| 182 | 192 | $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1" title="Topic 1">18 hours ago</a>', $link ); |
| 183 | 193 | |
| 184 | 194 | $t4 = $this->factory->topic->create( array( |
| | 195 | 'post_title' => 'Topic 4', |
| 185 | 196 | 'post_parent' => $f, |
| 186 | 197 | 'post_date' => $post_date_t4, |
| 187 | 198 | 'topic_meta' => array( |
| … |
… |
class BBP_Tests_Forums_Template_Forum extends BBP_UnitTestCase {
|
| 214 | 225 | $this->assertSame( '<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-4" title="Topic 4">12 hours ago</a>', $link ); |
| 215 | 226 | |
| 216 | 227 | $t5 = $this->factory->topic->create( array( |
| | 228 | 'post_title' => 'Topic 5', |
| 217 | 229 | 'post_parent' => $f, |
| 218 | 230 | 'post_date' => $post_date_t5, |
| 219 | 231 | 'topic_meta' => array( |
diff --git tests/phpunit/testcases/forums/template/get-last-thing.php tests/phpunit/testcases/forums/template/get-last-thing.php
index d68284b..15bccda 100644
|
|
|
class BBP_Tests_Forums_Template_Forum_Last_Thing extends BBP_UnitTestCase {
|
| 186 | 186 | $f = $this->factory->forum->create(); |
| 187 | 187 | |
| 188 | 188 | $t = $this->factory->topic->create( array( |
| | 189 | 'post_title' => 'Topic 1', |
| 189 | 190 | 'post_parent' => $f, |
| 190 | 191 | 'topic_meta' => array( |
| 191 | 192 | 'forum_id' => $f, |
| … |
… |
class BBP_Tests_Forums_Template_Forum_Last_Thing extends BBP_UnitTestCase {
|
| 339 | 340 | ) ); |
| 340 | 341 | |
| 341 | 342 | $this->factory->reply->create( array( |
| | 343 | 'post_title' => 'Reply To: Topic 1', |
| 342 | 344 | 'post_parent' => $t, |
| 343 | 345 | 'reply_meta' => array( |
| 344 | 346 | 'forum_id' => $f, |
diff --git tests/phpunit/testcases/replies/functions/reply.php tests/phpunit/testcases/replies/functions/reply.php
index edf2917..caadaed 100644
|
|
|
class BBP_Tests_Replies_Functions_Reply extends BBP_UnitTestCase {
|
| 25 | 25 | ) ); |
| 26 | 26 | |
| 27 | 27 | $r = $this->factory->reply->create( array( |
| | 28 | 'post_title' => 'Reply To: Topic 1', |
| | 29 | 'post_content' => 'Content of reply to Topic 1', |
| 28 | 30 | 'post_parent' => $t, |
| 29 | 31 | 'reply_meta' => array( |
| 30 | 32 | 'forum_id' => $f, |
| … |
… |
class BBP_Tests_Replies_Functions_Reply extends BBP_UnitTestCase {
|
| 35 | 37 | // Get the reply. |
| 36 | 38 | $reply = bbp_get_reply( $r ); |
| 37 | 39 | |
| | 40 | remove_all_filters( 'bbp_get_reply_content' ); |
| | 41 | |
| 38 | 42 | // Reply post. |
| 39 | 43 | $this->assertSame( 'Reply To: Topic 1', bbp_get_reply_title( $r ) ); |
| | 44 | $this->assertSame( 'Content of reply to Topic 1', bbp_get_reply_content( $r ) ); |
| 40 | 45 | $this->assertSame( 'publish', bbp_get_reply_status( $r ) ); |
| 41 | 46 | $this->assertSame( $t, wp_get_post_parent_id( $r ) ); |
| 42 | 47 | $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?reply=' . $reply->post_name, $reply->guid ); |
diff --git tests/phpunit/testcases/replies/template/reply.php tests/phpunit/testcases/replies/template/reply.php
index 6c787ec..828dbff 100644
|
|
|
class BBP_Tests_Replies_Template_Reply extends BBP_UnitTestCase {
|
| 260 | 260 | ) ); |
| 261 | 261 | |
| 262 | 262 | $r = $this->factory->reply->create( array( |
| | 263 | 'post_content' => 'Content of Reply 1', |
| 263 | 264 | 'post_parent' => $t, |
| 264 | 265 | 'reply_meta' => array( |
| 265 | 266 | 'forum_id' => $f, |
diff --git tests/phpunit/testcases/topics/functions/topic.php tests/phpunit/testcases/topics/functions/topic.php
index 0e640a8..5b191fb 100644
|
|
|
class BBP_Tests_Topics_Functions_Topic extends BBP_UnitTestCase {
|
| 21 | 21 | $post_date = date( 'Y-m-d H:i:s', $now - 60 * 60 * 100 ); |
| 22 | 22 | |
| 23 | 23 | $t = $this->factory->topic->create( array( |
| | 24 | 'post_title' => 'Topic 1', |
| | 25 | 'post_content' => 'Content for Topic 1', |
| 24 | 26 | 'post_parent' => $f, |
| 25 | 27 | 'post_date' => $post_date, |
| 26 | 28 | 'topic_meta' => array( |
| … |
… |
class BBP_Tests_Topics_Functions_Topic extends BBP_UnitTestCase {
|
| 40 | 42 | // Get the topic. |
| 41 | 43 | $topic = bbp_get_topic( $t ); |
| 42 | 44 | |
| | 45 | remove_all_filters( 'bbp_get_topic_content' ); |
| | 46 | |
| 43 | 47 | // Topic post. |
| 44 | 48 | $this->assertSame( 'Topic 1', bbp_get_topic_title( $t ) ); |
| | 49 | $this->assertSame( 'Content for Topic 1', bbp_get_topic_content( $t ) ); |
| 45 | 50 | $this->assertSame( 'publish', bbp_get_topic_status( $t ) ); |
| 46 | 51 | $this->assertSame( $f, wp_get_post_parent_id( $t ) ); |
| 47 | 52 | $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?topic=' . $topic->post_name, $topic->guid ); |
diff --git tests/phpunit/testcases/topics/template/links.php tests/phpunit/testcases/topics/template/links.php
index c001b09..a3e7f5b 100644
|
|
|
class BBP_Tests_Topics_Template_Links extends BBP_UnitTestCase {
|
| 50 | 50 | |
| 51 | 51 | $f = $this->factory->forum->create(); |
| 52 | 52 | $t = $this->factory->topic->create( array( |
| | 53 | 'post_title' => 'Topic 1', |
| 53 | 54 | 'post_parent' => $f, |
| 54 | 55 | 'post_date' => $post_date, |
| 55 | 56 | 'topic_meta' => array( |
| … |
… |
class BBP_Tests_Topics_Template_Links extends BBP_UnitTestCase {
|
| 104 | 105 | |
| 105 | 106 | $f = $this->factory->forum->create(); |
| 106 | 107 | $t = $this->factory->topic->create( array( |
| | 108 | 'post_title' => 'Topic 1', |
| 107 | 109 | 'post_parent' => $f, |
| 108 | 110 | 'post_date' => $post_date, |
| 109 | 111 | 'topic_meta' => array( |
diff --git tests/phpunit/testcases/topics/template/topic.php tests/phpunit/testcases/topics/template/topic.php
index 20ff26f..7e8752b 100644
|
|
|
class BBP_Tests_Topics_Template_Topic extends BBP_UnitTestCase {
|
| 57 | 57 | } |
| 58 | 58 | $f = $this->factory->forum->create(); |
| 59 | 59 | $t = $this->factory->topic->create( array( |
| | 60 | 'post_title' => 'Topic 1', |
| 60 | 61 | 'post_parent' => $f, |
| 61 | 62 | 'topic_meta' => array( |
| 62 | 63 | 'forum_id' => $f, |
| … |
… |
class BBP_Tests_Topics_Template_Topic extends BBP_UnitTestCase {
|
| 78 | 79 | public function test_bbp_get_topic_title() { |
| 79 | 80 | $f = $this->factory->forum->create(); |
| 80 | 81 | $t = $this->factory->topic->create( array( |
| | 82 | 'post_title' => 'Topic 1', |
| 81 | 83 | 'post_parent' => $f, |
| 82 | 84 | 'topic_meta' => array( |
| 83 | 85 | 'forum_id' => $f, |
| … |
… |
class BBP_Tests_Topics_Template_Topic extends BBP_UnitTestCase {
|
| 107 | 109 | public function test_bbp_get_topic_content() { |
| 108 | 110 | $f = $this->factory->forum->create(); |
| 109 | 111 | $t = $this->factory->topic->create( array( |
| | 112 | 'post_content' => 'Content of Topic 1', |
| 110 | 113 | 'post_parent' => $f, |
| 111 | 114 | 'topic_meta' => array( |
| 112 | 115 | 'forum_id' => $f, |
diff --git tests/phpunit/testcases/users/template/user.php tests/phpunit/testcases/users/template/user.php
index ea400ee..8a93cde 100644
|
|
|
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 24 | 24 | $this->set_current_user( $this->old_current_user ); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | | private function set_permalink_structure( $permalink_structure = '/%year%/%monthnum%/%day%/%postname%/' ) { |
| 28 | | global $wp_rewrite; |
| 29 | | $wp_rewrite->set_permalink_structure( $permalink_structure ); |
| 30 | | } |
| 31 | | |
| 32 | 27 | /** |
| 33 | 28 | * @covers ::bbp_user_id |
| 34 | 29 | * @covers ::bbp_get_user_id |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 129 | 124 | $display_name = $this->keymaster_userdata->display_name; |
| 130 | 125 | |
| 131 | 126 | // Pretty permalinks |
| 132 | | $this->set_permalink_structure(); |
| | 127 | $this->set_permalink_structure( '/%postname%/' ); |
| 133 | 128 | |
| 134 | 129 | $profile_link = '<a href="http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/" rel="nofollow">' . $display_name . '</a>'; |
| 135 | 130 | $user_profile_link = bbp_get_user_profile_link( $this->keymaster_id ); |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 144 | 139 | ob_clean(); |
| 145 | 140 | |
| 146 | 141 | // Ugly permalinks |
| 147 | | $this->set_permalink_structure( '' ); |
| | 142 | $this->set_permalink_structure(); |
| 148 | 143 | |
| 149 | 144 | $profile_link = '<a href="http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '" rel="nofollow">' . $display_name . '</a>'; |
| 150 | 145 | $user_profile_link = bbp_get_user_profile_link( $this->keymaster_id ); |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 179 | 174 | public function test_bbp_get_user_profile_url() { |
| 180 | 175 | |
| 181 | 176 | // Pretty permalinks |
| 182 | | $this->set_permalink_structure(); |
| | 177 | $this->set_permalink_structure( '/%postname%/' ); |
| 183 | 178 | $profile_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/'; |
| 184 | 179 | $user_profile_url = bbp_get_user_profile_url( $this->keymaster_id ); |
| 185 | 180 | |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 193 | 188 | ob_clean(); |
| 194 | 189 | |
| 195 | 190 | // Ugly permalinks |
| 196 | | $this->set_permalink_structure( '' ); |
| | 191 | $this->set_permalink_structure(); |
| 197 | 192 | |
| 198 | 193 | $profile_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id; |
| 199 | 194 | $user_profile_url = bbp_get_user_profile_url( $this->keymaster_id ); |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 214 | 209 | $display_name = $this->keymaster_userdata->display_name; |
| 215 | 210 | |
| 216 | 211 | // Pretty permalinks |
| 217 | | $this->set_permalink_structure(); |
| | 212 | $this->set_permalink_structure( '/%postname%/' ); |
| 218 | 213 | $profile_edit_link = '<a href="http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/edit/" rel="nofollow">' . $display_name . '</a>'; |
| 219 | 214 | $user_profile_edit_link = bbp_get_user_profile_edit_link( $this->keymaster_id ); |
| 220 | 215 | |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 228 | 223 | ob_clean(); |
| 229 | 224 | |
| 230 | 225 | // Ugly permalinks |
| 231 | | $this->set_permalink_structure( '' ); |
| | 226 | $this->set_permalink_structure(); |
| 232 | 227 | $profile_edit_link = '<a href="http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&edit=1" rel="nofollow">' . $display_name . '</a>'; |
| 233 | 228 | $user_profile_edit_link = bbp_get_user_profile_edit_link( $this->keymaster_id ); |
| 234 | 229 | |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 246 | 241 | public function test_bbp_user_profile_edit_url() { |
| 247 | 242 | |
| 248 | 243 | // Pretty permalinks |
| 249 | | $this->set_permalink_structure(); |
| | 244 | $this->set_permalink_structure( '/%postname%/' ); |
| 250 | 245 | $profile_edit_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/edit/'; |
| 251 | 246 | |
| 252 | 247 | // Output. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 256 | 251 | ob_clean(); |
| 257 | 252 | |
| 258 | 253 | // Ugly permalinks |
| 259 | | $this->set_permalink_structure( '' ); |
| | 254 | $this->set_permalink_structure(); |
| 260 | 255 | $profile_edit_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&edit=1'; |
| 261 | 256 | |
| 262 | 257 | // Output. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 270 | 265 | public function test_bbp_get_user_profile_edit_url() { |
| 271 | 266 | |
| 272 | 267 | // Pretty permalinks |
| 273 | | $this->set_permalink_structure(); |
| | 268 | $this->set_permalink_structure( '/%postname%/' ); |
| 274 | 269 | $profile_edit_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/edit/'; |
| 275 | 270 | |
| 276 | 271 | // String. |
| 277 | 272 | $this->assertSame( $profile_edit_url, bbp_get_user_profile_edit_url( $this->keymaster_id ) ); |
| 278 | 273 | |
| 279 | 274 | // Ugly permalinks |
| 280 | | $this->set_permalink_structure( '' ); |
| | 275 | $this->set_permalink_structure(); |
| 281 | 276 | $profile_edit_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&edit=1'; |
| 282 | 277 | |
| 283 | 278 | // String. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 323 | 318 | public function test_bbp_get_author_ip() { |
| 324 | 319 | $t = $this->factory->topic->create(); |
| 325 | 320 | |
| 326 | | $author_ip = '<span class="bbp-author-ip">(0.0.0.0)</span>'; |
| | 321 | $author_ip = '<span class="bbp-author-ip">(127.0.0.1)</span>'; |
| 327 | 322 | |
| 328 | 323 | // String. |
| 329 | 324 | $this->assertSame( $author_ip, bbp_get_author_ip( $t ) ); |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 375 | 370 | public function test_bbp_favorites_permalink() { |
| 376 | 371 | |
| 377 | 372 | // Pretty permalinks |
| 378 | | $this->set_permalink_structure(); |
| | 373 | $this->set_permalink_structure( '/%postname%/' ); |
| 379 | 374 | $favorites_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/favorites/'; |
| 380 | 375 | |
| 381 | 376 | // Output. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 385 | 380 | ob_clean(); |
| 386 | 381 | |
| 387 | 382 | // Ugly permalinks |
| 388 | | $this->set_permalink_structure( '' ); |
| | 383 | $this->set_permalink_structure(); |
| 389 | 384 | $favorites_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_favs=favorites'; |
| 390 | 385 | |
| 391 | 386 | // Output. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 399 | 394 | public function test_bbp_get_favorites_permalink() { |
| 400 | 395 | |
| 401 | 396 | // Pretty permalinks |
| 402 | | $this->set_permalink_structure(); |
| | 397 | $this->set_permalink_structure( '/%postname%/' ); |
| 403 | 398 | $favorites_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/favorites/'; |
| 404 | 399 | |
| 405 | 400 | // String. |
| 406 | 401 | $this->assertSame( $favorites_url, bbp_get_favorites_permalink( $this->keymaster_id ) ); |
| 407 | 402 | |
| 408 | 403 | // Ugly permalinks |
| 409 | | $this->set_permalink_structure( '' ); |
| | 404 | $this->set_permalink_structure(); |
| 410 | 405 | $favorites_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_favs=favorites'; |
| 411 | 406 | |
| 412 | 407 | // String. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 431 | 426 | public function test_bbp_subscriptions_permalink() { |
| 432 | 427 | |
| 433 | 428 | // Pretty permalinks |
| 434 | | $this->set_permalink_structure(); |
| | 429 | $this->set_permalink_structure( '/%postname%/' ); |
| 435 | 430 | $subscriptions_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/subscriptions/'; |
| 436 | 431 | |
| 437 | 432 | // Output. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 441 | 436 | ob_clean(); |
| 442 | 437 | |
| 443 | 438 | // Ugly permalinks |
| 444 | | $this->set_permalink_structure( '' ); |
| | 439 | $this->set_permalink_structure(); |
| 445 | 440 | $subscriptions_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_subs=subscriptions'; |
| 446 | 441 | |
| 447 | 442 | // Output. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 455 | 450 | public function test_bbp_get_subscriptions_permalink() { |
| 456 | 451 | |
| 457 | 452 | // Pretty permalinks |
| 458 | | $this->set_permalink_structure(); |
| | 453 | $this->set_permalink_structure( '/%postname%/' ); |
| 459 | 454 | $subscriptions_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/subscriptions/'; |
| 460 | 455 | |
| 461 | 456 | // String. |
| 462 | 457 | $this->assertSame( $subscriptions_url, bbp_get_subscriptions_permalink( $this->keymaster_id ) ); |
| 463 | 458 | |
| 464 | 459 | // Ugly permalinks |
| 465 | | $this->set_permalink_structure( '' ); |
| | 460 | $this->set_permalink_structure(); |
| 466 | 461 | $subscriptions_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_subs=subscriptions'; |
| 467 | 462 | |
| 468 | 463 | // String. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 564 | 559 | public function test_bbp_user_topics_created_url() { |
| 565 | 560 | |
| 566 | 561 | // Pretty permalinks |
| 567 | | $this->set_permalink_structure(); |
| | 562 | $this->set_permalink_structure( '/%postname%/' ); |
| 568 | 563 | $topics_created_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/topics/'; |
| 569 | 564 | |
| 570 | 565 | // Output. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 574 | 569 | ob_clean(); |
| 575 | 570 | |
| 576 | 571 | // Ugly permalinks |
| 577 | | $this->set_permalink_structure( '' ); |
| | 572 | $this->set_permalink_structure(); |
| 578 | 573 | $topics_created_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_tops=1'; |
| 579 | 574 | |
| 580 | 575 | // Output. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 588 | 583 | public function test_bbp_get_user_topics_created_url() { |
| 589 | 584 | |
| 590 | 585 | // Pretty permalinks |
| 591 | | $this->set_permalink_structure(); |
| | 586 | $this->set_permalink_structure( '/%postname%/' ); |
| 592 | 587 | $topics_created_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/topics/'; |
| 593 | 588 | |
| 594 | 589 | // String. |
| 595 | 590 | $this->assertSame( $topics_created_url, bbp_get_user_topics_created_url( $this->keymaster_id ) ); |
| 596 | 591 | |
| 597 | 592 | // Ugly permalinks |
| 598 | | $this->set_permalink_structure( '' ); |
| | 593 | $this->set_permalink_structure(); |
| 599 | 594 | $topics_created_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_tops=1'; |
| 600 | 595 | |
| 601 | 596 | // String. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 608 | 603 | public function test_bbp_user_replies_created_url() { |
| 609 | 604 | |
| 610 | 605 | // Pretty permalinks |
| 611 | | $this->set_permalink_structure(); |
| | 606 | $this->set_permalink_structure( '/%postname%/' ); |
| 612 | 607 | $replies_created_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/replies/'; |
| 613 | 608 | |
| 614 | 609 | // Output. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 618 | 613 | ob_clean(); |
| 619 | 614 | |
| 620 | 615 | // Ugly permalinks |
| 621 | | $this->set_permalink_structure( '' ); |
| | 616 | $this->set_permalink_structure(); |
| 622 | 617 | $replies_created_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user='. $this->keymaster_id . '&bbp_reps=1'; |
| 623 | 618 | |
| 624 | 619 | // Output. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 632 | 627 | public function test_bbp_get_user_replies_created_url() { |
| 633 | 628 | |
| 634 | 629 | // Pretty permalinks |
| 635 | | $this->set_permalink_structure(); |
| | 630 | $this->set_permalink_structure( '/%postname%/' ); |
| 636 | 631 | $replies_created_url = 'http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/replies/'; |
| 637 | 632 | |
| 638 | 633 | // String. |
| 639 | 634 | $this->assertSame( $replies_created_url, bbp_get_user_replies_created_url( $this->keymaster_id ) ); |
| 640 | 635 | |
| 641 | 636 | // Ugly permalinks |
| 642 | | $this->set_permalink_structure( '' ); |
| | 637 | $this->set_permalink_structure(); |
| 643 | 638 | $replies_created_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user='. $this->keymaster_id . '&bbp_reps=1'; |
| 644 | 639 | |
| 645 | 640 | // String. |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 714 | 709 | $wp_avatar = get_avatar( $current_user, $size ); |
| 715 | 710 | |
| 716 | 711 | // Pretty permalinks |
| 717 | | $this->set_permalink_structure(); |
| | 712 | $this->set_permalink_structure( '/%postname%/' ); |
| 718 | 713 | $author_link = '<a href="http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/" title="View ' . $display_name . |
| 719 | 714 | ''s profile" class="bbp-author-avatar" rel="nofollow">' . $wp_avatar . |
| 720 | 715 | '</a> <a href="http://' . WP_TESTS_DOMAIN . '/forums/user/' . $this->keymaster_userdata->user_nicename . '/" title="View ' . $display_name . |
| … |
… |
class BBP_Tests_Users_Template_User extends BBP_UnitTestCase {
|
| 730 | 725 | ob_clean(); |
| 731 | 726 | |
| 732 | 727 | // Ugly permalinks |
| 733 | | $this->set_permalink_structure( '' ); |
| | 728 | $this->set_permalink_structure(); |
| 734 | 729 | $author_link = '<a href="http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '" title="View ' . $display_name . |
| 735 | 730 | ''s profile" class="bbp-author-avatar" rel="nofollow">' . $wp_avatar . |
| 736 | 731 | '</a> <a href="http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '" title="View ' . $display_name . |