-
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 | */ |
76 | 76 | function test_edit_comment() { |
77 | | $post_id = self::$factory->post->create(); |
78 | | $comment_id = self::$factory->comment->create(array( |
| 77 | $post_id = self::factory()->post->create(); |
| 78 | $comment_id = self::factory()->comment->create(array( |
79 | 79 | 'comment_post_ID' => $post_id |
80 | 80 | )); |
81 | 81 | |
… |
… |
class Tests_Comment_Slashes extends WP_UnitTestCase { |
117 | 117 | * |
118 | 118 | */ |
119 | 119 | function test_wp_insert_comment() { |
120 | | $post_id = self::$factory->post->create(); |
| 120 | $post_id = self::factory()->post->create(); |
121 | 121 | |
122 | 122 | $comment_id = wp_insert_comment(array( |
123 | 123 | 'comment_post_ID' => $post_id, |
… |
… |
class Tests_Comment_Slashes extends WP_UnitTestCase { |
145 | 145 | * |
146 | 146 | */ |
147 | 147 | function test_wp_update_comment() { |
148 | | $post_id = self::$factory->post->create(); |
149 | | $comment_id = self::$factory->comment->create(array( |
| 148 | $post_id = self::factory()->post->create(); |
| 149 | $comment_id = self::factory()->comment->create(array( |
150 | 150 | 'comment_post_ID' => $post_id |
151 | 151 | )); |
152 | 152 | |
-
diff --git tests/phpunit/tests/comment/template.php tests/phpunit/tests/comment/template.php
index 8556cb0..00fd2b8 100644
|
|
|
5 | 5 | class Tests_Comment_Template extends WP_UnitTestCase { |
6 | 6 | |
7 | 7 | function test_get_comments_number() { |
8 | | $post_id = self::$factory->post->create(); |
| 8 | $post_id = self::factory()->post->create(); |
9 | 9 | |
10 | 10 | $this->assertEquals( 0, get_comments_number( 0 ) ); |
11 | 11 | $this->assertEquals( 0, get_comments_number( $post_id ) ); |
12 | 12 | $this->assertEquals( 0, get_comments_number( get_post( $post_id ) ) ); |
13 | 13 | |
14 | | self::$factory->comment->create_post_comments( $post_id, 12 ); |
| 14 | self::factory()->comment->create_post_comments( $post_id, 12 ); |
15 | 15 | |
16 | 16 | $this->assertEquals( 12, get_comments_number( $post_id ) ); |
17 | 17 | $this->assertEquals( 12, get_comments_number( get_post( $post_id ) ) ); |
18 | 18 | } |
19 | 19 | |
20 | 20 | function test_get_comments_number_without_arg() { |
21 | | $post_id = self::$factory->post->create(); |
| 21 | $post_id = self::factory()->post->create(); |
22 | 22 | $permalink = get_permalink( $post_id ); |
23 | 23 | $this->go_to( $permalink ); |
24 | 24 | |
25 | 25 | $this->assertEquals( 0, get_comments_number() ); |
26 | 26 | |
27 | | self::$factory->comment->create_post_comments( $post_id, 12 ); |
| 27 | self::factory()->comment->create_post_comments( $post_id, 12 ); |
28 | 28 | $this->go_to( $permalink ); |
29 | 29 | |
30 | 30 | $this->assertEquals( 12, get_comments_number() ); |
-
diff --git tests/phpunit/tests/comment/walker.php tests/phpunit/tests/comment/walker.php
index 8dd2607..fcd4f69 100644
|
|
class Tests_Comment_Walker extends WP_UnitTestCase { |
8 | 8 | function setUp() { |
9 | 9 | parent::setUp(); |
10 | 10 | |
11 | | $this->post_id = self::$factory->post->create(); |
| 11 | $this->post_id = self::factory()->post->create(); |
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @ticket 14041 |
16 | 16 | */ |
17 | 17 | function test_has_children() { |
18 | | $comment_parent = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); |
19 | | $comment_child = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_parent' => $comment_parent ) ); |
| 18 | $comment_parent = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) ); |
| 19 | $comment_child = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_parent' => $comment_parent ) ); |
20 | 20 | $comment_parent = get_comment( $comment_parent ); |
21 | 21 | $comment_child = get_comment( $comment_child ); |
22 | 22 | |
-
diff --git tests/phpunit/tests/comment/wpCountComments.php tests/phpunit/tests/comment/wpCountComments.php
index b618fbe..4165d36 100644
|
|
class Tests_WP_Count_Comments extends WP_UnitTestCase { |
15 | 15 | } |
16 | 16 | |
17 | 17 | public function test_wp_count_comments_approved() { |
18 | | self::$factory->comment->create( array( |
| 18 | self::factory()->comment->create( array( |
19 | 19 | 'comment_approved' => 1 |
20 | 20 | ) ); |
21 | 21 | |
… |
… |
class Tests_WP_Count_Comments extends WP_UnitTestCase { |
31 | 31 | } |
32 | 32 | |
33 | 33 | public function test_wp_count_comments_awaiting() { |
34 | | self::$factory->comment->create( array( |
| 34 | self::factory()->comment->create( array( |
35 | 35 | 'comment_approved' => 0 |
36 | 36 | ) ); |
37 | 37 | |
… |
… |
class Tests_WP_Count_Comments extends WP_UnitTestCase { |
47 | 47 | } |
48 | 48 | |
49 | 49 | public function test_wp_count_comments_spam() { |
50 | | self::$factory->comment->create( array( |
| 50 | self::factory()->comment->create( array( |
51 | 51 | 'comment_approved' => 'spam' |
52 | 52 | ) ); |
53 | 53 | |
… |
… |
class Tests_WP_Count_Comments extends WP_UnitTestCase { |
63 | 63 | } |
64 | 64 | |
65 | 65 | public function test_wp_count_comments_trash() { |
66 | | self::$factory->comment->create( array( |
| 66 | self::factory()->comment->create( array( |
67 | 67 | 'comment_approved' => 'trash' |
68 | 68 | ) ); |
69 | 69 | |
… |
… |
class Tests_WP_Count_Comments extends WP_UnitTestCase { |
79 | 79 | } |
80 | 80 | |
81 | 81 | public function test_wp_count_comments_post_trashed() { |
82 | | self::$factory->comment->create( array( |
| 82 | self::factory()->comment->create( array( |
83 | 83 | 'comment_approved' => 'post-trashed' |
84 | 84 | ) ); |
85 | 85 | |
… |
… |
class Tests_WP_Count_Comments extends WP_UnitTestCase { |
95 | 95 | } |
96 | 96 | |
97 | 97 | public function test_wp_count_comments_cache() { |
98 | | $post_id = self::$factory->post->create( array( |
| 98 | $post_id = self::factory()->post->create( array( |
99 | 99 | 'post_status' => 'publish' |
100 | 100 | ) ); |
101 | | $comment_id = self::$factory->comment->create( array( |
| 101 | $comment_id = self::factory()->comment->create( array( |
102 | 102 | 'comment_approved' => '1', |
103 | 103 | 'comment_post_ID' => $post_id |
104 | 104 | ) ); |
-
diff --git tests/phpunit/tests/customize/manager.php tests/phpunit/tests/customize/manager.php
index ec9e2b0..b9e7f31 100644
|
|
class Tests_WP_Customize_Manager extends WP_UnitTestCase { |
251 | 251 | * @see WP_Customize_Manager::set_return_url() |
252 | 252 | */ |
253 | 253 | function test_return_url() { |
254 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'author' ) ) ); |
| 254 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'author' ) ) ); |
255 | 255 | $this->assertEquals( get_admin_url(), $this->manager->get_return_url() ); |
256 | 256 | |
257 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 257 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
258 | 258 | $this->assertTrue( current_user_can( 'edit_theme_options' ) ); |
259 | 259 | $this->assertEquals( admin_url( 'themes.php' ), $this->manager->get_return_url() ); |
260 | 260 | |
… |
… |
class Tests_WP_Customize_Manager extends WP_UnitTestCase { |
301 | 301 | * @see WP_Customize_Manager::customize_pane_settings() |
302 | 302 | */ |
303 | 303 | function test_customize_pane_settings() { |
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 | $this->manager->register_controls(); |
306 | 306 | $this->manager->prepare_controls(); |
307 | 307 | $autofocus = array( 'control' => 'blogname' ); |
-
diff --git tests/phpunit/tests/customize/nav-menu-item-setting.php tests/phpunit/tests/customize/nav-menu-item-setting.php
index fab713e..ad2e7d2 100644
|
|
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
21 | 21 | function setUp() { |
22 | 22 | parent::setUp(); |
23 | 23 | require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; |
24 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 24 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
25 | 25 | |
26 | 26 | global $wp_customize; |
27 | 27 | $this->wp_customize = new WP_Customize_Manager(); |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
149 | 149 | function test_value_type_post_type() { |
150 | 150 | do_action( 'customize_register', $this->wp_customize ); |
151 | 151 | |
152 | | $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); |
| 152 | $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); |
153 | 153 | |
154 | 154 | $menu_id = wp_create_nav_menu( 'Menu' ); |
155 | 155 | $item_title = 'Greetings'; |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
192 | 192 | function test_value_type_taxonomy() { |
193 | 193 | do_action( 'customize_register', $this->wp_customize ); |
194 | 194 | |
195 | | $tax_id = self::$factory->category->create( array( 'name' => 'Salutations' ) ); |
| 195 | $tax_id = self::factory()->category->create( array( 'name' => 'Salutations' ) ); |
196 | 196 | |
197 | 197 | $menu_id = wp_create_nav_menu( 'Menu' ); |
198 | 198 | $item_title = 'Greetings'; |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
270 | 270 | $value = $menu->value(); |
271 | 271 | $this->assertEquals( $post_value, $value ); |
272 | 272 | |
273 | | $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); |
| 273 | $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); |
274 | 274 | $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
275 | 275 | 'menu-item-type' => 'post_type', |
276 | 276 | 'menu-item-object' => 'post', |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
296 | 296 | function test_preview_updated() { |
297 | 297 | do_action( 'customize_register', $this->wp_customize ); |
298 | 298 | |
299 | | $first_post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); |
300 | | $second_post_id = self::$factory->post->create( array( 'post_title' => 'Hola Muno' ) ); |
| 299 | $first_post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); |
| 300 | $second_post_id = self::factory()->post->create( array( 'post_title' => 'Hola Muno' ) ); |
301 | 301 | |
302 | 302 | $primary_menu_id = wp_create_nav_menu( 'Primary' ); |
303 | 303 | $secondary_menu_id = wp_create_nav_menu( 'Secondary' ); |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
348 | 348 | do_action( 'customize_register', $this->wp_customize ); |
349 | 349 | |
350 | 350 | $menu_id = wp_create_nav_menu( 'Primary' ); |
351 | | $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); |
| 351 | $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); |
352 | 352 | $item_ids = array(); |
353 | 353 | for ( $i = 0; $i < 5; $i += 1 ) { |
354 | 354 | $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
403 | 403 | do_action( 'customize_register', $this->wp_customize ); |
404 | 404 | |
405 | 405 | $menu_id = wp_create_nav_menu( 'Primary' ); |
406 | | $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); |
| 406 | $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); |
407 | 407 | $item_ids = array(); |
408 | 408 | for ( $i = 0; $i < 5; $i += 1 ) { |
409 | 409 | $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
488 | 488 | function test_save_updated() { |
489 | 489 | do_action( 'customize_register', $this->wp_customize ); |
490 | 490 | |
491 | | $first_post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); |
492 | | $second_post_id = self::$factory->post->create( array( 'post_title' => 'Hola Muno' ) ); |
| 491 | $first_post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); |
| 492 | $second_post_id = self::factory()->post->create( array( 'post_title' => 'Hola Muno' ) ); |
493 | 493 | |
494 | 494 | $primary_menu_id = wp_create_nav_menu( 'Primary' ); |
495 | 495 | $secondary_menu_id = wp_create_nav_menu( 'Secondary' ); |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
554 | 554 | do_action( 'customize_register', $this->wp_customize ); |
555 | 555 | |
556 | 556 | $menu_id = wp_create_nav_menu( 'Primary' ); |
557 | | $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); |
| 557 | $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); |
558 | 558 | $item_ids = array(); |
559 | 559 | for ( $i = 0; $i < 5; $i += 1 ) { |
560 | 560 | $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
… |
… |
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { |
623 | 623 | do_action( 'customize_register', $this->wp_customize ); |
624 | 624 | |
625 | 625 | $menu_id = wp_create_nav_menu( 'Primary' ); |
626 | | $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); |
| 626 | $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); |
627 | 627 | $item_ids = array(); |
628 | 628 | for ( $i = 0; $i < 5; $i += 1 ) { |
629 | 629 | $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
-
diff --git tests/phpunit/tests/customize/nav-menu-setting.php tests/phpunit/tests/customize/nav-menu-setting.php
index 7f4616c..a3438c9 100644
|
|
class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { |
22 | 22 | 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 | |
27 | 27 | global $wp_customize; |
28 | 28 | $this->wp_customize = new WP_Customize_Manager(); |
-
diff --git tests/phpunit/tests/customize/nav-menus.php tests/phpunit/tests/customize/nav-menus.php
index 5add129..dd620c3 100644
|
|
class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { |
22 | 22 | 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 Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { |
124 | 124 | ); |
125 | 125 | |
126 | 126 | // Create pages. |
127 | | self::$factory->post->create_many( 12, array( 'post_type' => 'page' ) ); |
| 127 | self::factory()->post->create_many( 12, array( 'post_type' => 'page' ) ); |
128 | 128 | |
129 | 129 | // Home is included in menu items when page is zero. |
130 | 130 | $items = $menus->load_available_items_query( 'post_type', 'page', 0 ); |
… |
… |
class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { |
145 | 145 | $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
146 | 146 | |
147 | 147 | // Create page. |
148 | | $post_id = self::$factory->post->create( array( 'post_title' => 'Post Title' ) ); |
| 148 | $post_id = self::factory()->post->create( array( 'post_title' => 'Post Title' ) ); |
149 | 149 | |
150 | 150 | // Create pages. |
151 | | self::$factory->post->create_many( 10 ); |
| 151 | self::factory()->post->create_many( 10 ); |
152 | 152 | |
153 | 153 | // Expected menu item array. |
154 | 154 | $expected = array( |
… |
… |
class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { |
175 | 175 | $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
176 | 176 | |
177 | 177 | // Create page. |
178 | | $page_id = self::$factory->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) ); |
| 178 | $page_id = self::factory()->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) ); |
179 | 179 | |
180 | 180 | // Expected menu item array. |
181 | 181 | $expected = array( |
… |
… |
class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { |
201 | 201 | $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
202 | 202 | |
203 | 203 | // Create post. |
204 | | $post_id = self::$factory->post->create( array( 'post_title' => 'Post Title' ) ); |
| 204 | $post_id = self::factory()->post->create( array( 'post_title' => 'Post Title' ) ); |
205 | 205 | |
206 | 206 | // Expected menu item array. |
207 | 207 | $expected = array( |
… |
… |
class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { |
227 | 227 | $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
228 | 228 | |
229 | 229 | // Create term. |
230 | | $term_id = self::$factory->category->create( array( 'name' => 'Term Title' ) ); |
| 230 | $term_id = self::factory()->category->create( array( 'name' => 'Term Title' ) ); |
231 | 231 | |
232 | 232 | // Expected menu item array. |
233 | 233 | $expected = array( |
… |
… |
class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { |
279 | 279 | |
280 | 280 | // Create posts |
281 | 281 | $post_ids = array(); |
282 | | $post_ids[] = self::$factory->post->create( array( 'post_title' => 'Search & Test' ) ); |
283 | | $post_ids[] = self::$factory->post->create( array( 'post_title' => 'Some Other Title' ) ); |
| 282 | $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Search & Test' ) ); |
| 283 | $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Some Other Title' ) ); |
284 | 284 | |
285 | 285 | // Create terms |
286 | 286 | $term_ids = array(); |
287 | | $term_ids[] = self::$factory->category->create( array( 'name' => 'Dogs Are Cool' ) ); |
288 | | $term_ids[] = self::$factory->category->create( array( 'name' => 'Cats Drool' ) ); |
| 287 | $term_ids[] = self::factory()->category->create( array( 'name' => 'Dogs Are Cool' ) ); |
| 288 | $term_ids[] = self::factory()->category->create( array( 'name' => 'Cats Drool' ) ); |
289 | 289 | |
290 | 290 | // Test empty results |
291 | 291 | $expected = array(); |
… |
… |
class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { |
386 | 386 | function test_customize_register() { |
387 | 387 | do_action( 'customize_register', $this->wp_customize ); |
388 | 388 | $menu_id = wp_create_nav_menu( 'Primary' ); |
389 | | $post_id = self::$factory->post->create( array( 'post_title' => 'Hello World' ) ); |
| 389 | $post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) ); |
390 | 390 | $item_id = wp_update_nav_menu_item( $menu_id, 0, array( |
391 | 391 | 'menu-item-type' => 'post_type', |
392 | 392 | 'menu-item-object' => 'post', |
-
diff --git tests/phpunit/tests/customize/panel.php tests/phpunit/tests/customize/panel.php
index f1b62cb..13359a1 100644
|
|
class Tests_WP_Customize_Panel extends WP_UnitTestCase { |
128 | 128 | * @see WP_Customize_Panel::check_capabilities() |
129 | 129 | */ |
130 | 130 | function test_check_capabilities() { |
131 | | $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 131 | $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
132 | 132 | wp_set_current_user( $user_id ); |
133 | 133 | |
134 | 134 | $panel = new WP_Customize_Panel( $this->manager, 'foo' ); |
… |
… |
class Tests_WP_Customize_Panel extends WP_UnitTestCase { |
154 | 154 | * @see WP_Customize_Panel::maybe_render() |
155 | 155 | */ |
156 | 156 | function test_maybe_render() { |
157 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 157 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
158 | 158 | $panel = new WP_Customize_Panel( $this->manager, 'bar' ); |
159 | 159 | $customize_render_panel_count = did_action( 'customize_render_panel' ); |
160 | 160 | add_action( 'customize_render_panel', array( $this, 'action_customize_render_panel_test' ) ); |
… |
… |
class Tests_WP_Customize_Panel extends WP_UnitTestCase { |
179 | 179 | * @see WP_Customize_Panel::print_template() |
180 | 180 | */ |
181 | 181 | function test_print_templates_standard() { |
182 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 182 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
183 | 183 | |
184 | 184 | $panel = new WP_Customize_Panel( $this->manager, 'baz' ); |
185 | 185 | ob_start(); |
… |
… |
class Tests_WP_Customize_Panel extends WP_UnitTestCase { |
197 | 197 | * @see WP_Customize_Panel::print_template() |
198 | 198 | */ |
199 | 199 | function test_print_templates_custom() { |
200 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 200 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
201 | 201 | |
202 | 202 | $panel = new Custom_Panel_Test( $this->manager, 'baz' ); |
203 | 203 | ob_start(); |
-
diff --git tests/phpunit/tests/customize/section.php tests/phpunit/tests/customize/section.php
index 2ed81b6..dad67ed 100644
|
|
class Tests_WP_Customize_Section extends WP_UnitTestCase { |
135 | 135 | * @see WP_Customize_Section::check_capabilities() |
136 | 136 | */ |
137 | 137 | function test_check_capabilities() { |
138 | | $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 138 | $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
139 | 139 | wp_set_current_user( $user_id ); |
140 | 140 | |
141 | 141 | $section = new WP_Customize_Section( $this->manager, 'foo' ); |
… |
… |
class Tests_WP_Customize_Section extends WP_UnitTestCase { |
161 | 161 | * @see WP_Customize_Section::maybe_render() |
162 | 162 | */ |
163 | 163 | function test_maybe_render() { |
164 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 164 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
165 | 165 | $section = new WP_Customize_Section( $this->manager, 'bar' ); |
166 | 166 | $customize_render_section_count = did_action( 'customize_render_section' ); |
167 | 167 | add_action( 'customize_render_section', array( $this, 'action_customize_render_section_test' ) ); |
… |
… |
class Tests_WP_Customize_Section extends WP_UnitTestCase { |
186 | 186 | * @see WP_Customize_Section::print_template() |
187 | 187 | */ |
188 | 188 | function test_print_templates_standard() { |
189 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 189 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
190 | 190 | |
191 | 191 | $section = new WP_Customize_Section( $this->manager, 'baz' ); |
192 | 192 | ob_start(); |
… |
… |
class Tests_WP_Customize_Section extends WP_UnitTestCase { |
201 | 201 | * @see WP_Customize_Section::print_template() |
202 | 202 | */ |
203 | 203 | function test_print_templates_custom() { |
204 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 204 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
205 | 205 | |
206 | 206 | $section = new Custom_Section_Test( $this->manager, 'baz' ); |
207 | 207 | ob_start(); |
-
diff --git tests/phpunit/tests/customize/setting.php tests/phpunit/tests/customize/setting.php
index 803f090..296554b 100644
|
|
class Tests_WP_Customize_Setting extends WP_UnitTestCase { |
394 | 394 | $this->assertTrue( 0 === did_action( 'customize_save_foo' ) ); |
395 | 395 | |
396 | 396 | // Satisfy all requirements for save to happen. |
397 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 397 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
398 | 398 | $this->assertTrue( false !== $setting->save() ); |
399 | 399 | $this->assertTrue( 1 === did_action( 'customize_update_custom' ) ); |
400 | 400 | $this->assertTrue( 1 === did_action( 'customize_save_foo' ) ); |
… |
… |
class Tests_WP_Customize_Setting extends WP_UnitTestCase { |
465 | 465 | $setting->preview(); |
466 | 466 | $this->assertTrue( $setting->is_current_blog_previewed() ); |
467 | 467 | |
468 | | $blog_id = self::$factory->blog->create(); |
| 468 | $blog_id = self::factory()->blog->create(); |
469 | 469 | switch_to_blog( $blog_id ); |
470 | 470 | $this->assertFalse( $setting->is_current_blog_previewed() ); |
471 | 471 | $this->assertNotEquals( $post_value, $setting->value() ); |
-
diff --git tests/phpunit/tests/customize/widgets.php tests/phpunit/tests/customize/widgets.php
index 6dd47d0..6584341 100644
|
|
class Tests_WP_Customize_Widgets extends WP_UnitTestCase { |
38 | 38 | |
39 | 39 | remove_action( 'after_setup_theme', 'twentyfifteen_setup' ); // @todo We should not be including a theme anyway |
40 | 40 | |
41 | | $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 41 | $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
42 | 42 | wp_set_current_user( $user_id ); |
43 | 43 | |
44 | 44 | $this->backup_registered_sidebars = $GLOBALS['wp_registered_sidebars']; |
-
diff --git tests/phpunit/tests/date/query.php tests/phpunit/tests/date/query.php
index 7ce8165..cc848be 100644
|
|
class Tests_WP_Date_Query extends WP_UnitTestCase { |
975 | 975 | * @ticket 31001 |
976 | 976 | */ |
977 | 977 | public function test_validate_date_values_should_process_array_value_for_year() { |
978 | | $p1 = self::$factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) ); |
979 | | $p2 = self::$factory->post->create( array( 'post_date' => '2013-01-12 00:00:00' ) ); |
| 978 | $p1 = self::factory()->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) ); |
| 979 | $p2 = self::factory()->post->create( array( 'post_date' => '2013-01-12 00:00:00' ) ); |
980 | 980 | |
981 | 981 | $q = new WP_Query( array( |
982 | 982 | 'date_query' => array( |
… |
… |
class Tests_WP_Date_Query extends WP_UnitTestCase { |
995 | 995 | * @ticket 31001 |
996 | 996 | */ |
997 | 997 | public function test_validate_date_values_should_process_array_value_for_day() { |
998 | | $p1 = self::$factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) ); |
999 | | $p2 = self::$factory->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) ); |
| 998 | $p1 = self::factory()->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) ); |
| 999 | $p2 = self::factory()->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) ); |
1000 | 1000 | |
1001 | 1001 | $q = new WP_Query( array( |
1002 | 1002 | 'date_query' => array( |
… |
… |
class Tests_WP_Date_Query extends WP_UnitTestCase { |
1016 | 1016 | * @expectedIncorrectUsage WP_Date_Query |
1017 | 1017 | */ |
1018 | 1018 | public function test_validate_date_values_should_process_array_value_for_day_when_values_are_invalid() { |
1019 | | $p1 = self::$factory->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) ); |
1020 | | $p2 = self::$factory->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) ); |
| 1019 | $p1 = self::factory()->post->create( array( 'post_date' => '2015-01-12 00:00:00' ) ); |
| 1020 | $p2 = self::factory()->post->create( array( 'post_date' => '2015-01-10 00:00:00' ) ); |
1021 | 1021 | |
1022 | 1022 | $q = new WP_Query( array( |
1023 | 1023 | 'date_query' => array( |
-
diff --git tests/phpunit/tests/db.php tests/phpunit/tests/db.php
index fd3517d..74036a2 100644
|
|
class Tests_DB extends WP_UnitTestCase { |
509 | 509 | $this->markTestSkipped( 'procedure could not be created (missing privileges?)' ); |
510 | 510 | } |
511 | 511 | |
512 | | $post_id = self::$factory->post->create(); |
| 512 | $post_id = self::factory()->post->create(); |
513 | 513 | |
514 | 514 | $this->assertNotEmpty( $wpdb->get_results( 'CALL `test_mysqli_flush_sync_procedure`' ) ); |
515 | 515 | $this->assertNotEmpty( $wpdb->get_results( "SELECT ID FROM `{$wpdb->posts}` LIMIT 1" ) ); |
-
diff --git tests/phpunit/tests/formatting/SanitizePost.php tests/phpunit/tests/formatting/SanitizePost.php
index 691c082..c741214 100644
|
|
class Tests_Formatting_SanitizePost extends WP_UnitTestCase { |
9 | 9 | * @ticket 22324 |
10 | 10 | */ |
11 | 11 | function test_int_fields() { |
12 | | $post = self::$factory->post->create_and_get(); |
| 12 | $post = self::factory()->post->create_and_get(); |
13 | 13 | $int_fields = array( |
14 | 14 | 'ID' => 'integer', |
15 | 15 | 'post_parent' => 'integer', |
-
diff --git tests/phpunit/tests/formatting/WpTrimExcerpt.php tests/phpunit/tests/formatting/WpTrimExcerpt.php
index 8aafa8e..da508c7 100644
|
|
class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase { |
9 | 9 | * @ticket 25349 |
10 | 10 | */ |
11 | 11 | public function test_secondary_loop_respect_more() { |
12 | | $post1 = self::$factory->post->create( array( |
| 12 | $post1 = self::factory()->post->create( array( |
13 | 13 | 'post_content' => 'Post 1 Page 1<!--more-->Post 1 Page 2', |
14 | 14 | ) ); |
15 | | $post2 = self::$factory->post->create( array( |
| 15 | $post2 = self::factory()->post->create( array( |
16 | 16 | 'post_content' => 'Post 2 Page 1<!--more-->Post 2 Page 2', |
17 | 17 | ) ); |
18 | 18 | |
… |
… |
class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase { |
34 | 34 | * @ticket 25349 |
35 | 35 | */ |
36 | 36 | public function test_secondary_loop_respect_nextpage() { |
37 | | $post1 = self::$factory->post->create( array( |
| 37 | $post1 = self::factory()->post->create( array( |
38 | 38 | 'post_content' => 'Post 1 Page 1<!--nextpage-->Post 1 Page 2', |
39 | 39 | ) ); |
40 | | $post2 = self::$factory->post->create( array( |
| 40 | $post2 = self::factory()->post->create( array( |
41 | 41 | 'post_content' => 'Post 2 Page 1<!--nextpage-->Post 2 Page 2', |
42 | 42 | ) ); |
43 | 43 | |
-
diff --git tests/phpunit/tests/functions.php tests/phpunit/tests/functions.php
index d44f470..1119770 100644
|
|
class Tests_Functions extends WP_UnitTestCase { |
689 | 689 | $actual = ob_get_clean(); |
690 | 690 | $this->assertEquals( '', $actual ); |
691 | 691 | |
692 | | $GLOBALS['post'] = self::$factory->post->create_and_get( array( |
| 692 | $GLOBALS['post'] = self::factory()->post->create_and_get( array( |
693 | 693 | 'post_date' => '2015-09-16 08:00:00' |
694 | 694 | ) ); |
695 | 695 | |
-
diff --git tests/phpunit/tests/functions/getArchives.php tests/phpunit/tests/functions/getArchives.php
index 393808d..2d70387 100644
|
|
EOF; |
87 | 87 | } |
88 | 88 | |
89 | 89 | function test_wp_get_archives_order() { |
90 | | self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => '1', 'post_date' => '2012-10-23 19:34:42' ) ); |
| 90 | self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => '1', 'post_date' => '2012-10-23 19:34:42' ) ); |
91 | 91 | |
92 | 92 | $date_full = date( 'F Y' ); |
93 | 93 | $oct_url = get_month_link( 2012, 10 ); |
… |
… |
EOF; |
110 | 110 | function test_wp_get_archives_post_type() { |
111 | 111 | register_post_type( 'taco', array( 'public' => true ) ); |
112 | 112 | |
113 | | self::$factory->post->create( array( |
| 113 | self::factory()->post->create( array( |
114 | 114 | 'post_type' => 'taco', |
115 | 115 | 'post_author' => '1', |
116 | 116 | 'post_date' => '2014-10-23 19:34:42' |
-
diff --git tests/phpunit/tests/general/archives.php tests/phpunit/tests/general/archives.php
index e34e6c1..3e10f2a 100644
|
|
class Tests_General_Archives extends WP_UnitTestCase { |
16 | 16 | function test_get_archives_cache() { |
17 | 17 | global $wpdb; |
18 | 18 | |
19 | | self::$factory->post->create_many( 3, array( 'post_type' => 'post' ) ); |
| 19 | self::factory()->post->create_many( 3, array( 'post_type' => 'post' ) ); |
20 | 20 | wp_cache_delete( 'last_changed', 'posts' ); |
21 | 21 | $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) ); |
22 | 22 | |
-
diff --git tests/phpunit/tests/includes/factory.php tests/phpunit/tests/includes/factory.php
index e7c6929..3eef943 100644
|
|
class TestFactoryFor extends WP_UnitTestCase { |
34 | 34 | */ |
35 | 35 | public function test_term_factory_create_and_get_should_return_term_object() { |
36 | 36 | register_taxonomy( 'wptests_tax', 'post' ); |
37 | | $term = self::$factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) ); |
| 37 | $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) ); |
38 | 38 | $this->assertInternalType( 'object', $term ); |
39 | 39 | $this->assertNotEmpty( $term->term_id ); |
40 | 40 | } |
-
diff --git tests/phpunit/tests/link.php tests/phpunit/tests/link.php
index 08275d1..272b4cd 100644
|
|
class Tests_Link extends WP_UnitTestCase { |
33 | 33 | } |
34 | 34 | |
35 | 35 | function test_wp_get_shortlink() { |
36 | | $post_id = self::$factory->post->create(); |
37 | | $post_id2 = self::$factory->post->create(); |
| 36 | $post_id = self::factory()->post->create(); |
| 37 | $post_id2 = self::factory()->post->create(); |
38 | 38 | |
39 | 39 | // Basic case |
40 | 40 | $this->assertEquals( get_permalink( $post_id ), wp_get_shortlink( $post_id, 'post' ) ); |
… |
… |
class Tests_Link extends WP_UnitTestCase { |
77 | 77 | } |
78 | 78 | |
79 | 79 | function test_wp_get_shortlink_with_page() { |
80 | | $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 80 | $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
81 | 81 | |
82 | 82 | // Basic case |
83 | 83 | // Don't test against get_permalink() since it uses ?page_id= for pages. |
… |
… |
class Tests_Link extends WP_UnitTestCase { |
92 | 92 | * @ticket 26871 |
93 | 93 | */ |
94 | 94 | function test_wp_get_shortlink_with_home_page() { |
95 | | $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 95 | $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
96 | 96 | update_option( 'show_on_front', 'page' ); |
97 | 97 | update_option( 'page_on_front', $post_id ); |
98 | 98 | |
… |
… |
class Tests_Link extends WP_UnitTestCase { |
108 | 108 | */ |
109 | 109 | function test_get_adjacent_post() { |
110 | 110 | // Need some sample posts to test adjacency |
111 | | $post_one = self::$factory->post->create_and_get( array( |
| 111 | $post_one = self::factory()->post->create_and_get( array( |
112 | 112 | 'post_title' => 'First', |
113 | 113 | 'post_date' => '2012-01-01 12:00:00' |
114 | 114 | ) ); |
115 | 115 | |
116 | | $post_two = self::$factory->post->create_and_get( array( |
| 116 | $post_two = self::factory()->post->create_and_get( array( |
117 | 117 | 'post_title' => 'Second', |
118 | 118 | 'post_date' => '2012-02-01 12:00:00' |
119 | 119 | ) ); |
120 | 120 | |
121 | | $post_three = self::$factory->post->create_and_get( array( |
| 121 | $post_three = self::factory()->post->create_and_get( array( |
122 | 122 | 'post_title' => 'Third', |
123 | 123 | 'post_date' => '2012-03-01 12:00:00' |
124 | 124 | ) ); |
125 | 125 | |
126 | | $post_four = self::$factory->post->create_and_get( array( |
| 126 | $post_four = self::factory()->post->create_and_get( array( |
127 | 127 | 'post_title' => 'Fourth', |
128 | 128 | 'post_date' => '2012-04-01 12:00:00' |
129 | 129 | ) ); |
… |
… |
class Tests_Link extends WP_UnitTestCase { |
183 | 183 | global $wpdb; |
184 | 184 | $wpdb->insert( $wpdb->term_taxonomy, array( 'taxonomy' => 'foo', 'term_id' => 12345, 'description' => '' ) ); |
185 | 185 | |
186 | | $include = self::$factory->term->create( array( |
| 186 | $include = self::factory()->term->create( array( |
187 | 187 | 'taxonomy' => 'category', |
188 | 188 | 'name' => 'Include', |
189 | 189 | ) ); |
190 | | $exclude = self::$factory->category->create(); |
| 190 | $exclude = self::factory()->category->create(); |
191 | 191 | |
192 | | $one = self::$factory->post->create_and_get( array( |
| 192 | $one = self::factory()->post->create_and_get( array( |
193 | 193 | 'post_date' => '2012-01-01 12:00:00', |
194 | 194 | 'post_category' => array( $include, $exclude ), |
195 | 195 | ) ); |
196 | 196 | |
197 | | $two = self::$factory->post->create_and_get( array( |
| 197 | $two = self::factory()->post->create_and_get( array( |
198 | 198 | 'post_date' => '2012-01-02 12:00:00', |
199 | 199 | 'post_category' => array(), |
200 | 200 | ) ); |
201 | 201 | |
202 | | $three = self::$factory->post->create_and_get( array( |
| 202 | $three = self::factory()->post->create_and_get( array( |
203 | 203 | 'post_date' => '2012-01-03 12:00:00', |
204 | 204 | 'post_category' => array( $include, $exclude ), |
205 | 205 | ) ); |
206 | 206 | |
207 | | $four = self::$factory->post->create_and_get( array( |
| 207 | $four = self::factory()->post->create_and_get( array( |
208 | 208 | 'post_date' => '2012-01-04 12:00:00', |
209 | 209 | 'post_category' => array( $include ), |
210 | 210 | ) ); |
211 | 211 | |
212 | | $five = self::$factory->post->create_and_get( array( |
| 212 | $five = self::factory()->post->create_and_get( array( |
213 | 213 | 'post_date' => '2012-01-05 12:00:00', |
214 | 214 | 'post_category' => array( $include, $exclude ), |
215 | 215 | ) ); |
… |
… |
class Tests_Link extends WP_UnitTestCase { |
249 | 249 | public function test_get_adjacent_post_excluded_terms() { |
250 | 250 | register_taxonomy( 'wptests_tax', 'post' ); |
251 | 251 | |
252 | | $t = self::$factory->term->create( array( |
| 252 | $t = self::factory()->term->create( array( |
253 | 253 | 'taxonomy' => 'wptests_tax', |
254 | 254 | ) ); |
255 | 255 | |
256 | | $p1 = self::$factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) ); |
257 | | $p2 = self::$factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) ); |
258 | | $p3 = self::$factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) ); |
| 256 | $p1 = self::factory()->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) ); |
| 257 | $p2 = self::factory()->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) ); |
| 258 | $p3 = self::factory()->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) ); |
259 | 259 | |
260 | 260 | wp_set_post_terms( $p2, array( $t ), 'wptests_tax' ); |
261 | 261 | |
… |
… |
class Tests_Link extends WP_UnitTestCase { |
281 | 281 | public function test_get_adjacent_post_excluded_terms_should_not_require_posts_to_have_terms_in_any_taxonomy() { |
282 | 282 | register_taxonomy( 'wptests_tax', 'post' ); |
283 | 283 | |
284 | | $t = self::$factory->term->create( array( |
| 284 | $t = self::factory()->term->create( array( |
285 | 285 | 'taxonomy' => 'wptests_tax', |
286 | 286 | ) ); |
287 | 287 | |
288 | | $p1 = self::$factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) ); |
289 | | $p2 = self::$factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) ); |
290 | | $p3 = self::$factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) ); |
| 288 | $p1 = self::factory()->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) ); |
| 289 | $p2 = self::factory()->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) ); |
| 290 | $p3 = self::factory()->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) ); |
291 | 291 | |
292 | 292 | wp_set_post_terms( $p2, array( $t ), 'wptests_tax' ); |
293 | 293 | |
… |
… |
class Tests_Link extends WP_UnitTestCase { |
348 | 348 | |
349 | 349 | flush_rewrite_rules(); |
350 | 350 | |
351 | | $p = self::$factory->post->create( array( |
| 351 | $p = self::factory()->post->create( array( |
352 | 352 | 'post_status' => 'publish', |
353 | 353 | 'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ) |
354 | 354 | ) ); |
… |
… |
class Tests_Link extends WP_UnitTestCase { |
368 | 368 | |
369 | 369 | flush_rewrite_rules(); |
370 | 370 | |
371 | | $p = self::$factory->post->create( array( |
| 371 | $p = self::factory()->post->create( array( |
372 | 372 | 'post_status' => 'future', |
373 | 373 | 'post_type' => 'wptests_pt', |
374 | 374 | 'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ) |
… |
… |
class Tests_Link extends WP_UnitTestCase { |
388 | 388 | public function test_unattached_attachment_has_a_pretty_permalink() { |
389 | 389 | $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); |
390 | 390 | |
391 | | $attachment_id = self::$factory->attachment->create_object( 'image.jpg', 0, array( |
| 391 | $attachment_id = self::factory()->attachment->create_object( 'image.jpg', 0, array( |
392 | 392 | 'post_mime_type' => 'image/jpeg', |
393 | 393 | 'post_type' => 'attachment', |
394 | 394 | 'post_title' => 'An Attachment!', |
… |
… |
class Tests_Link extends WP_UnitTestCase { |
412 | 412 | |
413 | 413 | flush_rewrite_rules(); |
414 | 414 | |
415 | | $post_id = self::$factory->post->create( array( 'post_type' => 'not_a_post_type' ) ); |
| 415 | $post_id = self::factory()->post->create( array( 'post_type' => 'not_a_post_type' ) ); |
416 | 416 | |
417 | | $attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array( |
| 417 | $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array( |
418 | 418 | 'post_mime_type' => 'image/jpeg', |
419 | 419 | 'post_type' => 'attachment', |
420 | 420 | 'post_title' => 'An Attachment!', |
-
diff --git tests/phpunit/tests/link/getAdjacentPostLink.php tests/phpunit/tests/link/getAdjacentPostLink.php
index 08064e1..68c511d 100644
|
|
class Tests_Link_GetAdjacentPostLink extends WP_UnitTestCase { |
10 | 10 | |
11 | 11 | public function setUp(){ |
12 | 12 | parent::setUp(); |
13 | | $this->cat_id = self::$factory->category->create( array( 'name' => 'other' ) ); |
| 13 | $this->cat_id = self::factory()->category->create( array( 'name' => 'other' ) ); |
14 | 14 | $this->post_ids = array(); |
15 | | $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 05:32:29', 'category_id' => 1 ) ); |
16 | | $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 04:32:29', 'category_id' => $this->cat_id ) ); |
17 | | $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 03:32:29', 'category_id' => 1 ) ); |
18 | | $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 02:32:29', 'category_id' => $this->cat_id ) ); |
19 | | $this->post_ids[] = self::$factory->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 01:32:29', 'category_id' => 1 ) ); |
| 15 | $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 05:32:29', 'category_id' => 1 ) ); |
| 16 | $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 04:32:29', 'category_id' => $this->cat_id ) ); |
| 17 | $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 03:32:29', 'category_id' => 1 ) ); |
| 18 | $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 02:32:29', 'category_id' => $this->cat_id ) ); |
| 19 | $this->post_ids[] = self::factory()->post->create( array( 'post_type' => 'post', 'post_date' => '2014-10-26 01:32:29', 'category_id' => 1 ) ); |
20 | 20 | |
21 | 21 | //set current post (has 2 on each end) |
22 | 22 | global $GLOBALS; |
-
diff --git tests/phpunit/tests/link/getNextCommentsLink.php tests/phpunit/tests/link/getNextCommentsLink.php
index 8f148db..204b205 100644
|
|
|
8 | 8 | class Tests_Link_GetNextCommentsLink extends WP_UnitTestCase { |
9 | 9 | |
10 | 10 | public function test_page_should_respect_value_of_cpage_query_var() { |
11 | | $p = self::$factory->post->create(); |
| 11 | $p = self::factory()->post->create(); |
12 | 12 | $this->go_to( get_permalink( $p ) ); |
13 | 13 | |
14 | 14 | $cpage = get_query_var( 'cpage' ); |
… |
… |
class Tests_Link_GetNextCommentsLink extends WP_UnitTestCase { |
25 | 25 | * @ticket 20319 |
26 | 26 | */ |
27 | 27 | public function test_page_should_default_to_1_when_no_cpage_query_var_is_found() { |
28 | | $p = self::$factory->post->create(); |
| 28 | $p = self::factory()->post->create(); |
29 | 29 | $this->go_to( get_permalink( $p ) ); |
30 | 30 | |
31 | 31 | $cpage = get_query_var( 'cpage' ); |
-
diff --git tests/phpunit/tests/link/getPostCommentsFeedLink.php tests/phpunit/tests/link/getPostCommentsFeedLink.php
index e3972fc..5e1eddc 100644
|
|
|
5 | 5 | class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { |
6 | 6 | |
7 | 7 | public function test_post_link() { |
8 | | $post_id = self::$factory->post->create(); |
| 8 | $post_id = self::factory()->post->create(); |
9 | 9 | |
10 | 10 | $link = get_post_comments_feed_link( $post_id ); |
11 | 11 | $expected = add_query_arg( array( |
… |
… |
class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { |
19 | 19 | public function test_post_pretty_link() { |
20 | 20 | $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); |
21 | 21 | |
22 | | $post_id = self::$factory->post->create(); |
| 22 | $post_id = self::factory()->post->create(); |
23 | 23 | |
24 | 24 | $link = get_post_comments_feed_link( $post_id ); |
25 | 25 | $expected = get_permalink( $post_id ) . 'feed/'; |
… |
… |
class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function test_attachment_link() { |
31 | | $post_id = self::$factory->post->create(); |
32 | | $attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array( |
| 31 | $post_id = self::factory()->post->create(); |
| 32 | $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array( |
33 | 33 | 'post_mime_type' => 'image/jpeg', |
34 | 34 | 'post_type' => 'attachment' |
35 | 35 | ) ); |
… |
… |
class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { |
46 | 46 | public function test_attachment_pretty_link() { |
47 | 47 | $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); |
48 | 48 | |
49 | | $post_id = self::$factory->post->create( array( |
| 49 | $post_id = self::factory()->post->create( array( |
50 | 50 | 'post_status' => 'publish' |
51 | 51 | ) ); |
52 | | $attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array( |
| 52 | $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array( |
53 | 53 | 'post_mime_type' => 'image/jpeg', |
54 | 54 | 'post_type' => 'attachment', |
55 | 55 | 'post_title' => 'Burrito' |
… |
… |
class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { |
66 | 66 | public function test_attachment_no_name_pretty_link() { |
67 | 67 | $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); |
68 | 68 | |
69 | | $post_id = self::$factory->post->create(); |
70 | | $attachment_id = self::$factory->attachment->create_object( 'image.jpg', $post_id, array( |
| 69 | $post_id = self::factory()->post->create(); |
| 70 | $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array( |
71 | 71 | 'post_mime_type' => 'image/jpeg', |
72 | 72 | 'post_type' => 'attachment' |
73 | 73 | ) ); |
… |
… |
class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { |
79 | 79 | } |
80 | 80 | |
81 | 81 | public function test_unattached_link() { |
82 | | $attachment_id = self::$factory->attachment->create_object( 'image.jpg', 0, array( |
| 82 | $attachment_id = self::factory()->attachment->create_object( 'image.jpg', 0, array( |
83 | 83 | 'post_mime_type' => 'image/jpeg', |
84 | 84 | 'post_type' => 'attachment' |
85 | 85 | ) ); |
… |
… |
class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { |
96 | 96 | public function test_unattached_pretty_link() { |
97 | 97 | $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); |
98 | 98 | |
99 | | $attachment_id = self::$factory->attachment->create_object( 'image.jpg', 0, array( |
| 99 | $attachment_id = self::factory()->attachment->create_object( 'image.jpg', 0, array( |
100 | 100 | 'post_mime_type' => 'image/jpeg', |
101 | 101 | 'post_type' => 'attachment' |
102 | 102 | ) ); |
-
diff --git tests/phpunit/tests/link/getPreviousCommentsLink.php tests/phpunit/tests/link/getPreviousCommentsLink.php
index ea9ad6c..ff4c088 100644
|
|
|
8 | 8 | class Tests_Link_GetPreviousCommentsLink extends WP_UnitTestCase { |
9 | 9 | |
10 | 10 | public function test_page_should_respect_value_of_cpage_query_var() { |
11 | | $p = self::$factory->post->create(); |
| 11 | $p = self::factory()->post->create(); |
12 | 12 | $this->go_to( get_permalink( $p ) ); |
13 | 13 | |
14 | 14 | $cpage = get_query_var( 'cpage' ); |
… |
… |
class Tests_Link_GetPreviousCommentsLink extends WP_UnitTestCase { |
22 | 22 | } |
23 | 23 | |
24 | 24 | public function test_page_should_default_to_1_when_no_cpage_query_var_is_found() { |
25 | | $p = self::$factory->post->create(); |
| 25 | $p = self::factory()->post->create(); |
26 | 26 | $this->go_to( get_permalink( $p ) ); |
27 | 27 | |
28 | 28 | $cpage = get_query_var( 'cpage' ); |
-
diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
index b68a537..24fbfd4 100644
|
|
EOF; |
236 | 236 | * @ticket 22960 |
237 | 237 | */ |
238 | 238 | function test_get_attached_images() { |
239 | | $post_id = self::$factory->post->create(); |
240 | | $attachment_id = self::$factory->attachment->create_object( $this->img_name, $post_id, array( |
| 239 | $post_id = self::factory()->post->create(); |
| 240 | $attachment_id = self::factory()->attachment->create_object( $this->img_name, $post_id, array( |
241 | 241 | 'post_mime_type' => 'image/jpeg', |
242 | 242 | 'post_type' => 'attachment' |
243 | 243 | ) ); |
… |
… |
EOF; |
253 | 253 | $ids1 = array(); |
254 | 254 | $ids1_srcs = array(); |
255 | 255 | foreach ( range( 1, 3 ) as $i ) { |
256 | | $attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array( |
| 256 | $attachment_id = self::factory()->attachment->create_object( "image$i.jpg", 0, array( |
257 | 257 | 'post_mime_type' => 'image/jpeg', |
258 | 258 | 'post_type' => 'attachment' |
259 | 259 | ) ); |
… |
… |
EOF; |
266 | 266 | $ids2 = array(); |
267 | 267 | $ids2_srcs = array(); |
268 | 268 | foreach ( range( 4, 6 ) as $i ) { |
269 | | $attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array( |
| 269 | $attachment_id = self::factory()->attachment->create_object( "image$i.jpg", 0, array( |
270 | 270 | 'post_mime_type' => 'image/jpeg', |
271 | 271 | 'post_type' => 'attachment' |
272 | 272 | ) ); |
… |
… |
EOF; |
284 | 284 | |
285 | 285 | [gallery ids="$ids2_joined"] |
286 | 286 | BLOB; |
287 | | $post_id = self::$factory->post->create( array( 'post_content' => $blob ) ); |
| 287 | $post_id = self::factory()->post->create( array( 'post_content' => $blob ) ); |
288 | 288 | $srcs = get_post_galleries_images( $post_id ); |
289 | 289 | $this->assertEquals( $srcs, array( $ids1_srcs, $ids2_srcs ) ); |
290 | 290 | } |
… |
… |
BLOB; |
296 | 296 | $ids1 = array(); |
297 | 297 | $ids1_srcs = array(); |
298 | 298 | foreach ( range( 1, 3 ) as $i ) { |
299 | | $attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array( |
| 299 | $attachment_id = self::factory()->attachment->create_object( "image$i.jpg", 0, array( |
300 | 300 | 'post_mime_type' => 'image/jpeg', |
301 | 301 | 'post_type' => 'attachment' |
302 | 302 | ) ); |
… |
… |
BLOB; |
309 | 309 | $ids2 = array(); |
310 | 310 | $ids2_srcs = array(); |
311 | 311 | foreach ( range( 4, 6 ) as $i ) { |
312 | | $attachment_id = self::$factory->attachment->create_object( "image$i.jpg", 0, array( |
| 312 | $attachment_id = self::factory()->attachment->create_object( "image$i.jpg", 0, array( |
313 | 313 | 'post_mime_type' => 'image/jpeg', |
314 | 314 | 'post_type' => 'attachment' |
315 | 315 | ) ); |
… |
… |
BLOB; |
327 | 327 | |
328 | 328 | [gallery ids="$ids2_joined"] |
329 | 329 | BLOB; |
330 | | $post_id = self::$factory->post->create( array( 'post_content' => $blob ) ); |
| 330 | $post_id = self::factory()->post->create( array( 'post_content' => $blob ) ); |
331 | 331 | $srcs = get_post_gallery_images( $post_id ); |
332 | 332 | $this->assertEquals( $srcs, $ids1_srcs ); |
333 | 333 | } |
… |
… |
VIDEO; |
505 | 505 | */ |
506 | 506 | function test_attachment_url_to_postid() { |
507 | 507 | $image_path = '2014/11/' . $this->img_name; |
508 | | $attachment_id = self::$factory->attachment->create_object( $image_path, 0, array( |
| 508 | $attachment_id = self::factory()->attachment->create_object( $image_path, 0, array( |
509 | 509 | 'post_mime_type' => 'image/jpeg', |
510 | 510 | 'post_type' => 'attachment', |
511 | 511 | ) ); |
… |
… |
VIDEO; |
516 | 516 | |
517 | 517 | function test_attachment_url_to_postid_schemes() { |
518 | 518 | $image_path = '2014/11/' . $this->img_name; |
519 | | $attachment_id = self::$factory->attachment->create_object( $image_path, 0, array( |
| 519 | $attachment_id = self::factory()->attachment->create_object( $image_path, 0, array( |
520 | 520 | 'post_mime_type' => 'image/jpeg', |
521 | 521 | 'post_type' => 'attachment', |
522 | 522 | ) ); |
… |
… |
VIDEO; |
530 | 530 | |
531 | 531 | function test_attachment_url_to_postid_filtered() { |
532 | 532 | $image_path = '2014/11/' . $this->img_name; |
533 | | $attachment_id = self::$factory->attachment->create_object( $image_path, 0, array( |
| 533 | $attachment_id = self::factory()->attachment->create_object( $image_path, 0, array( |
534 | 534 | 'post_mime_type' => 'image/jpeg', |
535 | 535 | 'post_type' => 'attachment', |
536 | 536 | ) ); |
… |
… |
EOF; |
704 | 704 | function test_wp_get_attachment_image_url() { |
705 | 705 | $this->assertFalse( wp_get_attachment_image_url( 0 ) ); |
706 | 706 | |
707 | | $post_id = self::$factory->post->create(); |
708 | | $attachment_id = self::$factory->attachment->create_object( $this->img_name, $post_id, array( |
| 707 | $post_id = self::factory()->post->create(); |
| 708 | $attachment_id = self::factory()->attachment->create_object( $this->img_name, $post_id, array( |
709 | 709 | 'post_mime_type' => 'image/jpeg', |
710 | 710 | 'post_type' => 'attachment', |
711 | 711 | ) ); |
… |
… |
EOF; |
760 | 760 | |
761 | 761 | // Make an image. |
762 | 762 | $filename = DIR_TESTDATA . '/images/test-image-large.png'; |
763 | | $id = self::$factory->attachment->create_upload_object( $filename ); |
| 763 | $id = self::factory()->attachment->create_upload_object( $filename ); |
764 | 764 | |
765 | 765 | $image = wp_get_attachment_metadata( $id ); |
766 | 766 | |
-
diff --git tests/phpunit/tests/meta.php tests/phpunit/tests/meta.php
index e975d6a..0676c7e 100644
|
|
class Tests_Meta extends WP_UnitTestCase { |
8 | 8 | |
9 | 9 | function setUp() { |
10 | 10 | parent::setUp(); |
11 | | $this->author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); |
| 11 | $this->author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) ); |
12 | 12 | $this->meta_id = add_metadata( 'user', $this->author->ID, 'meta_key', 'meta_value' ); |
13 | 13 | $this->delete_meta_id = add_metadata( 'user', $this->author->ID, 'delete_meta_key', 'delete_meta_value' ); |
14 | 14 | } |
… |
… |
class Tests_Meta extends WP_UnitTestCase { |
194 | 194 | * @ticket 16814 |
195 | 195 | */ |
196 | 196 | function test_meta_type_cast() { |
197 | | $post_id1 = self::$factory->post->create(); |
| 197 | $post_id1 = self::factory()->post->create(); |
198 | 198 | add_post_meta( $post_id1, 'num_as_longtext', 123 ); |
199 | 199 | add_post_meta( $post_id1, 'num_as_longtext_desc', 10 ); |
200 | | $post_id2 = self::$factory->post->create(); |
| 200 | $post_id2 = self::factory()->post->create(); |
201 | 201 | add_post_meta( $post_id2, 'num_as_longtext', 99 ); |
202 | 202 | add_post_meta( $post_id2, 'num_as_longtext_desc', 100 ); |
203 | 203 | |
… |
… |
class Tests_Meta extends WP_UnitTestCase { |
258 | 258 | } |
259 | 259 | |
260 | 260 | function test_meta_cache_order_asc() { |
261 | | $post_id = self::$factory->post->create(); |
| 261 | $post_id = self::factory()->post->create(); |
262 | 262 | $colors = array( 'red', 'blue', 'yellow', 'green' ); |
263 | 263 | foreach ( $colors as $color ) |
264 | 264 | add_post_meta( $post_id, 'color', $color ); |
-
diff --git tests/phpunit/tests/meta/slashes.php tests/phpunit/tests/meta/slashes.php
index 3f876d2..a5da86f 100644
|
|
|
8 | 8 | class Tests_Meta_Slashes extends WP_UnitTestCase { |
9 | 9 | function setUp() { |
10 | 10 | parent::setUp(); |
11 | | $this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) ); |
12 | | $this->post_id = self::$factory->post->create(); |
| 11 | $this->author_id = self::factory()->user->create( array( 'role' => 'editor' ) ); |
| 12 | $this->post_id = self::factory()->post->create(); |
13 | 13 | $this->old_current_user = get_current_user_id(); |
14 | 14 | wp_set_current_user( $this->author_id ); |
15 | 15 | |
… |
… |
class Tests_Meta_Slashes extends WP_UnitTestCase { |
32 | 32 | * |
33 | 33 | */ |
34 | 34 | function test_edit_post() { |
35 | | $id = self::$factory->post->create(); |
| 35 | $id = self::factory()->post->create(); |
36 | 36 | if ( function_exists( 'wp_add_post_meta' ) ) { |
37 | 37 | $meta_1 = wp_add_post_meta( $id, 'slash_test_1', 'foo' ); |
38 | 38 | $meta_2 = wp_add_post_meta( $id, 'slash_test_2', 'foo' ); |
… |
… |
class Tests_Meta_Slashes extends WP_UnitTestCase { |
108 | 108 | * |
109 | 109 | */ |
110 | 110 | function test_add_post_meta() { |
111 | | $id = self::$factory->post->create(); |
| 111 | $id = self::factory()->post->create(); |
112 | 112 | add_post_meta( $id, 'slash_test_1', addslashes( $this->slash_1 ) ); |
113 | 113 | add_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) ); |
114 | 114 | add_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) ); |
… |
… |
class Tests_Meta_Slashes extends WP_UnitTestCase { |
123 | 123 | * |
124 | 124 | */ |
125 | 125 | function test_update_post_meta() { |
126 | | $id = self::$factory->post->create(); |
| 126 | $id = self::factory()->post->create(); |
127 | 127 | update_post_meta( $id, 'slash_test_1', addslashes( $this->slash_1 ) ); |
128 | 128 | update_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) ); |
129 | 129 | update_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) ); |
… |
… |
class Tests_Meta_Slashes extends WP_UnitTestCase { |
141 | 141 | if ( !function_exists( 'wp_add_post_meta' ) ) { |
142 | 142 | return; |
143 | 143 | } |
144 | | $id = self::$factory->post->create(); |
| 144 | $id = self::factory()->post->create(); |
145 | 145 | wp_add_post_meta( $id, 'slash_test_1', $this->slash_1 ); |
146 | 146 | wp_add_post_meta( $id, 'slash_test_2', $this->slash_3 ); |
147 | 147 | wp_add_post_meta( $id, 'slash_test_3', $this->slash_4 ); |
… |
… |
class Tests_Meta_Slashes extends WP_UnitTestCase { |
159 | 159 | if ( !function_exists( 'wp_update_post_meta' ) ) { |
160 | 160 | return; |
161 | 161 | } |
162 | | $id = self::$factory->post->create(); |
| 162 | $id = self::factory()->post->create(); |
163 | 163 | wp_update_post_meta( $id, 'slash_test_1', $this->slash_1 ); |
164 | 164 | wp_update_post_meta( $id, 'slash_test_2', $this->slash_3 ); |
165 | 165 | wp_update_post_meta( $id, 'slash_test_3', $this->slash_4 ); |
… |
… |
class Tests_Meta_Slashes extends WP_UnitTestCase { |
174 | 174 | * |
175 | 175 | */ |
176 | 176 | function test_add_comment_meta() { |
177 | | $id = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); |
| 177 | $id = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) ); |
178 | 178 | |
179 | 179 | add_comment_meta( $id, 'slash_test_1', $this->slash_1 ); |
180 | 180 | add_comment_meta( $id, 'slash_test_2', $this->slash_3 ); |
… |
… |
class Tests_Meta_Slashes extends WP_UnitTestCase { |
198 | 198 | * |
199 | 199 | */ |
200 | 200 | function test_update_comment_meta() { |
201 | | $id = self::$factory->comment->create( array( 'comment_post_ID' => $this->post_id ) ); |
| 201 | $id = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) ); |
202 | 202 | |
203 | 203 | add_comment_meta( $id, 'slash_test_1', 'foo' ); |
204 | 204 | add_comment_meta( $id, 'slash_test_2', 'foo' ); |
… |
… |
class Tests_Meta_Slashes extends WP_UnitTestCase { |
226 | 226 | * |
227 | 227 | */ |
228 | 228 | function test_add_user_meta() { |
229 | | $id = self::$factory->user->create(); |
| 229 | $id = self::factory()->user->create(); |
230 | 230 | |
231 | 231 | add_user_meta( $id, 'slash_test_1', $this->slash_1 ); |
232 | 232 | add_user_meta( $id, 'slash_test_2', $this->slash_3 ); |
… |
… |
class Tests_Meta_Slashes extends WP_UnitTestCase { |
250 | 250 | * |
251 | 251 | */ |
252 | 252 | function test_update_user_meta() { |
253 | | $id = self::$factory->user->create(); |
| 253 | $id = self::factory()->user->create(); |
254 | 254 | |
255 | 255 | add_user_meta( $id, 'slash_test_1', 'foo' ); |
256 | 256 | add_user_meta( $id, 'slash_test_2', 'foo' ); |
-
diff --git tests/phpunit/tests/multisite/bootstrap.php tests/phpunit/tests/multisite/bootstrap.php
index b9fb2ad..c2fabbf 100644
|
|
class Tests_Multisite_Bootstrap extends WP_UnitTestCase { |
40 | 40 | ); |
41 | 41 | |
42 | 42 | foreach ( $ids as &$id ) { |
43 | | $id = self::$factory->network->create( $id ); |
| 43 | $id = self::factory()->network->create( $id ); |
44 | 44 | } |
45 | 45 | unset( $id ); |
46 | 46 | |
… |
… |
class Tests_Multisite_Bootstrap extends WP_UnitTestCase { |
88 | 88 | ); |
89 | 89 | |
90 | 90 | foreach ( $ids as &$id ) { |
91 | | $id = self::$factory->blog->create( $id ); |
| 91 | $id = self::factory()->blog->create( $id ); |
92 | 92 | } |
93 | 93 | unset( $id ); |
94 | 94 | |
… |
… |
class Tests_Multisite_Bootstrap extends WP_UnitTestCase { |
169 | 169 | ); |
170 | 170 | |
171 | 171 | foreach ( $network_ids as &$id ) { |
172 | | $id = self::$factory->network->create( $id ); |
| 172 | $id = self::factory()->network->create( $id ); |
173 | 173 | } |
174 | 174 | unset( $id ); |
175 | 175 | |
… |
… |
class Tests_Multisite_Bootstrap extends WP_UnitTestCase { |
182 | 182 | ); |
183 | 183 | |
184 | 184 | foreach ( $ids as &$id ) { |
185 | | $id = self::$factory->blog->create( $id ); |
| 185 | $id = self::factory()->blog->create( $id ); |
186 | 186 | } |
187 | 187 | unset( $id ); |
188 | 188 | |
-
diff --git tests/phpunit/tests/multisite/getSpaceUsed.php tests/phpunit/tests/multisite/getSpaceUsed.php
index bd355cc..cbc5138 100644
|
|
class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase { |
22 | 22 | } |
23 | 23 | |
24 | 24 | function test_get_space_used_switched_site() { |
25 | | $blog_id = self::$factory->blog->create(); |
| 25 | $blog_id = self::factory()->blog->create(); |
26 | 26 | switch_to_blog( $blog_id ); |
27 | 27 | |
28 | 28 | // Our comparison of space relies on an initial value of 0. If a previous test has failed or if the |
… |
… |
class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase { |
30 | 30 | // will be polluted. We create sites until an empty one is available. |
31 | 31 | while ( 0 != get_space_used() ) { |
32 | 32 | restore_current_blog(); |
33 | | $blog_id = self::$factory->blog->create(); |
| 33 | $blog_id = self::factory()->blog->create(); |
34 | 34 | switch_to_blog( $blog_id ); |
35 | 35 | } |
36 | 36 | |
… |
… |
class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase { |
58 | 58 | function test_get_space_used_main_site() { |
59 | 59 | $space_used = get_space_used(); |
60 | 60 | |
61 | | $blog_id = self::$factory->blog->create(); |
| 61 | $blog_id = self::factory()->blog->create(); |
62 | 62 | switch_to_blog( $blog_id ); |
63 | 63 | |
64 | 64 | // We don't rely on an initial value of 0 for space used, but should have a clean space available |
… |
… |
class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase { |
66 | 66 | // existing content directories in src. |
67 | 67 | while ( 0 != get_space_used() ) { |
68 | 68 | restore_current_blog(); |
69 | | $blog_id = self::$factory->blog->create(); |
| 69 | $blog_id = self::factory()->blog->create(); |
70 | 70 | switch_to_blog( $blog_id ); |
71 | 71 | } |
72 | 72 | |
-
diff --git tests/phpunit/tests/multisite/ms-files-rewriting.php tests/phpunit/tests/multisite/ms-files-rewriting.php
index 611e843..8bc87df 100644
|
|
class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase { |
37 | 37 | |
38 | 38 | $site = get_current_site(); |
39 | 39 | |
40 | | $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
41 | | $blog_id2 = self::$factory->blog->create( array( 'user_id' => $user_id ) ); |
| 40 | $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
| 41 | $blog_id2 = self::factory()->blog->create( array( 'user_id' => $user_id ) ); |
42 | 42 | $info = wp_upload_dir(); |
43 | 43 | $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); |
44 | 44 | $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); |
… |
… |
class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase { |
67 | 67 | // Upload a file to the main site on the network. |
68 | 68 | $file1 = wp_upload_bits( $filename, null, $contents ); |
69 | 69 | |
70 | | $blog_id = self::$factory->blog->create(); |
| 70 | $blog_id = self::factory()->blog->create(); |
71 | 71 | |
72 | 72 | switch_to_blog( $blog_id ); |
73 | 73 | $file2 = wp_upload_bits( $filename, null, $contents ); |
-
diff --git tests/phpunit/tests/multisite/network.php tests/phpunit/tests/multisite/network.php
index 01160ad..5888c73 100644
|
|
class Tests_Multisite_Network extends WP_UnitTestCase { |
37 | 37 | * as the main network ID. |
38 | 38 | */ |
39 | 39 | function test_get_main_network_id_two_networks() { |
40 | | self::$factory->network->create(); |
| 40 | self::factory()->network->create(); |
41 | 41 | |
42 | 42 | $this->assertEquals( 1, get_main_network_id() ); |
43 | 43 | } |
… |
… |
class Tests_Multisite_Network extends WP_UnitTestCase { |
49 | 49 | function test_get_main_network_id_after_network_switch() { |
50 | 50 | global $current_site; |
51 | 51 | |
52 | | $id = self::$factory->network->create(); |
| 52 | $id = self::factory()->network->create(); |
53 | 53 | |
54 | 54 | $current_site->id = (int) $id; |
55 | 55 | |
… |
… |
class Tests_Multisite_Network extends WP_UnitTestCase { |
65 | 65 | */ |
66 | 66 | function test_get_main_network_id_after_network_delete() { |
67 | 67 | global $wpdb, $current_site; |
68 | | $id = self::$factory->network->create(); |
| 68 | $id = self::factory()->network->create(); |
69 | 69 | |
70 | 70 | $current_site->id = (int) $id; |
71 | 71 | $wpdb->query( "UPDATE {$wpdb->site} SET id=100 WHERE id=1" ); |
… |
… |
class Tests_Multisite_Network extends WP_UnitTestCase { |
90 | 90 | $site_count_start = get_blog_count(); |
91 | 91 | // false for large networks by default |
92 | 92 | add_filter( 'enable_live_network_counts', '__return_false' ); |
93 | | self::$factory->blog->create_many( 4 ); |
| 93 | self::factory()->blog->create_many( 4 ); |
94 | 94 | |
95 | 95 | // count only updated when cron runs, so unchanged |
96 | 96 | $this->assertEquals( $site_count_start, (int) get_blog_count() ); |
97 | 97 | |
98 | 98 | add_filter( 'enable_live_network_counts', '__return_true' ); |
99 | | $site_ids = self::$factory->blog->create_many( 4 ); |
| 99 | $site_ids = self::factory()->blog->create_many( 4 ); |
100 | 100 | |
101 | 101 | $this->assertEquals( $site_count_start + 9, (int) get_blog_count() ); |
102 | 102 | |
… |
… |
class Tests_Multisite_Network extends WP_UnitTestCase { |
211 | 211 | |
212 | 212 | // Only false for large networks as of 3.7 |
213 | 213 | add_filter( 'enable_live_network_counts', '__return_false' ); |
214 | | self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 214 | self::factory()->user->create( array( 'role' => 'administrator' ) ); |
215 | 215 | |
216 | 216 | $count = get_user_count(); // No change, cache not refreshed |
217 | 217 | $this->assertEquals( $start_count, $count ); |
… |
… |
class Tests_Multisite_Network extends WP_UnitTestCase { |
240 | 240 | $dashboard_blog = get_dashboard_blog(); |
241 | 241 | $this->assertEquals( 1, $dashboard_blog->blog_id ); |
242 | 242 | |
243 | | $user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
244 | | $blog_id = self::$factory->blog->create( array( 'user_id' => $user_id ) ); |
| 243 | $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
| 244 | $blog_id = self::factory()->blog->create( array( 'user_id' => $user_id ) ); |
245 | 245 | $this->assertInternalType( 'int', $blog_id ); |
246 | 246 | |
247 | 247 | // set the dashboard blog to another one |
-
diff --git tests/phpunit/tests/multisite/site.php tests/phpunit/tests/multisite/site.php
index 0a51e6a..8afdbe8 100644
|
|
class Tests_Multisite_Site extends WP_UnitTestCase { |
34 | 34 | wp_cache_set( 'switch-test', $current_blog_id, 'switch-test' ); |
35 | 35 | $this->assertEquals( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); |
36 | 36 | |
37 | | $blog_id = self::$factory->blog->create(); |
| 37 | $blog_id = self::factory()->blog->create(); |
38 | 38 | |
39 | 39 | $cap_key = wp_get_current_user()->cap_key; |
40 | 40 | switch_to_blog( $blog_id ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
74 | 74 | function test_created_site_details() { |
75 | 75 | global $wpdb; |
76 | 76 | |
77 | | $blog_id = self::$factory->blog->create(); |
| 77 | $blog_id = self::factory()->blog->create(); |
78 | 78 | |
79 | 79 | $this->assertInternalType( 'int', $blog_id ); |
80 | 80 | $prefix = $wpdb->get_blog_prefix( $blog_id ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
130 | 130 | * When a site is flagged as 'deleted', its data should be cleared from cache. |
131 | 131 | */ |
132 | 132 | function test_data_in_cache_after_wpmu_delete_blog_drop_false() { |
133 | | $blog_id = self::$factory->blog->create(); |
| 133 | $blog_id = self::factory()->blog->create(); |
134 | 134 | |
135 | 135 | $details = get_blog_details( $blog_id, false ); |
136 | 136 | $key = md5( $details->domain . $details->path ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
151 | 151 | function test_data_in_tables_after_wpmu_delete_blog_drop_false() { |
152 | 152 | global $wpdb; |
153 | 153 | |
154 | | $blog_id = self::$factory->blog->create(); |
| 154 | $blog_id = self::factory()->blog->create(); |
155 | 155 | |
156 | 156 | // Delete the site without forcing a table drop. |
157 | 157 | wpmu_delete_blog( $blog_id, false ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
169 | 169 | * When a site is fully deleted, its data should be cleared from cache. |
170 | 170 | */ |
171 | 171 | function test_data_in_cache_after_wpmu_delete_blog_drop_true() { |
172 | | $blog_id = self::$factory->blog->create(); |
| 172 | $blog_id = self::factory()->blog->create(); |
173 | 173 | |
174 | 174 | $details = get_blog_details( $blog_id, false ); |
175 | 175 | $key = md5( $details->domain . $details->path ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
190 | 190 | function test_data_in_tables_after_wpmu_delete_blog_drop_true() { |
191 | 191 | global $wpdb; |
192 | 192 | |
193 | | $blog_id = self::$factory->blog->create(); |
| 193 | $blog_id = self::factory()->blog->create(); |
194 | 194 | |
195 | 195 | // Delete the site and force a table drop. |
196 | 196 | wpmu_delete_blog( $blog_id, true ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
247 | 247 | * The site count of a network should change when a site is flagged as 'deleted'. |
248 | 248 | */ |
249 | 249 | function test_network_count_after_wpmu_delete_blog_drop_false() { |
250 | | $blog_id = self::$factory->blog->create(); |
| 250 | $blog_id = self::factory()->blog->create(); |
251 | 251 | |
252 | 252 | // Delete the site without forcing a table drop. |
253 | 253 | wpmu_delete_blog( $blog_id, false ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
261 | 261 | * The site count of a network should change when a site is fully deleted. |
262 | 262 | */ |
263 | 263 | function test_blog_count_after_wpmu_delete_blog_drop_true() { |
264 | | $blog_id = self::$factory->blog->create(); |
| 264 | $blog_id = self::factory()->blog->create(); |
265 | 265 | |
266 | 266 | // Delete the site and force a table drop. |
267 | 267 | wpmu_delete_blog( $blog_id, true ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
283 | 283 | // Upload a file to the main site on the network. |
284 | 284 | $file1 = wp_upload_bits( $filename, null, $contents ); |
285 | 285 | |
286 | | $blog_id = self::$factory->blog->create(); |
| 286 | $blog_id = self::factory()->blog->create(); |
287 | 287 | |
288 | 288 | switch_to_blog( $blog_id ); |
289 | 289 | $file2 = wp_upload_bits( $filename, null, $contents ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
329 | 329 | */ |
330 | 330 | function test_get_blog_details_when_site_does_not_exist() { |
331 | 331 | // Create an unused site so that we can then assume an invalid site ID. |
332 | | $blog_id = self::$factory->blog->create(); |
| 332 | $blog_id = self::factory()->blog->create(); |
333 | 333 | $blog_id++; |
334 | 334 | |
335 | 335 | // Prime the cache for an invalid site. |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
339 | 339 | $this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) ); |
340 | 340 | |
341 | 341 | // Create a site in the invalid site's place. |
342 | | self::$factory->blog->create(); |
| 342 | self::factory()->blog->create(); |
343 | 343 | |
344 | 344 | // When a new site is created, its cache is cleared through refresh_blog_details. |
345 | 345 | $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
370 | 370 | global $test_action_counter; |
371 | 371 | $test_action_counter = 0; |
372 | 372 | |
373 | | $blog_id = self::$factory->blog->create(); |
| 373 | $blog_id = self::factory()->blog->create(); |
374 | 374 | update_blog_details( $blog_id, array( 'spam' => 1 ) ); |
375 | 375 | |
376 | 376 | add_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10 ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
394 | 394 | global $test_action_counter; |
395 | 395 | $test_action_counter = 0; |
396 | 396 | |
397 | | $blog_id = self::$factory->blog->create(); |
| 397 | $blog_id = self::factory()->blog->create(); |
398 | 398 | |
399 | 399 | add_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10 ); |
400 | 400 | update_blog_status( $blog_id, 'spam', 1 ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
417 | 417 | global $test_action_counter; |
418 | 418 | $test_action_counter = 0; |
419 | 419 | |
420 | | $blog_id = self::$factory->blog->create(); |
| 420 | $blog_id = self::factory()->blog->create(); |
421 | 421 | |
422 | 422 | add_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10 ); |
423 | 423 | update_blog_status( $blog_id, 'archived', 1 ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
440 | 440 | global $test_action_counter; |
441 | 441 | $test_action_counter = 0; |
442 | 442 | |
443 | | $blog_id = self::$factory->blog->create(); |
| 443 | $blog_id = self::factory()->blog->create(); |
444 | 444 | update_blog_details( $blog_id, array( 'archived' => 1 ) ); |
445 | 445 | |
446 | 446 | add_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10 ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
463 | 463 | global $test_action_counter; |
464 | 464 | $test_action_counter = 0; |
465 | 465 | |
466 | | $blog_id = self::$factory->blog->create(); |
| 466 | $blog_id = self::factory()->blog->create(); |
467 | 467 | |
468 | 468 | add_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10 ); |
469 | 469 | update_blog_status( $blog_id, 'deleted', 1 ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
486 | 486 | global $test_action_counter; |
487 | 487 | $test_action_counter = 0; |
488 | 488 | |
489 | | $blog_id = self::$factory->blog->create(); |
| 489 | $blog_id = self::factory()->blog->create(); |
490 | 490 | update_blog_details( $blog_id, array( 'deleted' => 1 ) ); |
491 | 491 | |
492 | 492 | add_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10 ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
510 | 510 | global $test_action_counter; |
511 | 511 | $test_action_counter = 0; |
512 | 512 | |
513 | | $blog_id = self::$factory->blog->create(); |
| 513 | $blog_id = self::factory()->blog->create(); |
514 | 514 | |
515 | 515 | add_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10 ); |
516 | 516 | update_blog_status( $blog_id, 'mature', 1 ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
533 | 533 | global $test_action_counter; |
534 | 534 | $test_action_counter = 0; |
535 | 535 | |
536 | | $blog_id = self::$factory->blog->create(); |
| 536 | $blog_id = self::factory()->blog->create(); |
537 | 537 | update_blog_details( $blog_id, array( 'mature' => 1 ) ); |
538 | 538 | |
539 | 539 | add_action( 'unmature_blog', array( $this, '_action_counter_cb' ), 10 ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
557 | 557 | global $test_action_counter; |
558 | 558 | $test_action_counter = 0; |
559 | 559 | |
560 | | $blog_id = self::$factory->blog->create(); |
| 560 | $blog_id = self::factory()->blog->create(); |
561 | 561 | |
562 | 562 | add_action( 'update_blog_public', array( $this, '_action_counter_cb' ), 10 ); |
563 | 563 | update_blog_status( $blog_id, 'public', 0 ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
583 | 583 | * @ticket 14511 |
584 | 584 | */ |
585 | 585 | function test_wp_get_sites_with_default_arguments() { |
586 | | self::$factory->blog->create( array( 'site_id' => 2 ) ); |
| 586 | self::factory()->blog->create( array( 'site_id' => 2 ) ); |
587 | 587 | |
588 | 588 | $this->assertCount( 1, wp_get_sites() ); |
589 | 589 | } |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
599 | 599 | * A network ID of null should query for all public sites on all networks. |
600 | 600 | */ |
601 | 601 | function test_wp_get_sites_with_network_id_null() { |
602 | | self::$factory->blog->create( array( 'site_id' => 2 ) ); |
| 602 | self::factory()->blog->create( array( 'site_id' => 2 ) ); |
603 | 603 | |
604 | 604 | $this->assertCount( 2, wp_get_sites( array( 'network_id' => null ) ) ); |
605 | 605 | } |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
608 | 608 | * Expect only sites on the specified network ID to be returned. |
609 | 609 | */ |
610 | 610 | function test_wp_get_sites_with_specific_network_id() { |
611 | | self::$factory->blog->create( array( 'site_id' => 2 ) ); |
| 611 | self::factory()->blog->create( array( 'site_id' => 2 ) ); |
612 | 612 | |
613 | 613 | $this->assertCount( 1, wp_get_sites( array( 'network_id' => 2 ) ) ); |
614 | 614 | } |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
617 | 617 | * Expect sites from both networks if both network IDs are specified. |
618 | 618 | */ |
619 | 619 | function test_wp_get_sites_with_multiple_network_ids() { |
620 | | self::$factory->blog->create( array( 'site_id' => 2 ) ); |
| 620 | self::factory()->blog->create( array( 'site_id' => 2 ) ); |
621 | 621 | |
622 | 622 | $this->assertCount( 2, wp_get_sites( array( 'network_id' => array( 1, 2 ) ) ) ); |
623 | 623 | } |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
626 | 626 | * Queries for public or non public sites should work across all networks if network ID is null. |
627 | 627 | */ |
628 | 628 | function test_wp_get_sites_with_public_meta_on_all_networks() { |
629 | | self::$factory->blog->create( array( 'site_id' => 2, 'meta' => array( 'public' => 0 ) ) ); |
| 629 | self::factory()->blog->create( array( 'site_id' => 2, 'meta' => array( 'public' => 0 ) ) ); |
630 | 630 | |
631 | 631 | $this->assertCount( 1, wp_get_sites( array( 'public' => 1, 'network_id' => null ) ) ); |
632 | 632 | $this->assertcount( 1, wp_get_sites( array( 'public' => 0, 'network_id' => null ) ) ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
636 | 636 | * If a network ID is specified, queries for public sites should be restricted to that network. |
637 | 637 | */ |
638 | 638 | function test_wp_get_sites_with_public_meta_restrict_to_one_network() { |
639 | | self::$factory->blog->create( array( 'site_id' => 1, 'meta' => array( 'public' => 0 ) ) ); |
| 639 | self::factory()->blog->create( array( 'site_id' => 1, 'meta' => array( 'public' => 0 ) ) ); |
640 | 640 | |
641 | 641 | $this->assertCount( 1, wp_get_sites( array( 'public' => 1, 'network_id' => 1 ) ) ); |
642 | 642 | $this->assertCount( 0, wp_get_sites( array( 'public' => 1, 'network_id' => 2 ) ) ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
647 | 647 | */ |
648 | 648 | function test_wp_get_sites_limit_offset() { |
649 | 649 | // Create 2 more sites (in addition to the default one) |
650 | | self::$factory->blog->create_many( 2 ); |
| 650 | self::factory()->blog->create_many( 2 ); |
651 | 651 | |
652 | 652 | // Expect first 2 sites when using limit |
653 | 653 | $this->assertCount( 2, wp_get_sites( array( 'limit' => 2 ) ) ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
670 | 670 | * @ticket 27952 |
671 | 671 | */ |
672 | 672 | function test_posts_count() { |
673 | | self::$factory->post->create(); |
674 | | $post2 = self::$factory->post->create(); |
| 673 | self::factory()->post->create(); |
| 674 | $post2 = self::factory()->post->create(); |
675 | 675 | $this->assertEquals( 2, get_blog_details()->post_count ); |
676 | 676 | |
677 | 677 | wp_delete_post( $post2 ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
701 | 701 | ); |
702 | 702 | |
703 | 703 | foreach ( $network_ids as &$id ) { |
704 | | $id = self::$factory->network->create( $id ); |
| 704 | $id = self::factory()->network->create( $id ); |
705 | 705 | } |
706 | 706 | unset( $id ); |
707 | 707 | |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
714 | 714 | ); |
715 | 715 | |
716 | 716 | foreach ( $ids as &$id ) { |
717 | | $id = self::$factory->blog->create( $id ); |
| 717 | $id = self::factory()->blog->create( $id ); |
718 | 718 | } |
719 | 719 | unset( $id ); |
720 | 720 | |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
772 | 772 | * the blog ID is requested through get_blog_id_from_url(). |
773 | 773 | */ |
774 | 774 | function test_get_blog_id_from_url() { |
775 | | $blog_id = self::$factory->blog->create(); |
| 775 | $blog_id = self::factory()->blog->create(); |
776 | 776 | $details = get_blog_details( $blog_id, false ); |
777 | 777 | $key = md5( $details->domain . $details->path ); |
778 | 778 | |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
785 | 785 | * Test the case insensitivity of the site lookup. |
786 | 786 | */ |
787 | 787 | function test_get_blog_id_from_url_is_case_insensitive() { |
788 | | $blog_id = self::$factory->blog->create( array( 'domain' => 'example.com', 'path' => '/xyz' ) ); |
| 788 | $blog_id = self::factory()->blog->create( array( 'domain' => 'example.com', 'path' => '/xyz' ) ); |
789 | 789 | $details = get_blog_details( $blog_id, false ); |
790 | 790 | |
791 | 791 | $this->assertEquals( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ), strtoupper( $details->path ) ) ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
795 | 795 | * Test the first and cached responses for a site that does not exist. |
796 | 796 | */ |
797 | 797 | function test_get_blog_id_from_url_that_does_not_exist() { |
798 | | $blog_id = self::$factory->blog->create( array( 'path' => '/xyz' ) ); |
| 798 | $blog_id = self::factory()->blog->create( array( 'path' => '/xyz' ) ); |
799 | 799 | $details = get_blog_details( $blog_id, false ); |
800 | 800 | |
801 | 801 | $this->assertEquals( 0, get_blog_id_from_url( $details->domain, 'foo' ) ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
807 | 807 | * behavior would be expected if passing `false` explicitly to `wpmu_delete_blog()`. |
808 | 808 | */ |
809 | 809 | function test_get_blog_id_from_url_with_deleted_flag() { |
810 | | $blog_id = self::$factory->blog->create(); |
| 810 | $blog_id = self::factory()->blog->create(); |
811 | 811 | $details = get_blog_details( $blog_id, false ); |
812 | 812 | $key = md5( $details->domain . $details->path ); |
813 | 813 | wpmu_delete_blog( $blog_id ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
821 | 821 | * -1 after an attempt at `get_blog_id_from_url()` is made. |
822 | 822 | */ |
823 | 823 | function test_get_blog_id_from_url_after_dropped() { |
824 | | $blog_id = self::$factory->blog->create(); |
| 824 | $blog_id = self::factory()->blog->create(); |
825 | 825 | $details = get_blog_details( $blog_id, false ); |
826 | 826 | $key = md5( $details->domain . $details->path ); |
827 | 827 | wpmu_delete_blog( $blog_id, true ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
850 | 850 | * Test with a site ID other than the main site to ensure a false response. |
851 | 851 | */ |
852 | 852 | function test_is_main_site_is_false_with_other_blog_id() { |
853 | | $blog_id = self::$factory->blog->create(); |
| 853 | $blog_id = self::factory()->blog->create(); |
854 | 854 | |
855 | 855 | $this->assertFalse( is_main_site( $blog_id ) ); |
856 | 856 | } |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
859 | 859 | * Test with no passed ID after switching to another site ID. |
860 | 860 | */ |
861 | 861 | function test_is_main_site_is_false_after_switch_to_blog() { |
862 | | $blog_id = self::$factory->blog->create(); |
| 862 | $blog_id = self::factory()->blog->create(); |
863 | 863 | switch_to_blog( $blog_id ); |
864 | 864 | |
865 | 865 | $this->assertFalse( is_main_site() ); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
878 | 878 | $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); |
879 | 879 | $this->assertEquals( '', $info['error'] ); |
880 | 880 | |
881 | | $blog_id = self::$factory->blog->create(); |
| 881 | $blog_id = self::factory()->blog->create(); |
882 | 882 | |
883 | 883 | switch_to_blog( $blog_id ); |
884 | 884 | $info = wp_upload_dir(); |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
900 | 900 | * another site on the network. |
901 | 901 | */ |
902 | 902 | function test_get_blog_post_from_another_site_on_network() { |
903 | | $blog_id = self::$factory->blog->create(); |
904 | | $post_id = self::$factory->post->create(); // Create a post on the primary site, ID 1. |
| 903 | $blog_id = self::factory()->blog->create(); |
| 904 | $post_id = self::factory()->post->create(); // Create a post on the primary site, ID 1. |
905 | 905 | $post = get_post( $post_id ); |
906 | 906 | switch_to_blog( $blog_id ); |
907 | 907 | |
… |
… |
class Tests_Multisite_Site extends WP_UnitTestCase { |
915 | 915 | * If get_blog_post() is used on the same site, it should still work. |
916 | 916 | */ |
917 | 917 | function test_get_blog_post_from_same_site() { |
918 | | $post_id = self::$factory->post->create(); |
| 918 | $post_id = self::factory()->post->create(); |
919 | 919 | |
920 | 920 | $this->assertEquals( get_blog_post( 1, $post_id ), get_post( $post_id ) ); |
921 | 921 | } |
-
diff --git tests/phpunit/tests/multisite/updateBlogDetails.php tests/phpunit/tests/multisite/updateBlogDetails.php
index 874d2bc..e106b02 100644
|
|
class Tests_Multisite_Update_Blog_Details extends WP_UnitTestCase { |
25 | 25 | } |
26 | 26 | |
27 | 27 | function test_update_blog_details() { |
28 | | $blog_id = self::$factory->blog->create(); |
| 28 | $blog_id = self::factory()->blog->create(); |
29 | 29 | |
30 | 30 | $result = update_blog_details( $blog_id, array( 'domain' => 'example.com', 'path' => 'my_path/' ) ); |
31 | 31 | |
… |
… |
class Tests_Multisite_Update_Blog_Details extends WP_UnitTestCase { |
53 | 53 | global $test_action_counter; |
54 | 54 | $test_action_counter = 0; |
55 | 55 | |
56 | | $blog_id = self::$factory->blog->create(); |
| 56 | $blog_id = self::factory()->blog->create(); |
57 | 57 | |
58 | 58 | // Set an initial value of '1' for the flag when '0' is the flag value being tested. |
59 | 59 | if ( '0' === $flag_value ) { |
-
diff --git tests/phpunit/tests/multisite/wpmuValidateUserSignup.php tests/phpunit/tests/multisite/wpmuValidateUserSignup.php
index 50ddce7..15cf56c 100644
|
|
class Tests_Multisite_WpmuValidateUserSignup extends WP_UnitTestCase { |
63 | 63 | } |
64 | 64 | |
65 | 65 | public function test_should_fail_for_existing_user_name() { |
66 | | $u = self::$factory->user->create( array( 'user_login' => 'foo123' ) ); |
| 66 | $u = self::factory()->user->create( array( 'user_login' => 'foo123' ) ); |
67 | 67 | $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' ); |
68 | 68 | $this->assertContains( 'user_name', $v['errors']->get_error_codes() ); |
69 | 69 | } |
70 | 70 | |
71 | 71 | public function test_should_fail_for_existing_user_email() { |
72 | | $u = self::$factory->user->create( array( 'user_email' => 'foo@example.com' ) ); |
| 72 | $u = self::factory()->user->create( array( 'user_email' => 'foo@example.com' ) ); |
73 | 73 | $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' ); |
74 | 74 | $this->assertContains( 'user_email', $v['errors']->get_error_codes() ); |
75 | 75 | } |
-
diff --git tests/phpunit/tests/oembed/controller.php tests/phpunit/tests/oembed/controller.php
index 9c9275b..bf646f5 100644
|
|
class Test_oEmbed_Controller extends WP_UnitTestCase { |
17 | 17 | } |
18 | 18 | |
19 | 19 | function test_request_json() { |
20 | | $user = self::$factory->user->create_and_get( array( |
| 20 | $user = self::factory()->user->create_and_get( array( |
21 | 21 | 'display_name' => 'John Doe', |
22 | 22 | ) ); |
23 | | $post = self::$factory->post->create_and_get( array( |
| 23 | $post = self::factory()->post->create_and_get( array( |
24 | 24 | 'post_author' => $user->ID, |
25 | 25 | 'post_title' => 'Hello World', |
26 | 26 | ) ); |
… |
… |
class Test_oEmbed_Controller extends WP_UnitTestCase { |
60 | 60 | } |
61 | 61 | |
62 | 62 | function test_request_jsonp() { |
63 | | $user = self::$factory->user->create_and_get( array( |
| 63 | $user = self::factory()->user->create_and_get( array( |
64 | 64 | 'display_name' => 'John Doe', |
65 | 65 | ) ); |
66 | | $post = self::$factory->post->create_and_get( array( |
| 66 | $post = self::factory()->post->create_and_get( array( |
67 | 67 | 'post_author' => $user->ID, |
68 | 68 | 'post_title' => 'Hello World', |
69 | 69 | ) ); |
… |
… |
class Test_oEmbed_Controller extends WP_UnitTestCase { |
83 | 83 | } |
84 | 84 | |
85 | 85 | function test_request_jsonp_invalid_callback() { |
86 | | $user = self::$factory->user->create_and_get( array( |
| 86 | $user = self::factory()->user->create_and_get( array( |
87 | 87 | 'display_name' => 'John Doe', |
88 | 88 | ) ); |
89 | | $post = self::$factory->post->create_and_get( array( |
| 89 | $post = self::factory()->post->create_and_get( array( |
90 | 90 | 'post_author' => $user->ID, |
91 | 91 | 'post_title' => 'Hello World', |
92 | 92 | ) ); |
… |
… |
class Test_oEmbed_Controller extends WP_UnitTestCase { |
118 | 118 | } |
119 | 119 | |
120 | 120 | function test_request_xml() { |
121 | | $user = self::$factory->user->create_and_get( array( |
| 121 | $user = self::factory()->user->create_and_get( array( |
122 | 122 | 'display_name' => 'John Doe', |
123 | 123 | ) ); |
124 | | $post = self::$factory->post->create_and_get( array( |
| 124 | $post = self::factory()->post->create_and_get( array( |
125 | 125 | 'post_author' => $user->ID, |
126 | 126 | 'post_title' => 'Hello World', |
127 | 127 | ) ); |
… |
… |
class Test_oEmbed_Controller extends WP_UnitTestCase { |
177 | 177 | $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' ); |
178 | 178 | } |
179 | 179 | |
180 | | $child = self::$factory->blog->create(); |
| 180 | $child = self::factory()->blog->create(); |
181 | 181 | |
182 | 182 | switch_to_blog( $child ); |
183 | 183 | |
184 | | $post = self::$factory->post->create_and_get( array( |
| 184 | $post = self::factory()->post->create_and_get( array( |
185 | 185 | 'post_title' => 'Hello Child Blog', |
186 | 186 | ) ); |
187 | 187 | |
… |
… |
class Test_oEmbed_Controller extends WP_UnitTestCase { |
207 | 207 | $this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url( '', 'json' ) ); |
208 | 208 | $this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url( '', 'xml' ) ); |
209 | 209 | |
210 | | $post_id = self::$factory->post->create(); |
| 210 | $post_id = self::factory()->post->create(); |
211 | 211 | $url = get_permalink( $post_id ); |
212 | 212 | $url_encoded = urlencode( $url ); |
213 | 213 | |
-
diff --git tests/phpunit/tests/oembed/discovery.php tests/phpunit/tests/oembed/discovery.php
index ef78bef..e7615f9 100644
|
|
class Tests_oEmbed_Discovery extends WP_UnitTestCase { |
12 | 12 | } |
13 | 13 | |
14 | 14 | function test_add_oembed_discovery_links_to_post() { |
15 | | $post_id = self::$factory->post->create(); |
| 15 | $post_id = self::factory()->post->create(); |
16 | 16 | $this->go_to( get_permalink( $post_id ) ); |
17 | 17 | |
18 | 18 | $this->assertQueryTrue( 'is_single', 'is_singular' ); |
… |
… |
class Tests_oEmbed_Discovery extends WP_UnitTestCase { |
28 | 28 | } |
29 | 29 | |
30 | 30 | function test_add_oembed_discovery_links_to_page() { |
31 | | $post_id = self::$factory->post->create( array( |
| 31 | $post_id = self::factory()->post->create( array( |
32 | 32 | 'post_type' => 'page' |
33 | 33 | )); |
34 | 34 | $this->go_to( get_permalink( $post_id ) ); |
… |
… |
class Tests_oEmbed_Discovery extends WP_UnitTestCase { |
46 | 46 | } |
47 | 47 | |
48 | 48 | function test_add_oembed_discovery_links_to_attachment() { |
49 | | $post_id = self::$factory->post->create(); |
| 49 | $post_id = self::factory()->post->create(); |
50 | 50 | $file = DIR_TESTDATA . '/images/canola.jpg'; |
51 | | $attachment_id = self::$factory->attachment->create_object( $file, $post_id, array( |
| 51 | $attachment_id = self::factory()->attachment->create_object( $file, $post_id, array( |
52 | 52 | 'post_mime_type' => 'image/jpeg', |
53 | 53 | ) ); |
54 | 54 | |
-
diff --git tests/phpunit/tests/oembed/getResponseData.php tests/phpunit/tests/oembed/getResponseData.php
index 0891642..6dcdcbd 100644
|
|
class Tests_oEmbed_Response_Data extends WP_UnitTestCase { |
9 | 9 | } |
10 | 10 | |
11 | 11 | function test_get_oembed_response_data() { |
12 | | $post = self::$factory->post->create_and_get( array( |
| 12 | $post = self::factory()->post->create_and_get( array( |
13 | 13 | 'post_title' => 'Some Post', |
14 | 14 | ) ); |
15 | 15 | |
… |
… |
class Tests_oEmbed_Response_Data extends WP_UnitTestCase { |
33 | 33 | * Test get_oembed_response_data with an author. |
34 | 34 | */ |
35 | 35 | function test_get_oembed_response_data_author() { |
36 | | $user_id = self::$factory->user->create( array( |
| 36 | $user_id = self::factory()->user->create( array( |
37 | 37 | 'display_name' => 'John Doe', |
38 | 38 | ) ); |
39 | 39 | |
40 | | $post = self::$factory->post->create_and_get( array( |
| 40 | $post = self::factory()->post->create_and_get( array( |
41 | 41 | 'post_title' => 'Some Post', |
42 | 42 | 'post_author' => $user_id, |
43 | 43 | ) ); |
… |
… |
class Tests_oEmbed_Response_Data extends WP_UnitTestCase { |
61 | 61 | function test_get_oembed_response_link() { |
62 | 62 | remove_filter( 'oembed_response_data', 'get_oembed_response_data_rich' ); |
63 | 63 | |
64 | | $post = self::$factory->post->create_and_get( array( |
| 64 | $post = self::factory()->post->create_and_get( array( |
65 | 65 | 'post_title' => 'Some Post', |
66 | 66 | ) ); |
67 | 67 | |
… |
… |
class Tests_oEmbed_Response_Data extends WP_UnitTestCase { |
81 | 81 | } |
82 | 82 | |
83 | 83 | function test_get_oembed_response_data_with_draft_post() { |
84 | | $post = self::$factory->post->create_and_get( array( |
| 84 | $post = self::factory()->post->create_and_get( array( |
85 | 85 | 'post_status' => 'draft', |
86 | 86 | ) ); |
87 | 87 | |
… |
… |
class Tests_oEmbed_Response_Data extends WP_UnitTestCase { |
89 | 89 | } |
90 | 90 | |
91 | 91 | function test_get_oembed_response_data_with_scheduled_post() { |
92 | | $post = self::$factory->post->create_and_get( array( |
| 92 | $post = self::factory()->post->create_and_get( array( |
93 | 93 | 'post_status' => 'future', |
94 | 94 | 'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ), |
95 | 95 | ) ); |
… |
… |
class Tests_oEmbed_Response_Data extends WP_UnitTestCase { |
98 | 98 | } |
99 | 99 | |
100 | 100 | function test_get_oembed_response_data_with_private_post() { |
101 | | $post = self::$factory->post->create_and_get( array( |
| 101 | $post = self::factory()->post->create_and_get( array( |
102 | 102 | 'post_status' => 'private', |
103 | 103 | ) ); |
104 | 104 | |
… |
… |
class Tests_oEmbed_Response_Data extends WP_UnitTestCase { |
106 | 106 | } |
107 | 107 | |
108 | 108 | function test_get_oembed_response_data_maxwidth_too_high() { |
109 | | $post = self::$factory->post->create_and_get(); |
| 109 | $post = self::factory()->post->create_and_get(); |
110 | 110 | |
111 | 111 | $data = get_oembed_response_data( $post, 1000 ); |
112 | 112 | |
… |
… |
class Tests_oEmbed_Response_Data extends WP_UnitTestCase { |
115 | 115 | } |
116 | 116 | |
117 | 117 | function test_get_oembed_response_data_maxwidth_too_low() { |
118 | | $post = self::$factory->post->create_and_get(); |
| 118 | $post = self::factory()->post->create_and_get(); |
119 | 119 | |
120 | 120 | $data = get_oembed_response_data( $post, 100 ); |
121 | 121 | |
… |
… |
class Tests_oEmbed_Response_Data extends WP_UnitTestCase { |
124 | 124 | } |
125 | 125 | |
126 | 126 | function test_get_oembed_response_data_maxwidth_invalid() { |
127 | | $post = self::$factory->post->create_and_get(); |
| 127 | $post = self::factory()->post->create_and_get(); |
128 | 128 | |
129 | 129 | $data = get_oembed_response_data( $post, '400;" DROP TABLES' ); |
130 | 130 | |
… |
… |
class Tests_oEmbed_Response_Data extends WP_UnitTestCase { |
138 | 138 | } |
139 | 139 | |
140 | 140 | function test_get_oembed_response_data_with_thumbnail() { |
141 | | $post = self::$factory->post->create_and_get(); |
| 141 | $post = self::factory()->post->create_and_get(); |
142 | 142 | $file = DIR_TESTDATA . '/images/canola.jpg'; |
143 | | $attachment_id = self::$factory->attachment->create_object( $file, $post->ID, array( |
| 143 | $attachment_id = self::factory()->attachment->create_object( $file, $post->ID, array( |
144 | 144 | 'post_mime_type' => 'image/jpeg', |
145 | 145 | ) ); |
146 | 146 | set_post_thumbnail( $post, $attachment_id ); |
… |
… |
class Tests_oEmbed_Response_Data extends WP_UnitTestCase { |
154 | 154 | } |
155 | 155 | |
156 | 156 | function test_get_oembed_response_data_for_attachment() { |
157 | | $parent = self::$factory->post->create(); |
| 157 | $parent = self::factory()->post->create(); |
158 | 158 | $file = DIR_TESTDATA . '/images/canola.jpg'; |
159 | | $post = self::$factory->attachment->create_object( $file, $parent, array( |
| 159 | $post = self::factory()->attachment->create_object( $file, $parent, array( |
160 | 160 | 'post_mime_type' => 'image/jpeg', |
161 | 161 | ) ); |
162 | 162 | |
-
diff --git tests/phpunit/tests/oembed/headers.php tests/phpunit/tests/oembed/headers.php
index 247e947..3c9f80f 100644
|
|
class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase { |
12 | 12 | $this->markTestSkipped( 'xdebug is required for this test' ); |
13 | 13 | } |
14 | 14 | |
15 | | $post = self::$factory->post->create_and_get( array( |
| 15 | $post = self::factory()->post->create_and_get( array( |
16 | 16 | 'post_title' => 'Hello World', |
17 | 17 | ) ); |
18 | 18 | |
… |
… |
class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase { |
46 | 46 | $this->markTestSkipped( 'xdebug is required for this test' ); |
47 | 47 | } |
48 | 48 | |
49 | | $post = self::$factory->post->create_and_get( array( |
| 49 | $post = self::factory()->post->create_and_get( array( |
50 | 50 | 'post_title' => 'Hello World', |
51 | 51 | ) ); |
52 | 52 | |
-
diff --git tests/phpunit/tests/oembed/postEmbedUrl.php tests/phpunit/tests/oembed/postEmbedUrl.php
index 1972bac..dda0f3c 100644
|
|
class Tests_Post_Embed_URL extends WP_UnitTestCase { |
12 | 12 | function test_get_post_embed_url_with_pretty_permalinks() { |
13 | 13 | update_option( 'permalink_structure', '/%postname%' ); |
14 | 14 | |
15 | | $post_id = self::$factory->post->create(); |
| 15 | $post_id = self::factory()->post->create(); |
16 | 16 | $permalink = get_permalink( $post_id ); |
17 | 17 | $embed_url = get_post_embed_url( $post_id ); |
18 | 18 | |
… |
… |
class Tests_Post_Embed_URL extends WP_UnitTestCase { |
22 | 22 | } |
23 | 23 | |
24 | 24 | function test_get_post_embed_url_with_ugly_permalinks() { |
25 | | $post_id = self::$factory->post->create(); |
| 25 | $post_id = self::factory()->post->create(); |
26 | 26 | $permalink = get_permalink( $post_id ); |
27 | 27 | $embed_url = get_post_embed_url( $post_id ); |
28 | 28 | |
-
diff --git tests/phpunit/tests/oembed/template.php tests/phpunit/tests/oembed/template.php
index 94d0d9c..da61db4 100644
|
|
|
5 | 5 | */ |
6 | 6 | class Tests_Embed_Template extends WP_UnitTestCase { |
7 | 7 | function test_oembed_output_post() { |
8 | | $user = self::$factory->user->create_and_get( array( |
| 8 | $user = self::factory()->user->create_and_get( array( |
9 | 9 | 'display_name' => 'John Doe', |
10 | 10 | ) ); |
11 | 11 | |
12 | | $post_id = self::$factory->post->create( array( |
| 12 | $post_id = self::factory()->post->create( array( |
13 | 13 | 'post_author' => $user->ID, |
14 | 14 | 'post_title' => 'Hello World', |
15 | 15 | 'post_content' => 'Foo Bar', |
… |
… |
class Tests_Embed_Template extends WP_UnitTestCase { |
30 | 30 | } |
31 | 31 | |
32 | 32 | function test_oembed_output_post_with_thumbnail() { |
33 | | $post_id = self::$factory->post->create( array( |
| 33 | $post_id = self::factory()->post->create( array( |
34 | 34 | 'post_title' => 'Hello World', |
35 | 35 | 'post_content' => 'Foo Bar', |
36 | 36 | 'post_excerpt' => 'Bar Baz', |
37 | 37 | ) ); |
38 | 38 | $file = DIR_TESTDATA . '/images/canola.jpg'; |
39 | | $attachment_id = self::$factory->attachment->create_object( $file, $post_id, array( |
| 39 | $attachment_id = self::factory()->attachment->create_object( $file, $post_id, array( |
40 | 40 | 'post_mime_type' => 'image/jpeg', |
41 | 41 | ) ); |
42 | 42 | set_post_thumbnail( $post_id, $attachment_id ); |
… |
… |
class Tests_Embed_Template extends WP_UnitTestCase { |
72 | 72 | } |
73 | 73 | |
74 | 74 | function test_oembed_output_attachment() { |
75 | | $post = self::$factory->post->create_and_get(); |
| 75 | $post = self::factory()->post->create_and_get(); |
76 | 76 | $file = DIR_TESTDATA . '/images/canola.jpg'; |
77 | | $attachment_id = self::$factory->attachment->create_object( $file, $post->ID, array( |
| 77 | $attachment_id = self::factory()->attachment->create_object( $file, $post->ID, array( |
78 | 78 | 'post_mime_type' => 'image/jpeg', |
79 | 79 | 'post_title' => 'Hello World', |
80 | 80 | 'post_content' => 'Foo Bar', |
… |
… |
class Tests_Embed_Template extends WP_UnitTestCase { |
97 | 97 | } |
98 | 98 | |
99 | 99 | function test_oembed_output_draft_post() { |
100 | | $post_id = self::$factory->post->create( array( |
| 100 | $post_id = self::factory()->post->create( array( |
101 | 101 | 'post_title' => 'Hello World', |
102 | 102 | 'post_content' => 'Foo Bar', |
103 | 103 | 'post_excerpt' => 'Bar Baz', |
… |
… |
class Tests_Embed_Template extends WP_UnitTestCase { |
118 | 118 | } |
119 | 119 | |
120 | 120 | function test_oembed_output_scheduled_post() { |
121 | | $post_id = self::$factory->post->create( array( |
| 121 | $post_id = self::factory()->post->create( array( |
122 | 122 | 'post_title' => 'Hello World', |
123 | 123 | 'post_content' => 'Foo Bar', |
124 | 124 | 'post_excerpt' => 'Bar Baz', |
… |
… |
class Tests_Embed_Template extends WP_UnitTestCase { |
140 | 140 | } |
141 | 141 | |
142 | 142 | function test_oembed_output_private_post() { |
143 | | $post_id = self::$factory->post->create( array( |
| 143 | $post_id = self::factory()->post->create( array( |
144 | 144 | 'post_title' => 'Hello World', |
145 | 145 | 'post_content' => 'Foo Bar', |
146 | 146 | 'post_excerpt' => 'Bar Baz', |
… |
… |
class Tests_Embed_Template extends WP_UnitTestCase { |
161 | 161 | } |
162 | 162 | |
163 | 163 | function test_oembed_output_private_post_with_permissions() { |
164 | | $user_id = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 164 | $user_id = self::factory()->user->create( array( 'role' => 'editor' ) ); |
165 | 165 | wp_set_current_user( $user_id ); |
166 | 166 | |
167 | | $post_id = self::$factory->post->create( array( |
| 167 | $post_id = self::factory()->post->create( array( |
168 | 168 | 'post_title' => 'Hello World', |
169 | 169 | 'post_content' => 'Foo Bar', |
170 | 170 | 'post_excerpt' => 'Bar Baz', |
… |
… |
class Tests_Embed_Template extends WP_UnitTestCase { |
193 | 193 | } |
194 | 194 | |
195 | 195 | function test_wp_embed_excerpt_more() { |
196 | | $post_id = self::$factory->post->create( array( |
| 196 | $post_id = self::factory()->post->create( array( |
197 | 197 | 'post_content' => 'Foo Bar', |
198 | 198 | ) ); |
199 | 199 | |
… |
… |
class Tests_Embed_Template extends WP_UnitTestCase { |
214 | 214 | function test_is_embed_post() { |
215 | 215 | $this->assertFalse( is_embed() ); |
216 | 216 | |
217 | | $post_id = self::$factory->post->create(); |
| 217 | $post_id = self::factory()->post->create(); |
218 | 218 | $this->go_to( get_post_embed_url( $post_id ) ); |
219 | 219 | $this->assertTrue( is_embed() ); |
220 | 220 | } |
221 | 221 | |
222 | 222 | function test_is_embed_attachment() { |
223 | | $post_id = self::$factory->post->create(); |
| 223 | $post_id = self::factory()->post->create(); |
224 | 224 | $file = DIR_TESTDATA . '/images/canola.jpg'; |
225 | | $attachment_id = self::$factory->attachment->create_object( $file, $post_id, array( |
| 225 | $attachment_id = self::factory()->attachment->create_object( $file, $post_id, array( |
226 | 226 | 'post_mime_type' => 'image/jpeg', |
227 | 227 | ) ); |
228 | 228 | $this->go_to( get_post_embed_url( $attachment_id ) ); |
… |
… |
class Tests_Embed_Template extends WP_UnitTestCase { |
240 | 240 | } |
241 | 241 | |
242 | 242 | function test_get_post_embed_html() { |
243 | | $post_id = self::$factory->post->create(); |
| 243 | $post_id = self::factory()->post->create(); |
244 | 244 | |
245 | 245 | $expected = '<iframe sandbox="allow-scripts" security="restricted" src="' . esc_url( get_post_embed_url( $post_id ) ) . '" width="200" height="200" title="Embedded WordPress Post" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>'; |
246 | 246 | |
-
diff --git tests/phpunit/tests/option/multisite.php tests/phpunit/tests/option/multisite.php
index 627b655..5cde7ba 100644
|
|
class Tests_Multisite_Option extends WP_UnitTestCase { |
98 | 98 | } |
99 | 99 | |
100 | 100 | function test_with_another_site() { |
101 | | $user_id = self::$factory->user->create(); |
| 101 | $user_id = self::factory()->user->create(); |
102 | 102 | $this->assertInternalType( 'integer', $user_id ); |
103 | 103 | |
104 | | $blog_id = self::$factory->blog->create( array( |
| 104 | $blog_id = self::factory()->blog->create( array( |
105 | 105 | 'user_id' => $user_id, |
106 | 106 | 'meta' => array( |
107 | 107 | 'public' => 1, |
-
diff --git tests/phpunit/tests/option/networkOption.php tests/phpunit/tests/option/networkOption.php
index f57c796..1e0bd71 100644
|
|
if ( is_multisite() ) : |
11 | 11 | */ |
12 | 12 | class Tests_Option_NetworkOption extends WP_UnitTestCase { |
13 | 13 | function test_add_network_option_not_available_on_other_network() { |
14 | | $id = self::$factory->network->create(); |
| 14 | $id = self::factory()->network->create(); |
15 | 15 | $option = rand_str(); |
16 | 16 | $value = rand_str(); |
17 | 17 | |
… |
… |
class Tests_Option_NetworkOption extends WP_UnitTestCase { |
20 | 20 | } |
21 | 21 | |
22 | 22 | function test_add_network_option_available_on_same_network() { |
23 | | $id = self::$factory->network->create(); |
| 23 | $id = self::factory()->network->create(); |
24 | 24 | $option = rand_str(); |
25 | 25 | $value = rand_str(); |
26 | 26 | |
… |
… |
class Tests_Option_NetworkOption extends WP_UnitTestCase { |
29 | 29 | } |
30 | 30 | |
31 | 31 | function test_delete_network_option_on_only_one_network() { |
32 | | $id = self::$factory->network->create(); |
| 32 | $id = self::factory()->network->create(); |
33 | 33 | $option = rand_str(); |
34 | 34 | $value = rand_str(); |
35 | 35 | |
-
diff --git tests/phpunit/tests/option/userSettings.php tests/phpunit/tests/option/userSettings.php
index 0c0aa3d..4da33e5 100644
|
|
class Tests_User_Settings extends WP_UnitTestCase { |
5 | 5 | function setUp() { |
6 | 6 | parent::setUp(); |
7 | 7 | |
8 | | $this->user_id = self::$factory->user->create( array( |
| 8 | $this->user_id = self::factory()->user->create( array( |
9 | 9 | 'role' => 'administrator' |
10 | 10 | ) ); |
11 | 11 | |
-
diff --git tests/phpunit/tests/post.php tests/phpunit/tests/post.php
index 17a93e4..df1ab0a 100644
|
|
class Tests_Post extends WP_UnitTestCase { |
545 | 545 | function test_get_page_by_path_priority() { |
546 | 546 | global $wpdb; |
547 | 547 | |
548 | | $attachment = self::$factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) ); |
549 | | $page = self::$factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) ); |
550 | | $other_att = self::$factory->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) ); |
| 548 | $attachment = self::factory()->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) ); |
| 549 | $page = self::factory()->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) ); |
| 550 | $other_att = self::factory()->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) ); |
551 | 551 | |
552 | 552 | $wpdb->update( $wpdb->posts, array( 'post_name' => 'some-page' ), array( 'ID' => $page->ID ) ); |
553 | 553 | clean_post_cache( $page->ID ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
565 | 565 | } |
566 | 566 | |
567 | 567 | function test_wp_publish_post() { |
568 | | $draft_id = self::$factory->post->create( array( 'post_status' => 'draft' ) ); |
| 568 | $draft_id = self::factory()->post->create( array( 'post_status' => 'draft' ) ); |
569 | 569 | |
570 | 570 | $post = get_post( $draft_id ); |
571 | 571 | $this->assertEquals( 'draft', $post->post_status ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
581 | 581 | */ |
582 | 582 | function test_wp_insert_post_and_wp_publish_post_with_future_date() { |
583 | 583 | $future_date = gmdate( 'Y-m-d H:i:s', time() + 10000000 ); |
584 | | $post_id = self::$factory->post->create( array( |
| 584 | $post_id = self::factory()->post->create( array( |
585 | 585 | 'post_status' => 'publish', |
586 | 586 | 'post_date' => $future_date, |
587 | 587 | ) ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
641 | 641 | * @ticket 22883 |
642 | 642 | */ |
643 | 643 | function test_get_page_uri_with_stdclass_post_object() { |
644 | | $post_id = self::$factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) ); |
| 644 | $post_id = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) ); |
645 | 645 | |
646 | 646 | // Mimick an old stdClass post object, missing the ancestors field. |
647 | 647 | $post_array = (object) get_post( $post_id, ARRAY_A ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
664 | 664 | * @ticket 15963 |
665 | 665 | */ |
666 | 666 | function test_get_post_uri_check_orphan() { |
667 | | $parent_id = self::$factory->post->create( array( 'post_name' => 'parent' ) ); |
668 | | $child_id = self::$factory->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) ); |
| 667 | $parent_id = self::factory()->post->create( array( 'post_name' => 'parent' ) ); |
| 668 | $child_id = self::factory()->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) ); |
669 | 669 | |
670 | 670 | // check the parent for good measure |
671 | 671 | $this->assertEquals( 'parent', get_page_uri( $parent_id ) ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
683 | 683 | */ |
684 | 684 | function test_get_post_ancestors_within_loop() { |
685 | 685 | global $post; |
686 | | $parent_id = self::$factory->post->create(); |
687 | | $post = self::$factory->post->create_and_get( array( 'post_parent' => $parent_id ) ); |
| 686 | $parent_id = self::factory()->post->create(); |
| 687 | $post = self::factory()->post->create_and_get( array( 'post_parent' => $parent_id ) ); |
688 | 688 | $this->assertEquals( array( $parent_id ), get_post_ancestors( 0 ) ); |
689 | 689 | } |
690 | 690 | |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
692 | 692 | * @ticket 23474 |
693 | 693 | */ |
694 | 694 | function test_update_invalid_post_id() { |
695 | | $post_id = self::$factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) ); |
| 695 | $post_id = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) ); |
696 | 696 | $post = get_post( $post_id, ARRAY_A ); |
697 | 697 | |
698 | 698 | $post['ID'] = 123456789; |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
707 | 707 | |
708 | 708 | function test_parse_post_content_single_page() { |
709 | 709 | global $multipage, $pages, $numpages; |
710 | | $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0' ) ); |
| 710 | $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) ); |
711 | 711 | $post = get_post( $post_id ); |
712 | 712 | setup_postdata( $post ); |
713 | 713 | $this->assertEquals( 0, $multipage ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
718 | 718 | |
719 | 719 | function test_parse_post_content_multi_page() { |
720 | 720 | global $multipage, $pages, $numpages; |
721 | | $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); |
| 721 | $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); |
722 | 722 | $post = get_post( $post_id ); |
723 | 723 | setup_postdata( $post ); |
724 | 724 | $this->assertEquals( 1, $multipage ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
729 | 729 | |
730 | 730 | function test_parse_post_content_remaining_single_page() { |
731 | 731 | global $multipage, $pages, $numpages; |
732 | | $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0' ) ); |
| 732 | $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) ); |
733 | 733 | $post = get_post( $post_id ); |
734 | 734 | setup_postdata( $post ); |
735 | 735 | $this->assertEquals( 0, $multipage ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
740 | 740 | |
741 | 741 | function test_parse_post_content_remaining_multi_page() { |
742 | 742 | global $multipage, $pages, $numpages; |
743 | | $post_id = self::$factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); |
| 743 | $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); |
744 | 744 | $post = get_post( $post_id ); |
745 | 745 | setup_postdata( $post ); |
746 | 746 | $this->assertEquals( 1, $multipage ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
754 | 754 | */ |
755 | 755 | function test_parse_post_content_starting_with_nextpage() { |
756 | 756 | global $multipage, $pages, $numpages; |
757 | | $post_id = self::$factory->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); |
| 757 | $post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); |
758 | 758 | $post = get_post( $post_id ); |
759 | 759 | setup_postdata( $post ); |
760 | 760 | $this->assertEquals( 1, $multipage ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
768 | 768 | */ |
769 | 769 | function test_parse_post_content_starting_with_nextpage_multi() { |
770 | 770 | global $multipage, $pages, $numpages; |
771 | | $post_id = self::$factory->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) ); |
| 771 | $post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) ); |
772 | 772 | $post = get_post( $post_id ); |
773 | 773 | setup_postdata( $post ); |
774 | 774 | $this->assertEquals( 0, $multipage ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
809 | 809 | function test_wp_count_posts() { |
810 | 810 | $post_type = rand_str(20); |
811 | 811 | register_post_type( $post_type ); |
812 | | self::$factory->post->create( array( |
| 812 | self::factory()->post->create( array( |
813 | 813 | 'post_type' => $post_type, |
814 | 814 | 'post_author' => self::$editor_id |
815 | 815 | ) ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
822 | 822 | function test_wp_count_posts_filtered() { |
823 | 823 | $post_type = rand_str(20); |
824 | 824 | register_post_type( $post_type ); |
825 | | self::$factory->post->create_many( 3, array( |
| 825 | self::factory()->post->create_many( 3, array( |
826 | 826 | 'post_type' => $post_type, |
827 | 827 | 'post_author' => self::$editor_id |
828 | 828 | ) ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
842 | 842 | } |
843 | 843 | |
844 | 844 | function test_wp_count_posts_insert_invalidation() { |
845 | | $post_ids = self::$factory->post->create_many( 3 ); |
| 845 | $post_ids = self::factory()->post->create_many( 3 ); |
846 | 846 | $initial_counts = wp_count_posts(); |
847 | 847 | |
848 | 848 | $key = array_rand( $post_ids ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
860 | 860 | } |
861 | 861 | |
862 | 862 | function test_wp_count_posts_trash_invalidation() { |
863 | | $post_ids = self::$factory->post->create_many( 3 ); |
| 863 | $post_ids = self::factory()->post->create_many( 3 ); |
864 | 864 | $initial_counts = wp_count_posts(); |
865 | 865 | |
866 | 866 | $key = array_rand( $post_ids ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
881 | 881 | * @ticket 13771 |
882 | 882 | */ |
883 | 883 | function test_get_the_date_with_id_returns_correct_time() { |
884 | | $post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); |
| 884 | $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); |
885 | 885 | $this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) ); |
886 | 886 | } |
887 | 887 | |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
899 | 899 | * @ticket 28310 |
900 | 900 | */ |
901 | 901 | function test_get_the_time_with_id_returns_correct_time() { |
902 | | $post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); |
| 902 | $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); |
903 | 903 | $this->assertEquals( '16:35:00', get_the_time( 'H:i:s', $post_id ) ); |
904 | 904 | } |
905 | 905 | |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
917 | 917 | * @ticket 28310 |
918 | 918 | */ |
919 | 919 | function test_get_post_time_with_id_returns_correct_time() { |
920 | | $post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); |
| 920 | $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); |
921 | 921 | $this->assertEquals( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) ); |
922 | 922 | } |
923 | 923 | |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
935 | 935 | * @ticket 28310 |
936 | 936 | */ |
937 | 937 | function test_get_post_modified_time_with_id_returns_correct_time() { |
938 | | $post_id = self::$factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); |
| 938 | $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); |
939 | 939 | $this->assertEquals( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) ); |
940 | 940 | } |
941 | 941 | |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
973 | 973 | register_post_type( $post_type, array( 'taxonomies' => array( 'post_tag', $tax ) ) ); |
974 | 974 | register_taxonomy( $tax, $post_type ); |
975 | 975 | |
976 | | $post = self::$factory->post->create( array( 'post_type' => $post_type ) ); |
| 976 | $post = self::factory()->post->create( array( 'post_type' => $post_type ) ); |
977 | 977 | wp_set_object_terms( $post, rand_str(), $tax ); |
978 | 978 | |
979 | 979 | $wp_tag_cloud = wp_tag_cloud( array( |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
1015 | 1015 | |
1016 | 1016 | require_once( ABSPATH . '/wp-admin/includes/post.php' ); |
1017 | 1017 | |
1018 | | $post_id = self::$factory->post->create(); |
| 1018 | $post_id = self::factory()->post->create(); |
1019 | 1019 | |
1020 | 1020 | $data = array( |
1021 | 1021 | 'post_ID' => $post_id, |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
1043 | 1043 | * @ticket 31168 |
1044 | 1044 | */ |
1045 | 1045 | function test_wp_insert_post_default_comment_ping_status_open() { |
1046 | | $post_id = self::$factory->post->create( array( |
| 1046 | $post_id = self::factory()->post->create( array( |
1047 | 1047 | 'post_author' => self::$editor_id, |
1048 | 1048 | 'post_status' => 'public', |
1049 | 1049 | 'post_content' => rand_str(), |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
1059 | 1059 | * @ticket 31168 |
1060 | 1060 | */ |
1061 | 1061 | function test_wp_insert_post_page_default_comment_ping_status_closed() { |
1062 | | $post_id = self::$factory->post->create( array( |
| 1062 | $post_id = self::factory()->post->create( array( |
1063 | 1063 | 'post_author' => self::$editor_id, |
1064 | 1064 | 'post_status' => 'public', |
1065 | 1065 | 'post_content' => rand_str(), |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
1078 | 1078 | function test_wp_insert_post_cpt_default_comment_ping_status_open() { |
1079 | 1079 | $post_type = rand_str(20); |
1080 | 1080 | register_post_type( $post_type, array( 'supports' => array( 'comments', 'trackbacks' ) ) ); |
1081 | | $post_id = self::$factory->post->create( array( |
| 1081 | $post_id = self::factory()->post->create( array( |
1082 | 1082 | 'post_author' => self::$editor_id, |
1083 | 1083 | 'post_status' => 'public', |
1084 | 1084 | 'post_content' => rand_str(), |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
1098 | 1098 | function test_wp_insert_post_cpt_default_comment_ping_status_closed() { |
1099 | 1099 | $post_type = rand_str(20); |
1100 | 1100 | register_post_type( $post_type ); |
1101 | | $post_id = self::$factory->post->create( array( |
| 1101 | $post_id = self::factory()->post->create( array( |
1102 | 1102 | 'post_author' => self::$editor_id, |
1103 | 1103 | 'post_status' => 'public', |
1104 | 1104 | 'post_content' => rand_str(), |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
1127 | 1127 | $this->assertTrue( current_user_can( 'edit_published_posts' ) ); |
1128 | 1128 | |
1129 | 1129 | // Create a sticky post. |
1130 | | $post = self::$factory->post->create_and_get( array( |
| 1130 | $post = self::factory()->post->create_and_get( array( |
1131 | 1131 | 'post_title' => 'Will be changed', |
1132 | 1132 | 'post_content' => 'Will be changed', |
1133 | 1133 | ) ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
1156 | 1156 | */ |
1157 | 1157 | function test_user_without_publish_cannot_affect_sticky_with_edit_post() { |
1158 | 1158 | // Create a sticky post. |
1159 | | $post = self::$factory->post->create_and_get( array( |
| 1159 | $post = self::factory()->post->create_and_get( array( |
1160 | 1160 | 'post_title' => 'Will be changed', |
1161 | 1161 | 'post_content' => 'Will be changed', |
1162 | 1162 | ) ); |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
1191 | 1191 | * @ticket 32585 |
1192 | 1192 | */ |
1193 | 1193 | public function test_wp_insert_post_author_zero() { |
1194 | | $post_id = self::$factory->post->create( array( 'post_author' => 0 ) ); |
| 1194 | $post_id = self::factory()->post->create( array( 'post_author' => 0 ) ); |
1195 | 1195 | |
1196 | 1196 | $this->assertEquals( 0, get_post( $post_id )->post_author ); |
1197 | 1197 | } |
… |
… |
class Tests_Post extends WP_UnitTestCase { |
1200 | 1200 | * @ticket 32585 |
1201 | 1201 | */ |
1202 | 1202 | public function test_wp_insert_post_author_null() { |
1203 | | $post_id = self::$factory->post->create( array( 'post_author' => null ) ); |
| 1203 | $post_id = self::factory()->post->create( array( 'post_author' => null ) ); |
1204 | 1204 | |
1205 | 1205 | $this->assertEquals( self::$editor_id, get_post( $post_id )->post_author ); |
1206 | 1206 | } |
-
diff --git tests/phpunit/tests/post/filtering.php tests/phpunit/tests/post/filtering.php
index faabf28..91e79cf 100644
|
|
EOF; |
31 | 31 | no such tag |
32 | 32 | EOF; |
33 | 33 | |
34 | | $id = self::$factory->post->create( array( 'post_content' => $content ) ); |
| 34 | $id = self::factory()->post->create( array( 'post_content' => $content ) ); |
35 | 35 | $post = get_post($id); |
36 | 36 | |
37 | 37 | $this->assertEquals( $expected, $post->post_content ); |
… |
… |
EOF; |
48 | 48 | <i>italics</i> |
49 | 49 | EOF; |
50 | 50 | |
51 | | $id = self::$factory->post->create( array( 'post_content' => $content ) ); |
| 51 | $id = self::factory()->post->create( array( 'post_content' => $content ) ); |
52 | 52 | $post = get_post($id); |
53 | 53 | |
54 | 54 | $this->assertEquals( $expected, $post->post_content ); |
… |
… |
EOF; |
65 | 65 | <img src='foo' width='500' /> |
66 | 66 | EOF; |
67 | 67 | |
68 | | $id = self::$factory->post->create( array( 'post_content' => $content ) ); |
| 68 | $id = self::factory()->post->create( array( 'post_content' => $content ) ); |
69 | 69 | $post = get_post($id); |
70 | 70 | |
71 | 71 | $this->assertEquals( $expected, $post->post_content ); |
… |
… |
EOF; |
84 | 84 | <img src='foo' width='500' height='300' /> |
85 | 85 | EOF; |
86 | 86 | |
87 | | $id = self::$factory->post->create( array( 'post_content' => $content ) ); |
| 87 | $id = self::factory()->post->create( array( 'post_content' => $content ) ); |
88 | 88 | $post = get_post($id); |
89 | 89 | |
90 | 90 | $this->assertEquals( $expected, $post->post_content ); |
… |
… |
that's continued after the jump</em> |
104 | 104 | breaks the graf</p> |
105 | 105 | EOF; |
106 | 106 | |
107 | | $id = self::$factory->post->create( array( 'post_content' => $content ) ); |
| 107 | $id = self::factory()->post->create( array( 'post_content' => $content ) ); |
108 | 108 | $post = get_post($id); |
109 | 109 | |
110 | 110 | $this->assertEquals( $content, $post->post_content ); |
-
diff --git tests/phpunit/tests/post/formats.php tests/phpunit/tests/post/formats.php
index ecb9bf2..c28e19e 100644
|
|
class Tests_Post_Formats extends WP_UnitTestCase { |
9 | 9 | } |
10 | 10 | |
11 | 11 | function test_set_get_post_format_for_post() { |
12 | | $post_id = self::$factory->post->create(); |
| 12 | $post_id = self::factory()->post->create(); |
13 | 13 | |
14 | 14 | $format = get_post_format( $post_id ); |
15 | 15 | $this->assertFalse( $format ); |
… |
… |
class Tests_Post_Formats extends WP_UnitTestCase { |
37 | 37 | * @ticket 22473 |
38 | 38 | */ |
39 | 39 | function test_set_get_post_format_for_page() { |
40 | | $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 40 | $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
41 | 41 | |
42 | 42 | $format = get_post_format( $post_id ); |
43 | 43 | $this->assertFalse( $format ); |
… |
… |
class Tests_Post_Formats extends WP_UnitTestCase { |
69 | 69 | } |
70 | 70 | |
71 | 71 | function test_has_format() { |
72 | | $post_id = self::$factory->post->create(); |
| 72 | $post_id = self::factory()->post->create(); |
73 | 73 | |
74 | 74 | $this->assertFalse( has_post_format( 'standard', $post_id ) ); |
75 | 75 | $this->assertFalse( has_post_format( '', $post_id ) ); |
… |
… |
$href |
111 | 111 | |
112 | 112 | $commentary |
113 | 113 | DATA; |
114 | | $link_post_id = self::$factory->post->create( array( 'post_content' => $link ) ); |
| 114 | $link_post_id = self::factory()->post->create( array( 'post_content' => $link ) ); |
115 | 115 | $content_link = get_url_in_content( get_post_field( 'post_content', $link_post_id ) ); |
116 | 116 | $this->assertEquals( false, $content_link ); |
117 | 117 | |
118 | | $link_with_post_id = self::$factory->post->create( array( 'post_content' => $link_with_commentary ) ); |
| 118 | $link_with_post_id = self::factory()->post->create( array( 'post_content' => $link_with_commentary ) ); |
119 | 119 | $content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) ); |
120 | 120 | $this->assertEquals( false, $content_link ); |
121 | 121 | |
… |
… |
DATA; |
125 | 125 | $content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) ); |
126 | 126 | $this->assertEquals( false, $content_link ); |
127 | 127 | |
128 | | $empty_post_id = self::$factory->post->create( array( 'post_content' => '' ) ); |
| 128 | $empty_post_id = self::factory()->post->create( array( 'post_content' => '' ) ); |
129 | 129 | $content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) ); |
130 | 130 | $this->assertEquals( false, $content_link ); |
131 | 131 | |
132 | | $comm_post_id = self::$factory->post->create( array( 'post_content' => $commentary ) ); |
| 132 | $comm_post_id = self::factory()->post->create( array( 'post_content' => $commentary ) ); |
133 | 133 | $content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) ); |
134 | 134 | $this->assertEquals( false, $content_link ); |
135 | 135 | |
136 | 136 | // Now with an href |
137 | | $href_post_id = self::$factory->post->create( array( 'post_content' => $href ) ); |
| 137 | $href_post_id = self::factory()->post->create( array( 'post_content' => $href ) ); |
138 | 138 | $content_link = get_url_in_content( get_post_field( 'post_content', $href_post_id ) ); |
139 | 139 | $this->assertEquals( $link, $content_link ); |
140 | 140 | |
141 | | $href_with_post_id = self::$factory->post->create( array( 'post_content' => $href_with_commentary ) ); |
| 141 | $href_with_post_id = self::factory()->post->create( array( 'post_content' => $href_with_commentary ) ); |
142 | 142 | $content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) ); |
143 | 143 | $this->assertEquals( $link, $content_link ); |
144 | 144 | |
… |
… |
DATA; |
148 | 148 | $content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) ); |
149 | 149 | $this->assertEquals( $link, $content_link ); |
150 | 150 | |
151 | | $empty_post_id = self::$factory->post->create( array( 'post_content' => '' ) ); |
| 151 | $empty_post_id = self::factory()->post->create( array( 'post_content' => '' ) ); |
152 | 152 | $content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) ); |
153 | 153 | $this->assertEquals( false, $content_link ); |
154 | 154 | |
155 | | $comm_post_id = self::$factory->post->create( array( 'post_content' => $commentary ) ); |
| 155 | $comm_post_id = self::factory()->post->create( array( 'post_content' => $commentary ) ); |
156 | 156 | $content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) ); |
157 | 157 | $this->assertEquals( false, $content_link ); |
158 | 158 | } |
-
diff --git tests/phpunit/tests/post/getBodyClass.php tests/phpunit/tests/post/getBodyClass.php
index 1592ad1..d7b89e8 100644
|
|
class Tests_Post_GetBodyClass extends WP_UnitTestCase { |
9 | 9 | |
10 | 10 | public function setUp() { |
11 | 11 | parent::setUp(); |
12 | | $this->post_id = self::$factory->post->create(); |
| 12 | $this->post_id = self::factory()->post->create(); |
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @ticket 30883 |
17 | 17 | */ |
18 | 18 | public function test_with_utf8_category_slugs() { |
19 | | $cat_id1 = self::$factory->category->create( array( 'name' => 'Первая рубрика' ) ); |
20 | | $cat_id2 = self::$factory->category->create( array( 'name' => 'Вторая рубрика' ) ); |
21 | | $cat_id3 = self::$factory->category->create( array( 'name' => '25кадр' ) ); |
| 19 | $cat_id1 = self::factory()->category->create( array( 'name' => 'Первая рубрика' ) ); |
| 20 | $cat_id2 = self::factory()->category->create( array( 'name' => 'Вторая рубрика' ) ); |
| 21 | $cat_id3 = self::factory()->category->create( array( 'name' => '25кадр' ) ); |
22 | 22 | wp_set_post_terms( $this->post_id, array( $cat_id1, $cat_id2, $cat_id3 ), 'category' ); |
23 | 23 | |
24 | 24 | $this->go_to( home_url( "?cat=$cat_id1" ) ); |
… |
… |
class Tests_Post_GetBodyClass extends WP_UnitTestCase { |
35 | 35 | * @ticket 30883 |
36 | 36 | */ |
37 | 37 | public function test_with_utf8_tag_slugs() { |
38 | | $tag_id1 = self::$factory->tag->create( array( 'name' => 'Первая метка' ) ); |
39 | | $tag_id2 = self::$factory->tag->create( array( 'name' => 'Вторая метка' ) ); |
40 | | $tag_id3 = self::$factory->tag->create( array( 'name' => '25кадр' ) ); |
| 38 | $tag_id1 = self::factory()->tag->create( array( 'name' => 'Первая метка' ) ); |
| 39 | $tag_id2 = self::factory()->tag->create( array( 'name' => 'Вторая метка' ) ); |
| 40 | $tag_id3 = self::factory()->tag->create( array( 'name' => '25кадр' ) ); |
41 | 41 | wp_set_post_terms( $this->post_id, array( $tag_id1, $tag_id2, $tag_id3 ), 'post_tag' ); |
42 | 42 | |
43 | 43 | $tag1 = get_term( $tag_id1, 'post_tag' ); |
… |
… |
class Tests_Post_GetBodyClass extends WP_UnitTestCase { |
59 | 59 | */ |
60 | 60 | public function test_with_utf8_term_slugs() { |
61 | 61 | register_taxonomy( 'wptests_tax', 'post' ); |
62 | | $term_id1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) ); |
63 | | $term_id2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) ); |
64 | | $term_id3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) ); |
| 62 | $term_id1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) ); |
| 63 | $term_id2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) ); |
| 64 | $term_id3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) ); |
65 | 65 | wp_set_post_terms( $this->post_id, array( $term_id1, $term_id2, $term_id3 ), 'wptests_tax' ); |
66 | 66 | |
67 | 67 | $term1 = get_term( $term_id1, 'wptests_tax' ); |
-
diff --git tests/phpunit/tests/post/getPages.php tests/phpunit/tests/post/getPages.php
index a9cf113..5391815 100644
|
|
class Tests_Post_getPages extends WP_UnitTestCase { |
15 | 15 | function test_get_pages_cache() { |
16 | 16 | global $wpdb; |
17 | 17 | |
18 | | self::$factory->post->create_many( 3, array( 'post_type' => 'page' ) ); |
| 18 | self::factory()->post->create_many( 3, array( 'post_type' => 'page' ) ); |
19 | 19 | wp_cache_delete( 'last_changed', 'posts' ); |
20 | 20 | $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) ); |
21 | 21 | |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
99 | 99 | * @ticket 20376 |
100 | 100 | */ |
101 | 101 | function test_get_pages_meta() { |
102 | | $posts = self::$factory->post->create_many( 3, array( 'post_type' => 'page' ) ); |
| 102 | $posts = self::factory()->post->create_many( 3, array( 'post_type' => 'page' ) ); |
103 | 103 | add_post_meta( $posts[0], 'some-meta-key', '0' ); |
104 | 104 | add_post_meta( $posts[1], 'some-meta-key', '' ); |
105 | 105 | add_post_meta( $posts[2], 'some-meta-key', '1' ); |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
116 | 116 | $page_ids = array(); |
117 | 117 | |
118 | 118 | foreach ( range( 1, 20 ) as $i ) |
119 | | $page_ids[] = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 119 | $page_ids[] = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
120 | 120 | |
121 | 121 | $inc = array_slice( $page_ids, 0, 10 ); |
122 | 122 | sort( $inc ); |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
138 | 138 | * @ticket 9470 |
139 | 139 | */ |
140 | 140 | function test_get_pages_parent() { |
141 | | $page_id1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
142 | | $page_id2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) ); |
143 | | $page_id3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id2 ) ); |
144 | | $page_id4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) ); |
| 141 | $page_id1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 142 | $page_id2 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) ); |
| 143 | $page_id3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id2 ) ); |
| 144 | $page_id4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) ); |
145 | 145 | |
146 | 146 | $pages = get_pages( array( 'parent' => 0, 'hierarchical' => false ) ); |
147 | 147 | $this->assertEqualSets( array( $page_id1 ), wp_list_pluck( $pages, 'ID' ) ); |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
166 | 166 | * @ticket 22389 |
167 | 167 | */ |
168 | 168 | function test_wp_dropdown_pages() { |
169 | | self::$factory->post->create_many( 5, array( 'post_type' => 'page' ) ); |
| 169 | self::factory()->post->create_many( 5, array( 'post_type' => 'page' ) ); |
170 | 170 | |
171 | 171 | preg_match_all( '#<option#', wp_dropdown_pages( 'echo=0' ), $matches ); |
172 | 172 | |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
177 | 177 | * @ticket 22208 |
178 | 178 | */ |
179 | 179 | function test_get_chidren_fields_ids() { |
180 | | $post_id = self::$factory->post->create(); |
181 | | $child_ids = self::$factory->post->create_many( 5, array( 'post_parent' => $post_id ) ); |
| 180 | $post_id = self::factory()->post->create(); |
| 181 | $child_ids = self::factory()->post->create_many( 5, array( 'post_parent' => $post_id ) ); |
182 | 182 | |
183 | 183 | $post_ids = get_children( array( 'fields' => 'ids', 'post_parent' => $post_id ) ); |
184 | 184 | $this->assertEqualSets( $child_ids, $post_ids ); |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
189 | 189 | */ |
190 | 190 | function test_get_pages_hierarchical_and_no_parent() { |
191 | 191 | global $wpdb; |
192 | | $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
193 | | $page_2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
194 | | $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
195 | | $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_2 ) ); |
| 192 | $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 193 | $page_2 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
| 194 | $page_3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
| 195 | $page_4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_2 ) ); |
196 | 196 | |
197 | 197 | $pages = get_pages(); // Defaults: hierarchical = true, parent = -1 |
198 | 198 | $pages_default_args = get_pages( array( 'hierarchical' => true, 'parent' => -1 ) ); |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
218 | 218 | * @ticket 18701 |
219 | 219 | */ |
220 | 220 | public function test_get_pages_hierarchical_empty_child_of() { |
221 | | $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
222 | | $page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
223 | | $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
224 | | $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
| 221 | $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 222 | $page_2 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 223 | $page_3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
| 224 | $page_4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
225 | 225 | |
226 | 226 | $pages = get_pages(); // Defaults: hierarchical = true, child_of = '', parent = -1 |
227 | 227 | $default_args = get_pages( array( |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
252 | 252 | * @ticket 18701 |
253 | 253 | */ |
254 | 254 | public function test_get_pages_non_hierarchical_empty_child_of() { |
255 | | $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
256 | | $page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
257 | | $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
258 | | $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
| 255 | $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 256 | $page_2 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 257 | $page_3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
| 258 | $page_4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
259 | 259 | |
260 | 260 | $pages = get_pages( array( 'hierarchical' => false ) ); // child_of = '', parent = -1 |
261 | 261 | |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
278 | 278 | * @ticket 18701 |
279 | 279 | */ |
280 | 280 | public function test_get_pages_hierarchical_non_empty_child_of() { |
281 | | $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
282 | | $page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
283 | | $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
284 | | $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) ); |
285 | | $page_5 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
| 281 | $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 282 | $page_2 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 283 | $page_3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
| 284 | $page_4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) ); |
| 285 | $page_5 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
286 | 286 | |
287 | 287 | $pages = get_pages( array( 'child_of' => $page_1 ) ); // Defaults: hierarchical = true, parent = -1. |
288 | 288 | |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
306 | 306 | * @ticket 18701 |
307 | 307 | */ |
308 | 308 | public function test_get_pages_non_hierarchical_non_empty_child_of() { |
309 | | $page_1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
310 | | $page_2 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
311 | | $page_3 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
312 | | $page_4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) ); |
313 | | $page_5 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
| 309 | $page_1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 310 | $page_2 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 311 | $page_3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
| 312 | $page_4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) ); |
| 313 | $page_5 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
314 | 314 | |
315 | 315 | $pages = get_pages( array( 'hierarchical' => false, 'child_of' => $page_1 ) ); |
316 | 316 | |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
338 | 338 | $type = 'taco'; |
339 | 339 | register_post_type( $type, array( 'hierarchical' => true, 'public' => true ) ); |
340 | 340 | |
341 | | $posts = self::$factory->post->create_many( 2, array( 'post_type' => $type ) ); |
| 341 | $posts = self::factory()->post->create_many( 2, array( 'post_type' => $type ) ); |
342 | 342 | $post_id = reset( $posts ); |
343 | 343 | |
344 | 344 | $this->go_to( "/?p=$post_id&post_type=$type" ); |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
360 | 360 | } |
361 | 361 | |
362 | 362 | function test_exclude_tree() { |
363 | | $post_id1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
364 | | $post_id2 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id1 ) ); |
365 | | $post_id3 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
366 | | $post_id4 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id3 ) ); |
| 363 | $post_id1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 364 | $post_id2 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id1 ) ); |
| 365 | $post_id3 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 366 | $post_id4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id3 ) ); |
367 | 367 | |
368 | 368 | $all = get_pages(); |
369 | 369 | |
… |
… |
class Tests_Post_getPages extends WP_UnitTestCase { |
384 | 384 | $exclude5 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) ); |
385 | 385 | $this->assertCount( 0, $exclude5 ); |
386 | 386 | |
387 | | $post_id5 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
388 | | $post_id6 = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id5 ) ); |
| 387 | $post_id5 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 388 | $post_id6 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id5 ) ); |
389 | 389 | |
390 | 390 | $exclude6 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) ); |
391 | 391 | $this->assertCount( 2, $exclude6 ); |
-
diff --git tests/phpunit/tests/post/getPostClass.php tests/phpunit/tests/post/getPostClass.php
index 81b96fa..3337114 100644
|
|
class Tests_Post_GetPostClass extends WP_UnitTestCase { |
9 | 9 | |
10 | 10 | public function setUp() { |
11 | 11 | parent::setUp(); |
12 | | $this->post_id = self::$factory->post->create(); |
| 12 | $this->post_id = self::factory()->post->create(); |
13 | 13 | } |
14 | 14 | |
15 | 15 | public function test_with_tags() { |
… |
… |
class Tests_Post_GetPostClass extends WP_UnitTestCase { |
22 | 22 | } |
23 | 23 | |
24 | 24 | public function test_with_categories() { |
25 | | $cats = self::$factory->category->create_many( 2 ); |
| 25 | $cats = self::factory()->category->create_many( 2 ); |
26 | 26 | wp_set_post_terms( $this->post_id, $cats, 'category' ); |
27 | 27 | |
28 | 28 | $cat0 = get_term( $cats[0], 'category' ); |
… |
… |
class Tests_Post_GetPostClass extends WP_UnitTestCase { |
57 | 57 | * @ticket 30883 |
58 | 58 | */ |
59 | 59 | public function test_with_utf8_category_slugs() { |
60 | | $cat_id1 = self::$factory->category->create( array( 'name' => 'Первая рубрика' ) ); |
61 | | $cat_id2 = self::$factory->category->create( array( 'name' => 'Вторая рубрика' ) ); |
62 | | $cat_id3 = self::$factory->category->create( array( 'name' => '25кадр' ) ); |
| 60 | $cat_id1 = self::factory()->category->create( array( 'name' => 'Первая рубрика' ) ); |
| 61 | $cat_id2 = self::factory()->category->create( array( 'name' => 'Вторая рубрика' ) ); |
| 62 | $cat_id3 = self::factory()->category->create( array( 'name' => '25кадр' ) ); |
63 | 63 | wp_set_post_terms( $this->post_id, array( $cat_id1, $cat_id2, $cat_id3 ), 'category' ); |
64 | 64 | |
65 | 65 | $found = get_post_class( '', $this->post_id ); |
… |
… |
class Tests_Post_GetPostClass extends WP_UnitTestCase { |
73 | 73 | * @ticket 30883 |
74 | 74 | */ |
75 | 75 | public function test_with_utf8_tag_slugs() { |
76 | | $tag_id1 = self::$factory->tag->create( array( 'name' => 'Первая метка' ) ); |
77 | | $tag_id2 = self::$factory->tag->create( array( 'name' => 'Вторая метка' ) ); |
78 | | $tag_id3 = self::$factory->tag->create( array( 'name' => '25кадр' ) ); |
| 76 | $tag_id1 = self::factory()->tag->create( array( 'name' => 'Первая метка' ) ); |
| 77 | $tag_id2 = self::factory()->tag->create( array( 'name' => 'Вторая метка' ) ); |
| 78 | $tag_id3 = self::factory()->tag->create( array( 'name' => '25кадр' ) ); |
79 | 79 | wp_set_post_terms( $this->post_id, array( $tag_id1, $tag_id2, $tag_id3 ), 'post_tag' ); |
80 | 80 | |
81 | 81 | $found = get_post_class( '', $this->post_id ); |
… |
… |
class Tests_Post_GetPostClass extends WP_UnitTestCase { |
90 | 90 | */ |
91 | 91 | public function test_with_utf8_term_slugs() { |
92 | 92 | register_taxonomy( 'wptests_tax', 'post' ); |
93 | | $term_id1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) ); |
94 | | $term_id2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) ); |
95 | | $term_id3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) ); |
| 93 | $term_id1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Первая метка' ) ); |
| 94 | $term_id2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Вторая метка' ) ); |
| 95 | $term_id3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => '25кадр' ) ); |
96 | 96 | wp_set_post_terms( $this->post_id, array( $term_id1, $term_id2, $term_id3 ), 'wptests_tax' ); |
97 | 97 | |
98 | 98 | $found = get_post_class( '', $this->post_id ); |
-
diff --git tests/phpunit/tests/post/getPostsByAuthorSql.php tests/phpunit/tests/post/getPostsByAuthorSql.php
index 0d0ff40..6ae8162 100644
|
|
class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { |
59 | 59 | |
60 | 60 | public function test_public_only_true_should_not_allow_any_private_posts_for_loggedin_user(){ |
61 | 61 | $current_user = get_current_user_id(); |
62 | | $u = self::$factory->user->create(); |
| 62 | $u = self::factory()->user->create(); |
63 | 63 | wp_set_current_user( $u ); |
64 | 64 | |
65 | 65 | $maybe_string = get_posts_by_author_sql( 'post', true, $u, true ); |
… |
… |
class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { |
70 | 70 | |
71 | 71 | public function test_public_only_should_default_to_false(){ |
72 | 72 | $current_user = get_current_user_id(); |
73 | | $u = self::$factory->user->create(); |
| 73 | $u = self::factory()->user->create(); |
74 | 74 | wp_set_current_user( $u ); |
75 | 75 | |
76 | 76 | $this->assertSame( get_posts_by_author_sql( 'post', true, $u, false ), get_posts_by_author_sql( 'post', true, $u ) ); |
… |
… |
class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { |
80 | 80 | |
81 | 81 | public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_current_user_matches_post_author(){ |
82 | 82 | $current_user = get_current_user_id(); |
83 | | $u = self::$factory->user->create(); |
| 83 | $u = self::factory()->user->create(); |
84 | 84 | wp_set_current_user( $u ); |
85 | 85 | |
86 | 86 | $maybe_string = get_posts_by_author_sql( 'post', true, $u, false ); |
… |
… |
class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { |
91 | 91 | |
92 | 92 | public function test_public_only_false_should_not_allow_access_to_private_posts_if_current_user_is_not_post_author(){ |
93 | 93 | $current_user = get_current_user_id(); |
94 | | $u1 = self::$factory->user->create(); |
95 | | $u2 = self::$factory->user->create(); |
| 94 | $u1 = self::factory()->user->create(); |
| 95 | $u2 = self::factory()->user->create(); |
96 | 96 | wp_set_current_user( $u1 ); |
97 | 97 | |
98 | 98 | $maybe_string = get_posts_by_author_sql( 'post', true, $u2, false ); |
… |
… |
class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { |
103 | 103 | |
104 | 104 | public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_post_author_is_not_provided(){ |
105 | 105 | $current_user = get_current_user_id(); |
106 | | $u = self::$factory->user->create(); |
| 106 | $u = self::factory()->user->create(); |
107 | 107 | wp_set_current_user( $u ); |
108 | 108 | |
109 | 109 | $maybe_string = get_posts_by_author_sql( 'post', true, $u, false ); |
… |
… |
class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { |
115 | 115 | |
116 | 116 | public function test_administrator_should_have_access_to_private_posts_when_public_only_is_false(){ |
117 | 117 | $current_user = get_current_user_id(); |
118 | | $u = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 118 | $u = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
119 | 119 | wp_set_current_user( $u ); |
120 | 120 | |
121 | 121 | $maybe_string = get_posts_by_author_sql( 'post', true, null, false ); |
… |
… |
class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { |
130 | 130 | register_post_type( 'bar', array( 'capabilities' => array( 'read_private_posts' => 'read_private_bar' ) ) ); |
131 | 131 | register_post_type( 'baz', array( 'capabilities' => array( 'read_private_posts' => 'read_private_baz' ) ) ); |
132 | 132 | $current_user = get_current_user_id(); |
133 | | $u = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 133 | $u = self::factory()->user->create( array( 'role' => 'editor' ) ); |
134 | 134 | $editor_role = get_role('editor'); |
135 | 135 | $editor_role->add_cap( 'read_private_baz' ); |
136 | 136 | wp_set_current_user( $u ); |
-
diff --git tests/phpunit/tests/post/listPages.php tests/phpunit/tests/post/listPages.php
index 2b89bb2..400d106 100644
|
|
class Tests_List_Pages extends WP_UnitTestCase { |
27 | 27 | global $wpdb; |
28 | 28 | $wpdb->query( 'TRUNCATE ' . $wpdb->prefix . 'posts' ); |
29 | 29 | $pages = array(); |
30 | | self::$factory->user->create(); |
31 | | $pages[] = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1' ) ); |
32 | | $pages[] = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2' ) ); |
33 | | $pages[] = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2' ) ); |
| 30 | self::factory()->user->create(); |
| 31 | $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1' ) ); |
| 32 | $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2' ) ); |
| 33 | $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2' ) ); |
34 | 34 | |
35 | 35 | foreach ( $pages as $page ) { |
36 | | $this->pages[$page] = self::$factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1' ) ); |
37 | | $this->pages[$page] = self::$factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2' ) ); |
38 | | $this->pages[$page] = self::$factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3' ) ); |
| 36 | $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1' ) ); |
| 37 | $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2' ) ); |
| 38 | $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3' ) ); |
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
-
diff --git tests/phpunit/tests/post/meta.php tests/phpunit/tests/post/meta.php
index e4e4d35..7ca095f 100644
|
|
class Tests_Post_Meta extends WP_UnitTestCase { |
8 | 8 | function setUp() { |
9 | 9 | parent::setUp(); |
10 | 10 | |
11 | | $this->author = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) ); |
| 11 | $this->author = new WP_User( self::factory()->user->create( array( 'role' => 'editor' ) ) ); |
12 | 12 | |
13 | 13 | $post = array( |
14 | 14 | 'post_author' => $this->author->ID, |
-
diff --git tests/phpunit/tests/post/nav-menu.php tests/phpunit/tests/post/nav-menu.php
index 40ac706..5ca95b6 100644
|
|
class Test_Nav_Menus extends WP_UnitTestCase { |
16 | 16 | } |
17 | 17 | |
18 | 18 | function test_wp_get_associated_nav_menu_items() { |
19 | | $tag_id = self::$factory->tag->create(); |
20 | | $cat_id = self::$factory->category->create(); |
21 | | $post_id = self::$factory->post->create(); |
22 | | $post_2_id = self::$factory->post->create(); |
23 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 19 | $tag_id = self::factory()->tag->create(); |
| 20 | $cat_id = self::factory()->category->create(); |
| 21 | $post_id = self::factory()->post->create(); |
| 22 | $post_2_id = self::factory()->post->create(); |
| 23 | $page_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
24 | 24 | |
25 | 25 | $tag_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( |
26 | 26 | 'menu-item-type' => 'taxonomy', |
… |
… |
class Test_Nav_Menus extends WP_UnitTestCase { |
119 | 119 | |
120 | 120 | public function test_wp_get_nav_menu_items_with_taxonomy_term() { |
121 | 121 | register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); |
122 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
123 | | $child_terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', 'parent' => $t ) ); |
| 122 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 123 | $child_terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', 'parent' => $t ) ); |
124 | 124 | |
125 | 125 | $term_menu_item = wp_update_nav_menu_item( $this->menu_id, 0, array( |
126 | 126 | 'menu-item-type' => 'taxonomy', |
-
diff --git tests/phpunit/tests/post/objects.php tests/phpunit/tests/post/objects.php
index 048e6b8..5ad92c6 100644
|
|
|
6 | 6 | class Tests_Post_Objects extends WP_UnitTestCase { |
7 | 7 | |
8 | 8 | function test_get_post() { |
9 | | $id = self::$factory->post->create(); |
| 9 | $id = self::factory()->post->create(); |
10 | 10 | |
11 | 11 | $post = get_post( $id ); |
12 | 12 | $this->assertInstanceOf( 'WP_Post', $post ); |
… |
… |
class Tests_Post_Objects extends WP_UnitTestCase { |
67 | 67 | } |
68 | 68 | |
69 | 69 | function test_get_post_ancestors() { |
70 | | $parent_id = self::$factory->post->create(); |
71 | | $child_id = self::$factory->post->create(); |
72 | | $grandchild_id = self::$factory->post->create(); |
| 70 | $parent_id = self::factory()->post->create(); |
| 71 | $child_id = self::factory()->post->create(); |
| 72 | $grandchild_id = self::factory()->post->create(); |
73 | 73 | $updated = wp_update_post( array( 'ID' => $child_id, 'post_parent' => $parent_id ) ); |
74 | 74 | $this->assertEquals( $updated, $child_id ); |
75 | 75 | $updated = wp_update_post( array( 'ID' => $grandchild_id, 'post_parent' => $child_id ) ); |
… |
… |
class Tests_Post_Objects extends WP_UnitTestCase { |
99 | 99 | } |
100 | 100 | |
101 | 101 | function test_get_post_category_property() { |
102 | | $post_id = self::$factory->post->create(); |
| 102 | $post_id = self::factory()->post->create(); |
103 | 103 | $post = get_post( $post_id ); |
104 | 104 | |
105 | 105 | $this->assertInternalType( 'array', $post->post_category ); |
… |
… |
class Tests_Post_Objects extends WP_UnitTestCase { |
118 | 118 | } |
119 | 119 | |
120 | 120 | function test_get_tags_input_property() { |
121 | | $post_id = self::$factory->post->create(); |
| 121 | $post_id = self::factory()->post->create(); |
122 | 122 | $post = get_post( $post_id ); |
123 | 123 | |
124 | 124 | $this->assertInternalType( 'array', $post->tags_input ); |
… |
… |
class Tests_Post_Objects extends WP_UnitTestCase { |
135 | 135 | } |
136 | 136 | |
137 | 137 | function test_get_page_template_property() { |
138 | | $post_id = self::$factory->post->create(); |
| 138 | $post_id = self::factory()->post->create(); |
139 | 139 | $post = get_post( $post_id ); |
140 | 140 | |
141 | 141 | $this->assertInternalType( 'string', $post->page_template ); |
… |
… |
class Tests_Post_Objects extends WP_UnitTestCase { |
155 | 155 | } |
156 | 156 | |
157 | 157 | function test_get_post_filter() { |
158 | | $post = get_post( self::$factory->post->create( array( |
| 158 | $post = get_post( self::factory()->post->create( array( |
159 | 159 | 'post_title' => "Mary's home" |
160 | 160 | ) ) ); |
161 | 161 | |
… |
… |
class Tests_Post_Objects extends WP_UnitTestCase { |
178 | 178 | } |
179 | 179 | |
180 | 180 | function test_get_post_identity() { |
181 | | $post = get_post( self::$factory->post->create() ); |
| 181 | $post = get_post( self::factory()->post->create() ); |
182 | 182 | |
183 | 183 | $post->foo = 'bar'; |
184 | 184 | |
… |
… |
class Tests_Post_Objects extends WP_UnitTestCase { |
187 | 187 | } |
188 | 188 | |
189 | 189 | function test_get_post_array() { |
190 | | $id = self::$factory->post->create(); |
| 190 | $id = self::factory()->post->create(); |
191 | 191 | |
192 | 192 | $post = get_post( $id, ARRAY_A ); |
193 | 193 | |
… |
… |
class Tests_Post_Objects extends WP_UnitTestCase { |
202 | 202 | function test_get_post_cache() { |
203 | 203 | global $wpdb; |
204 | 204 | |
205 | | $id = self::$factory->post->create(); |
| 205 | $id = self::factory()->post->create(); |
206 | 206 | wp_cache_delete( $id, 'posts' ); |
207 | 207 | |
208 | 208 | // get_post( stdClass ) should not prime the cache |
-
diff --git tests/phpunit/tests/post/output.php tests/phpunit/tests/post/output.php
index d3c0fb4..52c3eff 100644
|
|
class Tests_Post_Output extends WP_UnitTestCase { |
41 | 41 | This is the <b>body</b>. |
42 | 42 | EOF; |
43 | 43 | |
44 | | $post_id = self::$factory->post->create( compact( 'post_content' ) ); |
| 44 | $post_id = self::factory()->post->create( compact( 'post_content' ) ); |
45 | 45 | |
46 | 46 | $expected = <<<EOF |
47 | 47 | <p><i>This is the excerpt.</i><br /> |
… |
… |
baz = bar |
76 | 76 | |
77 | 77 | EOF; |
78 | 78 | |
79 | | $post_id = self::$factory->post->create( compact( 'post_content' ) ); |
| 79 | $post_id = self::factory()->post->create( compact( 'post_content' ) ); |
80 | 80 | $this->go_to( get_permalink( $post_id ) ); |
81 | 81 | $this->assertTrue( is_single() ); |
82 | 82 | $this->assertTrue( have_posts() ); |
… |
… |
EOF; |
114 | 114 | |
115 | 115 | EOF; |
116 | 116 | |
117 | | $post_id = self::$factory->post->create( compact( 'post_content' ) ); |
| 117 | $post_id = self::factory()->post->create( compact( 'post_content' ) ); |
118 | 118 | $this->go_to( get_permalink( $post_id ) ); |
119 | 119 | $this->assertTrue( is_single() ); |
120 | 120 | $this->assertTrue( have_posts() ); |
… |
… |
EOF; |
136 | 136 | <p><span class="Z3988" title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.aulast=Mariat&rft.aufirst=Denis&rft. au=Denis+Mariat&rft.au=Sead+Taourit&rft.au=G%C3%A9rard+Gu%C3%A9rin& rft.title=Genetics+Selection+Evolution&rft.atitle=&rft.date=2003&rft. volume=35&rft.issue=1&rft.spage=119&rft.epage=133&rft.genre=article& rft.id=info:DOI/10.1051%2Fgse%3A2002039"></span>Mariat, D., Taourit, S., Guérin, G. (2003). . <span style="font-style: italic">Genetics Selection Evolution, 35</span>(1), 119-133. DOI: <a rev="review" href="http://dx.doi.org/10.1051/gse:2002039">10.1051/gse:2002039</a></p> |
137 | 137 | EOF; |
138 | 138 | |
139 | | $post_id = self::$factory->post->create( compact( 'post_content' ) ); |
| 139 | $post_id = self::factory()->post->create( compact( 'post_content' ) ); |
140 | 140 | $this->go_to( get_permalink( $post_id ) ); |
141 | 141 | $this->assertTrue( is_single() ); |
142 | 142 | $this->assertTrue( have_posts() ); |
… |
… |
EOF; |
160 | 160 | <p><span title="My friends: Alice, Bob and Carol">foo</span></p> |
161 | 161 | EOF; |
162 | 162 | |
163 | | $post_id = self::$factory->post->create( compact( 'post_content' ) ); |
| 163 | $post_id = self::factory()->post->create( compact( 'post_content' ) ); |
164 | 164 | $this->go_to( get_permalink( $post_id ) ); |
165 | 165 | $this->assertTrue( is_single() ); |
166 | 166 | $this->assertTrue( have_posts() ); |
-
diff --git tests/phpunit/tests/post/query.php tests/phpunit/tests/post/query.php
index 5b86d21..bc0e865 100644
|
|
class Tests_Post_Query extends WP_UnitTestCase { |
11 | 11 | function test_category__and_var() { |
12 | 12 | $q = new WP_Query(); |
13 | 13 | |
14 | | $term_id = self::$factory->category->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) ); |
15 | | $term_id2 = self::$factory->category->create( array( 'slug' => 'hoo', 'name' => 'HOO!' ) ); |
16 | | $post_id = self::$factory->post->create(); |
| 14 | $term_id = self::factory()->category->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) ); |
| 15 | $term_id2 = self::factory()->category->create( array( 'slug' => 'hoo', 'name' => 'HOO!' ) ); |
| 16 | $post_id = self::factory()->post->create(); |
17 | 17 | |
18 | 18 | wp_set_post_categories( $post_id, $term_id ); |
19 | 19 | |
… |
… |
class Tests_Post_Query extends WP_UnitTestCase { |
41 | 41 | * @group taxonomy |
42 | 42 | */ |
43 | 43 | function test_empty_category__in() { |
44 | | $cat_id = self::$factory->category->create(); |
45 | | $post_id = self::$factory->post->create(); |
| 44 | $cat_id = self::factory()->category->create(); |
| 45 | $post_id = self::factory()->post->create(); |
46 | 46 | wp_set_post_categories( $post_id, $cat_id ); |
47 | 47 | |
48 | 48 | $q1 = get_posts( array( 'category__in' => array( $cat_id ) ) ); |
… |
… |
class Tests_Post_Query extends WP_UnitTestCase { |
71 | 71 | */ |
72 | 72 | function test_the_posts_filter() { |
73 | 73 | // Create posts and clear their caches. |
74 | | $post_ids = self::$factory->post->create_many( 4 ); |
| 74 | $post_ids = self::factory()->post->create_many( 4 ); |
75 | 75 | foreach ( $post_ids as $post_id ) |
76 | 76 | clean_post_cache( $post_id ); |
77 | 77 | |
… |
… |
class Tests_Post_Query extends WP_UnitTestCase { |
115 | 115 | } |
116 | 116 | |
117 | 117 | function test_post__in_ordering() { |
118 | | $post_id1 = self::$factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) ); |
119 | | $post_id2 = self::$factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) ); |
120 | | $post_id3 = self::$factory->post->create( array( |
| 118 | $post_id1 = self::factory()->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) ); |
| 119 | $post_id2 = self::factory()->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) ); |
| 120 | $post_id3 = self::factory()->post->create( array( |
121 | 121 | 'post_type' => 'page', |
122 | 122 | 'post_parent' => $post_id2, |
123 | 123 | 'menu_order' => rand( 1, 100 ) |
124 | 124 | ) ); |
125 | | $post_id4 = self::$factory->post->create( array( |
| 125 | $post_id4 = self::factory()->post->create( array( |
126 | 126 | 'post_type' => 'page', |
127 | 127 | 'post_parent' => $post_id2, |
128 | 128 | 'menu_order' => rand( 1, 100 ) |
129 | 129 | ) ); |
130 | | $post_id5 = self::$factory->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) ); |
| 130 | $post_id5 = self::factory()->post->create( array( 'post_type' => 'page', 'menu_order' => rand( 1, 100 ) ) ); |
131 | 131 | |
132 | 132 | $ordered = array( $post_id2, $post_id4, $post_id3, $post_id1, $post_id5 ); |
133 | 133 | |
… |
… |
class Tests_Post_Query extends WP_UnitTestCase { |
140 | 140 | } |
141 | 141 | |
142 | 142 | function test_post__in_attachment_ordering() { |
143 | | $post_id = self::$factory->post->create(); |
| 143 | $post_id = self::factory()->post->create(); |
144 | 144 | $att_ids = array(); |
145 | 145 | $file = DIR_TESTDATA . '/images/canola.jpg'; |
146 | | $att_ids[1] = self::$factory->attachment->create_object( $file, $post_id, array( |
| 146 | $att_ids[1] = self::factory()->attachment->create_object( $file, $post_id, array( |
147 | 147 | 'post_mime_type' => 'image/jpeg', |
148 | 148 | 'menu_order' => rand( 1, 100 ) |
149 | 149 | ) ); |
150 | | $att_ids[2] = self::$factory->attachment->create_object( $file, $post_id, array( |
| 150 | $att_ids[2] = self::factory()->attachment->create_object( $file, $post_id, array( |
151 | 151 | 'post_mime_type' => 'image/jpeg', |
152 | 152 | 'menu_order' => rand( 1, 100 ) |
153 | 153 | ) ); |
154 | | $att_ids[3] = self::$factory->attachment->create_object( $file, $post_id, array( |
| 154 | $att_ids[3] = self::factory()->attachment->create_object( $file, $post_id, array( |
155 | 155 | 'post_mime_type' => 'image/jpeg', |
156 | 156 | 'menu_order' => rand( 1, 100 ) |
157 | 157 | ) ); |
158 | | $att_ids[4] = self::$factory->attachment->create_object( $file, $post_id, array( |
| 158 | $att_ids[4] = self::factory()->attachment->create_object( $file, $post_id, array( |
159 | 159 | 'post_mime_type' => 'image/jpeg', |
160 | 160 | 'menu_order' => rand( 1, 100 ) |
161 | 161 | ) ); |
162 | | $att_ids[5] = self::$factory->attachment->create_object( $file, $post_id, array( |
| 162 | $att_ids[5] = self::factory()->attachment->create_object( $file, $post_id, array( |
163 | 163 | 'post_mime_type' => 'image/jpeg', |
164 | 164 | 'menu_order' => rand( 1, 100 ) |
165 | 165 | ) ); |
… |
… |
class Tests_Post_Query extends WP_UnitTestCase { |
311 | 311 | public function test_post_name__in() { |
312 | 312 | $q = new WP_Query(); |
313 | 313 | |
314 | | $post_ids[0] = self::$factory->post->create( array( 'post_title' => 'woo', 'post_date' => '2015-07-23 00:00:00' ) ); |
315 | | $post_ids[1] = self::$factory->post->create( array( 'post_title' => 'hoo', 'post_date' => '2015-07-23 00:00:00' ) ); |
316 | | $post_ids[2] = self::$factory->post->create( array( 'post_title' => 'test', 'post_date' => '2015-07-23 00:00:00' ) ); |
317 | | $post_ids[3] = self::$factory->post->create( array( 'post_title' => 'me', 'post_date' => '2015-07-23 00:00:00' ) ); |
| 314 | $post_ids[0] = self::factory()->post->create( array( 'post_title' => 'woo', 'post_date' => '2015-07-23 00:00:00' ) ); |
| 315 | $post_ids[1] = self::factory()->post->create( array( 'post_title' => 'hoo', 'post_date' => '2015-07-23 00:00:00' ) ); |
| 316 | $post_ids[2] = self::factory()->post->create( array( 'post_title' => 'test', 'post_date' => '2015-07-23 00:00:00' ) ); |
| 317 | $post_ids[3] = self::factory()->post->create( array( 'post_title' => 'me', 'post_date' => '2015-07-23 00:00:00' ) ); |
318 | 318 | |
319 | 319 | $requested = array( $post_ids[0], $post_ids[3] ); |
320 | 320 | $q->query( array( |
-
diff --git tests/phpunit/tests/post/revisions.php tests/phpunit/tests/post/revisions.php
index aaba1e2..2c97232 100644
|
|
class Tests_Post_Revisions extends WP_UnitTestCase { |
144 | 144 | * @ticket 16847 |
145 | 145 | */ |
146 | 146 | function test_revision_view_caps_post() { |
147 | | $post_id = self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) ); |
| 147 | $post_id = self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) ); |
148 | 148 | wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); |
149 | 149 | |
150 | 150 | $revisions = wp_get_post_revisions( $post_id ); |
… |
… |
class Tests_Post_Revisions extends WP_UnitTestCase { |
166 | 166 | * @ticket 16847 |
167 | 167 | */ |
168 | 168 | function test_revision_restore_caps_post() { |
169 | | $post_id = self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) ); |
| 169 | $post_id = self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) ); |
170 | 170 | wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); |
171 | 171 | |
172 | 172 | $revisions = wp_get_post_revisions( $post_id ); |
… |
… |
class Tests_Post_Revisions extends WP_UnitTestCase { |
186 | 186 | * @ticket 16847 |
187 | 187 | */ |
188 | 188 | function test_revision_diff_caps_post() { |
189 | | $post_id = self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) ); |
| 189 | $post_id = self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => self::$editor_user_id ) ); |
190 | 190 | wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); |
191 | 191 | wp_update_post( array( 'post_content' => 'This content is even better', 'ID' => $post_id ) ); |
192 | 192 | |
… |
… |
class Tests_Post_Revisions extends WP_UnitTestCase { |
214 | 214 | 'supports' => array( 'revisions' ), |
215 | 215 | ) ); |
216 | 216 | |
217 | | $post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) ); |
| 217 | $post_id = self::factory()->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) ); |
218 | 218 | wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); |
219 | 219 | |
220 | 220 | $revisions = wp_get_post_revisions( $post_id ); |
… |
… |
class Tests_Post_Revisions extends WP_UnitTestCase { |
247 | 247 | $editor_user->add_cap( 'edit_published_events' ); |
248 | 248 | |
249 | 249 | //create a post as Editor |
250 | | $post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) ); |
| 250 | $post_id = self::factory()->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) ); |
251 | 251 | wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); |
252 | 252 | |
253 | 253 | $revisions = wp_get_post_revisions( $post_id ); |
… |
… |
class Tests_Post_Revisions extends WP_UnitTestCase { |
282 | 282 | $old_id = get_current_user_id(); |
283 | 283 | wp_set_current_user( self::$editor_user_id ); |
284 | 284 | |
285 | | $post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_status' => 'draft' ) ); |
| 285 | $post_id = self::factory()->post->create( array( 'post_type' => $this->post_type, 'post_status' => 'draft' ) ); |
286 | 286 | wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); |
287 | 287 | |
288 | 288 | $revisions = wp_get_post_revisions( $post_id ); |
… |
… |
class Tests_Post_Revisions extends WP_UnitTestCase { |
314 | 314 | 'supports' => array( 'revisions' ), |
315 | 315 | ) ); |
316 | 316 | |
317 | | $post_id = self::$factory->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) ); |
| 317 | $post_id = self::factory()->post->create( array( 'post_type' => $this->post_type, 'post_author' => self::$editor_user_id ) ); |
318 | 318 | wp_update_post( array( 'post_content' => 'This content is much better', 'ID' => $post_id ) ); |
319 | 319 | wp_update_post( array( 'post_content' => 'This content is even better', 'ID' => $post_id ) ); |
320 | 320 | |
… |
… |
class Tests_Post_Revisions extends WP_UnitTestCase { |
337 | 337 | function test_wp_get_post_revisions_should_order_by_post_date() { |
338 | 338 | global $wpdb; |
339 | 339 | |
340 | | $post = self::$factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) ); |
| 340 | $post = self::factory()->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) ); |
341 | 341 | |
342 | 342 | $post = (array) $post; |
343 | 343 | $post_revision_fields = _wp_post_revision_fields( $post ); |
… |
… |
class Tests_Post_Revisions extends WP_UnitTestCase { |
365 | 365 | * @ticket 26042 |
366 | 366 | */ |
367 | 367 | function test_wp_get_post_revisions_should_order_by_ID_when_post_date_matches() { |
368 | | $post = self::$factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) ); |
| 368 | $post = self::factory()->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) ); |
369 | 369 | |
370 | 370 | $post = (array) $post; |
371 | 371 | $post_revision_fields = _wp_post_revision_fields( $post ); |
-
diff --git tests/phpunit/tests/post/slashes.php tests/phpunit/tests/post/slashes.php
index 0d3465f..f421141 100644
|
|
|
8 | 8 | class Tests_Post_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 | |
… |
… |
class Tests_Post_Slashes extends WP_UnitTestCase { |
33 | 33 | * |
34 | 34 | */ |
35 | 35 | function test_edit_post() { |
36 | | $id = self::$factory->post->create(); |
| 36 | $id = self::factory()->post->create(); |
37 | 37 | |
38 | 38 | $_POST = array(); |
39 | 39 | $_POST['post_ID'] = $id; |
… |
… |
class Tests_Post_Slashes extends WP_UnitTestCase { |
102 | 102 | * |
103 | 103 | */ |
104 | 104 | function test_wp_update_post() { |
105 | | $id = self::$factory->post->create(); |
| 105 | $id = self::factory()->post->create(); |
106 | 106 | |
107 | 107 | wp_update_post(array( |
108 | 108 | 'ID' => $id, |
-
diff --git tests/phpunit/tests/post/template.php tests/phpunit/tests/post/template.php
index 89b214f..0edf607 100644
|
|
class Tests_Post_Template extends WP_UnitTestCase { |
8 | 8 | function test_wp_link_pages() { |
9 | 9 | $contents = array( 'One', 'Two', 'Three' ); |
10 | 10 | $content = join( '<!--nextpage-->', $contents ); |
11 | | $post_id = self::$factory->post->create( array( 'post_content' => $content ) ); |
| 11 | $post_id = self::factory()->post->create( array( 'post_content' => $content ) ); |
12 | 12 | |
13 | 13 | $this->go_to( '?p=' . $post_id ); |
14 | 14 | |
… |
… |
class Tests_Post_Template extends WP_UnitTestCase { |
81 | 81 | $this->assertEmpty( $none ); |
82 | 82 | |
83 | 83 | $bump = ' '; |
84 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
85 | | $child_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id ) ); |
86 | | $grandchild_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_parent' => $child_id ) ); |
| 84 | $page_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 85 | $child_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id ) ); |
| 86 | $grandchild_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $child_id ) ); |
87 | 87 | |
88 | 88 | $title1 = get_post( $page_id )->post_title; |
89 | 89 | $title2 = get_post( $child_id )->post_title; |
… |
… |
NO; |
143 | 143 | * @ticket 12494 |
144 | 144 | */ |
145 | 145 | public function test_wp_dropdown_pages_value_field_should_default_to_ID() { |
146 | | $p = self::$factory->post->create( array( |
| 146 | $p = self::factory()->post->create( array( |
147 | 147 | 'post_type' => 'page', |
148 | 148 | ) ); |
149 | 149 | |
… |
… |
NO; |
159 | 159 | * @ticket 12494 |
160 | 160 | */ |
161 | 161 | public function test_wp_dropdown_pages_value_field_ID() { |
162 | | $p = self::$factory->post->create( array( |
| 162 | $p = self::factory()->post->create( array( |
163 | 163 | 'post_type' => 'page', |
164 | 164 | ) ); |
165 | 165 | |
… |
… |
NO; |
175 | 175 | * @ticket 12494 |
176 | 176 | */ |
177 | 177 | public function test_wp_dropdown_pages_value_field_post_name() { |
178 | | $p = self::$factory->post->create( array( |
| 178 | $p = self::factory()->post->create( array( |
179 | 179 | 'post_type' => 'page', |
180 | 180 | 'post_name' => 'foo', |
181 | 181 | ) ); |
… |
… |
NO; |
192 | 192 | * @ticket 12494 |
193 | 193 | */ |
194 | 194 | public function test_wp_dropdown_pages_value_field_should_fall_back_on_ID_when_an_invalid_value_is_provided() { |
195 | | $p = self::$factory->post->create( array( |
| 195 | $p = self::factory()->post->create( array( |
196 | 196 | 'post_type' => 'page', |
197 | 197 | 'post_name' => 'foo', |
198 | 198 | ) ); |
… |
… |
NO; |
209 | 209 | * @ticket 30082 |
210 | 210 | */ |
211 | 211 | public function test_wp_dropdown_pages_should_not_contain_class_attribute_when_no_class_is_passed() { |
212 | | $p = self::$factory->post->create( array( |
| 212 | $p = self::factory()->post->create( array( |
213 | 213 | 'post_type' => 'page', |
214 | 214 | 'post_name' => 'foo', |
215 | 215 | ) ); |
… |
… |
NO; |
225 | 225 | * @ticket 30082 |
226 | 226 | */ |
227 | 227 | public function test_wp_dropdown_pages_should_obey_class_parameter() { |
228 | | $p = self::$factory->post->create( array( |
| 228 | $p = self::factory()->post->create( array( |
229 | 229 | 'post_type' => 'page', |
230 | 230 | 'post_name' => 'foo', |
231 | 231 | ) ); |
… |
… |
NO; |
242 | 242 | * @ticket 31389 |
243 | 243 | */ |
244 | 244 | public function test_get_page_template_slug_by_id() { |
245 | | $page_id = self::$factory->post->create( array( |
| 245 | $page_id = self::factory()->post->create( array( |
246 | 246 | 'post_type' => 'page', |
247 | 247 | ) ); |
248 | 248 | |
… |
… |
NO; |
259 | 259 | * @ticket 31389 |
260 | 260 | */ |
261 | 261 | public function test_get_page_template_slug_from_loop() { |
262 | | $page_id = self::$factory->post->create( array( |
| 262 | $page_id = self::factory()->post->create( array( |
263 | 263 | 'post_type' => 'page', |
264 | 264 | ) ); |
265 | 265 | |
… |
… |
NO; |
273 | 273 | * @ticket 31389 |
274 | 274 | */ |
275 | 275 | public function test_get_page_template_slug_non_page() { |
276 | | $post_id = self::$factory->post->create( array( |
| 276 | $post_id = self::factory()->post->create( array( |
277 | 277 | 'post_type' => 'post', |
278 | 278 | ) ); |
279 | 279 | |
… |
… |
NO; |
288 | 288 | * @ticket 33974 |
289 | 289 | */ |
290 | 290 | public function test_wp_page_menu_wp_nav_menu_fallback() { |
291 | | $pages = self::$factory->post->create_many( 3, array( 'post_type' => 'page' ) ); |
| 291 | $pages = self::factory()->post->create_many( 3, array( 'post_type' => 'page' ) ); |
292 | 292 | |
293 | 293 | // No menus + wp_nav_menu() falls back to wp_page_menu(). |
294 | 294 | $menu = wp_nav_menu( array( 'echo' => false ) ); |
-
diff --git tests/phpunit/tests/post/wpUniquePostSlug.php tests/phpunit/tests/post/wpUniquePostSlug.php
index 2f7f013..690fc3e 100644
|
|
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
8 | 8 | * @ticket 21013 |
9 | 9 | */ |
10 | 10 | public function test_non_latin_slugs() { |
11 | | $author_id = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 11 | $author_id = self::factory()->user->create( array( 'role' => 'editor' ) ); |
12 | 12 | |
13 | 13 | $inputs = array( |
14 | 14 | 'Αρνάκι άσπρο και παχύ της μάνας του καμάρι, και άλλα τραγούδια', |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
49 | 49 | 'post_name' => 'some-slug', |
50 | 50 | 'post_status' => 'publish', |
51 | 51 | ); |
52 | | $one = self::$factory->post->create( $args ); |
| 52 | $one = self::factory()->post->create( $args ); |
53 | 53 | $args['post_type'] = 'post-type-2'; |
54 | | $two = self::$factory->post->create( $args ); |
| 54 | $two = self::factory()->post->create( $args ); |
55 | 55 | |
56 | 56 | $this->assertEquals( 'some-slug', get_post( $one )->post_name ); |
57 | 57 | $this->assertEquals( 'some-slug', get_post( $two )->post_name ); |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
74 | 74 | 'post_name' => 'some-slug', |
75 | 75 | 'post_status' => 'publish', |
76 | 76 | ); |
77 | | $one = self::$factory->post->create( $args ); |
| 77 | $one = self::factory()->post->create( $args ); |
78 | 78 | $args['post_name'] = 'some-slug-2'; |
79 | | $two = self::$factory->post->create( $args ); |
| 79 | $two = self::factory()->post->create( $args ); |
80 | 80 | |
81 | 81 | $this->assertEquals( 'some-slug', get_post( $one )->post_name ); |
82 | 82 | $this->assertEquals( 'some-slug-2', get_post( $two )->post_name ); |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
97 | 97 | 'post_name' => 'some-slug', |
98 | 98 | 'post_status' => 'publish', |
99 | 99 | ); |
100 | | $one = self::$factory->post->create( $args ); |
| 100 | $one = self::factory()->post->create( $args ); |
101 | 101 | |
102 | 102 | $args = array( |
103 | 103 | 'post_mime_type' => 'image/jpeg', |
104 | 104 | 'post_type' => 'attachment', |
105 | 105 | 'post_name' => 'image' |
106 | 106 | ); |
107 | | $attachment = self::$factory->attachment->create_object( 'image.jpg', $one, $args ); |
| 107 | $attachment = self::factory()->attachment->create_object( 'image.jpg', $one, $args ); |
108 | 108 | |
109 | 109 | $args = array( |
110 | 110 | 'post_type' => 'post-type-1', |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
112 | 112 | 'post_status' => 'publish', |
113 | 113 | 'post_parent' => $one |
114 | 114 | ); |
115 | | $two = self::$factory->post->create( $args ); |
| 115 | $two = self::factory()->post->create( $args ); |
116 | 116 | |
117 | 117 | $this->assertEquals( 'some-slug', get_post( $one )->post_name ); |
118 | 118 | $this->assertEquals( 'image', get_post( $attachment )->post_name ); |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
128 | 128 | * @dataProvider whitelist_post_statuses |
129 | 129 | */ |
130 | 130 | public function test_whitelisted_post_statuses_should_not_be_forced_to_be_unique( $status ) { |
131 | | $p1 = self::$factory->post->create( array( |
| 131 | $p1 = self::factory()->post->create( array( |
132 | 132 | 'post_type' => 'post', |
133 | 133 | 'post_name' => 'foo', |
134 | 134 | ) ); |
135 | 135 | |
136 | | $p2 = self::$factory->post->create( array( |
| 136 | $p2 = self::factory()->post->create( array( |
137 | 137 | 'post_type' => 'post', |
138 | 138 | ) ); |
139 | 139 | |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
151 | 151 | } |
152 | 152 | |
153 | 153 | public function test_revisions_should_not_be_forced_to_be_unique() { |
154 | | $p1 = self::$factory->post->create( array( |
| 154 | $p1 = self::factory()->post->create( array( |
155 | 155 | 'post_type' => 'post', |
156 | 156 | 'post_name' => 'foo', |
157 | 157 | ) ); |
158 | 158 | |
159 | | $p2 = self::$factory->post->create( array( |
| 159 | $p2 = self::factory()->post->create( array( |
160 | 160 | 'post_type' => 'post', |
161 | 161 | ) ); |
162 | 162 | |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
171 | 171 | public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_be_suffixed() { |
172 | 172 | $this->set_permalink_structure( '/%postname%/' ); |
173 | 173 | |
174 | | $p = self::$factory->post->create( array( |
| 174 | $p = self::factory()->post->create( array( |
175 | 175 | 'post_type' => 'post', |
176 | 176 | 'post_name' => 'foo', |
177 | 177 | ) ); |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
186 | 186 | public function test_slugs_resulting_in_permalinks_that_resemble_year_archives_should_not_be_suffixed_for_already_published_posts() { |
187 | 187 | $this->set_permalink_structure( '/%postname%/' ); |
188 | 188 | |
189 | | $p = self::$factory->post->create( array( |
| 189 | $p = self::factory()->post->create( array( |
190 | 190 | 'post_type' => 'post', |
191 | 191 | 'post_name' => 'foo', |
192 | 192 | 'post_status' => 'publish', |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
202 | 202 | public function test_yearlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_year_archives() { |
203 | 203 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
204 | 204 | |
205 | | $p = self::$factory->post->create( array( |
| 205 | $p = self::factory()->post->create( array( |
206 | 206 | 'post_type' => 'post', |
207 | 207 | 'post_name' => 'foo', |
208 | 208 | ) ); |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
217 | 217 | public function test_slugs_resulting_in_permalinks_that_resemble_month_archives_should_be_suffixed() { |
218 | 218 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
219 | 219 | |
220 | | $p = self::$factory->post->create( array( |
| 220 | $p = self::factory()->post->create( array( |
221 | 221 | 'post_type' => 'post', |
222 | 222 | 'post_name' => 'foo', |
223 | 223 | ) ); |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
232 | 232 | public function test_monthlike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_month_archives() { |
233 | 233 | $this->set_permalink_structure( '/%year%/foo/%postname%/' ); |
234 | 234 | |
235 | | $p = self::$factory->post->create( array( |
| 235 | $p = self::factory()->post->create( array( |
236 | 236 | 'post_type' => 'post', |
237 | 237 | 'post_name' => 'foo', |
238 | 238 | ) ); |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
247 | 247 | public function test_monthlike_slugs_should_not_be_suffixed_for_invalid_month_numbers() { |
248 | 248 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
249 | 249 | |
250 | | $p = self::$factory->post->create( array( |
| 250 | $p = self::factory()->post->create( array( |
251 | 251 | 'post_type' => 'post', |
252 | 252 | 'post_name' => 'foo', |
253 | 253 | ) ); |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
262 | 262 | public function test_slugs_resulting_in_permalinks_that_resemble_day_archives_should_be_suffixed() { |
263 | 263 | $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); |
264 | 264 | |
265 | | $p = self::$factory->post->create( array( |
| 265 | $p = self::factory()->post->create( array( |
266 | 266 | 'post_type' => 'post', |
267 | 267 | 'post_name' => 'foo', |
268 | 268 | ) ); |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
277 | 277 | public function test_daylike_slugs_should_not_be_suffixed_if_permalink_structure_does_not_result_in_a_clash_with_day_archives() { |
278 | 278 | $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); |
279 | 279 | |
280 | | $p = self::$factory->post->create( array( |
| 280 | $p = self::factory()->post->create( array( |
281 | 281 | 'post_type' => 'post', |
282 | 282 | 'post_name' => 'foo', |
283 | 283 | ) ); |
… |
… |
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
292 | 292 | public function test_daylike_slugs_should_not_be_suffixed_for_invalid_day_numbers() { |
293 | 293 | $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); |
294 | 294 | |
295 | | $p = self::$factory->post->create( array( |
| 295 | $p = self::factory()->post->create( array( |
296 | 296 | 'post_type' => 'post', |
297 | 297 | 'post_name' => 'foo', |
298 | 298 | ) ); |
-
diff --git tests/phpunit/tests/query.php tests/phpunit/tests/query.php
index 1bcf175..b5ab027 100644
|
|
class Tests_Query extends WP_UnitTestCase { |
14 | 14 | * |
15 | 15 | */ |
16 | 16 | function test_nested_loop_reset_postdata() { |
17 | | $post_id = self::$factory->post->create(); |
18 | | $nested_post_id = self::$factory->post->create(); |
| 17 | $post_id = self::factory()->post->create(); |
| 18 | $nested_post_id = self::factory()->post->create(); |
19 | 19 | |
20 | 20 | $first_query = new WP_Query( array( 'post__in' => array( $post_id ) ) ); |
21 | 21 | while ( $first_query->have_posts() ) { $first_query->the_post(); |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
43 | 43 | * @ticket 25380 |
44 | 44 | */ |
45 | 45 | function test_pre_posts_per_page() { |
46 | | self::$factory->post->create_many( 10 ); |
| 46 | self::factory()->post->create_many( 10 ); |
47 | 47 | |
48 | 48 | add_action( 'pre_get_posts', array( $this, 'filter_posts_per_page' ) ); |
49 | 49 | |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
61 | 61 | */ |
62 | 62 | function test_tag_queried_object() { |
63 | 63 | $slug = 'tag-slug-26627'; |
64 | | self::$factory->tag->create( array( 'slug' => $slug ) ); |
| 64 | self::factory()->tag->create( array( 'slug' => $slug ) ); |
65 | 65 | $tag = get_term_by( 'slug', $slug, 'post_tag' ); |
66 | 66 | |
67 | 67 | add_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 ); |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
94 | 94 | // Don't override the args provided below. |
95 | 95 | remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) ); |
96 | 96 | register_taxonomy( 'wptests_tax', 'post' ); |
97 | | $terms = self::$factory->term->create_many( 2, array( |
| 97 | $terms = self::factory()->term->create_many( 2, array( |
98 | 98 | 'taxonomy' => 'wptests_tax', |
99 | 99 | ) ); |
100 | 100 | |
101 | | $posts = self::$factory->post->create_many( 2 ); |
| 101 | $posts = self::factory()->post->create_many( 2 ); |
102 | 102 | |
103 | 103 | wp_set_object_terms( $posts[0], array( $terms[0] ), 'wptests_tax' ); |
104 | 104 | wp_set_object_terms( $posts[1], array( $terms[1] ), 'wptests_tax' ); |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
130 | 130 | } |
131 | 131 | |
132 | 132 | public function test_cat_querystring_single_term() { |
133 | | $c1 = self::$factory->category->create( array( |
| 133 | $c1 = self::factory()->category->create( array( |
134 | 134 | 'name' => 'Test Category 1', |
135 | 135 | 'slug' => 'test1', |
136 | 136 | ) ); |
137 | | $c2 = self::$factory->category->create( array( |
| 137 | $c2 = self::factory()->category->create( array( |
138 | 138 | 'name' => 'Test Category 2', |
139 | 139 | 'slug' => 'test2', |
140 | 140 | ) ); |
141 | 141 | |
142 | | $p1 = self::$factory->post->create(); |
143 | | $p2 = self::$factory->post->create(); |
144 | | $p3 = self::$factory->post->create(); |
| 142 | $p1 = self::factory()->post->create(); |
| 143 | $p2 = self::factory()->post->create(); |
| 144 | $p3 = self::factory()->post->create(); |
145 | 145 | |
146 | 146 | wp_set_object_terms( $p1, $c1, 'category' ); |
147 | 147 | wp_set_object_terms( $p2, array( $c1, $c2 ), 'category' ); |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
159 | 159 | } |
160 | 160 | |
161 | 161 | public function test_category_querystring_multiple_terms_comma_separated() { |
162 | | $c1 = self::$factory->category->create( array( |
| 162 | $c1 = self::factory()->category->create( array( |
163 | 163 | 'name' => 'Test Category 1', |
164 | 164 | 'slug' => 'test1', |
165 | 165 | ) ); |
166 | | $c2 = self::$factory->category->create( array( |
| 166 | $c2 = self::factory()->category->create( array( |
167 | 167 | 'name' => 'Test Category 2', |
168 | 168 | 'slug' => 'test2', |
169 | 169 | ) ); |
170 | | $c3 = self::$factory->category->create( array( |
| 170 | $c3 = self::factory()->category->create( array( |
171 | 171 | 'name' => 'Test Category 3', |
172 | 172 | 'slug' => 'test3', |
173 | 173 | ) ); |
174 | 174 | |
175 | | $p1 = self::$factory->post->create(); |
176 | | $p2 = self::$factory->post->create(); |
177 | | $p3 = self::$factory->post->create(); |
178 | | $p4 = self::$factory->post->create(); |
| 175 | $p1 = self::factory()->post->create(); |
| 176 | $p2 = self::factory()->post->create(); |
| 177 | $p3 = self::factory()->post->create(); |
| 178 | $p4 = self::factory()->post->create(); |
179 | 179 | |
180 | 180 | wp_set_object_terms( $p1, $c1, 'category' ); |
181 | 181 | wp_set_object_terms( $p2, array( $c1, $c2 ), 'category' ); |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
197 | 197 | * @ticket 33532 |
198 | 198 | */ |
199 | 199 | public function test_category_querystring_multiple_terms_formatted_as_array() { |
200 | | $c1 = self::$factory->category->create( array( |
| 200 | $c1 = self::factory()->category->create( array( |
201 | 201 | 'name' => 'Test Category 1', |
202 | 202 | 'slug' => 'test1', |
203 | 203 | ) ); |
204 | | $c2 = self::$factory->category->create( array( |
| 204 | $c2 = self::factory()->category->create( array( |
205 | 205 | 'name' => 'Test Category 2', |
206 | 206 | 'slug' => 'test2', |
207 | 207 | ) ); |
208 | | $c3 = self::$factory->category->create( array( |
| 208 | $c3 = self::factory()->category->create( array( |
209 | 209 | 'name' => 'Test Category 3', |
210 | 210 | 'slug' => 'test3', |
211 | 211 | ) ); |
212 | 212 | |
213 | | $p1 = self::$factory->post->create(); |
214 | | $p2 = self::$factory->post->create(); |
215 | | $p3 = self::$factory->post->create(); |
216 | | $p4 = self::$factory->post->create(); |
| 213 | $p1 = self::factory()->post->create(); |
| 214 | $p2 = self::factory()->post->create(); |
| 215 | $p3 = self::factory()->post->create(); |
| 216 | $p4 = self::factory()->post->create(); |
217 | 217 | |
218 | 218 | wp_set_object_terms( $p1, $c1, 'category' ); |
219 | 219 | wp_set_object_terms( $p2, array( $c1, $c2 ), 'category' ); |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
233 | 233 | |
234 | 234 | |
235 | 235 | public function test_tag_querystring_single_term() { |
236 | | $t1 = self::$factory->tag->create_and_get( array( |
| 236 | $t1 = self::factory()->tag->create_and_get( array( |
237 | 237 | 'name' => 'Test Tag 1', |
238 | 238 | 'slug' => 'test1', |
239 | 239 | ) ); |
240 | | $t2 = self::$factory->tag->create_and_get( array( |
| 240 | $t2 = self::factory()->tag->create_and_get( array( |
241 | 241 | 'name' => 'Test Tag 2', |
242 | 242 | 'slug' => 'test2', |
243 | 243 | ) ); |
244 | 244 | |
245 | | $p1 = self::$factory->post->create(); |
246 | | $p2 = self::$factory->post->create(); |
247 | | $p3 = self::$factory->post->create(); |
| 245 | $p1 = self::factory()->post->create(); |
| 246 | $p2 = self::factory()->post->create(); |
| 247 | $p3 = self::factory()->post->create(); |
248 | 248 | |
249 | 249 | wp_set_object_terms( $p1, $t1->slug, 'post_tag' ); |
250 | 250 | wp_set_object_terms( $p2, array( $t1->slug, $t2->slug ), 'post_tag' ); |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
262 | 262 | } |
263 | 263 | |
264 | 264 | public function test_tag_querystring_multiple_terms_comma_separated() { |
265 | | $c1 = self::$factory->tag->create_and_get( array( |
| 265 | $c1 = self::factory()->tag->create_and_get( array( |
266 | 266 | 'name' => 'Test Tag 1', |
267 | 267 | 'slug' => 'test1', |
268 | 268 | ) ); |
269 | | $c2 = self::$factory->tag->create_and_get( array( |
| 269 | $c2 = self::factory()->tag->create_and_get( array( |
270 | 270 | 'name' => 'Test Tag 2', |
271 | 271 | 'slug' => 'test2', |
272 | 272 | ) ); |
273 | | $c3 = self::$factory->tag->create_and_get( array( |
| 273 | $c3 = self::factory()->tag->create_and_get( array( |
274 | 274 | 'name' => 'Test Tag 3', |
275 | 275 | 'slug' => 'test3', |
276 | 276 | ) ); |
277 | 277 | |
278 | | $p1 = self::$factory->post->create(); |
279 | | $p2 = self::$factory->post->create(); |
280 | | $p3 = self::$factory->post->create(); |
281 | | $p4 = self::$factory->post->create(); |
| 278 | $p1 = self::factory()->post->create(); |
| 279 | $p2 = self::factory()->post->create(); |
| 280 | $p3 = self::factory()->post->create(); |
| 281 | $p4 = self::factory()->post->create(); |
282 | 282 | |
283 | 283 | wp_set_object_terms( $p1, $c1->slug, 'post_tag' ); |
284 | 284 | wp_set_object_terms( $p2, array( $c1->slug, $c2->slug ), 'post_tag' ); |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
300 | 300 | * @ticket 33532 |
301 | 301 | */ |
302 | 302 | public function test_tag_querystring_multiple_terms_formatted_as_array() { |
303 | | $c1 = self::$factory->tag->create_and_get( array( |
| 303 | $c1 = self::factory()->tag->create_and_get( array( |
304 | 304 | 'name' => 'Test Tag 1', |
305 | 305 | 'slug' => 'test1', |
306 | 306 | ) ); |
307 | | $c2 = self::$factory->tag->create_and_get( array( |
| 307 | $c2 = self::factory()->tag->create_and_get( array( |
308 | 308 | 'name' => 'Test Tag 2', |
309 | 309 | 'slug' => 'test2', |
310 | 310 | ) ); |
311 | | $c3 = self::$factory->tag->create_and_get( array( |
| 311 | $c3 = self::factory()->tag->create_and_get( array( |
312 | 312 | 'name' => 'Test Tag 3', |
313 | 313 | 'slug' => 'test3', |
314 | 314 | ) ); |
315 | 315 | |
316 | | $p1 = self::$factory->post->create(); |
317 | | $p2 = self::$factory->post->create(); |
318 | | $p3 = self::$factory->post->create(); |
319 | | $p4 = self::$factory->post->create(); |
| 316 | $p1 = self::factory()->post->create(); |
| 317 | $p2 = self::factory()->post->create(); |
| 318 | $p3 = self::factory()->post->create(); |
| 319 | $p4 = self::factory()->post->create(); |
320 | 320 | |
321 | 321 | wp_set_object_terms( $p1, $c1->slug, 'post_tag' ); |
322 | 322 | wp_set_object_terms( $p2, array( $c1->slug, $c2->slug ), 'post_tag' ); |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
341 | 341 | wp_insert_term( 'test2', 'test_tax_cat' ); |
342 | 342 | wp_insert_term( 'test3', 'test_tax_cat' ); |
343 | 343 | |
344 | | $p1 = self::$factory->post->create(); |
345 | | $p2 = self::$factory->post->create(); |
346 | | $p3 = self::$factory->post->create(); |
| 344 | $p1 = self::factory()->post->create(); |
| 345 | $p2 = self::factory()->post->create(); |
| 346 | $p3 = self::factory()->post->create(); |
347 | 347 | |
348 | 348 | wp_set_object_terms( $p1, 'test1', 'test_tax_cat' ); |
349 | 349 | wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' ); |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
365 | 365 | wp_insert_term( 'test2', 'test_tax_cat' ); |
366 | 366 | wp_insert_term( 'test3', 'test_tax_cat' ); |
367 | 367 | |
368 | | $p1 = self::$factory->post->create(); |
369 | | $p2 = self::$factory->post->create(); |
370 | | $p3 = self::$factory->post->create(); |
371 | | $p4 = self::$factory->post->create(); |
| 368 | $p1 = self::factory()->post->create(); |
| 369 | $p2 = self::factory()->post->create(); |
| 370 | $p3 = self::factory()->post->create(); |
| 371 | $p4 = self::factory()->post->create(); |
372 | 372 | |
373 | 373 | wp_set_object_terms( $p1, 'test1', 'test_tax_cat' ); |
374 | 374 | wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' ); |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
394 | 394 | wp_insert_term( 'test2', 'test_tax_cat' ); |
395 | 395 | wp_insert_term( 'test3', 'test_tax_cat' ); |
396 | 396 | |
397 | | $p1 = self::$factory->post->create(); |
398 | | $p2 = self::$factory->post->create(); |
399 | | $p3 = self::$factory->post->create(); |
400 | | $p4 = self::$factory->post->create(); |
| 397 | $p1 = self::factory()->post->create(); |
| 398 | $p2 = self::factory()->post->create(); |
| 399 | $p3 = self::factory()->post->create(); |
| 400 | $p4 = self::factory()->post->create(); |
401 | 401 | |
402 | 402 | wp_set_object_terms( $p1, 'test1', 'test_tax_cat' ); |
403 | 403 | wp_set_object_terms( $p2, array( 'test1', 'test2' ), 'test_tax_cat' ); |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
417 | 417 | * @ticket 31355 |
418 | 418 | */ |
419 | 419 | public function test_pages_dont_404_when_queried_post_id_is_modified() { |
420 | | $post_id = self::$factory->post->create( array( 'post_title' => 'A Test Page', 'post_type' => 'page' ) ); |
| 420 | $post_id = self::factory()->post->create( array( 'post_title' => 'A Test Page', 'post_type' => 'page' ) ); |
421 | 421 | |
422 | 422 | add_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) ); |
423 | 423 | |
… |
… |
class Tests_Query extends WP_UnitTestCase { |
438 | 438 | |
439 | 439 | register_post_type( 'guide', array( 'name' => 'Guide', 'public' => true, 'hierarchical' => true ) ); |
440 | 440 | $wp_rewrite->flush_rules(); |
441 | | $post_id = self::$factory->post->create( array( 'post_title' => 'A Test Guide', 'post_type' => 'guide' ) ); |
| 441 | $post_id = self::factory()->post->create( array( 'post_title' => 'A Test Guide', 'post_type' => 'guide' ) ); |
442 | 442 | |
443 | 443 | add_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) ); |
444 | 444 | |
-
diff --git tests/phpunit/tests/query/conditionals.php tests/phpunit/tests/query/conditionals.php
index c645a46..8a351e7 100644
|
|
class Tests_Query_Conditionals extends WP_UnitTestCase { |
45 | 45 | } |
46 | 46 | |
47 | 47 | function test_permalink() { |
48 | | $post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) ); |
| 48 | $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); |
49 | 49 | $this->go_to( get_permalink( $post_id ) ); |
50 | 50 | $this->assertQueryTrue('is_single', 'is_singular'); |
51 | 51 | } |
52 | 52 | |
53 | 53 | function test_post_comments_feed() { |
54 | | $post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) ); |
55 | | self::$factory->comment->create_post_comments( $post_id, 2 ); |
| 54 | $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); |
| 55 | self::factory()->comment->create_post_comments( $post_id, 2 ); |
56 | 56 | $this->go_to( get_post_comments_feed_link( $post_id ) ); |
57 | 57 | $this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed'); |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | 61 | function test_post_comments_feed_with_no_comments() { |
62 | | $post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) ); |
| 62 | $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); |
63 | 63 | $this->go_to( get_post_comments_feed_link( $post_id ) ); |
64 | 64 | $this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed'); |
65 | 65 | } |
66 | 66 | |
67 | 67 | function test_page() { |
68 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) ); |
| 68 | $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) ); |
69 | 69 | $this->go_to( get_permalink( $page_id ) ); |
70 | 70 | $this->assertQueryTrue('is_page','is_singular'); |
71 | 71 | } |
72 | 72 | |
73 | 73 | function test_parent_page() { |
74 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
| 74 | $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
75 | 75 | $this->go_to( get_permalink( $page_id ) ); |
76 | 76 | |
77 | 77 | $this->assertQueryTrue('is_page','is_singular'); |
78 | 78 | } |
79 | 79 | |
80 | 80 | function test_child_page_1() { |
81 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
82 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); |
| 81 | $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
| 82 | $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); |
83 | 83 | $this->go_to( get_permalink( $page_id ) ); |
84 | 84 | |
85 | 85 | $this->assertQueryTrue('is_page','is_singular'); |
86 | 86 | } |
87 | 87 | |
88 | 88 | function test_child_page_2() { |
89 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
90 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); |
91 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); |
| 89 | $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
| 90 | $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); |
| 91 | $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); |
92 | 92 | $this->go_to( get_permalink( $page_id ) ); |
93 | 93 | |
94 | 94 | $this->assertQueryTrue('is_page','is_singular'); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
97 | 97 | // '(about)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1' |
98 | 98 | function test_page_trackback() { |
99 | 99 | $page_ids = array(); |
100 | | $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
101 | | $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); |
102 | | $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); |
| 100 | $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
| 101 | $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); |
| 102 | $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); |
103 | 103 | foreach ( $page_ids as $page_id ) { |
104 | 104 | $url = get_permalink( $page_id ); |
105 | 105 | $this->go_to("{$url}trackback/"); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
116 | 116 | //'(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]' |
117 | 117 | function test_page_feed() { |
118 | 118 | $page_ids = array(); |
119 | | $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
120 | | $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); |
121 | | $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); |
| 119 | $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
| 120 | $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); |
| 121 | $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); |
122 | 122 | foreach ( $page_ids as $page_id ) { |
123 | | self::$factory->comment->create_post_comments( $page_id, 2 ); |
| 123 | self::factory()->comment->create_post_comments( $page_id, 2 ); |
124 | 124 | $url = get_permalink( $page_id ); |
125 | 125 | $this->go_to("{$url}feed/"); |
126 | 126 | |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
135 | 135 | |
136 | 136 | function test_page_feed_with_no_comments() { |
137 | 137 | $page_ids = array(); |
138 | | $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
139 | | $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); |
140 | | $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); |
| 138 | $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
| 139 | $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); |
| 140 | $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); |
141 | 141 | foreach ( $page_ids as $page_id ) { |
142 | 142 | $url = get_permalink( $page_id ); |
143 | 143 | $this->go_to("{$url}feed/"); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
154 | 154 | // '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]' |
155 | 155 | function test_page_feed_atom() { |
156 | 156 | $page_ids = array(); |
157 | | $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
158 | | $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); |
159 | | $page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); |
| 157 | $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); |
| 158 | $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); |
| 159 | $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); |
160 | 160 | foreach ( $page_ids as $page_id ) { |
161 | | self::$factory->comment->create_post_comments( $page_id, 2 ); |
| 161 | self::factory()->comment->create_post_comments( $page_id, 2 ); |
162 | 162 | |
163 | 163 | $url = get_permalink( $page_id ); |
164 | 164 | $this->go_to("{$url}feed/atom/"); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
174 | 174 | |
175 | 175 | // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]' |
176 | 176 | function test_page_page_2() { |
177 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) ); |
| 177 | $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) ); |
178 | 178 | $this->go_to("/about/page/2/"); |
179 | 179 | |
180 | 180 | // make sure the correct wp_query flags are set |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
187 | 187 | |
188 | 188 | // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]' |
189 | 189 | function test_page_page_2_no_slash() { |
190 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) ); |
| 190 | $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) ); |
191 | 191 | $this->go_to("/about/page2/"); |
192 | 192 | |
193 | 193 | // make sure the correct wp_query flags are set |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
201 | 201 | // FIXME: what is this for? |
202 | 202 | // '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]' |
203 | 203 | function test_pagination_of_posts_page() { |
204 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) ); |
| 204 | $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) ); |
205 | 205 | update_option( 'show_on_front', 'page' ); |
206 | 206 | update_option( 'page_for_posts', $page_id ); |
207 | 207 | |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
223 | 223 | // 'feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]', |
224 | 224 | // '(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]', |
225 | 225 | function test_main_feed_2() { |
226 | | self::$factory->post->create(); // @test_404 |
| 226 | self::factory()->post->create(); // @test_404 |
227 | 227 | $feeds = array('feed', 'rdf', 'rss', 'rss2', 'atom'); |
228 | 228 | |
229 | 229 | // long version |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
241 | 241 | } |
242 | 242 | |
243 | 243 | function test_main_feed() { |
244 | | self::$factory->post->create(); // @test_404 |
| 244 | self::factory()->post->create(); // @test_404 |
245 | 245 | $types = array('rss2', 'rss', 'atom'); |
246 | 246 | foreach ($types as $type) { |
247 | 247 | $this->go_to(get_feed_link($type)); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
252 | 252 | // 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]', |
253 | 253 | function test_paged() { |
254 | 254 | update_option( 'posts_per_page', 2 ); |
255 | | self::$factory->post->create_many( 5 ); |
| 255 | self::factory()->post->create_many( 5 ); |
256 | 256 | for ( $i = 2; $i <= 3; $i++ ) { |
257 | 257 | $this->go_to("/page/{$i}/"); |
258 | 258 | $this->assertQueryTrue('is_home', 'is_paged'); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
262 | 262 | // 'comments/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1', |
263 | 263 | // 'comments/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1', |
264 | 264 | function test_main_comments_feed() { |
265 | | $post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) ); |
266 | | self::$factory->comment->create_post_comments( $post_id, 2 ); |
| 265 | $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); |
| 266 | self::factory()->comment->create_post_comments( $post_id, 2 ); |
267 | 267 | |
268 | 268 | // check the url as generated by get_post_comments_feed_link() |
269 | 269 | $this->go_to( get_post_comments_feed_link( $post_id ) ); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
306 | 306 | // 'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]', |
307 | 307 | function test_search_paged() { |
308 | 308 | update_option( 'posts_per_page', 2 ); |
309 | | self::$factory->post->create_many( 3, array( 'post_title' => 'test' ) ); |
| 309 | self::factory()->post->create_many( 3, array( 'post_title' => 'test' ) ); |
310 | 310 | $this->go_to('/search/test/page/2/'); |
311 | 311 | $this->assertQueryTrue('is_search', 'is_paged'); |
312 | 312 | } |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
328 | 328 | // 'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', |
329 | 329 | // 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', |
330 | 330 | function test_category_feed() { |
331 | | self::$factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) ); |
| 331 | self::factory()->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) ); |
332 | 332 | // check the long form |
333 | 333 | $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); |
334 | 334 | foreach ($types as $type) { |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
347 | 347 | // 'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]', |
348 | 348 | function test_category_paged() { |
349 | 349 | update_option( 'posts_per_page', 2 ); |
350 | | self::$factory->post->create_many( 3 ); |
| 350 | self::factory()->post->create_many( 3 ); |
351 | 351 | $this->go_to('/category/uncategorized/page/2/'); |
352 | 352 | $this->assertQueryTrue('is_archive', 'is_category', 'is_paged'); |
353 | 353 | } |
354 | 354 | |
355 | 355 | // 'category/(.+?)/?$' => 'index.php?category_name=$matches[1]', |
356 | 356 | function test_category() { |
357 | | self::$factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) ); |
| 357 | self::factory()->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) ); |
358 | 358 | $this->go_to('/category/cat-a/'); |
359 | 359 | $this->assertQueryTrue('is_archive', 'is_category'); |
360 | 360 | } |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
362 | 362 | // 'tag/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', |
363 | 363 | // 'tag/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', |
364 | 364 | function test_tag_feed() { |
365 | | self::$factory->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) ); |
| 365 | self::factory()->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) ); |
366 | 366 | // check the long form |
367 | 367 | $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); |
368 | 368 | foreach ($types as $type) { |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
381 | 381 | // 'tag/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]', |
382 | 382 | function test_tag_paged() { |
383 | 383 | update_option( 'posts_per_page', 2 ); |
384 | | $post_ids = self::$factory->post->create_many( 3 ); |
| 384 | $post_ids = self::factory()->post->create_many( 3 ); |
385 | 385 | foreach ( $post_ids as $post_id ) |
386 | | self::$factory->term->add_post_terms( $post_id, 'tag-a', 'post_tag' ); |
| 386 | self::factory()->term->add_post_terms( $post_id, 'tag-a', 'post_tag' ); |
387 | 387 | $this->go_to('/tag/tag-a/page/2/'); |
388 | 388 | $this->assertQueryTrue('is_archive', 'is_tag', 'is_paged'); |
389 | 389 | } |
390 | 390 | |
391 | 391 | // 'tag/(.+?)/?$' => 'index.php?tag=$matches[1]', |
392 | 392 | function test_tag() { |
393 | | $term_id = self::$factory->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) ); |
| 393 | $term_id = self::factory()->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) ); |
394 | 394 | $this->go_to('/tag/tag-a/'); |
395 | 395 | $this->assertQueryTrue('is_archive', 'is_tag'); |
396 | 396 | |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
409 | 409 | // 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]', |
410 | 410 | // 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]', |
411 | 411 | function test_author_feed() { |
412 | | self::$factory->user->create( array( 'user_login' => 'user-a' ) ); |
| 412 | self::factory()->user->create( array( 'user_login' => 'user-a' ) ); |
413 | 413 | // check the long form |
414 | 414 | $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); |
415 | 415 | foreach ($types as $type) { |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
428 | 428 | // 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]', |
429 | 429 | function test_author_paged() { |
430 | 430 | update_option( 'posts_per_page', 2 ); |
431 | | $user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) ); |
432 | | self::$factory->post->create_many( 3, array( 'post_author' => $user_id ) ); |
| 431 | $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) ); |
| 432 | self::factory()->post->create_many( 3, array( 'post_author' => $user_id ) ); |
433 | 433 | $this->go_to('/author/user-a/page/2/'); |
434 | 434 | $this->assertQueryTrue('is_archive', 'is_author', 'is_paged'); |
435 | 435 | } |
436 | 436 | |
437 | 437 | // 'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]', |
438 | 438 | function test_author() { |
439 | | $user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) ); |
440 | | self::$factory->post->create( array( 'post_author' => $user_id ) ); |
| 439 | $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) ); |
| 440 | self::factory()->post->create( array( 'post_author' => $user_id ) ); |
441 | 441 | $this->go_to('/author/user-a/'); |
442 | 442 | $this->assertQueryTrue('is_archive', 'is_author'); |
443 | 443 | } |
444 | 444 | |
445 | 445 | function test_author_with_no_posts() { |
446 | | $user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) ); |
| 446 | $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) ); |
447 | 447 | $this->go_to('/author/user-a/'); |
448 | 448 | $this->assertQueryTrue('is_archive', 'is_author'); |
449 | 449 | } |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
451 | 451 | // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]', |
452 | 452 | // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]', |
453 | 453 | function test_ymd_feed() { |
454 | | self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); |
| 454 | self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); |
455 | 455 | // check the long form |
456 | 456 | $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); |
457 | 457 | foreach ($types as $type) { |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
470 | 470 | // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]', |
471 | 471 | function test_ymd_paged() { |
472 | 472 | update_option( 'posts_per_page', 2 ); |
473 | | self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); |
| 473 | self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); |
474 | 474 | $this->go_to('/2007/09/04/page/2/'); |
475 | 475 | $this->assertQueryTrue('is_archive', 'is_day', 'is_date', 'is_paged'); |
476 | 476 | } |
477 | 477 | |
478 | 478 | // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]', |
479 | 479 | function test_ymd() { |
480 | | self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); |
| 480 | self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); |
481 | 481 | $this->go_to('/2007/09/04/'); |
482 | 482 | $this->assertQueryTrue('is_archive', 'is_day', 'is_date'); |
483 | 483 | } |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
485 | 485 | // '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]', |
486 | 486 | // '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]', |
487 | 487 | function test_ym_feed() { |
488 | | self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); |
| 488 | self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); |
489 | 489 | // check the long form |
490 | 490 | $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); |
491 | 491 | foreach ($types as $type) { |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
504 | 504 | // '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]', |
505 | 505 | function test_ym_paged() { |
506 | 506 | update_option( 'posts_per_page', 2 ); |
507 | | self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); |
| 507 | self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); |
508 | 508 | $this->go_to('/2007/09/page/2/'); |
509 | 509 | $this->assertQueryTrue('is_archive', 'is_date', 'is_month', 'is_paged'); |
510 | 510 | } |
511 | 511 | |
512 | 512 | // '([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]', |
513 | 513 | function test_ym() { |
514 | | self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); |
| 514 | self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); |
515 | 515 | $this->go_to('/2007/09/'); |
516 | 516 | $this->assertQueryTrue('is_archive', 'is_date', 'is_month'); |
517 | 517 | } |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
519 | 519 | // '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]', |
520 | 520 | // '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]', |
521 | 521 | function test_y_feed() { |
522 | | self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); |
| 522 | self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); |
523 | 523 | // check the long form |
524 | 524 | $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); |
525 | 525 | foreach ($types as $type) { |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
538 | 538 | // '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]', |
539 | 539 | function test_y_paged() { |
540 | 540 | update_option( 'posts_per_page', 2 ); |
541 | | self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); |
| 541 | self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); |
542 | 542 | $this->go_to('/2007/page/2/'); |
543 | 543 | $this->assertQueryTrue('is_archive', 'is_date', 'is_year', 'is_paged'); |
544 | 544 | } |
545 | 545 | |
546 | 546 | // '([0-9]{4})/?$' => 'index.php?year=$matches[1]', |
547 | 547 | function test_y() { |
548 | | self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); |
| 548 | self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); |
549 | 549 | $this->go_to('/2007/'); |
550 | 550 | $this->assertQueryTrue('is_archive', 'is_date', 'is_year'); |
551 | 551 | } |
552 | 552 | |
553 | 553 | // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1', |
554 | 554 | function test_post_trackback() { |
555 | | $post_id = self::$factory->post->create(); |
| 555 | $post_id = self::factory()->post->create(); |
556 | 556 | $permalink = get_permalink( $post_id ); |
557 | 557 | $this->go_to("{$permalink}trackback/"); |
558 | 558 | $this->assertQueryTrue('is_single', 'is_singular', 'is_trackback'); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
561 | 561 | // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', |
562 | 562 | // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', |
563 | 563 | function test_post_comment_feed() { |
564 | | $post_id = self::$factory->post->create(); |
| 564 | $post_id = self::factory()->post->create(); |
565 | 565 | $permalink = get_permalink( $post_id ); |
566 | 566 | |
567 | 567 | $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
580 | 580 | |
581 | 581 | // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]', |
582 | 582 | function test_post_paged_short() { |
583 | | $post_id = self::$factory->post->create( array( |
| 583 | $post_id = self::factory()->post->create( array( |
584 | 584 | 'post_date' => '2007-09-04 00:00:00', |
585 | 585 | 'post_title' => 'a-post-with-multiple-pages', |
586 | 586 | 'post_content' => 'Page 1 <!--nextpage--> Page 2' |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
593 | 593 | |
594 | 594 | // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]', |
595 | 595 | function test_post_attachment() { |
596 | | $post_id = self::$factory->post->create( array( 'post_type' => 'attachment' ) ); |
| 596 | $post_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) ); |
597 | 597 | $permalink = get_attachment_link( $post_id ); |
598 | 598 | $this->go_to($permalink); |
599 | 599 | $this->assertQueryTrue('is_single', 'is_attachment', 'is_singular'); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
629 | 629 | 'public' => true |
630 | 630 | ) ); |
631 | 631 | |
632 | | $tag_id = self::$factory->tag->create( array( 'slug' => 'tag-slug' ) ); |
633 | | $post_id = self::$factory->post->create( array( 'post_type' => $cpt_name ) ); |
| 632 | $tag_id = self::factory()->tag->create( array( 'slug' => 'tag-slug' ) ); |
| 633 | $post_id = self::factory()->post->create( array( 'post_type' => $cpt_name ) ); |
634 | 634 | wp_set_object_terms( $post_id, $tag_id, 'post_tag' ); |
635 | 635 | |
636 | 636 | $this->go_to( '/ptawtq/' ); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
663 | 663 | 'has_archive' => true, |
664 | 664 | 'public' => true |
665 | 665 | ) ); |
666 | | self::$factory->post->create( array( 'post_type' => $cpt_name ) ); |
| 666 | self::factory()->post->create( array( 'post_type' => $cpt_name ) ); |
667 | 667 | |
668 | 668 | $this->go_to( "/$cpt_name/" ); |
669 | 669 | $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' ); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
683 | 683 | } |
684 | 684 | |
685 | 685 | function test_is_single() { |
686 | | $post_id = self::$factory->post->create(); |
| 686 | $post_id = self::factory()->post->create(); |
687 | 687 | $this->go_to( "/?p=$post_id" ); |
688 | 688 | |
689 | 689 | $post = get_queried_object(); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
714 | 714 | ) ); |
715 | 715 | |
716 | 716 | // Create parent and child posts |
717 | | $parent_id = self::$factory->post->create( array( |
| 717 | $parent_id = self::factory()->post->create( array( |
718 | 718 | 'post_type' => $post_type, |
719 | 719 | 'post_name' => 'foo' |
720 | 720 | ) ); |
721 | 721 | |
722 | | $post_id = self::$factory->post->create( array( |
| 722 | $post_id = self::factory()->post->create( array( |
723 | 723 | 'post_type' => $post_type, |
724 | 724 | 'post_name' => 'bar', |
725 | 725 | 'post_parent' => $parent_id |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
750 | 750 | * @ticket 24674 |
751 | 751 | */ |
752 | 752 | public function test_is_single_with_slug_that_begins_with_a_number_that_clashes_with_another_post_id() { |
753 | | $p1 = self::$factory->post->create(); |
| 753 | $p1 = self::factory()->post->create(); |
754 | 754 | |
755 | 755 | $p2_name = $p1 . '-post'; |
756 | | $p2 = self::$factory->post->create( array( |
| 756 | $p2 = self::factory()->post->create( array( |
757 | 757 | 'slug' => $p2_name, |
758 | 758 | ) ); |
759 | 759 | |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
768 | 768 | } |
769 | 769 | |
770 | 770 | function test_is_page() { |
771 | | $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 771 | $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
772 | 772 | $this->go_to( "/?page_id=$post_id" ); |
773 | 773 | |
774 | 774 | $post = get_queried_object(); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
788 | 788 | * @ticket 16802 |
789 | 789 | */ |
790 | 790 | function test_is_page_with_parent() { |
791 | | $parent_id = self::$factory->post->create( array( |
| 791 | $parent_id = self::factory()->post->create( array( |
792 | 792 | 'post_type' => 'page', |
793 | 793 | 'post_name' => 'foo', |
794 | 794 | ) ); |
795 | | $post_id = self::$factory->post->create( array( |
| 795 | $post_id = self::factory()->post->create( array( |
796 | 796 | 'post_type' => 'page', |
797 | 797 | 'post_name' => 'bar', |
798 | 798 | 'post_parent' => $parent_id, |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
818 | 818 | } |
819 | 819 | |
820 | 820 | function test_is_attachment() { |
821 | | $post_id = self::$factory->post->create( array( 'post_type' => 'attachment' ) ); |
| 821 | $post_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) ); |
822 | 822 | $this->go_to( "/?attachment_id=$post_id" ); |
823 | 823 | |
824 | 824 | $post = get_queried_object(); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
839 | 839 | * @ticket 24674 |
840 | 840 | */ |
841 | 841 | public function test_is_attachment_with_slug_that_begins_with_a_number_that_clashes_with_a_page_ID() { |
842 | | $p1 = self::$factory->post->create( array( 'post_type' => 'attachment' ) ); |
| 842 | $p1 = self::factory()->post->create( array( 'post_type' => 'attachment' ) ); |
843 | 843 | |
844 | 844 | $p2_name = $p1 . '-attachment'; |
845 | | $p2 = self::$factory->post->create( array( |
| 845 | $p2 = self::factory()->post->create( array( |
846 | 846 | 'post_type' => 'attachment', |
847 | 847 | 'post_name' => $p2_name, |
848 | 848 | ) ); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
861 | 861 | * @ticket 24674 |
862 | 862 | */ |
863 | 863 | public function test_is_author_with_nicename_that_begins_with_a_number_that_clashes_with_another_author_id() { |
864 | | $u1 = self::$factory->user->create(); |
| 864 | $u1 = self::factory()->user->create(); |
865 | 865 | |
866 | 866 | $u2_name = $u1 . '_user'; |
867 | | $u2 = self::$factory->user->create( array( |
| 867 | $u2 = self::factory()->user->create( array( |
868 | 868 | 'user_nicename' => $u2_name, |
869 | 869 | ) ); |
870 | 870 | |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
882 | 882 | * @ticket 24674 |
883 | 883 | */ |
884 | 884 | public function test_is_category_with_slug_that_begins_with_a_number_that_clashes_with_another_category_id() { |
885 | | $c1 = self::$factory->category->create(); |
| 885 | $c1 = self::factory()->category->create(); |
886 | 886 | |
887 | 887 | $c2_name = $c1 . '-category'; |
888 | | $c2 = self::$factory->category->create( array( |
| 888 | $c2 = self::factory()->category->create( array( |
889 | 889 | 'slug' => $c2_name, |
890 | 890 | ) ); |
891 | 891 | |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
903 | 903 | * @ticket 24674 |
904 | 904 | */ |
905 | 905 | public function test_is_tag_with_slug_that_begins_with_a_number_that_clashes_with_another_tag_id() { |
906 | | $t1 = self::$factory->tag->create(); |
| 906 | $t1 = self::factory()->tag->create(); |
907 | 907 | |
908 | 908 | $t2_name = $t1 . '-tag'; |
909 | | $t2 = self::$factory->tag->create( array( |
| 909 | $t2 = self::factory()->tag->create( array( |
910 | 910 | 'slug' => $t2_name, |
911 | 911 | ) ); |
912 | 912 | |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
924 | 924 | * @ticket 24674 |
925 | 925 | */ |
926 | 926 | public function test_is_page_with_page_id_zero_and_random_page_slug() { |
927 | | $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 927 | $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
928 | 928 | $this->go_to( "/?page_id=$post_id" ); |
929 | 929 | |
930 | 930 | // override post ID to 0 temporarily for testing |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
946 | 946 | * @ticket 24674 |
947 | 947 | */ |
948 | 948 | public function test_is_page_with_page_slug_that_begins_with_a_number_that_clashes_with_a_page_ID() { |
949 | | $p1 = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 949 | $p1 = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
950 | 950 | |
951 | 951 | $p2_name = $p1 . '-page'; |
952 | | $p2 = self::$factory->post->create( array( |
| 952 | $p2 = self::factory()->post->create( array( |
953 | 953 | 'post_type' => 'page', |
954 | 954 | 'post_name' => $p2_name, |
955 | 955 | ) ); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
965 | 965 | } |
966 | 966 | |
967 | 967 | function test_is_page_template() { |
968 | | $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 968 | $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
969 | 969 | update_post_meta($post_id, '_wp_page_template', 'example.php'); |
970 | 970 | $this->go_to( "/?page_id=$post_id" ); |
971 | 971 | $this->assertTrue( is_page_template( 'example.php' ) ); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
975 | 975 | * @ticket 31271 |
976 | 976 | */ |
977 | 977 | function test_is_page_template_default() { |
978 | | $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 978 | $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
979 | 979 | $this->go_to( "/?page_id=$post_id" ); |
980 | 980 | $this->assertTrue( is_page_template( 'default' ) ); |
981 | 981 | $this->assertTrue( is_page_template( array( 'random', 'default' ) ) ); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
985 | 985 | * @ticket 31271 |
986 | 986 | */ |
987 | 987 | function test_is_page_template_array() { |
988 | | $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 988 | $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
989 | 989 | update_post_meta($post_id, '_wp_page_template', 'example.php'); |
990 | 990 | $this->go_to( "/?page_id=$post_id" ); |
991 | 991 | $this->assertFalse( is_page_template( array( 'test.php' ) ) ); |
-
diff --git tests/phpunit/tests/query/dateQuery.php tests/phpunit/tests/query/dateQuery.php
index 0e79426..f40302d 100644
|
|
class Tests_Query_DateQuery extends WP_UnitTestCase { |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function test_date_query_before_array() { |
36 | | $p1 = self::$factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) ); |
37 | | $p2 = self::$factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) ); |
38 | | $p3 = self::$factory->post->create( array( 'post_date' => '2008-07-15 07:17:23',) ); |
39 | | $p4 = self::$factory->post->create( array( 'post_date' => '2009-06-11 07:17:23',) ); |
| 36 | $p1 = self::factory()->post->create( array( 'post_date' => '2007-09-24 07:17:23',) ); |
| 37 | $p2 = self::factory()->post->create( array( 'post_date' => '2008-03-29 07:17:23',) ); |
| 38 | $p3 = self::factory()->post->create( array( 'post_date' => '2008-07-15 07:17:23',) ); |
| 39 | $p4 = self::factory()->post->create( array( 'post_date' => '2009-06-11 07:17:23',) ); |
40 | 40 | |
41 | 41 | $posts = $this->_get_query_result( array( |
42 | 42 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
57 | 57 | * their minimum values when being used with "before". |
58 | 58 | */ |
59 | 59 | public function test_date_query_before_array_test_defaulting() { |
60 | | $p1 = self::$factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) ); |
61 | | $p2 = self::$factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) ); |
| 60 | $p1 = self::factory()->post->create( array( 'post_date' => '2007-09-24 07:17:23',) ); |
| 61 | $p2 = self::factory()->post->create( array( 'post_date' => '2008-03-29 07:17:23',) ); |
62 | 62 | |
63 | 63 | $posts = $this->_get_query_result( array( |
64 | 64 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
74 | 74 | } |
75 | 75 | |
76 | 76 | public function test_date_query_before_string() { |
77 | | $p1 = self::$factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) ); |
78 | | $p2 = self::$factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) ); |
79 | | $p3 = self::$factory->post->create( array( 'post_date' => '2008-07-15 07:17:23',) ); |
80 | | $p4 = self::$factory->post->create( array( 'post_date' => '2009-06-11 07:17:23',) ); |
| 77 | $p1 = self::factory()->post->create( array( 'post_date' => '2007-09-24 07:17:23',) ); |
| 78 | $p2 = self::factory()->post->create( array( 'post_date' => '2008-03-29 07:17:23',) ); |
| 79 | $p3 = self::factory()->post->create( array( 'post_date' => '2008-07-15 07:17:23',) ); |
| 80 | $p4 = self::factory()->post->create( array( 'post_date' => '2009-06-11 07:17:23',) ); |
81 | 81 | |
82 | 82 | $posts = $this->_get_query_result( array( |
83 | 83 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
91 | 91 | } |
92 | 92 | |
93 | 93 | public function test_date_query_after_array() { |
94 | | $p1 = self::$factory->post->create( array( 'post_date' => '2009-10-18 10:42:29', ) ); |
95 | | $p2 = self::$factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) ); |
96 | | $p3 = self::$factory->post->create( array( 'post_date' => '2010-06-11 07:17:23', ) ); |
| 94 | $p1 = self::factory()->post->create( array( 'post_date' => '2009-10-18 10:42:29', ) ); |
| 95 | $p2 = self::factory()->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) ); |
| 96 | $p3 = self::factory()->post->create( array( 'post_date' => '2010-06-11 07:17:23', ) ); |
97 | 97 | |
98 | 98 | $posts = $this->_get_query_result( array( |
99 | 99 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
115 | 115 | * their maximum values when being used with "after". |
116 | 116 | */ |
117 | 117 | public function test_date_query_after_array_test_defaulting() { |
118 | | $p1 = self::$factory->post->create( array( 'post_date' => '2008-12-18 10:42:29', ) ); |
119 | | $p2 = self::$factory->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) ); |
| 118 | $p1 = self::factory()->post->create( array( 'post_date' => '2008-12-18 10:42:29', ) ); |
| 119 | $p2 = self::factory()->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) ); |
120 | 120 | |
121 | 121 | $posts = $this->_get_query_result( array( |
122 | 122 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
132 | 132 | } |
133 | 133 | |
134 | 134 | public function test_date_query_after_string() { |
135 | | $p1 = self::$factory->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) ); |
136 | | $p2 = self::$factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) ); |
137 | | $p3 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); |
| 135 | $p1 = self::factory()->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) ); |
| 136 | $p2 = self::factory()->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) ); |
| 137 | $p3 = self::factory()->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); |
138 | 138 | |
139 | 139 | $posts = $this->_get_query_result( array( |
140 | 140 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
148 | 148 | } |
149 | 149 | |
150 | 150 | public function test_date_query_after_string_inclusive() { |
151 | | $p1 = self::$factory->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) ); |
152 | | $p2 = self::$factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) ); |
153 | | $p3 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); |
| 151 | $p1 = self::factory()->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) ); |
| 152 | $p2 = self::factory()->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) ); |
| 153 | $p3 = self::factory()->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); |
154 | 154 | |
155 | 155 | $posts = $this->_get_query_result( array( |
156 | 156 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
168 | 168 | * @ticket 26653 |
169 | 169 | */ |
170 | 170 | public function test_date_query_inclusive_between_dates() { |
171 | | $p1 = self::$factory->post->create( array( 'post_date' => '2006-12-18 09:42:29', ) ); |
172 | | $p2 = self::$factory->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) ); |
173 | | $p3 = self::$factory->post->create( array( 'post_date' => '2007-12-19 10:42:29', ) ); |
174 | | $p4 = self::$factory->post->create( array( 'post_date' => '2008-12-19 10:42:29', ) ); |
175 | | $p5 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); |
| 171 | $p1 = self::factory()->post->create( array( 'post_date' => '2006-12-18 09:42:29', ) ); |
| 172 | $p2 = self::factory()->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) ); |
| 173 | $p3 = self::factory()->post->create( array( 'post_date' => '2007-12-19 10:42:29', ) ); |
| 174 | $p4 = self::factory()->post->create( array( 'post_date' => '2008-12-19 10:42:29', ) ); |
| 175 | $p5 = self::factory()->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); |
176 | 176 | |
177 | 177 | $posts = $this->_get_query_result( array( |
178 | 178 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
195 | 195 | * @ticket 29908 |
196 | 196 | */ |
197 | 197 | public function test_beforeafter_with_date_string_Y() { |
198 | | $p1 = self::$factory->post->create( array( |
| 198 | $p1 = self::factory()->post->create( array( |
199 | 199 | 'post_date' => '2008-05-06 13:00:00', |
200 | 200 | ) ); |
201 | | $p2 = self::$factory->post->create( array( |
| 201 | $p2 = self::factory()->post->create( array( |
202 | 202 | 'post_date' => '2007-05-07 13:00:00', |
203 | 203 | ) ); |
204 | 204 | |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
228 | 228 | * @ticket 29908 |
229 | 229 | */ |
230 | 230 | public function test_beforeafter_with_date_string_Y_inclusive() { |
231 | | $p1 = self::$factory->post->create( array( |
| 231 | $p1 = self::factory()->post->create( array( |
232 | 232 | 'post_date' => '2008-05-06 13:00:00', |
233 | 233 | ) ); |
234 | | $p2 = self::$factory->post->create( array( |
| 234 | $p2 = self::factory()->post->create( array( |
235 | 235 | 'post_date' => '2007-05-07 13:00:00', |
236 | 236 | ) ); |
237 | 237 | |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
263 | 263 | * @ticket 29908 |
264 | 264 | */ |
265 | 265 | public function test_beforeafter_with_date_string_Ym() { |
266 | | $p1 = self::$factory->post->create( array( |
| 266 | $p1 = self::factory()->post->create( array( |
267 | 267 | 'post_date' => '2008-05-06 13:00:00', |
268 | 268 | ) ); |
269 | | $p2 = self::$factory->post->create( array( |
| 269 | $p2 = self::factory()->post->create( array( |
270 | 270 | 'post_date' => '2008-04-07 13:00:00', |
271 | 271 | ) ); |
272 | 272 | |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
296 | 296 | * @ticket 29908 |
297 | 297 | */ |
298 | 298 | public function test_beforeafter_with_date_string_Ym_inclusive() { |
299 | | $p1 = self::$factory->post->create( array( |
| 299 | $p1 = self::factory()->post->create( array( |
300 | 300 | 'post_date' => '2008-05-06 13:00:00', |
301 | 301 | ) ); |
302 | | $p2 = self::$factory->post->create( array( |
| 302 | $p2 = self::factory()->post->create( array( |
303 | 303 | 'post_date' => '2008-04-07 13:00:00', |
304 | 304 | ) ); |
305 | 305 | |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
331 | 331 | * @ticket 29908 |
332 | 332 | */ |
333 | 333 | public function test_beforeafter_with_date_string_Ymd() { |
334 | | $p1 = self::$factory->post->create( array( |
| 334 | $p1 = self::factory()->post->create( array( |
335 | 335 | 'post_date' => '2008-05-06 13:00:00', |
336 | 336 | ) ); |
337 | | $p2 = self::$factory->post->create( array( |
| 337 | $p2 = self::factory()->post->create( array( |
338 | 338 | 'post_date' => '2008-05-05 13:00:00', |
339 | 339 | ) ); |
340 | 340 | |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
364 | 364 | * @ticket 29908 |
365 | 365 | */ |
366 | 366 | public function test_beforeafter_with_date_string_Ymd_inclusive() { |
367 | | $p1 = self::$factory->post->create( array( |
| 367 | $p1 = self::factory()->post->create( array( |
368 | 368 | 'post_date' => '2008-05-06 13:00:00', |
369 | 369 | ) ); |
370 | | $p2 = self::$factory->post->create( array( |
| 370 | $p2 = self::factory()->post->create( array( |
371 | 371 | 'post_date' => '2008-05-05 13:00:00', |
372 | 372 | ) ); |
373 | 373 | |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
399 | 399 | * @ticket 29908 |
400 | 400 | */ |
401 | 401 | public function test_beforeafter_with_date_string_YmdHi() { |
402 | | $p1 = self::$factory->post->create( array( |
| 402 | $p1 = self::factory()->post->create( array( |
403 | 403 | 'post_date' => '2008-05-06 14:05:00', |
404 | 404 | ) ); |
405 | | $p2 = self::$factory->post->create( array( |
| 405 | $p2 = self::factory()->post->create( array( |
406 | 406 | 'post_date' => '2008-05-06 14:04:00', |
407 | 407 | ) ); |
408 | 408 | |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
432 | 432 | * @ticket 29908 |
433 | 433 | */ |
434 | 434 | public function test_beforeafter_with_date_string_YmdHi_inclusive() { |
435 | | $p1 = self::$factory->post->create( array( |
| 435 | $p1 = self::factory()->post->create( array( |
436 | 436 | 'post_date' => '2008-05-06 14:05:00', |
437 | 437 | ) ); |
438 | | $p2 = self::$factory->post->create( array( |
| 438 | $p2 = self::factory()->post->create( array( |
439 | 439 | 'post_date' => '2008-05-06 14:04:00', |
440 | 440 | ) ); |
441 | 441 | |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
467 | 467 | * @ticket 29908 |
468 | 468 | */ |
469 | 469 | public function test_beforeafter_with_date_string_YmdHis() { |
470 | | $p1 = self::$factory->post->create( array( |
| 470 | $p1 = self::factory()->post->create( array( |
471 | 471 | 'post_date' => '2008-05-06 14:05:15', |
472 | 472 | ) ); |
473 | | $p2 = self::$factory->post->create( array( |
| 473 | $p2 = self::factory()->post->create( array( |
474 | 474 | 'post_date' => '2008-05-06 14:05:14', |
475 | 475 | ) ); |
476 | 476 | |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
500 | 500 | * @ticket 29908 |
501 | 501 | */ |
502 | 502 | public function test_beforeafter_with_date_string_YmdHis_inclusive() { |
503 | | $p1 = self::$factory->post->create( array( |
| 503 | $p1 = self::factory()->post->create( array( |
504 | 504 | 'post_date' => '2008-05-06 14:04:15', |
505 | 505 | ) ); |
506 | | $p2 = self::$factory->post->create( array( |
| 506 | $p2 = self::factory()->post->create( array( |
507 | 507 | 'post_date' => '2008-05-06 14:04:14', |
508 | 508 | ) ); |
509 | 509 | |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
535 | 535 | * @ticket 29908 |
536 | 536 | */ |
537 | 537 | public function test_beforeafter_with_date_string_non_parseable() { |
538 | | $p1 = self::$factory->post->create( array( |
| 538 | $p1 = self::factory()->post->create( array( |
539 | 539 | 'post_date' => '2008-05-06 14:05:15', |
540 | 540 | ) ); |
541 | | $p2 = self::$factory->post->create( array( |
| 541 | $p2 = self::factory()->post->create( array( |
542 | 542 | 'post_date' => '2008-05-06 14:05:14', |
543 | 543 | ) ); |
544 | 544 | |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
564 | 564 | } |
565 | 565 | |
566 | 566 | public function test_date_query_year() { |
567 | | $p1 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); |
568 | | $p2 = self::$factory->post->create( array( 'post_date' => '2010-12-19 10:42:29', ) ); |
| 567 | $p1 = self::factory()->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); |
| 568 | $p2 = self::factory()->post->create( array( 'post_date' => '2010-12-19 10:42:29', ) ); |
569 | 569 | $posts = $this->_get_query_result( array( |
570 | 570 | 'date_query' => array( |
571 | 571 | array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
578 | 578 | } |
579 | 579 | |
580 | 580 | public function test_date_query_month() { |
581 | | $p1 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); |
582 | | $p2 = self::$factory->post->create( array( 'post_date' => '2010-11-19 10:42:29', ) ); |
| 581 | $p1 = self::factory()->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) ); |
| 582 | $p2 = self::factory()->post->create( array( 'post_date' => '2010-11-19 10:42:29', ) ); |
583 | 583 | $posts = $this->_get_query_result( array( |
584 | 584 | 'date_query' => array( |
585 | 585 | array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
592 | 592 | } |
593 | 593 | |
594 | 594 | public function test_date_query_week() { |
595 | | $p1 = self::$factory->post->create( array( 'post_date' => '2009-01-02 10:42:29', ) ); |
596 | | $p2 = self::$factory->post->create( array( 'post_date' => '2010-03-19 10:42:29', ) ); |
| 595 | $p1 = self::factory()->post->create( array( 'post_date' => '2009-01-02 10:42:29', ) ); |
| 596 | $p2 = self::factory()->post->create( array( 'post_date' => '2010-03-19 10:42:29', ) ); |
597 | 597 | $posts = $this->_get_query_result( array( |
598 | 598 | 'date_query' => array( |
599 | 599 | array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
606 | 606 | } |
607 | 607 | |
608 | 608 | public function test_date_query_day() { |
609 | | $p1 = self::$factory->post->create( array( 'post_date' => '2009-01-17 10:42:29', ) ); |
610 | | $p2 = self::$factory->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) ); |
| 609 | $p1 = self::factory()->post->create( array( 'post_date' => '2009-01-17 10:42:29', ) ); |
| 610 | $p2 = self::factory()->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) ); |
611 | 611 | |
612 | 612 | $posts = $this->_get_query_result( array( |
613 | 613 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
621 | 621 | } |
622 | 622 | |
623 | 623 | public function test_date_query_dayofweek() { |
624 | | $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) ); |
625 | | $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-20 10:42:29', ) ); |
| 624 | $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) ); |
| 625 | $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-20 10:42:29', ) ); |
626 | 626 | |
627 | 627 | $posts = $this->_get_query_result( array( |
628 | 628 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
639 | 639 | * @ticket 28063 |
640 | 640 | */ |
641 | 641 | public function test_date_query_dayofweek_iso() { |
642 | | $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-31 10:42:29', ) ); |
643 | | $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-30 10:42:29', ) ); |
| 642 | $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-31 10:42:29', ) ); |
| 643 | $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-30 10:42:29', ) ); |
644 | 644 | |
645 | 645 | $posts = $this->_get_query_result( array( |
646 | 646 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
654 | 654 | } |
655 | 655 | |
656 | 656 | public function test_date_query_hour() { |
657 | | $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 13:42:29', ) ); |
658 | | $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 12:42:29', ) ); |
| 657 | $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-21 13:42:29', ) ); |
| 658 | $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-21 12:42:29', ) ); |
659 | 659 | |
660 | 660 | $posts = $this->_get_query_result( array( |
661 | 661 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
673 | 673 | */ |
674 | 674 | public function test_date_query_hour_should_not_ignore_0() { |
675 | 675 | return; |
676 | | $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 00:42:29', ) ); |
677 | | $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 01:42:29', ) ); |
| 676 | $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-21 00:42:29', ) ); |
| 677 | $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-21 01:42:29', ) ); |
678 | 678 | |
679 | 679 | $posts = $this->_get_query_result( array( |
680 | 680 | 'year' => 2014, |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
688 | 688 | } |
689 | 689 | |
690 | 690 | public function test_date_query_minute() { |
691 | | $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:56:29', ) ); |
692 | | $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) ); |
| 691 | $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-21 10:56:29', ) ); |
| 692 | $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) ); |
693 | 693 | |
694 | 694 | $posts = $this->_get_query_result( array( |
695 | 695 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
703 | 703 | } |
704 | 704 | |
705 | 705 | public function test_date_query_second() { |
706 | | $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:21', ) ); |
707 | | $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) ); |
| 706 | $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-21 10:42:21', ) ); |
| 707 | $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) ); |
708 | 708 | |
709 | 709 | $posts = $this->_get_query_result( array( |
710 | 710 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
718 | 718 | } |
719 | 719 | |
720 | 720 | public function test_date_query_between_two_times() { |
721 | | $p1 = self::$factory->post->create( array( 'post_date' => '2005-12-18 08:42:29', ) ); |
722 | | $p2 = self::$factory->post->create( array( 'post_date' => '2006-12-18 09:00:29', ) ); |
723 | | $p3 = self::$factory->post->create( array( 'post_date' => '2007-12-18 10:42:29', ) ); |
724 | | $p4 = self::$factory->post->create( array( 'post_date' => '2008-12-18 17:00:29', ) ); |
725 | | $p5 = self::$factory->post->create( array( 'post_date' => '2009-12-18 18:42:29', ) ); |
| 721 | $p1 = self::factory()->post->create( array( 'post_date' => '2005-12-18 08:42:29', ) ); |
| 722 | $p2 = self::factory()->post->create( array( 'post_date' => '2006-12-18 09:00:29', ) ); |
| 723 | $p3 = self::factory()->post->create( array( 'post_date' => '2007-12-18 10:42:29', ) ); |
| 724 | $p4 = self::factory()->post->create( array( 'post_date' => '2008-12-18 17:00:29', ) ); |
| 725 | $p5 = self::factory()->post->create( array( 'post_date' => '2009-12-18 18:42:29', ) ); |
726 | 726 | |
727 | 727 | $posts = $this->_get_query_result( array( |
728 | 728 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
743 | 743 | } |
744 | 744 | |
745 | 745 | public function test_date_query_relation_or() { |
746 | | $p1 = self::$factory->post->create( array( 'post_date' => '2006-12-18 14:42:29', ) ); |
747 | | $p2 = self::$factory->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) ); |
748 | | $p3 = self::$factory->post->create( array( 'post_date' => '2007-12-19 10:34:29', ) ); |
| 746 | $p1 = self::factory()->post->create( array( 'post_date' => '2006-12-18 14:42:29', ) ); |
| 747 | $p2 = self::factory()->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) ); |
| 748 | $p3 = self::factory()->post->create( array( 'post_date' => '2007-12-19 10:34:29', ) ); |
749 | 749 | |
750 | 750 | $posts = $this->_get_query_result( array( |
751 | 751 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
763 | 763 | } |
764 | 764 | |
765 | 765 | public function test_date_query_compare_greater_than_or_equal_to() { |
766 | | $p1 = self::$factory->post->create( array( 'post_date' => '2006-12-18 13:42:29', ) ); |
767 | | $p2 = self::$factory->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) ); |
768 | | $p3 = self::$factory->post->create( array( 'post_date' => '2007-12-19 14:37:29', ) ); |
769 | | $p4 = self::$factory->post->create( array( 'post_date' => '2007-12-19 15:34:29', ) ); |
| 766 | $p1 = self::factory()->post->create( array( 'post_date' => '2006-12-18 13:42:29', ) ); |
| 767 | $p2 = self::factory()->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) ); |
| 768 | $p3 = self::factory()->post->create( array( 'post_date' => '2007-12-19 14:37:29', ) ); |
| 769 | $p4 = self::factory()->post->create( array( 'post_date' => '2007-12-19 15:34:29', ) ); |
770 | 770 | |
771 | 771 | $posts = $this->_get_query_result( array( |
772 | 772 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
784 | 784 | public function test_date_params_monthnum_m_duplicate() { |
785 | 785 | global $wpdb; |
786 | 786 | |
787 | | $p1 = self::$factory->post->create( array( 'post_date' => '2006-05-18 13:42:29', ) ); |
788 | | $p2 = self::$factory->post->create( array( 'post_date' => '2007-09-18 14:34:29', ) ); |
789 | | $p3 = self::$factory->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) ); |
| 787 | $p1 = self::factory()->post->create( array( 'post_date' => '2006-05-18 13:42:29', ) ); |
| 788 | $p2 = self::factory()->post->create( array( 'post_date' => '2007-09-18 14:34:29', ) ); |
| 789 | $p3 = self::factory()->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) ); |
790 | 790 | |
791 | 791 | $posts = $this->_get_query_result( array( |
792 | 792 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
804 | 804 | public function test_date_params_week_w_duplicate() { |
805 | 805 | global $wpdb; |
806 | 806 | |
807 | | $p1 = self::$factory->post->create( array( 'post_date' => '2014-10-01 13:42:29', ) ); |
808 | | $p2 = self::$factory->post->create( array( 'post_date' => '2014-10-22 14:34:29', ) ); |
809 | | $p3 = self::$factory->post->create( array( 'post_date' => '2014-10-15 14:34:29', ) ); |
| 807 | $p1 = self::factory()->post->create( array( 'post_date' => '2014-10-01 13:42:29', ) ); |
| 808 | $p2 = self::factory()->post->create( array( 'post_date' => '2014-10-22 14:34:29', ) ); |
| 809 | $p3 = self::factory()->post->create( array( 'post_date' => '2014-10-15 14:34:29', ) ); |
810 | 810 | |
811 | 811 | $posts = $this->_get_query_result( array( |
812 | 812 | 'date_query' => array( |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
825 | 825 | * @ticket 25775 |
826 | 826 | */ |
827 | 827 | public function test_date_query_with_taxonomy_join() { |
828 | | $p1 = self::$factory->post->create( array( |
| 828 | $p1 = self::factory()->post->create( array( |
829 | 829 | 'post_date' => '2013-04-27 01:01:01', |
830 | 830 | ) ); |
831 | | $p2 = self::$factory->post->create( array( |
| 831 | $p2 = self::factory()->post->create( array( |
832 | 832 | 'post_date' => '2013-03-21 01:01:01', |
833 | 833 | ) ); |
834 | 834 | |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
857 | 857 | * @ticket 29822 |
858 | 858 | */ |
859 | 859 | public function test_date_query_one_nested_query() { |
860 | | $p1 = self::$factory->post->create( array( 'post_date' => '2004-10-01 13:42:29', ) ); |
861 | | $p2 = self::$factory->post->create( array( 'post_date' => '2004-01-22 14:34:29', ) ); |
862 | | $p3 = self::$factory->post->create( array( 'post_date' => '1984-10-15 14:34:29', ) ); |
863 | | $p4 = self::$factory->post->create( array( 'post_date' => '1985-10-15 14:34:29', ) ); |
| 860 | $p1 = self::factory()->post->create( array( 'post_date' => '2004-10-01 13:42:29', ) ); |
| 861 | $p2 = self::factory()->post->create( array( 'post_date' => '2004-01-22 14:34:29', ) ); |
| 862 | $p3 = self::factory()->post->create( array( 'post_date' => '1984-10-15 14:34:29', ) ); |
| 863 | $p4 = self::factory()->post->create( array( 'post_date' => '1985-10-15 14:34:29', ) ); |
864 | 864 | $posts = $this->_get_query_result( array( |
865 | 865 | 'date_query' => array( |
866 | 866 | 'relation' => 'OR', |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
886 | 886 | * @ticket 29822 |
887 | 887 | */ |
888 | 888 | public function test_date_query_one_nested_query_multiple_columns_relation_and() { |
889 | | $p1 = self::$factory->post->create( array( |
| 889 | $p1 = self::factory()->post->create( array( |
890 | 890 | 'post_date' => '2012-03-05 15:30:55', |
891 | 891 | ) ); |
892 | 892 | $this->update_post_modified( $p1, '2014-11-03 14:43:00' ); |
893 | 893 | |
894 | | $p2 = self::$factory->post->create( array( |
| 894 | $p2 = self::factory()->post->create( array( |
895 | 895 | 'post_date' => '2012-05-05 15:30:55', |
896 | 896 | ) ); |
897 | 897 | $this->update_post_modified( $p2, '2014-10-03 14:43:00' ); |
898 | 898 | |
899 | | $p3 = self::$factory->post->create( array( |
| 899 | $p3 = self::factory()->post->create( array( |
900 | 900 | 'post_date' => '2013-05-05 15:30:55', |
901 | 901 | ) ); |
902 | 902 | $this->update_post_modified( $p3, '2014-10-03 14:43:00' ); |
903 | 903 | |
904 | | $p4 = self::$factory->post->create( array( |
| 904 | $p4 = self::factory()->post->create( array( |
905 | 905 | 'post_date' => '2012-02-05 15:30:55', |
906 | 906 | ) ); |
907 | 907 | $this->update_post_modified( $p4, '2012-12-03 14:43:00' ); |
… |
… |
class Tests_Query_DateQuery extends WP_UnitTestCase { |
937 | 937 | * @ticket 29822 |
938 | 938 | */ |
939 | 939 | public function test_date_query_nested_query_multiple_columns_mixed_relations() { |
940 | | $p1 = self::$factory->post->create( array( |
| 940 | $p1 = self::factory()->post->create( array( |
941 | 941 | 'post_date' => '2012-03-05 15:30:55', |
942 | 942 | ) ); |
943 | 943 | $this->update_post_modified( $p1, '2014-11-03 14:43:00' ); |
944 | 944 | |
945 | | $p2 = self::$factory->post->create( array( |
| 945 | $p2 = self::factory()->post->create( array( |
946 | 946 | 'post_date' => '2012-05-05 15:30:55', |
947 | 947 | ) ); |
948 | 948 | $this->update_post_modified( $p2, '2014-10-03 14:43:00' ); |
949 | 949 | |
950 | | $p3 = self::$factory->post->create( array( |
| 950 | $p3 = self::factory()->post->create( array( |
951 | 951 | 'post_date' => '2013-05-05 15:30:55', |
952 | 952 | ) ); |
953 | 953 | $this->update_post_modified( $p3, '2014-10-03 14:43:00' ); |
954 | 954 | |
955 | | $p4 = self::$factory->post->create( array( |
| 955 | $p4 = self::factory()->post->create( array( |
956 | 956 | 'post_date' => '2012-02-05 15:30:55', |
957 | 957 | ) ); |
958 | 958 | $this->update_post_modified( $p4, '2012-12-03 14:43:00' ); |
959 | 959 | |
960 | | $p5 = self::$factory->post->create( array( |
| 960 | $p5 = self::factory()->post->create( array( |
961 | 961 | 'post_date' => '2014-02-05 15:30:55', |
962 | 962 | ) ); |
963 | 963 | $this->update_post_modified( $p5, '2013-12-03 14:43:00' ); |
-
diff --git tests/phpunit/tests/query/isTerm.php tests/phpunit/tests/query/isTerm.php
index 6dcf4c9..c9a4160 100644
|
|
class Tests_Query_IsTerm extends WP_UnitTestCase { |
37 | 37 | |
38 | 38 | flush_rewrite_rules(); |
39 | 39 | |
40 | | $this->tag_id = self::$factory->tag->create( array( 'slug' => 'tag-slug' ) ); |
41 | | $this->cat_id = self::$factory->category->create( array( 'slug' => 'cat-slug' ) ); |
42 | | $this->tax_id = self::$factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug' ) ); |
43 | | $this->tax_id2 = self::$factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug2' ) ); |
44 | | $this->post_id = self::$factory->post->create(); |
| 40 | $this->tag_id = self::factory()->tag->create( array( 'slug' => 'tag-slug' ) ); |
| 41 | $this->cat_id = self::factory()->category->create( array( 'slug' => 'cat-slug' ) ); |
| 42 | $this->tax_id = self::factory()->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug' ) ); |
| 43 | $this->tax_id2 = self::factory()->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug2' ) ); |
| 44 | $this->post_id = self::factory()->post->create(); |
45 | 45 | wp_set_object_terms( $this->post_id, $this->cat_id, 'category' ); |
46 | 46 | wp_set_object_terms( $this->post_id, array( $this->tax_id, $this->tax_id2 ), 'testtax' ); |
47 | 47 | |
… |
… |
class Tests_Query_IsTerm extends WP_UnitTestCase { |
245 | 245 | remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) ); |
246 | 246 | |
247 | 247 | register_taxonomy( 'testtax2', 'post' ); |
248 | | $testtax2_term_id = self::$factory->term->create( array( |
| 248 | $testtax2_term_id = self::factory()->term->create( array( |
249 | 249 | 'taxonomy' => 'testtax2', |
250 | 250 | 'slug' => 'testtax2-slug', |
251 | 251 | ) ); |
-
diff --git tests/phpunit/tests/query/metaQuery.php tests/phpunit/tests/query/metaQuery.php
index 1bc5aab..2a9717a 100644
|
|
|
6 | 6 | */ |
7 | 7 | class Tests_Query_MetaQuery extends WP_UnitTestCase { |
8 | 8 | public function test_meta_query_no_key() { |
9 | | $p1 = self::$factory->post->create(); |
10 | | $p2 = self::$factory->post->create(); |
11 | | $p3 = self::$factory->post->create(); |
| 9 | $p1 = self::factory()->post->create(); |
| 10 | $p2 = self::factory()->post->create(); |
| 11 | $p3 = self::factory()->post->create(); |
12 | 12 | |
13 | 13 | add_post_meta( $p1, 'foo', 'bar' ); |
14 | 14 | add_post_meta( $p2, 'oof', 'bar' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function test_meta_query_no_value() { |
33 | | $p1 = self::$factory->post->create(); |
34 | | $p2 = self::$factory->post->create(); |
35 | | $p3 = self::$factory->post->create(); |
| 33 | $p1 = self::factory()->post->create(); |
| 34 | $p2 = self::factory()->post->create(); |
| 35 | $p3 = self::factory()->post->create(); |
36 | 36 | |
37 | 37 | add_post_meta( $p1, 'foo', 'bar' ); |
38 | 38 | add_post_meta( $p2, 'oof', 'bar' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
54 | 54 | } |
55 | 55 | |
56 | 56 | public function test_meta_query_single_query_compare_default() { |
57 | | $p1 = self::$factory->post->create(); |
58 | | $p2 = self::$factory->post->create(); |
| 57 | $p1 = self::factory()->post->create(); |
| 58 | $p2 = self::factory()->post->create(); |
59 | 59 | |
60 | 60 | add_post_meta( $p1, 'foo', 'bar' ); |
61 | 61 | |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
76 | 76 | } |
77 | 77 | |
78 | 78 | public function test_meta_query_single_query_compare_equals() { |
79 | | $p1 = self::$factory->post->create(); |
80 | | $p2 = self::$factory->post->create(); |
| 79 | $p1 = self::factory()->post->create(); |
| 80 | $p2 = self::factory()->post->create(); |
81 | 81 | |
82 | 82 | add_post_meta( $p1, 'foo', 'bar' ); |
83 | 83 | |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
99 | 99 | } |
100 | 100 | |
101 | 101 | public function test_meta_query_single_query_compare_not_equals() { |
102 | | $p1 = self::$factory->post->create(); |
103 | | $p2 = self::$factory->post->create(); |
104 | | $p3 = self::$factory->post->create(); |
| 102 | $p1 = self::factory()->post->create(); |
| 103 | $p2 = self::factory()->post->create(); |
| 104 | $p3 = self::factory()->post->create(); |
105 | 105 | |
106 | 106 | add_post_meta( $p1, 'foo', 'bar' ); |
107 | 107 | add_post_meta( $p2, 'foo', 'baz' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
124 | 124 | } |
125 | 125 | |
126 | 126 | public function test_meta_query_single_query_compare_arithmetic_comparisons() { |
127 | | $p1 = self::$factory->post->create(); |
128 | | $p2 = self::$factory->post->create(); |
129 | | $p3 = self::$factory->post->create(); |
| 127 | $p1 = self::factory()->post->create(); |
| 128 | $p2 = self::factory()->post->create(); |
| 129 | $p3 = self::factory()->post->create(); |
130 | 130 | |
131 | 131 | add_post_meta( $p1, 'foo', '1' ); |
132 | 132 | add_post_meta( $p2, 'foo', '2' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
202 | 202 | } |
203 | 203 | |
204 | 204 | public function test_meta_query_single_query_compare_like() { |
205 | | $p1 = self::$factory->post->create(); |
206 | | $p2 = self::$factory->post->create(); |
| 205 | $p1 = self::factory()->post->create(); |
| 206 | $p2 = self::factory()->post->create(); |
207 | 207 | |
208 | 208 | add_post_meta( $p1, 'foo', 'bar' ); |
209 | 209 | |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
225 | 225 | } |
226 | 226 | |
227 | 227 | public function test_meta_query_single_query_compare_not_like() { |
228 | | $p1 = self::$factory->post->create(); |
229 | | $p2 = self::$factory->post->create(); |
230 | | $p3 = self::$factory->post->create(); |
| 228 | $p1 = self::factory()->post->create(); |
| 229 | $p2 = self::factory()->post->create(); |
| 230 | $p3 = self::factory()->post->create(); |
231 | 231 | |
232 | 232 | add_post_meta( $p1, 'foo', 'bar' ); |
233 | 233 | add_post_meta( $p2, 'foo', 'rab' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
250 | 250 | } |
251 | 251 | |
252 | 252 | public function test_meta_query_single_query_compare_between_not_between() { |
253 | | $p1 = self::$factory->post->create(); |
254 | | $p2 = self::$factory->post->create(); |
255 | | $p3 = self::$factory->post->create(); |
| 253 | $p1 = self::factory()->post->create(); |
| 254 | $p2 = self::factory()->post->create(); |
| 255 | $p3 = self::factory()->post->create(); |
256 | 256 | |
257 | 257 | add_post_meta( $p1, 'foo', '1' ); |
258 | 258 | add_post_meta( $p2, 'foo', '10' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
294 | 294 | } |
295 | 295 | |
296 | 296 | public function test_meta_query_single_query_compare_regexp_rlike() { |
297 | | $p1 = self::$factory->post->create(); |
298 | | $p2 = self::$factory->post->create(); |
| 297 | $p1 = self::factory()->post->create(); |
| 298 | $p2 = self::factory()->post->create(); |
299 | 299 | |
300 | 300 | add_post_meta( $p1, 'foo', 'bar' ); |
301 | 301 | add_post_meta( $p2, 'foo', 'baz' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
335 | 335 | } |
336 | 336 | |
337 | 337 | public function test_meta_query_single_query_compare_not_regexp() { |
338 | | $p1 = self::$factory->post->create(); |
339 | | $p2 = self::$factory->post->create(); |
| 338 | $p1 = self::factory()->post->create(); |
| 339 | $p2 = self::factory()->post->create(); |
340 | 340 | |
341 | 341 | add_post_meta( $p1, 'foo', 'bar' ); |
342 | 342 | add_post_meta( $p2, 'foo', 'baz' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
359 | 359 | } |
360 | 360 | |
361 | 361 | public function test_meta_query_relation_default() { |
362 | | $p1 = self::$factory->post->create(); |
363 | | $p2 = self::$factory->post->create(); |
364 | | $p3 = self::$factory->post->create(); |
| 362 | $p1 = self::factory()->post->create(); |
| 363 | $p2 = self::factory()->post->create(); |
| 364 | $p3 = self::factory()->post->create(); |
365 | 365 | |
366 | 366 | add_post_meta( $p1, 'foo', 'foo value 1' ); |
367 | 367 | add_post_meta( $p1, 'bar', 'bar value 1' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
389 | 389 | } |
390 | 390 | |
391 | 391 | public function test_meta_query_relation_or() { |
392 | | $post_id = self::$factory->post->create(); |
| 392 | $post_id = self::factory()->post->create(); |
393 | 393 | add_post_meta( $post_id, 'foo', rand_str() ); |
394 | 394 | add_post_meta( $post_id, 'foo', rand_str() ); |
395 | | $post_id2 = self::$factory->post->create(); |
| 395 | $post_id2 = self::factory()->post->create(); |
396 | 396 | add_post_meta( $post_id2, 'bar', 'val2' ); |
397 | | $post_id3 = self::$factory->post->create(); |
| 397 | $post_id3 = self::factory()->post->create(); |
398 | 398 | add_post_meta( $post_id3, 'baz', rand_str() ); |
399 | | $post_id4 = self::$factory->post->create(); |
| 399 | $post_id4 = self::factory()->post->create(); |
400 | 400 | add_post_meta( $post_id4, 'froo', rand_str() ); |
401 | | $post_id5 = self::$factory->post->create(); |
| 401 | $post_id5 = self::factory()->post->create(); |
402 | 402 | add_post_meta( $post_id5, 'tango', 'val2' ); |
403 | | $post_id6 = self::$factory->post->create(); |
| 403 | $post_id6 = self::factory()->post->create(); |
404 | 404 | add_post_meta( $post_id6, 'bar', 'val1' ); |
405 | 405 | |
406 | 406 | $query = new WP_Query( array( |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
430 | 430 | } |
431 | 431 | |
432 | 432 | public function test_meta_query_relation_and() { |
433 | | $post_id = self::$factory->post->create(); |
| 433 | $post_id = self::factory()->post->create(); |
434 | 434 | add_post_meta( $post_id, 'foo', rand_str() ); |
435 | 435 | add_post_meta( $post_id, 'foo', rand_str() ); |
436 | | $post_id2 = self::$factory->post->create(); |
| 436 | $post_id2 = self::factory()->post->create(); |
437 | 437 | add_post_meta( $post_id2, 'bar', 'val2' ); |
438 | 438 | add_post_meta( $post_id2, 'foo', rand_str() ); |
439 | | $post_id3 = self::$factory->post->create(); |
| 439 | $post_id3 = self::factory()->post->create(); |
440 | 440 | add_post_meta( $post_id3, 'baz', rand_str() ); |
441 | | $post_id4 = self::$factory->post->create(); |
| 441 | $post_id4 = self::factory()->post->create(); |
442 | 442 | add_post_meta( $post_id4, 'froo', rand_str() ); |
443 | | $post_id5 = self::$factory->post->create(); |
| 443 | $post_id5 = self::factory()->post->create(); |
444 | 444 | add_post_meta( $post_id5, 'tango', 'val2' ); |
445 | | $post_id6 = self::$factory->post->create(); |
| 445 | $post_id6 = self::factory()->post->create(); |
446 | 446 | add_post_meta( $post_id6, 'bar', 'val1' ); |
447 | 447 | add_post_meta( $post_id6, 'foo', rand_str() ); |
448 | | $post_id7 = self::$factory->post->create(); |
| 448 | $post_id7 = self::factory()->post->create(); |
449 | 449 | add_post_meta( $post_id7, 'foo', rand_str() ); |
450 | 450 | add_post_meta( $post_id7, 'froo', rand_str() ); |
451 | 451 | add_post_meta( $post_id7, 'baz', rand_str() ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
499 | 499 | * @ticket 30681 |
500 | 500 | */ |
501 | 501 | public function test_meta_query_compare_exists() { |
502 | | $posts = self::$factory->post->create_many( 3 ); |
| 502 | $posts = self::factory()->post->create_many( 3 ); |
503 | 503 | add_post_meta( $posts[0], 'foo', 'bar' ); |
504 | 504 | add_post_meta( $posts[2], 'foo', 'baz' ); |
505 | 505 | |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
520 | 520 | * @ticket 30681 |
521 | 521 | */ |
522 | 522 | public function test_meta_query_compare_exists_with_value_should_convert_to_equals() { |
523 | | $posts = self::$factory->post->create_many( 3 ); |
| 523 | $posts = self::factory()->post->create_many( 3 ); |
524 | 524 | add_post_meta( $posts[0], 'foo', 'bar' ); |
525 | 525 | add_post_meta( $posts[2], 'foo', 'baz' ); |
526 | 526 | |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
542 | 542 | * @ticket 30681 |
543 | 543 | */ |
544 | 544 | public function test_meta_query_compare_not_exists_should_ignore_value() { |
545 | | $posts = self::$factory->post->create_many( 3 ); |
| 545 | $posts = self::factory()->post->create_many( 3 ); |
546 | 546 | add_post_meta( $posts[0], 'foo', 'bar' ); |
547 | 547 | add_post_meta( $posts[2], 'foo', 'baz' ); |
548 | 548 | |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
564 | 564 | * @ticket 18158 |
565 | 565 | */ |
566 | 566 | public function test_meta_query_compare_not_exists() { |
567 | | $post_id = self::$factory->post->create(); |
| 567 | $post_id = self::factory()->post->create(); |
568 | 568 | add_post_meta( $post_id, 'foo', rand_str() ); |
569 | | $post_id2 = self::$factory->post->create(); |
| 569 | $post_id2 = self::factory()->post->create(); |
570 | 570 | add_post_meta( $post_id2, 'bar', rand_str() ); |
571 | | $post_id3 = self::$factory->post->create(); |
| 571 | $post_id3 = self::factory()->post->create(); |
572 | 572 | add_post_meta( $post_id3, 'bar', rand_str() ); |
573 | | $post_id4 = self::$factory->post->create(); |
| 573 | $post_id4 = self::factory()->post->create(); |
574 | 574 | add_post_meta( $post_id4, 'baz', rand_str() ); |
575 | | $post_id5 = self::$factory->post->create(); |
| 575 | $post_id5 = self::factory()->post->create(); |
576 | 576 | add_post_meta( $post_id5, 'foo', rand_str() ); |
577 | 577 | |
578 | 578 | $query = new WP_Query( array( |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
636 | 636 | * @ticket 29062 |
637 | 637 | */ |
638 | 638 | public function test_meta_query_compare_not_exists_with_another_condition_relation_or() { |
639 | | $posts = self::$factory->post->create_many( 4 ); |
| 639 | $posts = self::factory()->post->create_many( 4 ); |
640 | 640 | update_post_meta( $posts[0], 'color', 'orange' ); |
641 | 641 | update_post_meta( $posts[1], 'color', 'blue' ); |
642 | 642 | update_post_meta( $posts[1], 'vegetable', 'onion' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
672 | 672 | * @ticket 24093 |
673 | 673 | */ |
674 | 674 | public function test_meta_query_relation_or_compare_equals() { |
675 | | $posts = self::$factory->post->create_many( 4 ); |
| 675 | $posts = self::factory()->post->create_many( 4 ); |
676 | 676 | add_post_meta( $posts[0], 'color', 'orange' ); |
677 | 677 | add_post_meta( $posts[1], 'color', 'blue' ); |
678 | 678 | add_post_meta( $posts[1], 'vegetable', 'onion' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
705 | 705 | * @ticket 24093 |
706 | 706 | */ |
707 | 707 | public function test_meta_query_relation_or_compare_equals_different_keys() { |
708 | | $posts = self::$factory->post->create_many( 4 ); |
| 708 | $posts = self::factory()->post->create_many( 4 ); |
709 | 709 | add_post_meta( $posts[0], 'color', 'orange' ); |
710 | 710 | add_post_meta( $posts[1], 'color', 'blue' ); |
711 | 711 | add_post_meta( $posts[1], 'vegetable', 'onion' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
738 | 738 | * @ticket 24093 |
739 | 739 | */ |
740 | 740 | public function test_meta_query_relation_or_compare_equals_and_in() { |
741 | | $posts = self::$factory->post->create_many( 4 ); |
| 741 | $posts = self::factory()->post->create_many( 4 ); |
742 | 742 | add_post_meta( $posts[0], 'color', 'orange' ); |
743 | 743 | add_post_meta( $posts[1], 'color', 'blue' ); |
744 | 744 | add_post_meta( $posts[1], 'vegetable', 'onion' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
771 | 771 | * @ticket 24093 |
772 | 772 | */ |
773 | 773 | public function test_meta_query_relation_or_compare_equals_and_like() { |
774 | | $posts = self::$factory->post->create_many( 4 ); |
| 774 | $posts = self::factory()->post->create_many( 4 ); |
775 | 775 | add_post_meta( $posts[0], 'color', 'orange' ); |
776 | 776 | add_post_meta( $posts[1], 'color', 'blue' ); |
777 | 777 | add_post_meta( $posts[1], 'vegetable', 'onion' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
804 | 804 | * @ticket 24093 |
805 | 805 | */ |
806 | 806 | public function test_meta_query_relation_or_compare_equals_and_between() { |
807 | | $posts = self::$factory->post->create_many( 4 ); |
| 807 | $posts = self::factory()->post->create_many( 4 ); |
808 | 808 | add_post_meta( $posts[0], 'number_of_colors', '2' ); |
809 | 809 | add_post_meta( $posts[1], 'number_of_colors', '5' ); |
810 | 810 | add_post_meta( $posts[1], 'vegetable', 'onion' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
838 | 838 | * @ticket 24093 |
839 | 839 | */ |
840 | 840 | public function test_meta_query_relation_and_compare_in_same_keys() { |
841 | | $posts = self::$factory->post->create_many( 4 ); |
| 841 | $posts = self::factory()->post->create_many( 4 ); |
842 | 842 | add_post_meta( $posts[0], 'color', 'orange' ); |
843 | 843 | add_post_meta( $posts[1], 'color', 'blue' ); |
844 | 844 | add_post_meta( $posts[1], 'vegetable', 'onion' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
873 | 873 | * @ticket 24093 |
874 | 874 | */ |
875 | 875 | public function test_meta_query_relation_and_compare_in_different_keys() { |
876 | | $posts = self::$factory->post->create_many( 4 ); |
| 876 | $posts = self::factory()->post->create_many( 4 ); |
877 | 877 | add_post_meta( $posts[0], 'color', 'orange' ); |
878 | 878 | add_post_meta( $posts[1], 'color', 'blue' ); |
879 | 879 | add_post_meta( $posts[1], 'vegetable', 'onion' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
908 | 908 | * @ticket 24093 |
909 | 909 | */ |
910 | 910 | public function test_meta_query_relation_and_compare_not_equals() { |
911 | | $posts = self::$factory->post->create_many( 4 ); |
| 911 | $posts = self::factory()->post->create_many( 4 ); |
912 | 912 | add_post_meta( $posts[0], 'color', 'orange' ); |
913 | 913 | add_post_meta( $posts[1], 'color', 'blue' ); |
914 | 914 | add_post_meta( $posts[1], 'vegetable', 'onion' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
942 | 942 | * @ticket 24093 |
943 | 943 | */ |
944 | 944 | public function test_meta_query_relation_and_compare_not_equals_different_keys() { |
945 | | $posts = self::$factory->post->create_many( 4 ); |
| 945 | $posts = self::factory()->post->create_many( 4 ); |
946 | 946 | |
947 | 947 | // !shallot, but orange. |
948 | 948 | add_post_meta( $posts[0], 'color', 'orange' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
983 | 983 | * @ticket 24093 |
984 | 984 | */ |
985 | 985 | public function test_meta_query_relation_and_compare_not_equals_not_in() { |
986 | | $posts = self::$factory->post->create_many( 4 ); |
| 986 | $posts = self::factory()->post->create_many( 4 ); |
987 | 987 | add_post_meta( $posts[0], 'color', 'orange' ); |
988 | 988 | add_post_meta( $posts[1], 'color', 'blue' ); |
989 | 989 | add_post_meta( $posts[1], 'vegetable', 'onion' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1017 | 1017 | * @ticket 24093 |
1018 | 1018 | */ |
1019 | 1019 | public function test_meta_query_relation_and_compare_not_equals_and_not_like() { |
1020 | | $posts = self::$factory->post->create_many( 4 ); |
| 1020 | $posts = self::factory()->post->create_many( 4 ); |
1021 | 1021 | add_post_meta( $posts[0], 'color', 'orange' ); |
1022 | 1022 | add_post_meta( $posts[1], 'color', 'blue' ); |
1023 | 1023 | add_post_meta( $posts[1], 'vegetable', 'onion' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1051 | 1051 | * @ticket 23033 |
1052 | 1052 | */ |
1053 | 1053 | public function test_meta_query_decimal_results() { |
1054 | | $post_1 = self::$factory->post->create(); |
1055 | | $post_2 = self::$factory->post->create(); |
1056 | | $post_3 = self::$factory->post->create(); |
1057 | | $post_4 = self::$factory->post->create(); |
| 1054 | $post_1 = self::factory()->post->create(); |
| 1055 | $post_2 = self::factory()->post->create(); |
| 1056 | $post_3 = self::factory()->post->create(); |
| 1057 | $post_4 = self::factory()->post->create(); |
1058 | 1058 | |
1059 | 1059 | update_post_meta( $post_1, 'decimal_value', '-0.3' ); |
1060 | 1060 | update_post_meta( $post_2, 'decimal_value', '0.23409844' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1226 | 1226 | * @ticket 29604 |
1227 | 1227 | */ |
1228 | 1228 | public function test_meta_query_with_orderby_meta_value_relation_or() { |
1229 | | $posts = self::$factory->post->create_many( 4 ); |
| 1229 | $posts = self::factory()->post->create_many( 4 ); |
1230 | 1230 | update_post_meta( $posts[0], 'foo', 5 ); |
1231 | 1231 | update_post_meta( $posts[1], 'foo', 6 ); |
1232 | 1232 | update_post_meta( $posts[2], 'foo', 4 ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1265 | 1265 | * @ticket 29604 |
1266 | 1266 | */ |
1267 | 1267 | public function test_meta_query_with_orderby_meta_value_relation_and() { |
1268 | | $posts = self::$factory->post->create_many( 4 ); |
| 1268 | $posts = self::factory()->post->create_many( 4 ); |
1269 | 1269 | update_post_meta( $posts[0], 'foo', 5 ); |
1270 | 1270 | update_post_meta( $posts[1], 'foo', 6 ); |
1271 | 1271 | update_post_meta( $posts[2], 'foo', 4 ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1308 | 1308 | * @ticket 29642 |
1309 | 1309 | */ |
1310 | 1310 | public function test_meta_query_nested() { |
1311 | | $p1 = self::$factory->post->create(); |
1312 | | $p2 = self::$factory->post->create(); |
1313 | | $p3 = self::$factory->post->create(); |
| 1311 | $p1 = self::factory()->post->create(); |
| 1312 | $p2 = self::factory()->post->create(); |
| 1313 | $p3 = self::factory()->post->create(); |
1314 | 1314 | |
1315 | 1315 | add_post_meta( $p1, 'foo', 'bar' ); |
1316 | 1316 | add_post_meta( $p2, 'foo2', 'bar' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1349 | 1349 | * @ticket 29642 |
1350 | 1350 | */ |
1351 | 1351 | public function test_meta_query_nested_two_levels_deep() { |
1352 | | $p1 = self::$factory->post->create(); |
1353 | | $p2 = self::$factory->post->create(); |
1354 | | $p3 = self::$factory->post->create(); |
| 1352 | $p1 = self::factory()->post->create(); |
| 1353 | $p2 = self::factory()->post->create(); |
| 1354 | $p3 = self::factory()->post->create(); |
1355 | 1355 | |
1356 | 1356 | add_post_meta( $p1, 'foo', 'bar' ); |
1357 | 1357 | add_post_meta( $p3, 'foo2', 'bar' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 | public function test_meta_between_not_between() { |
1397 | | $post_id = self::$factory->post->create(); |
| 1397 | $post_id = self::factory()->post->create(); |
1398 | 1398 | add_post_meta( $post_id, 'time', 500 ); |
1399 | | $post_id2 = self::$factory->post->create(); |
| 1399 | $post_id2 = self::factory()->post->create(); |
1400 | 1400 | add_post_meta( $post_id2, 'time', 1001 ); |
1401 | | $post_id3 = self::$factory->post->create(); |
| 1401 | $post_id3 = self::factory()->post->create(); |
1402 | 1402 | add_post_meta( $post_id3, 'time', 0 ); |
1403 | | $post_id4 = self::$factory->post->create(); |
| 1403 | $post_id4 = self::factory()->post->create(); |
1404 | 1404 | add_post_meta( $post_id4, 'time', 1 ); |
1405 | | $post_id5 = self::$factory->post->create(); |
| 1405 | $post_id5 = self::factory()->post->create(); |
1406 | 1406 | add_post_meta( $post_id5, 'time', 1000 ); |
1407 | 1407 | |
1408 | 1408 | $args = array( |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1443 | 1443 | */ |
1444 | 1444 | public function test_meta_default_compare() { |
1445 | 1445 | // compare should default to IN when meta_value is an array |
1446 | | $post_id = self::$factory->post->create(); |
| 1446 | $post_id = self::factory()->post->create(); |
1447 | 1447 | add_post_meta( $post_id, 'foo', 'bar' ); |
1448 | | $post_id2 = self::$factory->post->create(); |
| 1448 | $post_id2 = self::factory()->post->create(); |
1449 | 1449 | add_post_meta( $post_id2, 'bar', 'baz' ); |
1450 | | $post_id3 = self::$factory->post->create(); |
| 1450 | $post_id3 = self::factory()->post->create(); |
1451 | 1451 | add_post_meta( $post_id3, 'foo', 'baz' ); |
1452 | | $post_id4 = self::$factory->post->create(); |
| 1452 | $post_id4 = self::factory()->post->create(); |
1453 | 1453 | add_post_meta( $post_id4, 'baz', 'bar' ); |
1454 | | $post_id5 = self::$factory->post->create(); |
| 1454 | $post_id5 = self::factory()->post->create(); |
1455 | 1455 | add_post_meta( $post_id5, 'foo', rand_str() ); |
1456 | 1456 | |
1457 | 1457 | $posts = get_posts( array( |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1482 | 1482 | * @ticket 17264 |
1483 | 1483 | */ |
1484 | 1484 | public function test_duplicate_posts_when_no_key() { |
1485 | | $post_id = self::$factory->post->create(); |
| 1485 | $post_id = self::factory()->post->create(); |
1486 | 1486 | add_post_meta( $post_id, 'city', 'Lorem' ); |
1487 | 1487 | add_post_meta( $post_id, 'address', '123 Lorem St.' ); |
1488 | | $post_id2 = self::$factory->post->create(); |
| 1488 | $post_id2 = self::factory()->post->create(); |
1489 | 1489 | add_post_meta( $post_id2, 'city', 'Lorem' ); |
1490 | | $post_id3 = self::$factory->post->create(); |
| 1490 | $post_id3 = self::factory()->post->create(); |
1491 | 1491 | add_post_meta( $post_id3, 'city', 'Loren' ); |
1492 | 1492 | |
1493 | 1493 | $args = array( |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1513 | 1513 | * @ticket 15292 |
1514 | 1514 | */ |
1515 | 1515 | public function test_empty_meta_value() { |
1516 | | $post_id = self::$factory->post->create(); |
| 1516 | $post_id = self::factory()->post->create(); |
1517 | 1517 | add_post_meta( $post_id, 'foo', '0' ); |
1518 | 1518 | add_post_meta( $post_id, 'bar', 0 ); |
1519 | | $post_id2 = self::$factory->post->create(); |
| 1519 | $post_id2 = self::factory()->post->create(); |
1520 | 1520 | add_post_meta( $post_id2, 'foo', 1 ); |
1521 | | $post_id3 = self::$factory->post->create(); |
| 1521 | $post_id3 = self::factory()->post->create(); |
1522 | 1522 | add_post_meta( $post_id3, 'baz', 0 ); |
1523 | | $post_id4 = self::$factory->post->create(); |
| 1523 | $post_id4 = self::factory()->post->create(); |
1524 | 1524 | add_post_meta( $post_id4, 'baz', 0 ); |
1525 | | $post_id5 = self::$factory->post->create(); |
| 1525 | $post_id5 = self::factory()->post->create(); |
1526 | 1526 | add_post_meta( $post_id5, 'baz', 0 ); |
1527 | 1527 | add_post_meta( $post_id5, 'bar', '0' ); |
1528 | | $post_id6 = self::$factory->post->create(); |
| 1528 | $post_id6 = self::factory()->post->create(); |
1529 | 1529 | add_post_meta( $post_id6, 'baz', 0 ); |
1530 | 1530 | |
1531 | 1531 | $q = new WP_Query( array( 'meta_key' => 'foo', 'meta_value' => '0' ) ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1577 | 1577 | * @ticket 31045 |
1578 | 1578 | */ |
1579 | 1579 | public function test_orderby_clause_key() { |
1580 | | $posts = self::$factory->post->create_many( 3 ); |
| 1580 | $posts = self::factory()->post->create_many( 3 ); |
1581 | 1581 | add_post_meta( $posts[0], 'foo', 'aaa' ); |
1582 | 1582 | add_post_meta( $posts[1], 'foo', 'zzz' ); |
1583 | 1583 | add_post_meta( $posts[2], 'foo', 'jjj' ); |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1601 | 1601 | * @ticket 31045 |
1602 | 1602 | */ |
1603 | 1603 | public function test_orderby_clause_key_as_secondary_sort() { |
1604 | | $p1 = self::$factory->post->create( array( |
| 1604 | $p1 = self::factory()->post->create( array( |
1605 | 1605 | 'post_date' => '2015-01-28 03:00:00', |
1606 | 1606 | ) ); |
1607 | | $p2 = self::$factory->post->create( array( |
| 1607 | $p2 = self::factory()->post->create( array( |
1608 | 1608 | 'post_date' => '2015-01-28 05:00:00', |
1609 | 1609 | ) ); |
1610 | | $p3 = self::$factory->post->create( array( |
| 1610 | $p3 = self::factory()->post->create( array( |
1611 | 1611 | 'post_date' => '2015-01-28 03:00:00', |
1612 | 1612 | ) ); |
1613 | 1613 | |
… |
… |
class Tests_Query_MetaQuery extends WP_UnitTestCase { |
1636 | 1636 | * @ticket 31045 |
1637 | 1637 | */ |
1638 | 1638 | public function test_orderby_more_than_one_clause_key() { |
1639 | | $posts = self::$factory->post->create_many( 3 ); |
| 1639 | $posts = self::factory()->post->create_many( 3 ); |
1640 | 1640 | |
1641 | 1641 | add_post_meta( $posts[0], 'foo', 'jjj' ); |
1642 | 1642 | add_post_meta( $posts[1], 'foo', 'zzz' ); |
-
diff --git tests/phpunit/tests/query/postStatus.php tests/phpunit/tests/query/postStatus.php
index 764cc76..6532d52 100644
|
|
class Tests_Query_PostStatus extends WP_UnitTestCase { |
211 | 211 | public function test_single_post_with_nonpublic_status_should_not_be_shown_to_logged_out_users() { |
212 | 212 | register_post_type( 'foo_pt' ); |
213 | 213 | register_post_status( 'foo_ps', array( 'public' => false ) ); |
214 | | $p = self::$factory->post->create( array( 'post_status' => 'foo_ps' ) ); |
| 214 | $p = self::factory()->post->create( array( 'post_status' => 'foo_ps' ) ); |
215 | 215 | |
216 | 216 | $q = new WP_Query( array( |
217 | 217 | 'p' => $p, |
… |
… |
class Tests_Query_PostStatus extends WP_UnitTestCase { |
223 | 223 | public function test_single_post_with_nonpublic_and_protected_status_should_not_be_shown_for_user_who_cannot_edit_others_posts() { |
224 | 224 | register_post_type( 'foo_pt' ); |
225 | 225 | register_post_status( 'foo_ps', array( 'public' => false, 'protected' => true ) ); |
226 | | $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) ); |
| 226 | $p = self::factory()->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) ); |
227 | 227 | |
228 | 228 | wp_set_current_user( self::$author_user_id ); |
229 | 229 | |
… |
… |
class Tests_Query_PostStatus extends WP_UnitTestCase { |
237 | 237 | public function test_single_post_with_nonpublic_and_protected_status_should_be_shown_for_user_who_can_edit_others_posts() { |
238 | 238 | register_post_type( 'foo_pt' ); |
239 | 239 | register_post_status( 'foo_ps', array( 'public' => false, 'protected' => true ) ); |
240 | | $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); |
| 240 | $p = self::factory()->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); |
241 | 241 | |
242 | 242 | wp_set_current_user( self::$editor_user_id ); |
243 | 243 | |
… |
… |
class Tests_Query_PostStatus extends WP_UnitTestCase { |
251 | 251 | public function test_single_post_with_nonpublic_and_private_status_should_not_be_shown_for_user_who_cannot_edit_others_posts() { |
252 | 252 | register_post_type( 'foo_pt' ); |
253 | 253 | register_post_status( 'foo_ps', array( 'public' => false, 'private' => true ) ); |
254 | | $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) ); |
| 254 | $p = self::factory()->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) ); |
255 | 255 | |
256 | 256 | wp_set_current_user( self::$author_user_id ); |
257 | 257 | |
… |
… |
class Tests_Query_PostStatus extends WP_UnitTestCase { |
265 | 265 | public function test_single_post_with_nonpublic_and_private_status_should_be_shown_for_user_who_can_edit_others_posts() { |
266 | 266 | register_post_type( 'foo_pt' ); |
267 | 267 | register_post_status( 'foo_ps', array( 'public' => false, 'private' => true ) ); |
268 | | $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); |
| 268 | $p = self::factory()->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); |
269 | 269 | |
270 | 270 | wp_set_current_user( self::$editor_user_id ); |
271 | 271 | |
… |
… |
class Tests_Query_PostStatus extends WP_UnitTestCase { |
279 | 279 | public function test_single_post_with_nonpublic_and_protected_status_should_not_be_shown_for_any_user() { |
280 | 280 | register_post_type( 'foo_pt' ); |
281 | 281 | register_post_status( 'foo_ps', array( 'public' => false ) ); |
282 | | $p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); |
| 282 | $p = self::factory()->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) ); |
283 | 283 | |
284 | 284 | wp_set_current_user( self::$editor_user_id ); |
285 | 285 | |
… |
… |
class Tests_Query_PostStatus extends WP_UnitTestCase { |
294 | 294 | * @ticket 29167 |
295 | 295 | */ |
296 | 296 | public function test_specific_post_should_be_returned_if_trash_is_one_of_the_requested_post_statuses() { |
297 | | $p1 = self::$factory->post->create( array( 'post_status' => 'trash' ) ); |
298 | | $p2 = self::$factory->post->create( array( 'post_status' => 'publish' ) ); |
| 297 | $p1 = self::factory()->post->create( array( 'post_status' => 'trash' ) ); |
| 298 | $p2 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); |
299 | 299 | |
300 | 300 | $q = new WP_Query( array( |
301 | 301 | 'p' => $p1, |
-
diff --git tests/phpunit/tests/query/results.php tests/phpunit/tests/query/results.php
index 9cd81fc..30a3290 100644
|
|
class Tests_Query_Results extends WP_UnitTestCase { |
456 | 456 | * @ticket 16854 |
457 | 457 | */ |
458 | 458 | function test_query_author_vars() { |
459 | | $author_1 = self::$factory->user->create( array( 'user_login' => 'admin1', 'user_pass' => rand_str(), 'role' => 'author' ) ); |
460 | | $post_1 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) ); |
| 459 | $author_1 = self::factory()->user->create( array( 'user_login' => 'admin1', 'user_pass' => rand_str(), 'role' => 'author' ) ); |
| 460 | $post_1 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) ); |
461 | 461 | |
462 | | $author_2 = self::$factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); |
463 | | $post_2 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) ); |
| 462 | $author_2 = self::factory()->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); |
| 463 | $post_2 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) ); |
464 | 464 | |
465 | | $author_3 = self::$factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); |
466 | | $post_3 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) ); |
| 465 | $author_3 = self::factory()->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); |
| 466 | $post_3 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) ); |
467 | 467 | |
468 | | $author_4 = self::$factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); |
469 | | $post_4 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) ); |
| 468 | $author_4 = self::factory()->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); |
| 469 | $post_4 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) ); |
470 | 470 | |
471 | 471 | $posts = $this->q->query( array( |
472 | 472 | 'author' => '', |
… |
… |
class Tests_Query_Results extends WP_UnitTestCase { |
623 | 623 | * @ticket 20308 |
624 | 624 | */ |
625 | 625 | function test_post_password() { |
626 | | $one = (string) self::$factory->post->create( array( 'post_password' => '' ) ); |
627 | | $two = (string) self::$factory->post->create( array( 'post_password' => 'burrito' ) ); |
628 | | $three = (string) self::$factory->post->create( array( 'post_password' => 'burrito' ) ); |
| 626 | $one = (string) self::factory()->post->create( array( 'post_password' => '' ) ); |
| 627 | $two = (string) self::factory()->post->create( array( 'post_password' => 'burrito' ) ); |
| 628 | $three = (string) self::factory()->post->create( array( 'post_password' => 'burrito' ) ); |
629 | 629 | |
630 | 630 | $args = array( 'post__in' => array( $one, $two, $three ), 'fields' => 'ids' ); |
631 | 631 | |
… |
… |
class Tests_Query_Results extends WP_UnitTestCase { |
665 | 665 | function test_duplicate_slug_in_hierarchical_post_type() { |
666 | 666 | register_post_type( 'handbook', array( 'hierarchical' => true ) ); |
667 | 667 | |
668 | | $post_1 = self::$factory->post->create( array( 'post_title' => 'Getting Started', 'post_type' => 'handbook' ) ); |
669 | | $post_2 = self::$factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) ); |
670 | | $post_3 = self::$factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_2, 'post_type' => 'handbook' ) ); |
| 668 | $post_1 = self::factory()->post->create( array( 'post_title' => 'Getting Started', 'post_type' => 'handbook' ) ); |
| 669 | $post_2 = self::factory()->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) ); |
| 670 | $post_3 = self::factory()->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_2, 'post_type' => 'handbook' ) ); |
671 | 671 | |
672 | 672 | $result = $this->q->query( array( 'handbook' => 'getting-started', 'post_type' => 'handbook' ) ); |
673 | 673 | $this->assertCount( 1, $result ); |
… |
… |
class Tests_Query_Results extends WP_UnitTestCase { |
679 | 679 | function test_child_post_in_hierarchical_post_type_with_default_permalinks() { |
680 | 680 | register_post_type( 'handbook', array( 'hierarchical' => true ) ); |
681 | 681 | |
682 | | $post_1 = self::$factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) ); |
683 | | $post_2 = self::$factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_1, 'post_type' => 'handbook' ) ); |
| 682 | $post_1 = self::factory()->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) ); |
| 683 | $post_2 = self::factory()->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_1, 'post_type' => 'handbook' ) ); |
684 | 684 | |
685 | 685 | $this->assertContains( 'contributing-to-the-wordpress-codex/getting-started', get_permalink( $post_2 ) ); |
686 | 686 | |
… |
… |
class Tests_Query_Results extends WP_UnitTestCase { |
690 | 690 | |
691 | 691 | function test_title() { |
692 | 692 | $title = 'Tacos are Cool'; |
693 | | $post_id = self::$factory->post->create( array( |
| 693 | $post_id = self::factory()->post->create( array( |
694 | 694 | 'post_title' => $title, |
695 | 695 | 'post_type' => 'post', |
696 | 696 | 'post_status' => 'publish' |
-
diff --git tests/phpunit/tests/query/search.php tests/phpunit/tests/query/search.php
index 37bd21a..caf862c 100644
|
|
class Tests_Query_Search extends WP_UnitTestCase { |
31 | 31 | |
32 | 32 | function test_search_order_title_relevance() { |
33 | 33 | foreach ( range( 1, 7 ) as $i ) |
34 | | self::$factory->post->create( array( 'post_content' => $i . rand_str() . ' about', 'post_type' => $this->post_type ) ); |
35 | | $post_id = self::$factory->post->create( array( 'post_title' => 'About', 'post_type' => $this->post_type ) ); |
| 34 | self::factory()->post->create( array( 'post_content' => $i . rand_str() . ' about', 'post_type' => $this->post_type ) ); |
| 35 | $post_id = self::factory()->post->create( array( 'post_title' => 'About', 'post_type' => $this->post_type ) ); |
36 | 36 | |
37 | 37 | $posts = $this->get_search_results( 'About' ); |
38 | 38 | $this->assertEquals( $post_id, reset( $posts )->ID ); |
… |
… |
class Tests_Query_Search extends WP_UnitTestCase { |
63 | 63 | * @ticket 33988 |
64 | 64 | */ |
65 | 65 | public function test_s_should_exclude_term_prefixed_with_dash() { |
66 | | $p1 = self::$factory->post->create( array( |
| 66 | $p1 = self::factory()->post->create( array( |
67 | 67 | 'post_status' => 'publish', |
68 | 68 | 'post_content' => 'This post has foo but also bar', |
69 | 69 | ) ); |
70 | | $p2 = self::$factory->post->create( array( |
| 70 | $p2 = self::factory()->post->create( array( |
71 | 71 | 'post_status' => 'publish', |
72 | 72 | 'post_content' => 'This post has only foo', |
73 | 73 | ) ); |
… |
… |
class Tests_Query_Search extends WP_UnitTestCase { |
84 | 84 | * @ticket 33988 |
85 | 85 | */ |
86 | 86 | public function test_s_should_exclude_first_term_if_prefixed_with_dash() { |
87 | | $p1 = self::$factory->post->create( array( |
| 87 | $p1 = self::factory()->post->create( array( |
88 | 88 | 'post_status' => 'publish', |
89 | 89 | 'post_content' => 'This post has foo but also bar', |
90 | 90 | ) ); |
91 | | $p2 = self::$factory->post->create( array( |
| 91 | $p2 = self::factory()->post->create( array( |
92 | 92 | 'post_status' => 'publish', |
93 | 93 | 'post_content' => 'This post has only bar', |
94 | 94 | ) ); |
… |
… |
class Tests_Query_Search extends WP_UnitTestCase { |
105 | 105 | * @ticket 33988 |
106 | 106 | */ |
107 | 107 | public function test_s_should_not_exclude_for_dashes_in_the_middle_of_words() { |
108 | | $p1 = self::$factory->post->create( array( |
| 108 | $p1 = self::factory()->post->create( array( |
109 | 109 | 'post_status' => 'publish', |
110 | 110 | 'post_content' => 'This post has foo but also bar', |
111 | 111 | ) ); |
112 | | $p2 = self::$factory->post->create( array( |
| 112 | $p2 = self::factory()->post->create( array( |
113 | 113 | 'post_status' => 'publish', |
114 | 114 | 'post_content' => 'This post has only bar', |
115 | 115 | ) ); |
116 | | $p3 = self::$factory->post->create( array( |
| 116 | $p3 = self::factory()->post->create( array( |
117 | 117 | 'post_status' => 'publish', |
118 | 118 | 'post_content' => 'This post has only foo-bar', |
119 | 119 | ) ); |
-
diff --git tests/phpunit/tests/query/setupPostdata.php tests/phpunit/tests/query/setupPostdata.php
index 5381a97..73ec7bd 100644
|
|
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
39 | 39 | } |
40 | 40 | |
41 | 41 | public function test_id() { |
42 | | $p = self::$factory->post->create_and_get(); |
| 42 | $p = self::factory()->post->create_and_get(); |
43 | 43 | setup_postdata( $p ); |
44 | 44 | |
45 | 45 | $this->assertNotEmpty( $p->ID ); |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
50 | 50 | * @ticket 30970 |
51 | 51 | */ |
52 | 52 | public function test_setup_by_id() { |
53 | | $p = self::$factory->post->create_and_get(); |
| 53 | $p = self::factory()->post->create_and_get(); |
54 | 54 | setup_postdata( $p->ID ); |
55 | 55 | |
56 | 56 | $this->assertSame( $p->ID, $GLOBALS['id'] ); |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
72 | 72 | * @ticket 30970 |
73 | 73 | */ |
74 | 74 | public function test_setup_by_postish_object() { |
75 | | $p = self::$factory->post->create(); |
| 75 | $p = self::factory()->post->create(); |
76 | 76 | |
77 | 77 | $post = new stdClass(); |
78 | 78 | $post->ID = $p; |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
82 | 82 | } |
83 | 83 | |
84 | 84 | public function test_authordata() { |
85 | | $u = self::$factory->user->create_and_get(); |
86 | | $p = self::$factory->post->create_and_get( array( |
| 85 | $u = self::factory()->user->create_and_get(); |
| 86 | $p = self::factory()->post->create_and_get( array( |
87 | 87 | 'post_author' => $u->ID, |
88 | 88 | ) ); |
89 | 89 | setup_postdata( $p ); |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
93 | 93 | } |
94 | 94 | |
95 | 95 | public function test_currentday() { |
96 | | $p = self::$factory->post->create_and_get( array( |
| 96 | $p = self::factory()->post->create_and_get( array( |
97 | 97 | 'post_date' => '1980-09-09 06:30:00', |
98 | 98 | ) ); |
99 | 99 | setup_postdata( $p ); |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
102 | 102 | } |
103 | 103 | |
104 | 104 | public function test_currentmonth() { |
105 | | $p = self::$factory->post->create_and_get( array( |
| 105 | $p = self::factory()->post->create_and_get( array( |
106 | 106 | 'post_date' => '1980-09-09 06:30:00', |
107 | 107 | ) ); |
108 | 108 | setup_postdata( $p ); |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
111 | 111 | } |
112 | 112 | |
113 | 113 | public function test_secondary_query_post_vars() { |
114 | | $users = self::$factory->user->create_many( 2 ); |
| 114 | $users = self::factory()->user->create_many( 2 ); |
115 | 115 | |
116 | | $post1 = self::$factory->post->create_and_get( array( |
| 116 | $post1 = self::factory()->post->create_and_get( array( |
117 | 117 | 'post_author' => $users[0], |
118 | 118 | 'post_date' => '2012-02-02 02:00:00', |
119 | 119 | ) ); |
120 | 120 | |
121 | | $post2 = self::$factory->post->create_and_get( array( |
| 121 | $post2 = self::factory()->post->create_and_get( array( |
122 | 122 | 'post_author' => $users[1], |
123 | 123 | 'post_date' => '2013-03-03 03:00:00', |
124 | 124 | ) ); |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
157 | 157 | } |
158 | 158 | |
159 | 159 | public function test_single_page() { |
160 | | $post = self::$factory->post->create_and_get( array( |
| 160 | $post = self::factory()->post->create_and_get( array( |
161 | 161 | 'post_content' => 'Page 0', |
162 | 162 | ) ); |
163 | 163 | setup_postdata( $post ); |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
168 | 168 | } |
169 | 169 | |
170 | 170 | public function test_multi_page() { |
171 | | $post = self::$factory->post->create_and_get( array( |
| 171 | $post = self::factory()->post->create_and_get( array( |
172 | 172 | 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3', |
173 | 173 | ) ); |
174 | 174 | setup_postdata( $post ); |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
182 | 182 | * @ticket 16746 |
183 | 183 | */ |
184 | 184 | public function test_nextpage_at_start_of_content() { |
185 | | $post = self::$factory->post->create_and_get( array( |
| 185 | $post = self::factory()->post->create_and_get( array( |
186 | 186 | 'post_content' => '<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3', |
187 | 187 | ) ); |
188 | 188 | setup_postdata( $post ); |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
193 | 193 | } |
194 | 194 | |
195 | 195 | public function test_trim_nextpage_linebreaks() { |
196 | | $post = self::$factory->post->create_and_get( array( |
| 196 | $post = self::factory()->post->create_and_get( array( |
197 | 197 | 'post_content' => "Page 0\n<!--nextpage-->\nPage 1\nhas a line break\n<!--nextpage-->Page 2<!--nextpage-->\n\nPage 3", |
198 | 198 | ) ); |
199 | 199 | setup_postdata( $post ); |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
205 | 205 | * @ticket 25349 |
206 | 206 | */ |
207 | 207 | public function test_secondary_query_nextpage() { |
208 | | $post1 = self::$factory->post->create( array( |
| 208 | $post1 = self::factory()->post->create( array( |
209 | 209 | 'post_content' => 'Post 1 Page 1<!--nextpage-->Post 1 Page 2', |
210 | 210 | ) ); |
211 | | $post2 = self::$factory->post->create( array( |
| 211 | $post2 = self::factory()->post->create( array( |
212 | 212 | 'post_content' => 'Post 2 Page 1<!--nextpage-->Post 2 Page 2', |
213 | 213 | ) ); |
214 | 214 | |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
237 | 237 | } |
238 | 238 | |
239 | 239 | public function test_page_from_wp_query() { |
240 | | $page = self::$factory->post->create_and_get( array( |
| 240 | $page = self::factory()->post->create_and_get( array( |
241 | 241 | 'post_type' => 'page', |
242 | 242 | ) ); |
243 | 243 | |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
250 | 250 | } |
251 | 251 | |
252 | 252 | public function test_page_when_on_page() { |
253 | | $page = self::$factory->post->create_and_get( array( |
| 253 | $page = self::factory()->post->create_and_get( array( |
254 | 254 | 'post_type' => 'page', |
255 | 255 | ) ); |
256 | 256 | $this->go_to( get_permalink( $page ) ); |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
263 | 263 | * @ticket 20904 |
264 | 264 | */ |
265 | 265 | public function test_secondary_query_page() { |
266 | | $post = self::$factory->post->create_and_get(); |
| 266 | $post = self::factory()->post->create_and_get(); |
267 | 267 | $this->go_to( '/?page=3' ); |
268 | 268 | setup_postdata( $post ); |
269 | 269 | |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
271 | 271 | $this->assertSame( 3, $GLOBALS['page'] ); |
272 | 272 | |
273 | 273 | // Secondary loop. |
274 | | $posts = self::$factory->post->create_many( 5 ); |
| 274 | $posts = self::factory()->post->create_many( 5 ); |
275 | 275 | $q = new WP_Query( array( |
276 | 276 | 'page' => 4, |
277 | 277 | 'posts_per_page' => 1, |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
294 | 294 | * @ticket 20904 |
295 | 295 | */ |
296 | 296 | public function test_more_when_on_setup_post() { |
297 | | $post = self::$factory->post->create_and_get(); |
| 297 | $post = self::factory()->post->create_and_get(); |
298 | 298 | $this->go_to( get_permalink( $post ) ); |
299 | 299 | setup_postdata( $post ); |
300 | 300 | |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
307 | 307 | * $more should not be true when the set-up post is not the same as the current post. |
308 | 308 | */ |
309 | 309 | public function test_more_when_on_single() { |
310 | | $post1 = self::$factory->post->create_and_get(); |
311 | | $post2 = self::$factory->post->create_and_get(); |
| 310 | $post1 = self::factory()->post->create_and_get(); |
| 311 | $post2 = self::factory()->post->create_and_get(); |
312 | 312 | $this->go_to( get_permalink( $post1 ) ); |
313 | 313 | setup_postdata( $post2 ); |
314 | 314 | |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
321 | 321 | * $more should not be true when the set-up post is not the same as the current page. |
322 | 322 | */ |
323 | 323 | public function test_more_when_on_page() { |
324 | | $post = self::$factory->post->create_and_get(); |
325 | | $page = self::$factory->post->create_and_get( array( |
| 324 | $post = self::factory()->post->create_and_get(); |
| 325 | $page = self::factory()->post->create_and_get( array( |
326 | 326 | 'post_type' => 'page', |
327 | 327 | ) ); |
328 | 328 | $this->go_to( get_permalink( $page ) ); |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
335 | 335 | * @ticket 20904 |
336 | 336 | */ |
337 | 337 | public function test_more_when_on_feed() { |
338 | | $post = self::$factory->post->create_and_get(); |
| 338 | $post = self::factory()->post->create_and_get(); |
339 | 339 | $this->go_to( '/?feed=rss' ); |
340 | 340 | setup_postdata( $post ); |
341 | 341 | |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
347 | 347 | * @ticket 25349 |
348 | 348 | */ |
349 | 349 | public function test_secondary_query_more() { |
350 | | $post = self::$factory->post->create_and_get(); |
| 350 | $post = self::factory()->post->create_and_get(); |
351 | 351 | $this->go_to( get_permalink( $post ) ); |
352 | 352 | setup_postdata( $post ); |
353 | 353 | |
… |
… |
class Tests_Query_SetupPostdata extends WP_UnitTestCase { |
379 | 379 | * global $post should use the content of $a_post rather then the global post. |
380 | 380 | */ |
381 | 381 | function test_setup_postdata_loop() { |
382 | | $post_id = self::$factory->post->create( array( 'post_content' => 'global post' ) ); |
| 382 | $post_id = self::factory()->post->create( array( 'post_content' => 'global post' ) ); |
383 | 383 | $GLOBALS['wp_query']->post = $GLOBALS['post'] = get_post( $post_id ); |
384 | 384 | |
385 | | $ids = self::$factory->post->create_many(5); |
| 385 | $ids = self::factory()->post->create_many(5); |
386 | 386 | foreach ( $ids as $id ) { |
387 | 387 | $page = get_post( $id ); |
388 | 388 | if ( $page ) { |
-
diff --git tests/phpunit/tests/query/taxQuery.php tests/phpunit/tests/query/taxQuery.php
index cd495b8..8248b19 100644
|
|
|
6 | 6 | */ |
7 | 7 | class Tests_Query_TaxQuery extends WP_UnitTestCase { |
8 | 8 | public function test_tax_query_single_query_single_term_field_slug() { |
9 | | $t = self::$factory->term->create( array( |
| 9 | $t = self::factory()->term->create( array( |
10 | 10 | 'taxonomy' => 'category', |
11 | 11 | 'slug' => 'foo', |
12 | 12 | 'name' => 'Foo', |
13 | 13 | ) ); |
14 | | $p1 = self::$factory->post->create(); |
15 | | $p2 = self::$factory->post->create(); |
| 14 | $p1 = self::factory()->post->create(); |
| 15 | $p2 = self::factory()->post->create(); |
16 | 16 | |
17 | 17 | wp_set_post_terms( $p1, $t, 'category' ); |
18 | 18 | |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function test_tax_query_single_query_single_term_field_name() { |
36 | | $t = self::$factory->term->create( array( |
| 36 | $t = self::factory()->term->create( array( |
37 | 37 | 'taxonomy' => 'category', |
38 | 38 | 'slug' => 'foo', |
39 | 39 | 'name' => 'Foo', |
40 | 40 | ) ); |
41 | | $p1 = self::$factory->post->create(); |
42 | | $p2 = self::$factory->post->create(); |
| 41 | $p1 = self::factory()->post->create(); |
| 42 | $p2 = self::factory()->post->create(); |
43 | 43 | |
44 | 44 | wp_set_post_terms( $p1, $t, 'category' ); |
45 | 45 | |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
65 | 65 | public function test_field_name_should_work_for_names_with_spaces() { |
66 | 66 | register_taxonomy( 'wptests_tax', 'post' ); |
67 | 67 | |
68 | | $t = self::$factory->term->create( array( |
| 68 | $t = self::factory()->term->create( array( |
69 | 69 | 'taxonomy' => 'wptests_tax', |
70 | 70 | 'slug' => 'foo', |
71 | 71 | 'name' => 'Foo Bar', |
72 | 72 | ) ); |
73 | | $p1 = self::$factory->post->create(); |
74 | | $p2 = self::$factory->post->create(); |
| 73 | $p1 = self::factory()->post->create(); |
| 74 | $p2 = self::factory()->post->create(); |
75 | 75 | |
76 | 76 | wp_set_object_terms( $p1, $t, 'wptests_tax' ); |
77 | 77 | |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
90 | 90 | } |
91 | 91 | |
92 | 92 | public function test_tax_query_single_query_single_term_field_term_taxonomy_id() { |
93 | | $t = self::$factory->term->create( array( |
| 93 | $t = self::factory()->term->create( array( |
94 | 94 | 'taxonomy' => 'category', |
95 | 95 | 'slug' => 'foo', |
96 | 96 | 'name' => 'Foo', |
97 | 97 | ) ); |
98 | | $p1 = self::$factory->post->create(); |
99 | | $p2 = self::$factory->post->create(); |
| 98 | $p1 = self::factory()->post->create(); |
| 99 | $p2 = self::factory()->post->create(); |
100 | 100 | |
101 | 101 | $tt_ids = wp_set_post_terms( $p1, $t, 'category' ); |
102 | 102 | |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
117 | 117 | } |
118 | 118 | |
119 | 119 | public function test_tax_query_single_query_single_term_field_term_id() { |
120 | | $t = self::$factory->term->create( array( |
| 120 | $t = self::factory()->term->create( array( |
121 | 121 | 'taxonomy' => 'category', |
122 | 122 | 'slug' => 'foo', |
123 | 123 | 'name' => 'Foo', |
124 | 124 | ) ); |
125 | | $p1 = self::$factory->post->create(); |
126 | | $p2 = self::$factory->post->create(); |
| 125 | $p1 = self::factory()->post->create(); |
| 126 | $p2 = self::factory()->post->create(); |
127 | 127 | |
128 | 128 | wp_set_post_terms( $p1, $t, 'category' ); |
129 | 129 | |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
144 | 144 | } |
145 | 145 | |
146 | 146 | public function test_tax_query_single_query_single_term_operator_in() { |
147 | | $t = self::$factory->term->create( array( |
| 147 | $t = self::factory()->term->create( array( |
148 | 148 | 'taxonomy' => 'category', |
149 | 149 | 'slug' => 'foo', |
150 | 150 | 'name' => 'Foo', |
151 | 151 | ) ); |
152 | | $p1 = self::$factory->post->create(); |
153 | | $p2 = self::$factory->post->create(); |
| 152 | $p1 = self::factory()->post->create(); |
| 153 | $p2 = self::factory()->post->create(); |
154 | 154 | |
155 | 155 | wp_set_post_terms( $p1, $t, 'category' ); |
156 | 156 | |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
172 | 172 | } |
173 | 173 | |
174 | 174 | public function test_tax_query_single_query_single_term_operator_not_in() { |
175 | | $t = self::$factory->term->create( array( |
| 175 | $t = self::factory()->term->create( array( |
176 | 176 | 'taxonomy' => 'category', |
177 | 177 | 'slug' => 'foo', |
178 | 178 | 'name' => 'Foo', |
179 | 179 | ) ); |
180 | | $p1 = self::$factory->post->create(); |
181 | | $p2 = self::$factory->post->create(); |
| 180 | $p1 = self::factory()->post->create(); |
| 181 | $p2 = self::factory()->post->create(); |
182 | 182 | |
183 | 183 | wp_set_post_terms( $p1, $t, 'category' ); |
184 | 184 | |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
200 | 200 | } |
201 | 201 | |
202 | 202 | public function test_tax_query_single_query_single_term_operator_and() { |
203 | | $t = self::$factory->term->create( array( |
| 203 | $t = self::factory()->term->create( array( |
204 | 204 | 'taxonomy' => 'category', |
205 | 205 | 'slug' => 'foo', |
206 | 206 | 'name' => 'Foo', |
207 | 207 | ) ); |
208 | | $p1 = self::$factory->post->create(); |
209 | | $p2 = self::$factory->post->create(); |
| 208 | $p1 = self::factory()->post->create(); |
| 209 | $p2 = self::factory()->post->create(); |
210 | 210 | |
211 | 211 | wp_set_post_terms( $p1, $t, 'category' ); |
212 | 212 | |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
228 | 228 | } |
229 | 229 | |
230 | 230 | public function test_tax_query_single_query_multiple_terms_operator_in() { |
231 | | $t1 = self::$factory->term->create( array( |
| 231 | $t1 = self::factory()->term->create( array( |
232 | 232 | 'taxonomy' => 'category', |
233 | 233 | 'slug' => 'foo', |
234 | 234 | 'name' => 'Foo', |
235 | 235 | ) ); |
236 | | $t2 = self::$factory->term->create( array( |
| 236 | $t2 = self::factory()->term->create( array( |
237 | 237 | 'taxonomy' => 'category', |
238 | 238 | 'slug' => 'bar', |
239 | 239 | 'name' => 'Bar', |
240 | 240 | ) ); |
241 | | $p1 = self::$factory->post->create(); |
242 | | $p2 = self::$factory->post->create(); |
243 | | $p3 = self::$factory->post->create(); |
| 241 | $p1 = self::factory()->post->create(); |
| 242 | $p2 = self::factory()->post->create(); |
| 243 | $p3 = self::factory()->post->create(); |
244 | 244 | |
245 | 245 | wp_set_post_terms( $p1, $t1, 'category' ); |
246 | 246 | wp_set_post_terms( $p2, $t2, 'category' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
263 | 263 | } |
264 | 264 | |
265 | 265 | public function test_tax_query_single_query_multiple_terms_operator_not_in() { |
266 | | $t1 = self::$factory->term->create( array( |
| 266 | $t1 = self::factory()->term->create( array( |
267 | 267 | 'taxonomy' => 'category', |
268 | 268 | 'slug' => 'foo', |
269 | 269 | 'name' => 'Foo', |
270 | 270 | ) ); |
271 | | $t2 = self::$factory->term->create( array( |
| 271 | $t2 = self::factory()->term->create( array( |
272 | 272 | 'taxonomy' => 'category', |
273 | 273 | 'slug' => 'bar', |
274 | 274 | 'name' => 'Bar', |
275 | 275 | ) ); |
276 | | $p1 = self::$factory->post->create(); |
277 | | $p2 = self::$factory->post->create(); |
278 | | $p3 = self::$factory->post->create(); |
| 276 | $p1 = self::factory()->post->create(); |
| 277 | $p2 = self::factory()->post->create(); |
| 278 | $p3 = self::factory()->post->create(); |
279 | 279 | |
280 | 280 | wp_set_post_terms( $p1, $t1, 'category' ); |
281 | 281 | wp_set_post_terms( $p2, $t2, 'category' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
301 | 301 | * @ticket 18105 |
302 | 302 | */ |
303 | 303 | public function test_tax_query_single_query_multiple_queries_operator_not_in() { |
304 | | $t1 = self::$factory->term->create( array( |
| 304 | $t1 = self::factory()->term->create( array( |
305 | 305 | 'taxonomy' => 'category', |
306 | 306 | 'slug' => 'foo', |
307 | 307 | 'name' => 'Foo', |
308 | 308 | ) ); |
309 | | $t2 = self::$factory->term->create( array( |
| 309 | $t2 = self::factory()->term->create( array( |
310 | 310 | 'taxonomy' => 'category', |
311 | 311 | 'slug' => 'bar', |
312 | 312 | 'name' => 'Bar', |
313 | 313 | ) ); |
314 | | $p1 = self::$factory->post->create(); |
315 | | $p2 = self::$factory->post->create(); |
316 | | $p3 = self::$factory->post->create(); |
| 314 | $p1 = self::factory()->post->create(); |
| 315 | $p2 = self::factory()->post->create(); |
| 316 | $p3 = self::factory()->post->create(); |
317 | 317 | |
318 | 318 | wp_set_post_terms( $p1, $t1, 'category' ); |
319 | 319 | wp_set_post_terms( $p2, $t2, 'category' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
343 | 343 | } |
344 | 344 | |
345 | 345 | public function test_tax_query_single_query_multiple_terms_operator_and() { |
346 | | $t1 = self::$factory->term->create( array( |
| 346 | $t1 = self::factory()->term->create( array( |
347 | 347 | 'taxonomy' => 'category', |
348 | 348 | 'slug' => 'foo', |
349 | 349 | 'name' => 'Foo', |
350 | 350 | ) ); |
351 | | $t2 = self::$factory->term->create( array( |
| 351 | $t2 = self::factory()->term->create( array( |
352 | 352 | 'taxonomy' => 'category', |
353 | 353 | 'slug' => 'bar', |
354 | 354 | 'name' => 'Bar', |
355 | 355 | ) ); |
356 | | $p1 = self::$factory->post->create(); |
357 | | $p2 = self::$factory->post->create(); |
358 | | $p3 = self::$factory->post->create(); |
| 356 | $p1 = self::factory()->post->create(); |
| 357 | $p2 = self::factory()->post->create(); |
| 358 | $p3 = self::factory()->post->create(); |
359 | 359 | |
360 | 360 | wp_set_object_terms( $p1, $t1, 'category' ); |
361 | 361 | wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
384 | 384 | register_taxonomy( 'wptests_tax1', 'post' ); |
385 | 385 | register_taxonomy( 'wptests_tax2', 'post' ); |
386 | 386 | |
387 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
388 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| 387 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| 388 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
389 | 389 | |
390 | | $p1 = self::$factory->post->create(); |
391 | | $p2 = self::$factory->post->create(); |
392 | | $p3 = self::$factory->post->create(); |
| 390 | $p1 = self::factory()->post->create(); |
| 391 | $p2 = self::factory()->post->create(); |
| 392 | $p3 = self::factory()->post->create(); |
393 | 393 | |
394 | 394 | wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' ); |
395 | 395 | wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
416 | 416 | register_taxonomy( 'wptests_tax1', 'post' ); |
417 | 417 | register_taxonomy( 'wptests_tax2', 'post' ); |
418 | 418 | |
419 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
420 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| 419 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| 420 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
421 | 421 | |
422 | | $p1 = self::$factory->post->create(); |
423 | | $p2 = self::$factory->post->create(); |
424 | | $p3 = self::$factory->post->create(); |
| 422 | $p1 = self::factory()->post->create(); |
| 423 | $p2 = self::factory()->post->create(); |
| 424 | $p3 = self::factory()->post->create(); |
425 | 425 | |
426 | 426 | wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' ); |
427 | 427 | wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
448 | 448 | register_taxonomy( 'wptests_tax1', 'post' ); |
449 | 449 | register_taxonomy( 'wptests_tax2', 'post' ); |
450 | 450 | |
451 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
452 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| 451 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| 452 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
453 | 453 | |
454 | | $p1 = self::$factory->post->create(); |
455 | | $p2 = self::$factory->post->create(); |
456 | | $p3 = self::$factory->post->create(); |
| 454 | $p1 = self::factory()->post->create(); |
| 455 | $p2 = self::factory()->post->create(); |
| 456 | $p3 = self::factory()->post->create(); |
457 | 457 | |
458 | 458 | wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' ); |
459 | 459 | wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
481 | 481 | register_taxonomy( 'wptests_tax1', 'post' ); |
482 | 482 | register_taxonomy( 'wptests_tax2', 'post' ); |
483 | 483 | |
484 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
485 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| 484 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| 485 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
486 | 486 | |
487 | | $p1 = self::$factory->post->create(); |
488 | | $p2 = self::$factory->post->create(); |
489 | | $p3 = self::$factory->post->create(); |
| 487 | $p1 = self::factory()->post->create(); |
| 488 | $p2 = self::factory()->post->create(); |
| 489 | $p3 = self::factory()->post->create(); |
490 | 490 | |
491 | 491 | wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' ); |
492 | 492 | wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
506 | 506 | } |
507 | 507 | |
508 | 508 | public function test_tax_query_multiple_queries_relation_and() { |
509 | | $t1 = self::$factory->term->create( array( |
| 509 | $t1 = self::factory()->term->create( array( |
510 | 510 | 'taxonomy' => 'category', |
511 | 511 | 'slug' => 'foo', |
512 | 512 | 'name' => 'Foo', |
513 | 513 | ) ); |
514 | | $t2 = self::$factory->term->create( array( |
| 514 | $t2 = self::factory()->term->create( array( |
515 | 515 | 'taxonomy' => 'category', |
516 | 516 | 'slug' => 'bar', |
517 | 517 | 'name' => 'Bar', |
518 | 518 | ) ); |
519 | | $p1 = self::$factory->post->create(); |
520 | | $p2 = self::$factory->post->create(); |
521 | | $p3 = self::$factory->post->create(); |
| 519 | $p1 = self::factory()->post->create(); |
| 520 | $p2 = self::factory()->post->create(); |
| 521 | $p3 = self::factory()->post->create(); |
522 | 522 | |
523 | 523 | wp_set_object_terms( $p1, $t1, 'category' ); |
524 | 524 | wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
546 | 546 | } |
547 | 547 | |
548 | 548 | public function test_tax_query_multiple_queries_relation_or() { |
549 | | $t1 = self::$factory->term->create( array( |
| 549 | $t1 = self::factory()->term->create( array( |
550 | 550 | 'taxonomy' => 'category', |
551 | 551 | 'slug' => 'foo', |
552 | 552 | 'name' => 'Foo', |
553 | 553 | ) ); |
554 | | $t2 = self::$factory->term->create( array( |
| 554 | $t2 = self::factory()->term->create( array( |
555 | 555 | 'taxonomy' => 'category', |
556 | 556 | 'slug' => 'bar', |
557 | 557 | 'name' => 'Bar', |
558 | 558 | ) ); |
559 | | $p1 = self::$factory->post->create(); |
560 | | $p2 = self::$factory->post->create(); |
561 | | $p3 = self::$factory->post->create(); |
| 559 | $p1 = self::factory()->post->create(); |
| 560 | $p2 = self::factory()->post->create(); |
| 561 | $p3 = self::factory()->post->create(); |
562 | 562 | |
563 | 563 | wp_set_object_terms( $p1, $t1, 'category' ); |
564 | 564 | wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
586 | 586 | } |
587 | 587 | |
588 | 588 | public function test_tax_query_multiple_queries_different_taxonomies() { |
589 | | $t1 = self::$factory->term->create( array( |
| 589 | $t1 = self::factory()->term->create( array( |
590 | 590 | 'taxonomy' => 'post_tag', |
591 | 591 | 'slug' => 'foo', |
592 | 592 | 'name' => 'Foo', |
593 | 593 | ) ); |
594 | | $t2 = self::$factory->term->create( array( |
| 594 | $t2 = self::factory()->term->create( array( |
595 | 595 | 'taxonomy' => 'category', |
596 | 596 | 'slug' => 'bar', |
597 | 597 | 'name' => 'Bar', |
598 | 598 | ) ); |
599 | | $p1 = self::$factory->post->create(); |
600 | | $p2 = self::$factory->post->create(); |
601 | | $p3 = self::$factory->post->create(); |
| 599 | $p1 = self::factory()->post->create(); |
| 600 | $p2 = self::factory()->post->create(); |
| 601 | $p3 = self::factory()->post->create(); |
602 | 602 | |
603 | 603 | wp_set_object_terms( $p1, $t1, 'post_tag' ); |
604 | 604 | wp_set_object_terms( $p2, $t2, 'category' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
632 | 632 | register_taxonomy( 'foo', 'post' ); |
633 | 633 | register_taxonomy( 'bar', 'post' ); |
634 | 634 | |
635 | | $foo_term_1 = self::$factory->term->create( array( |
| 635 | $foo_term_1 = self::factory()->term->create( array( |
636 | 636 | 'taxonomy' => 'foo', |
637 | 637 | ) ); |
638 | | $foo_term_2 = self::$factory->term->create( array( |
| 638 | $foo_term_2 = self::factory()->term->create( array( |
639 | 639 | 'taxonomy' => 'foo', |
640 | 640 | ) ); |
641 | | $bar_term_1 = self::$factory->term->create( array( |
| 641 | $bar_term_1 = self::factory()->term->create( array( |
642 | 642 | 'taxonomy' => 'bar', |
643 | 643 | ) ); |
644 | | $bar_term_2 = self::$factory->term->create( array( |
| 644 | $bar_term_2 = self::factory()->term->create( array( |
645 | 645 | 'taxonomy' => 'bar', |
646 | 646 | ) ); |
647 | 647 | |
648 | | $p1 = self::$factory->post->create(); |
649 | | $p2 = self::$factory->post->create(); |
650 | | $p3 = self::$factory->post->create(); |
| 648 | $p1 = self::factory()->post->create(); |
| 649 | $p2 = self::factory()->post->create(); |
| 650 | $p3 = self::factory()->post->create(); |
651 | 651 | |
652 | 652 | wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' ); |
653 | 653 | wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
704 | 704 | register_taxonomy( 'foo', 'post' ); |
705 | 705 | register_taxonomy( 'bar', 'post' ); |
706 | 706 | |
707 | | $foo_term_1 = self::$factory->term->create( array( |
| 707 | $foo_term_1 = self::factory()->term->create( array( |
708 | 708 | 'taxonomy' => 'foo', |
709 | 709 | ) ); |
710 | | $foo_term_2 = self::$factory->term->create( array( |
| 710 | $foo_term_2 = self::factory()->term->create( array( |
711 | 711 | 'taxonomy' => 'foo', |
712 | 712 | ) ); |
713 | | $bar_term_1 = self::$factory->term->create( array( |
| 713 | $bar_term_1 = self::factory()->term->create( array( |
714 | 714 | 'taxonomy' => 'bar', |
715 | 715 | ) ); |
716 | | $bar_term_2 = self::$factory->term->create( array( |
| 716 | $bar_term_2 = self::factory()->term->create( array( |
717 | 717 | 'taxonomy' => 'bar', |
718 | 718 | ) ); |
719 | 719 | |
720 | | $p1 = self::$factory->post->create(); |
721 | | $p2 = self::$factory->post->create(); |
722 | | $p3 = self::$factory->post->create(); |
| 720 | $p1 = self::factory()->post->create(); |
| 721 | $p2 = self::factory()->post->create(); |
| 722 | $p3 = self::factory()->post->create(); |
723 | 723 | |
724 | 724 | wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' ); |
725 | 725 | wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
768 | 768 | register_taxonomy( 'foo', 'post' ); |
769 | 769 | register_taxonomy( 'bar', 'post' ); |
770 | 770 | |
771 | | $foo_term_1 = self::$factory->term->create( array( |
| 771 | $foo_term_1 = self::factory()->term->create( array( |
772 | 772 | 'taxonomy' => 'foo', |
773 | 773 | ) ); |
774 | | $foo_term_2 = self::$factory->term->create( array( |
| 774 | $foo_term_2 = self::factory()->term->create( array( |
775 | 775 | 'taxonomy' => 'foo', |
776 | 776 | ) ); |
777 | | $bar_term_1 = self::$factory->term->create( array( |
| 777 | $bar_term_1 = self::factory()->term->create( array( |
778 | 778 | 'taxonomy' => 'bar', |
779 | 779 | ) ); |
780 | | $bar_term_2 = self::$factory->term->create( array( |
| 780 | $bar_term_2 = self::factory()->term->create( array( |
781 | 781 | 'taxonomy' => 'bar', |
782 | 782 | ) ); |
783 | 783 | |
784 | | $p1 = self::$factory->post->create(); |
785 | | $p2 = self::$factory->post->create(); |
786 | | $p3 = self::$factory->post->create(); |
787 | | $p4 = self::$factory->post->create(); |
| 784 | $p1 = self::factory()->post->create(); |
| 785 | $p2 = self::factory()->post->create(); |
| 786 | $p3 = self::factory()->post->create(); |
| 787 | $p4 = self::factory()->post->create(); |
788 | 788 | |
789 | 789 | wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' ); |
790 | 790 | wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
840 | 840 | public function test_tax_query_relation_or_both_clauses_empty_terms() { |
841 | 841 | // An empty tax query should return an empty array, not all posts. |
842 | 842 | |
843 | | self::$factory->post->create_many( 2 ); |
| 843 | self::factory()->post->create_many( 2 ); |
844 | 844 | |
845 | 845 | $query = new WP_Query( array( |
846 | 846 | 'fields' => 'ids', |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
873 | 873 | public function test_tax_query_relation_or_one_clause_empty_terms() { |
874 | 874 | // An empty tax query should return an empty array, not all posts. |
875 | 875 | |
876 | | self::$factory->post->create_many( 2 ); |
| 876 | self::factory()->post->create_many( 2 ); |
877 | 877 | |
878 | 878 | $query = new WP_Query( array( |
879 | 879 | 'fields' => 'ids', |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
901 | 901 | } |
902 | 902 | |
903 | 903 | public function test_tax_query_include_children() { |
904 | | $cat_a = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Australia' ) ); |
905 | | $cat_b = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Sydney', 'parent' => $cat_a ) ); |
906 | | $cat_c = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'East Syndney', 'parent' => $cat_b ) ); |
907 | | $cat_d = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'West Syndney', 'parent' => $cat_b ) ); |
| 904 | $cat_a = self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => 'Australia' ) ); |
| 905 | $cat_b = self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => 'Sydney', 'parent' => $cat_a ) ); |
| 906 | $cat_c = self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => 'East Syndney', 'parent' => $cat_b ) ); |
| 907 | $cat_d = self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => 'West Syndney', 'parent' => $cat_b ) ); |
908 | 908 | |
909 | | $post_a = self::$factory->post->create( array( 'post_category' => array( $cat_a ) ) ); |
910 | | $post_b = self::$factory->post->create( array( 'post_category' => array( $cat_b ) ) ); |
911 | | $post_c = self::$factory->post->create( array( 'post_category' => array( $cat_c ) ) ); |
912 | | $post_d = self::$factory->post->create( array( 'post_category' => array( $cat_d ) ) ); |
| 909 | $post_a = self::factory()->post->create( array( 'post_category' => array( $cat_a ) ) ); |
| 910 | $post_b = self::factory()->post->create( array( 'post_category' => array( $cat_b ) ) ); |
| 911 | $post_c = self::factory()->post->create( array( 'post_category' => array( $cat_c ) ) ); |
| 912 | $post_d = self::factory()->post->create( array( 'post_category' => array( $cat_d ) ) ); |
913 | 913 | |
914 | 914 | $posts = get_posts( array( |
915 | 915 | 'fields' => 'ids', |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
1009 | 1009 | $q = new WP_Query(); |
1010 | 1010 | |
1011 | 1011 | register_taxonomy_for_object_type( 'post_tag', 'attachment:image' ); |
1012 | | $tag_id = self::$factory->term->create( array( 'slug' => rand_str(), 'name' => rand_str() ) ); |
1013 | | $image_id = self::$factory->attachment->create_object( 'image.jpg', 0, array( |
| 1012 | $tag_id = self::factory()->term->create( array( 'slug' => rand_str(), 'name' => rand_str() ) ); |
| 1013 | $image_id = self::factory()->attachment->create_object( 'image.jpg', 0, array( |
1014 | 1014 | 'post_mime_type' => 'image/jpeg', |
1015 | 1015 | 'post_type' => 'attachment' |
1016 | 1016 | ) ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | public function test_tax_query_no_taxonomy() { |
1038 | | $cat_id = self::$factory->category->create( array( 'name' => 'alpha' ) ); |
1039 | | self::$factory->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $cat_id ) ) ); |
| 1038 | $cat_id = self::factory()->category->create( array( 'name' => 'alpha' ) ); |
| 1039 | self::factory()->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $cat_id ) ) ); |
1040 | 1040 | |
1041 | 1041 | $response1 = new WP_Query( array( |
1042 | 1042 | 'tax_query' => array( |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
1076 | 1076 | public function test_term_taxonomy_id_field_no_taxonomy() { |
1077 | 1077 | $q = new WP_Query(); |
1078 | 1078 | |
1079 | | $posts = self::$factory->post->create_many( 5 ); |
| 1079 | $posts = self::factory()->post->create_many( 5 ); |
1080 | 1080 | |
1081 | 1081 | $cats = $tags = array(); |
1082 | 1082 | |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
1155 | 1155 | */ |
1156 | 1156 | public function test_populate_taxonomy_query_var_from_tax_query() { |
1157 | 1157 | register_taxonomy( 'foo', 'post' ); |
1158 | | $t = self::$factory->term->create( array( |
| 1158 | $t = self::factory()->term->create( array( |
1159 | 1159 | 'taxonomy' => 'foo', |
1160 | 1160 | ) ); |
1161 | | $c = self::$factory->term->create( array( |
| 1161 | $c = self::factory()->term->create( array( |
1162 | 1162 | 'taxonomy' => 'category', |
1163 | 1163 | ) ); |
1164 | 1164 | |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
1191 | 1191 | public function test_populate_taxonomy_query_var_from_tax_query_taxonomy_already_set() { |
1192 | 1192 | register_taxonomy( 'foo', 'post' ); |
1193 | 1193 | register_taxonomy( 'foo1', 'post' ); |
1194 | | $t = self::$factory->term->create( array( |
| 1194 | $t = self::factory()->term->create( array( |
1195 | 1195 | 'taxonomy' => 'foo', |
1196 | 1196 | ) ); |
1197 | 1197 | |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
1213 | 1213 | |
1214 | 1214 | public function test_populate_term_query_var_from_tax_query() { |
1215 | 1215 | register_taxonomy( 'foo', 'post' ); |
1216 | | $t = self::$factory->term->create( array( |
| 1216 | $t = self::factory()->term->create( array( |
1217 | 1217 | 'taxonomy' => 'foo', |
1218 | 1218 | 'slug' => 'bar', |
1219 | 1219 | ) ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
1235 | 1235 | |
1236 | 1236 | public function test_populate_term_id_query_var_from_tax_query() { |
1237 | 1237 | register_taxonomy( 'foo', 'post' ); |
1238 | | $t = self::$factory->term->create( array( |
| 1238 | $t = self::factory()->term->create( array( |
1239 | 1239 | 'taxonomy' => 'foo', |
1240 | 1240 | 'slug' => 'bar', |
1241 | 1241 | ) ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
1260 | 1260 | */ |
1261 | 1261 | public function test_populate_cat_category_name_query_var_from_tax_query() { |
1262 | 1262 | register_taxonomy( 'foo', 'post' ); |
1263 | | $t = self::$factory->term->create( array( |
| 1263 | $t = self::factory()->term->create( array( |
1264 | 1264 | 'taxonomy' => 'foo', |
1265 | 1265 | ) ); |
1266 | | $c = self::$factory->term->create( array( |
| 1266 | $c = self::factory()->term->create( array( |
1267 | 1267 | 'taxonomy' => 'category', |
1268 | 1268 | 'slug' => 'bar', |
1269 | 1269 | ) ); |
… |
… |
class Tests_Query_TaxQuery extends WP_UnitTestCase { |
1301 | 1301 | */ |
1302 | 1302 | public function test_populate_tag_id_query_var_from_tax_query() { |
1303 | 1303 | register_taxonomy( 'foo', 'post' ); |
1304 | | $t = self::$factory->term->create( array( |
| 1304 | $t = self::factory()->term->create( array( |
1305 | 1305 | 'taxonomy' => 'foo', |
1306 | 1306 | ) ); |
1307 | | $tag = self::$factory->term->create( array( |
| 1307 | $tag = self::factory()->term->create( array( |
1308 | 1308 | 'taxonomy' => 'post_tag', |
1309 | 1309 | 'slug' => 'bar', |
1310 | 1310 | ) ); |
-
diff --git tests/phpunit/tests/rest-api/rest-server.php tests/phpunit/tests/rest-api/rest-server.php
index bd0abb3..2ec561a 100644
|
|
class Tests_REST_Server extends WP_Test_REST_TestCase { |
136 | 136 | 'permission_callback' => '__return_true', |
137 | 137 | ) ); |
138 | 138 | |
139 | | $editor = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 139 | $editor = self::factory()->user->create( array( 'role' => 'editor' ) ); |
140 | 140 | |
141 | 141 | $request = new WP_REST_Request( 'GET', '/test-ns/test', array() ); |
142 | 142 | |
-
diff --git tests/phpunit/tests/rewrite.php tests/phpunit/tests/rewrite.php
index 2f60b34..338cb9b 100644
|
|
class Tests_Rewrite extends WP_UnitTestCase { |
85 | 85 | |
86 | 86 | function test_url_to_postid() { |
87 | 87 | |
88 | | $id = self::$factory->post->create(); |
| 88 | $id = self::factory()->post->create(); |
89 | 89 | $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); |
90 | 90 | |
91 | | $id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 91 | $id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
92 | 92 | $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); |
93 | 93 | } |
94 | 94 | |
95 | 95 | function test_url_to_postid_set_url_scheme_https_to_http() { |
96 | | $post_id = self::$factory->post->create(); |
| 96 | $post_id = self::factory()->post->create(); |
97 | 97 | $permalink = get_permalink( $post_id ); |
98 | 98 | $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); |
99 | 99 | |
100 | | $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 100 | $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
101 | 101 | $permalink = get_permalink( $post_id ); |
102 | 102 | $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); |
103 | 103 | } |
… |
… |
class Tests_Rewrite extends WP_UnitTestCase { |
109 | 109 | |
110 | 110 | $_SERVER['HTTPS'] = 'on'; |
111 | 111 | |
112 | | $post_id = self::$factory->post->create(); |
| 112 | $post_id = self::factory()->post->create(); |
113 | 113 | $permalink = get_permalink( $post_id ); |
114 | 114 | $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'http' ) ) ); |
115 | 115 | |
116 | | $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 116 | $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
117 | 117 | $permalink = get_permalink( $post_id ); |
118 | 118 | $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'http' ) ) ); |
119 | 119 | |
… |
… |
class Tests_Rewrite extends WP_UnitTestCase { |
128 | 128 | $post_type = rand_str( 12 ); |
129 | 129 | register_post_type( $post_type, array( 'public' => true ) ); |
130 | 130 | |
131 | | $id = self::$factory->post->create( array( 'post_type' => $post_type ) ); |
| 131 | $id = self::factory()->post->create( array( 'post_type' => $post_type ) ); |
132 | 132 | $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); |
133 | 133 | |
134 | 134 | _unregister_post_type( $post_type ); |
… |
… |
class Tests_Rewrite extends WP_UnitTestCase { |
136 | 136 | |
137 | 137 | function test_url_to_postid_hierarchical() { |
138 | 138 | |
139 | | $parent_id = self::$factory->post->create( array( 'post_title' => 'Parent', 'post_type' => 'page' ) ); |
140 | | $child_id = self::$factory->post->create( array( 'post_title' => 'Child', 'post_type' => 'page', 'post_parent' => $parent_id ) ); |
| 139 | $parent_id = self::factory()->post->create( array( 'post_title' => 'Parent', 'post_type' => 'page' ) ); |
| 140 | $child_id = self::factory()->post->create( array( 'post_title' => 'Child', 'post_type' => 'page', 'post_parent' => $parent_id ) ); |
141 | 141 | |
142 | 142 | $this->assertEquals( $parent_id, url_to_postid( get_permalink( $parent_id ) ) ); |
143 | 143 | $this->assertEquals( $child_id, url_to_postid( get_permalink( $child_id ) ) ); |
… |
… |
class Tests_Rewrite extends WP_UnitTestCase { |
145 | 145 | |
146 | 146 | function test_url_to_postid_hierarchical_with_matching_leaves() { |
147 | 147 | |
148 | | $parent_id = self::$factory->post->create( array( |
| 148 | $parent_id = self::factory()->post->create( array( |
149 | 149 | 'post_name' => 'parent', |
150 | 150 | 'post_type' => 'page', |
151 | 151 | ) ); |
152 | | $child_id_1 = self::$factory->post->create( array( |
| 152 | $child_id_1 = self::factory()->post->create( array( |
153 | 153 | 'post_name' => 'child1', |
154 | 154 | 'post_type' => 'page', |
155 | 155 | 'post_parent' => $parent_id, |
156 | 156 | ) ); |
157 | | $child_id_2 = self::$factory->post->create( array( |
| 157 | $child_id_2 = self::factory()->post->create( array( |
158 | 158 | 'post_name' => 'child2', |
159 | 159 | 'post_type' => 'page', |
160 | 160 | 'post_parent' => $parent_id, |
161 | 161 | ) ); |
162 | | $grandchild_id_1 = self::$factory->post->create( array( |
| 162 | $grandchild_id_1 = self::factory()->post->create( array( |
163 | 163 | 'post_name' => 'grandchild', |
164 | 164 | 'post_type' => 'page', |
165 | 165 | 'post_parent' => $child_id_1, |
166 | 166 | ) ); |
167 | | $grandchild_id_2 = self::$factory->post->create( array( |
| 167 | $grandchild_id_2 = self::factory()->post->create( array( |
168 | 168 | 'post_name' => 'grandchild', |
169 | 169 | 'post_type' => 'page', |
170 | 170 | 'post_parent' => $child_id_2, |
… |
… |
class Tests_Rewrite extends WP_UnitTestCase { |
180 | 180 | |
181 | 181 | update_option( 'home', home_url( '/example/' ) ); |
182 | 182 | |
183 | | $id = self::$factory->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'examp' ) ); |
| 183 | $id = self::factory()->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'examp' ) ); |
184 | 184 | $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); |
185 | 185 | $this->assertEquals( $id, url_to_postid( site_url('/example/examp' ) ) ); |
186 | 186 | $this->assertEquals( $id, url_to_postid( '/example/examp/' ) ); |
… |
… |
class Tests_Rewrite extends WP_UnitTestCase { |
244 | 244 | function test_url_to_postid_dupe_path() { |
245 | 245 | update_option( 'home', home_url('/example/') ); |
246 | 246 | |
247 | | $id = self::$factory->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'example' ) ); |
| 247 | $id = self::factory()->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'example' ) ); |
248 | 248 | |
249 | 249 | $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); |
250 | 250 | $this->assertEquals( $id, url_to_postid( site_url( '/example/example/' ) ) ); |
… |
… |
class Tests_Rewrite extends WP_UnitTestCase { |
258 | 258 | function test_url_to_postid_home_url_collision() { |
259 | 259 | update_option( 'home', home_url( '/example' ) ); |
260 | 260 | |
261 | | self::$factory->post->create( array( 'post_title' => 'Collision', 'post_type' => 'page', 'post_name' => 'collision' ) ); |
| 261 | self::factory()->post->create( array( 'post_title' => 'Collision', 'post_type' => 'page', 'post_name' => 'collision' ) ); |
262 | 262 | |
263 | 263 | // This url should NOT return a post ID |
264 | 264 | $badurl = site_url( '/example-collision' ); |
… |
… |
class Tests_Rewrite extends WP_UnitTestCase { |
277 | 277 | return false; |
278 | 278 | } |
279 | 279 | |
280 | | $blog_id = self::$factory->blog->create( array( 'path' => '/example' ) ); |
| 280 | $blog_id = self::factory()->blog->create( array( 'path' => '/example' ) ); |
281 | 281 | switch_to_blog( $blog_id ); |
282 | 282 | |
283 | | self::$factory->post->create( array( 'post_title' => 'Collision ', 'post_type' => 'page' ) ); |
| 283 | self::factory()->post->create( array( 'post_title' => 'Collision ', 'post_type' => 'page' ) ); |
284 | 284 | |
285 | 285 | // This url should NOT return a post ID |
286 | 286 | $badurl = network_home_url( '/example-collision' ); |
… |
… |
class Tests_Rewrite extends WP_UnitTestCase { |
294 | 294 | */ |
295 | 295 | public function test_is_home_should_be_false_when_visiting_custom_endpoint_without_a_registered_query_var_and_page_on_front_is_set() { |
296 | 296 | |
297 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
| 297 | $page_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
298 | 298 | update_option( 'show_on_front', 'page' ); |
299 | 299 | update_option( 'page_on_front', $page_id ); |
300 | 300 | |
… |
… |
class Tests_Rewrite extends WP_UnitTestCase { |
313 | 313 | function test_url_to_postid_with_post_slug_that_clashes_with_a_trashed_page() { |
314 | 314 | $this->set_permalink_structure( '/%postname%/' ); |
315 | 315 | |
316 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) ); |
317 | | $post_id = self::$factory->post->create( array( 'post_title' => get_post( $page_id )->post_title ) ); |
| 316 | $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) ); |
| 317 | $post_id = self::factory()->post->create( array( 'post_title' => get_post( $page_id )->post_title ) ); |
318 | 318 | |
319 | 319 | $this->assertEquals( $post_id, url_to_postid( get_permalink( $post_id ) ) ); |
320 | 320 | |
… |
… |
class Tests_Rewrite extends WP_UnitTestCase { |
327 | 327 | function test_parse_request_with_post_slug_that_clashes_with_a_trashed_page() { |
328 | 328 | $this->set_permalink_structure( '/%postname%/' ); |
329 | 329 | |
330 | | $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) ); |
331 | | $post_id = self::$factory->post->create( array( 'post_title' => get_post( $page_id )->post_title ) ); |
| 330 | $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) ); |
| 331 | $post_id = self::factory()->post->create( array( 'post_title' => get_post( $page_id )->post_title ) ); |
332 | 332 | |
333 | 333 | $this->go_to( get_permalink( $post_id ) ); |
334 | 334 | |
-
diff --git tests/phpunit/tests/rewrite/numericSlugs.php tests/phpunit/tests/rewrite/numericSlugs.php
index 652b28b..3f7aa11 100644
|
|
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
9 | 9 | |
10 | 10 | public function setUp() { |
11 | 11 | parent::setUp(); |
12 | | $this->author_id = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 12 | $this->author_id = self::factory()->user->create( array( 'role' => 'editor' ) ); |
13 | 13 | |
14 | 14 | // Override the post/archive slug collision prevention in `wp_unique_post_slug()`. |
15 | 15 | add_filter( 'wp_unique_post_slug', array( $this, 'filter_unique_post_slug' ), 10, 6 ); |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
23 | 23 | global $wpdb; |
24 | 24 | $this->set_permalink_structure( '/%postname%/' ); |
25 | 25 | |
26 | | $id = self::$factory->post->create( array( |
| 26 | $id = self::factory()->post->create( array( |
27 | 27 | 'post_author' => $this->author_id, |
28 | 28 | 'post_status' => 'publish', |
29 | 29 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
51 | 51 | global $wpdb; |
52 | 52 | $this->set_permalink_structure( '/%postname%/' ); |
53 | 53 | |
54 | | $id = self::$factory->post->create( array( |
| 54 | $id = self::factory()->post->create( array( |
55 | 55 | 'post_author' => $this->author_id, |
56 | 56 | 'post_status' => 'publish', |
57 | 57 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
76 | 76 | public function test_go_to_year_segment_collision_with_title() { |
77 | 77 | $this->set_permalink_structure( '/%postname%/' ); |
78 | 78 | |
79 | | $id = self::$factory->post->create( array( |
| 79 | $id = self::factory()->post->create( array( |
80 | 80 | 'post_author' => $this->author_id, |
81 | 81 | 'post_status' => 'publish', |
82 | 82 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
92 | 92 | public function test_url_to_postid_year_segment_collision_with_title() { |
93 | 93 | $this->set_permalink_structure( '/%postname%/' ); |
94 | 94 | |
95 | | $id = self::$factory->post->create( array( |
| 95 | $id = self::factory()->post->create( array( |
96 | 96 | 'post_author' => $this->author_id, |
97 | 97 | 'post_status' => 'publish', |
98 | 98 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
106 | 106 | public function test_go_to_month_segment_collision_without_title() { |
107 | 107 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
108 | 108 | |
109 | | $id = self::$factory->post->create( array( |
| 109 | $id = self::factory()->post->create( array( |
110 | 110 | 'post_author' => $this->author_id, |
111 | 111 | 'post_status' => 'publish', |
112 | 112 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
123 | 123 | public function test_url_to_postid_month_segment_collision_without_title() { |
124 | 124 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
125 | 125 | |
126 | | $id = self::$factory->post->create( array( |
| 126 | $id = self::factory()->post->create( array( |
127 | 127 | 'post_author' => $this->author_id, |
128 | 128 | 'post_status' => 'publish', |
129 | 129 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
138 | 138 | public function test_go_to_month_segment_collision_without_title_no_leading_zero() { |
139 | 139 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
140 | 140 | |
141 | | $id = self::$factory->post->create( array( |
| 141 | $id = self::factory()->post->create( array( |
142 | 142 | 'post_author' => $this->author_id, |
143 | 143 | 'post_status' => 'publish', |
144 | 144 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
155 | 155 | public function test_url_to_postid_month_segment_collision_without_title_no_leading_zero() { |
156 | 156 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
157 | 157 | |
158 | | $id = self::$factory->post->create( array( |
| 158 | $id = self::factory()->post->create( array( |
159 | 159 | 'post_author' => $this->author_id, |
160 | 160 | 'post_status' => 'publish', |
161 | 161 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
170 | 170 | public function test_go_to_month_segment_collision_with_title() { |
171 | 171 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
172 | 172 | |
173 | | $id = self::$factory->post->create( array( |
| 173 | $id = self::factory()->post->create( array( |
174 | 174 | 'post_author' => $this->author_id, |
175 | 175 | 'post_status' => 'publish', |
176 | 176 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
186 | 186 | public function test_url_to_postid_month_segment_collision_with_title() { |
187 | 187 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
188 | 188 | |
189 | | $id = self::$factory->post->create( array( |
| 189 | $id = self::factory()->post->create( array( |
190 | 190 | 'post_author' => $this->author_id, |
191 | 191 | 'post_status' => 'publish', |
192 | 192 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
200 | 200 | public function test_go_to_month_segment_collision_with_title_no_leading_zero() { |
201 | 201 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
202 | 202 | |
203 | | $id = self::$factory->post->create( array( |
| 203 | $id = self::factory()->post->create( array( |
204 | 204 | 'post_author' => $this->author_id, |
205 | 205 | 'post_status' => 'publish', |
206 | 206 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
216 | 216 | public function test_url_to_postid_month_segment_collision_with_title_no_leading_zero() { |
217 | 217 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
218 | 218 | |
219 | | $id = self::$factory->post->create( array( |
| 219 | $id = self::factory()->post->create( array( |
220 | 220 | 'post_author' => $this->author_id, |
221 | 221 | 'post_status' => 'publish', |
222 | 222 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
230 | 230 | public function test_go_to_day_segment_collision_without_title() { |
231 | 231 | $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); |
232 | 232 | |
233 | | $id = self::$factory->post->create( array( |
| 233 | $id = self::factory()->post->create( array( |
234 | 234 | 'post_author' => $this->author_id, |
235 | 235 | 'post_status' => 'publish', |
236 | 236 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
247 | 247 | public function test_url_to_postid_day_segment_collision_without_title() { |
248 | 248 | $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); |
249 | 249 | |
250 | | $id = self::$factory->post->create( array( |
| 250 | $id = self::factory()->post->create( array( |
251 | 251 | 'post_author' => $this->author_id, |
252 | 252 | 'post_status' => 'publish', |
253 | 253 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
262 | 262 | public function test_go_to_day_segment_collision_with_title() { |
263 | 263 | $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); |
264 | 264 | |
265 | | $id = self::$factory->post->create( array( |
| 265 | $id = self::factory()->post->create( array( |
266 | 266 | 'post_author' => $this->author_id, |
267 | 267 | 'post_status' => 'publish', |
268 | 268 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
278 | 278 | public function test_url_to_postid_day_segment_collision_with_title() { |
279 | 279 | $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); |
280 | 280 | |
281 | | $id = self::$factory->post->create( array( |
| 281 | $id = self::factory()->post->create( array( |
282 | 282 | 'post_author' => $this->author_id, |
283 | 283 | 'post_status' => 'publish', |
284 | 284 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
292 | 292 | public function test_numeric_slug_permalink_conflicts_should_only_be_resolved_for_the_main_query() { |
293 | 293 | $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); |
294 | 294 | |
295 | | $id = self::$factory->post->create( array( |
| 295 | $id = self::factory()->post->create( array( |
296 | 296 | 'post_author' => $this->author_id, |
297 | 297 | 'post_status' => 'publish', |
298 | 298 | 'post_content' => rand_str(), |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
314 | 314 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
315 | 315 | |
316 | 316 | // Make sure a post is published in 2013/02, to avoid 404s. |
317 | | self::$factory->post->create( array( |
| 317 | self::factory()->post->create( array( |
318 | 318 | 'post_author' => $this->author_id, |
319 | 319 | 'post_status' => 'publish', |
320 | 320 | 'post_content' => 'foo', |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
322 | 322 | 'post_date' => '2013-02-01 01:00:00', |
323 | 323 | ) ); |
324 | 324 | |
325 | | $id = self::$factory->post->create( array( |
| 325 | $id = self::factory()->post->create( array( |
326 | 326 | 'post_author' => $this->author_id, |
327 | 327 | 'post_status' => 'publish', |
328 | 328 | 'post_content' => 'foo', |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
342 | 342 | $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); |
343 | 343 | |
344 | 344 | // Make sure a post is published on 2015/01/01, to avoid 404s. |
345 | | self::$factory->post->create( array( |
| 345 | self::factory()->post->create( array( |
346 | 346 | 'post_author' => $this->author_id, |
347 | 347 | 'post_status' => 'publish', |
348 | 348 | 'post_content' => 'foo', |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
350 | 350 | 'post_date' => '2015-01-02 01:00:00', |
351 | 351 | ) ); |
352 | 352 | |
353 | | $id = self::$factory->post->create( array( |
| 353 | $id = self::factory()->post->create( array( |
354 | 354 | 'post_author' => $this->author_id, |
355 | 355 | 'post_status' => 'publish', |
356 | 356 | 'post_content' => 'foo', |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
369 | 369 | public function test_date_slug_collision_should_distinguish_valid_pagination_from_date() { |
370 | 370 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
371 | 371 | |
372 | | $id = self::$factory->post->create( array( |
| 372 | $id = self::factory()->post->create( array( |
373 | 373 | 'post_author' => $this->author_id, |
374 | 374 | 'post_status' => 'publish', |
375 | 375 | 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3', |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
385 | 385 | public function test_date_slug_collision_should_distinguish_too_high_pagination_from_date() { |
386 | 386 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
387 | 387 | |
388 | | $id = self::$factory->post->create( array( |
| 388 | $id = self::factory()->post->create( array( |
389 | 389 | 'post_author' => $this->author_id, |
390 | 390 | 'post_status' => 'publish', |
391 | 391 | 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3', |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
401 | 401 | public function test_date_slug_collision_should_not_require_pagination_query_var() { |
402 | 402 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
403 | 403 | |
404 | | $id = self::$factory->post->create( array( |
| 404 | $id = self::factory()->post->create( array( |
405 | 405 | 'post_author' => $this->author_id, |
406 | 406 | 'post_status' => 'publish', |
407 | 407 | 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3', |
… |
… |
class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { |
418 | 418 | public function test_date_slug_collision_should_be_ignored_when_pagination_var_is_present_but_post_does_not_have_multiple_pages() { |
419 | 419 | $this->set_permalink_structure( '/%year%/%postname%/' ); |
420 | 420 | |
421 | | $id = self::$factory->post->create( array( |
| 421 | $id = self::factory()->post->create( array( |
422 | 422 | 'post_author' => $this->author_id, |
423 | 423 | 'post_status' => 'publish', |
424 | 424 | 'post_content' => 'This post does not have pagination.', |
-
diff --git tests/phpunit/tests/rewrite/oldSlugRedirect.php tests/phpunit/tests/rewrite/oldSlugRedirect.php
index 97c187c..7192013 100644
|
|
class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase { |
12 | 12 | public function setUp() { |
13 | 13 | parent::setUp(); |
14 | 14 | |
15 | | $this->post_id = self::$factory->post->create( array( |
| 15 | $this->post_id = self::factory()->post->create( array( |
16 | 16 | 'post_title' => 'Foo Bar', |
17 | 17 | 'post_name' => 'foo-bar', |
18 | 18 | ) ); |
… |
… |
class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase { |
99 | 99 | |
100 | 100 | public function test_old_slug_redirect_attachment() { |
101 | 101 | $file = DIR_TESTDATA . '/images/canola.jpg'; |
102 | | $attachment_id = self::$factory->attachment->create_object( $file, $this->post_id, array( |
| 102 | $attachment_id = self::factory()->attachment->create_object( $file, $this->post_id, array( |
103 | 103 | 'post_mime_type' => 'image/jpeg', |
104 | 104 | 'post_name' => 'my-attachment', |
105 | 105 | ) ); |
-
diff --git tests/phpunit/tests/taxonomy.php tests/phpunit/tests/taxonomy.php
index 6c0447f..7f49fc2 100644
|
|
class Tests_Taxonomy extends WP_UnitTestCase { |
34 | 34 | } |
35 | 35 | |
36 | 36 | function test_get_the_taxonomies() { |
37 | | $post_id = self::$factory->post->create(); |
| 37 | $post_id = self::factory()->post->create(); |
38 | 38 | |
39 | 39 | $taxes = get_the_taxonomies( $post_id ); |
40 | 40 | $this->assertNotEmpty( $taxes ); |
41 | 41 | $this->assertEquals( array( 'category' ), array_keys( $taxes ) ); |
42 | 42 | |
43 | | $id = self::$factory->tag->create(); |
| 43 | $id = self::factory()->tag->create(); |
44 | 44 | wp_set_post_tags( $post_id, array( $id ) ); |
45 | 45 | |
46 | 46 | $taxes = get_the_taxonomies( $post_id ); |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
53 | 53 | * @group 27238 |
54 | 54 | */ |
55 | 55 | public function test_get_the_taxonomies_term_template() { |
56 | | $post_id = self::$factory->post->create(); |
| 56 | $post_id = self::factory()->post->create(); |
57 | 57 | |
58 | 58 | $taxes = get_the_taxonomies( $post_id, array( 'term_template' => '%2$s' ) ); |
59 | 59 | $this->assertEquals( 'Categories: Uncategorized.', $taxes['category'] ); |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
64 | 64 | } |
65 | 65 | |
66 | 66 | function test_the_taxonomies() { |
67 | | $post_id = self::$factory->post->create(); |
| 67 | $post_id = self::factory()->post->create(); |
68 | 68 | |
69 | 69 | ob_start(); |
70 | 70 | the_taxonomies( array( 'post' => $post_id ) ); |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
79 | 79 | * @group 27238 |
80 | 80 | */ |
81 | 81 | function test_the_taxonomies_term_template() { |
82 | | $post_id = self::$factory->post->create(); |
| 82 | $post_id = self::factory()->post->create(); |
83 | 83 | |
84 | 84 | $output = get_echo( 'the_taxonomies', array( array( 'post' => $post_id, 'term_template' => '%2$s' ) ) ); |
85 | 85 | $this->assertEquals( 'Categories: Uncategorized.', $output ); |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
262 | 262 | } |
263 | 263 | |
264 | 264 | public function test_get_objects_in_term_should_return_objects_ids() { |
265 | | $tag_id = self::$factory->tag->create(); |
266 | | $cat_id = self::$factory->category->create(); |
| 265 | $tag_id = self::factory()->tag->create(); |
| 266 | $cat_id = self::factory()->category->create(); |
267 | 267 | $posts_with_tag = array(); |
268 | 268 | $posts_with_category = array(); |
269 | 269 | |
270 | 270 | for ( $i = 0; $i < 3; $i++ ) { |
271 | | $post_id = self::$factory->post->create(); |
| 271 | $post_id = self::factory()->post->create(); |
272 | 272 | wp_set_post_tags( $post_id, array( $tag_id ) ); |
273 | 273 | $posts_with_tag[] = $post_id; |
274 | 274 | } |
275 | 275 | |
276 | 276 | for ( $i = 0; $i < 3; $i++ ) { |
277 | | $post_id = self::$factory->post->create(); |
| 277 | $post_id = self::factory()->post->create(); |
278 | 278 | wp_set_post_categories( $post_id, array( $cat_id ) ); |
279 | 279 | $posts_with_category[] = $post_id; |
280 | 280 | } |
281 | 281 | |
282 | 282 | for ( $i = 0; $i < 3; $i++ ) { |
283 | | self::$factory->post->create(); |
| 283 | self::factory()->post->create(); |
284 | 284 | } |
285 | 285 | |
286 | 286 | $posts_with_terms = array_merge( $posts_with_tag, $posts_with_category ); |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
295 | 295 | * @ticket 25706 |
296 | 296 | */ |
297 | 297 | function test_in_category() { |
298 | | $post = self::$factory->post->create_and_get(); |
| 298 | $post = self::factory()->post->create_and_get(); |
299 | 299 | |
300 | 300 | // in_category() returns false when first parameter is empty() |
301 | 301 | $this->assertFalse( in_category( '', $post ) ); |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
346 | 346 | |
347 | 347 | public function test_get_ancestors_taxonomy_non_hierarchical() { |
348 | 348 | register_taxonomy( 'wptests_tax', 'post' ); |
349 | | $t = self::$factory->term->create( array( |
| 349 | $t = self::factory()->term->create( array( |
350 | 350 | 'taxonomy' => 'wptests_tax', |
351 | 351 | ) ); |
352 | 352 | |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
358 | 358 | register_taxonomy( 'wptests_tax', 'post', array( |
359 | 359 | 'hierarchical' => true, |
360 | 360 | ) ); |
361 | | $t1 = self::$factory->term->create( array( |
| 361 | $t1 = self::factory()->term->create( array( |
362 | 362 | 'taxonomy' => 'wptests_tax', |
363 | 363 | ) ); |
364 | | $t2 = self::$factory->term->create( array( |
| 364 | $t2 = self::factory()->term->create( array( |
365 | 365 | 'taxonomy' => 'wptests_tax', |
366 | 366 | 'parent' => $t1, |
367 | 367 | ) ); |
368 | | $t3 = self::$factory->term->create( array( |
| 368 | $t3 = self::factory()->term->create( array( |
369 | 369 | 'taxonomy' => 'wptests_tax', |
370 | 370 | 'parent' => $t2, |
371 | 371 | ) ); |
372 | | $t4 = self::$factory->term->create( array( |
| 372 | $t4 = self::factory()->term->create( array( |
373 | 373 | 'taxonomy' => 'wptests_tax', |
374 | 374 | 'parent' => $t1, |
375 | 375 | ) ); |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
380 | 380 | |
381 | 381 | public function test_get_ancestors_post_type_non_hierarchical() { |
382 | 382 | register_post_type( 'wptests_pt' ); |
383 | | $p = self::$factory->post->create( array( |
| 383 | $p = self::factory()->post->create( array( |
384 | 384 | 'taxonomy' => 'wptests_pt', |
385 | 385 | ) ); |
386 | 386 | |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
391 | 391 | register_post_type( 'wptests_pt', array( |
392 | 392 | 'hierarchical' => true, |
393 | 393 | ) ); |
394 | | $p1 = self::$factory->post->create( array( |
| 394 | $p1 = self::factory()->post->create( array( |
395 | 395 | 'post_type' => 'wptests_pt', |
396 | 396 | ) ); |
397 | | $p2 = self::$factory->post->create( array( |
| 397 | $p2 = self::factory()->post->create( array( |
398 | 398 | 'post_type' => 'wptests_pt', |
399 | 399 | 'post_parent' => $p1, |
400 | 400 | ) ); |
401 | | $p3 = self::$factory->post->create( array( |
| 401 | $p3 = self::factory()->post->create( array( |
402 | 402 | 'post_type' => 'wptests_pt', |
403 | 403 | 'post_parent' => $p2, |
404 | 404 | ) ); |
405 | | $p4 = self::$factory->post->create( array( |
| 405 | $p4 = self::factory()->post->create( array( |
406 | 406 | 'post_type' => 'wptests_pt', |
407 | 407 | 'post_parent' => $p1, |
408 | 408 | ) ); |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
418 | 418 | register_post_type( 'wptests_conflict', array( |
419 | 419 | 'hierarchical' => true, |
420 | 420 | ) ); |
421 | | $p1 = self::$factory->post->create( array( |
| 421 | $p1 = self::factory()->post->create( array( |
422 | 422 | 'post_type' => 'wptests_conflict', |
423 | 423 | ) ); |
424 | | $p2 = self::$factory->post->create( array( |
| 424 | $p2 = self::factory()->post->create( array( |
425 | 425 | 'post_type' => 'wptests_conflict', |
426 | 426 | 'post_parent' => $p1, |
427 | 427 | ) ); |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
429 | 429 | register_taxonomy( 'wptests_conflict', 'post', array( |
430 | 430 | 'hierarchical' => true, |
431 | 431 | ) ); |
432 | | $t1 = self::$factory->term->create( array( |
| 432 | $t1 = self::factory()->term->create( array( |
433 | 433 | 'taxonomy' => 'wptests_conflict', |
434 | 434 | ) ); |
435 | | $t2 = self::$factory->term->create( array( |
| 435 | $t2 = self::factory()->term->create( array( |
436 | 436 | 'taxonomy' => 'wptests_conflict', |
437 | 437 | 'parent' => $t1, |
438 | 438 | ) ); |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
451 | 451 | 'public' => false, |
452 | 452 | ) ); |
453 | 453 | |
454 | | $t = self::$factory->term->create_and_get( array( |
| 454 | $t = self::factory()->term->create_and_get( array( |
455 | 455 | 'taxonomy' => 'wptests_tax', |
456 | 456 | ) ); |
457 | 457 | |
458 | | $p = self::$factory->post->create(); |
| 458 | $p = self::factory()->post->create(); |
459 | 459 | wp_set_object_terms( $p, $t->slug, 'wptests_tax' ); |
460 | 460 | |
461 | 461 | $this->go_to( '/?wptests_tax=' . $t->slug ); |
… |
… |
class Tests_Taxonomy extends WP_UnitTestCase { |
471 | 471 | 'public' => false, |
472 | 472 | ) ); |
473 | 473 | |
474 | | $t = self::$factory->term->create_and_get( array( |
| 474 | $t = self::factory()->term->create_and_get( array( |
475 | 475 | 'taxonomy' => 'wptests_tax', |
476 | 476 | ) ); |
477 | 477 | |
478 | | $p = self::$factory->post->create(); |
| 478 | $p = self::factory()->post->create(); |
479 | 479 | wp_set_object_terms( $p, $t->slug, 'wptests_tax' ); |
480 | 480 | |
481 | 481 | $this->go_to( '/?taxonomy=wptests_tax&term=' . $t->slug ); |
-
diff --git tests/phpunit/tests/term.php tests/phpunit/tests/term.php
index 1c76e96..ca5b79a 100644
|
|
class Tests_Term extends WP_UnitTestCase { |
23 | 23 | 'hierarchical' => true, |
24 | 24 | ) ); |
25 | 25 | |
26 | | $parent = self::$factory->term->create( array( |
| 26 | $parent = self::factory()->term->create( array( |
27 | 27 | 'taxonomy' => 'wptests_tax', |
28 | 28 | ) ); |
29 | 29 | |
30 | | $child = self::$factory->term->create( array( |
| 30 | $child = self::factory()->term->create( array( |
31 | 31 | 'taxonomy' => 'wptests_tax', |
32 | 32 | 'parent' => $parent, |
33 | 33 | 'slug' => 'foo', |
… |
… |
class Tests_Term extends WP_UnitTestCase { |
226 | 226 | public function test_wp_set_object_terms_append_true() { |
227 | 227 | register_taxonomy( 'wptests_tax', 'post' ); |
228 | 228 | $p = self::$post_ids[0]; |
229 | | $t1 = self::$factory->term->create( array( |
| 229 | $t1 = self::factory()->term->create( array( |
230 | 230 | 'taxonomy' => 'wptests_tax', |
231 | 231 | ) ); |
232 | | $t2 = self::$factory->term->create( array( |
| 232 | $t2 = self::factory()->term->create( array( |
233 | 233 | 'taxonomy' => 'wptests_tax', |
234 | 234 | ) ); |
235 | 235 | |
… |
… |
class Tests_Term extends WP_UnitTestCase { |
247 | 247 | public function test_wp_set_object_terms_append_false() { |
248 | 248 | register_taxonomy( 'wptests_tax', 'post' ); |
249 | 249 | $p = self::$post_ids[0]; |
250 | | $t1 = self::$factory->term->create( array( |
| 250 | $t1 = self::factory()->term->create( array( |
251 | 251 | 'taxonomy' => 'wptests_tax', |
252 | 252 | ) ); |
253 | | $t2 = self::$factory->term->create( array( |
| 253 | $t2 = self::factory()->term->create( array( |
254 | 254 | 'taxonomy' => 'wptests_tax', |
255 | 255 | ) ); |
256 | 256 | |
… |
… |
class Tests_Term extends WP_UnitTestCase { |
268 | 268 | public function test_wp_set_object_terms_append_default_to_false() { |
269 | 269 | register_taxonomy( 'wptests_tax', 'post' ); |
270 | 270 | $p = self::$post_ids[0]; |
271 | | $t1 = self::$factory->term->create( array( |
| 271 | $t1 = self::factory()->term->create( array( |
272 | 272 | 'taxonomy' => 'wptests_tax', |
273 | 273 | ) ); |
274 | | $t2 = self::$factory->term->create( array( |
| 274 | $t2 = self::factory()->term->create( array( |
275 | 275 | 'taxonomy' => 'wptests_tax', |
276 | 276 | ) ); |
277 | 277 | |
… |
… |
class Tests_Term extends WP_UnitTestCase { |
364 | 364 | */ |
365 | 365 | function test_wp_add_remove_object_terms() { |
366 | 366 | $posts = self::$post_ids; |
367 | | $tags = self::$factory->tag->create_many( 5 ); |
| 367 | $tags = self::factory()->tag->create_many( 5 ); |
368 | 368 | |
369 | 369 | $tt = wp_add_object_terms( $posts[0], $tags[1], 'post_tag' ); |
370 | 370 | $this->assertEquals( 1, count( $tt ) ); |
… |
… |
class Tests_Term extends WP_UnitTestCase { |
523 | 523 | */ |
524 | 524 | function test_object_term_cache_when_term_changes() { |
525 | 525 | $post_id = self::$post_ids[0]; |
526 | | $tag_id = self::$factory->tag->create( array( |
| 526 | $tag_id = self::factory()->tag->create( array( |
527 | 527 | 'name' => 'Amaze Tag', |
528 | 528 | 'description' => 'My Amazing Tag' |
529 | 529 | ) ); |
… |
… |
class Tests_Term extends WP_UnitTestCase { |
553 | 553 | public function test_get_the_terms_should_not_cache_wp_term_objects() { |
554 | 554 | $p = self::$post_ids[0]; |
555 | 555 | register_taxonomy( 'wptests_tax', 'post' ); |
556 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 556 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
557 | 557 | wp_set_object_terms( $p, $t, 'wptests_tax' ); |
558 | 558 | |
559 | 559 | // Prime the cache. |
… |
… |
class Tests_Term extends WP_UnitTestCase { |
572 | 572 | public function test_get_the_terms_should_return_wp_term_objects_from_cache() { |
573 | 573 | $p = self::$post_ids[0]; |
574 | 574 | register_taxonomy( 'wptests_tax', 'post' ); |
575 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 575 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
576 | 576 | wp_set_object_terms( $p, $t, 'wptests_tax' ); |
577 | 577 | |
578 | 578 | // Prime the cache. |
… |
… |
class Tests_Term extends WP_UnitTestCase { |
618 | 618 | * @ticket 19205 |
619 | 619 | */ |
620 | 620 | function test_orphan_category() { |
621 | | $cat_id1 = self::$factory->category->create(); |
| 621 | $cat_id1 = self::factory()->category->create(); |
622 | 622 | |
623 | 623 | wp_delete_category( $cat_id1 ); |
624 | 624 | |
625 | | $cat_id2 = self::$factory->category->create( array( 'parent' => $cat_id1 ) ); |
| 625 | $cat_id2 = self::factory()->category->create( array( 'parent' => $cat_id1 ) ); |
626 | 626 | $this->assertWPError( $cat_id2 ); |
627 | 627 | } |
628 | 628 | } |
-
diff --git tests/phpunit/tests/term/cache.php tests/phpunit/tests/term/cache.php
index 088a7fe..828917a 100644
|
|
class Tests_Term_Cache extends WP_UnitTestCase { |
15 | 15 | */ |
16 | 16 | function test_category_children_cache() { |
17 | 17 | // Test with only one Parent => Child |
18 | | $term_id1 = self::$factory->category->create(); |
19 | | $term_id1_child = self::$factory->category->create( array( 'parent' => $term_id1 ) ); |
| 18 | $term_id1 = self::factory()->category->create(); |
| 19 | $term_id1_child = self::factory()->category->create( array( 'parent' => $term_id1 ) ); |
20 | 20 | $hierarchy = _get_term_hierarchy( 'category' ); |
21 | 21 | |
22 | 22 | $this->assertEquals( array( $term_id1 => array( $term_id1_child ) ), $hierarchy ); |
23 | 23 | |
24 | 24 | // Add another Parent => Child |
25 | | $term_id2 = self::$factory->category->create(); |
26 | | $term_id2_child = self::$factory->category->create( array( 'parent' => $term_id2 ) ); |
| 25 | $term_id2 = self::factory()->category->create(); |
| 26 | $term_id2_child = self::factory()->category->create( array( 'parent' => $term_id2 ) ); |
27 | 27 | $hierarchy = _get_term_hierarchy( 'category' ); |
28 | 28 | |
29 | 29 | $this->assertEquals( array( $term_id1 => array( $term_id1_child ), $term_id2 => array( $term_id2_child ) ), $hierarchy ); |
… |
… |
class Tests_Term_Cache extends WP_UnitTestCase { |
33 | 33 | * @ticket 22526 |
34 | 34 | */ |
35 | 35 | function test_category_name_change() { |
36 | | $term = self::$factory->category->create_and_get( array( 'name' => 'Foo' ) ); |
37 | | $post_id = self::$factory->post->create(); |
| 36 | $term = self::factory()->category->create_and_get( array( 'name' => 'Foo' ) ); |
| 37 | $post_id = self::factory()->post->create(); |
38 | 38 | wp_set_post_categories( $post_id, $term->term_id ); |
39 | 39 | |
40 | 40 | $post = get_post( $post_id ); |
… |
… |
class Tests_Term_Cache extends WP_UnitTestCase { |
98 | 98 | global $wpdb; |
99 | 99 | |
100 | 100 | register_taxonomy( 'wptests_tax', 'post' ); |
101 | | $term = self::$factory->term->create( array( |
| 101 | $term = self::factory()->term->create( array( |
102 | 102 | 'taxonomy' => 'wptests_tax', |
103 | 103 | ) ); |
104 | 104 | |
… |
… |
class Tests_Term_Cache extends WP_UnitTestCase { |
124 | 124 | global $wpdb; |
125 | 125 | |
126 | 126 | register_taxonomy( 'wptests_tax', 'post' ); |
127 | | $term = self::$factory->term->create( array( |
| 127 | $term = self::factory()->term->create( array( |
128 | 128 | 'taxonomy' => 'wptests_tax', |
129 | 129 | ) ); |
130 | 130 | |
… |
… |
class Tests_Term_Cache extends WP_UnitTestCase { |
151 | 151 | global $wpdb; |
152 | 152 | |
153 | 153 | register_taxonomy( 'wptests_tax', 'post' ); |
154 | | $term = self::$factory->term->create( array( |
| 154 | $term = self::factory()->term->create( array( |
155 | 155 | 'taxonomy' => 'wptests_tax', |
156 | 156 | ) ); |
157 | 157 | |
… |
… |
class Tests_Term_Cache extends WP_UnitTestCase { |
182 | 182 | |
183 | 183 | register_taxonomy( 'wptests_tax', 'post' ); |
184 | 184 | |
185 | | $terms = self::$factory->term->create_many( 5, array( |
| 185 | $terms = self::factory()->term->create_many( 5, array( |
186 | 186 | 'taxonomy' => 'wptests_tax', |
187 | 187 | ) ); |
188 | 188 | |
-
diff --git tests/phpunit/tests/term/categoryExists.php tests/phpunit/tests/term/categoryExists.php
index ff1e39d..a44ed1f 100644
|
|
class Tests_Term_CategoryExists extends WP_UnitTestCase { |
5 | 5 | * @ticket 30975 |
6 | 6 | */ |
7 | 7 | public function test_category_exists_should_return_only_top_level_categories_when_parent_is_0() { |
8 | | $c1 = self::$factory->category->create(); |
9 | | $c2 = self::$factory->category->create( array( |
| 8 | $c1 = self::factory()->category->create(); |
| 9 | $c2 = self::factory()->category->create( array( |
10 | 10 | 'name' => 'Foo', |
11 | 11 | 'parent' => $c1, |
12 | 12 | ) ); |
13 | | $c3 = self::$factory->category->create( array( |
| 13 | $c3 = self::factory()->category->create( array( |
14 | 14 | 'name' => 'Foo', |
15 | 15 | ) ); |
16 | 16 | |
… |
… |
class Tests_Term_CategoryExists extends WP_UnitTestCase { |
24 | 24 | */ |
25 | 25 | public function test_category_exists_should_select_oldest_matching_category_when_no_parent_is_specified_1() { |
26 | 26 | // Foo child of c1 is created first. |
27 | | $c1 = self::$factory->category->create(); |
28 | | $c2 = self::$factory->category->create( array( |
| 27 | $c1 = self::factory()->category->create(); |
| 28 | $c2 = self::factory()->category->create( array( |
29 | 29 | 'name' => 'Foo', |
30 | 30 | 'parent' => $c1, |
31 | 31 | ) ); |
32 | | $c3 = self::$factory->category->create( array( |
| 32 | $c3 = self::factory()->category->create( array( |
33 | 33 | 'name' => 'Foo', |
34 | 34 | ) ); |
35 | 35 | |
… |
… |
class Tests_Term_CategoryExists extends WP_UnitTestCase { |
43 | 43 | */ |
44 | 44 | public function test_category_exists_should_select_oldest_matching_category_when_no_parent_is_specified_2() { |
45 | 45 | // Top-level Foo is created first. |
46 | | $c1 = self::$factory->category->create(); |
47 | | $c2 = self::$factory->category->create( array( |
| 46 | $c1 = self::factory()->category->create(); |
| 47 | $c2 = self::factory()->category->create( array( |
48 | 48 | 'name' => 'Foo', |
49 | 49 | ) ); |
50 | | $c3 = self::$factory->category->create( array( |
| 50 | $c3 = self::factory()->category->create( array( |
51 | 51 | 'name' => 'Foo', |
52 | 52 | 'parent' => $c1, |
53 | 53 | ) ); |
… |
… |
class Tests_Term_CategoryExists extends WP_UnitTestCase { |
61 | 61 | * @ticket 30975 |
62 | 62 | */ |
63 | 63 | public function test_category_exists_should_respect_nonempty_parent() { |
64 | | $c1 = self::$factory->category->create(); |
65 | | $c2 = self::$factory->category->create( array( |
| 64 | $c1 = self::factory()->category->create(); |
| 65 | $c2 = self::factory()->category->create( array( |
66 | 66 | 'name' => 'Foo', |
67 | 67 | 'parent' => $c1, |
68 | 68 | ) ); |
69 | | $c3 = self::$factory->category->create( array( |
| 69 | $c3 = self::factory()->category->create( array( |
70 | 70 | 'name' => 'Foo', |
71 | 71 | ) ); |
72 | 72 | |
-
diff --git tests/phpunit/tests/term/getEditTermLink.php tests/phpunit/tests/term/getEditTermLink.php
index 3fa0ae1..b4a0ec8 100644
|
|
|
6 | 6 | class Tests_Term_GetEditTermLink extends WP_UnitTestCase { |
7 | 7 | public function setUp() { |
8 | 8 | parent::setUp(); |
9 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 9 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
10 | 10 | register_taxonomy( 'wptests_tax', 'post' ); |
11 | 11 | } |
12 | 12 | |
13 | 13 | public function test_get_edit_term_link_default() { |
14 | | $term1 = self::$factory->term->create( array( |
| 14 | $term1 = self::factory()->term->create( array( |
15 | 15 | 'taxonomy' => 'wptests_tax', |
16 | 16 | 'name' => 'foo', |
17 | 17 | ) ); |
… |
… |
class Tests_Term_GetEditTermLink extends WP_UnitTestCase { |
25 | 25 | * @ticket 32786 |
26 | 26 | */ |
27 | 27 | public function test_get_edit_term_link_invalid_id() { |
28 | | $term1 = self::$factory->term->create( array( |
| 28 | $term1 = self::factory()->term->create( array( |
29 | 29 | 'taxonomy' => 'wptests_tax', |
30 | 30 | 'name' => 'foo', |
31 | 31 | ) ); |
-
diff --git tests/phpunit/tests/term/getTerm.php tests/phpunit/tests/term/getTerm.php
index 1a6f8fd..4ad45a1 100644
|
|
class Tests_Term_GetTerm extends WP_UnitTestCase { |
24 | 24 | public function test_passing_term_object_should_skip_database_query_when_filter_property_is_empty() { |
25 | 25 | global $wpdb; |
26 | 26 | |
27 | | $term = self::$factory->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) ); |
| 27 | $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) ); |
28 | 28 | clean_term_cache( $term->term_id, 'wptests_tax' ); |
29 | 29 | |
30 | 30 | $num_queries = $wpdb->num_queries; |
… |
… |
class Tests_Term_GetTerm extends WP_UnitTestCase { |
46 | 46 | public function test_cache_should_be_populated_by_successful_fetch() { |
47 | 47 | global $wpdb; |
48 | 48 | |
49 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 49 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
50 | 50 | clean_term_cache( $t, 'wptests_tax' ); |
51 | 51 | |
52 | 52 | // Prime cache. |
… |
… |
class Tests_Term_GetTerm extends WP_UnitTestCase { |
60 | 60 | } |
61 | 61 | |
62 | 62 | public function test_output_object() { |
63 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 63 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
64 | 64 | $this->assertInternalType( 'object', get_term( $t, 'wptests_tax', OBJECT ) ); |
65 | 65 | } |
66 | 66 | |
67 | 67 | public function test_output_array_a() { |
68 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 68 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
69 | 69 | $term = get_term( $t, 'wptests_tax', ARRAY_A ); |
70 | 70 | $this->assertInternalType( 'array', $term ); |
71 | 71 | $this->assertTrue( isset( $term['term_id'] ) ); |
72 | 72 | } |
73 | 73 | |
74 | 74 | public function test_output_array_n() { |
75 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 75 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
76 | 76 | $term = get_term( $t, 'wptests_tax', ARRAY_N ); |
77 | 77 | $this->assertInternalType( 'array', $term ); |
78 | 78 | $this->assertFalse( isset( $term['term_id'] ) ); |
… |
… |
class Tests_Term_GetTerm extends WP_UnitTestCase { |
82 | 82 | } |
83 | 83 | |
84 | 84 | public function test_output_should_fall_back_to_object_for_invalid_input() { |
85 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 85 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
86 | 86 | $this->assertInternalType( 'object', get_term( $t, 'wptests_tax', 'foo' ) ); |
87 | 87 | } |
88 | 88 | |
… |
… |
class Tests_Term_GetTerm extends WP_UnitTestCase { |
92 | 92 | public function test_numeric_properties_should_be_cast_to_ints() { |
93 | 93 | global $wpdb; |
94 | 94 | |
95 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 95 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
96 | 96 | |
97 | 97 | // Get raw data from the database. |
98 | 98 | $term_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms t JOIN $wpdb->term_taxonomy tt ON ( t.term_id = tt.term_id ) WHERE t.term_id = %d", $t ) ); |
… |
… |
class Tests_Term_GetTerm extends WP_UnitTestCase { |
111 | 111 | * @ticket 34332 |
112 | 112 | */ |
113 | 113 | public function test_should_return_null_when_provided_taxonomy_does_not_match_actual_term_taxonomy() { |
114 | | $term_id = self::$factory->term->create( array( 'taxonomy' => 'post_tag' ) ); |
| 114 | $term_id = self::factory()->term->create( array( 'taxonomy' => 'post_tag' ) ); |
115 | 115 | $this->assertNull( get_term( $term_id, 'category' ) ); |
116 | 116 | } |
117 | 117 | } |
-
diff --git tests/phpunit/tests/term/getTermBy.php tests/phpunit/tests/term/getTermBy.php
index 7d66b6e..9d80ab6 100644
|
|
class Tests_Term_GetTermBy extends WP_UnitTestCase { |
28 | 28 | register_taxonomy( 'wptests_tax', 'post' ); |
29 | 29 | |
30 | 30 | $slug = 'ńaș'; |
31 | | $t = self::$factory->term->create( array( |
| 31 | $t = self::factory()->term->create( array( |
32 | 32 | 'slug' => $slug, |
33 | 33 | 'taxonomy' => 'wptests_tax', |
34 | 34 | ) ); |
… |
… |
class Tests_Term_GetTermBy extends WP_UnitTestCase { |
44 | 44 | global $wpdb; |
45 | 45 | |
46 | 46 | register_taxonomy( 'wptests_tax', 'post' ); |
47 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 47 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
48 | 48 | $term = get_term( $t, 'wptests_tax' ); |
49 | 49 | |
50 | 50 | $new_ttid = $term->term_taxonomy_id + 1; |
… |
… |
class Tests_Term_GetTermBy extends WP_UnitTestCase { |
67 | 67 | global $wpdb; |
68 | 68 | |
69 | 69 | register_taxonomy( 'wptests_tax', 'post' ); |
70 | | $t = self::$factory->term->create( array( |
| 70 | $t = self::factory()->term->create( array( |
71 | 71 | 'taxonomy' => 'wptests_tax', |
72 | 72 | 'slug' => 'foo', |
73 | 73 | ) ); |
-
diff --git tests/phpunit/tests/term/getTermField.php tests/phpunit/tests/term/getTermField.php
index c616f41..a225acc 100644
|
|
class Tests_Term_getTermField extends WP_UnitTestCase { |
17 | 17 | * @ticket 34245 |
18 | 18 | */ |
19 | 19 | public function test_get_term_field_should_not_return_error_for_empty_taxonomy() { |
20 | | $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); |
| 20 | $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); |
21 | 21 | |
22 | 22 | $found = get_term_field( 'taxonomy', $term->term_id, '' ); |
23 | 23 | $this->assertNotWPError( $found ); |
… |
… |
class Tests_Term_getTermField extends WP_UnitTestCase { |
28 | 28 | * @ticket 34245 |
29 | 29 | */ |
30 | 30 | public function test_get_term_field_supplying_a_taxonomy() { |
31 | | $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); |
| 31 | $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); |
32 | 32 | |
33 | 33 | $found = get_term_field( 'taxonomy', $term->term_id, $term->taxonomy ); |
34 | 34 | $this->assertSame( $this->taxonomy, $found ); |
… |
… |
class Tests_Term_getTermField extends WP_UnitTestCase { |
38 | 38 | * @ticket 34245 |
39 | 39 | */ |
40 | 40 | public function test_get_term_field_supplying_no_taxonomy() { |
41 | | $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); |
| 41 | $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); |
42 | 42 | |
43 | 43 | $found = get_term_field( 'taxonomy', $term->term_id ); |
44 | 44 | $this->assertSame( $this->taxonomy, $found ); |
… |
… |
class Tests_Term_getTermField extends WP_UnitTestCase { |
48 | 48 | * @ticket 34245 |
49 | 49 | */ |
50 | 50 | public function test_get_term_field_should_accept_a_WP_Term_object_or_a_term_id() { |
51 | | $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); |
| 51 | $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); |
52 | 52 | |
53 | 53 | $this->assertInstanceOf( 'WP_Term', $term ); |
54 | 54 | $this->assertSame( $term->term_id, get_term_field( 'term_id', $term ) ); |
… |
… |
class Tests_Term_getTermField extends WP_UnitTestCase { |
59 | 59 | * @ticket 34245 |
60 | 60 | */ |
61 | 61 | public function test_get_term_field_invalid_taxonomy_should_return_WP_Error() { |
62 | | $term = self::$factory->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); |
| 62 | $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); |
63 | 63 | |
64 | 64 | $found = get_term_field( 'taxonomy', $term, 'foo-taxonomy' ); |
65 | 65 | $this->assertWPError( $found ); |
-
diff --git tests/phpunit/tests/term/getTermLink.php tests/phpunit/tests/term/getTermLink.php
index bd6c987..45c31ec 100644
|
|
class Tests_Term_GetTermLink extends WP_UnitTestCase { |
12 | 12 | } |
13 | 13 | |
14 | 14 | public function test_integer_should_be_interpreted_as_term_id() { |
15 | | $t1 = self::$factory->term->create( array( |
| 15 | $t1 = self::factory()->term->create( array( |
16 | 16 | 'taxonomy' => 'wptests_tax', |
17 | 17 | 'name' => 'foo', |
18 | 18 | ) ); |
19 | | $t2 = self::$factory->term->create( array( |
| 19 | $t2 = self::factory()->term->create( array( |
20 | 20 | 'taxonomy' => 'wptests_tax', |
21 | 21 | 'slug' => $t1, |
22 | 22 | ) ); |
… |
… |
class Tests_Term_GetTermLink extends WP_UnitTestCase { |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function test_numeric_string_should_be_interpreted_as_term_slug() { |
31 | | $t1 = self::$factory->term->create( array( |
| 31 | $t1 = self::factory()->term->create( array( |
32 | 32 | 'taxonomy' => 'wptests_tax', |
33 | 33 | 'name' => 'foo', |
34 | 34 | ) ); |
35 | | $t2 = self::$factory->term->create( array( |
| 35 | $t2 = self::factory()->term->create( array( |
36 | 36 | 'taxonomy' => 'wptests_tax', |
37 | 37 | 'slug' => $t1, |
38 | 38 | ) ); |
… |
… |
class Tests_Term_GetTermLink extends WP_UnitTestCase { |
49 | 49 | } |
50 | 50 | |
51 | 51 | public function test_category_should_use_cat_query_var_with_term_id() { |
52 | | $c = self::$factory->category->create(); |
| 52 | $c = self::factory()->category->create(); |
53 | 53 | |
54 | 54 | $actual = get_term_link( $c, 'category' ); |
55 | 55 | $this->assertContains( 'cat=' . $c, $actual ); |
… |
… |
class Tests_Term_GetTermLink extends WP_UnitTestCase { |
60 | 60 | 'query_var' => 'foo', |
61 | 61 | ) ); |
62 | 62 | |
63 | | $t = self::$factory->term->create( array( |
| 63 | $t = self::factory()->term->create( array( |
64 | 64 | 'taxonomy' => 'wptests_tax2', |
65 | 65 | 'slug' => 'bar', |
66 | 66 | ) ); |
… |
… |
class Tests_Term_GetTermLink extends WP_UnitTestCase { |
74 | 74 | 'query_var' => false, |
75 | 75 | ) ); |
76 | 76 | |
77 | | $t = self::$factory->term->create( array( |
| 77 | $t = self::factory()->term->create( array( |
78 | 78 | 'taxonomy' => 'wptests_tax2', |
79 | 79 | 'slug' => 'bar', |
80 | 80 | ) ); |
… |
… |
class Tests_Term_GetTermLink extends WP_UnitTestCase { |
97 | 97 | |
98 | 98 | flush_rewrite_rules(); |
99 | 99 | |
100 | | $t1 = self::$factory->term->create( array( |
| 100 | $t1 = self::factory()->term->create( array( |
101 | 101 | 'taxonomy' => 'wptests_tax2', |
102 | 102 | 'slug' => 'term1', |
103 | 103 | ) ); |
104 | 104 | |
105 | | $t2 = self::$factory->term->create( array( |
| 105 | $t2 = self::factory()->term->create( array( |
106 | 106 | 'taxonomy' => 'wptests_tax2', |
107 | 107 | 'slug' => 'term2', |
108 | 108 | 'parent' => $t1, |
… |
… |
class Tests_Term_GetTermLink extends WP_UnitTestCase { |
126 | 126 | |
127 | 127 | flush_rewrite_rules(); |
128 | 128 | |
129 | | $t1 = self::$factory->term->create( array( |
| 129 | $t1 = self::factory()->term->create( array( |
130 | 130 | 'taxonomy' => 'wptests_tax2', |
131 | 131 | 'slug' => 'term1', |
132 | 132 | ) ); |
133 | 133 | |
134 | | $t2 = self::$factory->term->create( array( |
| 134 | $t2 = self::factory()->term->create( array( |
135 | 135 | 'taxonomy' => 'wptests_tax2', |
136 | 136 | 'slug' => 'term2', |
137 | 137 | 'parent' => $t1, |
-
diff --git tests/phpunit/tests/term/getTerms.php tests/phpunit/tests/term/getTerms.php
index bdc3146..f3e9316 100644
|
|
class Tests_Term_getTerms extends WP_UnitTestCase { |
105 | 105 | * @ticket 23506 |
106 | 106 | */ |
107 | 107 | function test_get_terms_should_allow_arbitrary_indexed_taxonomies_array() { |
108 | | $term_id = self::$factory->tag->create(); |
| 108 | $term_id = self::factory()->tag->create(); |
109 | 109 | $terms = get_terms( array( '111' => 'post_tag' ), array( 'hide_empty' => false ) ); |
110 | 110 | $this->assertEquals( $term_id, reset( $terms )->term_id ); |
111 | 111 | } |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
114 | 114 | * @ticket 13661 |
115 | 115 | */ |
116 | 116 | function test_get_terms_fields() { |
117 | | $term_id1 = self::$factory->tag->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) ); |
118 | | $term_id2 = self::$factory->tag->create( array( 'slug' => 'hoo', 'name' => 'HOO!', 'parent' => $term_id1 ) ); |
| 117 | $term_id1 = self::factory()->tag->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) ); |
| 118 | $term_id2 = self::factory()->tag->create( array( 'slug' => 'hoo', 'name' => 'HOO!', 'parent' => $term_id1 ) ); |
119 | 119 | |
120 | 120 | $terms_id_parent = get_terms( 'post_tag', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) ); |
121 | 121 | $this->assertEquals( array( |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
148 | 148 | function test_get_terms_include_exclude() { |
149 | 149 | global $wpdb; |
150 | 150 | |
151 | | $term_id1 = self::$factory->tag->create(); |
152 | | $term_id2 = self::$factory->tag->create(); |
| 151 | $term_id1 = self::factory()->tag->create(); |
| 152 | $term_id2 = self::factory()->tag->create(); |
153 | 153 | $inc_terms = get_terms( 'post_tag', array( |
154 | 154 | 'include' => array( $term_id1, $term_id2 ), |
155 | 155 | 'hide_empty' => false |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
179 | 179 | public function test_exclude_with_hierarchical_true_for_non_hierarchical_taxonomy() { |
180 | 180 | register_taxonomy( 'wptests_tax', 'post' ); |
181 | 181 | |
182 | | $terms = self::$factory->term->create_many( 2, array( |
| 182 | $terms = self::factory()->term->create_many( 2, array( |
183 | 183 | 'taxonomy' => 'wptests_tax', |
184 | 184 | ) ); |
185 | 185 | |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
202 | 202 | |
203 | 203 | $term_id_uncategorized = get_option( 'default_category' ); |
204 | 204 | |
205 | | $term_id1 = self::$factory->category->create(); |
206 | | $term_id11 = self::$factory->category->create( array( 'parent' => $term_id1 ) ); |
207 | | $term_id2 = self::$factory->category->create(); |
208 | | $term_id22 = self::$factory->category->create( array( 'parent' => $term_id2 ) ); |
| 205 | $term_id1 = self::factory()->category->create(); |
| 206 | $term_id11 = self::factory()->category->create( array( 'parent' => $term_id1 ) ); |
| 207 | $term_id2 = self::factory()->category->create(); |
| 208 | $term_id22 = self::factory()->category->create( array( 'parent' => $term_id2 ) ); |
209 | 209 | |
210 | 210 | $terms = get_terms( 'category', array( |
211 | 211 | 'exclude' => $term_id_uncategorized, |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
228 | 228 | * @ticket 13992 |
229 | 229 | */ |
230 | 230 | function test_get_terms_search() { |
231 | | $term_id1 = self::$factory->tag->create( array( 'slug' => 'burrito' ) ); |
232 | | $term_id2 = self::$factory->tag->create( array( 'name' => 'Wilbur' ) ); |
| 231 | $term_id1 = self::factory()->tag->create( array( 'slug' => 'burrito' ) ); |
| 232 | $term_id2 = self::factory()->tag->create( array( 'name' => 'Wilbur' ) ); |
233 | 233 | |
234 | 234 | $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'search' => 'bur', 'fields' => 'ids' ) ); |
235 | 235 | $this->assertEqualSets( array( $term_id1, $term_id2 ), $terms ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
239 | 239 | * @ticket 8214 |
240 | 240 | */ |
241 | 241 | function test_get_terms_like() { |
242 | | $term_id1 = self::$factory->tag->create( array( 'name' => 'burrito', 'description' => 'This is a burrito.' ) ); |
243 | | $term_id2 = self::$factory->tag->create( array( 'name' => 'taco', 'description' => 'Burning man.' ) ); |
| 242 | $term_id1 = self::factory()->tag->create( array( 'name' => 'burrito', 'description' => 'This is a burrito.' ) ); |
| 243 | $term_id2 = self::factory()->tag->create( array( 'name' => 'taco', 'description' => 'Burning man.' ) ); |
244 | 244 | |
245 | 245 | $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'name__like' => 'bur', 'fields' => 'ids' ) ); |
246 | 246 | $this->assertEqualSets( array( $term_id1 ), $terms ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
274 | 274 | $tax = 'food'; |
275 | 275 | register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) ); |
276 | 276 | |
277 | | $cheese = self::$factory->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) ); |
| 277 | $cheese = self::factory()->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) ); |
278 | 278 | |
279 | | $cheddar = self::$factory->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) ); |
| 279 | $cheddar = self::factory()->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) ); |
280 | 280 | |
281 | | $post_ids = self::$factory->post->create_many( 2 ); |
| 281 | $post_ids = self::factory()->post->create_many( 2 ); |
282 | 282 | foreach ( $post_ids as $id ) { |
283 | 283 | wp_set_post_terms( $id, $cheddar, $tax ); |
284 | 284 | } |
285 | 285 | $term = get_term( $cheddar, $tax ); |
286 | 286 | $this->assertEquals( 2, $term->count ); |
287 | 287 | |
288 | | $brie = self::$factory->term->create( array( 'name' => 'Brie', 'parent' => $cheese, 'taxonomy' => $tax ) ); |
289 | | $post_id = self::$factory->post->create(); |
| 288 | $brie = self::factory()->term->create( array( 'name' => 'Brie', 'parent' => $cheese, 'taxonomy' => $tax ) ); |
| 289 | $post_id = self::factory()->post->create(); |
290 | 290 | wp_set_post_terms( $post_id, $brie, $tax ); |
291 | 291 | $term = get_term( $brie, $tax ); |
292 | 292 | $this->assertEquals( 1, $term->count ); |
293 | 293 | |
294 | | $crackers = self::$factory->term->create( array( 'name' => 'Crackers', 'taxonomy' => $tax ) ); |
| 294 | $crackers = self::factory()->term->create( array( 'name' => 'Crackers', 'taxonomy' => $tax ) ); |
295 | 295 | |
296 | | $butter = self::$factory->term->create( array( 'name' => 'Butter', 'parent' => $crackers, 'taxonomy' => $tax ) ); |
297 | | $post_ids = self::$factory->post->create_many( 1 ); |
| 296 | $butter = self::factory()->term->create( array( 'name' => 'Butter', 'parent' => $crackers, 'taxonomy' => $tax ) ); |
| 297 | $post_ids = self::factory()->post->create_many( 1 ); |
298 | 298 | foreach ( $post_ids as $id ) { |
299 | 299 | wp_set_post_terms( $id, $butter, $tax ); |
300 | 300 | } |
301 | 301 | $term = get_term( $butter, $tax ); |
302 | 302 | $this->assertEquals( 1, $term->count ); |
303 | 303 | |
304 | | $multigrain = self::$factory->term->create( array( 'name' => 'Multigrain', 'parent' => $crackers, 'taxonomy' => $tax ) ); |
305 | | $post_ids = self::$factory->post->create_many( 1 ); |
| 304 | $multigrain = self::factory()->term->create( array( 'name' => 'Multigrain', 'parent' => $crackers, 'taxonomy' => $tax ) ); |
| 305 | $post_ids = self::factory()->post->create_many( 1 ); |
306 | 306 | foreach ( $post_ids as $id ) { |
307 | 307 | wp_set_post_terms( $id, $multigrain, $tax ); |
308 | 308 | } |
309 | 309 | $term = get_term( $multigrain, $tax ); |
310 | 310 | $this->assertEquals( 1, $term->count ); |
311 | 311 | |
312 | | $fruit = self::$factory->term->create( array( 'name' => 'Fruit', 'taxonomy' => $tax ) ); |
313 | | $cranberries = self::$factory->term->create( array( 'name' => 'Cranberries', 'parent' => $fruit, 'taxonomy' => $tax ) ); |
| 312 | $fruit = self::factory()->term->create( array( 'name' => 'Fruit', 'taxonomy' => $tax ) ); |
| 313 | $cranberries = self::factory()->term->create( array( 'name' => 'Cranberries', 'parent' => $fruit, 'taxonomy' => $tax ) ); |
314 | 314 | |
315 | 315 | $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) ); |
316 | 316 | $this->assertEquals( 2, count( $terms ) ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
324 | 324 | $tax = 'food'; |
325 | 325 | register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) ); |
326 | 326 | |
327 | | $cheese = self::$factory->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) ); |
328 | | $cheddar = self::$factory->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) ); |
329 | | $spread = self::$factory->term->create( array( 'name' => 'Spread', 'parent' => $cheddar, 'taxonomy' => $tax ) ); |
330 | | $post_id = self::$factory->post->create(); |
| 327 | $cheese = self::factory()->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) ); |
| 328 | $cheddar = self::factory()->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) ); |
| 329 | $spread = self::factory()->term->create( array( 'name' => 'Spread', 'parent' => $cheddar, 'taxonomy' => $tax ) ); |
| 330 | $post_id = self::factory()->post->create(); |
331 | 331 | wp_set_post_terms( $post_id, $spread, $tax ); |
332 | 332 | $term = get_term( $spread, $tax ); |
333 | 333 | $this->assertEquals( 1, $term->count ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
348 | 348 | $parent = 0; |
349 | 349 | $t = array(); |
350 | 350 | foreach ( range( 1, 7 ) as $depth ) { |
351 | | $t[$depth] = self::$factory->term->create( array( 'name' => 'term' . $depth, 'taxonomy' => $tax, 'parent' => $parent ) ); |
| 351 | $t[$depth] = self::factory()->term->create( array( 'name' => 'term' . $depth, 'taxonomy' => $tax, 'parent' => $parent ) ); |
352 | 352 | $parent = $t[$depth]; |
353 | 353 | } |
354 | | $post_id = self::$factory->post->create(); |
| 354 | $post_id = self::factory()->post->create(); |
355 | 355 | wp_set_post_terms( $post_id, $t[7], $tax ); |
356 | 356 | $term = get_term( $t[7], $tax ); |
357 | 357 | $this->assertEquals( 1, $term->count ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
367 | 367 | * @ticket 27123 |
368 | 368 | */ |
369 | 369 | function test_get_terms_child_of() { |
370 | | $parent = self::$factory->category->create(); |
371 | | $child = self::$factory->category->create( array( 'parent' => $parent ) ); |
| 370 | $parent = self::factory()->category->create(); |
| 371 | $child = self::factory()->category->create( array( 'parent' => $parent ) ); |
372 | 372 | |
373 | 373 | $terms = get_terms( 'category', array( 'child_of' => $parent, 'hide_empty' => false ) ); |
374 | 374 | $this->assertEquals( 1, count( $terms ) ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
382 | 382 | |
383 | 383 | register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) ); |
384 | 384 | |
385 | | $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
| 385 | $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
386 | 386 | |
387 | 387 | $num_queries = $wpdb->num_queries; |
388 | 388 | |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
402 | 402 | register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) ); |
403 | 403 | register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); |
404 | 404 | |
405 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
406 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
407 | | $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); |
| 405 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| 406 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| 407 | $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); |
408 | 408 | |
409 | 409 | $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array( |
410 | 410 | 'fields' => 'ids', |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
440 | 440 | public function test__get_term_children_handles_cycles() { |
441 | 441 | remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 ); |
442 | 442 | |
443 | | $c1 = self::$factory->category->create(); |
444 | | $c2 = self::$factory->category->create( array( 'parent' => $c1 ) ); |
445 | | $c3 = self::$factory->category->create( array( 'parent' => $c2 ) ); |
| 443 | $c1 = self::factory()->category->create(); |
| 444 | $c2 = self::factory()->category->create( array( 'parent' => $c1 ) ); |
| 445 | $c3 = self::factory()->category->create( array( 'parent' => $c2 ) ); |
446 | 446 | wp_update_term( $c1, 'category', array( 'parent' => $c3 ) ); |
447 | 447 | |
448 | 448 | add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
459 | 459 | public function test__get_term_children_handles_cycles_when_terms_argument_contains_objects() { |
460 | 460 | remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 ); |
461 | 461 | |
462 | | $c1 = self::$factory->category->create_and_get(); |
463 | | $c2 = self::$factory->category->create_and_get( array( 'parent' => $c1->term_id ) ); |
464 | | $c3 = self::$factory->category->create_and_get( array( 'parent' => $c2->term_id ) ); |
| 462 | $c1 = self::factory()->category->create_and_get(); |
| 463 | $c2 = self::factory()->category->create_and_get( array( 'parent' => $c1->term_id ) ); |
| 464 | $c3 = self::factory()->category->create_and_get( array( 'parent' => $c2->term_id ) ); |
465 | 465 | wp_update_term( $c1->term_id, 'category', array( 'parent' => $c3->term_id ) ); |
466 | 466 | |
467 | 467 | add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
472 | 472 | } |
473 | 473 | |
474 | 474 | public function test_get_terms_by_slug() { |
475 | | $t1 = self::$factory->tag->create( array( 'slug' => 'foo' ) ); |
476 | | $t2 = self::$factory->tag->create( array( 'slug' => 'bar' ) ); |
| 475 | $t1 = self::factory()->tag->create( array( 'slug' => 'foo' ) ); |
| 476 | $t2 = self::factory()->tag->create( array( 'slug' => 'bar' ) ); |
477 | 477 | |
478 | 478 | $found = get_terms( 'post_tag', array( |
479 | 479 | 'hide_empty' => false, |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
488 | 488 | * @ticket 23636 |
489 | 489 | */ |
490 | 490 | public function test_get_terms_by_multiple_slugs() { |
491 | | $t1 = self::$factory->tag->create( array( 'slug' => 'foo' ) ); |
492 | | $t2 = self::$factory->tag->create( array( 'slug' => 'bar' ) ); |
493 | | $t3 = self::$factory->tag->create( array( 'slug' => 'barry' ) ); |
| 491 | $t1 = self::factory()->tag->create( array( 'slug' => 'foo' ) ); |
| 492 | $t2 = self::factory()->tag->create( array( 'slug' => 'bar' ) ); |
| 493 | $t3 = self::factory()->tag->create( array( 'slug' => 'barry' ) ); |
494 | 494 | |
495 | 495 | $found = get_terms( 'post_tag', array( |
496 | 496 | 'hide_empty' => false, |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
505 | 505 | * @ticket 30611 |
506 | 506 | */ |
507 | 507 | public function test_get_terms_by_name() { |
508 | | $t1 = self::$factory->tag->create( array( 'name' => 'Foo' ) ); |
509 | | $t2 = self::$factory->tag->create( array( 'name' => 'Bar' ) ); |
| 508 | $t1 = self::factory()->tag->create( array( 'name' => 'Foo' ) ); |
| 509 | $t2 = self::factory()->tag->create( array( 'name' => 'Bar' ) ); |
510 | 510 | |
511 | 511 | $found = get_terms( 'post_tag', array( |
512 | 512 | 'hide_empty' => false, |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
521 | 521 | * @ticket 30611 |
522 | 522 | */ |
523 | 523 | public function test_get_terms_by_multiple_names() { |
524 | | $t1 = self::$factory->tag->create( array( 'name' => 'Foo' ) ); |
525 | | $t2 = self::$factory->tag->create( array( 'name' => 'Bar' ) ); |
526 | | $t3 = self::$factory->tag->create( array( 'name' => 'Barry' ) ); |
| 524 | $t1 = self::factory()->tag->create( array( 'name' => 'Foo' ) ); |
| 525 | $t2 = self::factory()->tag->create( array( 'name' => 'Bar' ) ); |
| 526 | $t3 = self::factory()->tag->create( array( 'name' => 'Barry' ) ); |
527 | 527 | |
528 | 528 | $found = get_terms( 'post_tag', array( |
529 | 529 | 'hide_empty' => false, |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
540 | 540 | public function test_name_should_match_encoded_html_entities() { |
541 | 541 | register_taxonomy( 'wptests_tax', 'post' ); |
542 | 542 | |
543 | | $t = self::$factory->term->create( array( |
| 543 | $t = self::factory()->term->create( array( |
544 | 544 | 'taxonomy' => 'wptests_tax', |
545 | 545 | 'name' => 'Foo & Bar', |
546 | 546 | 'slug' => 'foo-and-bar', |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
569 | 569 | // If run on a flat hierarchy it should return everything. |
570 | 570 | $flat_tax = 'countries'; |
571 | 571 | register_taxonomy( $flat_tax, 'post', array( 'hierarchical' => false ) ); |
572 | | $australia = self::$factory->term->create( array( 'name' => 'Australia', 'taxonomy' => $flat_tax ) ); |
573 | | $china = self::$factory->term->create( array( 'name' => 'China', 'taxonomy' => $flat_tax ) ); |
574 | | $tanzania = self::$factory->term->create( array( 'name' => 'Tanzania', 'taxonomy' => $flat_tax ) ); |
| 572 | $australia = self::factory()->term->create( array( 'name' => 'Australia', 'taxonomy' => $flat_tax ) ); |
| 573 | $china = self::factory()->term->create( array( 'name' => 'China', 'taxonomy' => $flat_tax ) ); |
| 574 | $tanzania = self::factory()->term->create( array( 'name' => 'Tanzania', 'taxonomy' => $flat_tax ) ); |
575 | 575 | |
576 | 576 | $terms = get_terms( $flat_tax, array( |
577 | 577 | 'childless' => true, |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
601 | 601 | PEI |
602 | 602 | */ |
603 | 603 | // Level 1 |
604 | | $canada = self::$factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) ); |
| 604 | $canada = self::factory()->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) ); |
605 | 605 | |
606 | 606 | // Level 2 |
607 | | $ontario = self::$factory->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) ); |
608 | | $quebec = self::$factory->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) ); |
609 | | $pei = self::$factory->term->create( array( 'name' => 'PEI', 'parent' => $canada, 'taxonomy' => $tax ) ); |
| 607 | $ontario = self::factory()->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) ); |
| 608 | $quebec = self::factory()->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) ); |
| 609 | $pei = self::factory()->term->create( array( 'name' => 'PEI', 'parent' => $canada, 'taxonomy' => $tax ) ); |
610 | 610 | |
611 | 611 | // Level 3 |
612 | | $toronto = self::$factory->term->create( array( 'name' => 'Toronto', 'parent' => $ontario, 'taxonomy' => $tax ) ); |
613 | | $ottawa = self::$factory->term->create( array( 'name' => 'Ottawa', 'parent' => $ontario, 'taxonomy' => $tax ) ); |
614 | | $montreal = self::$factory->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) ); |
| 612 | $toronto = self::factory()->term->create( array( 'name' => 'Toronto', 'parent' => $ontario, 'taxonomy' => $tax ) ); |
| 613 | $ottawa = self::factory()->term->create( array( 'name' => 'Ottawa', 'parent' => $ontario, 'taxonomy' => $tax ) ); |
| 614 | $montreal = self::factory()->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) ); |
615 | 615 | |
616 | 616 | // Level 4 |
617 | | $nepean = self::$factory->term->create( array( 'name' => 'Nepean', 'parent' => $ottawa, 'taxonomy' => $tax ) ); |
| 617 | $nepean = self::factory()->term->create( array( 'name' => 'Nepean', 'parent' => $ottawa, 'taxonomy' => $tax ) ); |
618 | 618 | |
619 | 619 | $terms = get_terms( $tax, array( |
620 | 620 | 'childless' => true, |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
633 | 633 | register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) ); |
634 | 634 | |
635 | 635 | // Level 1 |
636 | | $canada = self::$factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) ); |
| 636 | $canada = self::factory()->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) ); |
637 | 637 | |
638 | 638 | // Level 2 |
639 | | $ontario = self::$factory->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) ); |
640 | | $quebec = self::$factory->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) ); |
| 639 | $ontario = self::factory()->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) ); |
| 640 | $quebec = self::factory()->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) ); |
641 | 641 | |
642 | 642 | // Level 3 |
643 | | $laval = self::$factory->term->create( array( 'name' => 'Laval', 'parent' => $quebec, 'taxonomy' => $tax ) ); |
644 | | $montreal = self::$factory->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) ); |
| 643 | $laval = self::factory()->term->create( array( 'name' => 'Laval', 'parent' => $quebec, 'taxonomy' => $tax ) ); |
| 644 | $montreal = self::factory()->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) ); |
645 | 645 | |
646 | 646 | // Level 4 |
647 | | $dorval = self::$factory->term->create( array( 'name' => 'Dorval', 'parent' => $montreal, 'taxonomy' => $tax ) ); |
| 647 | $dorval = self::factory()->term->create( array( 'name' => 'Dorval', 'parent' => $montreal, 'taxonomy' => $tax ) ); |
648 | 648 | |
649 | 649 | $terms = get_terms( $tax, array( |
650 | 650 | 'childless' => true, |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
663 | 663 | register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) ); |
664 | 664 | register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); |
665 | 665 | |
666 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
667 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) ); |
668 | | $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
669 | | $t4 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t3 ) ); |
| 666 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| 667 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) ); |
| 668 | $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| 669 | $t4 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t3 ) ); |
670 | 670 | |
671 | 671 | $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array( |
672 | 672 | 'fields' => 'ids', |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1098 | 1098 | register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) ); |
1099 | 1099 | register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); |
1100 | 1100 | |
1101 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
1102 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) ); |
1103 | | $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t2 ) ); |
| 1101 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| 1102 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) ); |
| 1103 | $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t2 ) ); |
1104 | 1104 | |
1105 | | $t4 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
1106 | | $t5 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t4 ) ); |
1107 | | $t6 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t5 ) ); |
| 1105 | $t4 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| 1106 | $t5 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t4 ) ); |
| 1107 | $t6 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t5 ) ); |
1108 | 1108 | |
1109 | | $p = self::$factory->post->create(); |
| 1109 | $p = self::factory()->post->create(); |
1110 | 1110 | |
1111 | 1111 | wp_set_object_terms( $p, $t3, 'wptests_tax1' ); |
1112 | 1112 | wp_set_object_terms( $p, $t6, 'wptests_tax2' ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1140 | 1140 | $tax = 'wptests_tax'; |
1141 | 1141 | register_taxonomy( $tax, 'post' ); |
1142 | 1142 | |
1143 | | $t1 = self::$factory->term->create( array( 'taxonomy' => $tax ) ); |
1144 | | $t2 = self::$factory->term->create( array( 'taxonomy' => $tax ) ); |
1145 | | $t3 = self::$factory->term->create( array( 'taxonomy' => $tax ) ); |
1146 | | $t4 = self::$factory->term->create( array( 'taxonomy' => $tax ) ); |
| 1143 | $t1 = self::factory()->term->create( array( 'taxonomy' => $tax ) ); |
| 1144 | $t2 = self::factory()->term->create( array( 'taxonomy' => $tax ) ); |
| 1145 | $t3 = self::factory()->term->create( array( 'taxonomy' => $tax ) ); |
| 1146 | $t4 = self::factory()->term->create( array( 'taxonomy' => $tax ) ); |
1147 | 1147 | |
1148 | 1148 | $found = get_terms( $tax, array( |
1149 | 1149 | 'fields' => 'ids', |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1164 | 1164 | $tax = 'wptests_tax'; |
1165 | 1165 | register_taxonomy( $tax, 'post' ); |
1166 | 1166 | |
1167 | | $t1 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'fff' ) ); |
1168 | | $t2 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'aaa' ) ); |
1169 | | $t3 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'zzz' ) ); |
1170 | | $t4 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'jjj' ) ); |
| 1167 | $t1 = self::factory()->term->create( array( 'taxonomy' => $tax, 'description' => 'fff' ) ); |
| 1168 | $t2 = self::factory()->term->create( array( 'taxonomy' => $tax, 'description' => 'aaa' ) ); |
| 1169 | $t3 = self::factory()->term->create( array( 'taxonomy' => $tax, 'description' => 'zzz' ) ); |
| 1170 | $t4 = self::factory()->term->create( array( 'taxonomy' => $tax, 'description' => 'jjj' ) ); |
1171 | 1171 | |
1172 | 1172 | $found = get_terms( $tax, array( |
1173 | 1173 | 'fields' => 'ids', |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1185 | 1185 | */ |
1186 | 1186 | public function test_orderby_term_id() { |
1187 | 1187 | register_taxonomy( 'wptests_tax', 'post' ); |
1188 | | $t1 = self::$factory->term->create( array( |
| 1188 | $t1 = self::factory()->term->create( array( |
1189 | 1189 | 'taxonomy' => 'wptests_tax', |
1190 | 1190 | 'name' => 'AAA', |
1191 | 1191 | ) ); |
1192 | | $t2 = self::$factory->term->create( array( |
| 1192 | $t2 = self::factory()->term->create( array( |
1193 | 1193 | 'taxonomy' => 'wptests_tax', |
1194 | 1194 | 'name' => 'ZZZ', |
1195 | 1195 | ) ); |
1196 | | $t3 = self::$factory->term->create( array( |
| 1196 | $t3 = self::factory()->term->create( array( |
1197 | 1197 | 'taxonomy' => 'wptests_tax', |
1198 | 1198 | 'name' => 'JJJ', |
1199 | 1199 | ) ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1243 | 1243 | |
1244 | 1244 | public function test_hierarchical_false_with_child_of_and_direct_child() { |
1245 | 1245 | $initial_terms = $this->create_hierarchical_terms(); |
1246 | | $post_id = self::$factory->post->create(); |
| 1246 | $post_id = self::factory()->post->create(); |
1247 | 1247 | wp_set_post_terms( |
1248 | 1248 | $post_id, |
1249 | 1249 | array( $initial_terms['seven_term']['term_id'] ), |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1323 | 1323 | |
1324 | 1324 | register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) ); |
1325 | 1325 | |
1326 | | $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
| 1326 | $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
1327 | 1327 | |
1328 | 1328 | $num_queries = $wpdb->num_queries; |
1329 | 1329 | |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1343 | 1343 | register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => true ) ); |
1344 | 1344 | register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); |
1345 | 1345 | |
1346 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
1347 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
1348 | | $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); |
| 1346 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| 1347 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| 1348 | $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); |
1349 | 1349 | |
1350 | 1350 | $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array( |
1351 | 1351 | 'fields' => 'ids', |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1395 | 1395 | public function test_pad_counts() { |
1396 | 1396 | register_taxonomy( 'wptests_tax_1', 'post', array( 'hierarchical' => true ) ); |
1397 | 1397 | |
1398 | | $posts = self::$factory->post->create_many( 3 ); |
| 1398 | $posts = self::factory()->post->create_many( 3 ); |
1399 | 1399 | |
1400 | | $t1 = self::$factory->term->create( array( |
| 1400 | $t1 = self::factory()->term->create( array( |
1401 | 1401 | 'taxonomy' => 'wptests_tax_1', |
1402 | 1402 | ) ); |
1403 | | $t2 = self::$factory->term->create( array( |
| 1403 | $t2 = self::factory()->term->create( array( |
1404 | 1404 | 'taxonomy' => 'wptests_tax_1', |
1405 | 1405 | 'parent' => $t1, |
1406 | 1406 | ) ); |
1407 | | $t3 = self::$factory->term->create( array( |
| 1407 | $t3 = self::factory()->term->create( array( |
1408 | 1408 | 'taxonomy' => 'wptests_tax_1', |
1409 | 1409 | 'parent' => $t2, |
1410 | 1410 | ) ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1436 | 1436 | public function test_pad_counts_should_not_recurse_infinitely_when_term_hierarchy_has_a_loop() { |
1437 | 1437 | remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 ); |
1438 | 1438 | |
1439 | | $c1 = self::$factory->category->create(); |
1440 | | $c2 = self::$factory->category->create( array( 'parent' => $c1 ) ); |
1441 | | $c3 = self::$factory->category->create( array( 'parent' => $c2 ) ); |
| 1439 | $c1 = self::factory()->category->create(); |
| 1440 | $c2 = self::factory()->category->create( array( 'parent' => $c1 ) ); |
| 1441 | $c3 = self::factory()->category->create( array( 'parent' => $c2 ) ); |
1442 | 1442 | wp_update_term( $c1, 'category', array( 'parent' => $c3 ) ); |
1443 | 1443 | |
1444 | 1444 | add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); |
1445 | 1445 | |
1446 | | $posts = self::$factory->post->create_many( 3 ); |
| 1446 | $posts = self::factory()->post->create_many( 3 ); |
1447 | 1447 | wp_set_post_terms( $posts[0], $c1, 'category' ); |
1448 | 1448 | wp_set_post_terms( $posts[1], $c2, 'category' ); |
1449 | 1449 | wp_set_post_terms( $posts[2], $c3, 'category' ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1466 | 1466 | register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => false ) ); |
1467 | 1467 | register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); |
1468 | 1468 | |
1469 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
1470 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
1471 | | $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); |
| 1469 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| 1470 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| 1471 | $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); |
1472 | 1472 | |
1473 | | $posts = self::$factory->post->create_many( 3 ); |
| 1473 | $posts = self::factory()->post->create_many( 3 ); |
1474 | 1474 | wp_set_object_terms( $posts[0], $t1, 'wptests_tax1' ); |
1475 | 1475 | wp_set_object_terms( $posts[1], $t2, 'wptests_tax2' ); |
1476 | 1476 | wp_set_object_terms( $posts[2], $t3, 'wptests_tax2' ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1499 | 1499 | global $wpdb; |
1500 | 1500 | |
1501 | 1501 | register_taxonomy( 'wptests_tax', 'post' ); |
1502 | | $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
| 1502 | $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
1503 | 1503 | add_term_meta( $terms[0], 'foo', 'bar' ); |
1504 | 1504 | add_term_meta( $terms[1], 'foo', 'bar' ); |
1505 | 1505 | add_term_meta( $terms[2], 'foo', 'bar' ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1525 | 1525 | global $wpdb; |
1526 | 1526 | |
1527 | 1527 | register_taxonomy( 'wptests_tax', 'post' ); |
1528 | | $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
| 1528 | $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
1529 | 1529 | add_term_meta( $terms[0], 'foo', 'bar' ); |
1530 | 1530 | add_term_meta( $terms[1], 'foo', 'bar' ); |
1531 | 1531 | add_term_meta( $terms[2], 'foo', 'bar' ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1550 | 1550 | */ |
1551 | 1551 | public function test_meta_query() { |
1552 | 1552 | register_taxonomy( 'wptests_tax', 'post' ); |
1553 | | $terms = self::$factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) ); |
| 1553 | $terms = self::factory()->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) ); |
1554 | 1554 | add_term_meta( $terms[0], 'foo', 'bar' ); |
1555 | 1555 | add_term_meta( $terms[1], 'foo', 'bar' ); |
1556 | 1556 | add_term_meta( $terms[2], 'foo', 'baz' ); |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1575 | 1575 | */ |
1576 | 1576 | public function test_should_return_wp_term_objects() { |
1577 | 1577 | register_taxonomy( 'wptests_tax', 'post' ); |
1578 | | $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| 1578 | $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
1579 | 1579 | |
1580 | 1580 | $found = get_terms( 'wptests_tax', array( |
1581 | 1581 | 'hide_empty' => false, |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1597 | 1597 | global $wpdb; |
1598 | 1598 | |
1599 | 1599 | register_taxonomy( 'wptests_tax', 'post' ); |
1600 | | $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| 1600 | $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
1601 | 1601 | |
1602 | 1602 | // Prime the cache. |
1603 | 1603 | get_terms( 'wptests_tax', array( |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1628 | 1628 | global $wpdb; |
1629 | 1629 | |
1630 | 1630 | register_taxonomy( 'wptests_tax', 'post' ); |
1631 | | $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| 1631 | $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
1632 | 1632 | |
1633 | 1633 | $found = get_terms( 'wptests_tax', array( |
1634 | 1634 | 'hide_empty' => false, |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1644 | 1644 | protected function create_hierarchical_terms_and_posts() { |
1645 | 1645 | $terms = array(); |
1646 | 1646 | |
1647 | | $terms['parent1'] = self::$factory->term->create( array( 'slug' => 'parent-1', 'name' => 'Parent 1', 'taxonomy' => 'hierarchical_fields' ) ); |
1648 | | $terms['parent2'] = self::$factory->term->create( array( 'slug' => 'parent-2', 'name' => 'Parent 2', 'taxonomy' => 'hierarchical_fields' ) ); |
1649 | | $terms['child1'] = self::$factory->term->create( array( 'slug' => 'child-1', 'name' => 'Child 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) ); |
1650 | | $terms['child2'] = self::$factory->term->create( array( 'slug' => 'child-2', 'name' => 'Child 2', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) ); |
1651 | | $terms['grandchild1'] = self::$factory->term->create( array( 'slug' => 'grandchild-1', 'name' => 'Grandchild 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['child1'] ) ); |
| 1647 | $terms['parent1'] = self::factory()->term->create( array( 'slug' => 'parent-1', 'name' => 'Parent 1', 'taxonomy' => 'hierarchical_fields' ) ); |
| 1648 | $terms['parent2'] = self::factory()->term->create( array( 'slug' => 'parent-2', 'name' => 'Parent 2', 'taxonomy' => 'hierarchical_fields' ) ); |
| 1649 | $terms['child1'] = self::factory()->term->create( array( 'slug' => 'child-1', 'name' => 'Child 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) ); |
| 1650 | $terms['child2'] = self::factory()->term->create( array( 'slug' => 'child-2', 'name' => 'Child 2', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) ); |
| 1651 | $terms['grandchild1'] = self::factory()->term->create( array( 'slug' => 'grandchild-1', 'name' => 'Grandchild 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['child1'] ) ); |
1652 | 1652 | |
1653 | | $post_id = self::$factory->post->create(); |
| 1653 | $post_id = self::factory()->post->create(); |
1654 | 1654 | wp_set_post_terms( $post_id, $terms['parent2'], 'hierarchical_fields', true ); |
1655 | 1655 | wp_set_post_terms( $post_id, $terms['child1'], 'hierarchical_fields', true ); |
1656 | 1656 | |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1714 | 1714 | ); |
1715 | 1715 | |
1716 | 1716 | // Ensure child terms are not empty |
1717 | | $first_post_id = self::$factory->post->create(); |
1718 | | $second_post_id = self::$factory->post->create(); |
| 1717 | $first_post_id = self::factory()->post->create(); |
| 1718 | $second_post_id = self::factory()->post->create(); |
1719 | 1719 | wp_set_post_terms( $first_post_id, array( $three_term['term_id'] ), 'category' ); |
1720 | 1720 | wp_set_post_terms( $second_post_id, array( $six_term['term_id'] ), 'category' ); |
1721 | 1721 | |
… |
… |
class Tests_Term_getTerms extends WP_UnitTestCase { |
1731 | 1731 | } |
1732 | 1732 | |
1733 | 1733 | protected function set_up_three_posts_and_tags() { |
1734 | | $posts = self::$factory->post->create_many( 3, array( 'post_type' => 'post' ) ); |
| 1734 | $posts = self::factory()->post->create_many( 3, array( 'post_type' => 'post' ) ); |
1735 | 1735 | foreach ( $posts as $post ) { |
1736 | 1736 | wp_set_object_terms( $post, rand_str(), 'post_tag' ); |
1737 | 1737 | } |
-
diff --git tests/phpunit/tests/term/isObjectInTerm.php tests/phpunit/tests/term/isObjectInTerm.php
index 2e65a71..0da95ab 100644
|
|
class Tests_IsObjectInTerm extends WP_UnitTestCase { |
7 | 7 | public function test_terms_are_ints() { |
8 | 8 | register_taxonomy( 'wptests_tax', 'post' ); |
9 | 9 | |
10 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
11 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 10 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 11 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
12 | 12 | |
13 | | $posts = self::$factory->post->create_many( 2 ); |
| 13 | $posts = self::factory()->post->create_many( 2 ); |
14 | 14 | wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' ); |
15 | 15 | |
16 | 16 | $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( $t1, $t2 ) ) ); |
… |
… |
class Tests_IsObjectInTerm extends WP_UnitTestCase { |
22 | 22 | public function test_terms_are_strings_and_match_term_id() { |
23 | 23 | register_taxonomy( 'wptests_tax', 'post' ); |
24 | 24 | |
25 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
26 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 25 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 26 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
27 | 27 | |
28 | | $posts = self::$factory->post->create_many( 2 ); |
| 28 | $posts = self::factory()->post->create_many( 2 ); |
29 | 29 | wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' ); |
30 | 30 | |
31 | 31 | $t1_str = (string) $t1; |
… |
… |
class Tests_IsObjectInTerm extends WP_UnitTestCase { |
40 | 40 | public function test_terms_are_strings_and_match_term_name() { |
41 | 41 | register_taxonomy( 'wptests_tax', 'post' ); |
42 | 42 | |
43 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Foo' ) ); |
44 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Bar') ); |
| 43 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Foo' ) ); |
| 44 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Bar') ); |
45 | 45 | |
46 | | $posts = self::$factory->post->create_many( 2 ); |
| 46 | $posts = self::factory()->post->create_many( 2 ); |
47 | 47 | wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' ); |
48 | 48 | |
49 | 49 | $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( 'Foo', 'Bar' ) ) ); |
… |
… |
class Tests_IsObjectInTerm extends WP_UnitTestCase { |
55 | 55 | public function test_terms_are_strings_and_match_term_slug() { |
56 | 56 | register_taxonomy( 'wptests_tax', 'post' ); |
57 | 57 | |
58 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) ); |
59 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') ); |
| 58 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) ); |
| 59 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') ); |
60 | 60 | |
61 | | $posts = self::$factory->post->create_many( 2 ); |
| 61 | $posts = self::factory()->post->create_many( 2 ); |
62 | 62 | wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' ); |
63 | 63 | |
64 | 64 | $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( 'foo', 'bar' ) ) ); |
… |
… |
class Tests_IsObjectInTerm extends WP_UnitTestCase { |
70 | 70 | public function test_terms_contain_strings_and_ints_and_match_term_id_as_int() { |
71 | 71 | register_taxonomy( 'wptests_tax', 'post' ); |
72 | 72 | |
73 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) ); |
74 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') ); |
| 73 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) ); |
| 74 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') ); |
75 | 75 | |
76 | | $posts = self::$factory->post->create_many( 2 ); |
| 76 | $posts = self::factory()->post->create_many( 2 ); |
77 | 77 | wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' ); |
78 | 78 | |
79 | 79 | $this->assertTrue( is_object_in_term( $posts[0], 'wptests_tax', array( $t1, 'bar' ) ) ); |
… |
… |
class Tests_IsObjectInTerm extends WP_UnitTestCase { |
87 | 87 | */ |
88 | 88 | public function test_should_not_return_true_if_term_name_begins_with_existing_term_id() { |
89 | 89 | register_taxonomy( 'wptests_tax', 'post' ); |
90 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 90 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
91 | 91 | |
92 | | $post_ID = self::$factory->post->create(); |
| 92 | $post_ID = self::factory()->post->create(); |
93 | 93 | wp_set_object_terms( $post_ID, $t, 'wptests_tax' ); |
94 | 94 | |
95 | 95 | $int_tax_name = $t . '_term_name'; |
… |
… |
class Tests_IsObjectInTerm extends WP_UnitTestCase { |
108 | 108 | global $wpdb; |
109 | 109 | |
110 | 110 | register_taxonomy( 'wptests_tax', 'post' ); |
111 | | $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| 111 | $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
112 | 112 | |
113 | 113 | $o = 12345; |
114 | 114 | wp_set_object_terms( $o, $terms[0], 'wptests_tax' ); |
… |
… |
class Tests_IsObjectInTerm extends WP_UnitTestCase { |
129 | 129 | global $wpdb; |
130 | 130 | |
131 | 131 | register_taxonomy( 'wptests_tax', 'post' ); |
132 | | $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| 132 | $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
133 | 133 | |
134 | 134 | $o = 12345; |
135 | 135 | wp_set_object_terms( $o, $terms[0], 'wptests_tax' ); |
-
diff --git tests/phpunit/tests/term/meta.php tests/phpunit/tests/term/meta.php
index dc96fcd..16e4527 100644
|
|
class Tests_Term_Meta extends WP_UnitTestCase { |
12 | 12 | } |
13 | 13 | |
14 | 14 | public function test_add() { |
15 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 15 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
16 | 16 | |
17 | 17 | $this->assertNotEmpty( add_term_meta( $t, 'foo', 'bar' ) ); |
18 | 18 | } |
19 | 19 | |
20 | 20 | public function test_add_unique() { |
21 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 21 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
22 | 22 | |
23 | 23 | $this->assertNotEmpty( add_term_meta( $t, 'foo', 'bar' ) ); |
24 | 24 | $this->assertFalse( add_term_meta( $t, 'foo', 'bar', true ) ); |
25 | 25 | } |
26 | 26 | |
27 | 27 | public function test_delete() { |
28 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 28 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
29 | 29 | add_term_meta( $t, 'foo', 'bar' ); |
30 | 30 | |
31 | 31 | $this->assertTrue( delete_term_meta( $t, 'foo' ) ); |
32 | 32 | } |
33 | 33 | |
34 | 34 | public function test_delete_with_invalid_meta_key_should_return_false() { |
35 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 35 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
36 | 36 | |
37 | 37 | $this->assertFalse( delete_term_meta( $t, 'foo' ) ); |
38 | 38 | } |
39 | 39 | |
40 | 40 | public function test_delete_should_respect_meta_value() { |
41 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 41 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
42 | 42 | add_term_meta( $t, 'foo', 'bar' ); |
43 | 43 | add_term_meta( $t, 'foo', 'baz' ); |
44 | 44 | |
… |
… |
class Tests_Term_Meta extends WP_UnitTestCase { |
49 | 49 | } |
50 | 50 | |
51 | 51 | public function test_get_with_no_key_should_fetch_all_keys() { |
52 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 52 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
53 | 53 | add_term_meta( $t, 'foo', 'bar' ); |
54 | 54 | add_term_meta( $t, 'foo1', 'baz' ); |
55 | 55 | |
… |
… |
class Tests_Term_Meta extends WP_UnitTestCase { |
63 | 63 | } |
64 | 64 | |
65 | 65 | public function test_get_with_key_should_fetch_all_for_key() { |
66 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 66 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
67 | 67 | add_term_meta( $t, 'foo', 'bar' ); |
68 | 68 | add_term_meta( $t, 'foo', 'baz' ); |
69 | 69 | add_term_meta( $t, 'foo1', 'baz' ); |
… |
… |
class Tests_Term_Meta extends WP_UnitTestCase { |
75 | 75 | } |
76 | 76 | |
77 | 77 | public function test_get_should_respect_single_true() { |
78 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 78 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
79 | 79 | add_term_meta( $t, 'foo', 'bar' ); |
80 | 80 | add_term_meta( $t, 'foo', 'baz' ); |
81 | 81 | |
… |
… |
class Tests_Term_Meta extends WP_UnitTestCase { |
84 | 84 | } |
85 | 85 | |
86 | 86 | public function test_update_should_pass_to_add_when_no_value_exists_for_key() { |
87 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 87 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
88 | 88 | |
89 | 89 | $actual = update_term_meta( $t, 'foo', 'bar' ); |
90 | 90 | $this->assertInternalType( 'int', $actual ); |
… |
… |
class Tests_Term_Meta extends WP_UnitTestCase { |
95 | 95 | } |
96 | 96 | |
97 | 97 | public function test_update_should_return_true_when_updating_existing_value_for_key() { |
98 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 98 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
99 | 99 | |
100 | 100 | add_term_meta( $t, 'foo', 'bar' ); |
101 | 101 | |
… |
… |
class Tests_Term_Meta extends WP_UnitTestCase { |
109 | 109 | public function test_term_meta_should_be_lazy_loaded_for_all_terms_in_wp_query_loop() { |
110 | 110 | global $wpdb; |
111 | 111 | |
112 | | $p = self::$factory->post->create( array( 'post_status' => 'publish' ) ); |
| 112 | $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); |
113 | 113 | |
114 | 114 | register_taxonomy( 'wptests_tax', 'post' ); |
115 | | $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
| 115 | $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
116 | 116 | wp_set_object_terms( $p, $terms, 'wptests_tax' ); |
117 | 117 | foreach ( $terms as $t ) { |
118 | 118 | add_term_meta( $t, 'foo', 'bar' ); |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Create another term, which should *not* be lazy loaded because it's unattached. |
122 | | $orphan_term = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 122 | $orphan_term = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
123 | 123 | add_term_meta( $orphan_term, 'foo', 'bar' ); |
124 | 124 | |
125 | 125 | // Force results to be cached, even when using extended cache. |
… |
… |
class Tests_Term_Meta extends WP_UnitTestCase { |
154 | 154 | public function test_term_meta_should_be_lazy_loaded_only_for_the_queries_in_which_the_term_has_posts() { |
155 | 155 | global $wpdb; |
156 | 156 | |
157 | | $posts = self::$factory->post->create_many( 3, array( 'post_status' => 'publish' ) ); |
| 157 | $posts = self::factory()->post->create_many( 3, array( 'post_status' => 'publish' ) ); |
158 | 158 | register_taxonomy( 'wptests_tax', 'post' ); |
159 | | $terms = self::$factory->term->create_many( 6, array( 'taxonomy' => 'wptests_tax' ) ); |
| 159 | $terms = self::factory()->term->create_many( 6, array( 'taxonomy' => 'wptests_tax' ) ); |
160 | 160 | |
161 | 161 | wp_set_object_terms( $posts[0], array( $terms[0], $terms[1] ), 'wptests_tax' ); |
162 | 162 | wp_set_object_terms( $posts[1], array( $terms[2], $terms[3] ), 'wptests_tax' ); |
… |
… |
class Tests_Term_Meta extends WP_UnitTestCase { |
201 | 201 | } |
202 | 202 | |
203 | 203 | public function test_adding_term_meta_should_bust_get_terms_cache() { |
204 | | $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| 204 | $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
205 | 205 | |
206 | 206 | add_term_meta( $terms[0], 'foo', 'bar' ); |
207 | 207 | |
… |
… |
class Tests_Term_Meta extends WP_UnitTestCase { |
236 | 236 | } |
237 | 237 | |
238 | 238 | public function test_updating_term_meta_should_bust_get_terms_cache() { |
239 | | $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| 239 | $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
240 | 240 | |
241 | 241 | add_term_meta( $terms[0], 'foo', 'bar' ); |
242 | 242 | add_term_meta( $terms[1], 'foo', 'baz' ); |
… |
… |
class Tests_Term_Meta extends WP_UnitTestCase { |
272 | 272 | } |
273 | 273 | |
274 | 274 | public function test_deleting_term_meta_should_bust_get_terms_cache() { |
275 | | $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| 275 | $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
276 | 276 | |
277 | 277 | add_term_meta( $terms[0], 'foo', 'bar' ); |
278 | 278 | add_term_meta( $terms[1], 'foo', 'bar' ); |
-
diff --git tests/phpunit/tests/term/query.php tests/phpunit/tests/term/query.php
index bc863b1..2b717c7 100644
|
|
class Tests_Tax_Query extends WP_UnitTestCase { |
125 | 125 | } |
126 | 126 | |
127 | 127 | public function test_transform_query_resulting_field_sanitized() { |
128 | | $t1 = self::$factory->category->create( array( 'slug' => 'foo', ) ); |
129 | | $t2 = self::$factory->category->create( array( 'slug' => 'bar', ) ); |
130 | | $p = self::$factory->post->create(); |
| 128 | $t1 = self::factory()->category->create( array( 'slug' => 'foo', ) ); |
| 129 | $t2 = self::factory()->category->create( array( 'slug' => 'bar', ) ); |
| 130 | $p = self::factory()->post->create(); |
131 | 131 | wp_set_post_categories( $p, $t1 ); |
132 | 132 | |
133 | 133 | $tq1 = new WP_Tax_Query( array( |
… |
… |
class Tests_Tax_Query extends WP_UnitTestCase { |
150 | 150 | } |
151 | 151 | |
152 | 152 | public function test_transform_query_field_slug() { |
153 | | $t1 = self::$factory->category->create( array( 'slug' => 'foo', ) ); |
154 | | $p = self::$factory->post->create(); |
| 153 | $t1 = self::factory()->category->create( array( 'slug' => 'foo', ) ); |
| 154 | $p = self::factory()->post->create(); |
155 | 155 | $tt_ids = wp_set_post_categories( $p, $t1 ); |
156 | 156 | |
157 | 157 | $tq = new WP_Tax_Query( array( |
… |
… |
class Tests_Tax_Query extends WP_UnitTestCase { |
168 | 168 | } |
169 | 169 | |
170 | 170 | public function test_transform_query_field_name() { |
171 | | $t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) ); |
172 | | $p = self::$factory->post->create(); |
| 171 | $t1 = self::factory()->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) ); |
| 172 | $p = self::factory()->post->create(); |
173 | 173 | $tt_ids = wp_set_post_categories( $p, $t1 ); |
174 | 174 | |
175 | 175 | $tq = new WP_Tax_Query( array( |
… |
… |
class Tests_Tax_Query extends WP_UnitTestCase { |
186 | 186 | } |
187 | 187 | |
188 | 188 | public function test_transform_query_field_term_taxonomy_id() { |
189 | | $t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) ); |
190 | | $p = self::$factory->post->create(); |
| 189 | $t1 = self::factory()->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) ); |
| 190 | $p = self::factory()->post->create(); |
191 | 191 | $tt_ids = wp_set_post_categories( $p, $t1 ); |
192 | 192 | |
193 | 193 | $tq = new WP_Tax_Query( array( |
… |
… |
class Tests_Tax_Query extends WP_UnitTestCase { |
204 | 204 | } |
205 | 205 | |
206 | 206 | public function test_transform_query_field_term_taxonomy_default() { |
207 | | $t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) ); |
208 | | $p = self::$factory->post->create(); |
| 207 | $t1 = self::factory()->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) ); |
| 208 | $p = self::factory()->post->create(); |
209 | 209 | $tt_ids = wp_set_post_categories( $p, $t1 ); |
210 | 210 | |
211 | 211 | $tq = new WP_Tax_Query( array( |
… |
… |
class Tests_Tax_Query extends WP_UnitTestCase { |
240 | 240 | public function test_get_sql_relation_or_operator_in() { |
241 | 241 | register_taxonomy( 'wptests_tax', 'post' ); |
242 | 242 | |
243 | | $t1 = self::$factory->term->create( array( |
| 243 | $t1 = self::factory()->term->create( array( |
244 | 244 | 'taxonomy' => 'wptests_tax', |
245 | 245 | ) ); |
246 | | $t2 = self::$factory->term->create( array( |
| 246 | $t2 = self::factory()->term->create( array( |
247 | 247 | 'taxonomy' => 'wptests_tax', |
248 | 248 | ) ); |
249 | | $t3 = self::$factory->term->create( array( |
| 249 | $t3 = self::factory()->term->create( array( |
250 | 250 | 'taxonomy' => 'wptests_tax', |
251 | 251 | ) ); |
252 | 252 | |
… |
… |
class Tests_Tax_Query extends WP_UnitTestCase { |
284 | 284 | public function test_get_sql_relation_and_operator_in() { |
285 | 285 | register_taxonomy( 'wptests_tax', 'post' ); |
286 | 286 | |
287 | | $t1 = self::$factory->term->create( array( |
| 287 | $t1 = self::factory()->term->create( array( |
288 | 288 | 'taxonomy' => 'wptests_tax', |
289 | 289 | ) ); |
290 | | $t2 = self::$factory->term->create( array( |
| 290 | $t2 = self::factory()->term->create( array( |
291 | 291 | 'taxonomy' => 'wptests_tax', |
292 | 292 | ) ); |
293 | | $t3 = self::$factory->term->create( array( |
| 293 | $t3 = self::factory()->term->create( array( |
294 | 294 | 'taxonomy' => 'wptests_tax', |
295 | 295 | ) ); |
296 | 296 | |
… |
… |
class Tests_Tax_Query extends WP_UnitTestCase { |
327 | 327 | public function test_get_sql_nested_relation_or_operator_in() { |
328 | 328 | register_taxonomy( 'wptests_tax', 'post' ); |
329 | 329 | |
330 | | $t1 = self::$factory->term->create( array( |
| 330 | $t1 = self::factory()->term->create( array( |
331 | 331 | 'taxonomy' => 'wptests_tax', |
332 | 332 | ) ); |
333 | | $t2 = self::$factory->term->create( array( |
| 333 | $t2 = self::factory()->term->create( array( |
334 | 334 | 'taxonomy' => 'wptests_tax', |
335 | 335 | ) ); |
336 | | $t3 = self::$factory->term->create( array( |
| 336 | $t3 = self::factory()->term->create( array( |
337 | 337 | 'taxonomy' => 'wptests_tax', |
338 | 338 | ) ); |
339 | 339 | |
-
diff --git tests/phpunit/tests/term/slashes.php tests/phpunit/tests/term/slashes.php
index 7183bdb..9970a25 100644
|
|
|
8 | 8 | class Tests_Term_Slashes extends WP_Ajax_UnitTestCase { |
9 | 9 | function setUp() { |
10 | 10 | parent::setUp(); |
11 | | $this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 11 | $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
12 | 12 | $this->old_current_user = get_current_user_id(); |
13 | 13 | wp_set_current_user( $this->author_id ); |
14 | 14 | |
… |
… |
class Tests_Term_Slashes extends WP_Ajax_UnitTestCase { |
84 | 84 | 'post_tag' |
85 | 85 | ); |
86 | 86 | foreach ( $taxonomies as $taxonomy ) { |
87 | | $id = self::$factory->term->create(array( |
| 87 | $id = self::factory()->term->create(array( |
88 | 88 | 'taxonomy' => $taxonomy |
89 | 89 | )); |
90 | 90 | |
-
diff --git tests/phpunit/tests/term/termExists.php tests/phpunit/tests/term/termExists.php
index d628b31..b00b6e8 100644
|
|
class Tests_TermExists extends WP_UnitTestCase { |
9 | 9 | } |
10 | 10 | |
11 | 11 | public function test_term_exists_term_int_taxonomy_nonempty_term_exists() { |
12 | | $t = self::$factory->term->create( array( |
| 12 | $t = self::factory()->term->create( array( |
13 | 13 | 'taxonomy' => 'post_tag', |
14 | 14 | ) ); |
15 | 15 | |
… |
… |
class Tests_TermExists extends WP_UnitTestCase { |
22 | 22 | } |
23 | 23 | |
24 | 24 | public function test_term_exists_term_int_taxonomy_nonempty_wrong_taxonomy() { |
25 | | $t = self::$factory->term->create( array( |
| 25 | $t = self::factory()->term->create( array( |
26 | 26 | 'taxonomy' => 'post_tag', |
27 | 27 | ) ); |
28 | 28 | |
… |
… |
class Tests_TermExists extends WP_UnitTestCase { |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function test_term_exists_term_int_taxonomy_empty_term_exists() { |
33 | | $t = self::$factory->term->create( array( |
| 33 | $t = self::factory()->term->create( array( |
34 | 34 | 'taxonomy' => 'post_tag', |
35 | 35 | ) ); |
36 | 36 | |
… |
… |
class Tests_TermExists extends WP_UnitTestCase { |
43 | 43 | } |
44 | 44 | |
45 | 45 | public function test_term_exists_unslash_term() { |
46 | | $t = self::$factory->term->create( array( |
| 46 | $t = self::factory()->term->create( array( |
47 | 47 | 'taxonomy' => 'post_tag', |
48 | 48 | 'name' => 'I "love" WordPress\'s taxonomy system', |
49 | 49 | ) ); |
… |
… |
class Tests_TermExists extends WP_UnitTestCase { |
53 | 53 | } |
54 | 54 | |
55 | 55 | public function test_term_exists_trim_term() { |
56 | | $t = self::$factory->term->create( array( |
| 56 | $t = self::factory()->term->create( array( |
57 | 57 | 'taxonomy' => 'post_tag', |
58 | 58 | 'slug' => 'foo', |
59 | 59 | ) ); |
… |
… |
class Tests_TermExists extends WP_UnitTestCase { |
84 | 84 | 'hierarchical' => true, |
85 | 85 | ) ); |
86 | 86 | |
87 | | $parent_term = self::$factory->term->create( array( |
| 87 | $parent_term = self::factory()->term->create( array( |
88 | 88 | 'taxonomy' => 'foo', |
89 | 89 | ) ); |
90 | 90 | |
91 | | $t = self::$factory->term->create( array( |
| 91 | $t = self::factory()->term->create( array( |
92 | 92 | 'taxonomy' => 'foo', |
93 | 93 | 'parent' => $parent_term, |
94 | 94 | 'slug' => 'child-term', |
… |
… |
class Tests_TermExists extends WP_UnitTestCase { |
110 | 110 | 'hierarchical' => true, |
111 | 111 | ) ); |
112 | 112 | |
113 | | $parent_term = self::$factory->term->create( array( |
| 113 | $parent_term = self::factory()->term->create( array( |
114 | 114 | 'taxonomy' => 'foo', |
115 | 115 | ) ); |
116 | 116 | |
117 | | $t = self::$factory->term->create( array( |
| 117 | $t = self::factory()->term->create( array( |
118 | 118 | 'taxonomy' => 'foo', |
119 | 119 | 'parent' => $parent_term, |
120 | 120 | 'slug' => 'child-term', |
… |
… |
class Tests_TermExists extends WP_UnitTestCase { |
132 | 132 | 'hierarchical' => true, |
133 | 133 | ) ); |
134 | 134 | |
135 | | $parent_term = self::$factory->term->create( array( |
| 135 | $parent_term = self::factory()->term->create( array( |
136 | 136 | 'taxonomy' => 'foo', |
137 | 137 | ) ); |
138 | 138 | |
139 | | $t = self::$factory->term->create( array( |
| 139 | $t = self::factory()->term->create( array( |
140 | 140 | 'taxonomy' => 'foo', |
141 | 141 | 'parent' => $parent_term, |
142 | 142 | 'name' => 'Child Term', |
… |
… |
class Tests_TermExists extends WP_UnitTestCase { |
153 | 153 | public function test_term_exists_taxonomy_nonempty_parent_empty_match_slug() { |
154 | 154 | register_taxonomy( 'foo', 'post', array() ); |
155 | 155 | |
156 | | $t = self::$factory->term->create( array( |
| 156 | $t = self::factory()->term->create( array( |
157 | 157 | 'taxonomy' => 'foo', |
158 | 158 | 'slug' => 'kewl-dudez', |
159 | 159 | ) ); |
… |
… |
class Tests_TermExists extends WP_UnitTestCase { |
169 | 169 | public function test_term_exists_taxonomy_nonempty_parent_empty_match_name() { |
170 | 170 | register_taxonomy( 'foo', 'post', array() ); |
171 | 171 | |
172 | | $t = self::$factory->term->create( array( |
| 172 | $t = self::factory()->term->create( array( |
173 | 173 | 'taxonomy' => 'foo', |
174 | 174 | 'name' => 'Kewl Dudez', |
175 | 175 | ) ); |
… |
… |
class Tests_TermExists extends WP_UnitTestCase { |
185 | 185 | public function test_term_exists_taxonomy_empty_parent_empty_match_slug() { |
186 | 186 | register_taxonomy( 'foo', 'post', array() ); |
187 | 187 | |
188 | | $t = self::$factory->term->create( array( |
| 188 | $t = self::factory()->term->create( array( |
189 | 189 | 'taxonomy' => 'foo', |
190 | 190 | 'name' => 'juicy-fruit', |
191 | 191 | ) ); |
… |
… |
class Tests_TermExists extends WP_UnitTestCase { |
201 | 201 | public function test_term_exists_taxonomy_empty_parent_empty_match_name() { |
202 | 202 | register_taxonomy( 'foo', 'post', array() ); |
203 | 203 | |
204 | | $t = self::$factory->term->create( array( |
| 204 | $t = self::factory()->term->create( array( |
205 | 205 | 'taxonomy' => 'foo', |
206 | 206 | 'name' => 'Juicy Fruit', |
207 | 207 | ) ); |
-
diff --git tests/phpunit/tests/term/wpDeleteObjectTermRelationships.php tests/phpunit/tests/term/wpDeleteObjectTermRelationships.php
index dee5918..319a818 100644
|
|
class Tests_Term_WpDeleteObjectTermRelationships extends WP_UnitTestCase { |
9 | 9 | register_taxonomy( 'wptests_tax1', 'post' ); |
10 | 10 | register_taxonomy( 'wptests_tax2', 'post' ); |
11 | 11 | |
12 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
13 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| 12 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| 13 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
14 | 14 | |
15 | 15 | $object_id = 567; |
16 | 16 | |
… |
… |
class Tests_Term_WpDeleteObjectTermRelationships extends WP_UnitTestCase { |
33 | 33 | register_taxonomy( 'wptests_tax2', 'post' ); |
34 | 34 | register_taxonomy( 'wptests_tax3', 'post' ); |
35 | 35 | |
36 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
37 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
38 | | $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax3' ) ); |
| 36 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| 37 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| 38 | $t3 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax3' ) ); |
39 | 39 | |
40 | 40 | $object_id = 567; |
41 | 41 | |
-
diff --git tests/phpunit/tests/term/wpDeleteTerm.php tests/phpunit/tests/term/wpDeleteTerm.php
index f47caa4..7a62d72 100644
|
|
class Tests_Term_WpDeleteTerm extends WP_UnitTestCase { |
12 | 12 | public function test_count_property_passed_to_filters_should_reflect_pre_deleted_term() { |
13 | 13 | register_taxonomy( 'wptests_tax', 'post' ); |
14 | 14 | |
15 | | $terms = self::$factory->term->create_many( 2, array( |
| 15 | $terms = self::factory()->term->create_many( 2, array( |
16 | 16 | 'taxonomy' => 'wptests_tax', |
17 | 17 | ) ); |
18 | 18 | |
19 | | $p = self::$factory->post->create(); |
| 19 | $p = self::factory()->post->create(); |
20 | 20 | |
21 | 21 | wp_set_object_terms( $p, array( $terms[0] ), 'wptests_tax' ); |
22 | 22 | |
-
diff --git tests/phpunit/tests/term/wpGenerateTagCloud.php tests/phpunit/tests/term/wpGenerateTagCloud.php
index 7f5352d..742b321 100644
|
|
class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { |
27 | 27 | * @param $args Options for `wp_generate_tag_cloud()`. |
28 | 28 | */ |
29 | 29 | function test_empty_tags_list_returned( $expected, $args ) { |
30 | | $term_ids = self::$factory->term->create_many( 4, array( 'taxonomy' => 'post_tag' ) ); |
| 30 | $term_ids = self::factory()->term->create_many( 4, array( 'taxonomy' => 'post_tag' ) ); |
31 | 31 | $this->terms = array(); |
32 | 32 | foreach ( $term_ids as $term_id ) { |
33 | 33 | $this->terms[] = get_term( $term_id, 'post_tag' ); |
… |
… |
class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { |
71 | 71 | } |
72 | 72 | |
73 | 73 | function test_hide_empty_false() { |
74 | | $term_id = self::$factory->tag->create(); |
| 74 | $term_id = self::factory()->tag->create(); |
75 | 75 | $term = get_term( $term_id, 'post_tag' ); |
76 | 76 | |
77 | 77 | $tags = $this->retrieve_terms( array( |
… |
… |
class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { |
85 | 85 | } |
86 | 86 | |
87 | 87 | function test_hide_empty_false_format_array() { |
88 | | $term_id = self::$factory->tag->create(); |
| 88 | $term_id = self::factory()->tag->create(); |
89 | 89 | $term = get_term( $term_id, 'post_tag' ); |
90 | 90 | |
91 | 91 | $tags = $this->retrieve_terms( array( |
… |
… |
class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { |
101 | 101 | } |
102 | 102 | |
103 | 103 | function test_hide_empty_false_format_list() { |
104 | | $term_id = self::$factory->tag->create(); |
| 104 | $term_id = self::factory()->tag->create(); |
105 | 105 | $term = get_term( $term_id, 'post_tag' ); |
106 | 106 | |
107 | 107 | $tags = $this->retrieve_terms( array( |
… |
… |
class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { |
117 | 117 | } |
118 | 118 | |
119 | 119 | function test_hide_empty_false_multi() { |
120 | | $term_ids = self::$factory->tag->create_many( 4 ); |
| 120 | $term_ids = self::factory()->tag->create_many( 4 ); |
121 | 121 | $terms = array(); |
122 | 122 | foreach ( $term_ids as $term_id ) { |
123 | 123 | $terms[] = get_term( $term_id, 'post_tag' ); |
… |
… |
class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { |
139 | 139 | } |
140 | 140 | |
141 | 141 | function test_hide_empty_false_multi_format_list() { |
142 | | $term_ids = self::$factory->tag->create_many( 4 ); |
| 142 | $term_ids = self::factory()->tag->create_many( 4 ); |
143 | 143 | $terms = array(); |
144 | 144 | foreach ( $term_ids as $term_id ) { |
145 | 145 | $terms[] = get_term( $term_id, 'post_tag' ); |
… |
… |
class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { |
166 | 166 | |
167 | 167 | public function test_topic_count_text() { |
168 | 168 | register_taxonomy( 'wptests_tax', 'post' ); |
169 | | $term_ids = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| 169 | $term_ids = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
170 | 170 | $this->terms = array(); |
171 | 171 | foreach ( $term_ids as $term_id ) { |
172 | 172 | $this->terms[] = get_term( $term_id, 'post_tag' ); |
173 | 173 | } |
174 | | $posts = self::$factory->post->create_many( 2 ); |
| 174 | $posts = self::factory()->post->create_many( 2 ); |
175 | 175 | |
176 | 176 | wp_set_post_terms( $posts[0], $term_ids, 'wptests_tax' ); |
177 | 177 | wp_set_post_terms( $posts[1], array( $term_ids[1] ), 'wptests_tax' ); |
… |
… |
class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { |
196 | 196 | |
197 | 197 | public function test_topic_count_text_callback() { |
198 | 198 | register_taxonomy( 'wptests_tax', 'post' ); |
199 | | $term_ids = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| 199 | $term_ids = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
200 | 200 | $this->terms = array(); |
201 | 201 | foreach ( $term_ids as $term_id ) { |
202 | 202 | $this->terms[] = get_term( $term_id, 'post_tag' ); |
203 | 203 | } |
204 | | $posts = self::$factory->post->create_many( 2 ); |
| 204 | $posts = self::factory()->post->create_many( 2 ); |
205 | 205 | |
206 | 206 | wp_set_post_terms( $posts[0], $term_ids, 'wptests_tax' ); |
207 | 207 | wp_set_post_terms( $posts[1], array( $term_ids[1] ), 'wptests_tax' ); |
-
diff --git tests/phpunit/tests/term/wpGetObjectTerms.php tests/phpunit/tests/term/wpGetObjectTerms.php
index 3d7a90f..ffa8781 100644
|
|
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
13 | 13 | } |
14 | 14 | |
15 | 15 | public function test_get_object_terms_by_slug() { |
16 | | $post_id = self::$factory->post->create(); |
| 16 | $post_id = self::factory()->post->create(); |
17 | 17 | |
18 | 18 | $terms_1 = array('Foo', 'Bar', 'Baz'); |
19 | 19 | $terms_1_slugs = array('foo', 'bar', 'baz'); |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
31 | 31 | * @ticket 11003 |
32 | 32 | */ |
33 | 33 | public function test_should_not_filter_out_duplicate_terms_associated_with_different_objects() { |
34 | | $post_id1 = self::$factory->post->create(); |
35 | | $post_id2 = self::$factory->post->create(); |
36 | | $cat_id = self::$factory->category->create(); |
37 | | $cat_id2 = self::$factory->category->create(); |
| 34 | $post_id1 = self::factory()->post->create(); |
| 35 | $post_id2 = self::factory()->post->create(); |
| 36 | $cat_id = self::factory()->category->create(); |
| 37 | $cat_id2 = self::factory()->category->create(); |
38 | 38 | wp_set_post_categories( $post_id1, array( $cat_id, $cat_id2 ) ); |
39 | 39 | wp_set_post_categories( $post_id2, $cat_id ); |
40 | 40 | |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
54 | 54 | * @ticket 17646 |
55 | 55 | */ |
56 | 56 | public function test_should_return_objects_with_int_properties() { |
57 | | $post_id = self::$factory->post->create(); |
| 57 | $post_id = self::factory()->post->create(); |
58 | 58 | $term = wp_insert_term( 'one', $this->taxonomy ); |
59 | 59 | wp_set_object_terms( $post_id, $term, $this->taxonomy ); |
60 | 60 | |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
73 | 73 | * @ticket 26339 |
74 | 74 | */ |
75 | 75 | public function test_references_should_be_reset_after_wp_get_object_terms_filter() { |
76 | | $post_id = self::$factory->post->create(); |
| 76 | $post_id = self::factory()->post->create(); |
77 | 77 | $terms_1 = array('foo', 'bar', 'baz'); |
78 | 78 | |
79 | 79 | wp_set_object_terms( $post_id, $terms_1, $this->taxonomy ); |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
86 | 86 | } |
87 | 87 | |
88 | 88 | public function test_orderby_name() { |
89 | | $p = self::$factory->post->create(); |
| 89 | $p = self::factory()->post->create(); |
90 | 90 | |
91 | | $t1 = self::$factory->term->create( array( |
| 91 | $t1 = self::factory()->term->create( array( |
92 | 92 | 'taxonomy' => $this->taxonomy, |
93 | 93 | 'name' => 'AAA', |
94 | 94 | ) ); |
95 | | $t2 = self::$factory->term->create( array( |
| 95 | $t2 = self::factory()->term->create( array( |
96 | 96 | 'taxonomy' => $this->taxonomy, |
97 | 97 | 'name' => 'ZZZ', |
98 | 98 | ) ); |
99 | | $t3 = self::$factory->term->create( array( |
| 99 | $t3 = self::factory()->term->create( array( |
100 | 100 | 'taxonomy' => $this->taxonomy, |
101 | 101 | 'name' => 'JJJ', |
102 | 102 | ) ); |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
112 | 112 | } |
113 | 113 | |
114 | 114 | public function test_orderby_count() { |
115 | | $posts = self::$factory->post->create_many( 3 ); |
| 115 | $posts = self::factory()->post->create_many( 3 ); |
116 | 116 | |
117 | | $t1 = self::$factory->term->create( array( |
| 117 | $t1 = self::factory()->term->create( array( |
118 | 118 | 'taxonomy' => $this->taxonomy, |
119 | 119 | 'name' => 'AAA', |
120 | 120 | ) ); |
121 | | $t2 = self::$factory->term->create( array( |
| 121 | $t2 = self::factory()->term->create( array( |
122 | 122 | 'taxonomy' => $this->taxonomy, |
123 | 123 | 'name' => 'ZZZ', |
124 | 124 | ) ); |
125 | | $t3 = self::$factory->term->create( array( |
| 125 | $t3 = self::factory()->term->create( array( |
126 | 126 | 'taxonomy' => $this->taxonomy, |
127 | 127 | 'name' => 'JJJ', |
128 | 128 | ) ); |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
140 | 140 | } |
141 | 141 | |
142 | 142 | public function test_orderby_slug() { |
143 | | $p = self::$factory->post->create(); |
| 143 | $p = self::factory()->post->create(); |
144 | 144 | |
145 | | $t1 = self::$factory->term->create( array( |
| 145 | $t1 = self::factory()->term->create( array( |
146 | 146 | 'taxonomy' => $this->taxonomy, |
147 | 147 | 'slug' => 'aaa', |
148 | 148 | ) ); |
149 | | $t2 = self::$factory->term->create( array( |
| 149 | $t2 = self::factory()->term->create( array( |
150 | 150 | 'taxonomy' => $this->taxonomy, |
151 | 151 | 'slug' => 'zzz', |
152 | 152 | ) ); |
153 | | $t3 = self::$factory->term->create( array( |
| 153 | $t3 = self::factory()->term->create( array( |
154 | 154 | 'taxonomy' => $this->taxonomy, |
155 | 155 | 'slug' => 'jjj', |
156 | 156 | ) ); |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
166 | 166 | } |
167 | 167 | |
168 | 168 | public function test_orderby_term_group() { |
169 | | $p = self::$factory->post->create(); |
| 169 | $p = self::factory()->post->create(); |
170 | 170 | |
171 | | $t1 = self::$factory->term->create( array( |
| 171 | $t1 = self::factory()->term->create( array( |
172 | 172 | 'taxonomy' => $this->taxonomy, |
173 | 173 | ) ); |
174 | | $t2 = self::$factory->term->create( array( |
| 174 | $t2 = self::factory()->term->create( array( |
175 | 175 | 'taxonomy' => $this->taxonomy, |
176 | 176 | ) ); |
177 | | $t3 = self::$factory->term->create( array( |
| 177 | $t3 = self::factory()->term->create( array( |
178 | 178 | 'taxonomy' => $this->taxonomy, |
179 | 179 | ) ); |
180 | 180 | |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
195 | 195 | } |
196 | 196 | |
197 | 197 | public function test_orderby_term_order() { |
198 | | $p = self::$factory->post->create(); |
| 198 | $p = self::factory()->post->create(); |
199 | 199 | |
200 | | $t1 = self::$factory->term->create( array( |
| 200 | $t1 = self::factory()->term->create( array( |
201 | 201 | 'taxonomy' => $this->taxonomy, |
202 | 202 | ) ); |
203 | | $t2 = self::$factory->term->create( array( |
| 203 | $t2 = self::factory()->term->create( array( |
204 | 204 | 'taxonomy' => $this->taxonomy, |
205 | 205 | ) ); |
206 | | $t3 = self::$factory->term->create( array( |
| 206 | $t3 = self::factory()->term->create( array( |
207 | 207 | 'taxonomy' => $this->taxonomy, |
208 | 208 | ) ); |
209 | 209 | |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
231 | 231 | * @ticket 28688 |
232 | 232 | */ |
233 | 233 | public function test_orderby_parent() { |
234 | | $p = self::$factory->post->create(); |
| 234 | $p = self::factory()->post->create(); |
235 | 235 | |
236 | | $t1 = self::$factory->term->create( array( |
| 236 | $t1 = self::factory()->term->create( array( |
237 | 237 | 'taxonomy' => $this->taxonomy, |
238 | 238 | ) ); |
239 | | $t2 = self::$factory->term->create( array( |
| 239 | $t2 = self::factory()->term->create( array( |
240 | 240 | 'taxonomy' => $this->taxonomy, |
241 | 241 | ) ); |
242 | | $t3 = self::$factory->term->create( array( |
| 242 | $t3 = self::factory()->term->create( array( |
243 | 243 | 'taxonomy' => $this->taxonomy, |
244 | 244 | ) ); |
245 | 245 | |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
269 | 269 | register_taxonomy( 'wptests_tax_2', 'post' ); |
270 | 270 | register_taxonomy( 'wptests_tax_3', 'post' ); |
271 | 271 | |
272 | | $p = self::$factory->post->create(); |
| 272 | $p = self::factory()->post->create(); |
273 | 273 | |
274 | | $t1 = self::$factory->term->create( array( |
| 274 | $t1 = self::factory()->term->create( array( |
275 | 275 | 'taxonomy' => $this->taxonomy, |
276 | 276 | ) ); |
277 | | $t2 = self::$factory->term->create( array( |
| 277 | $t2 = self::factory()->term->create( array( |
278 | 278 | 'taxonomy' => 'wptests_tax_3', |
279 | 279 | ) ); |
280 | | $t3 = self::$factory->term->create( array( |
| 280 | $t3 = self::factory()->term->create( array( |
281 | 281 | 'taxonomy' => 'wptests_tax_2', |
282 | 282 | ) ); |
283 | 283 | |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
297 | 297 | * @ticket 28688 |
298 | 298 | */ |
299 | 299 | public function test_orderby_tt_id() { |
300 | | $p = self::$factory->post->create(); |
| 300 | $p = self::factory()->post->create(); |
301 | 301 | |
302 | | $t1 = self::$factory->term->create( array( |
| 302 | $t1 = self::factory()->term->create( array( |
303 | 303 | 'taxonomy' => $this->taxonomy, |
304 | 304 | ) ); |
305 | | $t2 = self::$factory->term->create( array( |
| 305 | $t2 = self::factory()->term->create( array( |
306 | 306 | 'taxonomy' => $this->taxonomy, |
307 | 307 | ) ); |
308 | | $t3 = self::$factory->term->create( array( |
| 308 | $t3 = self::factory()->term->create( array( |
309 | 309 | 'taxonomy' => $this->taxonomy, |
310 | 310 | ) ); |
311 | 311 | |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
330 | 330 | } |
331 | 331 | |
332 | 332 | public function test_order_desc() { |
333 | | $p = self::$factory->post->create(); |
| 333 | $p = self::factory()->post->create(); |
334 | 334 | |
335 | | $t1 = self::$factory->term->create( array( |
| 335 | $t1 = self::factory()->term->create( array( |
336 | 336 | 'taxonomy' => $this->taxonomy, |
337 | 337 | 'name' => 'AAA', |
338 | 338 | ) ); |
339 | | $t2 = self::$factory->term->create( array( |
| 339 | $t2 = self::factory()->term->create( array( |
340 | 340 | 'taxonomy' => $this->taxonomy, |
341 | 341 | 'name' => 'ZZZ', |
342 | 342 | ) ); |
343 | | $t3 = self::$factory->term->create( array( |
| 343 | $t3 = self::factory()->term->create( array( |
344 | 344 | 'taxonomy' => $this->taxonomy, |
345 | 345 | 'name' => 'JJJ', |
346 | 346 | ) ); |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
360 | 360 | * @ticket 15675 |
361 | 361 | */ |
362 | 362 | public function test_parent() { |
363 | | $t1 = self::$factory->term->create( array( |
| 363 | $t1 = self::factory()->term->create( array( |
364 | 364 | 'taxonomy' => $this->taxonomy, |
365 | 365 | ) ); |
366 | | $t2 = self::$factory->term->create( array( |
| 366 | $t2 = self::factory()->term->create( array( |
367 | 367 | 'taxonomy' => $this->taxonomy, |
368 | 368 | ) ); |
369 | | $t3 = self::$factory->term->create( array( |
| 369 | $t3 = self::factory()->term->create( array( |
370 | 370 | 'taxonomy' => $this->taxonomy, |
371 | 371 | 'parent' => $t1, |
372 | 372 | ) ); |
373 | | $t4 = self::$factory->term->create( array( |
| 373 | $t4 = self::factory()->term->create( array( |
374 | 374 | 'taxonomy' => $this->taxonomy, |
375 | 375 | 'parent' => $t2, |
376 | 376 | ) ); |
377 | 377 | |
378 | | $p = self::$factory->post->create(); |
| 378 | $p = self::factory()->post->create(); |
379 | 379 | |
380 | 380 | wp_set_object_terms( $p, array( $t1, $t2, $t3, $t3 ), $this->taxonomy ); |
381 | 381 | |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
391 | 391 | * @ticket 15675 |
392 | 392 | */ |
393 | 393 | public function test_parent_0() { |
394 | | $t1 = self::$factory->term->create( array( |
| 394 | $t1 = self::factory()->term->create( array( |
395 | 395 | 'taxonomy' => $this->taxonomy, |
396 | 396 | ) ); |
397 | | $t2 = self::$factory->term->create( array( |
| 397 | $t2 = self::factory()->term->create( array( |
398 | 398 | 'taxonomy' => $this->taxonomy, |
399 | 399 | ) ); |
400 | | $t3 = self::$factory->term->create( array( |
| 400 | $t3 = self::factory()->term->create( array( |
401 | 401 | 'taxonomy' => $this->taxonomy, |
402 | 402 | 'parent' => $t1, |
403 | 403 | ) ); |
404 | | $t4 = self::$factory->term->create( array( |
| 404 | $t4 = self::factory()->term->create( array( |
405 | 405 | 'taxonomy' => $this->taxonomy, |
406 | 406 | 'parent' => $t2, |
407 | 407 | ) ); |
408 | 408 | |
409 | | $p = self::$factory->post->create(); |
| 409 | $p = self::factory()->post->create(); |
410 | 410 | |
411 | 411 | wp_set_object_terms( $p, array( $t1, $t2, $t3, $t3 ), $this->taxonomy ); |
412 | 412 | |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
425 | 425 | global $wpdb; |
426 | 426 | |
427 | 427 | register_taxonomy( 'wptests_tax', 'post' ); |
428 | | $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
| 428 | $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
429 | 429 | add_term_meta( $terms[0], 'foo', 'bar' ); |
430 | 430 | add_term_meta( $terms[1], 'foo', 'bar' ); |
431 | 431 | add_term_meta( $terms[2], 'foo', 'bar' ); |
432 | 432 | |
433 | | $p = self::$factory->post->create(); |
| 433 | $p = self::factory()->post->create(); |
434 | 434 | wp_set_object_terms( $p, $terms, 'wptests_tax' ); |
435 | 435 | |
436 | 436 | $found = wp_get_object_terms( $p, 'wptests_tax' ); |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
451 | 451 | global $wpdb; |
452 | 452 | |
453 | 453 | register_taxonomy( 'wptests_tax', 'post' ); |
454 | | $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
| 454 | $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
455 | 455 | add_term_meta( $terms[0], 'foo', 'bar' ); |
456 | 456 | add_term_meta( $terms[1], 'foo', 'bar' ); |
457 | 457 | add_term_meta( $terms[2], 'foo', 'bar' ); |
458 | 458 | |
459 | | $p = self::$factory->post->create(); |
| 459 | $p = self::factory()->post->create(); |
460 | 460 | wp_set_object_terms( $p, $terms, 'wptests_tax' ); |
461 | 461 | |
462 | 462 | $found = wp_get_object_terms( $p, 'wptests_tax', array( |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
477 | 477 | */ |
478 | 478 | public function test_meta_query() { |
479 | 479 | register_taxonomy( 'wptests_tax', 'post' ); |
480 | | $terms = self::$factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) ); |
| 480 | $terms = self::factory()->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) ); |
481 | 481 | add_term_meta( $terms[0], 'foo', 'bar' ); |
482 | 482 | add_term_meta( $terms[1], 'foo', 'bar' ); |
483 | 483 | add_term_meta( $terms[2], 'foo', 'baz' ); |
484 | 484 | add_term_meta( $terms[3], 'foob', 'ar' ); |
485 | 485 | |
486 | | $p = self::$factory->post->create(); |
| 486 | $p = self::factory()->post->create(); |
487 | 487 | wp_set_object_terms( $p, $terms, 'wptests_tax' ); |
488 | 488 | |
489 | 489 | $found = wp_get_object_terms( $p, 'wptests_tax', array( |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
503 | 503 | */ |
504 | 504 | public function test_should_return_wp_term_objects_for_fields_all() { |
505 | 505 | register_taxonomy( 'wptests_tax', 'post' ); |
506 | | $p = self::$factory->post->create(); |
507 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 506 | $p = self::factory()->post->create(); |
| 507 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
508 | 508 | wp_set_object_terms( $p, $t, 'wptests_tax' ); |
509 | 509 | |
510 | 510 | $found = wp_get_object_terms( $p, 'wptests_tax', array( |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
522 | 522 | */ |
523 | 523 | public function test_should_return_wp_term_objects_for_fields_all_with_object_id() { |
524 | 524 | register_taxonomy( 'wptests_tax', 'post' ); |
525 | | $p = self::$factory->post->create(); |
526 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 525 | $p = self::factory()->post->create(); |
| 526 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
527 | 527 | wp_set_object_terms( $p, $t, 'wptests_tax' ); |
528 | 528 | |
529 | 529 | $found = wp_get_object_terms( $p, 'wptests_tax', array( |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
543 | 543 | global $wpdb; |
544 | 544 | |
545 | 545 | register_taxonomy( 'wptests_tax', 'post' ); |
546 | | $p = self::$factory->post->create(); |
547 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 546 | $p = self::factory()->post->create(); |
| 547 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
548 | 548 | wp_set_object_terms( $p, $t, 'wptests_tax' ); |
549 | 549 | |
550 | 550 | $found = wp_get_object_terms( $p, 'wptests_tax', array( |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
561 | 561 | */ |
562 | 562 | public function test_object_id_should_not_be_cached_with_term_object() { |
563 | 563 | register_taxonomy( 'wptests_tax', 'post' ); |
564 | | $p = self::$factory->post->create(); |
565 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 564 | $p = self::factory()->post->create(); |
| 565 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
566 | 566 | wp_set_object_terms( $p, $t, 'wptests_tax' ); |
567 | 567 | |
568 | 568 | $found = wp_get_object_terms( $p, 'wptests_tax', array( |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
585 | 585 | |
586 | 586 | register_taxonomy( 'wptests_tax1', 'post' ); |
587 | 587 | register_taxonomy( 'wptests_tax2', 'post' ); |
588 | | $p = self::$factory->post->create(); |
589 | | $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
590 | | $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
| 588 | $p = self::factory()->post->create(); |
| 589 | $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); |
| 590 | $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); |
591 | 591 | wp_set_object_terms( $p, $t1, 'wptests_tax1' ); |
592 | 592 | wp_set_object_terms( $p, $t2, 'wptests_tax2' ); |
593 | 593 | |
… |
… |
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { |
611 | 611 | */ |
612 | 612 | public function test_object_id_should_be_set_on_objects_that_share_terms() { |
613 | 613 | register_taxonomy( 'wptests_tax', 'post' ); |
614 | | $posts = self::$factory->post->create_many( 2 ); |
615 | | $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
| 614 | $posts = self::factory()->post->create_many( 2 ); |
| 615 | $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); |
616 | 616 | wp_set_object_terms( $posts[0], $t, 'wptests_tax' ); |
617 | 617 | wp_set_object_terms( $posts[1], $t, 'wptests_tax' ); |
618 | 618 | |
-
diff --git tests/phpunit/tests/term/wpInsertTerm.php tests/phpunit/tests/term/wpInsertTerm.php
index 18e3fd3..ea7ba45 100644
|
|
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
160 | 160 | * @ticket 17689 |
161 | 161 | */ |
162 | 162 | public function test_wp_insert_term_duplicate_name() { |
163 | | $term = self::$factory->tag->create_and_get( array( 'name' => 'Bozo' ) ); |
| 163 | $term = self::factory()->tag->create_and_get( array( 'name' => 'Bozo' ) ); |
164 | 164 | $this->assertNotWPError( $term ); |
165 | 165 | $this->assertTrue( empty( $term->errors ) ); |
166 | 166 | |
167 | 167 | // Test existing term name with unique slug |
168 | | $term1 = self::$factory->tag->create( array( 'name' => 'Bozo', 'slug' => 'bozo1' ) ); |
| 168 | $term1 = self::factory()->tag->create( array( 'name' => 'Bozo', 'slug' => 'bozo1' ) ); |
169 | 169 | $this->assertNotWPError( $term1 ); |
170 | 170 | |
171 | 171 | // Test an existing term name |
172 | | $term2 = self::$factory->tag->create( array( 'name' => 'Bozo' ) ); |
| 172 | $term2 = self::factory()->tag->create( array( 'name' => 'Bozo' ) ); |
173 | 173 | $this->assertTrue( is_wp_error( $term2 ) ); |
174 | 174 | $this->assertNotEmpty( $term2->errors ); |
175 | 175 | |
176 | 176 | // Test named terms ending in special characters |
177 | | $term3 = self::$factory->tag->create( array( 'name' => 'T$' ) ); |
178 | | $term4 = self::$factory->tag->create( array( 'name' => 'T$$' ) ); |
179 | | $term5 = self::$factory->tag->create( array( 'name' => 'T$$$' ) ); |
180 | | $term6 = self::$factory->tag->create( array( 'name' => 'T$$$$' ) ); |
181 | | $term7 = self::$factory->tag->create( array( 'name' => 'T$$$$' ) ); |
| 177 | $term3 = self::factory()->tag->create( array( 'name' => 'T$' ) ); |
| 178 | $term4 = self::factory()->tag->create( array( 'name' => 'T$$' ) ); |
| 179 | $term5 = self::factory()->tag->create( array( 'name' => 'T$$$' ) ); |
| 180 | $term6 = self::factory()->tag->create( array( 'name' => 'T$$$$' ) ); |
| 181 | $term7 = self::factory()->tag->create( array( 'name' => 'T$$$$' ) ); |
182 | 182 | $this->assertTrue( is_wp_error( $term7 ) ); |
183 | 183 | $this->assertNotEmpty( $term7->errors ); |
184 | 184 | $this->assertEquals( $term6, $term7->error_data['term_exists'] ); |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
187 | 187 | $this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) ); |
188 | 188 | |
189 | 189 | // Test named terms with only special characters |
190 | | $term8 = self::$factory->tag->create( array( 'name' => '$' ) ); |
191 | | $term9 = self::$factory->tag->create( array( 'name' => '$$' ) ); |
192 | | $term10 = self::$factory->tag->create( array( 'name' => '$$$' ) ); |
193 | | $term11 = self::$factory->tag->create( array( 'name' => '$$$$' ) ); |
194 | | $term12 = self::$factory->tag->create( array( 'name' => '$$$$' ) ); |
| 190 | $term8 = self::factory()->tag->create( array( 'name' => '$' ) ); |
| 191 | $term9 = self::factory()->tag->create( array( 'name' => '$$' ) ); |
| 192 | $term10 = self::factory()->tag->create( array( 'name' => '$$$' ) ); |
| 193 | $term11 = self::factory()->tag->create( array( 'name' => '$$$$' ) ); |
| 194 | $term12 = self::factory()->tag->create( array( 'name' => '$$$$' ) ); |
195 | 195 | $this->assertTrue( is_wp_error( $term12 ) ); |
196 | 196 | $this->assertNotEmpty( $term12->errors ); |
197 | 197 | $this->assertEquals( $term11, $term12->error_data['term_exists'] ); |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
199 | 199 | $terms = array_map( 'get_tag', array( $term8, $term9, $term10, $term11 ) ); |
200 | 200 | $this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) ); |
201 | 201 | |
202 | | $term13 = self::$factory->tag->create( array( 'name' => 'A' ) ); |
| 202 | $term13 = self::factory()->tag->create( array( 'name' => 'A' ) ); |
203 | 203 | $this->assertNotWPError( $term13 ); |
204 | | $term14 = self::$factory->tag->create( array( 'name' => 'A' ) ); |
| 204 | $term14 = self::factory()->tag->create( array( 'name' => 'A' ) ); |
205 | 205 | $this->assertTrue( is_wp_error( $term14 ) ); |
206 | | $term15 = self::$factory->tag->create( array( 'name' => 'A+', 'slug' => 'a' ) ); |
| 206 | $term15 = self::factory()->tag->create( array( 'name' => 'A+', 'slug' => 'a' ) ); |
207 | 207 | $this->assertNotWPError( $term15 ); |
208 | | $term16 = self::$factory->tag->create( array( 'name' => 'A+' ) ); |
| 208 | $term16 = self::factory()->tag->create( array( 'name' => 'A+' ) ); |
209 | 209 | $this->assertTrue( is_wp_error( $term16 ) ); |
210 | | $term17 = self::$factory->tag->create( array( 'name' => 'A++' ) ); |
| 210 | $term17 = self::factory()->tag->create( array( 'name' => 'A++' ) ); |
211 | 211 | $this->assertNotWPError( $term17 ); |
212 | | $term18 = self::$factory->tag->create( array( 'name' => 'A-', 'slug' => 'a' ) ); |
| 212 | $term18 = self::factory()->tag->create( array( 'name' => 'A-', 'slug' => 'a' ) ); |
213 | 213 | $this->assertNotWPError( $term18 ); |
214 | | $term19 = self::$factory->tag->create( array( 'name' => 'A-' ) ); |
| 214 | $term19 = self::factory()->tag->create( array( 'name' => 'A-' ) ); |
215 | 215 | $this->assertTrue( is_wp_error( $term19 ) ); |
216 | | $term20 = self::$factory->tag->create( array( 'name' => 'A--' ) ); |
| 216 | $term20 = self::factory()->tag->create( array( 'name' => 'A--' ) ); |
217 | 217 | $this->assertNotWPError( $term20 ); |
218 | 218 | } |
219 | 219 | |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
222 | 222 | */ |
223 | 223 | public function test_wp_insert_term_should_not_allow_duplicate_names_when_slug_is_a_duplicate_of_the_same_term_in_non_hierarchical_taxonomy() { |
224 | 224 | register_taxonomy( 'wptests_tax', 'post' ); |
225 | | $t1 = self::$factory->term->create( array( |
| 225 | $t1 = self::factory()->term->create( array( |
226 | 226 | 'name' => 'Foo', |
227 | 227 | 'slug' => 'foo', |
228 | 228 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
241 | 241 | */ |
242 | 242 | public function test_wp_insert_term_should_not_allow_duplicate_names_when_slug_is_a_duplicate_of_a_different_term_in_non_hierarchical_taxonomy() { |
243 | 243 | register_taxonomy( 'wptests_tax', 'post' ); |
244 | | $t1 = self::$factory->term->create( array( |
| 244 | $t1 = self::factory()->term->create( array( |
245 | 245 | 'name' => 'Foo', |
246 | 246 | 'slug' => 'foo', |
247 | 247 | 'taxonomy' => 'wptests_tax', |
248 | 248 | ) ); |
249 | 249 | |
250 | | $t2 = self::$factory->term->create( array( |
| 250 | $t2 = self::factory()->term->create( array( |
251 | 251 | 'name' => 'Bar', |
252 | 252 | 'slug' => 'bar', |
253 | 253 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
266 | 266 | */ |
267 | 267 | public function test_wp_insert_term_should_allow_duplicate_names_when_a_unique_slug_has_been_provided_in_non_hierarchical_taxonomy() { |
268 | 268 | register_taxonomy( 'wptests_tax', 'post' ); |
269 | | $t1 = self::$factory->term->create( array( |
| 269 | $t1 = self::factory()->term->create( array( |
270 | 270 | 'name' => 'Foo', |
271 | 271 | 'slug' => 'foo', |
272 | 272 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
288 | 288 | */ |
289 | 289 | public function test_wp_insert_term_should_not_allow_duplicate_names_when_the_slug_is_not_provided_in_non_hierarchical_taxonomy() { |
290 | 290 | register_taxonomy( 'wptests_tax', 'post' ); |
291 | | $t1 = self::$factory->term->create( array( |
| 291 | $t1 = self::factory()->term->create( array( |
292 | 292 | 'name' => 'Foo', |
293 | 293 | 'slug' => 'foo', |
294 | 294 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
305 | 305 | */ |
306 | 306 | public function test_wp_insert_term_should_not_allow_duplicate_names_when_slug_is_a_duplicate_of_the_same_term_in_hierarchical_taxonomy() { |
307 | 307 | register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); |
308 | | $t1 = self::$factory->term->create( array( |
| 308 | $t1 = self::factory()->term->create( array( |
309 | 309 | 'name' => 'Foo', |
310 | 310 | 'slug' => 'foo', |
311 | 311 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
324 | 324 | */ |
325 | 325 | public function test_wp_insert_term_should_not_allow_duplicate_names_when_slug_is_a_duplicate_of_a_different_term_at_same_hierarchy_level_in_hierarchical_taxonomy() { |
326 | 326 | register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); |
327 | | $t1 = self::$factory->term->create( array( |
| 327 | $t1 = self::factory()->term->create( array( |
328 | 328 | 'name' => 'Foo', |
329 | 329 | 'slug' => 'foo', |
330 | 330 | 'taxonomy' => 'wptests_tax', |
331 | 331 | ) ); |
332 | 332 | |
333 | | $t2 = self::$factory->term->create( array( |
| 333 | $t2 = self::factory()->term->create( array( |
334 | 334 | 'name' => 'Bar', |
335 | 335 | 'slug' => 'bar', |
336 | 336 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
349 | 349 | */ |
350 | 350 | public function test_wp_insert_term_should_allow_duplicate_names_when_slug_is_a_duplicate_of_a_term_at_different_hierarchy_level_in_hierarchical_taxonomy() { |
351 | 351 | register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); |
352 | | $t1 = self::$factory->term->create( array( |
| 352 | $t1 = self::factory()->term->create( array( |
353 | 353 | 'name' => 'Foo', |
354 | 354 | 'slug' => 'foo', |
355 | 355 | 'taxonomy' => 'wptests_tax', |
356 | 356 | ) ); |
357 | 357 | |
358 | | $t2 = self::$factory->term->create(); |
| 358 | $t2 = self::factory()->term->create(); |
359 | 359 | |
360 | | $t3 = self::$factory->term->create( array( |
| 360 | $t3 = self::factory()->term->create( array( |
361 | 361 | 'name' => 'Bar', |
362 | 362 | 'slug' => 'bar', |
363 | 363 | 'parent' => $t2, |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
381 | 381 | */ |
382 | 382 | public function test_wp_insert_term_should_allow_duplicate_names_when_a_unique_slug_has_been_provided_in_hierarchical_taxonomy() { |
383 | 383 | register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); |
384 | | $t1 = self::$factory->term->create( array( |
| 384 | $t1 = self::factory()->term->create( array( |
385 | 385 | 'name' => 'Foo', |
386 | 386 | 'slug' => 'foo', |
387 | 387 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
403 | 403 | */ |
404 | 404 | public function test_wp_insert_term_should_not_allow_duplicate_names_when_the_slug_is_not_provided_in_hierarchical_taxonomy() { |
405 | 405 | register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); |
406 | | $t1 = self::$factory->term->create( array( |
| 406 | $t1 = self::factory()->term->create( array( |
407 | 407 | 'name' => 'Foo', |
408 | 408 | 'slug' => 'foo', |
409 | 409 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
419 | 419 | */ |
420 | 420 | public function test_wp_insert_term_duplicate_slug_same_taxonomy() { |
421 | 421 | register_taxonomy( 'wptests_tax', 'post' ); |
422 | | $t = self::$factory->term->create( array( |
| 422 | $t = self::factory()->term->create( array( |
423 | 423 | 'name' => 'Foo', |
424 | 424 | 'slug' => 'foo', |
425 | 425 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
443 | 443 | public function test_wp_insert_term_duplicate_slug_different_taxonomy() { |
444 | 444 | register_taxonomy( 'wptests_tax', 'post' ); |
445 | 445 | register_taxonomy( 'wptests_tax_2', 'post' ); |
446 | | $t = self::$factory->term->create( array( |
| 446 | $t = self::factory()->term->create( array( |
447 | 447 | 'name' => 'Foo', |
448 | 448 | 'slug' => 'foo', |
449 | 449 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
473 | 473 | |
474 | 474 | register_taxonomy( 'wptests_tax', 'post' ); |
475 | 475 | register_taxonomy( 'wptests_tax_2', 'post' ); |
476 | | $t = self::$factory->term->create( array( |
| 476 | $t = self::factory()->term->create( array( |
477 | 477 | 'name' => 'Foo', |
478 | 478 | 'slug' => 'foo', |
479 | 479 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
501 | 501 | |
502 | 502 | public function test_wp_insert_term_alias_of_no_term_group() { |
503 | 503 | register_taxonomy( 'wptests_tax', 'post' ); |
504 | | $t1 = self::$factory->term->create( array( |
| 504 | $t1 = self::factory()->term->create( array( |
505 | 505 | 'taxonomy' => 'wptests_tax', |
506 | 506 | ) ); |
507 | 507 | $term_1 = get_term( $t1, 'wptests_tax' ); |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
523 | 523 | |
524 | 524 | public function test_wp_insert_term_alias_of_existing_term_group() { |
525 | 525 | register_taxonomy( 'wptests_tax', 'post' ); |
526 | | $t1 = self::$factory->term->create( array( |
| 526 | $t1 = self::factory()->term->create( array( |
527 | 527 | 'taxonomy' => 'wptests_tax', |
528 | 528 | ) ); |
529 | 529 | $term_1 = get_term( $t1, 'wptests_tax' ); |
530 | 530 | |
531 | | $t2 = self::$factory->term->create( array( |
| 531 | $t2 = self::factory()->term->create( array( |
532 | 532 | 'taxonomy' => 'wptests_tax', |
533 | 533 | 'alias_of' => $term_1->slug, |
534 | 534 | ) ); |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
591 | 591 | 'hierarchical' => true, |
592 | 592 | ) ); |
593 | 593 | |
594 | | $t = self::$factory->term->create( array( |
| 594 | $t = self::factory()->term->create( array( |
595 | 595 | 'taxonomy' => 'wptests_tax', |
596 | 596 | ) ); |
597 | 597 | |
… |
… |
class Tests_Term_WpInsertTerm extends WP_UnitTestCase { |
623 | 623 | public function test_wp_insert_term_with_and_without_accents() { |
624 | 624 | register_taxonomy( 'wptests_tax', 'post' ); |
625 | 625 | |
626 | | $t1 = self::$factory->term->create( array( |
| 626 | $t1 = self::factory()->term->create( array( |
627 | 627 | 'name' => 'Foó', |
628 | 628 | 'taxonomy' => 'wptests_tax', |
629 | 629 | ) ); |
630 | | $t2 = self::$factory->term->create( array( |
| 630 | $t2 = self::factory()->term->create( array( |
631 | 631 | 'name' => 'Foo', |
632 | 632 | 'taxonomy' => 'wptests_tax', |
633 | 633 | ) ); |
-
diff --git tests/phpunit/tests/term/wpUniqueTermSlug.php tests/phpunit/tests/term/wpUniqueTermSlug.php
index 98bca8a..2d5291c 100644
|
|
class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { |
11 | 11 | } |
12 | 12 | |
13 | 13 | public function test_unique_slug_should_be_unchanged() { |
14 | | $term = self::$factory->term->create_and_get( array( |
| 14 | $term = self::factory()->term->create_and_get( array( |
15 | 15 | 'taxonomy' => 'wptests_tax1', |
16 | 16 | 'name' => 'foo', |
17 | 17 | 'slug' => 'foo', |
… |
… |
class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { |
22 | 22 | } |
23 | 23 | |
24 | 24 | public function test_nonunique_slug_in_different_taxonomy_should_be_unchanged() { |
25 | | $term1 = self::$factory->term->create( array( |
| 25 | $term1 = self::factory()->term->create( array( |
26 | 26 | 'taxonomy' => 'wptests_tax2', |
27 | 27 | 'name' => 'bar', |
28 | 28 | 'slug' => 'bar', |
29 | 29 | ) ); |
30 | 30 | |
31 | | $term2 = self::$factory->term->create( array( |
| 31 | $term2 = self::factory()->term->create( array( |
32 | 32 | 'taxonomy' => 'wptests_tax1', |
33 | 33 | 'name' => 'foo', |
34 | 34 | 'slug' => 'foo', |
… |
… |
class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { |
40 | 40 | } |
41 | 41 | |
42 | 42 | public function test_nonunique_slug_in_same_nonhierarchical_taxonomy_should_be_changed() { |
43 | | $term1 = self::$factory->term->create( array( |
| 43 | $term1 = self::factory()->term->create( array( |
44 | 44 | 'taxonomy' => 'wptests_tax1', |
45 | 45 | 'name' => 'bar', |
46 | 46 | 'slug' => 'bar', |
47 | 47 | ) ); |
48 | 48 | |
49 | | $term2 = self::$factory->term->create( array( |
| 49 | $term2 = self::factory()->term->create( array( |
50 | 50 | 'taxonomy' => 'wptests_tax1', |
51 | 51 | 'name' => 'foo', |
52 | 52 | 'slug' => 'foo', |
… |
… |
class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { |
58 | 58 | } |
59 | 59 | |
60 | 60 | public function test_nonunique_slug_in_same_hierarchical_taxonomy_with_same_parent_should_be_suffixed_with_parent_slug() { |
61 | | $parent = self::$factory->term->create( array( |
| 61 | $parent = self::factory()->term->create( array( |
62 | 62 | 'taxonomy' => 'wptests_tax2', |
63 | 63 | 'slug' => 'parent-term', |
64 | 64 | ) ); |
65 | 65 | |
66 | | $term1 = self::$factory->term->create( array( |
| 66 | $term1 = self::factory()->term->create( array( |
67 | 67 | 'taxonomy' => 'wptests_tax2', |
68 | 68 | 'name' => 'bar', |
69 | 69 | 'slug' => 'bar', |
70 | 70 | 'parent' => $parent, |
71 | 71 | ) ); |
72 | 72 | |
73 | | $term2 = self::$factory->term->create( array( |
| 73 | $term2 = self::factory()->term->create( array( |
74 | 74 | 'taxonomy' => 'wptests_tax2', |
75 | 75 | 'name' => 'foo', |
76 | 76 | 'slug' => 'foo', |
… |
… |
class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { |
83 | 83 | } |
84 | 84 | |
85 | 85 | public function test_nonunique_slug_in_same_hierarchical_taxonomy_at_different_level_of_hierarchy_should_be_suffixed_with_number() { |
86 | | $parent = self::$factory->term->create( array( |
| 86 | $parent = self::factory()->term->create( array( |
87 | 87 | 'taxonomy' => 'wptests_tax2', |
88 | 88 | 'slug' => 'parent-term', |
89 | 89 | ) ); |
90 | 90 | |
91 | | $term1 = self::$factory->term->create( array( |
| 91 | $term1 = self::factory()->term->create( array( |
92 | 92 | 'taxonomy' => 'wptests_tax2', |
93 | 93 | 'name' => 'bar', |
94 | 94 | 'slug' => 'bar', |
95 | 95 | 'parent' => $parent, |
96 | 96 | ) ); |
97 | 97 | |
98 | | $term2 = self::$factory->term->create( array( |
| 98 | $term2 = self::factory()->term->create( array( |
99 | 99 | 'taxonomy' => 'wptests_tax2', |
100 | 100 | 'name' => 'foo', |
101 | 101 | 'slug' => 'foo', |
-
diff --git tests/phpunit/tests/term/wpUpdateTerm.php tests/phpunit/tests/term/wpUpdateTerm.php
index 047fa9a..4d9d17b 100644
|
|
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
20 | 20 | |
21 | 21 | public function test_wp_update_term_unslash_name() { |
22 | 22 | register_taxonomy( 'wptests_tax', 'post' ); |
23 | | $t = self::$factory->term->create( array( |
| 23 | $t = self::factory()->term->create( array( |
24 | 24 | 'taxonomy' => 'wptests_tax', |
25 | 25 | ) ); |
26 | 26 | |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
36 | 36 | |
37 | 37 | public function test_wp_update_term_unslash_description() { |
38 | 38 | register_taxonomy( 'wptests_tax', 'post' ); |
39 | | $t = self::$factory->term->create( array( |
| 39 | $t = self::factory()->term->create( array( |
40 | 40 | 'taxonomy' => 'wptests_tax', |
41 | 41 | ) ); |
42 | 42 | |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
52 | 52 | |
53 | 53 | public function test_wp_update_term_name_empty_string() { |
54 | 54 | register_taxonomy( 'wptests_tax', 'post' ); |
55 | | $t = self::$factory->term->create( array( |
| 55 | $t = self::factory()->term->create( array( |
56 | 56 | 'taxonomy' => 'wptests_tax', |
57 | 57 | ) ); |
58 | 58 | |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
76 | 76 | |
77 | 77 | $this->assertNull( term_exists( $fake_term_id, 'wptests_tax' ) ); |
78 | 78 | |
79 | | $t = self::$factory->term->create( array( |
| 79 | $t = self::factory()->term->create( array( |
80 | 80 | 'taxonomy' => 'wptests_tax', |
81 | 81 | ) ); |
82 | 82 | |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
94 | 94 | |
95 | 95 | public function test_wp_update_term_slug_empty_string_while_not_updating_name() { |
96 | 96 | register_taxonomy( 'wptests_tax', 'post' ); |
97 | | $t = self::$factory->term->create( array( |
| 97 | $t = self::factory()->term->create( array( |
98 | 98 | 'taxonomy' => 'wptests_tax', |
99 | 99 | 'name' => 'Foo Bar', |
100 | 100 | ) ); |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
110 | 110 | |
111 | 111 | public function test_wp_update_term_slug_empty_string_while_updating_name() { |
112 | 112 | register_taxonomy( 'wptests_tax', 'post' ); |
113 | | $t = self::$factory->term->create( array( |
| 113 | $t = self::factory()->term->create( array( |
114 | 114 | 'taxonomy' => 'wptests_tax', |
115 | 115 | ) ); |
116 | 116 | |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
126 | 126 | |
127 | 127 | public function test_wp_update_term_slug_set_slug() { |
128 | 128 | register_taxonomy( 'wptests_tax', 'post' ); |
129 | | $t = self::$factory->term->create( array( |
| 129 | $t = self::factory()->term->create( array( |
130 | 130 | 'taxonomy' => 'wptests_tax', |
131 | 131 | ) ); |
132 | 132 | |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
145 | 145 | public function test_wp_update_term_should_not_create_duplicate_slugs_within_the_same_taxonomy() { |
146 | 146 | register_taxonomy( 'wptests_tax', 'post' ); |
147 | 147 | |
148 | | $t1 = self::$factory->term->create( array( |
| 148 | $t1 = self::factory()->term->create( array( |
149 | 149 | 'name' => 'Foo', |
150 | 150 | 'slug' => 'foo', |
151 | 151 | 'taxonomy' => 'wptests_tax', |
152 | 152 | ) ); |
153 | 153 | |
154 | | $t2 = self::$factory->term->create( array( |
| 154 | $t2 = self::factory()->term->create( array( |
155 | 155 | 'name' => 'Bar', |
156 | 156 | 'slug' => 'bar', |
157 | 157 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
172 | 172 | register_taxonomy( 'wptests_tax', 'post' ); |
173 | 173 | register_taxonomy( 'wptests_tax_2', 'post' ); |
174 | 174 | |
175 | | $t1 = self::$factory->term->create( array( |
| 175 | $t1 = self::factory()->term->create( array( |
176 | 176 | 'name' => 'Foo', |
177 | 177 | 'slug' => 'foo', |
178 | 178 | 'taxonomy' => 'wptests_tax', |
179 | 179 | ) ); |
180 | 180 | |
181 | | $t2 = self::$factory->term->create( array( |
| 181 | $t2 = self::factory()->term->create( array( |
182 | 182 | 'name' => 'Foo', |
183 | 183 | 'slug' => 'bar', |
184 | 184 | 'taxonomy' => 'wptests_tax_2', |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
202 | 202 | register_taxonomy( 'wptests_tax', 'post' ); |
203 | 203 | register_taxonomy( 'wptests_tax_2', 'post' ); |
204 | 204 | |
205 | | $t1 = self::$factory->term->create( array( |
| 205 | $t1 = self::factory()->term->create( array( |
206 | 206 | 'name' => 'Foo', |
207 | 207 | 'slug' => 'foo', |
208 | 208 | 'taxonomy' => 'wptests_tax', |
209 | 209 | ) ); |
210 | 210 | |
211 | | $t2 = self::$factory->term->create( array( |
| 211 | $t2 = self::factory()->term->create( array( |
212 | 212 | 'name' => 'Bar', |
213 | 213 | 'slug' => 'bar', |
214 | 214 | 'taxonomy' => 'wptests_tax_2', |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
232 | 232 | 'hierarchical' => true, |
233 | 233 | ) ); |
234 | 234 | |
235 | | $t1 = self::$factory->term->create( array( |
| 235 | $t1 = self::factory()->term->create( array( |
236 | 236 | 'name' => 'Foo', |
237 | 237 | 'slug' => 'foo', |
238 | 238 | 'taxonomy' => 'wptests_tax', |
239 | 239 | ) ); |
240 | 240 | |
241 | | $t2 = self::$factory->term->create( array( |
| 241 | $t2 = self::factory()->term->create( array( |
242 | 242 | 'name' => 'Bar', |
243 | 243 | 'slug' => 'bar', |
244 | 244 | 'taxonomy' => 'wptests_tax', |
245 | 245 | 'parent' => $t1, |
246 | 246 | ) ); |
247 | 247 | |
248 | | $t3 = self::$factory->term->create( array( |
| 248 | $t3 = self::factory()->term->create( array( |
249 | 249 | 'name' => 'Bar Child', |
250 | 250 | 'slug' => 'bar-child', |
251 | 251 | 'taxonomy' => 'wptests_tax', |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
282 | 282 | array( '%d' ) |
283 | 283 | ); |
284 | 284 | |
285 | | $posts = self::$factory->post->create_many( 2 ); |
| 285 | $posts = self::factory()->post->create_many( 2 ); |
286 | 286 | wp_set_object_terms( $posts[0], array( 'Foo' ), 'wptests_tax' ); |
287 | 287 | wp_set_object_terms( $posts[1], array( 'Foo' ), 'wptests_tax_2' ); |
288 | 288 | |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
302 | 302 | |
303 | 303 | public function test_wp_update_term_alias_of_no_term_group() { |
304 | 304 | register_taxonomy( 'wptests_tax', 'post' ); |
305 | | $t1 = self::$factory->term->create( array( |
| 305 | $t1 = self::factory()->term->create( array( |
306 | 306 | 'taxonomy' => 'wptests_tax', |
307 | 307 | ) ); |
308 | 308 | $term_1 = get_term( $t1, 'wptests_tax' ); |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
323 | 323 | |
324 | 324 | public function test_wp_update_term_alias_of_existing_term_group() { |
325 | 325 | register_taxonomy( 'wptests_tax', 'post' ); |
326 | | $t1 = self::$factory->term->create( array( |
| 326 | $t1 = self::factory()->term->create( array( |
327 | 327 | 'taxonomy' => 'wptests_tax', |
328 | 328 | ) ); |
329 | 329 | $term_1 = get_term( $t1, 'wptests_tax' ); |
330 | 330 | |
331 | | $t2 = self::$factory->term->create( array( |
| 331 | $t2 = self::factory()->term->create( array( |
332 | 332 | 'taxonomy' => 'wptests_tax', |
333 | 333 | 'alias_of' => $term_1->slug, |
334 | 334 | ) ); |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
359 | 359 | |
360 | 360 | public function test_wp_update_term_slug_same_as_old_slug() { |
361 | 361 | register_taxonomy( 'wptests_tax', 'post' ); |
362 | | $t = self::$factory->term->create( array( |
| 362 | $t = self::factory()->term->create( array( |
363 | 363 | 'taxonomy' => 'wptests_tax', |
364 | 364 | 'slug' => 'foo', |
365 | 365 | ) ); |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
377 | 377 | |
378 | 378 | public function test_wp_update_term_duplicate_slug_generated_due_to_empty_slug_param() { |
379 | 379 | register_taxonomy( 'wptests_tax', 'post' ); |
380 | | $t1 = self::$factory->term->create( array( |
| 380 | $t1 = self::factory()->term->create( array( |
381 | 381 | 'taxonomy' => 'wptests_tax', |
382 | 382 | 'slug' => 'foo-bar', |
383 | 383 | ) ); |
384 | | $t2 = self::$factory->term->create( array( |
| 384 | $t2 = self::factory()->term->create( array( |
385 | 385 | 'taxonomy' => 'wptests_tax', |
386 | 386 | 'name' => 'not foo bar', |
387 | 387 | ) ); |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
402 | 402 | register_taxonomy( 'wptests_tax', 'post', array( |
403 | 403 | 'hierarchical' => true, |
404 | 404 | ) ); |
405 | | $p = self::$factory->term->create( array( |
| 405 | $p = self::factory()->term->create( array( |
406 | 406 | 'taxonomy' => 'wptests_tax', |
407 | 407 | ) ); |
408 | | $t1 = self::$factory->term->create( array( |
| 408 | $t1 = self::factory()->term->create( array( |
409 | 409 | 'taxonomy' => 'wptests_tax', |
410 | 410 | 'slug' => 'foo-bar', |
411 | 411 | ) ); |
412 | | $t2 = self::$factory->term->create( array( |
| 412 | $t2 = self::factory()->term->create( array( |
413 | 413 | 'taxonomy' => 'wptests_tax', |
414 | 414 | ) ); |
415 | 415 | |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
428 | 428 | |
429 | 429 | public function test_wp_update_term_duplicate_slug_failure() { |
430 | 430 | register_taxonomy( 'wptests_tax', 'post' ); |
431 | | $t1 = self::$factory->term->create( array( |
| 431 | $t1 = self::factory()->term->create( array( |
432 | 432 | 'taxonomy' => 'wptests_tax', |
433 | 433 | 'slug' => 'foo-bar', |
434 | 434 | ) ); |
435 | | $t2 = self::$factory->term->create( array( |
| 435 | $t2 = self::factory()->term->create( array( |
436 | 436 | 'taxonomy' => 'wptests_tax', |
437 | 437 | 'slug' => 'my-old-slug', |
438 | 438 | ) ); |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
451 | 451 | |
452 | 452 | public function test_wp_update_term_should_return_term_id_and_term_taxonomy_id() { |
453 | 453 | register_taxonomy( 'wptests_tax', 'post' ); |
454 | | $t = self::$factory->term->create( array( |
| 454 | $t = self::factory()->term->create( array( |
455 | 455 | 'taxonomy' => 'wptests_tax', |
456 | 456 | ) ); |
457 | 457 | $found = wp_update_term( $t, 'wptests_tax', array( |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
477 | 477 | */ |
478 | 478 | public function test_wp_update_term_should_return_int_values_for_term_id_and_term_taxonomy_id() { |
479 | 479 | register_taxonomy( 'wptests_tax', 'post' ); |
480 | | $t = self::$factory->term->create( array( |
| 480 | $t = self::factory()->term->create( array( |
481 | 481 | 'taxonomy' => 'wptests_tax', |
482 | 482 | ) ); |
483 | 483 | $found = wp_update_term( $t, 'wptests_tax', array( |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
491 | 491 | public function test_wp_update_term_should_clean_object_term_cache() { |
492 | 492 | register_taxonomy( 'wptests_tax_for_post', 'post' ); |
493 | 493 | register_taxonomy( 'wptests_tax_for_page', 'page' ); |
494 | | $post = self::$factory->post->create(); |
495 | | $page = self::$factory->post->create( array( |
| 494 | $post = self::factory()->post->create(); |
| 495 | $page = self::factory()->post->create( array( |
496 | 496 | 'post_type' => 'page', |
497 | 497 | ) ); |
498 | 498 | |
499 | | $t_for_post = self::$factory->term->create( array( |
| 499 | $t_for_post = self::factory()->term->create( array( |
500 | 500 | 'taxonomy' => 'wptests_tax_for_post', |
501 | 501 | ) ); |
502 | | $t_for_page = self::$factory->term->create( array( |
| 502 | $t_for_page = self::factory()->term->create( array( |
503 | 503 | 'taxonomy' => 'wptests_tax_for_page', |
504 | 504 | ) ); |
505 | 505 | |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
527 | 527 | 'hierarchical' => true, |
528 | 528 | ) ); |
529 | 529 | |
530 | | $t1 = self::$factory->term->create( array( |
| 530 | $t1 = self::factory()->term->create( array( |
531 | 531 | 'taxonomy' => 'wptests_tax', |
532 | 532 | ) ); |
533 | | $t2 = self::$factory->term->create( array( |
| 533 | $t2 = self::factory()->term->create( array( |
534 | 534 | 'taxonomy' => 'wptests_tax', |
535 | 535 | ) ); |
536 | 536 | |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
567 | 567 | 'hierarchical' => true, |
568 | 568 | ) ); |
569 | 569 | |
570 | | $t1 = self::$factory->term->create( array( |
| 570 | $t1 = self::factory()->term->create( array( |
571 | 571 | 'taxonomy' => 'wptests_tax', |
572 | 572 | 'slug' => 'parent-term', |
573 | 573 | ) ); |
574 | 574 | |
575 | | $t2 = self::$factory->term->create( array( |
| 575 | $t2 = self::factory()->term->create( array( |
576 | 576 | 'taxonomy' => 'wptests_tax', |
577 | 577 | 'slug' => 'foo', |
578 | 578 | ) ); |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
599 | 599 | 'hierarchical' => true, |
600 | 600 | ) ); |
601 | 601 | |
602 | | $t1 = self::$factory->term->create( array( |
| 602 | $t1 = self::factory()->term->create( array( |
603 | 603 | 'taxonomy' => 'wptests_tax', |
604 | 604 | 'slug' => 'parent-term', |
605 | 605 | ) ); |
606 | 606 | |
607 | 607 | // Same slug but in a different tax. |
608 | | $t2 = self::$factory->term->create( array( |
| 608 | $t2 = self::factory()->term->create( array( |
609 | 609 | 'taxonomy' => 'wptests_tax_2', |
610 | 610 | 'slug' => 'foo', |
611 | 611 | ) ); |
612 | 612 | |
613 | | $t3 = self::$factory->term->create( array( |
| 613 | $t3 = self::factory()->term->create( array( |
614 | 614 | 'taxonomy' => 'wptests_tax', |
615 | 615 | 'slug' => 'foo', |
616 | 616 | ) ); |
… |
… |
class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { |
630 | 630 | * @ticket 31954 |
631 | 631 | */ |
632 | 632 | public function test_wp_update_term_with_null_get_term() { |
633 | | $t = self::$factory->term->create( array( 'taxonomy' => 'category' ) ); |
| 633 | $t = self::factory()->term->create( array( 'taxonomy' => 'category' ) ); |
634 | 634 | $found = wp_update_term( $t, 'post_tag', array( 'slug' => 'foo' ) ); |
635 | 635 | |
636 | 636 | $this->assertWPError( $found ); |
-
diff --git tests/phpunit/tests/url.php tests/phpunit/tests/url.php
index baae9d6..3c3c19a 100644
|
|
class Tests_URL extends WP_UnitTestCase { |
272 | 272 | |
273 | 273 | public function test_get_adjacent_post() { |
274 | 274 | $now = time(); |
275 | | $post_id = self::$factory->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); |
276 | | $post_id2 = self::$factory->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); |
| 275 | $post_id = self::factory()->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); |
| 276 | $post_id2 = self::factory()->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); |
277 | 277 | |
278 | 278 | if ( ! isset( $GLOBALS['post'] ) ) |
279 | 279 | $GLOBALS['post'] = null; |
… |
… |
class Tests_URL extends WP_UnitTestCase { |
305 | 305 | * @ticket 30287 |
306 | 306 | */ |
307 | 307 | public function test_get_adjacent_post_should_return_private_posts_belonging_to_the_current_user() { |
308 | | $u = self::$factory->user->create( array( 'role' => 'author' ) ); |
| 308 | $u = self::factory()->user->create( array( 'role' => 'author' ) ); |
309 | 309 | $old_uid = get_current_user_id(); |
310 | 310 | wp_set_current_user( $u ); |
311 | 311 | |
312 | 312 | $now = time(); |
313 | | $p1 = self::$factory->post->create( array( 'post_author' => $u, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); |
314 | | $p2 = self::$factory->post->create( array( 'post_author' => $u, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); |
| 313 | $p1 = self::factory()->post->create( array( 'post_author' => $u, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); |
| 314 | $p2 = self::factory()->post->create( array( 'post_author' => $u, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); |
315 | 315 | |
316 | 316 | if ( ! isset( $GLOBALS['post'] ) ) { |
317 | 317 | $GLOBALS['post'] = null; |
… |
… |
class Tests_URL extends WP_UnitTestCase { |
331 | 331 | * @ticket 30287 |
332 | 332 | */ |
333 | 333 | public function test_get_adjacent_post_should_return_private_posts_belonging_to_other_users_if_the_current_user_can_read_private_posts() { |
334 | | $u1 = self::$factory->user->create( array( 'role' => 'author' ) ); |
335 | | $u2 = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 334 | $u1 = self::factory()->user->create( array( 'role' => 'author' ) ); |
| 335 | $u2 = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
336 | 336 | $old_uid = get_current_user_id(); |
337 | 337 | wp_set_current_user( $u2 ); |
338 | 338 | |
339 | 339 | $now = time(); |
340 | | $p1 = self::$factory->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); |
341 | | $p2 = self::$factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); |
| 340 | $p1 = self::factory()->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); |
| 341 | $p2 = self::factory()->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); |
342 | 342 | |
343 | 343 | if ( ! isset( $GLOBALS['post'] ) ) { |
344 | 344 | $GLOBALS['post'] = null; |
… |
… |
class Tests_URL extends WP_UnitTestCase { |
358 | 358 | * @ticket 30287 |
359 | 359 | */ |
360 | 360 | public function test_get_adjacent_post_should_not_return_private_posts_belonging_to_other_users_if_the_current_user_cannot_read_private_posts() { |
361 | | $u1 = self::$factory->user->create( array( 'role' => 'author' ) ); |
362 | | $u2 = self::$factory->user->create( array( 'role' => 'author' ) ); |
| 361 | $u1 = self::factory()->user->create( array( 'role' => 'author' ) ); |
| 362 | $u2 = self::factory()->user->create( array( 'role' => 'author' ) ); |
363 | 363 | $old_uid = get_current_user_id(); |
364 | 364 | wp_set_current_user( $u2 ); |
365 | 365 | |
366 | 366 | $now = time(); |
367 | | $p1 = self::$factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now - 2 ) ) ); |
368 | | $p2 = self::$factory->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); |
369 | | $p3 = self::$factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); |
| 367 | $p1 = self::factory()->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now - 2 ) ) ); |
| 368 | $p2 = self::factory()->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) ); |
| 369 | $p3 = self::factory()->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) ); |
370 | 370 | |
371 | 371 | if ( ! isset( $GLOBALS['post'] ) ) { |
372 | 372 | $GLOBALS['post'] = null; |
-
diff --git tests/phpunit/tests/user.php tests/phpunit/tests/user.php
index 07bbabd..82c99ef 100644
|
|
class Tests_User extends WP_UnitTestCase { |
43 | 43 | // add one of each user role |
44 | 44 | $nusers = array(); |
45 | 45 | foreach ( array('administrator', 'editor', 'author', 'contributor', 'subscriber' ) as $role ) { |
46 | | $id = self::$factory->user->create( array( 'role' => $role ) ); |
| 46 | $id = self::factory()->user->create( array( 'role' => $role ) ); |
47 | 47 | $nusers[ $id ] = $id; |
48 | 48 | } |
49 | 49 | |
… |
… |
class Tests_User extends WP_UnitTestCase { |
244 | 244 | ); |
245 | 245 | |
246 | 246 | foreach ( $roles as $role => $level ) { |
247 | | $user_id = self::$factory->user->create( array( 'role' => $role ) ); |
| 247 | $user_id = self::factory()->user->create( array( 'role' => $role ) ); |
248 | 248 | $user = new WP_User( $user_id ); |
249 | 249 | |
250 | 250 | $this->assertTrue( isset( $user->user_level ) ); |
… |
… |
class Tests_User extends WP_UnitTestCase { |
292 | 292 | } |
293 | 293 | |
294 | 294 | function test_get() { |
295 | | $user_id = self::$factory->user->create( array( |
| 295 | $user_id = self::factory()->user->create( array( |
296 | 296 | 'role' => 'author', |
297 | 297 | 'user_login' => 'test_wp_user_get', |
298 | 298 | 'user_pass' => 'password', |
… |
… |
class Tests_User extends WP_UnitTestCase { |
310 | 310 | } |
311 | 311 | |
312 | 312 | function test_has_prop() { |
313 | | $user_id = self::$factory->user->create( array( |
| 313 | $user_id = self::factory()->user->create( array( |
314 | 314 | 'role' => 'author', |
315 | 315 | 'user_login' => 'test_wp_user_has_prop', |
316 | 316 | 'user_pass' => 'password', |
… |
… |
class Tests_User extends WP_UnitTestCase { |
327 | 327 | } |
328 | 328 | |
329 | 329 | function test_update_user() { |
330 | | $user_id = self::$factory->user->create( array( |
| 330 | $user_id = self::factory()->user->create( array( |
331 | 331 | 'role' => 'author', |
332 | 332 | 'user_login' => 'test_wp_update_user', |
333 | 333 | 'user_pass' => 'password', |
… |
… |
class Tests_User extends WP_UnitTestCase { |
383 | 383 | function test_global_userdata() { |
384 | 384 | global $userdata, $wpdb; |
385 | 385 | |
386 | | $user_id = self::$factory->user->create( array( 'role' => 'subscriber' ) ); |
| 386 | $user_id = self::factory()->user->create( array( 'role' => 'subscriber' ) ); |
387 | 387 | wp_set_current_user( $user_id ); |
388 | 388 | |
389 | 389 | $this->assertNotEmpty( $userdata ); |
… |
… |
class Tests_User extends WP_UnitTestCase { |
497 | 497 | * @ticket 21431 |
498 | 498 | */ |
499 | 499 | function test_count_many_users_posts() { |
500 | | $user_id_a = self::$factory->user->create( array( 'role' => 'author' ) ); |
501 | | $user_id_b = self::$factory->user->create( array( 'role' => 'author' ) ); |
502 | | $post_id_a = self::$factory->post->create( array( 'post_author' => $user_id_a ) ); |
503 | | $post_id_b = self::$factory->post->create( array( 'post_author' => $user_id_b ) ); |
504 | | $post_id_c = self::$factory->post->create( array( 'post_author' => $user_id_b, 'post_status' => 'private' ) ); |
| 500 | $user_id_a = self::factory()->user->create( array( 'role' => 'author' ) ); |
| 501 | $user_id_b = self::factory()->user->create( array( 'role' => 'author' ) ); |
| 502 | $post_id_a = self::factory()->post->create( array( 'post_author' => $user_id_a ) ); |
| 503 | $post_id_b = self::factory()->post->create( array( 'post_author' => $user_id_b ) ); |
| 504 | $post_id_c = self::factory()->post->create( array( 'post_author' => $user_id_b, 'post_status' => 'private' ) ); |
505 | 505 | |
506 | 506 | wp_set_current_user( $user_id_a ); |
507 | 507 | $counts = count_many_users_posts( array( $user_id_a, $user_id_b), 'post', false ); |
… |
… |
class Tests_User extends WP_UnitTestCase { |
771 | 771 | * @ticket 33793 |
772 | 772 | */ |
773 | 773 | public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename() { |
774 | | $u1 = self::$factory->user->create( array( |
| 774 | $u1 = self::factory()->user->create( array( |
775 | 775 | 'user_nicename' => str_repeat( 'a', 50 ), |
776 | 776 | ) ); |
777 | 777 | |
… |
… |
class Tests_User extends WP_UnitTestCase { |
792 | 792 | * @ticket 33793 |
793 | 793 | */ |
794 | 794 | public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename_when_suffix_has_more_than_one_character() { |
795 | | $users = self::$factory->user->create_many( 4, array( |
| 795 | $users = self::factory()->user->create_many( 4, array( |
796 | 796 | 'user_nicename' => str_repeat( 'a', 50 ), |
797 | 797 | ) ); |
798 | 798 | |
… |
… |
class Tests_User extends WP_UnitTestCase { |
876 | 876 | */ |
877 | 877 | function test_email_case() { |
878 | 878 | // Create a test user with a lower-case email address. |
879 | | $user_id = self::$factory->user->create( array( |
| 879 | $user_id = self::factory()->user->create( array( |
880 | 880 | 'user_email' => 'test@test.com', |
881 | 881 | ) ); |
882 | 882 | |
… |
… |
class Tests_User extends WP_UnitTestCase { |
895 | 895 | */ |
896 | 896 | function test_email_change() { |
897 | 897 | // Create a test user. |
898 | | $user_id = self::$factory->user->create( array( |
| 898 | $user_id = self::factory()->user->create( array( |
899 | 899 | 'user_email' => 'test@test.com', |
900 | 900 | ) ); |
901 | 901 | |
… |
… |
class Tests_User extends WP_UnitTestCase { |
983 | 983 | * @expectedDeprecated wp_new_user_notification |
984 | 984 | */ |
985 | 985 | function test_wp_new_user_notification_old_signature_throws_deprecated_warning() { |
986 | | $user = self::$factory->user->create( array( |
| 986 | $user = self::factory()->user->create( array( |
987 | 987 | 'role' => 'author', |
988 | 988 | 'user_login' => 'test_wp_new_user_notification', |
989 | 989 | 'user_pass' => 'password', |
-
diff --git tests/phpunit/tests/user/author.php tests/phpunit/tests/user/author.php
index d236d2a..73ae3b6 100644
|
|
class Tests_User_Author_Template extends WP_UnitTestCase { |
15 | 15 | function setUp() { |
16 | 16 | parent::setUp(); |
17 | 17 | |
18 | | $this->author_id = self::$factory->user->create( array( |
| 18 | $this->author_id = self::factory()->user->create( array( |
19 | 19 | 'role' => 'author', |
20 | 20 | 'user_login' => 'test_author', |
21 | 21 | 'description' => 'test_author', |
… |
… |
class Tests_User_Author_Template extends WP_UnitTestCase { |
31 | 31 | ); |
32 | 32 | |
33 | 33 | // insert a post and make sure the ID is ok |
34 | | $this->post_id = self::$factory->post->create( $post ); |
| 34 | $this->post_id = self::factory()->post->create( $post ); |
35 | 35 | |
36 | 36 | setup_postdata( get_post( $this->post_id ) ); |
37 | 37 | } |
… |
… |
class Tests_User_Author_Template extends WP_UnitTestCase { |
90 | 90 | function test_get_the_author_posts_with_custom_post_type() { |
91 | 91 | register_post_type( 'wptests_pt' ); |
92 | 92 | |
93 | | $cpt_ids = self::$factory->post->create_many( 2, array( |
| 93 | $cpt_ids = self::factory()->post->create_many( 2, array( |
94 | 94 | 'post_author' => $this->author_id, |
95 | 95 | 'post_type' => 'wptests_pt', |
96 | 96 | ) ); |
… |
… |
class Tests_User_Author_Template extends WP_UnitTestCase { |
105 | 105 | * @ticket 30355 |
106 | 106 | */ |
107 | 107 | public function test_get_the_author_posts_link_no_permalinks() { |
108 | | $author = self::$factory->user->create_and_get( array( |
| 108 | $author = self::factory()->user->create_and_get( array( |
109 | 109 | 'display_name' => 'Foo', |
110 | 110 | 'user_nicename' => 'bar' |
111 | 111 | ) ); |
… |
… |
class Tests_User_Author_Template extends WP_UnitTestCase { |
129 | 129 | public function test_get_the_author_posts_link_with_permalinks() { |
130 | 130 | $this->set_permalink_structure( '/%postname%/' ); |
131 | 131 | |
132 | | $author = self::$factory->user->create_and_get( array( |
| 132 | $author = self::factory()->user->create_and_get( array( |
133 | 133 | 'display_name' => 'Foo', |
134 | 134 | 'user_nicename' => 'bar' |
135 | 135 | ) ); |
-
diff --git tests/phpunit/tests/user/capabilities.php tests/phpunit/tests/user/capabilities.php
index 0d1960b..99b0c56 100644
|
|
class Tests_User_Capabilities extends WP_UnitTestCase { |
222 | 222 | // test the default roles and caps |
223 | 223 | function test_all_roles_and_caps() { |
224 | 224 | $users = array( |
225 | | 'administrator' => self::$factory->user->create_and_get( array( 'role' => 'administrator' ) ), |
226 | | 'editor' => self::$factory->user->create_and_get( array( 'role' => 'editor' ) ), |
227 | | 'author' => self::$factory->user->create_and_get( array( 'role' => 'author' ) ), |
228 | | 'contributor' => self::$factory->user->create_and_get( array( 'role' => 'contributor' ) ), |
229 | | 'subscriber' => self::$factory->user->create_and_get( array( 'role' => 'subscriber' ) ), |
| 225 | 'administrator' => self::factory()->user->create_and_get( array( 'role' => 'administrator' ) ), |
| 226 | 'editor' => self::factory()->user->create_and_get( array( 'role' => 'editor' ) ), |
| 227 | 'author' => self::factory()->user->create_and_get( array( 'role' => 'author' ) ), |
| 228 | 'contributor' => self::factory()->user->create_and_get( array( 'role' => 'contributor' ) ), |
| 229 | 'subscriber' => self::factory()->user->create_and_get( array( 'role' => 'subscriber' ) ), |
230 | 230 | ); |
231 | 231 | $caps = $this->getCapsAndRoles(); |
232 | 232 | |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
258 | 258 | // special case for the link manager |
259 | 259 | function test_link_manager_caps() { |
260 | 260 | $users = array( |
261 | | 'administrator' => self::$factory->user->create_and_get( array( 'role' => 'administrator' ) ), |
262 | | 'editor' => self::$factory->user->create_and_get( array( 'role' => 'editor' ) ), |
263 | | 'author' => self::$factory->user->create_and_get( array( 'role' => 'author' ) ), |
264 | | 'contributor' => self::$factory->user->create_and_get( array( 'role' => 'contributor' ) ), |
265 | | 'subscriber' => self::$factory->user->create_and_get( array( 'role' => 'subscriber' ) ), |
| 261 | 'administrator' => self::factory()->user->create_and_get( array( 'role' => 'administrator' ) ), |
| 262 | 'editor' => self::factory()->user->create_and_get( array( 'role' => 'editor' ) ), |
| 263 | 'author' => self::factory()->user->create_and_get( array( 'role' => 'author' ) ), |
| 264 | 'contributor' => self::factory()->user->create_and_get( array( 'role' => 'contributor' ) ), |
| 265 | 'subscriber' => self::factory()->user->create_and_get( array( 'role' => 'subscriber' ) ), |
266 | 266 | ); |
267 | 267 | $caps = array( |
268 | 268 | 'manage_links' => array( 'administrator', 'editor' ), |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
305 | 305 | } |
306 | 306 | $caps = $this->getCapsAndRoles(); |
307 | 307 | |
308 | | $user = self::$factory->user->create_and_get( array( 'role' => 'administrator' ) ); |
| 308 | $user = self::factory()->user->create_and_get( array( 'role' => 'administrator' ) ); |
309 | 309 | grant_super_admin( $user->ID ); |
310 | 310 | |
311 | 311 | $this->assertTrue( is_super_admin( $user->ID ) ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
321 | 321 | |
322 | 322 | // a role that doesn't exist |
323 | 323 | function test_bogus_role() { |
324 | | $user = self::$factory->user->create_and_get( array( 'role' => 'invalid_role' ) ); |
| 324 | $user = self::factory()->user->create_and_get( array( 'role' => 'invalid_role' ) ); |
325 | 325 | |
326 | 326 | // make sure the user is valid |
327 | 327 | $this->assertTrue( $user->exists(), "User does not exist" ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
339 | 339 | |
340 | 340 | // a user with multiple roles |
341 | 341 | function test_user_subscriber_contributor() { |
342 | | $user = self::$factory->user->create_and_get( array( 'role' => 'subscriber' ) ); |
| 342 | $user = self::factory()->user->create_and_get( array( 'role' => 'subscriber' ) ); |
343 | 343 | |
344 | 344 | // make sure the user is valid |
345 | 345 | $this->assertTrue( $user->exists(), "User does not exist" ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
372 | 372 | $this->_flush_roles(); |
373 | 373 | $this->assertTrue( $wp_roles->is_role( $role_name ) ); |
374 | 374 | |
375 | | $user = self::$factory->user->create_and_get( array( 'role' => $role_name ) ); |
| 375 | $user = self::factory()->user->create_and_get( array( 'role' => $role_name ) ); |
376 | 376 | |
377 | 377 | // make sure the user is valid |
378 | 378 | $this->assertTrue( $user->exists(), "User does not exist" ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
409 | 409 | $this->_flush_roles(); |
410 | 410 | $this->assertTrue( $wp_roles->is_role( $role_name ) ); |
411 | 411 | |
412 | | $user = self::$factory->user->create_and_get( array( 'role' => $role_name ) ); |
| 412 | $user = self::factory()->user->create_and_get( array( 'role' => $role_name ) ); |
413 | 413 | |
414 | 414 | // make sure the user is valid |
415 | 415 | $this->assertTrue( $user->exists(), "User does not exist" ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
446 | 446 | $this->assertTrue( $wp_roles->is_role($role_name) ); |
447 | 447 | |
448 | 448 | // assign a user to that role |
449 | | $id = self::$factory->user->create( array( 'role' => $role_name ) ); |
| 449 | $id = self::factory()->user->create( array( 'role' => $role_name ) ); |
450 | 450 | |
451 | 451 | // now add a cap to the role |
452 | 452 | $wp_roles->add_cap($role_name, 'sweep_floor'); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
484 | 484 | $this->assertTrue( $wp_roles->is_role($role_name) ); |
485 | 485 | |
486 | 486 | // assign a user to that role |
487 | | $id = self::$factory->user->create( array( 'role' => $role_name ) ); |
| 487 | $id = self::factory()->user->create( array( 'role' => $role_name ) ); |
488 | 488 | |
489 | 489 | // now remove a cap from the role |
490 | 490 | $wp_roles->remove_cap($role_name, 'polish_doorknobs'); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
513 | 513 | // add an extra capability to a user |
514 | 514 | |
515 | 515 | // there are two contributors |
516 | | $id_1 = self::$factory->user->create( array( 'role' => 'contributor' ) ); |
517 | | $id_2 = self::$factory->user->create( array( 'role' => 'contributor' ) ); |
| 516 | $id_1 = self::factory()->user->create( array( 'role' => 'contributor' ) ); |
| 517 | $id_2 = self::factory()->user->create( array( 'role' => 'contributor' ) ); |
518 | 518 | |
519 | 519 | // user 1 has an extra capability |
520 | 520 | $user_1 = new WP_User($id_1); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
550 | 550 | // add an extra capability to a user then remove it |
551 | 551 | |
552 | 552 | // there are two contributors |
553 | | $id_1 = self::$factory->user->create( array( 'role' => 'contributor' ) ); |
554 | | $id_2 = self::$factory->user->create( array( 'role' => 'contributor' ) ); |
| 553 | $id_1 = self::factory()->user->create( array( 'role' => 'contributor' ) ); |
| 554 | $id_2 = self::factory()->user->create( array( 'role' => 'contributor' ) ); |
555 | 555 | |
556 | 556 | // user 1 has an extra capability |
557 | 557 | $user_1 = new WP_User($id_1); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
581 | 581 | // make sure the user_level is correctly set and changed with the user's role |
582 | 582 | |
583 | 583 | // user starts as an author |
584 | | $id = self::$factory->user->create( array( 'role' => 'author' ) ); |
| 584 | $id = self::factory()->user->create( array( 'role' => 'author' ) ); |
585 | 585 | $user = new WP_User($id); |
586 | 586 | $this->assertTrue($user->exists(), "Problem getting user $id"); |
587 | 587 | |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
604 | 604 | |
605 | 605 | function test_user_remove_all_caps() { |
606 | 606 | // user starts as an author |
607 | | $id = self::$factory->user->create( array( 'role' => 'author' ) ); |
| 607 | $id = self::factory()->user->create( array( 'role' => 'author' ) ); |
608 | 608 | $user = new WP_User($id); |
609 | 609 | $this->assertTrue($user->exists(), "Problem getting user $id"); |
610 | 610 | |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
646 | 646 | // simple tests for some common meta capabilities |
647 | 647 | |
648 | 648 | // Make our author |
649 | | $author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); |
| 649 | $author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) ); |
650 | 650 | |
651 | 651 | // make a post |
652 | | $post = self::$factory->post->create( array( 'post_author' => $author->ID, 'post_type' => 'post' ) ); |
| 652 | $post = self::factory()->post->create( array( 'post_author' => $author->ID, 'post_type' => 'post' ) ); |
653 | 653 | |
654 | 654 | // the author of the post |
655 | 655 | $this->assertTrue($author->exists(), "Problem getting user $author->ID"); |
656 | 656 | |
657 | 657 | // add some other users |
658 | | $admin = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
659 | | $author_2 = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); |
660 | | $editor = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) ); |
661 | | $contributor = new WP_User( self::$factory->user->create( array( 'role' => 'contributor' ) ) ); |
| 658 | $admin = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
| 659 | $author_2 = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) ); |
| 660 | $editor = new WP_User( self::factory()->user->create( array( 'role' => 'editor' ) ) ); |
| 661 | $contributor = new WP_User( self::factory()->user->create( array( 'role' => 'contributor' ) ) ); |
662 | 662 | |
663 | 663 | // administrators, editors and the post owner can edit it |
664 | 664 | $this->assertTrue($admin->has_cap('edit_post', $post)); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
732 | 732 | */ |
733 | 733 | function test_authorless_post( $status ) { |
734 | 734 | // Make a post without an author |
735 | | $post = self::$factory->post->create( array( 'post_author' => 0, 'post_type' => 'post', 'post_status' => $status ) ); |
| 735 | $post = self::factory()->post->create( array( 'post_author' => 0, 'post_type' => 'post', 'post_status' => $status ) ); |
736 | 736 | |
737 | 737 | // Add an editor and contributor |
738 | | $editor = self::$factory->user->create_and_get( array( 'role' => 'editor' ) ); |
739 | | $contributor = self::$factory->user->create_and_get( array( 'role' => 'contributor' ) ); |
| 738 | $editor = self::factory()->user->create_and_get( array( 'role' => 'editor' ) ); |
| 739 | $contributor = self::factory()->user->create_and_get( array( 'role' => 'contributor' ) ); |
740 | 740 | |
741 | 741 | // editor can edit, view, and trash |
742 | 742 | $this->assertTrue( $editor->has_cap( 'edit_post', $post ) ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
753 | 753 | * @ticket 16714 |
754 | 754 | */ |
755 | 755 | function test_create_posts_caps() { |
756 | | $author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); |
757 | | $admin = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
758 | | $author_2 = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); |
759 | | $editor = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) ); |
760 | | $contributor = new WP_User( self::$factory->user->create( array( 'role' => 'contributor' ) ) ); |
| 756 | $author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) ); |
| 757 | $admin = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
| 758 | $author_2 = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) ); |
| 759 | $editor = new WP_User( self::factory()->user->create( array( 'role' => 'editor' ) ) ); |
| 760 | $contributor = new WP_User( self::factory()->user->create( array( 'role' => 'contributor' ) ) ); |
761 | 761 | |
762 | 762 | // create_posts isn't a real cap. |
763 | 763 | $this->assertFalse($admin->has_cap('create_posts')); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
818 | 818 | // simple tests for some common meta capabilities |
819 | 819 | |
820 | 820 | // Make our author |
821 | | $author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); |
| 821 | $author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) ); |
822 | 822 | |
823 | 823 | // make a page |
824 | | $page = self::$factory->post->create( array( 'post_author' => $author->ID, 'post_type' => 'page' ) ); |
| 824 | $page = self::factory()->post->create( array( 'post_author' => $author->ID, 'post_type' => 'page' ) ); |
825 | 825 | |
826 | 826 | // the author of the page |
827 | 827 | $this->assertTrue($author->exists(), "Problem getting user " . $author->ID); |
828 | 828 | |
829 | 829 | // add some other users |
830 | | $admin = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
831 | | $author_2 = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); |
832 | | $editor = new WP_User( self::$factory->user->create( array( 'role' => 'editor' ) ) ); |
833 | | $contributor = new WP_User( self::$factory->user->create( array( 'role' => 'contributor' ) ) ); |
| 830 | $admin = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
| 831 | $author_2 = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) ); |
| 832 | $editor = new WP_User( self::factory()->user->create( array( 'role' => 'editor' ) ) ); |
| 833 | $contributor = new WP_User( self::factory()->user->create( array( 'role' => 'contributor' ) ) ); |
834 | 834 | |
835 | 835 | // administrators, editors and the post owner can edit it |
836 | 836 | $this->assertTrue($admin->has_cap('edit_page', $page)); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
853 | 853 | * @ticket 21786 |
854 | 854 | */ |
855 | 855 | function test_negative_caps() { |
856 | | $author = new WP_User( self::$factory->user->create( array( 'role' => 'author' ) ) ); |
| 856 | $author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) ); |
857 | 857 | $author->add_cap( 'foo', false ); |
858 | 858 | $this->assertTrue ( isset( $author->caps['foo'] ) ); |
859 | 859 | $author->remove_cap( 'foo' ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
864 | 864 | * @ticket 18932 |
865 | 865 | */ |
866 | 866 | function test_set_role_same_role() { |
867 | | $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 867 | $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
868 | 868 | $caps = $user->caps; |
869 | 869 | $this->assertNotEmpty( $user->caps ); |
870 | 870 | $user->set_role( 'administrator' ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
875 | 875 | function test_current_user_can_for_blog() { |
876 | 876 | global $wpdb; |
877 | 877 | |
878 | | $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 878 | $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
879 | 879 | $old_uid = get_current_user_id(); |
880 | 880 | wp_set_current_user( $user->ID ); |
881 | 881 | |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
890 | 890 | $this->assertFalse( current_user_can_for_blog( 12345, 'edit_posts' ) ); |
891 | 891 | $wpdb->suppress_errors( $suppress ); |
892 | 892 | |
893 | | $blog_id = self::$factory->blog->create( array( 'user_id' => $user->ID ) ); |
| 893 | $blog_id = self::factory()->blog->create( array( 'user_id' => $user->ID ) ); |
894 | 894 | $this->assertTrue( current_user_can_for_blog( $blog_id, 'edit_posts' ) ); |
895 | 895 | $this->assertFalse( current_user_can_for_blog( $blog_id, 'foo_the_bar' ) ); |
896 | 896 | |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
904 | 904 | } |
905 | 905 | |
906 | 906 | $orig_blog_id = get_current_blog_id(); |
907 | | $blog_id = self::$factory->blog->create(); |
| 907 | $blog_id = self::factory()->blog->create(); |
908 | 908 | |
909 | 909 | $this->_nullify_current_user(); |
910 | 910 | |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
932 | 932 | * @ticket 28374 |
933 | 933 | */ |
934 | 934 | function test_current_user_edit_caps() { |
935 | | $user = new WP_User( self::$factory->user->create( array( 'role' => 'contributor' ) ) ); |
| 935 | $user = new WP_User( self::factory()->user->create( array( 'role' => 'contributor' ) ) ); |
936 | 936 | wp_set_current_user( $user->ID ); |
937 | 937 | |
938 | 938 | $user->add_cap( 'publish_posts' ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
945 | 945 | } |
946 | 946 | |
947 | 947 | function test_subscriber_cant_edit_posts() { |
948 | | $user = new WP_User( self::$factory->user->create( array( 'role' => 'subscriber' ) ) ); |
| 948 | $user = new WP_User( self::factory()->user->create( array( 'role' => 'subscriber' ) ) ); |
949 | 949 | wp_set_current_user( $user->ID ); |
950 | 950 | |
951 | | $post = self::$factory->post->create( array( 'post_author' => 1 ) ); |
| 951 | $post = self::factory()->post->create( array( 'post_author' => 1 ) ); |
952 | 952 | |
953 | 953 | $this->assertFalse( current_user_can( 'edit_post', $post ) ); |
954 | 954 | $this->assertFalse( current_user_can( 'edit_post', $post + 1 ) ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
960 | 960 | return; |
961 | 961 | } |
962 | 962 | |
963 | | $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
964 | | $other_user = new WP_User( self::$factory->user->create( array( 'role' => 'subscriber' ) ) ); |
| 963 | $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
| 964 | $other_user = new WP_User( self::factory()->user->create( array( 'role' => 'subscriber' ) ) ); |
965 | 965 | |
966 | 966 | wp_set_current_user( $user->ID ); |
967 | 967 | |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
974 | 974 | return; |
975 | 975 | } |
976 | 976 | |
977 | | $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 977 | $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
978 | 978 | |
979 | 979 | wp_set_current_user( $user->ID ); |
980 | 980 | |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
987 | 987 | return; |
988 | 988 | } |
989 | 989 | |
990 | | $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 990 | $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
991 | 991 | $user->add_cap( 'manage_network_users' ); |
992 | | $other_user = new WP_User( self::$factory->user->create( array( 'role' => 'subscriber' ) ) ); |
| 992 | $other_user = new WP_User( self::factory()->user->create( array( 'role' => 'subscriber' ) ) ); |
993 | 993 | |
994 | 994 | wp_set_current_user( $user->ID ); |
995 | 995 | |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
1002 | 1002 | return; |
1003 | 1003 | } |
1004 | 1004 | |
1005 | | $user = new WP_User( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 1005 | $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
1006 | 1006 | $user->add_cap( 'manage_network_users' ); |
1007 | | $super_admin = new WP_User( self::$factory->user->create( array( 'role' => 'subscriber' ) ) ); |
| 1007 | $super_admin = new WP_User( self::factory()->user->create( array( 'role' => 'subscriber' ) ) ); |
1008 | 1008 | grant_super_admin( $super_admin->ID ); |
1009 | 1009 | |
1010 | 1010 | wp_set_current_user( $user->ID ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
1017 | 1017 | */ |
1018 | 1018 | function test_require_edit_others_posts_if_post_type_doesnt_exist() { |
1019 | 1019 | register_post_type( 'existed' ); |
1020 | | $post_id = self::$factory->post->create( array( 'post_type' => 'existed' ) ); |
| 1020 | $post_id = self::factory()->post->create( array( 'post_type' => 'existed' ) ); |
1021 | 1021 | _unregister_post_type( 'existed' ); |
1022 | 1022 | |
1023 | | $subscriber_id = self::$factory->user->create( array( 'role' => 'subscriber' ) ); |
1024 | | $editor_id = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 1023 | $subscriber_id = self::factory()->user->create( array( 'role' => 'subscriber' ) ); |
| 1024 | $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) ); |
1025 | 1025 | |
1026 | 1026 | $this->setExpectedIncorrectUsage( 'map_meta_cap' ); |
1027 | 1027 | foreach ( array( 'delete_post', 'edit_post', 'read_post', 'publish_post' ) as $cap ) { |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
1046 | 1046 | |
1047 | 1047 | $cpt = get_post_type_object( 'page_capability' ); |
1048 | 1048 | |
1049 | | $admin = self::$factory->user->create_and_get( array( 'role' => 'administrator' ) ); |
1050 | | $editor = self::$factory->user->create_and_get( array( 'role' => 'editor' ) ); |
1051 | | $author = self::$factory->user->create_and_get( array( 'role' => 'author' ) ); |
1052 | | $contributor = self::$factory->user->create_and_get( array( 'role' => 'contributor' ) ); |
| 1049 | $admin = self::factory()->user->create_and_get( array( 'role' => 'administrator' ) ); |
| 1050 | $editor = self::factory()->user->create_and_get( array( 'role' => 'editor' ) ); |
| 1051 | $author = self::factory()->user->create_and_get( array( 'role' => 'author' ) ); |
| 1052 | $contributor = self::factory()->user->create_and_get( array( 'role' => 'contributor' ) ); |
1053 | 1053 | |
1054 | 1054 | $this->assertEquals( 'edit_pages', $cpt->cap->edit_posts ); |
1055 | 1055 | $this->assertTrue( user_can( $admin->ID, $cpt->cap->edit_posts ) ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
1057 | 1057 | $this->assertFalse( user_can( $author->ID, $cpt->cap->edit_posts ) ); |
1058 | 1058 | $this->assertFalse( user_can( $contributor->ID, $cpt->cap->edit_posts ) ); |
1059 | 1059 | |
1060 | | $admin_post = self::$factory->post->create_and_get( array( |
| 1060 | $admin_post = self::factory()->post->create_and_get( array( |
1061 | 1061 | 'post_author' => $admin->ID, |
1062 | 1062 | 'post_type' => 'page_capability', |
1063 | 1063 | ) ); |
… |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
1067 | 1067 | $this->assertFalse( user_can( $author->ID, 'edit_post', $admin_post->ID ) ); |
1068 | 1068 | $this->assertFalse( user_can( $contributor->ID, 'edit_post', $admin_post->ID ) ); |
1069 | 1069 | |
1070 | | $author_post = self::$factory->post->create_and_get( array( |
| 1070 | $author_post = self::factory()->post->create_and_get( array( |
1071 | 1071 | 'post_author' => $author->ID, |
1072 | 1072 | 'post_type' => 'page_capability', |
1073 | 1073 | ) ); |
-
diff --git tests/phpunit/tests/user/countUsers.php tests/phpunit/tests/user/countUsers.php
index 4a758f0..257a045 100644
|
|
class Tests_User_CountUsers extends WP_UnitTestCase { |
17 | 17 | } |
18 | 18 | |
19 | 19 | // Setup users |
20 | | $admin = self::$factory->user->create( array( |
| 20 | $admin = self::factory()->user->create( array( |
21 | 21 | 'role' => 'administrator', |
22 | 22 | ) ); |
23 | | $editor = self::$factory->user->create( array( |
| 23 | $editor = self::factory()->user->create( array( |
24 | 24 | 'role' => 'editor', |
25 | 25 | ) ); |
26 | | $author = self::$factory->user->create( array( |
| 26 | $author = self::factory()->user->create( array( |
27 | 27 | 'role' => 'author', |
28 | 28 | ) ); |
29 | | $contributor = self::$factory->user->create( array( |
| 29 | $contributor = self::factory()->user->create( array( |
30 | 30 | 'role' => 'contributor', |
31 | 31 | ) ); |
32 | | $subscriber = self::$factory->user->create( array( |
| 32 | $subscriber = self::factory()->user->create( array( |
33 | 33 | 'role' => 'subscriber', |
34 | 34 | ) ); |
35 | | $none = self::$factory->user->create( array( |
| 35 | $none = self::factory()->user->create( array( |
36 | 36 | 'role' => '', |
37 | 37 | ) ); |
38 | | $nobody = self::$factory->user->create( array( |
| 38 | $nobody = self::factory()->user->create( array( |
39 | 39 | 'role' => '', |
40 | 40 | ) ); |
41 | 41 | |
… |
… |
class Tests_User_CountUsers extends WP_UnitTestCase { |
67 | 67 | } |
68 | 68 | |
69 | 69 | // Setup users |
70 | | $admin = self::$factory->user->create( array( |
| 70 | $admin = self::factory()->user->create( array( |
71 | 71 | 'role' => 'administrator', |
72 | 72 | ) ); |
73 | | $editor = self::$factory->user->create( array( |
| 73 | $editor = self::factory()->user->create( array( |
74 | 74 | 'role' => 'editor', |
75 | 75 | ) ); |
76 | | $author = self::$factory->user->create( array( |
| 76 | $author = self::factory()->user->create( array( |
77 | 77 | 'role' => 'author', |
78 | 78 | ) ); |
79 | | $contributor = self::$factory->user->create( array( |
| 79 | $contributor = self::factory()->user->create( array( |
80 | 80 | 'role' => 'contributor', |
81 | 81 | ) ); |
82 | | $subscriber = self::$factory->user->create( array( |
| 82 | $subscriber = self::factory()->user->create( array( |
83 | 83 | 'role' => 'subscriber', |
84 | 84 | ) ); |
85 | | $none = self::$factory->user->create( array( |
| 85 | $none = self::factory()->user->create( array( |
86 | 86 | 'role' => '', |
87 | 87 | ) ); |
88 | | $nobody = self::$factory->user->create( array( |
| 88 | $nobody = self::factory()->user->create( array( |
89 | 89 | 'role' => '', |
90 | 90 | ) ); |
91 | 91 | |
92 | 92 | // Setup blogs |
93 | | $blog_1 = (int) self::$factory->blog->create( array( |
| 93 | $blog_1 = (int) self::factory()->blog->create( array( |
94 | 94 | 'user_id' => $editor, |
95 | 95 | ) ); |
96 | | $blog_2 = (int) self::$factory->blog->create( array( |
| 96 | $blog_2 = (int) self::factory()->blog->create( array( |
97 | 97 | 'user_id' => $author, |
98 | 98 | ) ); |
99 | 99 | |
-
diff --git tests/phpunit/tests/user/dateQuery.php tests/phpunit/tests/user/dateQuery.php
index 448bd59..07b6c3a 100644
|
|
class Tests_User_DateQuery extends WP_UnitTestCase { |
9 | 9 | * @ticket 27283 |
10 | 10 | */ |
11 | 11 | public function test_user_registered() { |
12 | | $u1 = self::$factory->user->create( array( |
| 12 | $u1 = self::factory()->user->create( array( |
13 | 13 | 'user_registered' => '2012-02-14 05:05:05', |
14 | 14 | ) ); |
15 | | $u2 = self::$factory->user->create( array( |
| 15 | $u2 = self::factory()->user->create( array( |
16 | 16 | 'user_registered' => '2013-02-14 05:05:05', |
17 | 17 | ) ); |
18 | 18 | |
… |
… |
class Tests_User_DateQuery extends WP_UnitTestCase { |
31 | 31 | * @ticket 27283 |
32 | 32 | */ |
33 | 33 | public function test_user_registered_relation_or() { |
34 | | $u1 = self::$factory->user->create( array( |
| 34 | $u1 = self::factory()->user->create( array( |
35 | 35 | 'user_registered' => '2012-02-14 05:05:05', |
36 | 36 | ) ); |
37 | | $u2 = self::$factory->user->create( array( |
| 37 | $u2 = self::factory()->user->create( array( |
38 | 38 | 'user_registered' => '2013-02-14 05:05:05', |
39 | 39 | ) ); |
40 | | $u3 = self::$factory->user->create( array( |
| 40 | $u3 = self::factory()->user->create( array( |
41 | 41 | 'user_registered' => '2014-02-14 05:05:05', |
42 | 42 | ) ); |
43 | 43 | |
-
diff --git tests/phpunit/tests/user/listAuthors.php tests/phpunit/tests/user/listAuthors.php
index 11432ac..86f1a3b 100644
|
|
class Tests_User_ListAuthors extends WP_UnitTestCase { |
71 | 71 | } |
72 | 72 | |
73 | 73 | function test_wp_list_authors_exclude_admin() { |
74 | | self::$factory->post->create( array( 'post_type' => 'post', 'post_author' => 1 ) ); |
| 74 | self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => 1 ) ); |
75 | 75 | $expected['exclude_admin'] = '<li><a href="' . get_author_posts_url( 1 ) . '" title="Posts by admin">admin</a></li><li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>'; |
76 | 76 | $this->AssertEquals( $expected['exclude_admin'], wp_list_authors( array( 'echo' => false, 'exclude_admin' => 0 ) ) ); |
77 | 77 | } |
-
diff --git tests/phpunit/tests/user/mapMetaCap.php tests/phpunit/tests/user/mapMetaCap.php
index 4a65003..1b86dd1 100644
|
|
class Tests_User_MapMetaCap extends WP_UnitTestCase { |
12 | 12 | |
13 | 13 | $this->user_ids = array(); |
14 | 14 | |
15 | | $this->user_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
16 | | $this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 15 | $this->user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
| 16 | $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
17 | 17 | |
18 | 18 | if ( isset( $GLOBALS['super_admins'] ) ) |
19 | 19 | $this->super_admins = $GLOBALS['super_admins']; |
… |
… |
class Tests_User_MapMetaCap extends WP_UnitTestCase { |
248 | 248 | * @ticket 27020 |
249 | 249 | */ |
250 | 250 | function test_authorless_posts_capabilties() { |
251 | | $post_id = self::$factory->post->create( array( 'post_author' => 0, 'post_type' => 'post', 'post_status' => 'publish' ) ); |
252 | | $editor = self::$factory->user->create( array( 'role' => 'editor' ) ); |
| 251 | $post_id = self::factory()->post->create( array( 'post_author' => 0, 'post_type' => 'post', 'post_status' => 'publish' ) ); |
| 252 | $editor = self::factory()->user->create( array( 'role' => 'editor' ) ); |
253 | 253 | |
254 | 254 | $this->assertEquals( array( 'edit_others_posts', 'edit_published_posts' ), map_meta_cap( 'edit_post', $editor, $post_id ) ); |
255 | 255 | $this->assertEquals( array( 'delete_others_posts', 'delete_published_posts' ), map_meta_cap( 'delete_post', $editor, $post_id ) ); |
-
diff --git tests/phpunit/tests/user/multisite.php tests/phpunit/tests/user/multisite.php
index 2a36d36..2e970b1 100644
|
|
class Tests_Multisite_User extends WP_UnitTestCase { |
25 | 25 | } |
26 | 26 | |
27 | 27 | function test_remove_user_from_blog() { |
28 | | $user1 = self::$factory->user->create_and_get(); |
29 | | $user2 = self::$factory->user->create_and_get(); |
| 28 | $user1 = self::factory()->user->create_and_get(); |
| 29 | $user2 = self::factory()->user->create_and_get(); |
30 | 30 | |
31 | | $post_id = self::$factory->post->create( array( 'post_author' => $user1->ID ) ); |
| 31 | $post_id = self::factory()->post->create( array( 'post_author' => $user1->ID ) ); |
32 | 32 | |
33 | 33 | remove_user_from_blog( $user1->ID, 1, $user2->ID ); |
34 | 34 | |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
42 | 42 | * Test the returned data from get_blogs_of_user() |
43 | 43 | */ |
44 | 44 | function test_get_blogs_of_user() { |
45 | | $user1_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 45 | $user1_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
46 | 46 | |
47 | 47 | // Maintain a list of 6 total sites and include the primary network site. |
48 | | $blog_ids = self::$factory->blog->create_many( 5, array( 'user_id' => $user1_id ) ); |
| 48 | $blog_ids = self::factory()->blog->create_many( 5, array( 'user_id' => $user1_id ) ); |
49 | 49 | $blog_ids = array_merge( array( 1 ), $blog_ids ); |
50 | 50 | |
51 | 51 | // All sites are new and not marked as spam, archived, or deleted. |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
114 | 114 | function test_is_blog_user() { |
115 | 115 | global $wpdb; |
116 | 116 | |
117 | | $user1_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 117 | $user1_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
118 | 118 | |
119 | 119 | $old_current = get_current_user_id(); |
120 | 120 | wp_set_current_user( $user1_id ); |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
124 | 124 | |
125 | 125 | $blog_ids = array(); |
126 | 126 | |
127 | | $blog_ids = self::$factory->blog->create_many( 5 ); |
| 127 | $blog_ids = self::factory()->blog->create_many( 5 ); |
128 | 128 | foreach ( $blog_ids as $blog_id ) { |
129 | 129 | $this->assertInternalType( 'int', $blog_id ); |
130 | 130 | $this->assertTrue( is_blog_user( $blog_id ) ); |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
138 | 138 | function test_is_user_member_of_blog() { |
139 | 139 | global $wpdb; |
140 | 140 | |
141 | | $user1_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
142 | | $user2_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 141 | $user1_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
| 142 | $user2_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
143 | 143 | |
144 | 144 | $old_current = get_current_user_id(); |
145 | 145 | |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
156 | 156 | $this->assertTrue( is_user_member_of_blog( $user1_id ) ); |
157 | 157 | $this->assertTrue( is_user_member_of_blog( $user1_id, $wpdb->blogid ) ); |
158 | 158 | |
159 | | $blog_ids = self::$factory->blog->create_many( 5 ); |
| 159 | $blog_ids = self::factory()->blog->create_many( 5 ); |
160 | 160 | foreach ( $blog_ids as $blog_id ) { |
161 | 161 | $this->assertInternalType( 'int', $blog_id ); |
162 | 162 | |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
197 | 197 | * @ticket 23192 |
198 | 198 | */ |
199 | 199 | function test_is_user_spammy() { |
200 | | $user_id = self::$factory->user->create( array( |
| 200 | $user_id = self::factory()->user->create( array( |
201 | 201 | 'role' => 'author', |
202 | 202 | 'user_login' => 'testuser1', |
203 | 203 | ) ); |
204 | 204 | |
205 | 205 | $spam_username = (string) $user_id; |
206 | | $spam_user_id = self::$factory->user->create( array( |
| 206 | $spam_user_id = self::factory()->user->create( array( |
207 | 207 | 'role' => 'author', |
208 | 208 | 'user_login' => $spam_username, |
209 | 209 | ) ); |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
219 | 219 | function test_user_member_of_blog() { |
220 | 220 | global $wp_rewrite; |
221 | 221 | |
222 | | self::$factory->blog->create(); |
223 | | $user_id = self::$factory->user->create(); |
224 | | self::$factory->blog->create( array( 'user_id' => $user_id ) ); |
| 222 | self::factory()->blog->create(); |
| 223 | $user_id = self::factory()->user->create(); |
| 224 | self::factory()->blog->create( array( 'user_id' => $user_id ) ); |
225 | 225 | |
226 | 226 | $blogs = get_blogs_of_user( $user_id ); |
227 | 227 | $this->assertCount( 2, $blogs ); |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
261 | 261 | unset( $GLOBALS['super_admins'] ); |
262 | 262 | } |
263 | 263 | |
264 | | $user_id = self::$factory->user->create(); |
| 264 | $user_id = self::factory()->user->create(); |
265 | 265 | grant_super_admin( $user_id ); |
266 | 266 | revoke_super_admin( $user_id ); |
267 | 267 | |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
278 | 278 | unset( $GLOBALS['super_admins'] ); |
279 | 279 | } |
280 | 280 | |
281 | | $user_id = self::$factory->user->create(); |
| 281 | $user_id = self::factory()->user->create(); |
282 | 282 | grant_super_admin( $user_id ); |
283 | 283 | revoke_super_admin( $user_id ); |
284 | 284 | wpmu_delete_user( $user_id ); |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
297 | 297 | unset( $GLOBALS['super_admins'] ); |
298 | 298 | } |
299 | 299 | |
300 | | $user_id = self::$factory->user->create(); |
| 300 | $user_id = self::factory()->user->create(); |
301 | 301 | grant_super_admin( $user_id ); |
302 | 302 | |
303 | 303 | $this->assertFalse( wpmu_delete_user( $user_id ) ); |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
316 | 316 | unset( $GLOBALS['super_admins'] ); |
317 | 317 | } |
318 | 318 | |
319 | | $user_id = self::$factory->user->create(); |
| 319 | $user_id = self::factory()->user->create(); |
320 | 320 | |
321 | 321 | $this->assertFalse( is_super_admin( $user_id ) ); |
322 | 322 | $this->assertFalse( revoke_super_admin( $user_id ) ); |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
329 | 329 | $this->assertFalse( isset( $GLOBALS['super_admins'] ) ); |
330 | 330 | |
331 | 331 | // Try with two users. |
332 | | $second_user = self::$factory->user->create(); |
| 332 | $second_user = self::factory()->user->create(); |
333 | 333 | $this->assertTrue( grant_super_admin( $user_id ) ); |
334 | 334 | $this->assertTrue( grant_super_admin( $second_user ) ); |
335 | 335 | $this->assertTrue( is_super_admin( $second_user ) ); |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
343 | 343 | } |
344 | 344 | |
345 | 345 | public function test_numeric_string_user_id() { |
346 | | $u = self::$factory->user->create(); |
| 346 | $u = self::factory()->user->create(); |
347 | 347 | |
348 | 348 | $u_string = (string) $u; |
349 | 349 | $this->assertTrue( wpmu_delete_user( $u_string ) ); |
… |
… |
class Tests_Multisite_User extends WP_UnitTestCase { |
361 | 361 | * @ticket 33800 |
362 | 362 | */ |
363 | 363 | public function test_should_return_false_for_object_user_id() { |
364 | | $u_obj = self::$factory->user->create_and_get(); |
| 364 | $u_obj = self::factory()->user->create_and_get(); |
365 | 365 | $this->assertFalse( wpmu_delete_user( $u_obj ) ); |
366 | 366 | $this->assertEquals( $u_obj->ID, username_exists( $u_obj->user_login ) ); |
367 | 367 | } |
-
diff --git tests/phpunit/tests/user/query.php tests/phpunit/tests/user/query.php
index 0287975..a354bed 100644
|
|
class Tests_User_Query extends WP_UnitTestCase { |
245 | 245 | * @ticket 31265 |
246 | 246 | */ |
247 | 247 | public function test_orderby_clause_key_as_secondary_sort() { |
248 | | $u1 = self::$factory->user->create( array( |
| 248 | $u1 = self::factory()->user->create( array( |
249 | 249 | 'user_registered' => '2015-01-28 03:00:00', |
250 | 250 | ) ); |
251 | | $u2 = self::$factory->user->create( array( |
| 251 | $u2 = self::factory()->user->create( array( |
252 | 252 | 'user_registered' => '2015-01-28 05:00:00', |
253 | 253 | ) ); |
254 | | $u3 = self::$factory->user->create( array( |
| 254 | $u3 = self::factory()->user->create( array( |
255 | 255 | 'user_registered' => '2015-01-28 03:00:00', |
256 | 256 | ) ); |
257 | 257 | |
… |
… |
class Tests_User_Query extends WP_UnitTestCase { |
598 | 598 | $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' ); |
599 | 599 | } |
600 | 600 | |
601 | | $b = self::$factory->blog->create(); |
| 601 | $b = self::factory()->blog->create(); |
602 | 602 | |
603 | 603 | add_user_to_blog( $b, self::$author_ids[0], 'author' ); |
604 | 604 | |
… |
… |
class Tests_User_Query extends WP_UnitTestCase { |
624 | 624 | $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' ); |
625 | 625 | } |
626 | 626 | |
627 | | $b = self::$factory->blog->create(); |
| 627 | $b = self::factory()->blog->create(); |
628 | 628 | add_user_to_blog( $b, self::$author_ids[0], 'author' ); |
629 | 629 | |
630 | 630 | $query = new WP_User_Query( array( |
… |
… |
class Tests_User_Query extends WP_UnitTestCase { |
649 | 649 | $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); |
650 | 650 | } |
651 | 651 | |
652 | | $b = self::$factory->blog->create(); |
| 652 | $b = self::factory()->blog->create(); |
653 | 653 | |
654 | 654 | add_user_to_blog( $b, self::$author_ids[0], 'subscriber' ); |
655 | 655 | add_user_to_blog( $b, self::$author_ids[1], 'author' ); |
… |
… |
class Tests_User_Query extends WP_UnitTestCase { |
675 | 675 | $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); |
676 | 676 | } |
677 | 677 | |
678 | | $b = self::$factory->blog->create(); |
| 678 | $b = self::factory()->blog->create(); |
679 | 679 | |
680 | 680 | add_user_to_blog( $b, self::$author_ids[0], 'subscriber' ); |
681 | 681 | add_user_to_blog( $b, self::$author_ids[1], 'author' ); |
… |
… |
class Tests_User_Query extends WP_UnitTestCase { |
707 | 707 | register_post_type( 'wptests_pt_public', array( 'public' => true ) ); |
708 | 708 | register_post_type( 'wptests_pt_private', array( 'public' => false ) ); |
709 | 709 | |
710 | | self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) ); |
711 | | self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) ); |
| 710 | self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) ); |
| 711 | self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) ); |
712 | 712 | |
713 | 713 | $q = new WP_User_Query( array( |
714 | 714 | 'has_published_posts' => true, |
… |
… |
class Tests_User_Query extends WP_UnitTestCase { |
727 | 727 | register_post_type( 'wptests_pt_public', array( 'public' => true ) ); |
728 | 728 | register_post_type( 'wptests_pt_private', array( 'public' => false ) ); |
729 | 729 | |
730 | | self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) ); |
731 | | self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) ); |
732 | | self::$factory->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) ); |
| 730 | self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) ); |
| 731 | self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) ); |
| 732 | self::factory()->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) ); |
733 | 733 | |
734 | 734 | $q = new WP_User_Query( array( |
735 | 735 | 'has_published_posts' => array( 'wptests_pt_private', 'post' ), |
… |
… |
class Tests_User_Query extends WP_UnitTestCase { |
748 | 748 | register_post_type( 'wptests_pt_public', array( 'public' => true ) ); |
749 | 749 | register_post_type( 'wptests_pt_private', array( 'public' => false ) ); |
750 | 750 | |
751 | | self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'draft', 'post_type' => 'wptests_pt_public' ) ); |
752 | | self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'inherit', 'post_type' => 'wptests_pt_private' ) ); |
753 | | self::$factory->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) ); |
| 751 | self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'draft', 'post_type' => 'wptests_pt_public' ) ); |
| 752 | self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'inherit', 'post_type' => 'wptests_pt_private' ) ); |
| 753 | self::factory()->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) ); |
754 | 754 | |
755 | 755 | $q = new WP_User_Query( array( |
756 | 756 | 'has_published_posts' => array( 'wptests_pt_public', 'wptests_pt_private', 'post' ), |
… |
… |
class Tests_User_Query extends WP_UnitTestCase { |
770 | 770 | $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); |
771 | 771 | } |
772 | 772 | |
773 | | $blogs = self::$factory->blog->create_many( 2 ); |
| 773 | $blogs = self::factory()->blog->create_many( 2 ); |
774 | 774 | |
775 | 775 | add_user_to_blog( $blogs[0], self::$author_ids[0], 'author' ); |
776 | 776 | add_user_to_blog( $blogs[0], self::$author_ids[1], 'author' ); |
… |
… |
class Tests_User_Query extends WP_UnitTestCase { |
778 | 778 | add_user_to_blog( $blogs[1], self::$author_ids[1], 'author' ); |
779 | 779 | |
780 | 780 | switch_to_blog( $blogs[0] ); |
781 | | self::$factory->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'post' ) ); |
| 781 | self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'post' ) ); |
782 | 782 | restore_current_blog(); |
783 | 783 | |
784 | 784 | switch_to_blog( $blogs[1] ); |
785 | | self::$factory->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'post' ) ); |
| 785 | self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'post' ) ); |
786 | 786 | restore_current_blog(); |
787 | 787 | |
788 | 788 | $q = new WP_User_Query( array( |
… |
… |
class Tests_User_Query extends WP_UnitTestCase { |
931 | 931 | * @ticket 22212 |
932 | 932 | */ |
933 | 933 | public function test_get_single_role_by_string_which_is_similar() { |
934 | | $another_editor = self::$factory->user->create( array( |
| 934 | $another_editor = self::factory()->user->create( array( |
935 | 935 | 'role' => 'another-editor', |
936 | 936 | ) ); |
937 | 937 | |
… |
… |
class Tests_User_Query extends WP_UnitTestCase { |
1148 | 1148 | $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); |
1149 | 1149 | } |
1150 | 1150 | |
1151 | | $sites = self::$factory->blog->create_many( 2 ); |
| 1151 | $sites = self::factory()->blog->create_many( 2 ); |
1152 | 1152 | |
1153 | 1153 | add_user_to_blog( $sites[0], self::$author_ids[0], 'author' ); |
1154 | 1154 | add_user_to_blog( $sites[1], self::$author_ids[1], 'author' ); |
-
diff --git tests/phpunit/tests/user/session.php tests/phpunit/tests/user/session.php
index ee29cce..c3f9638 100644
|
|
class Tests_User_Session extends WP_UnitTestCase { |
10 | 10 | function setUp() { |
11 | 11 | parent::setUp(); |
12 | 12 | remove_all_filters( 'session_token_manager' ); |
13 | | $user_id = self::$factory->user->create(); |
| 13 | $user_id = self::factory()->user->create(); |
14 | 14 | $this->manager = WP_Session_Tokens::get_instance( $user_id ); |
15 | 15 | $this->assertInstanceOf( 'WP_Session_Tokens', $this->manager ); |
16 | 16 | $this->assertInstanceOf( 'WP_User_Meta_Session_Tokens', $this->manager ); |
-
diff --git tests/phpunit/tests/user/slashes.php tests/phpunit/tests/user/slashes.php
index 9b44484..54dbf78 100644
|
|
|
8 | 8 | class Tests_User_Slashes extends WP_UnitTestCase { |
9 | 9 | function setUp() { |
10 | 10 | parent::setUp(); |
11 | | $this->author_id = self::$factory->user->create( array( 'role' => 'administrator' ) ); |
| 11 | $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); |
12 | 12 | $this->old_current_user = get_current_user_id(); |
13 | 13 | wp_set_current_user( $this->author_id ); |
14 | 14 | |
… |
… |
class Tests_User_Slashes extends WP_UnitTestCase { |
83 | 83 | * |
84 | 84 | */ |
85 | 85 | function test_edit_user() { |
86 | | $id = self::$factory->user->create(); |
| 86 | $id = self::factory()->user->create(); |
87 | 87 | |
88 | 88 | $_POST = $_GET = $_REQUEST = array(); |
89 | 89 | $_POST['role'] = 'subscriber'; |
… |
… |
class Tests_User_Slashes extends WP_UnitTestCase { |
173 | 173 | * |
174 | 174 | */ |
175 | 175 | function test_wp_update_user() { |
176 | | $id = self::$factory->user->create(); |
| 176 | $id = self::factory()->user->create(); |
177 | 177 | $id = wp_update_user(array( |
178 | 178 | 'ID' => $id, |
179 | 179 | 'role' => 'subscriber', |
-
diff --git tests/phpunit/tests/user/updateUserCaches.php tests/phpunit/tests/user/updateUserCaches.php
index 7d29cec..9be0717 100644
|
|
class Tests_User_UpdateUserCaches extends WP_UnitTestCase { |
7 | 7 | public function test_should_store_entire_database_row_in_users_bucket() { |
8 | 8 | global $wpdb; |
9 | 9 | |
10 | | $u = self::$factory->user->create(); |
| 10 | $u = self::factory()->user->create(); |
11 | 11 | $raw_userdata = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $u ) ); |
12 | 12 | |
13 | 13 | update_user_caches( $raw_userdata ); |
… |
… |
class Tests_User_UpdateUserCaches extends WP_UnitTestCase { |
57 | 57 | public function test_should_store_raw_data_in_users_bucket_when_passed_a_wp_user_object() { |
58 | 58 | global $wpdb; |
59 | 59 | |
60 | | $u = self::$factory->user->create(); |
| 60 | $u = self::factory()->user->create(); |
61 | 61 | $raw_userdata = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $u ) ); |
62 | 62 | $user_object = new WP_User( $u ); |
63 | 63 | |
-
diff --git tests/phpunit/tests/user/wpDeleteUser.php tests/phpunit/tests/user/wpDeleteUser.php
index 6c05a2a..20d54c9 100644
|
|
class Tests_User_WpDeleteUser extends WP_UnitTestCase { |
14 | 14 | // Logged out users don't have blogs. |
15 | 15 | $this->assertEquals( array(), get_blogs_of_user( 0 ) ); |
16 | 16 | |
17 | | $user_id = self::$factory->user->create( array( 'role' => 'subscriber' ) ); |
| 17 | $user_id = self::factory()->user->create( array( 'role' => 'subscriber' ) ); |
18 | 18 | $blogs = get_blogs_of_user( $user_id ); |
19 | 19 | $this->assertEquals( array( 1 ), array_keys( $blogs ) ); |
20 | 20 | |
… |
… |
class Tests_User_WpDeleteUser extends WP_UnitTestCase { |
34 | 34 | function test_is_user_member_of_blog() { |
35 | 35 | $old_current = get_current_user_id(); |
36 | 36 | |
37 | | $user_id = self::$factory->user->create( array( 'role' => 'subscriber' ) ); |
| 37 | $user_id = self::factory()->user->create( array( 'role' => 'subscriber' ) ); |
38 | 38 | wp_set_current_user( $user_id ); |
39 | 39 | |
40 | 40 | $this->assertTrue( is_user_member_of_blog() ); |
… |
… |
class Tests_User_WpDeleteUser extends WP_UnitTestCase { |
54 | 54 | } |
55 | 55 | |
56 | 56 | function test_delete_user() { |
57 | | $user_id = self::$factory->user->create( array( 'role' => 'author' ) ); |
| 57 | $user_id = self::factory()->user->create( array( 'role' => 'author' ) ); |
58 | 58 | $user = new WP_User( $user_id ); |
59 | 59 | |
60 | 60 | $post = array( |
… |
… |
class Tests_User_WpDeleteUser extends WP_UnitTestCase { |
111 | 111 | * @ticket 20447 |
112 | 112 | */ |
113 | 113 | function test_wp_delete_user_reassignment_clears_post_caches() { |
114 | | $user_id = self::$factory->user->create(); |
115 | | $reassign = self::$factory->user->create(); |
116 | | $post_id = self::$factory->post->create( array( 'post_author' => $user_id ) ); |
| 114 | $user_id = self::factory()->user->create(); |
| 115 | $reassign = self::factory()->user->create(); |
| 116 | $post_id = self::factory()->post->create( array( 'post_author' => $user_id ) ); |
117 | 117 | |
118 | 118 | get_post( $post_id ); // Ensure this post is in the cache. |
119 | 119 | |
… |
… |
class Tests_User_WpDeleteUser extends WP_UnitTestCase { |
128 | 128 | $this->markTestSkipped( 'wp_delete_user() does not delete user records in Multisite.' ); |
129 | 129 | } |
130 | 130 | |
131 | | $u = self::$factory->user->create(); |
| 131 | $u = self::factory()->user->create(); |
132 | 132 | |
133 | 133 | $u_string = (string) $u; |
134 | 134 | $this->assertTrue( wp_delete_user( $u_string ) ); |
… |
… |
class Tests_User_WpDeleteUser extends WP_UnitTestCase { |
150 | 150 | $this->markTestSkipped( 'wp_delete_user() does not delete user records in Multisite.' ); |
151 | 151 | } |
152 | 152 | |
153 | | $u_obj = self::$factory->user->create_and_get(); |
| 153 | $u_obj = self::factory()->user->create_and_get(); |
154 | 154 | $this->assertFalse( wp_delete_user( $u_obj ) ); |
155 | 155 | $this->assertEquals( $u_obj->ID, username_exists( $u_obj->user_login ) ); |
156 | 156 | } |
-
diff --git tests/phpunit/tests/user/wpGetUsersWithNoRole.php tests/phpunit/tests/user/wpGetUsersWithNoRole.php
index d9cc898..6eb6823 100644
|
|
class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase { |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Setup users |
18 | | $admin = self::$factory->user->create( array( |
| 18 | $admin = self::factory()->user->create( array( |
19 | 19 | 'role' => 'administrator', |
20 | 20 | ) ); |
21 | | $editor = self::$factory->user->create( array( |
| 21 | $editor = self::factory()->user->create( array( |
22 | 22 | 'role' => 'editor', |
23 | 23 | ) ); |
24 | | $nobody = self::$factory->user->create( array( |
| 24 | $nobody = self::factory()->user->create( array( |
25 | 25 | 'role' => '', |
26 | 26 | ) ); |
27 | | $nobody_else = self::$factory->user->create( array( |
| 27 | $nobody_else = self::factory()->user->create( array( |
28 | 28 | 'role' => '', |
29 | 29 | ) ); |
30 | 30 | |
… |
… |
class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase { |
49 | 49 | } |
50 | 50 | |
51 | 51 | // Setup users |
52 | | $admin = self::$factory->user->create( array( |
| 52 | $admin = self::factory()->user->create( array( |
53 | 53 | 'role' => 'administrator', |
54 | 54 | ) ); |
55 | | $editor = self::$factory->user->create( array( |
| 55 | $editor = self::factory()->user->create( array( |
56 | 56 | 'role' => 'editor', |
57 | 57 | ) ); |
58 | | $nobody = self::$factory->user->create( array( |
| 58 | $nobody = self::factory()->user->create( array( |
59 | 59 | 'role' => '', |
60 | 60 | ) ); |
61 | 61 | |
62 | 62 | // Setup blogs |
63 | | $blog_1 = (int) self::$factory->blog->create( array( |
| 63 | $blog_1 = (int) self::factory()->blog->create( array( |
64 | 64 | 'user_id' => $editor, |
65 | 65 | ) ); |
66 | 66 | |
-
diff --git tests/phpunit/tests/user/wpSetCurrentUser.php tests/phpunit/tests/user/wpSetCurrentUser.php
index 5b7c0f0..212041c 100644
|
|
|
5 | 5 | */ |
6 | 6 | class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { |
7 | 7 | public function test_set_by_id() { |
8 | | $u = self::$factory->user->create(); |
| 8 | $u = self::factory()->user->create(); |
9 | 9 | |
10 | 10 | $user = wp_set_current_user( $u ); |
11 | 11 | |
… |
… |
class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { |
15 | 15 | } |
16 | 16 | |
17 | 17 | public function test_name_should_be_ignored_if_id_is_not_null() { |
18 | | $u = self::$factory->user->create(); |
| 18 | $u = self::factory()->user->create(); |
19 | 19 | |
20 | 20 | $user = wp_set_current_user( $u, 'foo' ); |
21 | 21 | |
… |
… |
class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { |
25 | 25 | } |
26 | 26 | |
27 | 27 | public function test_should_set_by_name_if_id_is_null_and_current_user_is_nonempty() { |
28 | | $u1 = self::$factory->user->create(); |
| 28 | $u1 = self::factory()->user->create(); |
29 | 29 | wp_set_current_user( $u1 ); |
30 | 30 | $this->assertSame( $u1, get_current_user_id() ); |
31 | 31 | |
32 | | $u2 = self::$factory->user->create( array( |
| 32 | $u2 = self::factory()->user->create( array( |
33 | 33 | 'user_login' => 'foo', |
34 | 34 | ) ); |
35 | 35 | |
… |
… |
class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { |
49 | 49 | wp_set_current_user( 0 ); |
50 | 50 | $this->assertSame( 0, get_current_user_id() ); |
51 | 51 | |
52 | | $u = self::$factory->user->create( array( |
| 52 | $u = self::factory()->user->create( array( |
53 | 53 | 'user_login' => 'foo', |
54 | 54 | ) ); |
55 | 55 | |
-
diff --git tests/phpunit/tests/widgets.php tests/phpunit/tests/widgets.php
index 35cadc4..7b64efb 100644
|
|
class Tests_Widgets extends WP_UnitTestCase { |
438 | 438 | $this->assertEmpty( $wp_customize ); |
439 | 439 | $this->assertFalse( $widget->is_preview() ); |
440 | 440 | |
441 | | wp_set_current_user( self::$factory->user->create( array( 'role' => 'administrator' ) ) ); |
| 441 | wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); |
442 | 442 | require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; |
443 | 443 | $wp_customize = new WP_Customize_Manager(); |
444 | 444 | $wp_customize->start_previewing_theme(); |
-
diff --git tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php
index ef23c7b..8d9c027 100644
|
|
class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { |
22 | 22 | function test_no_editable_posts() { |
23 | 23 | $this->make_user_by_role( 'author' ); |
24 | 24 | $editor = $this->make_user_by_role( 'editor' ); |
25 | | self::$factory->post->create( array( 'post_author' => $editor ) ); |
| 25 | self::factory()->post->create( array( 'post_author' => $editor ) ); |
26 | 26 | |
27 | 27 | $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); |
28 | 28 | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
… |
… |
class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { |
32 | 32 | function test_date() { |
33 | 33 | $this->make_user_by_role( 'author' ); |
34 | 34 | |
35 | | self::$factory->post->create(); |
| 35 | self::factory()->post->create(); |
36 | 36 | |
37 | 37 | $results = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); |
38 | 38 | $this->assertNotInstanceOf( 'IXR_Error', $results ); |
-
diff --git tests/phpunit/tests/xmlrpc/mw/editPost.php tests/phpunit/tests/xmlrpc/mw/editPost.php
index 982ab23..fbdf20e 100644
|
|
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
126 | 126 | |
127 | 127 | // create attachment |
128 | 128 | $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); |
129 | | $attachment_id = self::$factory->attachment->create_upload_object( $filename, $post_id ); |
| 129 | $attachment_id = self::factory()->attachment->create_upload_object( $filename, $post_id ); |
130 | 130 | |
131 | 131 | // add post thumbnail to post that does not have one |
132 | 132 | $post2 = array( 'wp_post_thumbnail' => $attachment_id ); |
… |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
141 | 141 | $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); |
142 | 142 | |
143 | 143 | // create another attachment |
144 | | $attachment2_id = self::$factory->attachment->create_upload_object( $filename, $post_id ); |
| 144 | $attachment2_id = self::factory()->attachment->create_upload_object( $filename, $post_id ); |
145 | 145 | |
146 | 146 | // change the post's post_thumbnail |
147 | 147 | $post4 = array( 'wp_post_thumbnail' => $attachment2_id ); |
… |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
228 | 228 | |
229 | 229 | $editor_id = $this->make_user_by_role( 'editor' ); |
230 | 230 | |
231 | | $post_id = self::$factory->post->create( array( |
| 231 | $post_id = self::factory()->post->create( array( |
232 | 232 | 'post_author' => $editor_id |
233 | 233 | ) ); |
234 | 234 | |
… |
… |
class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { |
251 | 251 | function test_empty_not_null() { |
252 | 252 | $editor_id = $this->make_user_by_role( 'editor' ); |
253 | 253 | |
254 | | $post_id = self::$factory->post->create( array( |
| 254 | $post_id = self::factory()->post->create( array( |
255 | 255 | 'post_title' => 'Title', |
256 | 256 | 'post_author' => $editor_id, |
257 | 257 | 'tags_input' => 'taco' |
-
diff --git tests/phpunit/tests/xmlrpc/mw/getPost.php tests/phpunit/tests/xmlrpc/mw/getPost.php
index e8d77b7..9ae05e7 100644
|
|
class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { |
95 | 95 | |
96 | 96 | // create attachment |
97 | 97 | $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); |
98 | | $attachment_id = self::$factory->attachment->create_upload_object( $filename ); |
| 98 | $attachment_id = self::factory()->attachment->create_upload_object( $filename ); |
99 | 99 | |
100 | 100 | set_post_thumbnail( $this->post_id, $attachment_id ); |
101 | 101 | |
-
diff --git tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php
index 641fb03..ac5e021 100644
|
|
class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { |
100 | 100 | |
101 | 101 | // create attachment |
102 | 102 | $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); |
103 | | $attachment_id = self::$factory->attachment->create_upload_object( $filename, $this->post_id ); |
| 103 | $attachment_id = self::factory()->attachment->create_upload_object( $filename, $this->post_id ); |
104 | 104 | set_post_thumbnail( $this->post_id, $attachment_id ); |
105 | 105 | |
106 | 106 | $results = $this->myxmlrpcserver->mw_getRecentPosts( array( $this->post_id, 'author', 'author' ) ); |
-
diff --git tests/phpunit/tests/xmlrpc/mw/newPost.php tests/phpunit/tests/xmlrpc/mw/newPost.php
index e780479..c849f65 100644
|
|
class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { |
117 | 117 | |
118 | 118 | // create attachment |
119 | 119 | $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); |
120 | | $attachment_id = self::$factory->attachment->create_upload_object( $filename ); |
| 120 | $attachment_id = self::factory()->attachment->create_upload_object( $filename ); |
121 | 121 | |
122 | 122 | $post = array( 'title' => 'Post Thumbnail Test', 'wp_post_thumbnail' => $attachment_id ); |
123 | 123 | $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/deletePost.php tests/phpunit/tests/xmlrpc/wp/deletePost.php
index 93c3390..e7284a7 100644
|
|
class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { |
21 | 21 | |
22 | 22 | function test_incapable_user() { |
23 | 23 | $this->make_user_by_role( 'subscriber' ); |
24 | | $post_id = self::$factory->post->create(); |
| 24 | $post_id = self::factory()->post->create(); |
25 | 25 | |
26 | 26 | $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'subscriber', 'subscriber', $post_id ) ); |
27 | 27 | $this->assertInstanceOf( 'IXR_Error', $result ); |
… |
… |
class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { |
30 | 30 | |
31 | 31 | function test_post_deleted() { |
32 | 32 | $this->make_user_by_role( 'editor' ); |
33 | | $post_id = self::$factory->post->create(); |
| 33 | $post_id = self::factory()->post->create(); |
34 | 34 | |
35 | 35 | $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'editor', 'editor', $post_id ) ); |
36 | 36 | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/editComment.php tests/phpunit/tests/xmlrpc/wp/editComment.php
index 9e7c1f9..c885957 100644
|
|
class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { |
7 | 7 | |
8 | 8 | function test_author_can_edit_own_comment() { |
9 | 9 | $author_id = $this->make_user_by_role( 'author' ); |
10 | | $post_id = self::$factory->post->create( array( |
| 10 | $post_id = self::factory()->post->create( array( |
11 | 11 | 'post_title' => 'Post test by author', |
12 | 12 | 'post_author' => $author_id |
13 | 13 | ) ); |
… |
… |
class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { |
29 | 29 | function test_author_cannot_edit_others_comment() { |
30 | 30 | $this->make_user_by_role( 'author' ); |
31 | 31 | $editor_id = $this->make_user_by_role( 'editor' ); |
32 | | $post_id = self::$factory->post->create( array( |
| 32 | $post_id = self::factory()->post->create( array( |
33 | 33 | 'post_title' => 'Post test by editor', |
34 | 34 | 'post_author' => $editor_id |
35 | 35 | ) ); |
… |
… |
class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { |
49 | 49 | |
50 | 50 | function test_trash_comment() { |
51 | 51 | $this->make_user_by_role( 'administrator' ); |
52 | | $post_id = self::$factory->post->create(); |
| 52 | $post_id = self::factory()->post->create(); |
53 | 53 | |
54 | 54 | $comment_data = array( |
55 | 55 | 'comment_post_ID' => $post_id, |
… |
… |
class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { |
78 | 78 | update_option( 'timezone_string', 'America/New_York' ); |
79 | 79 | |
80 | 80 | $this->make_user_by_role( 'administrator' ); |
81 | | $post_id = self::$factory->post->create(); |
| 81 | $post_id = self::factory()->post->create(); |
82 | 82 | |
83 | 83 | $comment_data = array( |
84 | 84 | 'comment_post_ID' => $post_id, |
-
diff --git tests/phpunit/tests/xmlrpc/wp/editPost.php tests/phpunit/tests/xmlrpc/wp/editPost.php
index 299f3a4..20ba377 100644
|
|
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
126 | 126 | |
127 | 127 | // create attachment |
128 | 128 | $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); |
129 | | $attachment_id = self::$factory->attachment->create_upload_object( $filename, $post_id ); |
| 129 | $attachment_id = self::factory()->attachment->create_upload_object( $filename, $post_id ); |
130 | 130 | |
131 | 131 | // add post thumbnail to post that does not have one |
132 | 132 | $post2 = array( 'post_thumbnail' => $attachment_id ); |
… |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
148 | 148 | $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) ); |
149 | 149 | |
150 | 150 | // create another attachment |
151 | | $attachment2_id = self::$factory->attachment->create_upload_object( $filename, $post_id ); |
| 151 | $attachment2_id = self::factory()->attachment->create_upload_object( $filename, $post_id ); |
152 | 152 | |
153 | 153 | // change the post's post_thumbnail |
154 | 154 | $post4 = array( 'post_thumbnail' => $attachment2_id ); |
… |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
208 | 208 | function test_capable_unsticky() { |
209 | 209 | $editor_id = $this->make_user_by_role( 'editor' ); |
210 | 210 | |
211 | | $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) ); |
| 211 | $post_id = self::factory()->post->create( array( 'post_author' => $editor_id ) ); |
212 | 212 | stick_post( $post_id ); |
213 | 213 | |
214 | 214 | $post2 = array( 'sticky' => false ); |
… |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
220 | 220 | function test_password_transition_unsticky() { |
221 | 221 | // when transitioning to private status or adding a post password, post should be un-stuck |
222 | 222 | $editor_id = $this->make_user_by_role( 'editor' ); |
223 | | $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) ); |
| 223 | $post_id = self::factory()->post->create( array( 'post_author' => $editor_id ) ); |
224 | 224 | stick_post( $post_id ); |
225 | 225 | |
226 | 226 | $post2 = array( 'post_password' => 'foobar', 'sticky' => false ); |
… |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
234 | 234 | |
235 | 235 | $yesterday = strtotime( '-1 day' ); |
236 | 236 | |
237 | | $post_id = self::$factory->post->create( array( |
| 237 | $post_id = self::factory()->post->create( array( |
238 | 238 | 'post_title' => 'Post Revision Test', |
239 | 239 | 'post_content' => 'Not edited', |
240 | 240 | 'post_author' => $editor_id, |
… |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
263 | 263 | function test_edit_attachment() { |
264 | 264 | $editor_id = $this->make_user_by_role( 'editor' ); |
265 | 265 | |
266 | | $post_id = self::$factory->post->create( array( |
| 266 | $post_id = self::factory()->post->create( array( |
267 | 267 | 'post_title' => 'Post Revision Test', |
268 | 268 | 'post_content' => 'Not edited', |
269 | 269 | 'post_status' => 'inherit', |
… |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
282 | 282 | function test_use_invalid_post_status() { |
283 | 283 | $editor_id = $this->make_user_by_role( 'editor' ); |
284 | 284 | |
285 | | $post_id = self::$factory->post->create( array( |
| 285 | $post_id = self::factory()->post->create( array( |
286 | 286 | 'post_title' => 'Post Revision Test', |
287 | 287 | 'post_content' => 'Not edited', |
288 | 288 | 'post_author' => $editor_id, |
… |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
302 | 302 | function test_loss_of_categories_on_edit() { |
303 | 303 | $editor_id = $this->make_user_by_role( 'editor' ); |
304 | 304 | |
305 | | $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) ); |
306 | | $term_id = self::$factory->category->create(); |
307 | | self::$factory->term->add_post_terms( $post_id, $term_id, 'category', true ); |
| 305 | $post_id = self::factory()->post->create( array( 'post_author' => $editor_id ) ); |
| 306 | $term_id = self::factory()->category->create(); |
| 307 | self::factory()->term->add_post_terms( $post_id, $term_id, 'category', true ); |
308 | 308 | $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' ); |
309 | 309 | $this->assertContains( $term_id, $term_ids ); |
310 | 310 | |
… |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
322 | 322 | function test_clear_categories_on_edit() { |
323 | 323 | $editor_id = $this->make_user_by_role( 'editor' ); |
324 | 324 | |
325 | | $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) ); |
326 | | $term_id = self::$factory->category->create(); |
327 | | self::$factory->term->add_post_terms( $post_id, $term_id, 'category', true ); |
| 325 | $post_id = self::factory()->post->create( array( 'post_author' => $editor_id ) ); |
| 326 | $term_id = self::factory()->category->create(); |
| 327 | self::factory()->term->add_post_terms( $post_id, $term_id, 'category', true ); |
328 | 328 | $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' ); |
329 | 329 | $this->assertContains( $term_id, $term_ids ); |
330 | 330 | |
… |
… |
class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { |
365 | 365 | $editor_id = $this->make_user_by_role( 'editor' ); |
366 | 366 | |
367 | 367 | // Add a dummy post |
368 | | $post_id = self::$factory->post->create( array( |
| 368 | $post_id = self::factory()->post->create( array( |
369 | 369 | 'post_title' => 'Post Enclosure Test', |
370 | 370 | 'post_content' => 'Fake content', |
371 | 371 | 'post_author' => $editor_id, |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getComment.php tests/phpunit/tests/xmlrpc/wp/getComment.php
index f80d357..1e6bda1 100644
|
|
class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { |
13 | 13 | function setUp() { |
14 | 14 | parent::setUp(); |
15 | 15 | |
16 | | $this->post_id = self::$factory->post->create(); |
| 16 | $this->post_id = self::factory()->post->create(); |
17 | 17 | |
18 | 18 | $this->parent_comment_data = array( |
19 | 19 | 'comment_post_ID' => $this->post_id, |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getComments.php tests/phpunit/tests/xmlrpc/wp/getComments.php
index 261bf95..a4bdf22 100644
|
|
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
21 | 21 | } |
22 | 22 | |
23 | 23 | function test_capable_user() { |
24 | | $this->post_id = self::$factory->post->create(); |
25 | | self::$factory->comment->create_post_comments( $this->post_id, 2 ); |
| 24 | $this->post_id = self::factory()->post->create(); |
| 25 | self::factory()->comment->create_post_comments( $this->post_id, 2 ); |
26 | 26 | |
27 | 27 | $this->make_user_by_role( 'editor' ); |
28 | 28 | |
… |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
36 | 36 | } |
37 | 37 | |
38 | 38 | function test_post_filter() { |
39 | | $this->post_id = self::$factory->post->create(); |
40 | | self::$factory->comment->create_post_comments( $this->post_id, 2 ); |
| 39 | $this->post_id = self::factory()->post->create(); |
| 40 | self::factory()->comment->create_post_comments( $this->post_id, 2 ); |
41 | 41 | |
42 | 42 | $this->make_user_by_role( 'editor' ); |
43 | 43 | |
… |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
52 | 52 | } |
53 | 53 | |
54 | 54 | function test_number_filter() { |
55 | | $this->post_id = self::$factory->post->create(); |
56 | | self::$factory->comment->create_post_comments( $this->post_id, 11 ); |
| 55 | $this->post_id = self::factory()->post->create(); |
| 56 | self::factory()->comment->create_post_comments( $this->post_id, 11 ); |
57 | 57 | |
58 | 58 | $this->make_user_by_role( 'editor' ); |
59 | 59 | |
… |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
76 | 76 | function test_contributor_capabilities() { |
77 | 77 | $this->make_user_by_role( 'contributor' ); |
78 | 78 | $author_id = $this->make_user_by_role( 'author' ); |
79 | | $author_post_id = self::$factory->post->create( array( |
| 79 | $author_post_id = self::factory()->post->create( array( |
80 | 80 | 'post_title' => 'Author', |
81 | 81 | 'post_author' => $author_id, |
82 | 82 | 'post_status' => 'publish' |
83 | 83 | ) ); |
84 | 84 | |
85 | | self::$factory->comment->create( array( |
| 85 | self::factory()->comment->create( array( |
86 | 86 | 'comment_post_ID' => $author_post_id, |
87 | 87 | 'comment_author' => "Commenter 1", |
88 | 88 | 'comment_author_url' => "http://example.com/1/", |
… |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
90 | 90 | ) ); |
91 | 91 | |
92 | 92 | $editor_id = $this->make_user_by_role( 'editor' ); |
93 | | $editor_post_id = self::$factory->post->create( array( |
| 93 | $editor_post_id = self::factory()->post->create( array( |
94 | 94 | 'post_title' => 'Editor', |
95 | 95 | 'post_author' => $editor_id, |
96 | 96 | 'post_status' => 'publish' |
97 | 97 | ) ); |
98 | 98 | |
99 | | self::$factory->comment->create( array( |
| 99 | self::factory()->comment->create( array( |
100 | 100 | 'comment_post_ID' => $editor_post_id, |
101 | 101 | 'comment_author' => 'Commenter 2', |
102 | 102 | 'comment_author_url' => 'http://example.com/2/', |
… |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
110 | 110 | |
111 | 111 | function test_author_capabilities() { |
112 | 112 | $author_id = $this->make_user_by_role( 'author' ); |
113 | | $author_post_id = self::$factory->post->create( array( |
| 113 | $author_post_id = self::factory()->post->create( array( |
114 | 114 | 'post_title' => 'Author', |
115 | 115 | 'post_author' => $author_id, |
116 | 116 | 'post_status' => 'publish' |
117 | 117 | ) ); |
118 | 118 | |
119 | | self::$factory->comment->create( array( |
| 119 | self::factory()->comment->create( array( |
120 | 120 | 'comment_post_ID' => $author_post_id, |
121 | 121 | 'comment_author' => 'Commenter 1', |
122 | 122 | 'comment_author_url' => 'http://example.com/1/', |
… |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
124 | 124 | ) ); |
125 | 125 | |
126 | 126 | $editor_id = $this->make_user_by_role( 'editor' ); |
127 | | $editor_post_id = self::$factory->post->create( array( |
| 127 | $editor_post_id = self::factory()->post->create( array( |
128 | 128 | 'post_title' => 'Editor', |
129 | 129 | 'post_author' => $editor_id, |
130 | 130 | 'post_status' => 'publish' |
131 | 131 | ) ); |
132 | 132 | |
133 | | self::$factory->comment->create( array( |
| 133 | self::factory()->comment->create( array( |
134 | 134 | 'comment_post_ID' => $editor_post_id, |
135 | 135 | 'comment_author' => 'Commenter 2', |
136 | 136 | 'comment_author_url' => 'http://example.com/2/', |
… |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
166 | 166 | |
167 | 167 | function test_editor_capabilities() { |
168 | 168 | $author_id = $this->make_user_by_role( 'author' ); |
169 | | $author_post_id = self::$factory->post->create( array( |
| 169 | $author_post_id = self::factory()->post->create( array( |
170 | 170 | 'post_title' => 'Author', |
171 | 171 | 'post_author' => $author_id, |
172 | 172 | 'post_status' => 'publish' |
173 | 173 | ) ); |
174 | 174 | |
175 | | self::$factory->comment->create( array( |
| 175 | self::factory()->comment->create( array( |
176 | 176 | 'comment_post_ID' => $author_post_id, |
177 | 177 | 'comment_author' => 'Commenter 1', |
178 | 178 | 'comment_author_url' => 'http://example.com/1/', |
… |
… |
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { |
180 | 180 | )); |
181 | 181 | |
182 | 182 | $editor_id = $this->make_user_by_role( 'editor' ); |
183 | | $editor_post_id = self::$factory->post->create( array( |
| 183 | $editor_post_id = self::factory()->post->create( array( |
184 | 184 | 'post_title' => 'Editor', |
185 | 185 | 'post_author' => $editor_id, |
186 | 186 | 'post_status' => 'publish' |
187 | 187 | ) ); |
188 | 188 | |
189 | | self::$factory->comment->create(array( |
| 189 | self::factory()->comment->create(array( |
190 | 190 | 'comment_post_ID' => $editor_post_id, |
191 | 191 | 'comment_author' => 'Commenter 2', |
192 | 192 | 'comment_author_url' => 'http://example.com/2/', |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getPost.php tests/phpunit/tests/xmlrpc/wp/getPost.php
index 345a8a7..6e6ecae 100644
|
|
class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { |
122 | 122 | function test_valid_page() { |
123 | 123 | $this->make_user_by_role( 'editor' ); |
124 | 124 | |
125 | | $parent_page_id = self::$factory->post->create( array( 'post_type' => 'page' ) ); |
126 | | $child_page_id = self::$factory->post->create( array( |
| 125 | $parent_page_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); |
| 126 | $child_page_id = self::factory()->post->create( array( |
127 | 127 | 'post_type' => 'page', |
128 | 128 | 'post_parent' => $parent_page_id, |
129 | 129 | 'menu_order' => 2 |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getPosts.php tests/phpunit/tests/xmlrpc/wp/getPosts.php
index 62bac31..3d8dff4 100644
|
|
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
54 | 54 | $post_ids = array(); |
55 | 55 | $num_posts = 4; |
56 | 56 | foreach ( range( 1, $num_posts ) as $i ) { |
57 | | $post_ids[] = self::$factory->post->create( array( |
| 57 | $post_ids[] = self::factory()->post->create( array( |
58 | 58 | 'post_type' => $cpt_name, |
59 | 59 | 'post_date' => date( 'Y-m-d H:i:s', time() + $i ) |
60 | 60 | ) ); |
… |
… |
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
80 | 80 | // add comments to some of the posts |
81 | 81 | foreach ( $post_ids as $key => $post_id ) { |
82 | 82 | // Larger post IDs will get more comments. |
83 | | self::$factory->comment->create_post_comments( $post_id, $key ); |
| 83 | self::factory()->comment->create_post_comments( $post_id, $key ); |
84 | 84 | } |
85 | 85 | |
86 | 86 | // get results ordered by comment count |
… |
… |
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
109 | 109 | |
110 | 110 | function test_fields() { |
111 | 111 | $this->make_user_by_role( 'editor' ); |
112 | | self::$factory->post->create(); |
| 112 | self::factory()->post->create(); |
113 | 113 | |
114 | 114 | // check default fields |
115 | 115 | $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor' ) ); |
… |
… |
class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { |
136 | 136 | function test_search() { |
137 | 137 | $this->make_user_by_role( 'editor' ); |
138 | 138 | |
139 | | $post_ids[] = self::$factory->post->create( array( 'post_title' => 'First: ' . rand_str() ) ); |
140 | | $post_ids[] = self::$factory->post->create( array( 'post_title' => 'Second: ' . rand_str() ) ); |
| 139 | $post_ids[] = self::factory()->post->create( array( 'post_title' => 'First: ' . rand_str() ) ); |
| 140 | $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Second: ' . rand_str() ) ); |
141 | 141 | |
142 | 142 | // Search for none of them |
143 | 143 | $filter = array( 's' => rand_str() ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getRevisions.php tests/phpunit/tests/xmlrpc/wp/getRevisions.php
index 831a603..a407c65 100644
|
|
class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { |
14 | 14 | function test_incapable_user() { |
15 | 15 | $this->make_user_by_role( 'subscriber' ); |
16 | 16 | |
17 | | $post_id = self::$factory->post->create(); |
| 17 | $post_id = self::factory()->post->create(); |
18 | 18 | |
19 | 19 | $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'subscriber', 'subscriber', $post_id ) ); |
20 | 20 | $this->assertInstanceOf( 'IXR_Error', $result ); |
… |
… |
class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { |
24 | 24 | function test_capable_user() { |
25 | 25 | $this->make_user_by_role( 'editor' ); |
26 | 26 | |
27 | | $post_id = self::$factory->post->create(); |
| 27 | $post_id = self::factory()->post->create(); |
28 | 28 | $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) ); |
29 | 29 | $this->assertNotInstanceOf( 'IXR_Error', $result ); |
30 | 30 | } |
… |
… |
class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { |
32 | 32 | function test_revision_count() { |
33 | 33 | $this->make_user_by_role( 'editor' ); |
34 | 34 | |
35 | | $post_id = self::$factory->post->create(); |
| 35 | $post_id = self::factory()->post->create(); |
36 | 36 | wp_insert_post( array( 'ID' => $post_id, 'post_content' => 'Edit 1' ) ); // Create the initial revision |
37 | 37 | |
38 | 38 | $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getTerms.php tests/phpunit/tests/xmlrpc/wp/getTerms.php
index b8d1bdb..e6b459e 100644
|
|
class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { |
106 | 106 | $cat1 = wp_create_category( 'wp.getTerms_' . rand_str( 16 ) ); |
107 | 107 | $cat2 = wp_create_category( 'wp.getTerms_' . rand_str( 16 ) ); |
108 | 108 | |
109 | | self::$factory->post->create_many( 5, array( 'post_category' => array( $cat1 ) ) ); |
110 | | self::$factory->post->create_many( 3, array( 'post_category' => array( $cat2 ) ) ); |
| 109 | self::factory()->post->create_many( 5, array( 'post_category' => array( $cat1 ) ) ); |
| 110 | self::factory()->post->create_many( 3, array( 'post_category' => array( $cat2 ) ) ); |
111 | 111 | |
112 | 112 | $filter = array( 'orderby' => 'count', 'order' => 'DESC' ); |
113 | 113 | $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/getUsers.php tests/phpunit/tests/xmlrpc/wp/getUsers.php
index 81fc833..27a7556 100644
|
|
class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { |
79 | 79 | if ( is_multisite() ) |
80 | 80 | grant_super_admin( $administrator_id ); |
81 | 81 | |
82 | | self::$factory->user->create_many( 5 ); |
| 82 | self::factory()->user->create_many( 5 ); |
83 | 83 | |
84 | 84 | $user_ids = get_users( array( 'fields' => 'ID' ) ); |
85 | 85 | |
-
diff --git tests/phpunit/tests/xmlrpc/wp/newComment.php tests/phpunit/tests/xmlrpc/wp/newComment.php
index 5ac6ae4..eb0f3b7 100644
|
|
|
6 | 6 | class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { |
7 | 7 | function test_new_comment_post_closed() { |
8 | 8 | $this->make_user_by_role( 'administrator' ); |
9 | | $post = self::$factory->post->create_and_get( array( |
| 9 | $post = self::factory()->post->create_and_get( array( |
10 | 10 | 'comment_status' => 'closed' |
11 | 11 | ) ); |
12 | 12 | |
-
diff --git tests/phpunit/tests/xmlrpc/wp/newPost.php tests/phpunit/tests/xmlrpc/wp/newPost.php
index 4c881b8..3f9343f 100644
|
|
class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { |
128 | 128 | |
129 | 129 | // create attachment |
130 | 130 | $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); |
131 | | $attachment_id = self::$factory->attachment->create_upload_object( $filename ); |
| 131 | $attachment_id = self::factory()->attachment->create_upload_object( $filename ); |
132 | 132 | |
133 | 133 | $post = array( 'post_title' => 'Post Thumbnail Test', 'post_thumbnail' => $attachment_id ); |
134 | 134 | $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); |
-
diff --git tests/phpunit/tests/xmlrpc/wp/restoreRevision.php tests/phpunit/tests/xmlrpc/wp/restoreRevision.php
index f53afa7..75f5d74 100644
|
|
class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase { |
10 | 10 | function setUp() { |
11 | 11 | parent::setUp(); |
12 | 12 | |
13 | | $this->post_id = self::$factory->post->create( array( 'post_content' => 'edit1' ) ); // Not saved as a revision |
| 13 | $this->post_id = self::factory()->post->create( array( 'post_content' => 'edit1' ) ); // Not saved as a revision |
14 | 14 | // First saved revision on update, see https://core.trac.wordpress.org/changeset/24650 |
15 | 15 | wp_insert_post( array( 'ID' => $this->post_id, 'post_content' => 'edit2' ) ); |
16 | 16 | |