-
diff --git .gitignore .gitignore
index dd18e54..b7ac88d 100644
|
|
|
4 | 4 | wp-config.php |
5 | 5 | wp-tests-config.php |
6 | 6 | .htaccess |
7 | | |
| 7 | .idea |
8 | 8 | # Files and folders related to build/test tools |
9 | 9 | /phpunit.xml |
10 | 10 | /tests/phpunit/data/plugins/wordpress-importer |
-
diff --git tests/phpunit/includes/testcase-ajax.php tests/phpunit/includes/testcase-ajax.php
index 6296ced..3227fa6 100644
|
|
abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase { |
75 | 75 | error_reporting( $this->_error_level & ~E_WARNING ); |
76 | 76 | |
77 | 77 | // Make some posts |
78 | | self::$factory->post->create_many( 5 ); |
| 78 | self::factory()->post->create_many( 5 ); |
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
… |
… |
abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase { |
148 | 148 | */ |
149 | 149 | protected function _setRole( $role ) { |
150 | 150 | $post = $_POST; |
151 | | $user_id = self::$factory->user->create( array( 'role' => $role ) ); |
| 151 | $user_id = self::factory()->user->create( array( 'role' => $role ) ); |
152 | 152 | wp_set_current_user( $user_id ); |
153 | 153 | $_POST = array_merge($_POST, $post); |
154 | 154 | } |
-
diff --git tests/phpunit/includes/testcase-canonical.php tests/phpunit/includes/testcase-canonical.php
index 6470a64..a82c8c5 100644
|
|
class WP_Canonical_UnitTestCase extends WP_UnitTestCase { |
49 | 49 | wp_set_current_user( self::$author_id ); |
50 | 50 | |
51 | 51 | // Already created by install defaults: |
52 | | // self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'uncategorized' ) ); |
| 52 | // self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => 'uncategorized' ) ); |
53 | 53 | |
54 | 54 | self::$post_ids[] = $factory->post->create( array( 'import_id' => 587, 'post_title' => 'post-format-test-audio', 'post_date' => '2008-06-02 00:00:00' ) ); |
55 | 55 | self::$post_ids[] = $post_id = $factory->post->create( array( 'post_title' => 'post-format-test-gallery', 'post_date' => '2008-06-10 00:00:00' ) ); |
-
diff --git tests/phpunit/includes/testcase-xmlrpc.php tests/phpunit/includes/testcase-xmlrpc.php
index 6f69569..5fefb51 100644
|
|
class WP_XMLRPC_UnitTestCase extends WP_UnitTestCase { |
22 | 22 | } |
23 | 23 | |
24 | 24 | protected function make_user_by_role( $role ) { |
25 | | return self::$factory->user->create( array( |
| 25 | return self::factory()->user->create( array( |
26 | 26 | 'user_login' => $role, |
27 | 27 | 'user_pass' => $role, |
28 | 28 | 'role' => $role |
-
diff --git tests/phpunit/includes/testcase.php tests/phpunit/includes/testcase.php
index e7c3308..e3cc573 100644
|
|
class WP_UnitTestCase extends PHPUnit_Framework_TestCase { |
14 | 14 | protected static $hooks_saved = array(); |
15 | 15 | protected static $ignore_files; |
16 | 16 | |
17 | | /** |
18 | | * @var WP_UnitTest_Factory |
19 | | */ |
20 | | protected static $factory; |
| 17 | |
| 18 | function __isset( $name ) { |
| 19 | return 'factory' === $name; |
| 20 | } |
| 21 | |
| 22 | |
| 23 | function __get( $name ) { |
| 24 | if ( 'factory' === $name ) { |
| 25 | return self::factory(); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | |
| 30 | |
| 31 | protected static function factory() { |
| 32 | static $factory = null; |
| 33 | if ( ! $factory ) { |
| 34 | $factory = new WP_UnitTest_Factory(); |
| 35 | } |
| 36 | return $factory; |
| 37 | } |
21 | 38 | |
22 | 39 | public static function get_called_class() { |
23 | 40 | if ( function_exists( 'get_called_class' ) ) { |
… |
… |
class WP_UnitTestCase extends PHPUnit_Framework_TestCase { |
37 | 54 | public static function setUpBeforeClass() { |
38 | 55 | parent::setUpBeforeClass(); |
39 | 56 | |
40 | | if ( ! self::$factory ) { |
41 | | self::$factory = new WP_UnitTest_Factory(); |
42 | | } |
43 | | |
44 | 57 | $c = self::get_called_class(); |
45 | 58 | if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) { |
46 | 59 | return; |
47 | 60 | } |
48 | 61 | |
49 | | call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::$factory ); |
| 62 | call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::factory() ); |
50 | 63 | |
51 | 64 | self::commit_transaction(); |
52 | 65 | } |
-
diff --git tests/phpunit/tests/admin/includesComment.php tests/phpunit/tests/admin/includesComment.php
index 46f3b11..36f9897 100644
|
|
|
6 | 6 | */ |
7 | 7 | class Tests_Admin_IncludesComment extends WP_UnitTestCase { |
8 | 8 | public function test_must_match_date_and_author() { |
9 | | $p1 = self::$factory->post->create(); |
10 | | $c1 = self::$factory->comment->create( array( |
| 9 | $p1 = self::factory()->post->create(); |
| 10 | $c1 = self::factory()->comment->create( array( |
11 | 11 | 'comment_author' => 1, |
12 | 12 | 'comment_date' => '2014-05-06 12:00:00', |
13 | 13 | 'comment_post_ID' => $p1, |
14 | 14 | ) ); |
15 | 15 | |
16 | | $p2 = self::$factory->post->create(); |
17 | | $c2 = self::$factory->comment->create( array( |
| 16 | $p2 = self::factory()->post->create(); |
| 17 | $c2 = self::factory()->comment->create( array( |
18 | 18 | 'comment_author' => 2, |
19 | 19 | 'comment_date' => '2004-01-02 12:00:00', |
20 | 20 | 'comment_post_ID' => $p2, |
… |
… |
class Tests_Admin_IncludesComment extends WP_UnitTestCase { |
28 | 28 | * @ticket 33871 |
29 | 29 | */ |
30 | 30 | public function test_default_value_of_timezone_should_be_blog() { |
31 | | $p = self::$factory->post->create(); |
32 | | $c = self::$factory->comment->create( array( |
| 31 | $p = self::factory()->post->create(); |
| 32 | $c = self::factory()->comment->create( array( |
33 | 33 | 'comment_author' => 1, |
34 | 34 | 'comment_post_ID' => $p, |
35 | 35 | 'comment_date' => '2014-05-06 12:00:00', |
… |
… |
class Tests_Admin_IncludesComment extends WP_UnitTestCase { |
43 | 43 | * @ticket 33871 |
44 | 44 | */ |
45 | 45 | public function test_should_respect_timezone_blog() { |
46 | | $p = self::$factory->post->create(); |
47 | | $c = self::$factory->comment->create( array( |
| 46 | $p = self::factory()->post->create(); |
| 47 | $c = self::factory()->comment->create( array( |
48 | 48 | 'comment_author' => 1, |
49 | 49 | 'comment_post_ID' => $p, |
50 | 50 | 'comment_date' => '2014-05-06 12:00:00', |
… |
… |
class Tests_Admin_IncludesComment extends WP_UnitTestCase { |
58 | 58 | * @ticket 33871 |
59 | 59 | */ |
60 | 60 | public function test_should_respect_timezone_gmt() { |
61 | | $p = self::$factory->post->create(); |
62 | | $c = self::$factory->comment->create( array( |
| 61 | $p = self::factory()->post->create(); |
| 62 | $c = self::factory()->comment->create( array( |
63 | 63 | 'comment_author' => 1, |
64 | 64 | 'comment_post_ID' => $p, |
65 | 65 | 'comment_date' => '2014-05-06 12:00:00', |
… |
… |
class Tests_Admin_IncludesComment extends WP_UnitTestCase { |
73 | 73 | * @ticket 33871 |
74 | 74 | */ |
75 | 75 | public function test_invalid_timezone_should_fall_back_on_blog() { |
76 | | $p = self::$factory->post->create(); |
77 | | $c = self::$factory->comment->create( array( |
| 76 | $p = self::factory()->post->create(); |
| 77 | $c = self::factory()->comment->create( array( |
78 | 78 | 'comment_author' => 1, |
79 | 79 | 'comment_post_ID' => $p, |
80 | 80 | 'comment_date' => '2014-05-06 12:00:00', |
-
diff --git tests/phpunit/tests/admin/includesPlugin.php tests/phpunit/tests/admin/includesPlugin.php
index a51a929..b7ed20d 100644
|
|
class Tests_Admin_includesPlugin extends WP_UnitTestCase { |
29 | 29 | |
30 | 30 | function test_menu_page_url() { |
31 | 31 | $current_user = get_current_user_id(); |
32 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 32 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
33 | 33 | update_option( 'siteurl', 'http://example.com' ); |
34 | 34 | |
35 | 35 | // add some pages |
-
diff --git tests/phpunit/tests/admin/includesPost.php tests/phpunit/tests/admin/includesPost.php
index 7fa3dd3..8874a1c 100644
|
|
class Tests_Admin_includesPost extends WP_UnitTestCase { |
11 | 11 | } |
12 | 12 | |
13 | 13 | function test__wp_translate_postdata_cap_checks_contributor() { |
14 | | $contributor_id = self::$factory->user->create( array( 'role' => 'contributor' ) ); |
15 | | $editor_id = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 14 | $contributor_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); |
| 15 | $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) ); |
16 | 16 | |
17 | 17 | wp_set_current_user( $contributor_id ); |
18 | 18 | |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
51 | 51 | |
52 | 52 | // Edit Draft Post for another user |
53 | 53 | $_post_data = array(); |
54 | | $_post_data['post_ID'] = self::$factory->post->create( array( 'post_author' => $editor_id ) ); |
| 54 | $_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => $editor_id ) ); |
55 | 55 | $_post_data['post_author'] = $editor_id; |
56 | 56 | $_post_data['post_type'] = 'post'; |
57 | 57 | $_post_data['post_status'] = 'draft'; |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
64 | 64 | } |
65 | 65 | |
66 | 66 | function test__wp_translate_postdata_cap_checks_editor() { |
67 | | $contributor_id = self::$factory->user->create( array( 'role' => 'contributor' ) ); |
68 | | $editor_id = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 67 | $contributor_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); |
| 68 | $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) ); |
69 | 69 | |
70 | 70 | wp_set_current_user( $editor_id ); |
71 | 71 | |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
104 | 104 | |
105 | 105 | // Edit Draft Post for another user |
106 | 106 | $_post_data = array(); |
107 | | $_post_data['post_ID'] = self::$factory->post->create( array( 'post_author' => $contributor_id ) ); |
| 107 | $_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => $contributor_id ) ); |
108 | 108 | $_post_data['post_author'] = $contributor_id; |
109 | 109 | $_post_data['post_type'] = 'post'; |
110 | 110 | $_post_data['post_status'] = 'draft'; |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
122 | 122 | * @ticket 25272 |
123 | 123 | */ |
124 | 124 | function test_edit_post_auto_draft() { |
125 | | $user_id = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 125 | $user_id = self::factory()->user->create( array( 'role' => 'editor' ) ); |
126 | 126 | wp_set_current_user( $user_id ); |
127 | | $post = self::$factory->post->create_and_get( array( 'post_status' => 'auto-draft' ) ); |
| 127 | $post = self::factory()->post->create_and_get( array( 'post_status' => 'auto-draft' ) ); |
128 | 128 | $this->assertEquals( 'auto-draft', $post->post_status ); |
129 | 129 | $post_data = array( |
130 | 130 | 'post_title' => 'Post title', |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
140 | 140 | * @ticket 30615 |
141 | 141 | */ |
142 | 142 | public function test_edit_post_should_parse_tax_input_by_name_rather_than_slug_for_nonhierarchical_taxonomies() { |
143 | | $u = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 143 | $u = self::factory()->user->create( array( 'role' => 'editor' ) ); |
144 | 144 | wp_set_current_user( $u ); |
145 | 145 | |
146 | 146 | register_taxonomy( 'wptests_tax', array( 'post' ) ); |
147 | | $t1 = self::$factory->term->create( array( |
| 147 | $t1 = self::factory()->term->create( array( |
148 | 148 | 'taxonomy' => 'wptests_tax', |
149 | 149 | 'name' => 'foo', |
150 | 150 | 'slug' => 'bar', |
151 | 151 | ) ); |
152 | | $t2 = self::$factory->term->create( array( |
| 152 | $t2 = self::factory()->term->create( array( |
153 | 153 | 'taxonomy' => 'wptests_tax', |
154 | 154 | 'name' => 'bar', |
155 | 155 | 'slug' => 'foo', |
156 | 156 | ) ); |
157 | 157 | |
158 | | $p = self::$factory->post->create(); |
| 158 | $p = self::factory()->post->create(); |
159 | 159 | |
160 | 160 | $post_data = array( |
161 | 161 | 'post_ID' => $p, |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
179 | 179 | * @ticket 30615 |
180 | 180 | */ |
181 | 181 | public function test_edit_post_should_not_create_terms_for_an_empty_tag_input_field() { |
182 | | $u = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 182 | $u = self::factory()->user->create( array( 'role' => 'editor' ) ); |
183 | 183 | wp_set_current_user( $u ); |
184 | 184 | |
185 | 185 | register_taxonomy( 'wptests_tax', array( 'post' ) ); |
186 | | $t1 = self::$factory->term->create( array( |
| 186 | $t1 = self::factory()->term->create( array( |
187 | 187 | 'taxonomy' => 'wptests_tax', |
188 | 188 | 'name' => 'foo', |
189 | 189 | 'slug' => 'bar', |
190 | 190 | ) ); |
191 | 191 | |
192 | | $p = self::$factory->post->create(); |
| 192 | $p = self::factory()->post->create(); |
193 | 193 | |
194 | 194 | $post_data = array( |
195 | 195 | 'post_ID' => $p, |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
209 | 209 | * @ticket 27792 |
210 | 210 | */ |
211 | 211 | function test_bulk_edit_posts_stomping() { |
212 | | $admin = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
213 | | $users = self::$factory->user->create_many( 2, array( 'role' => 'author' ) ); |
| 212 | $admin = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
| 213 | $users = self::factory()->user->create_many( 2, array( 'role' => 'author' ) ); |
214 | 214 | wp_set_current_user( $admin ); |
215 | 215 | |
216 | | $post1 = self::$factory->post->create( array( |
| 216 | $post1 = self::factory()->post->create( array( |
217 | 217 | 'post_author' => $users[0], |
218 | 218 | 'comment_status' => 'open', |
219 | 219 | 'ping_status' => 'open', |
220 | 220 | 'post_status' => 'publish', |
221 | 221 | ) ); |
222 | 222 | |
223 | | $post2 = self::$factory->post->create( array( |
| 223 | $post2 = self::factory()->post->create( array( |
224 | 224 | 'post_author' => $users[1], |
225 | 225 | 'comment_status' => 'closed', |
226 | 226 | 'ping_status' => 'closed', |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
255 | 255 | $this->set_permalink_structure( "/$permalink_structure/" ); |
256 | 256 | |
257 | 257 | $future_date = date( 'Y-m-d H:i:s', time() + 100 ); |
258 | | $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); |
| 258 | $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); |
259 | 259 | |
260 | 260 | $found = get_sample_permalink( $p ); |
261 | 261 | $expected = trailingslashit( home_url( $permalink_structure ) ); |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
268 | 268 | * @ticket 18306 |
269 | 269 | */ |
270 | 270 | public function test_get_sample_permalink_html_should_use_default_permalink_for_view_post_link_when_pretty_permalinks_are_disabled() { |
271 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 271 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
272 | 272 | |
273 | 273 | $future_date = date( 'Y-m-d H:i:s', time() + 100 ); |
274 | | $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); |
| 274 | $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); |
275 | 275 | |
276 | 276 | $found = get_sample_permalink_html( $p ); |
277 | 277 | $this->assertContains( 'href="' . get_option( 'home' ) . '/?p=' . $p . '"', $found ); |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
284 | 284 | public function test_get_sample_permalink_html_should_use_pretty_permalink_for_view_post_link_when_pretty_permalinks_are_enabled() { |
285 | 285 | $this->set_permalink_structure( '/%postname%/' ); |
286 | 286 | |
287 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 287 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
288 | 288 | |
289 | 289 | $future_date = date( 'Y-m-d H:i:s', time() + 100 ); |
290 | | $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); |
| 290 | $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); |
291 | 291 | |
292 | 292 | $found = get_sample_permalink_html( $p ); |
293 | 293 | $post = get_post( $p ); |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
301 | 301 | public function test_get_sample_permalink_html_should_use_correct_permalink_for_view_post_link_when_changing_slug() { |
302 | 302 | $this->set_permalink_structure( '/%postname%/' ); |
303 | 303 | |
304 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 304 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
305 | 305 | |
306 | 306 | // Published posts should use published permalink |
307 | | $p = self::$factory->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo' ) ); |
| 307 | $p = self::factory()->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo' ) ); |
308 | 308 | |
309 | 309 | $found = get_sample_permalink_html( $p, null, 'new_slug' ); |
310 | 310 | $post = get_post( $p ); |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
313 | 313 | |
314 | 314 | // Scheduled posts should use published permalink |
315 | 315 | $future_date = date( 'Y-m-d H:i:s', time() + 100 ); |
316 | | $p = self::$factory->post->create( array( 'post_status' => 'future', 'post_name' => 'bar', 'post_date' => $future_date ) ); |
| 316 | $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'bar', 'post_date' => $future_date ) ); |
317 | 317 | |
318 | 318 | $found = get_sample_permalink_html( $p, null, 'new_slug' ); |
319 | 319 | $post = get_post( $p ); |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
321 | 321 | $this->assertContains( 'href="' . get_option( 'home' ) . "/" . $post->post_name . '/"', $found, $message ); |
322 | 322 | |
323 | 323 | // Draft posts should use preview link |
324 | | $p = self::$factory->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz' ) ); |
| 324 | $p = self::factory()->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz' ) ); |
325 | 325 | |
326 | 326 | $found = get_sample_permalink_html( $p, null, 'new_slug' ); |
327 | 327 | $post = get_post( $p ); |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
339 | 339 | public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_year_archives() { |
340 | 340 | $this->set_permalink_structure( '/%postname%/' ); |
341 | 341 | |
342 | | $p = self::$factory->post->create( array( |
| 342 | $p = self::factory()->post->create( array( |
343 | 343 | 'post_name' => '2015', |
344 | 344 | ) ); |
345 | 345 | |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
353 | 353 | public function test_get_sample_permalink_should_allow_yearlike_slugs_if_permastruct_does_not_cause_an_archive_conflict() { |
354 | 354 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
355 | 355 | |
356 | | $p = self::$factory->post->create( array( |
| 356 | $p = self::factory()->post->create( array( |
357 | 357 | 'post_name' => '2015', |
358 | 358 | ) ); |
359 | 359 | |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
367 | 367 | public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_month_archives() { |
368 | 368 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
369 | 369 | |
370 | | $p = self::$factory->post->create( array( |
| 370 | $p = self::factory()->post->create( array( |
371 | 371 | 'post_name' => '11', |
372 | 372 | ) ); |
373 | 373 | |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
381 | 381 | public function test_get_sample_permalink_should_ignore_potential_month_conflicts_for_invalid_monthnum() { |
382 | 382 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
383 | 383 | |
384 | | $p = self::$factory->post->create( array( |
| 384 | $p = self::factory()->post->create( array( |
385 | 385 | 'post_name' => '13', |
386 | 386 | ) ); |
387 | 387 | |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
395 | 395 | public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_day_archives() { |
396 | 396 | $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); |
397 | 397 | |
398 | | $p = self::$factory->post->create( array( |
| 398 | $p = self::factory()->post->create( array( |
399 | 399 | 'post_name' => '30', |
400 | 400 | ) ); |
401 | 401 | |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
409 | 409 | public function test_get_sample_permalink_should_iterate_slug_suffix_when_a_date_conflict_is_found() { |
410 | 410 | $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); |
411 | 411 | |
412 | | self::$factory->post->create( array( |
| 412 | self::factory()->post->create( array( |
413 | 413 | 'post_name' => '30-2', |
414 | 414 | ) ); |
415 | 415 | |
416 | | $p = self::$factory->post->create( array( |
| 416 | $p = self::factory()->post->create( array( |
417 | 417 | 'post_name' => '30', |
418 | 418 | ) ); |
419 | 419 | |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
427 | 427 | public function test_get_sample_permalink_should_ignore_potential_day_conflicts_for_invalid_day() { |
428 | 428 | $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); |
429 | 429 | |
430 | | $p = self::$factory->post->create( array( |
| 430 | $p = self::factory()->post->create( array( |
431 | 431 | 'post_name' => '32', |
432 | 432 | ) ); |
433 | 433 | |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
441 | 441 | public function test_get_sample_permalink_should_allow_daylike_slugs_if_permastruct_does_not_cause_an_archive_conflict() { |
442 | 442 | $this->set_permalink_structure( '/%year%/%month%/%day%/%postname%/' ); |
443 | 443 | |
444 | | $p = self::$factory->post->create( array( |
| 444 | $p = self::factory()->post->create( array( |
445 | 445 | 'post_name' => '30', |
446 | 446 | ) ); |
447 | 447 | |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
450 | 450 | } |
451 | 451 | |
452 | 452 | public function test_post_exists_should_match_title() { |
453 | | $p = self::$factory->post->create( array( |
| 453 | $p = self::factory()->post->create( array( |
454 | 454 | 'post_title' => 'Foo Bar', |
455 | 455 | ) ); |
456 | 456 | |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
458 | 458 | } |
459 | 459 | |
460 | 460 | public function test_post_exists_should_not_match_nonexistent_title() { |
461 | | $p = self::$factory->post->create( array( |
| 461 | $p = self::factory()->post->create( array( |
462 | 462 | 'post_title' => 'Foo Bar', |
463 | 463 | ) ); |
464 | 464 | |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
468 | 468 | public function test_post_exists_should_match_nonempty_content() { |
469 | 469 | $title = 'Foo Bar'; |
470 | 470 | $content = 'Foo Bar Baz'; |
471 | | $p = self::$factory->post->create( array( |
| 471 | $p = self::factory()->post->create( array( |
472 | 472 | 'post_title' => $title, |
473 | 473 | 'post_content' => $content, |
474 | 474 | ) ); |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
479 | 479 | public function test_post_exists_should_not_match_when_nonempty_content_doesnt_match() { |
480 | 480 | $title = 'Foo Bar'; |
481 | 481 | $content = 'Foo Bar Baz'; |
482 | | $p = self::$factory->post->create( array( |
| 482 | $p = self::factory()->post->create( array( |
483 | 483 | 'post_title' => $title, |
484 | 484 | 'post_content' => $content . ' Quz', |
485 | 485 | ) ); |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
490 | 490 | public function test_post_exists_should_match_nonempty_date() { |
491 | 491 | $title = 'Foo Bar'; |
492 | 492 | $date = '2014-05-08 12:00:00'; |
493 | | $p = self::$factory->post->create( array( |
| 493 | $p = self::factory()->post->create( array( |
494 | 494 | 'post_title' => $title, |
495 | 495 | 'post_date' => $date, |
496 | 496 | ) ); |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
501 | 501 | public function test_post_exists_should_not_match_when_nonempty_date_doesnt_match() { |
502 | 502 | $title = 'Foo Bar'; |
503 | 503 | $date = '2014-05-08 12:00:00'; |
504 | | $p = self::$factory->post->create( array( |
| 504 | $p = self::factory()->post->create( array( |
505 | 505 | 'post_title' => $title, |
506 | 506 | 'post_date' => '2015-10-10 00:00:00', |
507 | 507 | ) ); |
… |
… |
class Tests_Admin_includesPost extends WP_UnitTestCase { |
513 | 513 | $title = 'Foo Bar'; |
514 | 514 | $content = 'Foo Bar Baz'; |
515 | 515 | $date = '2014-05-08 12:00:00'; |
516 | | $p = self::$factory->post->create( array( |
| 516 | $p = self::factory()->post->create( array( |
517 | 517 | 'post_title' => $title, |
518 | 518 | 'post_content' => $content, |
519 | 519 | 'post_date' => $date, |
-
diff --git tests/phpunit/tests/adminbar.php tests/phpunit/tests/adminbar.php
index 0ef6647..cf83adc 100644
|
|
class Tests_AdminBar extends WP_UnitTestCase { |
15 | 15 | * @ticket 21117 |
16 | 16 | */ |
17 | 17 | function test_content_post_type() { |
18 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'editor' ) ) ); |
| 18 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) ); |
19 | 19 | |
20 | 20 | register_post_type( 'content', array( 'show_in_admin_bar' => true ) ); |
21 | 21 | |
… |
… |
class Tests_AdminBar extends WP_UnitTestCase { |
34 | 34 | * @ticket 21117 |
35 | 35 | */ |
36 | 36 | function test_merging_existing_meta_values() { |
37 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'editor' ) ) ); |
| 37 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) ); |
38 | 38 | |
39 | 39 | $admin_bar = new WP_Admin_Bar; |
40 | 40 | |
… |
… |
class Tests_AdminBar extends WP_UnitTestCase { |
62 | 62 | $this->markTestSkipped( 'Test does not run in multisite' ); |
63 | 63 | } |
64 | 64 | |
65 | | $nobody = self::$factory->user->create( array( 'role' => '' ) ); |
| 65 | $nobody = self::factory()->user->create( array( 'role' => '' ) ); |
66 | 66 | $this->assertFalse( user_can( $nobody, 'read' ) ); |
67 | 67 | |
68 | 68 | wp_set_current_user( $nobody ); |
… |
… |
class Tests_AdminBar extends WP_UnitTestCase { |
92 | 92 | $this->markTestSkipped( 'Test does not run in multisite' ); |
93 | 93 | } |
94 | 94 | |
95 | | $editor = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 95 | $editor = self::factory()->user->create( array( 'role' => 'editor' ) ); |
96 | 96 | $this->assertTrue( user_can( $editor, 'read' ) ); |
97 | 97 | |
98 | 98 | wp_set_current_user( $editor ); |
… |
… |
class Tests_AdminBar extends WP_UnitTestCase { |
125 | 125 | $this->markTestSkipped( 'Test only runs in multisite' ); |
126 | 126 | } |
127 | 127 | |
128 | | $admin = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
129 | | $editor = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 128 | $admin = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
| 129 | $editor = self::factory()->user->create( array( 'role' => 'editor' ) ); |
130 | 130 | |
131 | 131 | $this->assertTrue( user_can( $admin, 'read' ) ); |
132 | 132 | $this->assertTrue( user_can( $editor, 'read' ) ); |
133 | 133 | |
134 | | $new_blog_id = self::$factory->blog->create( array( |
| 134 | $new_blog_id = self::factory()->blog->create( array( |
135 | 135 | 'user_id' => $admin, |
136 | 136 | ) ); |
137 | 137 | |
… |
… |
class Tests_AdminBar extends WP_UnitTestCase { |
179 | 179 | $this->markTestSkipped( 'Test only runs in multisite' ); |
180 | 180 | } |
181 | 181 | |
182 | | $admin = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
183 | | $nobody = self::$factory->user->create( array( 'role' => '' ) ); |
| 182 | $admin = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
| 183 | $nobody = self::factory()->user->create( array( 'role' => '' ) ); |
184 | 184 | |
185 | 185 | $this->assertTrue( user_can( $admin, 'read' ) ); |
186 | 186 | $this->assertFalse( user_can( $nobody, 'read' ) ); |
187 | 187 | |
188 | | $new_blog_id = self::$factory->blog->create( array( |
| 188 | $new_blog_id = self::factory()->blog->create( array( |
189 | 189 | 'user_id' => $admin, |
190 | 190 | ) ); |
191 | 191 | |
-
diff --git tests/phpunit/tests/ajax/Autosave.php tests/phpunit/tests/ajax/Autosave.php
index aac9274..4b2b26c 100644
|
|
class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase { |
33 | 33 | public function setUp() { |
34 | 34 | parent::setUp(); |
35 | 35 | // Set a user so the $post has 'post_author' |
36 | | $this->user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 36 | $this->user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
37 | 37 | wp_set_current_user( $this->user_id ); |
38 | 38 | |
39 | | $post_id = self::$factory->post->create( array( 'post_status' => 'draft' ) ); |
| 39 | $post_id = self::factory()->post->create( array( 'post_status' => 'draft' ) ); |
40 | 40 | $this->_post = get_post( $post_id ); |
41 | 41 | } |
42 | 42 | |
… |
… |
class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase { |
97 | 97 | */ |
98 | 98 | public function test_autosave_locked_post() { |
99 | 99 | // Lock the post to another user |
100 | | $another_user_id = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 100 | $another_user_id = self::factory()->user->create( array( 'role' => 'editor' ) ); |
101 | 101 | wp_set_current_user( $another_user_id ); |
102 | 102 | wp_set_post_lock( $this->_post->ID ); |
103 | 103 | |
-
diff --git tests/phpunit/tests/ajax/CustomizeMenus.php tests/phpunit/tests/ajax/CustomizeMenus.php
index 94fc646..87191c6 100644
|
|
class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { |
22 | 22 | public function setUp() { |
23 | 23 | parent::setUp(); |
24 | 24 | require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; |
25 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 25 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
26 | 26 | global $wp_customize; |
27 | 27 | $this->wp_customize = new WP_Customize_Manager(); |
28 | 28 | $wp_customize = $this->wp_customize; |
… |
… |
class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { |
65 | 65 | $this->setExpectedException( 'WPAjaxDieStopException' ); |
66 | 66 | } |
67 | 67 | |
68 | | wp_set_current_user( self::$factory->user->create( array( 'role' => $role ) ) ); |
| 68 | wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) ); |
69 | 69 | |
70 | 70 | $_POST = array( |
71 | 71 | 'action' => 'load-available-menu-items-customizer', |
… |
… |
class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { |
307 | 307 | ); |
308 | 308 | |
309 | 309 | // Create some terms and pages. |
310 | | self::$factory->term->create_many( 5 ); |
311 | | self::$factory->post->create_many( 5, array( 'post_type' => 'page' ) ); |
| 310 | self::factory()->term->create_many( 5 ); |
| 311 | self::factory()->post->create_many( 5, array( 'post_type' => 'page' ) ); |
312 | 312 | |
313 | 313 | $_POST = array_merge( array( |
314 | 314 | 'action' => 'load-available-menu-items-customizer', |
… |
… |
class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { |
396 | 396 | $this->setExpectedException( 'WPAjaxDieStopException' ); |
397 | 397 | } |
398 | 398 | |
399 | | wp_set_current_user( self::$factory->user->create( array( 'role' => $role ) ) ); |
| 399 | wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) ); |
400 | 400 | |
401 | 401 | $_POST = array( |
402 | 402 | 'action' => 'search-available-menu-items-customizer', |
… |
… |
class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { |
469 | 469 | */ |
470 | 470 | function test_ajax_search_available_items_results( $post_args, $expected_results ) { |
471 | 471 | |
472 | | self::$factory->post->create_many( 5, array( 'post_title' => 'Test Post' ) ); |
| 472 | self::factory()->post->create_many( 5, array( 'post_title' => 'Test Post' ) ); |
473 | 473 | |
474 | 474 | $_POST = array_merge( array( |
475 | 475 | 'action' => 'search-available-menu-items-customizer', |
-
diff --git tests/phpunit/tests/ajax/DeleteComment.php tests/phpunit/tests/ajax/DeleteComment.php
index 8b3282a..182894e 100644
|
|
class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase { |
26 | 26 | */ |
27 | 27 | public function setUp() { |
28 | 28 | parent::setUp(); |
29 | | $post_id = self::$factory->post->create(); |
30 | | $this->_comments = self::$factory->comment->create_post_comments( $post_id, 15 ); |
| 29 | $post_id = self::factory()->post->create(); |
| 30 | $this->_comments = self::factory()->comment->create_post_comments( $post_id, 15 ); |
31 | 31 | $this->_comments = array_map( 'get_comment', $this->_comments ); |
32 | 32 | } |
33 | 33 | |
-
diff --git tests/phpunit/tests/ajax/DimComment.php tests/phpunit/tests/ajax/DimComment.php
index 9795f7b..ba06f42 100644
|
|
class Tests_Ajax_DimComment extends WP_Ajax_UnitTestCase { |
26 | 26 | */ |
27 | 27 | public function setUp() { |
28 | 28 | parent::setUp(); |
29 | | $post_id = self::$factory->post->create(); |
30 | | $this->_comments = self::$factory->comment->create_post_comments( $post_id, 15 ); |
| 29 | $post_id = self::factory()->post->create(); |
| 30 | $this->_comments = self::factory()->comment->create_post_comments( $post_id, 15 ); |
31 | 31 | $this->_comments = array_map( 'get_comment', $this->_comments ); |
32 | 32 | } |
33 | 33 | |
-
diff --git tests/phpunit/tests/ajax/EditComment.php tests/phpunit/tests/ajax/EditComment.php
index b29690d..ef5c647 100644
|
|
class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase { |
26 | 26 | */ |
27 | 27 | public function setUp() { |
28 | 28 | parent::setUp(); |
29 | | $post_id = self::$factory->post->create(); |
30 | | self::$factory->comment->create_post_comments( $post_id, 5 ); |
| 29 | $post_id = self::factory()->post->create(); |
| 30 | self::factory()->comment->create_post_comments( $post_id, 5 ); |
31 | 31 | $this->_comment_post = get_post( $post_id ); |
32 | 32 | } |
33 | 33 | |
-
diff --git tests/phpunit/tests/ajax/GetComments.php tests/phpunit/tests/ajax/GetComments.php
index 3702b0b..911bf00 100644
|
|
class Tests_Ajax_GetComments extends WP_Ajax_UnitTestCase { |
32 | 32 | */ |
33 | 33 | public function setUp() { |
34 | 34 | parent::setUp(); |
35 | | $post_id = self::$factory->post->create(); |
36 | | self::$factory->comment->create_post_comments( $post_id, 5 ); |
| 35 | $post_id = self::factory()->post->create(); |
| 36 | self::factory()->comment->create_post_comments( $post_id, 5 ); |
37 | 37 | $this->_comment_post = get_post( $post_id ); |
38 | 38 | |
39 | | $post_id = self::$factory->post->create(); |
| 39 | $post_id = self::factory()->post->create(); |
40 | 40 | $this->_no_comment_post = get_post( $post_id ); |
41 | 41 | |
42 | 42 | unset( $GLOBALS['post_id'] ); |
-
diff --git tests/phpunit/tests/ajax/QuickEdit.php tests/phpunit/tests/ajax/QuickEdit.php
index a7ce874..357ab1f 100644
|
|
class Tests_Ajax_QuickEdit extends WP_Ajax_UnitTestCase { |
25 | 25 | 'hierarchical' => true, |
26 | 26 | ) ); |
27 | 27 | |
28 | | $t1 = self::$factory->term->create( array( |
| 28 | $t1 = self::factory()->term->create( array( |
29 | 29 | 'taxonomy' => 'wptests_tax_1', |
30 | 30 | ) ); |
31 | | $t2 = self::$factory->term->create( array( |
| 31 | $t2 = self::factory()->term->create( array( |
32 | 32 | 'taxonomy' => 'wptests_tax_2', |
33 | 33 | ) ); |
34 | 34 | |
35 | 35 | // Become an administrator. |
36 | 36 | $this->_setRole( 'administrator' ); |
37 | 37 | |
38 | | $post = self::$factory->post->create_and_get( array( |
| 38 | $post = self::factory()->post->create_and_get( array( |
39 | 39 | 'post_author' => get_current_user_id(), |
40 | 40 | ) ); |
41 | 41 | |
-
diff --git tests/phpunit/tests/ajax/ReplytoComment.php tests/phpunit/tests/ajax/ReplytoComment.php
index 98e7965..e0f001c 100644
|
|
class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { |
32 | 32 | */ |
33 | 33 | public function setUp() { |
34 | 34 | parent::setUp(); |
35 | | $post_id = self::$factory->post->create(); |
36 | | self::$factory->comment->create_post_comments( $post_id, 5 ); |
| 35 | $post_id = self::factory()->post->create(); |
| 36 | self::factory()->comment->create_post_comments( $post_id, 5 ); |
37 | 37 | $this->_comment_post = get_post( $post_id ); |
38 | 38 | |
39 | | $post_id = self::$factory->post->create( array( 'post_status' => 'draft' ) ); |
| 39 | $post_id = self::factory()->post->create( array( 'post_status' => 'draft' ) ); |
40 | 40 | $this->_draft_post = get_post( $post_id ); |
41 | 41 | } |
42 | 42 | |
-
diff --git tests/phpunit/tests/attachment/slashes.php tests/phpunit/tests/attachment/slashes.php
index b44d5a9..724e6a9 100644
|
|
|
8 | 8 | class Tests_Attachment_Slashes extends WP_UnitTestCase { |
9 | 9 | function setUp() { |
10 | 10 | parent::setUp(); |
11 | | $this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 11 | $this->author_id = self::factory()->user->create( array( 'role' => 'editor' ) ); |
12 | 12 | $this->old_current_user = get_current_user_id(); |
13 | 13 | wp_set_current_user( $this->author_id ); |
14 | 14 | |
-
diff --git tests/phpunit/tests/avatar.php tests/phpunit/tests/avatar.php
index 7475e45..e777f10 100644
|
|
class Tests_Avatar extends WP_UnitTestCase { |
87 | 87 | $url2 = get_avatar_url( $user ); |
88 | 88 | $this->assertEquals( $url, $url2 ); |
89 | 89 | |
90 | | $post_id = self::$factory->post->create( array( 'post_author' => 1 ) ); |
| 90 | $post_id = self::factory()->post->create( array( 'post_author' => 1 ) ); |
91 | 91 | $post = get_post( $post_id ); |
92 | 92 | $url2 = get_avatar_url( $post ); |
93 | 93 | $this->assertEquals( $url, $url2 ); |
94 | 94 | |
95 | | $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1 ) ); |
| 95 | $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1 ) ); |
96 | 96 | $comment = get_comment( $comment_id ); |
97 | 97 | $url2 = get_avatar_url( $comment ); |
98 | 98 | $this->assertEquals( $url, $url2 ); |
… |
… |
class Tests_Avatar extends WP_UnitTestCase { |
138 | 138 | public function test_get_avatar_comment_types_filter() { |
139 | 139 | $url = get_avatar_url( 1 ); |
140 | 140 | |
141 | | $post_id = self::$factory->post->create( array( 'post_author' => 1 ) ); |
142 | | $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1, 'comment_type' => 'pingback' ) ); |
| 141 | $post_id = self::factory()->post->create( array( 'post_author' => 1 ) ); |
| 142 | $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1, 'comment_type' => 'pingback' ) ); |
143 | 143 | $comment = get_comment( $comment_id ); |
144 | 144 | |
145 | 145 | $url2 = get_avatar_url( $comment ); |
-
diff --git tests/phpunit/tests/canonical/pageOnFront.php tests/phpunit/tests/canonical/pageOnFront.php
index 53afc8c..030befa 100644
|
|
class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase { |
18 | 18 | parent::setUp(); |
19 | 19 | |
20 | 20 | update_option( 'show_on_front', 'page' ); |
21 | | update_option( 'page_for_posts', self::$factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) ); |
22 | | update_option( 'page_on_front', self::$factory->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) ); |
| 21 | update_option( 'page_for_posts', self::factory()->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) ); |
| 22 | update_option( 'page_on_front', self::factory()->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) ); |
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
-
diff --git tests/phpunit/tests/canonical/paged.php tests/phpunit/tests/canonical/paged.php
index f734f40..8f1dbfd 100644
|
|
class Tests_Canonical_Paged extends WP_Canonical_UnitTestCase { |
12 | 12 | This is a paragraph.'; |
13 | 13 | $next = '<!--nextpage-->'; |
14 | 14 | |
15 | | $post_id = self::$factory->post->create( array( |
| 15 | $post_id = self::factory()->post->create( array( |
16 | 16 | 'post_status' => 'publish', |
17 | 17 | 'post_content' => "{$para}{$next}{$para}{$next}{$para}" |
18 | 18 | ) ); |
-
diff --git tests/phpunit/tests/category.php tests/phpunit/tests/category.php
index 613e6d5..913f4dc 100644
|
|
class Tests_Category extends WP_UnitTestCase { |
21 | 21 | */ |
22 | 22 | function test_get_all_category_ids() { |
23 | 23 | // create categories |
24 | | self::$factory->category->create_many( 2 ); |
| 24 | self::factory()->category->create_many( 2 ); |
25 | 25 | |
26 | 26 | // create new taxonomy to ensure not included |
27 | 27 | register_taxonomy( 'test_tax_cat', 'post' ); |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
38 | 38 | function test_get_category_by_slug() { |
39 | 39 | |
40 | 40 | // create Test Categories |
41 | | $testcat = self::$factory->category->create_and_get( |
| 41 | $testcat = self::factory()->category->create_and_get( |
42 | 42 | array( |
43 | 43 | 'slug' => 'testcat', |
44 | 44 | 'name' => 'Test Category 1' |
45 | 45 | ) |
46 | 46 | ); |
47 | | $testcat2 = self::$factory->category->create_and_get( |
| 47 | $testcat2 = self::factory()->category->create_and_get( |
48 | 48 | array( |
49 | 49 | 'slug' => 'testcat2', |
50 | 50 | 'name' => 'Test Category 2' |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
73 | 73 | 'name' => 'Test MCC', |
74 | 74 | 'description' => 'Category Test' |
75 | 75 | ); |
76 | | $testcat = self::$factory->category->create_and_get( $testcat_array ); |
| 76 | $testcat = self::factory()->category->create_and_get( $testcat_array ); |
77 | 77 | $testcat_array['term_id'] = $testcat->term_id; |
78 | 78 | |
79 | 79 | $testcat2_array = array( |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
82 | 82 | 'description' => 'Category Test', |
83 | 83 | 'parent' => $testcat->term_id |
84 | 84 | ); |
85 | | $testcat2 = self::$factory->category->create_and_get( $testcat2_array ); |
| 85 | $testcat2 = self::factory()->category->create_and_get( $testcat2_array ); |
86 | 86 | $testcat2_array['term_id'] = $testcat2->term_id; |
87 | 87 | |
88 | 88 | // unset properties to enable validation of object |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
145 | 145 | function test_get_cat_name() { |
146 | 146 | |
147 | 147 | // create Test Category |
148 | | $testcat = self::$factory->category->create_and_get( |
| 148 | $testcat = self::factory()->category->create_and_get( |
149 | 149 | array( |
150 | 150 | 'slug' => 'testcat', |
151 | 151 | 'name' => 'Test Category 1' |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
165 | 165 | function test_get_cat_ID() { |
166 | 166 | |
167 | 167 | // create Test Category |
168 | | $testcat = self::$factory->category->create_and_get( |
| 168 | $testcat = self::factory()->category->create_and_get( |
169 | 169 | array( |
170 | 170 | 'slug' => 'testcat', |
171 | 171 | 'name' => 'Test Category 1' |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
185 | 185 | function test_get_category_by_path() { |
186 | 186 | |
187 | 187 | // create Test Categories |
188 | | $root_id = self::$factory->category->create( |
| 188 | $root_id = self::factory()->category->create( |
189 | 189 | array( |
190 | 190 | 'slug' => 'root', |
191 | 191 | ) |
192 | 192 | ); |
193 | | $root_cat_id = self::$factory->category->create( |
| 193 | $root_cat_id = self::factory()->category->create( |
194 | 194 | array( |
195 | 195 | 'slug' => 'cat', |
196 | 196 | 'parent' => $root_id |
197 | 197 | ) |
198 | 198 | ); |
199 | | $root_cat_cat_id = self::$factory->category->create( |
| 199 | $root_cat_cat_id = self::factory()->category->create( |
200 | 200 | array( |
201 | 201 | 'slug' => 'cat', //note this is modified on create |
202 | 202 | 'parent' => $root_cat_id |
203 | 203 | ) |
204 | 204 | ); |
205 | | $root_path_id = self::$factory->category->create( |
| 205 | $root_path_id = self::factory()->category->create( |
206 | 206 | array( |
207 | 207 | 'slug' => 'path', |
208 | 208 | 'parent' => $root_id |
209 | 209 | ) |
210 | 210 | ); |
211 | | $root_path_cat_id = self::$factory->category->create( |
| 211 | $root_path_cat_id = self::factory()->category->create( |
212 | 212 | array( |
213 | 213 | 'slug' => 'cat', //note this is modified on create |
214 | 214 | 'parent' => $root_path_id |
215 | 215 | ) |
216 | 216 | ); |
217 | | $root_level_id = self::$factory->category->create( |
| 217 | $root_level_id = self::factory()->category->create( |
218 | 218 | array( |
219 | 219 | 'slug' => 'level-1', |
220 | 220 | 'parent' => $root_id |
221 | 221 | ) |
222 | 222 | ); |
223 | | $root_level_cat_id = self::$factory->category->create( |
| 223 | $root_level_cat_id = self::factory()->category->create( |
224 | 224 | array( |
225 | 225 | 'slug' => 'cat', //note this is modified on create |
226 | 226 | 'parent' => $root_level_id |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
248 | 248 | */ |
249 | 249 | public function test_wp_dropdown_categories_value_field_should_default_to_term_id() { |
250 | 250 | // Create a test category. |
251 | | $cat_id = self::$factory->category->create( array( |
| 251 | $cat_id = self::factory()->category->create( array( |
252 | 252 | 'name' => 'Test Category', |
253 | 253 | 'slug' => 'test_category', |
254 | 254 | ) ); |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
268 | 268 | */ |
269 | 269 | public function test_wp_dropdown_categories_value_field_term_id() { |
270 | 270 | // Create a test category. |
271 | | $cat_id = self::$factory->category->create( array( |
| 271 | $cat_id = self::factory()->category->create( array( |
272 | 272 | 'name' => 'Test Category', |
273 | 273 | 'slug' => 'test_category', |
274 | 274 | ) ); |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
289 | 289 | */ |
290 | 290 | public function test_wp_dropdown_categories_value_field_slug() { |
291 | 291 | // Create a test category. |
292 | | $cat_id = self::$factory->category->create( array( |
| 292 | $cat_id = self::factory()->category->create( array( |
293 | 293 | 'name' => 'Test Category', |
294 | 294 | 'slug' => 'test_category', |
295 | 295 | ) ); |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
310 | 310 | */ |
311 | 311 | public function test_wp_dropdown_categories_value_field_should_fall_back_on_term_id_when_an_invalid_value_is_provided() { |
312 | 312 | // Create a test category. |
313 | | $cat_id = self::$factory->category->create( array( |
| 313 | $cat_id = self::factory()->category->create( array( |
314 | 314 | 'name' => 'Test Category', |
315 | 315 | 'slug' => 'test_category', |
316 | 316 | ) ); |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
330 | 330 | * @ticket 32330 |
331 | 331 | */ |
332 | 332 | public function test_wp_dropdown_categories_selected_should_respect_custom_value_field() { |
333 | | $c1 = self::$factory->category->create( array( |
| 333 | $c1 = self::factory()->category->create( array( |
334 | 334 | 'name' => 'Test Category 1', |
335 | 335 | 'slug' => 'test_category_1', |
336 | 336 | ) ); |
337 | 337 | |
338 | | $c2 = self::$factory->category->create( array( |
| 338 | $c2 = self::factory()->category->create( array( |
339 | 339 | 'name' => 'Test Category 2', |
340 | 340 | 'slug' => 'test_category_2', |
341 | 341 | ) ); |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
354 | 354 | * @ticket 33452 |
355 | 355 | */ |
356 | 356 | public function test_wp_dropdown_categories_show_option_all_should_be_selected_if_no_selected_value_is_explicitly_passed_and_value_field_does_not_have_string_values() { |
357 | | $cats = self::$factory->category->create_many( 3 ); |
| 357 | $cats = self::factory()->category->create_many( 3 ); |
358 | 358 | |
359 | 359 | $found = wp_dropdown_categories( array( |
360 | 360 | 'echo' => 0, |
… |
… |
class Tests_Category extends WP_UnitTestCase { |
375 | 375 | * @ticket 33452 |
376 | 376 | */ |
377 | 377 | public function test_wp_dropdown_categories_show_option_all_should_be_selected_if_selected_value_of_0_string_is_explicitly_passed_and_value_field_does_not_have_string_values() { |
378 | | $cats = self::$factory->category->create_many( 3 ); |
| 378 | $cats = self::factory()->category->create_many( 3 ); |
379 | 379 | |
380 | 380 | $found = wp_dropdown_categories( array( |
381 | 381 | 'echo' => 0, |
-
diff --git tests/phpunit/tests/category/getCategoryParents.php tests/phpunit/tests/category/getCategoryParents.php
index b9c6998..9805de9 100644
|
|
class Tests_Category_GetCategoryParents extends WP_UnitTestCase { |
10 | 10 | public function setUp() { |
11 | 11 | parent::setUp(); |
12 | 12 | |
13 | | $this->c1 = self::$factory->category->create_and_get(); |
14 | | $this->c2 = self::$factory->category->create_and_get( array( |
| 13 | $this->c1 = self::factory()->category->create_and_get(); |
| 14 | $this->c2 = self::factory()->category->create_and_get( array( |
15 | 15 | 'parent' => $this->c1->term_id, |
16 | 16 | ) ); |
17 | 17 | } |
… |
… |
class Tests_Category_GetCategoryParents extends WP_UnitTestCase { |
51 | 51 | } |
52 | 52 | |
53 | 53 | public function test_visited() { |
54 | | $c3 = self::$factory->category->create_and_get( array( |
| 54 | $c3 = self::factory()->category->create_and_get( array( |
55 | 55 | 'parent' => $this->c2->term_id, |
56 | 56 | ) ); |
57 | | $c4 = self::$factory->category->create_and_get( array( |
| 57 | $c4 = self::factory()->category->create_and_get( array( |
58 | 58 | 'parent' => $c3->term_id, |
59 | 59 | ) ); |
60 | 60 | |
-
diff --git tests/phpunit/tests/category/wpListCategories.php tests/phpunit/tests/category/wpListCategories.php
index 0a49f0f..048f72d 100644
|
|
|
5 | 5 | */ |
6 | 6 | class Tests_Category_WpListCategories extends WP_UnitTestCase { |
7 | 7 | public function test_class() { |
8 | | $c = self::$factory->category->create(); |
| 8 | $c = self::factory()->category->create(); |
9 | 9 | |
10 | 10 | $found = wp_list_categories( array( |
11 | 11 | 'hide_empty' => false, |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function test_class_containing_current_cat() { |
19 | | $c1 = self::$factory->category->create(); |
20 | | $c2 = self::$factory->category->create(); |
| 19 | $c1 = self::factory()->category->create(); |
| 20 | $c2 = self::factory()->category->create(); |
21 | 21 | |
22 | 22 | $found = wp_list_categories( array( |
23 | 23 | 'hide_empty' => false, |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function test_class_containing_current_cat_parent() { |
33 | | $c1 = self::$factory->category->create(); |
34 | | $c2 = self::$factory->category->create( array( |
| 33 | $c1 = self::factory()->category->create(); |
| 34 | $c2 = self::factory()->category->create( array( |
35 | 35 | 'parent' => $c1, |
36 | 36 | ) ); |
37 | 37 | |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
49 | 49 | * @ticket 33565 |
50 | 50 | */ |
51 | 51 | public function test_current_category_should_accept_an_array_of_ids() { |
52 | | $cats = self::$factory->category->create_many( 3 ); |
| 52 | $cats = self::factory()->category->create_many( 3 ); |
53 | 53 | |
54 | 54 | $found = wp_list_categories( array( |
55 | 55 | 'echo' => false, |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
66 | 66 | * @ticket 16792 |
67 | 67 | */ |
68 | 68 | public function test_should_not_create_element_when_cat_name_is_filtered_to_empty_string() { |
69 | | $c1 = self::$factory->category->create( array( |
| 69 | $c1 = self::factory()->category->create( array( |
70 | 70 | 'name' => 'Test Cat 1', |
71 | 71 | ) ); |
72 | | $c2 = self::$factory->category->create( array( |
| 72 | $c2 = self::factory()->category->create( array( |
73 | 73 | 'name' => 'Test Cat 2', |
74 | 74 | ) ); |
75 | 75 | |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
88 | 88 | } |
89 | 89 | |
90 | 90 | public function test_show_option_all_link_should_go_to_home_page_when_show_on_front_is_false() { |
91 | | $cats = self::$factory->category->create_many( 2 ); |
| 91 | $cats = self::factory()->category->create_many( 2 ); |
92 | 92 | |
93 | 93 | $found = wp_list_categories( array( |
94 | 94 | 'echo' => false, |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
101 | 101 | } |
102 | 102 | |
103 | 103 | public function test_show_option_all_link_should_respect_page_for_posts() { |
104 | | $cats = self::$factory->category->create_many( 2 ); |
105 | | $p = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 104 | $cats = self::factory()->category->create_many( 2 ); |
| 105 | $p = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
106 | 106 | |
107 | 107 | update_option( 'show_on_front', 'page' ); |
108 | 108 | update_option( 'page_for_posts', $p ); |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
125 | 125 | register_post_type( 'wptests_pt2', array( 'has_archive' => true ) ); |
126 | 126 | register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) ); |
127 | 127 | |
128 | | $terms = self::$factory->term->create_many( 2, array( |
| 128 | $terms = self::factory()->term->create_many( 2, array( |
129 | 129 | 'taxonomy' => 'wptests_tax', |
130 | 130 | ) ); |
131 | 131 | |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
149 | 149 | register_post_type( 'wptests_pt2', array( 'has_archive' => true ) ); |
150 | 150 | register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) ); |
151 | 151 | |
152 | | $terms = self::$factory->term->create_many( 2, array( |
| 152 | $terms = self::factory()->term->create_many( 2, array( |
153 | 153 | 'taxonomy' => 'wptests_tax', |
154 | 154 | ) ); |
155 | 155 | |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
170 | 170 | register_post_type( 'wptests_pt2', array( 'has_archive' => true ) ); |
171 | 171 | register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'post', 'wptests_pt2' ) ); |
172 | 172 | |
173 | | $terms = self::$factory->term->create_many( 2, array( |
| 173 | $terms = self::factory()->term->create_many( 2, array( |
174 | 174 | 'taxonomy' => 'wptests_tax', |
175 | 175 | ) ); |
176 | 176 | |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
191 | 191 | register_post_type( 'wptests_pt2', array( 'has_archive' => false ) ); |
192 | 192 | register_taxonomy( 'wptests_tax', array( 'foo', 'wptests_pt', 'wptests_pt2' ) ); |
193 | 193 | |
194 | | $terms = self::$factory->term->create_many( 2, array( |
| 194 | $terms = self::factory()->term->create_many( 2, array( |
195 | 195 | 'taxonomy' => 'wptests_tax', |
196 | 196 | ) ); |
197 | 197 | |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
254 | 254 | * @ticket 33460 |
255 | 255 | */ |
256 | 256 | public function test_hide_title_if_empty_should_be_ignored_when_category_list_is_not_empty() { |
257 | | $cat = self::$factory->category->create(); |
| 257 | $cat = self::factory()->category->create(); |
258 | 258 | |
259 | 259 | $found = wp_list_categories( array( |
260 | 260 | 'echo' => false, |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
269 | 269 | * @ticket 12981 |
270 | 270 | */ |
271 | 271 | public function test_exclude_tree_should_be_respected() { |
272 | | $c = self::$factory->category->create(); |
273 | | $parent = self::$factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) ); |
274 | | $child = self::$factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) ); |
| 272 | $c = self::factory()->category->create(); |
| 273 | $parent = self::factory()->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) ); |
| 274 | $child = self::factory()->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) ); |
275 | 275 | |
276 | 276 | $args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude_tree' => $parent ); |
277 | 277 | |
… |
… |
class Tests_Category_WpListCategories extends WP_UnitTestCase { |
286 | 286 | * @ticket 12981 |
287 | 287 | */ |
288 | 288 | public function test_exclude_tree_should_be_merged_with_exclude() { |
289 | | $c = self::$factory->category->create(); |
290 | | $parent = self::$factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) ); |
291 | | $child = self::$factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) ); |
292 | | $parent2 = self::$factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent2' ) ); |
293 | | $child2 = self::$factory->category->create( array( 'name' => 'Child', 'slug' => 'child2', 'parent' => $parent2 ) ); |
| 289 | $c = self::factory()->category->create(); |
| 290 | $parent = self::factory()->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) ); |
| 291 | $child = self::factory()->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $parent ) ); |
| 292 | $parent2 = self::factory()->category->create( array( 'name' => 'Parent', 'slug' => 'parent2' ) ); |
| 293 | $child2 = self::factory()->category->create( array( 'name' => 'Child', 'slug' => 'child2', 'parent' => $parent2 ) ); |
294 | 294 | |
295 | 295 | $args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude_tree' => $parent ); |
296 | 296 | |
-
diff --git tests/phpunit/tests/comment-submission.php tests/phpunit/tests/comment-submission.php
index 1fed4f4..96ba7a2 100644
|
|
class Tests_Comment_Submission extends WP_UnitTestCase { |
38 | 38 | |
39 | 39 | $this->assertSame( 0, did_action( $error ) ); |
40 | 40 | |
41 | | $post = self::$factory->post->create_and_get( array( |
| 41 | $post = self::factory()->post->create_and_get( array( |
42 | 42 | 'comment_status' => 'closed', |
43 | 43 | ) ); |
44 | 44 | $data = array( |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
58 | 58 | |
59 | 59 | $this->assertSame( 0, did_action( $error ) ); |
60 | 60 | |
61 | | $post = self::$factory->post->create_and_get(); |
| 61 | $post = self::factory()->post->create_and_get(); |
62 | 62 | wp_trash_post( $post ); |
63 | 63 | $data = array( |
64 | 64 | 'comment_post_ID' => $post->ID, |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
77 | 77 | |
78 | 78 | $this->assertSame( 0, did_action( $error ) ); |
79 | 79 | |
80 | | $post = self::$factory->post->create_and_get( array( |
| 80 | $post = self::factory()->post->create_and_get( array( |
81 | 81 | 'post_status' => 'draft', |
82 | 82 | ) ); |
83 | 83 | $data = array( |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
98 | 98 | |
99 | 99 | $this->assertSame( 0, did_action( $error ) ); |
100 | 100 | |
101 | | $post = self::$factory->post->create_and_get( array( |
| 101 | $post = self::factory()->post->create_and_get( array( |
102 | 102 | 'post_date' => date( 'Y-m-d H:i:s', strtotime( '+1 day' ) ), |
103 | 103 | ) ); |
104 | 104 | |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
121 | 121 | |
122 | 122 | $this->assertSame( 0, did_action( $error ) ); |
123 | 123 | |
124 | | $post = self::$factory->post->create_and_get( array( |
| 124 | $post = self::factory()->post->create_and_get( array( |
125 | 125 | 'post_password' => 'password', |
126 | 126 | ) ); |
127 | 127 | $data = array( |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
142 | 142 | |
143 | 143 | $_COOKIE['wp-postpass_' . COOKIEHASH] = $hasher->HashPassword( $password ); |
144 | 144 | |
145 | | $post = self::$factory->post->create_and_get( array( |
| 145 | $post = self::factory()->post->create_and_get( array( |
146 | 146 | 'post_password' => $password, |
147 | 147 | ) ); |
148 | 148 | $data = array( |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
162 | 162 | |
163 | 163 | public function test_submitting_valid_comment_as_logged_in_user_succeeds() { |
164 | 164 | |
165 | | $user = self::$factory->user->create_and_get( array( |
| 165 | $user = self::factory()->user->create_and_get( array( |
166 | 166 | 'user_url' => 'http://user.example.org' |
167 | 167 | ) ); |
168 | 168 | |
169 | 169 | wp_set_current_user( $user->ID ); |
170 | 170 | |
171 | | $post = self::$factory->post->create_and_get(); |
| 171 | $post = self::factory()->post->create_and_get(); |
172 | 172 | $data = array( |
173 | 173 | 'comment_post_ID' => $post->ID, |
174 | 174 | 'comment' => 'Comment', |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
187 | 187 | |
188 | 188 | public function test_submitting_valid_comment_anonymously_succeeds() { |
189 | 189 | |
190 | | $post = self::$factory->post->create_and_get(); |
| 190 | $post = self::factory()->post->create_and_get(); |
191 | 191 | $data = array( |
192 | 192 | 'comment_post_ID' => $post->ID, |
193 | 193 | 'comment' => 'Comment', |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
214 | 214 | */ |
215 | 215 | public function test_submitting_comment_handles_slashes_correctly_handles_slashes() { |
216 | 216 | |
217 | | $post = self::$factory->post->create_and_get(); |
| 217 | $post = self::factory()->post->create_and_get(); |
218 | 218 | $data = array( |
219 | 219 | 'comment_post_ID' => $post->ID, |
220 | 220 | 'comment' => 'Comment with 1 slash: \\', |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
236 | 236 | |
237 | 237 | $error = 'not_logged_in'; |
238 | 238 | |
239 | | $post = self::$factory->post->create_and_get( array( |
| 239 | $post = self::factory()->post->create_and_get( array( |
240 | 240 | 'post_status' => 'private', |
241 | 241 | ) ); |
242 | 242 | $data = array( |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
252 | 252 | |
253 | 253 | public function test_submitting_comment_to_own_private_post_succeeds() { |
254 | 254 | |
255 | | $user = self::$factory->user->create_and_get(); |
| 255 | $user = self::factory()->user->create_and_get(); |
256 | 256 | |
257 | 257 | wp_set_current_user( $user->ID ); |
258 | 258 | |
259 | | $post = self::$factory->post->create_and_get( array( |
| 259 | $post = self::factory()->post->create_and_get( array( |
260 | 260 | 'post_status' => 'private', |
261 | 261 | 'post_author' => $user->ID, |
262 | 262 | ) ); |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
274 | 274 | |
275 | 275 | public function test_submitting_comment_to_accessible_private_post_succeeds() { |
276 | 276 | |
277 | | $author = self::$factory->user->create_and_get( array( |
| 277 | $author = self::factory()->user->create_and_get( array( |
278 | 278 | 'role' => 'author', |
279 | 279 | ) ); |
280 | | $user = self::$factory->user->create_and_get( array( |
| 280 | $user = self::factory()->user->create_and_get( array( |
281 | 281 | 'role' => 'editor', |
282 | 282 | ) ); |
283 | 283 | |
284 | 284 | wp_set_current_user( $user->ID ); |
285 | 285 | |
286 | | $post = self::$factory->post->create_and_get( array( |
| 286 | $post = self::factory()->post->create_and_get( array( |
287 | 287 | 'post_status' => 'private', |
288 | 288 | 'post_author' => $author->ID, |
289 | 289 | ) ); |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
301 | 301 | |
302 | 302 | public function test_anonymous_user_cannot_comment_unfiltered_html() { |
303 | 303 | |
304 | | $post = self::$factory->post->create_and_get(); |
| 304 | $post = self::factory()->post->create_and_get(); |
305 | 305 | $data = array( |
306 | 306 | 'comment_post_ID' => $post->ID, |
307 | 307 | 'comment' => 'Comment <script>alert(document.cookie);</script>', |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
318 | 318 | |
319 | 319 | public function test_unprivileged_user_cannot_comment_unfiltered_html() { |
320 | 320 | |
321 | | $user = self::$factory->user->create_and_get( array( |
| 321 | $user = self::factory()->user->create_and_get( array( |
322 | 322 | 'role' => 'author', |
323 | 323 | ) ); |
324 | 324 | wp_set_current_user( $user->ID ); |
325 | 325 | |
326 | 326 | $this->assertFalse( current_user_can( 'unfiltered_html' ) ); |
327 | 327 | |
328 | | $post = self::$factory->post->create_and_get(); |
| 328 | $post = self::factory()->post->create_and_get(); |
329 | 329 | $data = array( |
330 | 330 | 'comment_post_ID' => $post->ID, |
331 | 331 | 'comment' => 'Comment <script>alert(document.cookie);</script>', |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
340 | 340 | |
341 | 341 | public function test_unprivileged_user_cannot_comment_unfiltered_html_even_with_valid_nonce() { |
342 | 342 | |
343 | | $user = self::$factory->user->create_and_get( array( |
| 343 | $user = self::factory()->user->create_and_get( array( |
344 | 344 | 'role' => 'author', |
345 | 345 | ) ); |
346 | 346 | wp_set_current_user( $user->ID ); |
347 | 347 | |
348 | 348 | $this->assertFalse( current_user_can( 'unfiltered_html' ) ); |
349 | 349 | |
350 | | $post = self::$factory->post->create_and_get(); |
| 350 | $post = self::factory()->post->create_and_get(); |
351 | 351 | $action = 'unfiltered-html-comment_' . $post->ID; |
352 | 352 | $nonce = wp_create_nonce( $action ); |
353 | 353 | |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
370 | 370 | |
371 | 371 | $this->assertFalse( defined( 'DISALLOW_UNFILTERED_HTML' ) ); |
372 | 372 | |
373 | | $user = self::$factory->user->create_and_get( array( |
| 373 | $user = self::factory()->user->create_and_get( array( |
374 | 374 | 'role' => 'editor', |
375 | 375 | ) ); |
376 | 376 | |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
384 | 384 | |
385 | 385 | $this->assertTrue( current_user_can( 'unfiltered_html' ) ); |
386 | 386 | |
387 | | $post = self::$factory->post->create_and_get(); |
| 387 | $post = self::factory()->post->create_and_get(); |
388 | 388 | $action = 'unfiltered-html-comment_' . $post->ID; |
389 | 389 | $nonce = wp_create_nonce( $action ); |
390 | 390 | |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
405 | 405 | |
406 | 406 | public function test_privileged_user_cannot_comment_unfiltered_html_without_valid_nonce() { |
407 | 407 | |
408 | | $user = self::$factory->user->create_and_get( array( |
| 408 | $user = self::factory()->user->create_and_get( array( |
409 | 409 | 'role' => 'editor', |
410 | 410 | ) ); |
411 | 411 | |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
419 | 419 | |
420 | 420 | $this->assertTrue( current_user_can( 'unfiltered_html' ) ); |
421 | 421 | |
422 | | $post = self::$factory->post->create_and_get(); |
| 422 | $post = self::factory()->post->create_and_get(); |
423 | 423 | $data = array( |
424 | 424 | 'comment_post_ID' => $post->ID, |
425 | 425 | 'comment' => 'Comment <script>alert(document.cookie);</script>', |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
439 | 439 | $_comment_registration = get_option( 'comment_registration' ); |
440 | 440 | update_option( 'comment_registration', '1' ); |
441 | 441 | |
442 | | $post = self::$factory->post->create_and_get(); |
| 442 | $post = self::factory()->post->create_and_get(); |
443 | 443 | $data = array( |
444 | 444 | 'comment_post_ID' => $post->ID, |
445 | 445 | ); |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
459 | 459 | $_require_name_email = get_option( 'require_name_email' ); |
460 | 460 | update_option( 'require_name_email', '1' ); |
461 | 461 | |
462 | | $post = self::$factory->post->create_and_get(); |
| 462 | $post = self::factory()->post->create_and_get(); |
463 | 463 | $data = array( |
464 | 464 | 'comment_post_ID' => $post->ID, |
465 | 465 | 'comment' => 'Comment', |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
481 | 481 | $_require_name_email = get_option( 'require_name_email' ); |
482 | 482 | update_option( 'require_name_email', '1' ); |
483 | 483 | |
484 | | $post = self::$factory->post->create_and_get(); |
| 484 | $post = self::factory()->post->create_and_get(); |
485 | 485 | $data = array( |
486 | 486 | 'comment_post_ID' => $post->ID, |
487 | 487 | 'comment' => 'Comment', |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
503 | 503 | $_require_name_email = get_option( 'require_name_email' ); |
504 | 504 | update_option( 'require_name_email', '1' ); |
505 | 505 | |
506 | | $post = self::$factory->post->create_and_get(); |
| 506 | $post = self::factory()->post->create_and_get(); |
507 | 507 | $data = array( |
508 | 508 | 'comment_post_ID' => $post->ID, |
509 | 509 | 'comment' => 'Comment', |
… |
… |
class Tests_Comment_Submission extends WP_UnitTestCase { |
523 | 523 | |
524 | 524 | $error = 'require_valid_comment'; |
525 | 525 | |
526 | | $post = self::$factory->post->create_and_get(); |
| 526 | $post = self::factory()->post->create_and_get(); |
527 | 527 | $data = array( |
528 | 528 | 'comment_post_ID' => $post->ID, |
529 | 529 | 'comment' => '', |
-
diff --git tests/phpunit/tests/comment.php tests/phpunit/tests/comment.php
index a059149..cf55e07 100644
|
|
class Tests_Comment extends WP_UnitTestCase { |
21 | 21 | } |
22 | 22 | |
23 | 23 | function test_wp_update_comment() { |
24 | | $post = self::$factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post' ) ); |
25 | | $post2 = self::$factory->post->create_and_get( array( 'post_title' => 'some-post-2', 'post_type' => 'post' ) ); |
26 | | $comments = self::$factory->comment->create_post_comments( $post->ID, 5 ); |
| 24 | $post = self::factory()->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post' ) ); |
| 25 | $post2 = self::factory()->post->create_and_get( array( 'post_title' => 'some-post-2', 'post_type' => 'post' ) ); |
| 26 | $comments = self::factory()->comment->create_post_comments( $post->ID, 5 ); |
27 | 27 | $result = wp_update_comment( array( 'comment_ID' => $comments[0], 'comment_parent' => $comments[1] ) ); |
28 | 28 | $this->assertEquals( 1, $result ); |
29 | 29 | $comment = get_comment( $comments[0] ); |
… |
… |
class Tests_Comment extends WP_UnitTestCase { |
39 | 39 | * @ticket 30627 |
40 | 40 | */ |
41 | 41 | function test_wp_update_comment_updates_comment_type() { |
42 | | $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id ) ); |
| 42 | $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); |
43 | 43 | |
44 | 44 | wp_update_comment( array( 'comment_ID' => $comment_id, 'comment_type' => 'pingback' ) ); |
45 | 45 | |
… |
… |
class Tests_Comment extends WP_UnitTestCase { |
51 | 51 | * @ticket 30307 |
52 | 52 | */ |
53 | 53 | function test_wp_update_comment_updates_user_id() { |
54 | | $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id ) ); |
| 54 | $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); |
55 | 55 | |
56 | 56 | wp_update_comment( array( 'comment_ID' => $comment_id, 'user_id' => 1 ) ); |
57 | 57 | |
… |
… |
class Tests_Comment extends WP_UnitTestCase { |
60 | 60 | } |
61 | 61 | |
62 | 62 | public function test_get_approved_comments() { |
63 | | $ca1 = self::$factory->comment->create( array( |
| 63 | $ca1 = self::factory()->comment->create( array( |
64 | 64 | 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' |
65 | 65 | ) ); |
66 | | $ca2 = self::$factory->comment->create( array( |
| 66 | $ca2 = self::factory()->comment->create( array( |
67 | 67 | 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' |
68 | 68 | ) ); |
69 | | $ca3 = self::$factory->comment->create( array( |
| 69 | $ca3 = self::factory()->comment->create( array( |
70 | 70 | 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' |
71 | 71 | ) ); |
72 | | $c2 = self::$factory->comment->create( array( |
| 72 | $c2 = self::factory()->comment->create( array( |
73 | 73 | 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' |
74 | 74 | ) ); |
75 | | $c3 = self::$factory->comment->create( array( |
| 75 | $c3 = self::factory()->comment->create( array( |
76 | 76 | 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' |
77 | 77 | ) ); |
78 | | $c4 = self::$factory->comment->create( array( |
| 78 | $c4 = self::factory()->comment->create( array( |
79 | 79 | 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' |
80 | 80 | ) ); |
81 | | $c5 = self::$factory->comment->create( array( |
| 81 | $c5 = self::factory()->comment->create( array( |
82 | 82 | 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' |
83 | 83 | ) ); |
84 | 84 | |
… |
… |
class Tests_Comment extends WP_UnitTestCase { |
92 | 92 | * @ticket 30412 |
93 | 93 | */ |
94 | 94 | public function test_get_approved_comments_with_post_id_0_should_return_empty_array() { |
95 | | $ca1 = self::$factory->comment->create( array( |
| 95 | $ca1 = self::factory()->comment->create( array( |
96 | 96 | 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' |
97 | 97 | ) ); |
98 | 98 | |
… |
… |
class Tests_Comment extends WP_UnitTestCase { |
256 | 256 | * @ticket 32566 |
257 | 257 | */ |
258 | 258 | public function test_wp_notify_moderator_should_not_throw_notice_when_post_author_is_0() { |
259 | | $p = self::$factory->post->create( array( |
| 259 | $p = self::factory()->post->create( array( |
260 | 260 | 'post_author' => 0, |
261 | 261 | ) ); |
262 | 262 | |
263 | | $c = self::$factory->comment->create( array( |
| 263 | $c = self::factory()->comment->create( array( |
264 | 264 | 'comment_post_ID' => $p, |
265 | 265 | ) ); |
266 | 266 | |
… |
… |
class Tests_Comment extends WP_UnitTestCase { |
271 | 271 | * @ticket 33587 |
272 | 272 | */ |
273 | 273 | public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_marked_as_spam() { |
274 | | $c = self::$factory->comment->create( array( |
| 274 | $c = self::factory()->comment->create( array( |
275 | 275 | 'comment_post_ID' => self::$post_id, |
276 | 276 | 'comment_approved' => 'spam', |
277 | 277 | ) ); |
… |
… |
class Tests_Comment extends WP_UnitTestCase { |
284 | 284 | * @ticket 12431 |
285 | 285 | */ |
286 | 286 | public function test_wp_new_comment_with_meta() { |
287 | | $c = self::$factory->comment->create( array( |
| 287 | $c = self::factory()->comment->create( array( |
288 | 288 | 'comment_approved' => '1', |
289 | 289 | 'comment_meta' => array( |
290 | 290 | 'food' => 'taco', |
… |
… |
class Tests_Comment extends WP_UnitTestCase { |
299 | 299 | * @ticket 8071 |
300 | 300 | */ |
301 | 301 | public function test_wp_comment_get_children_should_fill_children() { |
302 | | $c1 = self::$factory->comment->create( array( |
| 302 | $c1 = self::factory()->comment->create( array( |
303 | 303 | 'comment_post_ID' => self::$post_id, |
304 | 304 | 'comment_approved' => '1', |
305 | 305 | ) ); |
306 | 306 | |
307 | | $c2 = self::$factory->comment->create( array( |
| 307 | $c2 = self::factory()->comment->create( array( |
308 | 308 | 'comment_post_ID' => self::$post_id, |
309 | 309 | 'comment_approved' => '1', |
310 | 310 | 'comment_parent' => $c1, |
311 | 311 | ) ); |
312 | 312 | |
313 | | $c3 = self::$factory->comment->create( array( |
| 313 | $c3 = self::factory()->comment->create( array( |
314 | 314 | 'comment_post_ID' => self::$post_id, |
315 | 315 | 'comment_approved' => '1', |
316 | 316 | 'comment_parent' => $c2, |
317 | 317 | ) ); |
318 | 318 | |
319 | | $c4 = self::$factory->comment->create( array( |
| 319 | $c4 = self::factory()->comment->create( array( |
320 | 320 | 'comment_post_ID' => self::$post_id, |
321 | 321 | 'comment_approved' => '1', |
322 | 322 | 'comment_parent' => $c1, |
323 | 323 | ) ); |
324 | 324 | |
325 | | $c5 = self::$factory->comment->create( array( |
| 325 | $c5 = self::factory()->comment->create( array( |
326 | 326 | 'comment_post_ID' => self::$post_id, |
327 | 327 | 'comment_approved' => '1', |
328 | 328 | ) ); |
329 | 329 | |
330 | | $c6 = self::$factory->comment->create( array( |
| 330 | $c6 = self::factory()->comment->create( array( |
331 | 331 | 'comment_post_ID' => self::$post_id, |
332 | 332 | 'comment_approved' => '1', |
333 | 333 | 'comment_parent' => $c5, |
… |
… |
class Tests_Comment extends WP_UnitTestCase { |
347 | 347 | * @group 27571 |
348 | 348 | */ |
349 | 349 | public function test_post_properties_should_be_lazyloaded() { |
350 | | $c = self::$factory->comment->create( array( 'comment_post_ID' => self::$post_id ) ); |
| 350 | $c = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); |
351 | 351 | |
352 | 352 | $post = get_post( self::$post_id ); |
353 | 353 | $comment = get_comment( $c ); |
-
diff --git tests/phpunit/tests/comment/checkComment.php tests/phpunit/tests/comment/checkComment.php
index 40bca3a..576b838 100644
|
|
class Tests_Comment_CheckComment extends WP_UnitTestCase { |
31 | 31 | } |
32 | 32 | |
33 | 33 | public function test_should_return_true_when_comment_whitelist_is_enabled_and_author_has_approved_comment() { |
34 | | $post_id = self::$factory->post->create(); |
| 34 | $post_id = self::factory()->post->create(); |
35 | 35 | $prev_args = array( |
36 | 36 | 'comment_post_ID' => $post_id, |
37 | 37 | 'comment_content' => 'Can we build it?', |
… |
… |
class Tests_Comment_CheckComment extends WP_UnitTestCase { |
39 | 39 | 'comment_author_email' => 'bob@example.com', |
40 | 40 | 'comment_author' => 'BobtheBuilder', |
41 | 41 | ); |
42 | | $prev_comment_id = self::$factory->comment->create( $prev_args ); |
| 42 | $prev_comment_id = self::factory()->comment->create( $prev_args ); |
43 | 43 | |
44 | 44 | update_option( 'comment_whitelist', 1 ); |
45 | 45 | |
-
diff --git tests/phpunit/tests/comment/commentForm.php tests/phpunit/tests/comment/commentForm.php
index bd91dbf..c6bb43f 100644
|
|
|
5 | 5 | */ |
6 | 6 | class Tests_Comment_CommentForm extends WP_UnitTestCase { |
7 | 7 | public function test_default_markup_for_submit_button_and_wrapper() { |
8 | | $p = self::$factory->post->create(); |
| 8 | $p = self::factory()->post->create(); |
9 | 9 | |
10 | 10 | $args = array( |
11 | 11 | 'name_submit' => 'foo-name', |
… |
… |
class Tests_Comment_CommentForm extends WP_UnitTestCase { |
21 | 21 | } |
22 | 22 | |
23 | 23 | public function test_custom_submit_button() { |
24 | | $p = self::$factory->post->create(); |
| 24 | $p = self::factory()->post->create(); |
25 | 25 | |
26 | 26 | $args = array( |
27 | 27 | 'name_submit' => 'foo-name', |
… |
… |
class Tests_Comment_CommentForm extends WP_UnitTestCase { |
37 | 37 | } |
38 | 38 | |
39 | 39 | public function test_custom_submit_field() { |
40 | | $p = self::$factory->post->create(); |
| 40 | $p = self::factory()->post->create(); |
41 | 41 | |
42 | 42 | $args = array( |
43 | 43 | 'name_submit' => 'foo-name', |
… |
… |
class Tests_Comment_CommentForm extends WP_UnitTestCase { |
57 | 57 | * @ticket 32312 |
58 | 58 | */ |
59 | 59 | public function test_submit_button_and_submit_field_should_fall_back_on_defaults_when_filtered_defaults_do_not_contain_the_keys() { |
60 | | $p = self::$factory->post->create(); |
| 60 | $p = self::factory()->post->create(); |
61 | 61 | |
62 | 62 | $args = array( |
63 | 63 | 'name_submit' => 'foo-name', |
-
diff --git tests/phpunit/tests/comment/commentsTemplate.php tests/phpunit/tests/comment/commentsTemplate.php
index 31f7cbf..3e134ad 100644
|
|
class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { |
12 | 12 | */ |
13 | 13 | public function test_should_respect_comment_order_asc_when_default_comments_page_is_newest() { |
14 | 14 | $now = time(); |
15 | | $p = self::$factory->post->create(); |
16 | | $comment_1 = self::$factory->comment->create( array( |
| 15 | $p = self::factory()->post->create(); |
| 16 | $comment_1 = self::factory()->comment->create( array( |
17 | 17 | 'comment_post_ID' => $p, |
18 | 18 | 'comment_content' => '1', |
19 | 19 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
20 | 20 | ) ); |
21 | | $comment_2 = self::$factory->comment->create( array( |
| 21 | $comment_2 = self::factory()->comment->create( array( |
22 | 22 | 'comment_post_ID' => $p, |
23 | 23 | 'comment_content' => '2', |
24 | 24 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
… |
… |
class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { |
42 | 42 | */ |
43 | 43 | public function test_should_respect_comment_order_desc_when_default_comments_page_is_newest() { |
44 | 44 | $now = time(); |
45 | | $p = self::$factory->post->create(); |
46 | | $comment_1 = self::$factory->comment->create( array( |
| 45 | $p = self::factory()->post->create(); |
| 46 | $comment_1 = self::factory()->comment->create( array( |
47 | 47 | 'comment_post_ID' => $p, |
48 | 48 | 'comment_content' => '1', |
49 | 49 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
50 | 50 | ) ); |
51 | | $comment_2 = self::$factory->comment->create( array( |
| 51 | $comment_2 = self::factory()->comment->create( array( |
52 | 52 | 'comment_post_ID' => $p, |
53 | 53 | 'comment_content' => '2', |
54 | 54 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
… |
… |
class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { |
72 | 72 | */ |
73 | 73 | public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest() { |
74 | 74 | $now = time(); |
75 | | $p = self::$factory->post->create(); |
76 | | $comment_1 = self::$factory->comment->create( array( |
| 75 | $p = self::factory()->post->create(); |
| 76 | $comment_1 = self::factory()->comment->create( array( |
77 | 77 | 'comment_post_ID' => $p, |
78 | 78 | 'comment_content' => '1', |
79 | 79 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
80 | 80 | ) ); |
81 | | $comment_2 = self::$factory->comment->create( array( |
| 81 | $comment_2 = self::factory()->comment->create( array( |
82 | 82 | 'comment_post_ID' => $p, |
83 | 83 | 'comment_content' => '2', |
84 | 84 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
… |
… |
class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { |
102 | 102 | */ |
103 | 103 | public function test_should_respect_comment_order_desc_when_default_comments_page_is_oldest() { |
104 | 104 | $now = time(); |
105 | | $p = self::$factory->post->create(); |
106 | | $comment_1 = self::$factory->comment->create( array( |
| 105 | $p = self::factory()->post->create(); |
| 106 | $comment_1 = self::factory()->comment->create( array( |
107 | 107 | 'comment_post_ID' => $p, |
108 | 108 | 'comment_content' => '1', |
109 | 109 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
110 | 110 | ) ); |
111 | | $comment_2 = self::$factory->comment->create( array( |
| 111 | $comment_2 = self::factory()->comment->create( array( |
112 | 112 | 'comment_post_ID' => $p, |
113 | 113 | 'comment_content' => '2', |
114 | 114 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
… |
… |
class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { |
132 | 132 | */ |
133 | 133 | public function test_should_respect_comment_order_asc_when_default_comments_page_is_newest_on_subsequent_pages() { |
134 | 134 | $now = time(); |
135 | | $p = self::$factory->post->create(); |
136 | | $comment_1 = self::$factory->comment->create( array( |
| 135 | $p = self::factory()->post->create(); |
| 136 | $comment_1 = self::factory()->comment->create( array( |
137 | 137 | 'comment_post_ID' => $p, |
138 | 138 | 'comment_content' => '1', |
139 | 139 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
140 | 140 | ) ); |
141 | | $comment_2 = self::$factory->comment->create( array( |
| 141 | $comment_2 = self::factory()->comment->create( array( |
142 | 142 | 'comment_post_ID' => $p, |
143 | 143 | 'comment_content' => '2', |
144 | 144 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
145 | 145 | ) ); |
146 | | $comment_3 = self::$factory->comment->create( array( |
| 146 | $comment_3 = self::factory()->comment->create( array( |
147 | 147 | 'comment_post_ID' => $p, |
148 | 148 | 'comment_content' => '3', |
149 | 149 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), |
150 | 150 | ) ); |
151 | | $comment_4 = self::$factory->comment->create( array( |
| 151 | $comment_4 = self::factory()->comment->create( array( |
152 | 152 | 'comment_post_ID' => $p, |
153 | 153 | 'comment_content' => '4', |
154 | 154 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), |
155 | 155 | ) ); |
156 | | $comment_5 = self::$factory->comment->create( array( |
| 156 | $comment_5 = self::factory()->comment->create( array( |
157 | 157 | 'comment_post_ID' => $p, |
158 | 158 | 'comment_content' => '3', |
159 | 159 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ), |
160 | 160 | ) ); |
161 | | $comment_6 = self::$factory->comment->create( array( |
| 161 | $comment_6 = self::factory()->comment->create( array( |
162 | 162 | 'comment_post_ID' => $p, |
163 | 163 | 'comment_content' => '4', |
164 | 164 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ), |
… |
… |
class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { |
187 | 187 | */ |
188 | 188 | public function test_should_respect_comment_order_desc_when_default_comments_page_is_newest_on_subsequent_pages() { |
189 | 189 | $now = time(); |
190 | | $p = self::$factory->post->create(); |
191 | | $comment_1 = self::$factory->comment->create( array( |
| 190 | $p = self::factory()->post->create(); |
| 191 | $comment_1 = self::factory()->comment->create( array( |
192 | 192 | 'comment_post_ID' => $p, |
193 | 193 | 'comment_content' => '1', |
194 | 194 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
195 | 195 | ) ); |
196 | | $comment_2 = self::$factory->comment->create( array( |
| 196 | $comment_2 = self::factory()->comment->create( array( |
197 | 197 | 'comment_post_ID' => $p, |
198 | 198 | 'comment_content' => '2', |
199 | 199 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
200 | 200 | ) ); |
201 | | $comment_3 = self::$factory->comment->create( array( |
| 201 | $comment_3 = self::factory()->comment->create( array( |
202 | 202 | 'comment_post_ID' => $p, |
203 | 203 | 'comment_content' => '3', |
204 | 204 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), |
205 | 205 | ) ); |
206 | | $comment_4 = self::$factory->comment->create( array( |
| 206 | $comment_4 = self::factory()->comment->create( array( |
207 | 207 | 'comment_post_ID' => $p, |
208 | 208 | 'comment_content' => '4', |
209 | 209 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), |
210 | 210 | ) ); |
211 | | $comment_5 = self::$factory->comment->create( array( |
| 211 | $comment_5 = self::factory()->comment->create( array( |
212 | 212 | 'comment_post_ID' => $p, |
213 | 213 | 'comment_content' => '3', |
214 | 214 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ), |
215 | 215 | ) ); |
216 | | $comment_6 = self::$factory->comment->create( array( |
| 216 | $comment_6 = self::factory()->comment->create( array( |
217 | 217 | 'comment_post_ID' => $p, |
218 | 218 | 'comment_content' => '4', |
219 | 219 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ), |
… |
… |
class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { |
242 | 242 | */ |
243 | 243 | public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest_on_subsequent_pages() { |
244 | 244 | $now = time(); |
245 | | $p = self::$factory->post->create(); |
246 | | $comment_1 = self::$factory->comment->create( array( |
| 245 | $p = self::factory()->post->create(); |
| 246 | $comment_1 = self::factory()->comment->create( array( |
247 | 247 | 'comment_post_ID' => $p, |
248 | 248 | 'comment_content' => '1', |
249 | 249 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
250 | 250 | ) ); |
251 | | $comment_2 = self::$factory->comment->create( array( |
| 251 | $comment_2 = self::factory()->comment->create( array( |
252 | 252 | 'comment_post_ID' => $p, |
253 | 253 | 'comment_content' => '2', |
254 | 254 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
255 | 255 | ) ); |
256 | | $comment_3 = self::$factory->comment->create( array( |
| 256 | $comment_3 = self::factory()->comment->create( array( |
257 | 257 | 'comment_post_ID' => $p, |
258 | 258 | 'comment_content' => '3', |
259 | 259 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), |
260 | 260 | ) ); |
261 | | $comment_4 = self::$factory->comment->create( array( |
| 261 | $comment_4 = self::factory()->comment->create( array( |
262 | 262 | 'comment_post_ID' => $p, |
263 | 263 | 'comment_content' => '4', |
264 | 264 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), |
… |
… |
class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { |
287 | 287 | */ |
288 | 288 | public function test_should_respect_comment_order_desc_when_default_comments_page_is_oldest_on_subsequent_pages() { |
289 | 289 | $now = time(); |
290 | | $p = self::$factory->post->create(); |
291 | | $comment_1 = self::$factory->comment->create( array( |
| 290 | $p = self::factory()->post->create(); |
| 291 | $comment_1 = self::factory()->comment->create( array( |
292 | 292 | 'comment_post_ID' => $p, |
293 | 293 | 'comment_content' => '1', |
294 | 294 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
295 | 295 | ) ); |
296 | | $comment_2 = self::$factory->comment->create( array( |
| 296 | $comment_2 = self::factory()->comment->create( array( |
297 | 297 | 'comment_post_ID' => $p, |
298 | 298 | 'comment_content' => '2', |
299 | 299 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
300 | 300 | ) ); |
301 | | $comment_3 = self::$factory->comment->create( array( |
| 301 | $comment_3 = self::factory()->comment->create( array( |
302 | 302 | 'comment_post_ID' => $p, |
303 | 303 | 'comment_content' => '3', |
304 | 304 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), |
305 | 305 | ) ); |
306 | | $comment_4 = self::$factory->comment->create( array( |
| 306 | $comment_4 = self::factory()->comment->create( array( |
307 | 307 | 'comment_post_ID' => $p, |
308 | 308 | 'comment_content' => '4', |
309 | 309 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), |
… |
… |
class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { |
334 | 334 | */ |
335 | 335 | public function test_last_page_of_comments_should_be_full_when_default_comment_page_is_newest() { |
336 | 336 | $now = time(); |
337 | | $p = self::$factory->post->create(); |
338 | | $comment_1 = self::$factory->comment->create( array( |
| 337 | $p = self::factory()->post->create(); |
| 338 | $comment_1 = self::factory()->comment->create( array( |
339 | 339 | 'comment_post_ID' => $p, |
340 | 340 | 'comment_content' => '1', |
341 | 341 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
342 | 342 | ) ); |
343 | | $comment_2 = self::$factory->comment->create( array( |
| 343 | $comment_2 = self::factory()->comment->create( array( |
344 | 344 | 'comment_post_ID' => $p, |
345 | 345 | 'comment_content' => '2', |
346 | 346 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
347 | 347 | ) ); |
348 | | $comment_3 = self::$factory->comment->create( array( |
| 348 | $comment_3 = self::factory()->comment->create( array( |
349 | 349 | 'comment_post_ID' => $p, |
350 | 350 | 'comment_content' => '3', |
351 | 351 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), |
… |
… |
class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { |
376 | 376 | */ |
377 | 377 | public function test_first_page_of_comments_should_have_remainder_when_default_comments_page_is_newest() { |
378 | 378 | $now = time(); |
379 | | $p = self::$factory->post->create(); |
380 | | $comment_1 = self::$factory->comment->create( array( |
| 379 | $p = self::factory()->post->create(); |
| 380 | $comment_1 = self::factory()->comment->create( array( |
381 | 381 | 'comment_post_ID' => $p, |
382 | 382 | 'comment_content' => '1', |
383 | 383 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
384 | 384 | ) ); |
385 | | $comment_2 = self::$factory->comment->create( array( |
| 385 | $comment_2 = self::factory()->comment->create( array( |
386 | 386 | 'comment_post_ID' => $p, |
387 | 387 | 'comment_content' => '2', |
388 | 388 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
389 | 389 | ) ); |
390 | | $comment_3 = self::$factory->comment->create( array( |
| 390 | $comment_3 = self::factory()->comment->create( array( |
391 | 391 | 'comment_post_ID' => $p, |
392 | 392 | 'comment_content' => '3', |
393 | 393 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), |
… |
… |
class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { |
416 | 416 | */ |
417 | 417 | public function test_comment_permalinks_should_be_correct_when_using_default_display_callback_with_default_comment_page_oldest() { |
418 | 418 | $now = time(); |
419 | | $p = self::$factory->post->create(); |
420 | | $comment_1 = self::$factory->comment->create( array( |
| 419 | $p = self::factory()->post->create(); |
| 420 | $comment_1 = self::factory()->comment->create( array( |
421 | 421 | 'comment_post_ID' => $p, |
422 | 422 | 'comment_content' => '1', |
423 | 423 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
424 | 424 | ) ); |
425 | | $comment_2 = self::$factory->comment->create( array( |
| 425 | $comment_2 = self::factory()->comment->create( array( |
426 | 426 | 'comment_post_ID' => $p, |
427 | 427 | 'comment_content' => '2', |
428 | 428 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
429 | 429 | ) ); |
430 | | $comment_3 = self::$factory->comment->create( array( |
| 430 | $comment_3 = self::factory()->comment->create( array( |
431 | 431 | 'comment_post_ID' => $p, |
432 | 432 | 'comment_content' => '3', |
433 | 433 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), |
434 | 434 | ) ); |
435 | | $comment_4 = self::$factory->comment->create( array( |
| 435 | $comment_4 = self::factory()->comment->create( array( |
436 | 436 | 'comment_post_ID' => $p, |
437 | 437 | 'comment_content' => '4', |
438 | 438 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), |
… |
… |
class Tests_Comment_CommentsTemplate extends WP_UnitTestCase { |
480 | 480 | */ |
481 | 481 | public function test_comment_permalinks_should_be_correct_when_using_default_display_callback_with_default_comment_page_newest() { |
482 | 482 | $now = time(); |
483 | | $p = self::$factory->post->create(); |
484 | | $comment_1 = self::$factory->comment->create( array( |
| 483 | $p = self::factory()->post->create(); |
| 484 | $comment_1 = self::factory()->comment->create( array( |
485 | 485 | 'comment_post_ID' => $p, |
486 | 486 | 'comment_content' => '1', |
487 | 487 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
488 | 488 | ) ); |
489 | | $comment_2 = self::$factory->comment->create( array( |
| 489 | $comment_2 = self::factory()->comment->create( array( |
490 | 490 | 'comment_post_ID' => $p, |
491 | 491 | 'comment_content' => '2', |
492 | 492 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
493 | 493 | ) ); |
494 | | $comment_3 = self::$factory->comment->create( array( |
| 494 | $comment_3 = self::factory()->comment->create( array( |
495 | 495 | 'comment_post_ID' => $p, |
496 | 496 | 'comment_content' => '3', |
497 | 497 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), |
498 | 498 | ) ); |
499 | | $comment_4 = self::$factory->comment->create( array( |
| 499 | $comment_4 = self::factory()->comment->create( array( |
500 | 500 | 'comment_post_ID' => $p, |
501 | 501 | 'comment_content' => '4', |
502 | 502 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), |
503 | 503 | ) ); |
504 | | $comment_5 = self::$factory->comment->create( array( |
| 504 | $comment_5 = self::factory()->comment->create( array( |
505 | 505 | 'comment_post_ID' => $p, |
506 | 506 | 'comment_content' => '4', |
507 | 507 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ), |
508 | 508 | ) ); |
509 | | $comment_6 = self::$factory->comment->create( array( |
| 509 | $comment_6 = self::factory()->comment->create( array( |
510 | 510 | 'comment_post_ID' => $p, |
511 | 511 | 'comment_content' => '4', |
512 | 512 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ), |
-
diff --git tests/phpunit/tests/comment/dateQuery.php tests/phpunit/tests/comment/dateQuery.php
index cccdb97..5859b5c 100644
|
|
class Tests_Comment_DateQuery extends WP_UnitTestCase { |
22 | 22 | |
23 | 23 | // Just some dummy posts to use as parents for comments |
24 | 24 | for ( $i = 1; $i <= 2; $i++ ) { |
25 | | $this->posts[$i] = self::$factory->post->create(); |
| 25 | $this->posts[$i] = self::factory()->post->create(); |
26 | 26 | } |
27 | 27 | |
28 | 28 | // Be careful modifying this. Tests are coded to expect this exact sample data. |
… |
… |
class Tests_Comment_DateQuery extends WP_UnitTestCase { |
39 | 39 | ); |
40 | 40 | |
41 | 41 | foreach ( $comment_dates as $comment_date => $comment_parent ) { |
42 | | $result = self::$factory->comment->create( array( |
| 42 | $result = self::factory()->comment->create( array( |
43 | 43 | 'comment_date' => $comment_date, |
44 | 44 | 'comment_post_ID' => $this->posts[ $comment_parent ], |
45 | 45 | ) ); |
-
diff --git tests/phpunit/tests/comment/getCommentClass.php tests/phpunit/tests/comment/getCommentClass.php
index 09bd5c8..a4518a2 100644
|
|
|
5 | 5 | */ |
6 | 6 | class Tests_Comment_GetCommentClass extends WP_UnitTestCase { |
7 | 7 | public function test_should_accept_comment_id() { |
8 | | $post_id = self::$factory->post->create(); |
9 | | $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) ); |
| 8 | $post_id = self::factory()->post->create(); |
| 9 | $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id ) ); |
10 | 10 | |
11 | 11 | $classes = get_comment_class( '', $comment_id ); |
12 | 12 | $this->assertContains( 'comment', $classes ); |
13 | 13 | } |
14 | 14 | |
15 | 15 | public function test_should_accept_comment_object() { |
16 | | $post_id = self::$factory->post->create(); |
17 | | $comment = self::$factory->comment->create_and_get( array( 'comment_post_ID' => $post_id ) ); |
| 16 | $post_id = self::factory()->post->create(); |
| 17 | $comment = self::factory()->comment->create_and_get( array( 'comment_post_ID' => $post_id ) ); |
18 | 18 | |
19 | 19 | $classes = get_comment_class( '', $comment ); |
20 | 20 | $this->assertContains( 'comment', $classes ); |
21 | 21 | } |
22 | 22 | |
23 | 23 | public function test_should_append_single_class() { |
24 | | $post_id = self::$factory->post->create(); |
25 | | $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) ); |
| 24 | $post_id = self::factory()->post->create(); |
| 25 | $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id ) ); |
26 | 26 | |
27 | 27 | $classes = get_comment_class( 'foo', $comment_id ); |
28 | 28 | $this->assertContains( 'foo', $classes ); |
29 | 29 | } |
30 | 30 | |
31 | 31 | public function test_should_append_array_of_classes() { |
32 | | $post_id = self::$factory->post->create(); |
33 | | $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) ); |
| 32 | $post_id = self::factory()->post->create(); |
| 33 | $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id ) ); |
34 | 34 | |
35 | 35 | $classes = get_comment_class( array( 'foo', 'bar' ), $comment_id ); |
36 | 36 | $this->assertContains( 'foo', $classes ); |
-
diff --git tests/phpunit/tests/comment/getCommentCount.php tests/phpunit/tests/comment/getCommentCount.php
index 45ba8e7..34e2219 100644
|
|
class Tests_Get_Comment_Count extends WP_UnitTestCase { |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function test_get_comment_count_approved() { |
17 | | self::$factory->comment->create( array( |
| 17 | self::factory()->comment->create( array( |
18 | 18 | 'comment_approved' => 1 |
19 | 19 | ) ); |
20 | 20 | |
… |
… |
class Tests_Get_Comment_Count extends WP_UnitTestCase { |
29 | 29 | } |
30 | 30 | |
31 | 31 | public function test_get_comment_count_awaiting() { |
32 | | self::$factory->comment->create( array( |
| 32 | self::factory()->comment->create( array( |
33 | 33 | 'comment_approved' => 0 |
34 | 34 | ) ); |
35 | 35 | |
… |
… |
class Tests_Get_Comment_Count extends WP_UnitTestCase { |
44 | 44 | } |
45 | 45 | |
46 | 46 | public function test_get_comment_count_spam() { |
47 | | self::$factory->comment->create( array( |
| 47 | self::factory()->comment->create( array( |
48 | 48 | 'comment_approved' => 'spam' |
49 | 49 | ) ); |
50 | 50 | |
… |
… |
class Tests_Get_Comment_Count extends WP_UnitTestCase { |
59 | 59 | } |
60 | 60 | |
61 | 61 | public function test_get_comment_count_trash() { |
62 | | self::$factory->comment->create( array( |
| 62 | self::factory()->comment->create( array( |
63 | 63 | 'comment_approved' => 'trash' |
64 | 64 | ) ); |
65 | 65 | |
… |
… |
class Tests_Get_Comment_Count extends WP_UnitTestCase { |
74 | 74 | } |
75 | 75 | |
76 | 76 | public function test_get_comment_count_post_trashed() { |
77 | | self::$factory->comment->create( array( |
| 77 | self::factory()->comment->create( array( |
78 | 78 | 'comment_approved' => 'post-trashed' |
79 | 79 | ) ); |
80 | 80 | |
-
diff --git tests/phpunit/tests/comment/getCommentExcerpt.php tests/phpunit/tests/comment/getCommentExcerpt.php
index 6eee6e6..cfb66e7 100644
|
|
Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function test_get_comment_excerpt() { |
17 | | $comment_id = self::$factory->comment->create( array( |
| 17 | $comment_id = self::factory()->comment->create( array( |
18 | 18 | 'comment_content' => self::$bacon_comment |
19 | 19 | ) ); |
20 | 20 | |
… |
… |
Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco |
24 | 24 | } |
25 | 25 | |
26 | 26 | public function test_get_comment_excerpt_filtered() { |
27 | | $comment_id = self::$factory->comment->create( array( |
| 27 | $comment_id = self::factory()->comment->create( array( |
28 | 28 | 'comment_content' => self::$bacon_comment |
29 | 29 | ) ); |
30 | 30 | |
-
diff --git tests/phpunit/tests/comment/getCommentLink.php tests/phpunit/tests/comment/getCommentLink.php
index 0b4e44c..c0ce30e 100644
|
|
class Tests_Comment_GetCommentLink extends WP_UnitTestCase { |
11 | 11 | parent::setUp(); |
12 | 12 | |
13 | 13 | $now = time(); |
14 | | $this->p = self::$factory->post->create(); |
15 | | $this->comments[] = self::$factory->comment->create( array( |
| 14 | $this->p = self::factory()->post->create(); |
| 15 | $this->comments[] = self::factory()->comment->create( array( |
16 | 16 | 'comment_post_ID' => $this->p, |
17 | 17 | 'comment_content' => '1', |
18 | 18 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
19 | 19 | ) ); |
20 | | $this->comments[] = self::$factory->comment->create( array( |
| 20 | $this->comments[] = self::factory()->comment->create( array( |
21 | 21 | 'comment_post_ID' => $this->p, |
22 | 22 | 'comment_content' => '2', |
23 | 23 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ), |
24 | 24 | ) ); |
25 | | $this->comments[] = self::$factory->comment->create( array( |
| 25 | $this->comments[] = self::factory()->comment->create( array( |
26 | 26 | 'comment_post_ID' => $this->p, |
27 | 27 | 'comment_content' => '3', |
28 | 28 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ), |
29 | 29 | ) ); |
30 | | $this->comments[] = self::$factory->comment->create( array( |
| 30 | $this->comments[] = self::factory()->comment->create( array( |
31 | 31 | 'comment_post_ID' => $this->p, |
32 | 32 | 'comment_content' => '4', |
33 | 33 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ), |
34 | 34 | ) ); |
35 | | $this->comments[] = self::$factory->comment->create( array( |
| 35 | $this->comments[] = self::factory()->comment->create( array( |
36 | 36 | 'comment_post_ID' => $this->p, |
37 | 37 | 'comment_content' => '4', |
38 | 38 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ), |
39 | 39 | ) ); |
40 | | $this->comments[] = self::$factory->comment->create( array( |
| 40 | $this->comments[] = self::factory()->comment->create( array( |
41 | 41 | 'comment_post_ID' => $this->p, |
42 | 42 | 'comment_content' => '4', |
43 | 43 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ), |
-
diff --git tests/phpunit/tests/comment/getCommentsPagesCount.php tests/phpunit/tests/comment/getCommentsPagesCount.php
index d6e21bc..9246f71 100644
|
|
class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { |
38 | 38 | */ |
39 | 39 | function test_empty() { |
40 | 40 | //setup post and comments |
41 | | $post_id = self::$factory->post->create( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) ); |
| 41 | $post_id = self::factory()->post->create( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) ); |
42 | 42 | $this->go_to( '/?p=' . $post_id ); |
43 | 43 | |
44 | 44 | global $wp_query; |
… |
… |
class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { |
60 | 60 | */ |
61 | 61 | function test_threaded_comments( ) { |
62 | 62 | //setup post and comments |
63 | | $post = self::$factory->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) ); |
64 | | $comments = self::$factory->comment->create_post_comments( $post->ID, 15 ); |
65 | | self::$factory->comment->create_post_comments( $post->ID, 6, array( 'comment_parent' => $comments[0] ) ); |
| 63 | $post = self::factory()->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) ); |
| 64 | $comments = self::factory()->comment->create_post_comments( $post->ID, 15 ); |
| 65 | self::factory()->comment->create_post_comments( $post->ID, 6, array( 'comment_parent' => $comments[0] ) ); |
66 | 66 | $comments = get_comments( array( 'post_id' => $post->ID ) ); |
67 | 67 | |
68 | 68 | $this->assertEquals( 3, get_comment_pages_count( $comments, 10, false ) ); |
… |
… |
class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { |
76 | 76 | function test_option_thread_comments() { |
77 | 77 | |
78 | 78 | //setup post and comments |
79 | | $post = self::$factory->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) ); |
80 | | $comments = self::$factory->comment->create_post_comments( $post->ID, 15 ); |
81 | | self::$factory->comment->create_post_comments( $post->ID, 6, array('comment_parent' => $comments[0] ) ); |
| 79 | $post = self::factory()->post->create_and_get( array( 'post_title' => 'comment--post', 'post_type' => 'post' ) ); |
| 80 | $comments = self::factory()->comment->create_post_comments( $post->ID, 15 ); |
| 81 | self::factory()->comment->create_post_comments( $post->ID, 6, array('comment_parent' => $comments[0] ) ); |
82 | 82 | $comments = get_comments( array( 'post_id' => $post->ID ) ); |
83 | 83 | |
84 | 84 | update_option( 'thread_comments', false ); |
… |
… |
class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { |
104 | 104 | |
105 | 105 | update_option( 'posts_per_rss', 100 ); |
106 | 106 | |
107 | | $post = self::$factory->post->create_and_get( array( 'post_title' => 'comment-post', 'post_type' => 'post' ) ); |
108 | | $comments = self::$factory->comment->create_post_comments( $post->ID, 25 ); |
| 107 | $post = self::factory()->post->create_and_get( array( 'post_title' => 'comment-post', 'post_type' => 'post' ) ); |
| 108 | $comments = self::factory()->comment->create_post_comments( $post->ID, 25 ); |
109 | 109 | |
110 | 110 | $wp_query = new WP_Query( array( 'p' => $post->ID, 'comments_per_page' => 10, 'feed' =>'comments-' ) ); |
111 | 111 | |
-
diff --git tests/phpunit/tests/comment/getPageOfComment.php tests/phpunit/tests/comment/getPageOfComment.php
index 390b6ed..7de16a9 100644
|
|
|
7 | 7 | class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { |
8 | 8 | |
9 | 9 | public function test_last_comment() { |
10 | | $p = self::$factory->post->create(); |
| 10 | $p = self::factory()->post->create(); |
11 | 11 | |
12 | 12 | // page 4 |
13 | | $comment_last = self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-24 00:00:00' ) ); |
14 | | self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-23 00:00:00' ) ); |
| 13 | $comment_last = self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-24 00:00:00' ) ); |
| 14 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-23 00:00:00' ) ); |
15 | 15 | |
16 | 16 | // page 3 |
17 | | self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-22 00:00:00' ) ); |
18 | | self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-21 00:00:00' ) ); |
19 | | self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-20 00:00:00' ) ); |
| 17 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-22 00:00:00' ) ); |
| 18 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-21 00:00:00' ) ); |
| 19 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-20 00:00:00' ) ); |
20 | 20 | |
21 | 21 | // page 2 |
22 | | self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-19 00:00:00' ) ); |
23 | | self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-18 00:00:00' ) ); |
24 | | self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-17 00:00:00' ) ); |
| 22 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-19 00:00:00' ) ); |
| 23 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-18 00:00:00' ) ); |
| 24 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-17 00:00:00' ) ); |
25 | 25 | |
26 | 26 | // page 1 |
27 | | self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-16 00:00:00' ) ); |
28 | | self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-15 00:00:00' ) ); |
29 | | $comment_first = self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-14 00:00:00' ) ); |
| 27 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-16 00:00:00' ) ); |
| 28 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-15 00:00:00' ) ); |
| 29 | $comment_first = self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-14 00:00:00' ) ); |
30 | 30 | |
31 | 31 | $this->assertEquals( 4, get_page_of_comment( $comment_last[0], array( 'per_page' => 3 ) ) ); |
32 | 32 | $this->assertEquals( 2, get_page_of_comment( $comment_last[0], array( 'per_page' => 10 ) ) ); |
… |
… |
class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { |
36 | 36 | } |
37 | 37 | |
38 | 38 | public function test_type_pings() { |
39 | | $p = self::$factory->post->create(); |
| 39 | $p = self::factory()->post->create(); |
40 | 40 | $now = time(); |
41 | 41 | |
42 | 42 | $trackbacks = array(); |
43 | 43 | for ( $i = 0; $i <= 3; $i++ ) { |
44 | | $trackbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); |
| 44 | $trackbacks[ $i ] = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); |
45 | 45 | $now -= 10 * $i; |
46 | 46 | } |
47 | 47 | |
48 | 48 | $pingbacks = array(); |
49 | 49 | for ( $i = 0; $i <= 6; $i++ ) { |
50 | | $pingbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'pingback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); |
| 50 | $pingbacks[ $i ] = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'pingback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); |
51 | 51 | $now -= 10 * $i; |
52 | 52 | } |
53 | 53 | |
… |
… |
class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { |
62 | 62 | public function test_subsequent_calls_should_hit_cache() { |
63 | 63 | global $wpdb; |
64 | 64 | |
65 | | $p = self::$factory->post->create(); |
66 | | $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); |
| 65 | $p = self::factory()->post->create(); |
| 66 | $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) ); |
67 | 67 | |
68 | 68 | // Prime cache. |
69 | 69 | $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) ); |
… |
… |
class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { |
81 | 81 | public function test_cache_hits_should_be_sensitive_to_comment_type() { |
82 | 82 | global $wpdb; |
83 | 83 | |
84 | | $p = self::$factory->post->create(); |
85 | | $comment = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'comment' ) ); |
| 84 | $p = self::factory()->post->create(); |
| 85 | $comment = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'comment' ) ); |
86 | 86 | |
87 | 87 | $now = time(); |
88 | 88 | $trackbacks = array(); |
89 | 89 | for ( $i = 0; $i <= 5; $i++ ) { |
90 | | $trackbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 10 * $i ) ) ) ); |
| 90 | $trackbacks[ $i ] = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 10 * $i ) ) ) ); |
91 | 91 | } |
92 | 92 | |
93 | 93 | // Prime cache for trackbacks. |
… |
… |
class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { |
105 | 105 | * @ticket 11334 |
106 | 106 | */ |
107 | 107 | public function test_cache_should_be_invalidated_when_comment_is_approved() { |
108 | | $p = self::$factory->post->create(); |
109 | | $c = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0 ) ); |
| 108 | $p = self::factory()->post->create(); |
| 109 | $c = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0 ) ); |
110 | 110 | |
111 | 111 | // Prime cache. |
112 | 112 | $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) ); |
… |
… |
class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { |
121 | 121 | * @ticket 11334 |
122 | 122 | */ |
123 | 123 | public function test_cache_should_be_invalidated_when_comment_is_deleted() { |
124 | | $p = self::$factory->post->create(); |
125 | | $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); |
| 124 | $p = self::factory()->post->create(); |
| 125 | $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) ); |
126 | 126 | |
127 | 127 | // Prime cache. |
128 | 128 | $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) ); |
… |
… |
class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { |
137 | 137 | * @ticket 11334 |
138 | 138 | */ |
139 | 139 | public function test_cache_should_be_invalidated_when_comment_is_spammed() { |
140 | | $p = self::$factory->post->create(); |
141 | | $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); |
| 140 | $p = self::factory()->post->create(); |
| 141 | $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) ); |
142 | 142 | |
143 | 143 | // Prime cache. |
144 | 144 | $page_1 = get_page_of_comment( $c, array( 'per_page' => 3 ) ); |
… |
… |
class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { |
155 | 155 | public function test_cache_should_be_invalidated_when_older_comment_is_published() { |
156 | 156 | $now = time(); |
157 | 157 | |
158 | | $p = self::$factory->post->create(); |
159 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); |
160 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) ); |
161 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) ); |
| 158 | $p = self::factory()->post->create(); |
| 159 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); |
| 160 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) ); |
| 161 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) ); |
162 | 162 | |
163 | 163 | $this->assertEquals( 1, get_page_of_comment( $c1, array( 'per_page' => 2 ) ) ); |
164 | 164 | |
… |
… |
class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { |
171 | 171 | * @ticket 34057 |
172 | 172 | */ |
173 | 173 | public function test_query_should_be_limited_to_comments_on_the_proper_post() { |
174 | | $posts = self::$factory->post->create_many( 2 ); |
| 174 | $posts = self::factory()->post->create_many( 2 ); |
175 | 175 | |
176 | 176 | $now = time(); |
177 | 177 | $comments_0 = $comments_1 = array(); |
178 | 178 | for ( $i = 0; $i < 5; $i++ ) { |
179 | | $comments_0[] = self::$factory->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); |
180 | | $comments_1[] = self::$factory->comment->create( array( 'comment_post_ID' => $posts[1], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); |
| 179 | $comments_0[] = self::factory()->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); |
| 180 | $comments_1[] = self::factory()->comment->create( array( 'comment_post_ID' => $posts[1], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); |
181 | 181 | } |
182 | 182 | |
183 | 183 | $found_0 = get_page_of_comment( $comments_0[0], array( 'per_page' => 2 ) ); |
… |
… |
class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { |
191 | 191 | * @ticket 13939 |
192 | 192 | */ |
193 | 193 | public function test_only_top_level_comments_should_be_included_in_older_count() { |
194 | | $post = self::$factory->post->create(); |
| 194 | $post = self::factory()->post->create(); |
195 | 195 | |
196 | 196 | $now = time(); |
197 | 197 | $comment_parents = $comment_children = array(); |
198 | 198 | for ( $i = 0; $i < 5; $i++ ) { |
199 | | $parent = self::$factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); |
| 199 | $parent = self::factory()->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); |
200 | 200 | $comment_parents[ $i ] = $parent; |
201 | 201 | |
202 | | $child = self::$factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ), 'comment_parent' => $parent ) ); |
| 202 | $child = self::factory()->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ), 'comment_parent' => $parent ) ); |
203 | 203 | $comment_children[ $i ] = $child; |
204 | 204 | } |
205 | 205 | |
… |
… |
class Tests_Comment_GetPageOfComment extends WP_UnitTestCase { |
228 | 228 | public function test_comments_per_page_option_should_be_fallback_when_query_var_is_not_available() { |
229 | 229 | $now = time(); |
230 | 230 | |
231 | | $p = self::$factory->post->create(); |
232 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); |
233 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) ); |
234 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) ); |
| 231 | $p = self::factory()->post->create(); |
| 232 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); |
| 233 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) ); |
| 234 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) ); |
235 | 235 | |
236 | 236 | update_option( 'comments_per_page', 2 ); |
237 | 237 | |
-
diff --git tests/phpunit/tests/comment/metaCache.php tests/phpunit/tests/comment/metaCache.php
index 6756325..166ad25 100644
|
|
class Tests_Comment_Meta_Cache extends WP_UnitTestCase { |
10 | 10 | public function test_update_comment_meta_cache_should_default_to_true() { |
11 | 11 | global $wpdb; |
12 | 12 | |
13 | | $p = self::$factory->post->create( array( 'post_status' => 'publish' ) ); |
14 | | $comment_ids = self::$factory->comment->create_post_comments( $p, 3 ); |
| 13 | $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); |
| 14 | $comment_ids = self::factory()->comment->create_post_comments( $p, 3 ); |
15 | 15 | |
16 | 16 | foreach ( $comment_ids as $cid ) { |
17 | 17 | update_comment_meta( $cid, 'foo', 'bar' ); |
… |
… |
class Tests_Comment_Meta_Cache extends WP_UnitTestCase { |
38 | 38 | public function test_update_comment_meta_cache_true() { |
39 | 39 | global $wpdb; |
40 | 40 | |
41 | | $p = self::$factory->post->create( array( 'post_status' => 'publish' ) ); |
42 | | $comment_ids = self::$factory->comment->create_post_comments( $p, 3 ); |
| 41 | $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); |
| 42 | $comment_ids = self::factory()->comment->create_post_comments( $p, 3 ); |
43 | 43 | |
44 | 44 | foreach ( $comment_ids as $cid ) { |
45 | 45 | update_comment_meta( $cid, 'foo', 'bar' ); |
… |
… |
class Tests_Comment_Meta_Cache extends WP_UnitTestCase { |
67 | 67 | public function test_update_comment_meta_cache_false() { |
68 | 68 | global $wpdb; |
69 | 69 | |
70 | | $p = self::$factory->post->create( array( 'post_status' => 'publish' ) ); |
71 | | $comment_ids = self::$factory->comment->create_post_comments( $p, 3 ); |
| 70 | $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); |
| 71 | $comment_ids = self::factory()->comment->create_post_comments( $p, 3 ); |
72 | 72 | |
73 | 73 | foreach ( $comment_ids as $cid ) { |
74 | 74 | update_comment_meta( $cid, 'foo', 'bar' ); |
… |
… |
class Tests_Comment_Meta_Cache extends WP_UnitTestCase { |
93 | 93 | public function test_comment_meta_should_be_lazy_loaded_for_all_comments_in_comments_template() { |
94 | 94 | global $wpdb; |
95 | 95 | |
96 | | $p = self::$factory->post->create( array( 'post_status' => 'publish' ) ); |
97 | | $comment_ids = self::$factory->comment->create_post_comments( $p, 3 ); |
| 96 | $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); |
| 97 | $comment_ids = self::factory()->comment->create_post_comments( $p, 3 ); |
98 | 98 | |
99 | 99 | foreach ( $comment_ids as $cid ) { |
100 | 100 | update_comment_meta( $cid, 'sauce', 'fire' ); |
… |
… |
class Tests_Comment_Meta_Cache extends WP_UnitTestCase { |
128 | 128 | public function test_comment_meta_should_be_lazy_loaded_in_comment_feed_queries() { |
129 | 129 | global $wpdb; |
130 | 130 | |
131 | | $posts = self::$factory->post->create_many( 2, array( 'post_status' => 'publish' ) ); |
| 131 | $posts = self::factory()->post->create_many( 2, array( 'post_status' => 'publish' ) ); |
132 | 132 | |
133 | 133 | $now = time(); |
134 | 134 | $comments = array(); |
135 | 135 | for ( $i = 0; $i < 5; $i++ ) { |
136 | | $comments[] = self::$factory->comment->create( array( |
| 136 | $comments[] = self::factory()->comment->create( array( |
137 | 137 | 'comment_post_ID' => $posts[0], |
138 | 138 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ), |
139 | 139 | ) ); |
… |
… |
class Tests_Comment_Meta_Cache extends WP_UnitTestCase { |
172 | 172 | public function test_comment_meta_should_be_lazy_loaded_in_single_post_comment_feed_queries() { |
173 | 173 | global $wpdb; |
174 | 174 | |
175 | | $posts = self::$factory->post->create_many( 2, array( 'post_status' => 'publish' ) ); |
| 175 | $posts = self::factory()->post->create_many( 2, array( 'post_status' => 'publish' ) ); |
176 | 176 | |
177 | 177 | $now = time(); |
178 | 178 | $comments = array(); |
179 | 179 | for ( $i = 0; $i < 5; $i++ ) { |
180 | | $comments[] = self::$factory->comment->create( array( |
| 180 | $comments[] = self::factory()->comment->create( array( |
181 | 181 | 'comment_post_ID' => $posts[0], |
182 | 182 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ), |
183 | 183 | ) ); |
-
diff --git tests/phpunit/tests/comment/query.php tests/phpunit/tests/comment/query.php
index 9a1c79b..4ccfe8c 100644
|
|
class Tests_Comment_Query extends WP_UnitTestCase { |
12 | 12 | function setUp() { |
13 | 13 | parent::setUp(); |
14 | 14 | |
15 | | $this->post_id = self::$factory->post->create(); |
| 15 | $this->post_id = self::factory()->post->create(); |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function test_query() { |
19 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
20 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
21 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
22 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
23 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 19 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 20 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 21 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 22 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 23 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
24 | 24 | |
25 | 25 | $q = new WP_Comment_Query(); |
26 | 26 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
31 | 31 | } |
32 | 32 | |
33 | 33 | public function test_query_post_id_0() { |
34 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 34 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
35 | 35 | |
36 | 36 | $q = new WP_Comment_Query(); |
37 | 37 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
46 | 46 | * @ticket 12668 |
47 | 47 | */ |
48 | 48 | public function test_query_type_empty_string() { |
49 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
50 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
51 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
52 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
53 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 49 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 50 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 51 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 52 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 53 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
54 | 54 | |
55 | 55 | $q = new WP_Comment_Query(); |
56 | 56 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
65 | 65 | * @ticket 12668 |
66 | 66 | */ |
67 | 67 | public function test_query_type_comment() { |
68 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
69 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
70 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
71 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
72 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 68 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 69 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 70 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 71 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 72 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
73 | 73 | |
74 | 74 | $q = new WP_Comment_Query(); |
75 | 75 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
81 | 81 | } |
82 | 82 | |
83 | 83 | public function test_query_type_pingback() { |
84 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
85 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
86 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
87 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 84 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 85 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 86 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 87 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
88 | 88 | |
89 | 89 | $q = new WP_Comment_Query(); |
90 | 90 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
97 | 97 | } |
98 | 98 | |
99 | 99 | public function test_query_type_trackback() { |
100 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
101 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
102 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
103 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 100 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 101 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 102 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 103 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
104 | 104 | |
105 | 105 | $q = new WP_Comment_Query(); |
106 | 106 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
116 | 116 | * 'pings' is an alias for 'trackback' + 'pingback'. |
117 | 117 | */ |
118 | 118 | public function test_query_type_pings() { |
119 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
120 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
121 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
122 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
123 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 119 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 120 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 121 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 122 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 123 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
124 | 124 | |
125 | 125 | $q = new WP_Comment_Query(); |
126 | 126 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
136 | 136 | * @ticket 12668 |
137 | 137 | */ |
138 | 138 | public function test_type_array_comments_and_custom() { |
139 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
140 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
141 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
142 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
143 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
144 | | $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 139 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 140 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 141 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 142 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 143 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 144 | $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
145 | 145 | |
146 | 146 | $q = new WP_Comment_Query(); |
147 | 147 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
156 | 156 | * @ticket 12668 |
157 | 157 | */ |
158 | 158 | public function test_type_not__in_array_custom() { |
159 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
160 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
161 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
162 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
163 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
164 | | $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 159 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 160 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 161 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 162 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 163 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 164 | $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
165 | 165 | |
166 | 166 | $q = new WP_Comment_Query(); |
167 | 167 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
176 | 176 | * @ticket 12668 |
177 | 177 | */ |
178 | 178 | public function test_type__in_array_and_not_type_array_custom() { |
179 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
180 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
181 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
182 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
183 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
184 | | $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 179 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 180 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 181 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 182 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 183 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 184 | $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
185 | 185 | |
186 | 186 | $q = new WP_Comment_Query(); |
187 | 187 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
197 | 197 | * @ticket 12668 |
198 | 198 | */ |
199 | 199 | public function test_type_array_and_type__not_in_array_custom() { |
200 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
201 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
202 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
203 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
204 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
205 | | $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 200 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 201 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 202 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 203 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 204 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 205 | $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
206 | 206 | |
207 | 207 | $q = new WP_Comment_Query(); |
208 | 208 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
218 | 218 | * @ticket 12668 |
219 | 219 | */ |
220 | 220 | public function test_type__not_in_custom() { |
221 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
222 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
223 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
224 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
225 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
226 | | $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 221 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 222 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 223 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 224 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 225 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 226 | $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
227 | 227 | |
228 | 228 | $q = new WP_Comment_Query(); |
229 | 229 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
238 | 238 | * @ticket 12668 |
239 | 239 | */ |
240 | 240 | public function test_type_array_comments_and_pings() { |
241 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
242 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
243 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
244 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
245 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 241 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 242 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 243 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 244 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 245 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
246 | 246 | |
247 | 247 | $q = new WP_Comment_Query(); |
248 | 248 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
257 | 257 | * @ticket 12668 |
258 | 258 | */ |
259 | 259 | public function test_type_array_comment_pings() { |
260 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
261 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
262 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 260 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 261 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 262 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
263 | 263 | |
264 | 264 | $q = new WP_Comment_Query(); |
265 | 265 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
274 | 274 | * @ticket 12668 |
275 | 275 | */ |
276 | 276 | public function test_type_array_pingback() { |
277 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
278 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
279 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 277 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 278 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 279 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
280 | 280 | |
281 | 281 | $q = new WP_Comment_Query(); |
282 | 282 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
291 | 291 | * @ticket 12668 |
292 | 292 | */ |
293 | 293 | public function test_type_array_custom_pingpack() { |
294 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
295 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
296 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 294 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 295 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 296 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
297 | 297 | |
298 | 298 | $q = new WP_Comment_Query(); |
299 | 299 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
308 | 308 | * @ticket 12668 |
309 | 309 | */ |
310 | 310 | public function test_type_array_pings() { |
311 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
312 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
313 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 311 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 312 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 313 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
314 | 314 | |
315 | 315 | $q = new WP_Comment_Query(); |
316 | 316 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
325 | 325 | * @ticket 12668 |
326 | 326 | */ |
327 | 327 | public function test_type_status_approved_array_comment_pings() { |
328 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
329 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
330 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
331 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'pingback' ) ); |
| 328 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 329 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 330 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 331 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'pingback' ) ); |
332 | 332 | |
333 | 333 | $q = new WP_Comment_Query(); |
334 | 334 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
344 | 344 | * @ticket 12668 |
345 | 345 | */ |
346 | 346 | public function test_type_array_trackback() { |
347 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
348 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
349 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 347 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 348 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 349 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
350 | 350 | |
351 | 351 | $q = new WP_Comment_Query(); |
352 | 352 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
361 | 361 | * @ticket 12668 |
362 | 362 | */ |
363 | 363 | public function test_type_array_custom_trackback() { |
364 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
365 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
366 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 364 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 365 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 366 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
367 | 367 | |
368 | 368 | $q = new WP_Comment_Query(); |
369 | 369 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
378 | 378 | * @ticket 12668 |
379 | 379 | */ |
380 | 380 | public function test_type_array_pings_approved() { |
381 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
382 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
383 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
384 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'trackback' ) ); |
| 381 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 382 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 383 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 384 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'trackback' ) ); |
385 | 385 | |
386 | 386 | $q = new WP_Comment_Query(); |
387 | 387 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
397 | 397 | * @ticket 29612 |
398 | 398 | */ |
399 | 399 | public function test_status_empty_string() { |
400 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
401 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
402 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'spam' ) ); |
| 400 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 401 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
| 402 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'spam' ) ); |
403 | 403 | |
404 | 404 | $q = new WP_Comment_Query(); |
405 | 405 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
414 | 414 | * @ticket 21101 |
415 | 415 | */ |
416 | 416 | public function test_status_hold() { |
417 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
418 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
| 417 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 418 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
419 | 419 | |
420 | 420 | $q = new WP_Comment_Query(); |
421 | 421 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
430 | 430 | * @ticket 21101 |
431 | 431 | */ |
432 | 432 | public function test_status_approve() { |
433 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
434 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
| 433 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 434 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
435 | 435 | |
436 | 436 | $q = new WP_Comment_Query(); |
437 | 437 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
443 | 443 | } |
444 | 444 | |
445 | 445 | public function test_status_custom() { |
446 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
447 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); |
448 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo1' ) ); |
| 446 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 447 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); |
| 448 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo1' ) ); |
449 | 449 | |
450 | 450 | $q = new WP_Comment_Query(); |
451 | 451 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
457 | 457 | } |
458 | 458 | |
459 | 459 | public function test_status_all() { |
460 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
461 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); |
462 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
| 460 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 461 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); |
| 462 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
463 | 463 | |
464 | 464 | $q = new WP_Comment_Query(); |
465 | 465 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
471 | 471 | } |
472 | 472 | |
473 | 473 | public function test_status_default_to_all() { |
474 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
475 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); |
476 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
| 474 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 475 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); |
| 476 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
477 | 477 | |
478 | 478 | $q = new WP_Comment_Query(); |
479 | 479 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
487 | 487 | * @ticket 29612 |
488 | 488 | */ |
489 | 489 | public function test_status_comma_any() { |
490 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
491 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); |
492 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
| 490 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 491 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); |
| 492 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
493 | 493 | |
494 | 494 | $q = new WP_Comment_Query(); |
495 | 495 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
504 | 504 | * @ticket 29612 |
505 | 505 | */ |
506 | 506 | public function test_status_comma_separated() { |
507 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
508 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); |
509 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
| 507 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 508 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); |
| 509 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
510 | 510 | |
511 | 511 | $q = new WP_Comment_Query(); |
512 | 512 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
521 | 521 | * @ticket 29612 |
522 | 522 | */ |
523 | 523 | public function test_status_array() { |
524 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
525 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); |
526 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
| 524 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 525 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); |
| 526 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
527 | 527 | |
528 | 528 | $q = new WP_Comment_Query(); |
529 | 529 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
537 | 537 | function test_get_comments_for_post() { |
538 | 538 | $limit = 5; |
539 | 539 | |
540 | | $post_id = self::$factory->post->create(); |
541 | | self::$factory->comment->create_post_comments( $post_id, $limit ); |
| 540 | $post_id = self::factory()->post->create(); |
| 541 | self::factory()->comment->create_post_comments( $post_id, $limit ); |
542 | 542 | $comments = get_comments( array( 'post_id' => $post_id ) ); |
543 | 543 | $this->assertEquals( $limit, count( $comments ) ); |
544 | 544 | foreach ( $comments as $comment ) { |
545 | 545 | $this->assertEquals( $post_id, $comment->comment_post_ID ); |
546 | 546 | } |
547 | 547 | |
548 | | $post_id2 = self::$factory->post->create(); |
549 | | self::$factory->comment->create_post_comments( $post_id2, $limit ); |
| 548 | $post_id2 = self::factory()->post->create(); |
| 549 | self::factory()->comment->create_post_comments( $post_id2, $limit ); |
550 | 550 | $comments = get_comments( array( 'post_id' => $post_id2 ) ); |
551 | 551 | $this->assertEquals( $limit, count( $comments ) ); |
552 | 552 | foreach ( $comments as $comment ) { |
553 | 553 | $this->assertEquals( $post_id2, $comment->comment_post_ID ); |
554 | 554 | } |
555 | 555 | |
556 | | $post_id3 = self::$factory->post->create(); |
557 | | self::$factory->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '0' ) ); |
| 556 | $post_id3 = self::factory()->post->create(); |
| 557 | self::factory()->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '0' ) ); |
558 | 558 | $comments = get_comments( array( 'post_id' => $post_id3 ) ); |
559 | 559 | $this->assertEquals( $limit, count( $comments ) ); |
560 | 560 | foreach ( $comments as $comment ) { |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
570 | 570 | $comments = get_comments( array( 'post_id' => $post_id3, 'status' => 'approve' ) ); |
571 | 571 | $this->assertEquals( 0, count( $comments ) ); |
572 | 572 | |
573 | | self::$factory->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '1' ) ); |
| 573 | self::factory()->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '1' ) ); |
574 | 574 | $comments = get_comments( array( 'post_id' => $post_id3 ) ); |
575 | 575 | $this->assertEquals( $limit * 2, count( $comments ) ); |
576 | 576 | foreach ( $comments as $comment ) { |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
582 | 582 | * @ticket 21003 |
583 | 583 | */ |
584 | 584 | function test_orderby_meta() { |
585 | | $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); |
586 | | $comment_id2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); |
587 | | $comment_id3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); |
| 585 | $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) ); |
| 586 | $comment_id2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) ); |
| 587 | $comment_id3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) ); |
588 | 588 | |
589 | 589 | add_comment_meta( $comment_id, 'key', 'value1', true ); |
590 | 590 | add_comment_meta( $comment_id, 'key1', 'value1', true ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
632 | 632 | * @ticket 30478 |
633 | 633 | */ |
634 | 634 | public function test_orderby_clause_key() { |
635 | | $comments = self::$factory->comment->create_many( 3 ); |
| 635 | $comments = self::factory()->comment->create_many( 3 ); |
636 | 636 | add_comment_meta( $comments[0], 'foo', 'aaa' ); |
637 | 637 | add_comment_meta( $comments[1], 'foo', 'zzz' ); |
638 | 638 | add_comment_meta( $comments[2], 'foo', 'jjj' ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
657 | 657 | * @ticket 30478 |
658 | 658 | */ |
659 | 659 | public function test_orderby_clause_key_as_secondary_sort() { |
660 | | $c1 = self::$factory->comment->create( array( |
| 660 | $c1 = self::factory()->comment->create( array( |
661 | 661 | 'comment_date' => '2015-01-28 03:00:00', |
662 | 662 | ) ); |
663 | | $c2 = self::$factory->comment->create( array( |
| 663 | $c2 = self::factory()->comment->create( array( |
664 | 664 | 'comment_date' => '2015-01-28 05:00:00', |
665 | 665 | ) ); |
666 | | $c3 = self::$factory->comment->create( array( |
| 666 | $c3 = self::factory()->comment->create( array( |
667 | 667 | 'comment_date' => '2015-01-28 03:00:00', |
668 | 668 | ) ); |
669 | 669 | |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
693 | 693 | * @ticket 30478 |
694 | 694 | */ |
695 | 695 | public function test_orderby_more_than_one_clause_key() { |
696 | | $comments = self::$factory->comment->create_many( 3 ); |
| 696 | $comments = self::factory()->comment->create_many( 3 ); |
697 | 697 | |
698 | 698 | add_comment_meta( $comments[0], 'foo', 'jjj' ); |
699 | 699 | add_comment_meta( $comments[1], 'foo', 'zzz' ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
728 | 728 | * @group 32081 |
729 | 729 | */ |
730 | 730 | public function test_meta_query_should_work_with_comment__in() { |
731 | | $comments = self::$factory->comment->create_many( 3 ); |
| 731 | $comments = self::factory()->comment->create_many( 3 ); |
732 | 732 | |
733 | 733 | add_comment_meta( $comments[0], 'foo', 'jjj' ); |
734 | 734 | add_comment_meta( $comments[1], 'foo', 'zzz' ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
752 | 752 | * @group 32081 |
753 | 753 | */ |
754 | 754 | public function test_meta_query_should_work_with_comment__not_in() { |
755 | | $comments = self::$factory->comment->create_many( 3 ); |
| 755 | $comments = self::factory()->comment->create_many( 3 ); |
756 | 756 | |
757 | 757 | add_comment_meta( $comments[0], 'foo', 'jjj' ); |
758 | 758 | add_comment_meta( $comments[1], 'foo', 'zzz' ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
776 | 776 | * @ticket 27064 |
777 | 777 | */ |
778 | 778 | function test_get_comments_by_user() { |
779 | | $users = self::$factory->user->create_many( 2 ); |
780 | | self::$factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
781 | | self::$factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
782 | | self::$factory->comment->create( array( 'user_id' => $users[1], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 779 | $users = self::factory()->user->create_many( 2 ); |
| 780 | self::factory()->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 781 | self::factory()->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 782 | self::factory()->comment->create( array( 'user_id' => $users[1], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
783 | 783 | |
784 | 784 | $comments = get_comments( array( |
785 | 785 | 'user_id' => $users[0], |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
808 | 808 | * @ticket 28434 |
809 | 809 | */ |
810 | 810 | function test_fields_ids_query() { |
811 | | $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
812 | | $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
813 | | $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 811 | $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 812 | $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 813 | $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
814 | 814 | |
815 | 815 | // Ensure we are dealing with integers, and not objects. |
816 | 816 | $this->assertInternalType( 'integer', $comment_1 ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
826 | 826 | * @ticket 29189 |
827 | 827 | */ |
828 | 828 | function test_fields_comment__in() { |
829 | | $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
830 | | $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
831 | | $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 829 | $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 830 | $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 831 | $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
832 | 832 | |
833 | 833 | $comment_ids = get_comments( array( |
834 | 834 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
842 | 842 | * @ticket 29189 |
843 | 843 | */ |
844 | 844 | function test_fields_comment__not_in() { |
845 | | $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
846 | | $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
847 | | $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 845 | $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 846 | $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 847 | $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
848 | 848 | |
849 | 849 | $comment_ids = get_comments( array( |
850 | 850 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
858 | 858 | * @ticket 29189 |
859 | 859 | */ |
860 | 860 | function test_fields_post__in() { |
861 | | $p1 = self::$factory->post->create(); |
862 | | $p2 = self::$factory->post->create(); |
863 | | $p3 = self::$factory->post->create(); |
| 861 | $p1 = self::factory()->post->create(); |
| 862 | $p2 = self::factory()->post->create(); |
| 863 | $p3 = self::factory()->post->create(); |
864 | 864 | |
865 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) ); |
866 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); |
867 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 865 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 866 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 867 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); |
868 | 868 | |
869 | 869 | $comment_ids = get_comments( array( |
870 | 870 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
878 | 878 | * @ticket 29189 |
879 | 879 | */ |
880 | 880 | function test_fields_post__not_in() { |
881 | | $p1 = self::$factory->post->create(); |
882 | | $p2 = self::$factory->post->create(); |
883 | | $p3 = self::$factory->post->create(); |
| 881 | $p1 = self::factory()->post->create(); |
| 882 | $p2 = self::factory()->post->create(); |
| 883 | $p3 = self::factory()->post->create(); |
884 | 884 | |
885 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) ); |
886 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); |
887 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 885 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 886 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 887 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); |
888 | 888 | |
889 | 889 | $comment_ids = get_comments( array( |
890 | 890 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
901 | 901 | $author_id1 = 105; |
902 | 902 | $author_id2 = 106; |
903 | 903 | |
904 | | $p1 = self::$factory->post->create( array( 'post_author' => $author_id1 ) ); |
905 | | $p2 = self::$factory->post->create( array( 'post_author' => $author_id1 ) ); |
906 | | $p3 = self::$factory->post->create( array( 'post_author' => $author_id2 ) ); |
| 904 | $p1 = self::factory()->post->create( array( 'post_author' => $author_id1 ) ); |
| 905 | $p2 = self::factory()->post->create( array( 'post_author' => $author_id1 ) ); |
| 906 | $p3 = self::factory()->post->create( array( 'post_author' => $author_id2 ) ); |
907 | 907 | |
908 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); |
909 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); |
910 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 908 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 909 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 910 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); |
911 | 911 | |
912 | 912 | $comment_ids = get_comments( array( |
913 | 913 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
924 | 924 | $author_id1 = 111; |
925 | 925 | $author_id2 = 112; |
926 | 926 | |
927 | | $p1 = self::$factory->post->create( array( 'post_author' => $author_id1 ) ); |
928 | | $p2 = self::$factory->post->create( array( 'post_author' => $author_id1 ) ); |
929 | | $p3 = self::$factory->post->create( array( 'post_author' => $author_id2 ) ); |
| 927 | $p1 = self::factory()->post->create( array( 'post_author' => $author_id1 ) ); |
| 928 | $p2 = self::factory()->post->create( array( 'post_author' => $author_id1 ) ); |
| 929 | $p3 = self::factory()->post->create( array( 'post_author' => $author_id2 ) ); |
930 | 930 | |
931 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); |
932 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); |
933 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 931 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 932 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 933 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); |
934 | 934 | |
935 | 935 | $comment_ids = get_comments( array( |
936 | 936 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
944 | 944 | * @ticket 29885 |
945 | 945 | */ |
946 | 946 | function test_fields_author__in() { |
947 | | $p1 = self::$factory->post->create(); |
948 | | $p2 = self::$factory->post->create(); |
949 | | $p3 = self::$factory->post->create(); |
950 | | $p4 = self::$factory->post->create(); |
| 947 | $p1 = self::factory()->post->create(); |
| 948 | $p2 = self::factory()->post->create(); |
| 949 | $p3 = self::factory()->post->create(); |
| 950 | $p4 = self::factory()->post->create(); |
951 | 951 | |
952 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); |
953 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) ); |
954 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) ); |
955 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) ); |
| 952 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 953 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) ); |
| 954 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) ); |
| 955 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) ); |
956 | 956 | |
957 | 957 | $comment_ids = get_comments( array( |
958 | 958 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
966 | 966 | * @ticket 29885 |
967 | 967 | */ |
968 | 968 | function test_fields_author__not_in() { |
969 | | $p1 = self::$factory->post->create(); |
970 | | $p2 = self::$factory->post->create(); |
971 | | $p3 = self::$factory->post->create(); |
972 | | $p4 = self::$factory->post->create(); |
| 969 | $p1 = self::factory()->post->create(); |
| 970 | $p2 = self::factory()->post->create(); |
| 971 | $p3 = self::factory()->post->create(); |
| 972 | $p4 = self::factory()->post->create(); |
973 | 973 | |
974 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); |
975 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) ); |
976 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) ); |
977 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) ); |
| 974 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 975 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 2, 'comment_approved' => '1' ) ); |
| 976 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 3, 'comment_approved' => '1' ) ); |
| 977 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $p4, 'user_id' => 4, 'comment_approved' => '1' ) ); |
978 | 978 | |
979 | 979 | $comment_ids = get_comments( array( |
980 | 980 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
988 | 988 | * @ticket 19623 |
989 | 989 | */ |
990 | 990 | public function test_get_comments_with_status_all() { |
991 | | $comment_1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
992 | | $comment_2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
993 | | $comment_3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); |
| 991 | $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 992 | $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 993 | $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); |
994 | 994 | $comments_approved_1 = get_comments( array( 'status' => 'all' ) ); |
995 | 995 | |
996 | 996 | $comment_ids = get_comments( array( 'fields' => 'ids' ) ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1001 | 1001 | * @ticket 19623 |
1002 | 1002 | */ |
1003 | 1003 | public function test_get_comments_with_include_unapproved_user_id() { |
1004 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
1005 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
1006 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); |
1007 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); |
| 1004 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 1005 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 1006 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); |
| 1007 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); |
1008 | 1008 | |
1009 | 1009 | $found = get_comments( array( |
1010 | 1010 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1019 | 1019 | * @ticket 19623 |
1020 | 1020 | */ |
1021 | 1021 | public function test_get_comments_with_include_unapproved_user_id_array() { |
1022 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
1023 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
1024 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); |
1025 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); |
1026 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); |
| 1022 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 1023 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 1024 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); |
| 1025 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); |
| 1026 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); |
1027 | 1027 | |
1028 | 1028 | $found = get_comments( array( |
1029 | 1029 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1038 | 1038 | * @ticket 19623 |
1039 | 1039 | */ |
1040 | 1040 | public function test_get_comments_with_include_unapproved_user_id_comma_separated() { |
1041 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
1042 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
1043 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); |
1044 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); |
1045 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); |
| 1041 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 1042 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 1043 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); |
| 1044 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); |
| 1045 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); |
1046 | 1046 | |
1047 | 1047 | $found = get_comments( array( |
1048 | 1048 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1057 | 1057 | * @ticket 19623 |
1058 | 1058 | */ |
1059 | 1059 | public function test_get_comments_with_include_unapproved_author_email() { |
1060 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
1061 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); |
1062 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); |
1063 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); |
| 1060 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 1061 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); |
| 1062 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); |
| 1063 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); |
1064 | 1064 | |
1065 | 1065 | $found = get_comments( array( |
1066 | 1066 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1075 | 1075 | * @ticket 19623 |
1076 | 1076 | */ |
1077 | 1077 | public function test_get_comments_with_include_unapproved_mixed_array() { |
1078 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
1079 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); |
1080 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); |
1081 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); |
1082 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); |
| 1078 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 1079 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); |
| 1080 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); |
| 1081 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); |
| 1082 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); |
1083 | 1083 | |
1084 | 1084 | $found = get_comments( array( |
1085 | 1085 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1094 | 1094 | * @ticket 19623 |
1095 | 1095 | */ |
1096 | 1096 | public function test_get_comments_with_include_unapproved_mixed_comma_separated() { |
1097 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
1098 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); |
1099 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); |
1100 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); |
1101 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); |
| 1097 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 1098 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); |
| 1099 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); |
| 1100 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); |
| 1101 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); |
1102 | 1102 | |
1103 | 1103 | $found = get_comments( array( |
1104 | 1104 | 'fields' => 'ids', |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1110 | 1110 | } |
1111 | 1111 | |
1112 | 1112 | public function test_search() { |
1113 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); |
1114 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'foo@example.com' ) ); |
1115 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); |
1116 | | $c4 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_author_IP' => 'foo.bar' ) ); |
1117 | | $c5 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_content' => 'Nice foo comment' ) ); |
1118 | | $c6 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com' ) ); |
| 1113 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); |
| 1114 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'foo@example.com' ) ); |
| 1115 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); |
| 1116 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_author_IP' => 'foo.bar' ) ); |
| 1117 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_content' => 'Nice foo comment' ) ); |
| 1118 | $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com' ) ); |
1119 | 1119 | |
1120 | 1120 | $q = new WP_Comment_Query(); |
1121 | 1121 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1363 | 1363 | */ |
1364 | 1364 | public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_ASC() { |
1365 | 1365 | $now = current_time( 'mysql', 1 ); |
1366 | | $comments = self::$factory->comment->create_many( 5, array( |
| 1366 | $comments = self::factory()->comment->create_many( 5, array( |
1367 | 1367 | 'comment_post_ID' => $this->post_id, |
1368 | 1368 | 'comment_date_gmt' => $now, |
1369 | 1369 | ) ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1383 | 1383 | */ |
1384 | 1384 | public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_DESC() { |
1385 | 1385 | $now = current_time( 'mysql', 1 ); |
1386 | | $comments = self::$factory->comment->create_many( 5, array( |
| 1386 | $comments = self::factory()->comment->create_many( 5, array( |
1387 | 1387 | 'comment_post_ID' => $this->post_id, |
1388 | 1388 | 'comment_date_gmt' => $now, |
1389 | 1389 | ) ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1416 | 1416 | } |
1417 | 1417 | |
1418 | 1418 | public function test_count() { |
1419 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); |
1420 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); |
| 1419 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); |
| 1420 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); |
1421 | 1421 | |
1422 | 1422 | $q = new WP_Comment_Query(); |
1423 | 1423 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1431 | 1431 | * @ticket 23369 |
1432 | 1432 | */ |
1433 | 1433 | public function test_count_with_meta_query() { |
1434 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); |
1435 | | $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); |
1436 | | $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); |
| 1434 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); |
| 1435 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); |
| 1436 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); |
1437 | 1437 | add_comment_meta( $c1, 'foo', 'bar' ); |
1438 | 1438 | add_comment_meta( $c3, 'foo', 'bar' ); |
1439 | 1439 | |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1455 | 1455 | register_post_type( 'post-type-1' ); |
1456 | 1456 | register_post_type( 'post-type-2' ); |
1457 | 1457 | |
1458 | | $p1 = self::$factory->post->create( array( 'post_type' => 'post-type-1' ) ); |
1459 | | $p2 = self::$factory->post->create( array( 'post_type' => 'post-type-2' ) ); |
| 1458 | $p1 = self::factory()->post->create( array( 'post_type' => 'post-type-1' ) ); |
| 1459 | $p2 = self::factory()->post->create( array( 'post_type' => 'post-type-2' ) ); |
1460 | 1460 | |
1461 | | $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); |
1462 | | $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); |
| 1461 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| 1462 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
1463 | 1463 | |
1464 | 1464 | $q = new WP_Comment_Query(); |
1465 | 1465 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1480 | 1480 | register_post_type( 'post-type-1' ); |
1481 | 1481 | register_post_type( 'post-type-2' ); |
1482 | 1482 | |
1483 | | $p1 = self::$factory->post->create( array( 'post_type' => 'post-type-1' ) ); |
1484 | | $p2 = self::$factory->post->create( array( 'post_type' => 'post-type-2' ) ); |
| 1483 | $p1 = self::factory()->post->create( array( 'post_type' => 'post-type-1' ) ); |
| 1484 | $p2 = self::factory()->post->create( array( 'post_type' => 'post-type-2' ) ); |
1485 | 1485 | |
1486 | | $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); |
1487 | | $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); |
| 1486 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| 1487 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
1488 | 1488 | |
1489 | 1489 | $q = new WP_Comment_Query(); |
1490 | 1490 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1505 | 1505 | register_post_type( 'post-type-1' ); |
1506 | 1506 | register_post_type( 'post-type-2' ); |
1507 | 1507 | |
1508 | | $p1 = self::$factory->post->create( array( 'post_type' => 'post-type-1' ) ); |
1509 | | $p2 = self::$factory->post->create( array( 'post_type' => 'post-type-2' ) ); |
1510 | | $p3 = self::$factory->post->create( array( 'post_type' => 'post-type-3' ) ); |
| 1508 | $p1 = self::factory()->post->create( array( 'post_type' => 'post-type-1' ) ); |
| 1509 | $p2 = self::factory()->post->create( array( 'post_type' => 'post-type-2' ) ); |
| 1510 | $p3 = self::factory()->post->create( array( 'post_type' => 'post-type-3' ) ); |
1511 | 1511 | |
1512 | | $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); |
1513 | | $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); |
1514 | | $c3 = self::$factory->comment->create_post_comments( $p3, 1 ); |
| 1512 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| 1513 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
| 1514 | $c3 = self::factory()->comment->create_post_comments( $p3, 1 ); |
1515 | 1515 | |
1516 | 1516 | $q = new WP_Comment_Query(); |
1517 | 1517 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | public function test_post_name_single_value() { |
1529 | | $p1 = self::$factory->post->create( array( 'post_name' => 'foo' ) ); |
1530 | | $p2 = self::$factory->post->create( array( 'post_name' => 'bar' ) ); |
| 1529 | $p1 = self::factory()->post->create( array( 'post_name' => 'foo' ) ); |
| 1530 | $p2 = self::factory()->post->create( array( 'post_name' => 'bar' ) ); |
1531 | 1531 | |
1532 | | $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); |
1533 | | $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); |
| 1532 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| 1533 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
1534 | 1534 | |
1535 | 1535 | $q = new WP_Comment_Query(); |
1536 | 1536 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1545 | 1545 | * @ticket 20006 |
1546 | 1546 | */ |
1547 | 1547 | public function test_post_name_singleton_array() { |
1548 | | $p1 = self::$factory->post->create( array( 'post_name' => 'foo' ) ); |
1549 | | $p2 = self::$factory->post->create( array( 'post_name' => 'bar' ) ); |
| 1548 | $p1 = self::factory()->post->create( array( 'post_name' => 'foo' ) ); |
| 1549 | $p2 = self::factory()->post->create( array( 'post_name' => 'bar' ) ); |
1550 | 1550 | |
1551 | | $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); |
1552 | | $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); |
| 1551 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| 1552 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
1553 | 1553 | |
1554 | 1554 | $q = new WP_Comment_Query(); |
1555 | 1555 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1564 | 1564 | * @ticket 20006 |
1565 | 1565 | */ |
1566 | 1566 | public function test_post_name_array() { |
1567 | | $p1 = self::$factory->post->create( array( 'post_name' => 'foo' ) ); |
1568 | | $p2 = self::$factory->post->create( array( 'post_name' => 'bar' ) ); |
1569 | | $p3 = self::$factory->post->create( array( 'post_name' => 'baz' ) ); |
| 1567 | $p1 = self::factory()->post->create( array( 'post_name' => 'foo' ) ); |
| 1568 | $p2 = self::factory()->post->create( array( 'post_name' => 'bar' ) ); |
| 1569 | $p3 = self::factory()->post->create( array( 'post_name' => 'baz' ) ); |
1570 | 1570 | |
1571 | | $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); |
1572 | | $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); |
1573 | | $c3 = self::$factory->comment->create_post_comments( $p3, 1 ); |
| 1571 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| 1572 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
| 1573 | $c3 = self::factory()->comment->create_post_comments( $p3, 1 ); |
1574 | 1574 | |
1575 | 1575 | $q = new WP_Comment_Query(); |
1576 | 1576 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1582 | 1582 | } |
1583 | 1583 | |
1584 | 1584 | public function test_post_status_single_value() { |
1585 | | $p1 = self::$factory->post->create( array( 'post_status' => 'publish' ) ); |
1586 | | $p2 = self::$factory->post->create( array( 'post_status' => 'draft' ) ); |
| 1585 | $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); |
| 1586 | $p2 = self::factory()->post->create( array( 'post_status' => 'draft' ) ); |
1587 | 1587 | |
1588 | | $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); |
1589 | | $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); |
| 1588 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| 1589 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
1590 | 1590 | |
1591 | 1591 | $q = new WP_Comment_Query(); |
1592 | 1592 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1601 | 1601 | * @ticket 20006 |
1602 | 1602 | */ |
1603 | 1603 | public function test_post_status_singleton_array() { |
1604 | | $p1 = self::$factory->post->create( array( 'post_status' => 'publish' ) ); |
1605 | | $p2 = self::$factory->post->create( array( 'post_status' => 'draft' ) ); |
| 1604 | $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); |
| 1605 | $p2 = self::factory()->post->create( array( 'post_status' => 'draft' ) ); |
1606 | 1606 | |
1607 | | $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); |
1608 | | $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); |
| 1607 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| 1608 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
1609 | 1609 | |
1610 | 1610 | $q = new WP_Comment_Query(); |
1611 | 1611 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1620 | 1620 | * @ticket 20006 |
1621 | 1621 | */ |
1622 | 1622 | public function test_post_status_array() { |
1623 | | $p1 = self::$factory->post->create( array( 'post_status' => 'publish' ) ); |
1624 | | $p2 = self::$factory->post->create( array( 'post_status' => 'draft' ) ); |
1625 | | $p3 = self::$factory->post->create( array( 'post_status' => 'future' ) ); |
| 1623 | $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); |
| 1624 | $p2 = self::factory()->post->create( array( 'post_status' => 'draft' ) ); |
| 1625 | $p3 = self::factory()->post->create( array( 'post_status' => 'future' ) ); |
1626 | 1626 | |
1627 | | $c1 = self::$factory->comment->create_post_comments( $p1, 1 ); |
1628 | | $c2 = self::$factory->comment->create_post_comments( $p2, 1 ); |
1629 | | $c3 = self::$factory->comment->create_post_comments( $p3, 1 ); |
| 1627 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| 1628 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
| 1629 | $c3 = self::factory()->comment->create_post_comments( $p3, 1 ); |
1630 | 1630 | |
1631 | 1631 | $q = new WP_Comment_Query(); |
1632 | 1632 | $found = $q->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1641 | 1641 | * @ticket 24826 |
1642 | 1642 | */ |
1643 | 1643 | public function test_comment_query_object() { |
1644 | | $comment_id = self::$factory->comment->create(); |
| 1644 | $comment_id = self::factory()->comment->create(); |
1645 | 1645 | |
1646 | 1646 | $query1 = new WP_Comment_Query(); |
1647 | 1647 | $this->assertNull( $query1->query_vars ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1663 | 1663 | public function test_comment_cache_key_should_ignore_custom_params() { |
1664 | 1664 | global $wpdb; |
1665 | 1665 | |
1666 | | $p = self::$factory->post->create(); |
1667 | | $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); |
| 1666 | $p = self::factory()->post->create(); |
| 1667 | $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) ); |
1668 | 1668 | |
1669 | 1669 | $q1 = new WP_Comment_Query(); |
1670 | 1670 | $q1->query( array( |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1688 | 1688 | * @ticket 32762 |
1689 | 1689 | */ |
1690 | 1690 | public function test_it_should_be_possible_to_modify_meta_query_using_pre_get_comments_action() { |
1691 | | $comments = self::$factory->comment->create_many( 2, array( |
| 1691 | $comments = self::factory()->comment->create_many( 2, array( |
1692 | 1692 | 'comment_post_ID' => $this->post_id, |
1693 | 1693 | ) ); |
1694 | 1694 | |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1719 | 1719 | * @ticket 32762 |
1720 | 1720 | */ |
1721 | 1721 | public function test_it_should_be_possible_to_modify_meta_params_using_pre_get_comments_action() { |
1722 | | $comments = self::$factory->comment->create_many( 2, array( |
| 1722 | $comments = self::factory()->comment->create_many( 2, array( |
1723 | 1723 | 'comment_post_ID' => $this->post_id, |
1724 | 1724 | ) ); |
1725 | 1725 | |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1746 | 1746 | * @ticket 33882 |
1747 | 1747 | */ |
1748 | 1748 | public function test_parent__in() { |
1749 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
1750 | | $c2 = self::$factory->comment->create( array( |
| 1749 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 1750 | $c2 = self::factory()->comment->create( array( |
1751 | 1751 | 'comment_post_ID' => $this->post_id, |
1752 | 1752 | 'comment_approved' => '1', |
1753 | 1753 | 'comment_parent' => $c1, |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1766 | 1766 | * @ticket 33882 |
1767 | 1767 | */ |
1768 | 1768 | public function test_parent__in_commas() { |
1769 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
1770 | | $c2 = self::$factory->comment->create( array( |
| 1769 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 1770 | $c2 = self::factory()->comment->create( array( |
1771 | 1771 | 'comment_post_ID' => $this->post_id, |
1772 | 1772 | 'comment_approved' => '1' |
1773 | 1773 | ) ); |
1774 | | $c3 = self::$factory->comment->create( array( |
| 1774 | $c3 = self::factory()->comment->create( array( |
1775 | 1775 | 'comment_post_ID' => $this->post_id, |
1776 | 1776 | 'comment_approved' => '1', |
1777 | 1777 | 'comment_parent' => $c1, |
1778 | 1778 | ) ); |
1779 | | $c4 = self::$factory->comment->create( array( |
| 1779 | $c4 = self::factory()->comment->create( array( |
1780 | 1780 | 'comment_post_ID' => $this->post_id, |
1781 | 1781 | 'comment_approved' => '1', |
1782 | 1782 | 'comment_parent' => $c2, |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1795 | 1795 | * @ticket 33882 |
1796 | 1796 | */ |
1797 | 1797 | public function test_parent__not_in() { |
1798 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 1798 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
1799 | 1799 | |
1800 | | self::$factory->comment->create( array( |
| 1800 | self::factory()->comment->create( array( |
1801 | 1801 | 'comment_post_ID' => $this->post_id, |
1802 | 1802 | 'comment_approved' => '1', |
1803 | 1803 | 'comment_parent' => $c1, |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1816 | 1816 | * @ticket 33882 |
1817 | 1817 | */ |
1818 | 1818 | public function test_parent__not_in_commas() { |
1819 | | $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
1820 | | $c2 = self::$factory->comment->create( array( |
| 1819 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 1820 | $c2 = self::factory()->comment->create( array( |
1821 | 1821 | 'comment_post_ID' => $this->post_id, |
1822 | 1822 | 'comment_approved' => '1' |
1823 | 1823 | ) ); |
1824 | 1824 | |
1825 | | self::$factory->comment->create( array( |
| 1825 | self::factory()->comment->create( array( |
1826 | 1826 | 'comment_post_ID' => $this->post_id, |
1827 | 1827 | 'comment_approved' => '1', |
1828 | 1828 | 'comment_parent' => $c1, |
1829 | 1829 | ) ); |
1830 | | self::$factory->comment->create( array( |
| 1830 | self::factory()->comment->create( array( |
1831 | 1831 | 'comment_post_ID' => $this->post_id, |
1832 | 1832 | 'comment_approved' => '1', |
1833 | 1833 | 'comment_parent' => $c2, |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1846 | 1846 | * @ticket 33883 |
1847 | 1847 | */ |
1848 | 1848 | public function test_orderby_comment__in() { |
1849 | | self::$factory->comment->create( array( |
| 1849 | self::factory()->comment->create( array( |
1850 | 1850 | 'comment_post_ID' => $this->post_id, |
1851 | 1851 | 'comment_approved' => '1' |
1852 | 1852 | ) ); |
1853 | 1853 | |
1854 | | $c2 = self::$factory->comment->create( array( |
| 1854 | $c2 = self::factory()->comment->create( array( |
1855 | 1855 | 'comment_post_ID' => $this->post_id, |
1856 | 1856 | 'comment_approved' => '1' |
1857 | 1857 | ) ); |
1858 | | $c3 = self::$factory->comment->create( array( |
| 1858 | $c3 = self::factory()->comment->create( array( |
1859 | 1859 | 'comment_post_ID' => $this->post_id, |
1860 | 1860 | 'comment_approved' => '1' |
1861 | 1861 | ) ); |
1862 | 1862 | |
1863 | | self::$factory->comment->create( array( |
| 1863 | self::factory()->comment->create( array( |
1864 | 1864 | 'comment_post_ID' => $this->post_id, |
1865 | 1865 | 'comment_approved' => '1' |
1866 | 1866 | ) ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1880 | 1880 | * @ticket 8071 |
1881 | 1881 | */ |
1882 | 1882 | public function test_no_found_rows_should_default_to_true() { |
1883 | | $comments = self::$factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); |
| 1883 | $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); |
1884 | 1884 | |
1885 | 1885 | $q = new WP_Comment_Query( array( |
1886 | 1886 | 'post_id' => $this->post_id, |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1895 | 1895 | * @ticket 8071 |
1896 | 1896 | */ |
1897 | 1897 | public function test_should_respect_no_found_rows_true() { |
1898 | | $comments = self::$factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); |
| 1898 | $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); |
1899 | 1899 | |
1900 | 1900 | $q = new WP_Comment_Query( array( |
1901 | 1901 | 'post_id' => $this->post_id, |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1911 | 1911 | * @ticket 8071 |
1912 | 1912 | */ |
1913 | 1913 | public function test_should_respect_no_found_rows_false() { |
1914 | | $comments = self::$factory->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); |
| 1914 | $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); |
1915 | 1915 | |
1916 | 1916 | $q = new WP_Comment_Query( array( |
1917 | 1917 | 'post_id' => $this->post_id, |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1927 | 1927 | * @ticket 8071 |
1928 | 1928 | */ |
1929 | 1929 | public function test_hierarchical_should_skip_child_comments_in_offset() { |
1930 | | $top_level_0 = self::$factory->comment->create( array( |
| 1930 | $top_level_0 = self::factory()->comment->create( array( |
1931 | 1931 | 'comment_post_ID' => $this->post_id, |
1932 | 1932 | 'comment_approved' => '1', |
1933 | 1933 | ) ); |
1934 | 1934 | |
1935 | | $child_of_0 = self::$factory->comment->create( array( |
| 1935 | $child_of_0 = self::factory()->comment->create( array( |
1936 | 1936 | 'comment_post_ID' => $this->post_id, |
1937 | 1937 | 'comment_approved' => '1', |
1938 | 1938 | 'comment_parent' => $top_level_0, |
1939 | 1939 | ) ); |
1940 | 1940 | |
1941 | | $top_level_comments = self::$factory->comment->create_many( 3, array( |
| 1941 | $top_level_comments = self::factory()->comment->create_many( 3, array( |
1942 | 1942 | 'comment_post_ID' => $this->post_id, |
1943 | 1943 | 'comment_approved' => '1', |
1944 | 1944 | ) ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1960 | 1960 | * @ticket 8071 |
1961 | 1961 | */ |
1962 | 1962 | public function test_hierarchical_should_not_include_child_comments_in_number() { |
1963 | | $top_level_0 = self::$factory->comment->create( array( |
| 1963 | $top_level_0 = self::factory()->comment->create( array( |
1964 | 1964 | 'comment_post_ID' => $this->post_id, |
1965 | 1965 | 'comment_approved' => '1', |
1966 | 1966 | ) ); |
1967 | 1967 | |
1968 | | $child_of_0 = self::$factory->comment->create( array( |
| 1968 | $child_of_0 = self::factory()->comment->create( array( |
1969 | 1969 | 'comment_post_ID' => $this->post_id, |
1970 | 1970 | 'comment_approved' => '1', |
1971 | 1971 | 'comment_parent' => $top_level_0, |
1972 | 1972 | ) ); |
1973 | 1973 | |
1974 | | $top_level_comments = self::$factory->comment->create_many( 3, array( |
| 1974 | $top_level_comments = self::factory()->comment->create_many( 3, array( |
1975 | 1975 | 'comment_post_ID' => $this->post_id, |
1976 | 1976 | 'comment_approved' => '1', |
1977 | 1977 | ) ); |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
1991 | 1991 | * @ticket 8071 |
1992 | 1992 | */ |
1993 | 1993 | public function test_hierarchical_threaded() { |
1994 | | $c1 = self::$factory->comment->create( array( |
| 1994 | $c1 = self::factory()->comment->create( array( |
1995 | 1995 | 'comment_post_ID' => $this->post_id, |
1996 | 1996 | 'comment_approved' => '1', |
1997 | 1997 | ) ); |
1998 | 1998 | |
1999 | | $c2 = self::$factory->comment->create( array( |
| 1999 | $c2 = self::factory()->comment->create( array( |
2000 | 2000 | 'comment_post_ID' => $this->post_id, |
2001 | 2001 | 'comment_approved' => '1', |
2002 | 2002 | 'comment_parent' => $c1, |
2003 | 2003 | ) ); |
2004 | 2004 | |
2005 | | $c3 = self::$factory->comment->create( array( |
| 2005 | $c3 = self::factory()->comment->create( array( |
2006 | 2006 | 'comment_post_ID' => $this->post_id, |
2007 | 2007 | 'comment_approved' => '1', |
2008 | 2008 | 'comment_parent' => $c2, |
2009 | 2009 | ) ); |
2010 | 2010 | |
2011 | | $c4 = self::$factory->comment->create( array( |
| 2011 | $c4 = self::factory()->comment->create( array( |
2012 | 2012 | 'comment_post_ID' => $this->post_id, |
2013 | 2013 | 'comment_approved' => '1', |
2014 | 2014 | 'comment_parent' => $c1, |
2015 | 2015 | ) ); |
2016 | 2016 | |
2017 | | $c5 = self::$factory->comment->create( array( |
| 2017 | $c5 = self::factory()->comment->create( array( |
2018 | 2018 | 'comment_post_ID' => $this->post_id, |
2019 | 2019 | 'comment_approved' => '1', |
2020 | 2020 | ) ); |
2021 | 2021 | |
2022 | | $c6 = self::$factory->comment->create( array( |
| 2022 | $c6 = self::factory()->comment->create( array( |
2023 | 2023 | 'comment_post_ID' => $this->post_id, |
2024 | 2024 | 'comment_approved' => '1', |
2025 | 2025 | 'comment_parent' => $c5, |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
2054 | 2054 | * @ticket 8071 |
2055 | 2055 | */ |
2056 | 2056 | public function test_hierarchical_threaded_approved() { |
2057 | | $c1 = self::$factory->comment->create( array( |
| 2057 | $c1 = self::factory()->comment->create( array( |
2058 | 2058 | 'comment_post_ID' => $this->post_id, |
2059 | 2059 | 'comment_approved' => '1', |
2060 | 2060 | ) ); |
2061 | 2061 | |
2062 | | $c2 = self::$factory->comment->create( array( |
| 2062 | $c2 = self::factory()->comment->create( array( |
2063 | 2063 | 'comment_post_ID' => $this->post_id, |
2064 | 2064 | 'comment_approved' => '1', |
2065 | 2065 | 'comment_parent' => $c1, |
2066 | 2066 | ) ); |
2067 | 2067 | |
2068 | | $c3 = self::$factory->comment->create( array( |
| 2068 | $c3 = self::factory()->comment->create( array( |
2069 | 2069 | 'comment_post_ID' => $this->post_id, |
2070 | 2070 | 'comment_approved' => '0', |
2071 | 2071 | 'comment_parent' => $c2, |
2072 | 2072 | ) ); |
2073 | 2073 | |
2074 | | $c4 = self::$factory->comment->create( array( |
| 2074 | $c4 = self::factory()->comment->create( array( |
2075 | 2075 | 'comment_post_ID' => $this->post_id, |
2076 | 2076 | 'comment_approved' => '1', |
2077 | 2077 | 'comment_parent' => $c1, |
2078 | 2078 | ) ); |
2079 | 2079 | |
2080 | | $c5 = self::$factory->comment->create( array( |
| 2080 | $c5 = self::factory()->comment->create( array( |
2081 | 2081 | 'comment_post_ID' => $this->post_id, |
2082 | 2082 | 'comment_approved' => '1', |
2083 | 2083 | ) ); |
2084 | 2084 | |
2085 | | self::$factory->comment->create( array( |
| 2085 | self::factory()->comment->create( array( |
2086 | 2086 | 'comment_post_ID' => $this->post_id, |
2087 | 2087 | 'comment_approved' => '1', |
2088 | 2088 | 'comment_parent' => $c5, |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
2117 | 2117 | public function test_update_comment_post_cache_should_be_disabled_by_default() { |
2118 | 2118 | global $wpdb; |
2119 | 2119 | |
2120 | | $p = self::$factory->post->create(); |
2121 | | $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); |
| 2120 | $p = self::factory()->post->create(); |
| 2121 | $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) ); |
2122 | 2122 | |
2123 | 2123 | $q = new WP_Comment_Query( array( |
2124 | 2124 | 'post_ID' => $p, |
… |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
2135 | 2135 | public function test_should_respect_update_comment_post_cache_true() { |
2136 | 2136 | global $wpdb; |
2137 | 2137 | |
2138 | | $p = self::$factory->post->create(); |
2139 | | $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); |
| 2138 | $p = self::factory()->post->create(); |
| 2139 | $c = self::factory()->comment->create( array( 'comment_post_ID' => $p ) ); |
2140 | 2140 | |
2141 | 2141 | $q = new WP_Comment_Query( array( |
2142 | 2142 | 'post_ID' => $p, |
-
diff --git tests/phpunit/tests/comment/slashes.php tests/phpunit/tests/comment/slashes.php
index 01b4e99..6a87ab5 100644
|
|
class Tests_Comment_Slashes extends WP_UnitTestCase { |
9 | 9 | function setUp() { |
10 | 10 | parent::setUp(); |
11 | 11 | // we need an admin user to bypass comment flood protection |
12 | | $this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 12 | $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
13 | 13 | $this->old_current_user = get_current_user_id(); |
14 | 14 | wp_set_current_user( $this->author_id ); |
15 | 15 | |
… |
… |
class Tests_Comment_Slashes extends WP_UnitTestCase { |
34 | 34 | * |
35 | 35 | */ |
36 | 36 | function test_wp_new_comment() { |
37 | | $post_id = self::$factory->post->create(); |
| 37 | $post_id = self::factory()->post->create(); |
38 | 38 | |
39 | 39 | // not testing comment_author_email or comment_author_url |
40 | 40 | // as slashes are not permitted in that data |
… |
… |
class Tests_Comment_Slashes extends WP_UnitTestCase { |
74 | 74 | * |
75 | 75 | */ |