Changeset 5791 for trunk/tests/phpunit/testcases/common/query.php
- Timestamp:
- 05/23/2015 06:50:53 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/common/query.php
r5789 r5791 13 13 * @group counts 14 14 * @covers ::bbp_get_public_child_count 15 * @todo Implement test_bbp_get_public_child_ids().16 15 */ 17 16 public function test_bbp_get_public_child_count() { 18 17 $f = $this->factory->forum->create(); 18 19 // Test initial forum public child counts 20 $count = bbp_get_public_child_count( $f, bbp_get_forum_post_type() ); 21 $this->assertSame( 0, $count ); 22 23 $count = bbp_get_public_child_count( $f, bbp_get_topic_post_type() ); 24 $this->assertSame( 0, $count ); 25 26 /* Sub-Forums *********************************************************/ 27 28 $this->factory->forum->create_many( 3, array( 29 'post_parent' => $f, 30 ) ); 31 32 $this->factory->forum->create( array( 33 'post_parent' => $f, 34 'post_status' => bbp_get_private_status_id(), 35 ) ); 36 37 $count = bbp_get_public_child_count( $f, bbp_get_forum_post_type() ); 38 $this->assertSame( 3, $count ); 39 40 $this->factory->forum->create_many( 2, array( 41 'post_parent' => $f, 42 ) ); 43 44 $count = bbp_get_public_child_count( $f, bbp_get_forum_post_type() ); 45 $this->assertSame( 5, $count ); 46 47 /* Topics *************************************************************/ 48 49 $t1 = $this->factory->topic->create_many( 3, array( 50 'post_parent' => $f, 51 'topic_meta' => array( 52 'forum_id' => $f, 53 ), 54 ) ); 55 56 $this->factory->topic->create( array( 57 'post_parent' => $f, 58 'post_status' => bbp_get_spam_status_id(), 59 'topic_meta' => array( 60 'forum_id' => $f, 61 ), 62 ) ); 63 64 $count = bbp_get_public_child_count( $f, bbp_get_topic_post_type() ); 65 $this->assertSame( 3, $count ); 66 67 $this->factory->topic->create_many( 2, array( 68 'post_parent' => $f, 69 'topic_meta' => array( 70 'forum_id' => $f, 71 ), 72 ) ); 73 74 $count = bbp_get_public_child_count( $f, bbp_get_topic_post_type() ); 75 $this->assertSame( 5, $count ); 76 77 /* Replies ************************************************************/ 78 79 $this->factory->reply->create_many( 3, array( 80 'post_parent' => $t1[0], 81 'reply_meta' => array( 82 'forum_id' => $f, 83 'topic_id' => $t1[0], 84 ), 85 ) ); 86 87 $this->factory->reply->create( array( 88 'post_parent' => $t1[0], 89 'post_status' => bbp_get_spam_status_id(), 90 'reply_meta' => array( 91 'forum_id' => $f, 92 'topic_id' => $t1[0], 93 ), 94 ) ); 95 96 $count = bbp_get_public_child_count( $t1[0], bbp_get_reply_post_type() ); 97 $this->assertSame( 3, $count ); 98 99 $this->factory->reply->create_many( 2, array( 100 'post_parent' => $t1[0], 101 'reply_meta' => array( 102 'forum_id' => $f, 103 'topic_id' => $t1[0], 104 ), 105 ) ); 106 107 $count = bbp_get_public_child_count( $t1[0], bbp_get_reply_post_type() ); 108 $this->assertSame( 5, $count ); 19 109 } 20 110 21 111 /** 22 112 * @covers ::bbp_get_public_child_ids 23 * @todo Implement test_bbp_get_public_child_ids().24 113 */ 25 114 public function test_bbp_get_public_child_ids() { 26 115 $f = $this->factory->forum->create(); 116 117 // Test initial forum public child counts 118 $count = count( bbp_get_public_child_ids( $f, bbp_get_forum_post_type() ) ); 119 $this->assertSame( 0, $count ); 120 121 $count = count( bbp_get_public_child_ids( $f, bbp_get_topic_post_type() ) ); 122 $this->assertSame( 0, $count ); 123 124 /* Sub-Forums *********************************************************/ 125 126 $this->factory->forum->create_many( 3, array( 127 'post_parent' => $f, 128 ) ); 129 130 $this->factory->forum->create( array( 131 'post_parent' => $f, 132 'post_status' => bbp_get_private_status_id(), 133 ) ); 134 135 bbp_clean_post_cache( $f ); 136 $count = count( bbp_get_public_child_ids( $f, bbp_get_forum_post_type() ) ); 137 $this->assertSame( 3, $count ); 138 139 $this->factory->forum->create_many( 2, array( 140 'post_parent' => $f, 141 ) ); 142 143 $count = count( bbp_get_public_child_ids( $f, bbp_get_forum_post_type() ) ); 144 $this->assertSame( 5, $count ); 145 146 /* Topics *************************************************************/ 147 148 $t1 = $this->factory->topic->create_many( 3, array( 149 'post_parent' => $f, 150 'topic_meta' => array( 151 'forum_id' => $f, 152 ), 153 ) ); 154 155 $this->factory->topic->create( array( 156 'post_parent' => $f, 157 'post_status' => bbp_get_spam_status_id(), 158 'topic_meta' => array( 159 'forum_id' => $f, 160 ), 161 ) ); 162 163 $count = count( bbp_get_public_child_ids( $f, bbp_get_topic_post_type() ) ); 164 $this->assertSame( 3, $count ); 165 166 $this->factory->topic->create_many( 2, array( 167 'post_parent' => $f, 168 'topic_meta' => array( 169 'forum_id' => $f, 170 ), 171 ) ); 172 173 $count = count( bbp_get_public_child_ids( $f, bbp_get_topic_post_type() ) ); 174 $this->assertSame( 5, $count ); 175 176 /* Replies ************************************************************/ 177 178 $this->factory->reply->create_many( 3, array( 179 'post_parent' => $t1[0], 180 'reply_meta' => array( 181 'forum_id' => $f, 182 'topic_id' => $t1[0], 183 ), 184 ) ); 185 186 $this->factory->reply->create( array( 187 'post_parent' => $t1[0], 188 'post_status' => bbp_get_spam_status_id(), 189 'reply_meta' => array( 190 'forum_id' => $f, 191 'topic_id' => $t1[0], 192 ), 193 ) ); 194 195 $count = count( bbp_get_public_child_ids( $t1[0], bbp_get_reply_post_type() ) ); 196 $this->assertSame( 3, $count ); 197 198 $this->factory->reply->create_many( 2, array( 199 'post_parent' => $t1[0], 200 'reply_meta' => array( 201 'forum_id' => $f, 202 'topic_id' => $t1[0], 203 ), 204 ) ); 205 206 $count = count( bbp_get_public_child_ids( $t1[0], bbp_get_reply_post_type() ) ); 207 $this->assertSame( 5, $count ); 27 208 } 28 209
Note: See TracChangeset
for help on using the changeset viewer.