Changeset 6006
- Timestamp:
- 04/19/2016 06:15:52 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/forums/template/counts.php
r5767 r6006 25 25 bbp_update_forum_subforum_count( $f1 ); 26 26 27 // Output 27 // Output. 28 28 $count = bbp_get_forum_subforum_count( $f1, false ); 29 29 $this->expectOutputString( $formatted_value ); 30 30 bbp_forum_subforum_count( $f1 ); 31 31 32 // Formatted string 32 // Formatted string. 33 33 $count = bbp_get_forum_subforum_count( $f1, false ); 34 34 $this->assertSame( $formatted_value, $count ); 35 35 36 // Integer 36 // Integer. 37 37 $count = bbp_get_forum_subforum_count( $f1, true ); 38 38 $this->assertSame( $int_value, $count ); 39 39 40 // Direct query 40 // Direct query. 41 41 $count = count( bbp_forum_query_subforum_ids( $f1 ) ); 42 42 $this->assertSame( $int_value, $count ); … … 48 48 */ 49 49 public function test_bbp_get_forum_topic_count() { 50 $f = $this->factory->forum->create(); 50 $c = $this->factory->forum->create( array( 51 'forum_meta' => array( 52 'forum_type' => 'category', 53 ), 54 ) ); 55 56 $f = $this->factory->forum->create( array( 57 'post_parent' => $c, 58 'forum_meta' => array( 59 'forum_id' => $c, 60 ), 61 ) ); 62 51 63 $int_value = 3; 52 64 $formatted_value = bbp_number_format( $int_value ); 53 65 54 66 $this->factory->topic->create_many( $int_value, array( 55 'post_parent' => $f 56 ) ); 57 67 'post_parent' => $f, 68 ) ); 69 70 bbp_update_forum_topic_count( $c ); 58 71 bbp_update_forum_topic_count( $f ); 59 72 60 // Output73 // Forum output. 61 74 $count = bbp_get_forum_topic_count( $f, true, false ); 62 75 $this->expectOutputString( $formatted_value ); 63 76 bbp_forum_topic_count( $f ); 64 77 65 // For matted string78 // Forum formatted string. 66 79 $count = bbp_get_forum_topic_count( $f, true, false ); 67 80 $this->assertSame( $formatted_value, $count ); 68 81 69 // Integer82 // Forum integer. 70 83 $count = bbp_get_forum_topic_count( $f, true, true ); 84 $this->assertSame( $int_value, $count ); 85 86 // Category topic count. 87 $count = bbp_get_forum_topic_count( $c, false, true ); 88 $this->assertSame( 0, $count ); 89 90 // Category total topic count. 91 $count = bbp_get_forum_topic_count( $c, true, true ); 71 92 $this->assertSame( $int_value, $count ); 72 93 } … … 77 98 */ 78 99 public function test_bbp_get_forum_reply_count() { 79 $f = $this->factory->forum->create(); 100 $c = $this->factory->forum->create( array( 101 'forum_meta' => array( 102 'forum_type' => 'category', 103 ), 104 ) ); 105 106 $f = $this->factory->forum->create( array( 107 'post_parent' => $c, 108 'forum_meta' => array( 109 'forum_id' => $c, 110 ), 111 ) ); 112 80 113 $t = $this->factory->topic->create( array( 81 'post_parent' => $f 114 'post_parent' => $f, 82 115 ) ); 83 116 … … 86 119 87 120 $this->factory->reply->create_many( $int_value, array( 88 'post_parent' => $t 89 ) ); 90 121 'post_parent' => $t, 122 ) ); 123 124 bbp_update_forum_reply_count( $c ); 91 125 bbp_update_forum_reply_count( $f ); 92 126 93 // Output127 // Forum Output. 94 128 $count = bbp_get_forum_reply_count( $f, true, false ); 95 129 $this->expectOutputString( $formatted_value ); 96 130 bbp_forum_reply_count( $f ); 97 131 98 // For matted string132 // Forum formatted string. 99 133 $count = bbp_get_forum_reply_count( $f, true, false ); 100 134 $this->assertSame( $formatted_value, $count ); 101 135 102 // Integer136 // Forum integer. 103 137 $count = bbp_get_forum_reply_count( $f, true, true ); 138 $this->assertSame( $int_value, $count ); 139 140 // Category reply count. 141 $count = bbp_get_forum_reply_count( $c, false, true ); 142 $this->assertSame( 0, $count ); 143 144 // Category total reply count. 145 $count = bbp_get_forum_reply_count( $c, true, true ); 104 146 $this->assertSame( $int_value, $count ); 105 147 } … … 110 152 */ 111 153 public function test_bbp_get_forum_post_count() { 112 $f = $this->factory->forum->create(); 154 $c = $this->factory->forum->create( array( 155 'forum_meta' => array( 156 'forum_type' => 'category', 157 ), 158 ) ); 159 160 $f = $this->factory->forum->create( array( 161 'post_parent' => $c, 162 'forum_meta' => array( 163 'forum_id' => $c, 164 ), 165 ) ); 166 113 167 $t = $this->factory->topic->create( array( 114 'post_parent' => $f 115 ) ); 116 117 $int_value = 3; 118 119 // Topic + Replies 168 'post_parent' => $f, 169 ) ); 170 171 $int_value = 3; 172 173 // Topic + Replies. 120 174 $result = 4; 121 175 $formatted_result = bbp_number_format( $result ); 122 176 123 177 $this->factory->reply->create_many( $int_value, array( 124 'post_parent' => $t 125 ) ); 126 178 'post_parent' => $t, 179 ) ); 180 181 bbp_update_forum_topic_count( $c ); 127 182 bbp_update_forum_topic_count( $f ); 183 bbp_update_forum_reply_count( $c ); 128 184 bbp_update_forum_reply_count( $f ); 129 185 130 // Output186 // Forum output. 131 187 $count = bbp_get_forum_post_count( $f, true, false ); 132 188 $this->expectOutputString( $formatted_result ); 133 189 bbp_forum_post_count( $f ); 134 190 135 // For matted string191 // Forum formatted string. 136 192 $count = bbp_get_forum_post_count( $f, true, false ); 137 193 $this->assertSame( $formatted_result, $count ); 138 194 139 // Integer195 // Forum integer. 140 196 $count = bbp_get_forum_post_count( $f, true, true ); 141 197 $this->assertSame( $result, $count ); 198 199 // Category post count. 200 $count = bbp_get_forum_post_count( $c, false, true ); 201 $this->assertSame( 0, $count ); 202 203 // Category total post count. 204 $count = bbp_get_forum_post_count( $c, true, true ); 205 $this->assertSame( $result, $count ); 142 206 } 143 207 … … 147 211 */ 148 212 public function test_bbp_get_forum_topic_count_hidden() { 149 $f = $this->factory->forum->create(); 213 $c = $this->factory->forum->create( array( 214 'forum_meta' => array( 215 'forum_type' => 'category', 216 ), 217 ) ); 218 219 $f = $this->factory->forum->create( array( 220 'post_parent' => $c, 221 'forum_meta' => array( 222 'forum_id' => $c, 223 ), 224 ) ); 225 150 226 $int_value = 3; 151 227 $formatted_value = bbp_number_format( $int_value ); … … 153 229 $this->factory->topic->create_many( $int_value, array( 154 230 'post_parent' => $f, 155 'post_status' => bbp_get_spam_status_id() 156 ) ); 157 231 'post_status' => bbp_get_spam_status_id(), 232 ) ); 233 234 bbp_update_forum_topic_count_hidden( $c ); 158 235 bbp_update_forum_topic_count_hidden( $f ); 159 236 160 // Output237 // Forum output. 161 238 $count = bbp_get_forum_topic_count_hidden( $f, false ); 162 239 $this->expectOutputString( $formatted_value ); 163 240 bbp_forum_topic_count_hidden( $f ); 164 241 165 // For matted string242 // Forum formatted string. 166 243 $count = bbp_get_forum_topic_count_hidden( $f, false ); 167 244 $this->assertSame( $formatted_value, $count ); 168 245 169 // Integer 170 $count = bbp_get_forum_topic_count_hidden( $f, true, true ); 171 $this->assertSame( $int_value, $count ); 246 // Forum integer. 247 $count = bbp_get_forum_topic_count_hidden( $f, true ); 248 $this->assertSame( $int_value, $count ); 249 250 // Category topic count hidden. 251 $count = bbp_get_forum_topic_count_hidden( $c, true ); 252 $this->assertSame( 0, $count ); 253 254 // Category total topic count hidden. 255 $count = bbp_get_forum_topic_count_hidden( $c, true ); 256 $this->assertSame( 0, $count ); 172 257 } 173 258 }
Note: See TracChangeset
for help on using the changeset viewer.