mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Unit Tests: one $factory to rule them all, and it shall be static.
Using more than one instance of `WP_UnitTest_Factory` causes all kinds of craziness, due to out-of-sync internal generator sequences. Since we want to use `setUpBeforeClass`, we were creating ad hoc instances. To avoid that, we were injecting one `static` instance via Dependency Injection in `wpSetUpBeforeClass`. All tests should really use the `static` instance, so we will remove the instance prop `$factory`. Replace `$this->factory` with `self::$factory` over 2000 times. Rewrite all of the tests that were hard-coding dynamic values. #YOLOFriday git-svn-id: https://develop.svn.wordpress.org/trunk@35225 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -45,50 +45,50 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_permalink() {
|
||||
$post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) );
|
||||
$this->go_to( get_permalink( $post_id ) );
|
||||
$this->assertQueryTrue('is_single', 'is_singular');
|
||||
}
|
||||
|
||||
function test_post_comments_feed() {
|
||||
$post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) );
|
||||
$this->factory->comment->create_post_comments( $post_id, 2 );
|
||||
$post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) );
|
||||
self::$factory->comment->create_post_comments( $post_id, 2 );
|
||||
$this->go_to( get_post_comments_feed_link( $post_id ) );
|
||||
$this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed');
|
||||
}
|
||||
|
||||
|
||||
function test_post_comments_feed_with_no_comments() {
|
||||
$post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) );
|
||||
$this->go_to( get_post_comments_feed_link( $post_id ) );
|
||||
$this->assertQueryTrue('is_feed', 'is_single', 'is_singular', 'is_comment_feed');
|
||||
}
|
||||
|
||||
function test_page() {
|
||||
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) );
|
||||
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) );
|
||||
$this->go_to( get_permalink( $page_id ) );
|
||||
$this->assertQueryTrue('is_page','is_singular');
|
||||
}
|
||||
|
||||
function test_parent_page() {
|
||||
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$this->go_to( get_permalink( $page_id ) );
|
||||
|
||||
$this->assertQueryTrue('is_page','is_singular');
|
||||
}
|
||||
|
||||
function test_child_page_1() {
|
||||
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
|
||||
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
|
||||
$this->go_to( get_permalink( $page_id ) );
|
||||
|
||||
$this->assertQueryTrue('is_page','is_singular');
|
||||
}
|
||||
|
||||
function test_child_page_2() {
|
||||
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
|
||||
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
|
||||
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
|
||||
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
|
||||
$this->go_to( get_permalink( $page_id ) );
|
||||
|
||||
$this->assertQueryTrue('is_page','is_singular');
|
||||
@@ -97,9 +97,9 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// '(about)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1'
|
||||
function test_page_trackback() {
|
||||
$page_ids = array();
|
||||
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
|
||||
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
|
||||
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
|
||||
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
|
||||
foreach ( $page_ids as $page_id ) {
|
||||
$url = get_permalink( $page_id );
|
||||
$this->go_to("{$url}trackback/");
|
||||
@@ -116,11 +116,11 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
//'(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]'
|
||||
function test_page_feed() {
|
||||
$page_ids = array();
|
||||
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
|
||||
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
|
||||
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
|
||||
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
|
||||
foreach ( $page_ids as $page_id ) {
|
||||
$this->factory->comment->create_post_comments( $page_id, 2 );
|
||||
self::$factory->comment->create_post_comments( $page_id, 2 );
|
||||
$url = get_permalink( $page_id );
|
||||
$this->go_to("{$url}feed/");
|
||||
|
||||
@@ -135,9 +135,9 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
|
||||
function test_page_feed_with_no_comments() {
|
||||
$page_ids = array();
|
||||
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
|
||||
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
|
||||
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
|
||||
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
|
||||
foreach ( $page_ids as $page_id ) {
|
||||
$url = get_permalink( $page_id );
|
||||
$this->go_to("{$url}feed/");
|
||||
@@ -154,11 +154,11 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]'
|
||||
function test_page_feed_atom() {
|
||||
$page_ids = array();
|
||||
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
|
||||
$page_ids[] = $page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
|
||||
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) );
|
||||
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) );
|
||||
$page_ids[] = $page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) );
|
||||
foreach ( $page_ids as $page_id ) {
|
||||
$this->factory->comment->create_post_comments( $page_id, 2 );
|
||||
self::$factory->comment->create_post_comments( $page_id, 2 );
|
||||
|
||||
$url = get_permalink( $page_id );
|
||||
$this->go_to("{$url}feed/atom/");
|
||||
@@ -174,7 +174,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
|
||||
// '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]'
|
||||
function test_page_page_2() {
|
||||
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
|
||||
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
|
||||
$this->go_to("/about/page/2/");
|
||||
|
||||
// make sure the correct wp_query flags are set
|
||||
@@ -187,7 +187,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
|
||||
// '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]'
|
||||
function test_page_page_2_no_slash() {
|
||||
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
|
||||
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
|
||||
$this->go_to("/about/page2/");
|
||||
|
||||
// make sure the correct wp_query flags are set
|
||||
@@ -201,7 +201,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// FIXME: what is this for?
|
||||
// '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]'
|
||||
function test_pagination_of_posts_page() {
|
||||
$page_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
|
||||
$page_id = self::$factory->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) );
|
||||
update_option( 'show_on_front', 'page' );
|
||||
update_option( 'page_for_posts', $page_id );
|
||||
|
||||
@@ -223,7 +223,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// 'feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]',
|
||||
// '(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]',
|
||||
function test_main_feed_2() {
|
||||
$this->factory->post->create(); // @test_404
|
||||
self::$factory->post->create(); // @test_404
|
||||
$feeds = array('feed', 'rdf', 'rss', 'rss2', 'atom');
|
||||
|
||||
// long version
|
||||
@@ -241,7 +241,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_main_feed() {
|
||||
$this->factory->post->create(); // @test_404
|
||||
self::$factory->post->create(); // @test_404
|
||||
$types = array('rss2', 'rss', 'atom');
|
||||
foreach ($types as $type) {
|
||||
$this->go_to(get_feed_link($type));
|
||||
@@ -252,7 +252,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]',
|
||||
function test_paged() {
|
||||
update_option( 'posts_per_page', 2 );
|
||||
$this->factory->post->create_many( 5 );
|
||||
self::$factory->post->create_many( 5 );
|
||||
for ( $i = 2; $i <= 3; $i++ ) {
|
||||
$this->go_to("/page/{$i}/");
|
||||
$this->assertQueryTrue('is_home', 'is_paged');
|
||||
@@ -262,8 +262,8 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// 'comments/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1',
|
||||
// 'comments/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1',
|
||||
function test_main_comments_feed() {
|
||||
$post_id = $this->factory->post->create( array( 'post_title' => 'hello-world' ) );
|
||||
$this->factory->comment->create_post_comments( $post_id, 2 );
|
||||
$post_id = self::$factory->post->create( array( 'post_title' => 'hello-world' ) );
|
||||
self::$factory->comment->create_post_comments( $post_id, 2 );
|
||||
|
||||
// check the url as generated by get_post_comments_feed_link()
|
||||
$this->go_to( get_post_comments_feed_link( $post_id ) );
|
||||
@@ -306,7 +306,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// 'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]',
|
||||
function test_search_paged() {
|
||||
update_option( 'posts_per_page', 2 );
|
||||
$this->factory->post->create_many( 3, array( 'post_title' => 'test' ) );
|
||||
self::$factory->post->create_many( 3, array( 'post_title' => 'test' ) );
|
||||
$this->go_to('/search/test/page/2/');
|
||||
$this->assertQueryTrue('is_search', 'is_paged');
|
||||
}
|
||||
@@ -328,7 +328,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// 'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
|
||||
// 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
|
||||
function test_category_feed() {
|
||||
$this->factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
|
||||
self::$factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
|
||||
// check the long form
|
||||
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
|
||||
foreach ($types as $type) {
|
||||
@@ -347,14 +347,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// 'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]',
|
||||
function test_category_paged() {
|
||||
update_option( 'posts_per_page', 2 );
|
||||
$this->factory->post->create_many( 3 );
|
||||
self::$factory->post->create_many( 3 );
|
||||
$this->go_to('/category/uncategorized/page/2/');
|
||||
$this->assertQueryTrue('is_archive', 'is_category', 'is_paged');
|
||||
}
|
||||
|
||||
// 'category/(.+?)/?$' => 'index.php?category_name=$matches[1]',
|
||||
function test_category() {
|
||||
$this->factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
|
||||
self::$factory->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) );
|
||||
$this->go_to('/category/cat-a/');
|
||||
$this->assertQueryTrue('is_archive', 'is_category');
|
||||
}
|
||||
@@ -362,7 +362,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// 'tag/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
|
||||
// 'tag/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
|
||||
function test_tag_feed() {
|
||||
$this->factory->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) );
|
||||
self::$factory->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) );
|
||||
// check the long form
|
||||
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
|
||||
foreach ($types as $type) {
|
||||
@@ -381,16 +381,16 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// 'tag/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]',
|
||||
function test_tag_paged() {
|
||||
update_option( 'posts_per_page', 2 );
|
||||
$post_ids = $this->factory->post->create_many( 3 );
|
||||
$post_ids = self::$factory->post->create_many( 3 );
|
||||
foreach ( $post_ids as $post_id )
|
||||
$this->factory->term->add_post_terms( $post_id, 'tag-a', 'post_tag' );
|
||||
self::$factory->term->add_post_terms( $post_id, 'tag-a', 'post_tag' );
|
||||
$this->go_to('/tag/tag-a/page/2/');
|
||||
$this->assertQueryTrue('is_archive', 'is_tag', 'is_paged');
|
||||
}
|
||||
|
||||
// 'tag/(.+?)/?$' => 'index.php?tag=$matches[1]',
|
||||
function test_tag() {
|
||||
$term_id = $this->factory->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) );
|
||||
$term_id = self::$factory->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) );
|
||||
$this->go_to('/tag/tag-a/');
|
||||
$this->assertQueryTrue('is_archive', 'is_tag');
|
||||
|
||||
@@ -409,7 +409,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
|
||||
// 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
|
||||
function test_author_feed() {
|
||||
$this->factory->user->create( array( 'user_login' => 'user-a' ) );
|
||||
self::$factory->user->create( array( 'user_login' => 'user-a' ) );
|
||||
// check the long form
|
||||
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
|
||||
foreach ($types as $type) {
|
||||
@@ -428,22 +428,22 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]',
|
||||
function test_author_paged() {
|
||||
update_option( 'posts_per_page', 2 );
|
||||
$user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) );
|
||||
$this->factory->post->create_many( 3, array( 'post_author' => $user_id ) );
|
||||
$user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) );
|
||||
self::$factory->post->create_many( 3, array( 'post_author' => $user_id ) );
|
||||
$this->go_to('/author/user-a/page/2/');
|
||||
$this->assertQueryTrue('is_archive', 'is_author', 'is_paged');
|
||||
}
|
||||
|
||||
// 'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]',
|
||||
function test_author() {
|
||||
$user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) );
|
||||
$this->factory->post->create( array( 'post_author' => $user_id ) );
|
||||
$user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) );
|
||||
self::$factory->post->create( array( 'post_author' => $user_id ) );
|
||||
$this->go_to('/author/user-a/');
|
||||
$this->assertQueryTrue('is_archive', 'is_author');
|
||||
}
|
||||
|
||||
function test_author_with_no_posts() {
|
||||
$user_id = $this->factory->user->create( array( 'user_login' => 'user-a' ) );
|
||||
$user_id = self::$factory->user->create( array( 'user_login' => 'user-a' ) );
|
||||
$this->go_to('/author/user-a/');
|
||||
$this->assertQueryTrue('is_archive', 'is_author');
|
||||
}
|
||||
@@ -451,7 +451,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// '([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]',
|
||||
// '([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]',
|
||||
function test_ymd_feed() {
|
||||
$this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
// check the long form
|
||||
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
|
||||
foreach ($types as $type) {
|
||||
@@ -470,14 +470,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// '([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]',
|
||||
function test_ymd_paged() {
|
||||
update_option( 'posts_per_page', 2 );
|
||||
$this->factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
$this->go_to('/2007/09/04/page/2/');
|
||||
$this->assertQueryTrue('is_archive', 'is_day', 'is_date', 'is_paged');
|
||||
}
|
||||
|
||||
// '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]',
|
||||
function test_ymd() {
|
||||
$this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
$this->go_to('/2007/09/04/');
|
||||
$this->assertQueryTrue('is_archive', 'is_day', 'is_date');
|
||||
}
|
||||
@@ -485,7 +485,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
|
||||
// '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
|
||||
function test_ym_feed() {
|
||||
$this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
// check the long form
|
||||
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
|
||||
foreach ($types as $type) {
|
||||
@@ -504,14 +504,14 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]',
|
||||
function test_ym_paged() {
|
||||
update_option( 'posts_per_page', 2 );
|
||||
$this->factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
$this->go_to('/2007/09/page/2/');
|
||||
$this->assertQueryTrue('is_archive', 'is_date', 'is_month', 'is_paged');
|
||||
}
|
||||
|
||||
// '([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]',
|
||||
function test_ym() {
|
||||
$this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
$this->go_to('/2007/09/');
|
||||
$this->assertQueryTrue('is_archive', 'is_date', 'is_month');
|
||||
}
|
||||
@@ -519,7 +519,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
|
||||
// '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
|
||||
function test_y_feed() {
|
||||
$this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
// check the long form
|
||||
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
|
||||
foreach ($types as $type) {
|
||||
@@ -538,21 +538,21 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]',
|
||||
function test_y_paged() {
|
||||
update_option( 'posts_per_page', 2 );
|
||||
$this->factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
self::$factory->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
$this->go_to('/2007/page/2/');
|
||||
$this->assertQueryTrue('is_archive', 'is_date', 'is_year', 'is_paged');
|
||||
}
|
||||
|
||||
// '([0-9]{4})/?$' => 'index.php?year=$matches[1]',
|
||||
function test_y() {
|
||||
$this->factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
self::$factory->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) );
|
||||
$this->go_to('/2007/');
|
||||
$this->assertQueryTrue('is_archive', 'is_date', 'is_year');
|
||||
}
|
||||
|
||||
// '([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',
|
||||
function test_post_trackback() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
$permalink = get_permalink( $post_id );
|
||||
$this->go_to("{$permalink}trackback/");
|
||||
$this->assertQueryTrue('is_single', 'is_singular', 'is_trackback');
|
||||
@@ -561,7 +561,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
// '([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]',
|
||||
// '([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]',
|
||||
function test_post_comment_feed() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
$permalink = get_permalink( $post_id );
|
||||
|
||||
$types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
|
||||
@@ -580,7 +580,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
|
||||
// '([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]',
|
||||
function test_post_paged_short() {
|
||||
$post_id = $this->factory->post->create( array(
|
||||
$post_id = self::$factory->post->create( array(
|
||||
'post_date' => '2007-09-04 00:00:00',
|
||||
'post_title' => 'a-post-with-multiple-pages',
|
||||
'post_content' => 'Page 1 <!--nextpage--> Page 2'
|
||||
@@ -593,7 +593,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
|
||||
// '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
|
||||
function test_post_attachment() {
|
||||
$post_id = $this->factory->post->create( array( 'post_type' => 'attachment' ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_type' => 'attachment' ) );
|
||||
$permalink = get_attachment_link( $post_id );
|
||||
$this->go_to($permalink);
|
||||
$this->assertQueryTrue('is_single', 'is_attachment', 'is_singular');
|
||||
@@ -629,8 +629,8 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
'public' => true
|
||||
) );
|
||||
|
||||
$tag_id = $this->factory->tag->create( array( 'slug' => 'tag-slug' ) );
|
||||
$post_id = $this->factory->post->create( array( 'post_type' => $cpt_name ) );
|
||||
$tag_id = self::$factory->tag->create( array( 'slug' => 'tag-slug' ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_type' => $cpt_name ) );
|
||||
wp_set_object_terms( $post_id, $tag_id, 'post_tag' );
|
||||
|
||||
$this->go_to( '/ptawtq/' );
|
||||
@@ -663,7 +663,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
'has_archive' => true,
|
||||
'public' => true
|
||||
) );
|
||||
$this->factory->post->create( array( 'post_type' => $cpt_name ) );
|
||||
self::$factory->post->create( array( 'post_type' => $cpt_name ) );
|
||||
|
||||
$this->go_to( "/$cpt_name/" );
|
||||
$this->assertQueryTrue( 'is_post_type_archive', 'is_archive' );
|
||||
@@ -683,7 +683,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_is_single() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
$this->go_to( "/?p=$post_id" );
|
||||
|
||||
$post = get_queried_object();
|
||||
@@ -714,12 +714,12 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
) );
|
||||
|
||||
// Create parent and child posts
|
||||
$parent_id = $this->factory->post->create( array(
|
||||
$parent_id = self::$factory->post->create( array(
|
||||
'post_type' => $post_type,
|
||||
'post_name' => 'foo'
|
||||
) );
|
||||
|
||||
$post_id = $this->factory->post->create( array(
|
||||
$post_id = self::$factory->post->create( array(
|
||||
'post_type' => $post_type,
|
||||
'post_name' => 'bar',
|
||||
'post_parent' => $parent_id
|
||||
@@ -750,10 +750,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
* @ticket 24674
|
||||
*/
|
||||
public function test_is_single_with_slug_that_begins_with_a_number_that_clashes_with_another_post_id() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
|
||||
$p2_name = $p1 . '-post';
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'slug' => $p2_name,
|
||||
) );
|
||||
|
||||
@@ -768,7 +768,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_is_page() {
|
||||
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
|
||||
$this->go_to( "/?page_id=$post_id" );
|
||||
|
||||
$post = get_queried_object();
|
||||
@@ -788,11 +788,11 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
* @ticket 16802
|
||||
*/
|
||||
function test_is_page_with_parent() {
|
||||
$parent_id = $this->factory->post->create( array(
|
||||
$parent_id = self::$factory->post->create( array(
|
||||
'post_type' => 'page',
|
||||
'post_name' => 'foo',
|
||||
) );
|
||||
$post_id = $this->factory->post->create( array(
|
||||
$post_id = self::$factory->post->create( array(
|
||||
'post_type' => 'page',
|
||||
'post_name' => 'bar',
|
||||
'post_parent' => $parent_id,
|
||||
@@ -818,7 +818,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_is_attachment() {
|
||||
$post_id = $this->factory->post->create( array( 'post_type' => 'attachment' ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_type' => 'attachment' ) );
|
||||
$this->go_to( "/?attachment_id=$post_id" );
|
||||
|
||||
$post = get_queried_object();
|
||||
@@ -839,10 +839,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
* @ticket 24674
|
||||
*/
|
||||
public function test_is_attachment_with_slug_that_begins_with_a_number_that_clashes_with_a_page_ID() {
|
||||
$p1 = $this->factory->post->create( array( 'post_type' => 'attachment' ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_type' => 'attachment' ) );
|
||||
|
||||
$p2_name = $p1 . '-attachment';
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_type' => 'attachment',
|
||||
'post_name' => $p2_name,
|
||||
) );
|
||||
@@ -861,10 +861,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
* @ticket 24674
|
||||
*/
|
||||
public function test_is_author_with_nicename_that_begins_with_a_number_that_clashes_with_another_author_id() {
|
||||
$u1 = $this->factory->user->create();
|
||||
$u1 = self::$factory->user->create();
|
||||
|
||||
$u2_name = $u1 . '_user';
|
||||
$u2 = $this->factory->user->create( array(
|
||||
$u2 = self::$factory->user->create( array(
|
||||
'user_nicename' => $u2_name,
|
||||
) );
|
||||
|
||||
@@ -882,10 +882,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
* @ticket 24674
|
||||
*/
|
||||
public function test_is_category_with_slug_that_begins_with_a_number_that_clashes_with_another_category_id() {
|
||||
$c1 = $this->factory->category->create();
|
||||
$c1 = self::$factory->category->create();
|
||||
|
||||
$c2_name = $c1 . '-category';
|
||||
$c2 = $this->factory->category->create( array(
|
||||
$c2 = self::$factory->category->create( array(
|
||||
'slug' => $c2_name,
|
||||
) );
|
||||
|
||||
@@ -903,10 +903,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
* @ticket 24674
|
||||
*/
|
||||
public function test_is_tag_with_slug_that_begins_with_a_number_that_clashes_with_another_tag_id() {
|
||||
$t1 = $this->factory->tag->create();
|
||||
$t1 = self::$factory->tag->create();
|
||||
|
||||
$t2_name = $t1 . '-tag';
|
||||
$t2 = $this->factory->tag->create( array(
|
||||
$t2 = self::$factory->tag->create( array(
|
||||
'slug' => $t2_name,
|
||||
) );
|
||||
|
||||
@@ -924,7 +924,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
* @ticket 24674
|
||||
*/
|
||||
public function test_is_page_with_page_id_zero_and_random_page_slug() {
|
||||
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
|
||||
$this->go_to( "/?page_id=$post_id" );
|
||||
|
||||
// override post ID to 0 temporarily for testing
|
||||
@@ -946,10 +946,10 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
* @ticket 24674
|
||||
*/
|
||||
public function test_is_page_with_page_slug_that_begins_with_a_number_that_clashes_with_a_page_ID() {
|
||||
$p1 = $this->factory->post->create( array( 'post_type' => 'page' ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_type' => 'page' ) );
|
||||
|
||||
$p2_name = $p1 . '-page';
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_type' => 'page',
|
||||
'post_name' => $p2_name,
|
||||
) );
|
||||
@@ -965,7 +965,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_is_page_template() {
|
||||
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
|
||||
update_post_meta($post_id, '_wp_page_template', 'example.php');
|
||||
$this->go_to( "/?page_id=$post_id" );
|
||||
$this->assertTrue( is_page_template( 'example.php' ) );
|
||||
@@ -975,7 +975,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
* @ticket 31271
|
||||
*/
|
||||
function test_is_page_template_default() {
|
||||
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
|
||||
$this->go_to( "/?page_id=$post_id" );
|
||||
$this->assertTrue( is_page_template( 'default' ) );
|
||||
$this->assertTrue( is_page_template( array( 'random', 'default' ) ) );
|
||||
@@ -985,7 +985,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
* @ticket 31271
|
||||
*/
|
||||
function test_is_page_template_array() {
|
||||
$post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
|
||||
update_post_meta($post_id, '_wp_page_template', 'example.php');
|
||||
$this->go_to( "/?page_id=$post_id" );
|
||||
$this->assertFalse( is_page_template( array( 'test.php' ) ) );
|
||||
|
||||
@@ -33,10 +33,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_before_array() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) );
|
||||
$p3 = $this->factory->post->create( array( 'post_date' => '2008-07-15 07:17:23',) );
|
||||
$p4 = $this->factory->post->create( array( 'post_date' => '2009-06-11 07:17:23',) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) );
|
||||
$p3 = self::$factory->post->create( array( 'post_date' => '2008-07-15 07:17:23',) );
|
||||
$p4 = self::$factory->post->create( array( 'post_date' => '2009-06-11 07:17:23',) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -57,8 +57,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* their minimum values when being used with "before".
|
||||
*/
|
||||
public function test_date_query_before_array_test_defaulting() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -74,10 +74,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_before_string() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) );
|
||||
$p3 = $this->factory->post->create( array( 'post_date' => '2008-07-15 07:17:23',) );
|
||||
$p4 = $this->factory->post->create( array( 'post_date' => '2009-06-11 07:17:23',) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2007-09-24 07:17:23',) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2008-03-29 07:17:23',) );
|
||||
$p3 = self::$factory->post->create( array( 'post_date' => '2008-07-15 07:17:23',) );
|
||||
$p4 = self::$factory->post->create( array( 'post_date' => '2009-06-11 07:17:23',) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -91,9 +91,9 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_after_array() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2009-10-18 10:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) );
|
||||
$p3 = $this->factory->post->create( array( 'post_date' => '2010-06-11 07:17:23', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2009-10-18 10:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) );
|
||||
$p3 = self::$factory->post->create( array( 'post_date' => '2010-06-11 07:17:23', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -115,8 +115,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* their maximum values when being used with "after".
|
||||
*/
|
||||
public function test_date_query_after_array_test_defaulting() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2008-12-18 10:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2008-12-18 10:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -132,9 +132,9 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_after_string() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) );
|
||||
$p3 = $this->factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) );
|
||||
$p3 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -148,9 +148,9 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_after_string_inclusive() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) );
|
||||
$p3 = $this->factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2009-12-18 09:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2009-12-18 10:42:29', ) );
|
||||
$p3 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -168,11 +168,11 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 26653
|
||||
*/
|
||||
public function test_date_query_inclusive_between_dates() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2006-12-18 09:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) );
|
||||
$p3 = $this->factory->post->create( array( 'post_date' => '2007-12-19 10:42:29', ) );
|
||||
$p4 = $this->factory->post->create( array( 'post_date' => '2008-12-19 10:42:29', ) );
|
||||
$p5 = $this->factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2006-12-18 09:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) );
|
||||
$p3 = self::$factory->post->create( array( 'post_date' => '2007-12-19 10:42:29', ) );
|
||||
$p4 = self::$factory->post->create( array( 'post_date' => '2008-12-19 10:42:29', ) );
|
||||
$p5 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -195,10 +195,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29908
|
||||
*/
|
||||
public function test_beforeafter_with_date_string_Y() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 13:00:00',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2007-05-07 13:00:00',
|
||||
) );
|
||||
|
||||
@@ -228,10 +228,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29908
|
||||
*/
|
||||
public function test_beforeafter_with_date_string_Y_inclusive() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 13:00:00',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2007-05-07 13:00:00',
|
||||
) );
|
||||
|
||||
@@ -263,10 +263,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29908
|
||||
*/
|
||||
public function test_beforeafter_with_date_string_Ym() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 13:00:00',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-04-07 13:00:00',
|
||||
) );
|
||||
|
||||
@@ -296,10 +296,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29908
|
||||
*/
|
||||
public function test_beforeafter_with_date_string_Ym_inclusive() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 13:00:00',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-04-07 13:00:00',
|
||||
) );
|
||||
|
||||
@@ -331,10 +331,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29908
|
||||
*/
|
||||
public function test_beforeafter_with_date_string_Ymd() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 13:00:00',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-05 13:00:00',
|
||||
) );
|
||||
|
||||
@@ -364,10 +364,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29908
|
||||
*/
|
||||
public function test_beforeafter_with_date_string_Ymd_inclusive() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 13:00:00',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-05 13:00:00',
|
||||
) );
|
||||
|
||||
@@ -399,10 +399,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29908
|
||||
*/
|
||||
public function test_beforeafter_with_date_string_YmdHi() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 14:05:00',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 14:04:00',
|
||||
) );
|
||||
|
||||
@@ -432,10 +432,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29908
|
||||
*/
|
||||
public function test_beforeafter_with_date_string_YmdHi_inclusive() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 14:05:00',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 14:04:00',
|
||||
) );
|
||||
|
||||
@@ -467,10 +467,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29908
|
||||
*/
|
||||
public function test_beforeafter_with_date_string_YmdHis() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 14:05:15',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 14:05:14',
|
||||
) );
|
||||
|
||||
@@ -500,10 +500,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29908
|
||||
*/
|
||||
public function test_beforeafter_with_date_string_YmdHis_inclusive() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 14:04:15',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 14:04:14',
|
||||
) );
|
||||
|
||||
@@ -535,10 +535,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29908
|
||||
*/
|
||||
public function test_beforeafter_with_date_string_non_parseable() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 14:05:15',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2008-05-06 14:05:14',
|
||||
) );
|
||||
|
||||
@@ -564,8 +564,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_year() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2010-12-19 10:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2010-12-19 10:42:29', ) );
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
array(
|
||||
@@ -578,8 +578,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_month() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2010-11-19 10:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2009-12-19 10:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2010-11-19 10:42:29', ) );
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
array(
|
||||
@@ -592,8 +592,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_week() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2009-01-02 10:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2010-03-19 10:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2009-01-02 10:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2010-03-19 10:42:29', ) );
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
array(
|
||||
@@ -606,8 +606,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_day() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2009-01-17 10:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2009-01-17 10:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2009-01-18 10:42:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -621,8 +621,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_dayofweek() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2014-10-20 10:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2014-10-20 10:42:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -639,8 +639,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 28063
|
||||
*/
|
||||
public function test_date_query_dayofweek_iso() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2014-10-31 10:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2014-10-30 10:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2014-10-31 10:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2014-10-30 10:42:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -654,8 +654,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_hour() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2014-10-21 13:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2014-10-21 12:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 13:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 12:42:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -673,8 +673,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_date_query_hour_should_not_ignore_0() {
|
||||
return;
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2014-10-21 00:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2014-10-21 01:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 00:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 01:42:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'year' => 2014,
|
||||
@@ -688,8 +688,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_minute() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2014-10-21 10:56:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:56:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -703,8 +703,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_second() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2014-10-21 10:42:21', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:21', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2014-10-21 10:42:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -718,11 +718,11 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_between_two_times() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2005-12-18 08:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2006-12-18 09:00:29', ) );
|
||||
$p3 = $this->factory->post->create( array( 'post_date' => '2007-12-18 10:42:29', ) );
|
||||
$p4 = $this->factory->post->create( array( 'post_date' => '2008-12-18 17:00:29', ) );
|
||||
$p5 = $this->factory->post->create( array( 'post_date' => '2009-12-18 18:42:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2005-12-18 08:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2006-12-18 09:00:29', ) );
|
||||
$p3 = self::$factory->post->create( array( 'post_date' => '2007-12-18 10:42:29', ) );
|
||||
$p4 = self::$factory->post->create( array( 'post_date' => '2008-12-18 17:00:29', ) );
|
||||
$p5 = self::$factory->post->create( array( 'post_date' => '2009-12-18 18:42:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -743,9 +743,9 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_relation_or() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2006-12-18 14:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) );
|
||||
$p3 = $this->factory->post->create( array( 'post_date' => '2007-12-19 10:34:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2006-12-18 14:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2007-01-18 10:42:29', ) );
|
||||
$p3 = self::$factory->post->create( array( 'post_date' => '2007-12-19 10:34:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -763,10 +763,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_date_query_compare_greater_than_or_equal_to() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2006-12-18 13:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) );
|
||||
$p3 = $this->factory->post->create( array( 'post_date' => '2007-12-19 14:37:29', ) );
|
||||
$p4 = $this->factory->post->create( array( 'post_date' => '2007-12-19 15:34:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2006-12-18 13:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) );
|
||||
$p3 = self::$factory->post->create( array( 'post_date' => '2007-12-19 14:37:29', ) );
|
||||
$p4 = self::$factory->post->create( array( 'post_date' => '2007-12-19 15:34:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -784,9 +784,9 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
public function test_date_params_monthnum_m_duplicate() {
|
||||
global $wpdb;
|
||||
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2006-05-18 13:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2007-09-18 14:34:29', ) );
|
||||
$p3 = $this->factory->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2006-05-18 13:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2007-09-18 14:34:29', ) );
|
||||
$p3 = self::$factory->post->create( array( 'post_date' => '2007-01-18 14:34:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -804,9 +804,9 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
public function test_date_params_week_w_duplicate() {
|
||||
global $wpdb;
|
||||
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2014-10-01 13:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2014-10-22 14:34:29', ) );
|
||||
$p3 = $this->factory->post->create( array( 'post_date' => '2014-10-15 14:34:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2014-10-01 13:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2014-10-22 14:34:29', ) );
|
||||
$p3 = self::$factory->post->create( array( 'post_date' => '2014-10-15 14:34:29', ) );
|
||||
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
@@ -825,10 +825,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 25775
|
||||
*/
|
||||
public function test_date_query_with_taxonomy_join() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2013-04-27 01:01:01',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2013-03-21 01:01:01',
|
||||
) );
|
||||
|
||||
@@ -857,10 +857,10 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29822
|
||||
*/
|
||||
public function test_date_query_one_nested_query() {
|
||||
$p1 = $this->factory->post->create( array( 'post_date' => '2004-10-01 13:42:29', ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_date' => '2004-01-22 14:34:29', ) );
|
||||
$p3 = $this->factory->post->create( array( 'post_date' => '1984-10-15 14:34:29', ) );
|
||||
$p4 = $this->factory->post->create( array( 'post_date' => '1985-10-15 14:34:29', ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_date' => '2004-10-01 13:42:29', ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_date' => '2004-01-22 14:34:29', ) );
|
||||
$p3 = self::$factory->post->create( array( 'post_date' => '1984-10-15 14:34:29', ) );
|
||||
$p4 = self::$factory->post->create( array( 'post_date' => '1985-10-15 14:34:29', ) );
|
||||
$posts = $this->_get_query_result( array(
|
||||
'date_query' => array(
|
||||
'relation' => 'OR',
|
||||
@@ -886,22 +886,22 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29822
|
||||
*/
|
||||
public function test_date_query_one_nested_query_multiple_columns_relation_and() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2012-03-05 15:30:55',
|
||||
) );
|
||||
$this->update_post_modified( $p1, '2014-11-03 14:43:00' );
|
||||
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2012-05-05 15:30:55',
|
||||
) );
|
||||
$this->update_post_modified( $p2, '2014-10-03 14:43:00' );
|
||||
|
||||
$p3 = $this->factory->post->create( array(
|
||||
$p3 = self::$factory->post->create( array(
|
||||
'post_date' => '2013-05-05 15:30:55',
|
||||
) );
|
||||
$this->update_post_modified( $p3, '2014-10-03 14:43:00' );
|
||||
|
||||
$p4 = $this->factory->post->create( array(
|
||||
$p4 = self::$factory->post->create( array(
|
||||
'post_date' => '2012-02-05 15:30:55',
|
||||
) );
|
||||
$this->update_post_modified( $p4, '2012-12-03 14:43:00' );
|
||||
@@ -937,27 +937,27 @@ class Tests_Query_DateQuery extends WP_UnitTestCase {
|
||||
* @ticket 29822
|
||||
*/
|
||||
public function test_date_query_nested_query_multiple_columns_mixed_relations() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2012-03-05 15:30:55',
|
||||
) );
|
||||
$this->update_post_modified( $p1, '2014-11-03 14:43:00' );
|
||||
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2012-05-05 15:30:55',
|
||||
) );
|
||||
$this->update_post_modified( $p2, '2014-10-03 14:43:00' );
|
||||
|
||||
$p3 = $this->factory->post->create( array(
|
||||
$p3 = self::$factory->post->create( array(
|
||||
'post_date' => '2013-05-05 15:30:55',
|
||||
) );
|
||||
$this->update_post_modified( $p3, '2014-10-03 14:43:00' );
|
||||
|
||||
$p4 = $this->factory->post->create( array(
|
||||
$p4 = self::$factory->post->create( array(
|
||||
'post_date' => '2012-02-05 15:30:55',
|
||||
) );
|
||||
$this->update_post_modified( $p4, '2012-12-03 14:43:00' );
|
||||
|
||||
$p5 = $this->factory->post->create( array(
|
||||
$p5 = self::$factory->post->create( array(
|
||||
'post_date' => '2014-02-05 15:30:55',
|
||||
) );
|
||||
$this->update_post_modified( $p5, '2013-12-03 14:43:00' );
|
||||
|
||||
@@ -37,11 +37,11 @@ class Tests_Query_IsTerm extends WP_UnitTestCase {
|
||||
|
||||
flush_rewrite_rules();
|
||||
|
||||
$this->tag_id = $this->factory->tag->create( array( 'slug' => 'tag-slug' ) );
|
||||
$this->cat_id = $this->factory->category->create( array( 'slug' => 'cat-slug' ) );
|
||||
$this->tax_id = $this->factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug' ) );
|
||||
$this->tax_id2 = $this->factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug2' ) );
|
||||
$this->post_id = $this->factory->post->create();
|
||||
$this->tag_id = self::$factory->tag->create( array( 'slug' => 'tag-slug' ) );
|
||||
$this->cat_id = self::$factory->category->create( array( 'slug' => 'cat-slug' ) );
|
||||
$this->tax_id = self::$factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug' ) );
|
||||
$this->tax_id2 = self::$factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug2' ) );
|
||||
$this->post_id = self::$factory->post->create();
|
||||
wp_set_object_terms( $this->post_id, $this->cat_id, 'category' );
|
||||
wp_set_object_terms( $this->post_id, array( $this->tax_id, $this->tax_id2 ), 'testtax' );
|
||||
|
||||
@@ -245,7 +245,7 @@ class Tests_Query_IsTerm extends WP_UnitTestCase {
|
||||
remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
|
||||
|
||||
register_taxonomy( 'testtax2', 'post' );
|
||||
$testtax2_term_id = $this->factory->term->create( array(
|
||||
$testtax2_term_id = self::$factory->term->create( array(
|
||||
'taxonomy' => 'testtax2',
|
||||
'slug' => 'testtax2-slug',
|
||||
) );
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
*/
|
||||
class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
public function test_meta_query_no_key() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', 'bar' );
|
||||
add_post_meta( $p2, 'oof', 'bar' );
|
||||
@@ -30,9 +30,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_no_value() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', 'bar' );
|
||||
add_post_meta( $p2, 'oof', 'bar' );
|
||||
@@ -54,8 +54,8 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_single_query_compare_default() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', 'bar' );
|
||||
|
||||
@@ -76,8 +76,8 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_single_query_compare_equals() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', 'bar' );
|
||||
|
||||
@@ -99,9 +99,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_single_query_compare_not_equals() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', 'bar' );
|
||||
add_post_meta( $p2, 'foo', 'baz' );
|
||||
@@ -124,9 +124,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_single_query_compare_arithmetic_comparisons() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', '1' );
|
||||
add_post_meta( $p2, 'foo', '2' );
|
||||
@@ -202,8 +202,8 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_single_query_compare_like() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', 'bar' );
|
||||
|
||||
@@ -225,9 +225,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_single_query_compare_not_like() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', 'bar' );
|
||||
add_post_meta( $p2, 'foo', 'rab' );
|
||||
@@ -250,9 +250,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_single_query_compare_between_not_between() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', '1' );
|
||||
add_post_meta( $p2, 'foo', '10' );
|
||||
@@ -294,8 +294,8 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_single_query_compare_regexp_rlike() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', 'bar' );
|
||||
add_post_meta( $p2, 'foo', 'baz' );
|
||||
@@ -335,8 +335,8 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_single_query_compare_not_regexp() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', 'bar' );
|
||||
add_post_meta( $p2, 'foo', 'baz' );
|
||||
@@ -359,9 +359,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_relation_default() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', 'foo value 1' );
|
||||
add_post_meta( $p1, 'bar', 'bar value 1' );
|
||||
@@ -389,18 +389,18 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_relation_or() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
add_post_meta( $post_id, 'foo', rand_str() );
|
||||
add_post_meta( $post_id, 'foo', rand_str() );
|
||||
$post_id2 = $this->factory->post->create();
|
||||
$post_id2 = self::$factory->post->create();
|
||||
add_post_meta( $post_id2, 'bar', 'val2' );
|
||||
$post_id3 = $this->factory->post->create();
|
||||
$post_id3 = self::$factory->post->create();
|
||||
add_post_meta( $post_id3, 'baz', rand_str() );
|
||||
$post_id4 = $this->factory->post->create();
|
||||
$post_id4 = self::$factory->post->create();
|
||||
add_post_meta( $post_id4, 'froo', rand_str() );
|
||||
$post_id5 = $this->factory->post->create();
|
||||
$post_id5 = self::$factory->post->create();
|
||||
add_post_meta( $post_id5, 'tango', 'val2' );
|
||||
$post_id6 = $this->factory->post->create();
|
||||
$post_id6 = self::$factory->post->create();
|
||||
add_post_meta( $post_id6, 'bar', 'val1' );
|
||||
|
||||
$query = new WP_Query( array(
|
||||
@@ -430,22 +430,22 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_query_relation_and() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
add_post_meta( $post_id, 'foo', rand_str() );
|
||||
add_post_meta( $post_id, 'foo', rand_str() );
|
||||
$post_id2 = $this->factory->post->create();
|
||||
$post_id2 = self::$factory->post->create();
|
||||
add_post_meta( $post_id2, 'bar', 'val2' );
|
||||
add_post_meta( $post_id2, 'foo', rand_str() );
|
||||
$post_id3 = $this->factory->post->create();
|
||||
$post_id3 = self::$factory->post->create();
|
||||
add_post_meta( $post_id3, 'baz', rand_str() );
|
||||
$post_id4 = $this->factory->post->create();
|
||||
$post_id4 = self::$factory->post->create();
|
||||
add_post_meta( $post_id4, 'froo', rand_str() );
|
||||
$post_id5 = $this->factory->post->create();
|
||||
$post_id5 = self::$factory->post->create();
|
||||
add_post_meta( $post_id5, 'tango', 'val2' );
|
||||
$post_id6 = $this->factory->post->create();
|
||||
$post_id6 = self::$factory->post->create();
|
||||
add_post_meta( $post_id6, 'bar', 'val1' );
|
||||
add_post_meta( $post_id6, 'foo', rand_str() );
|
||||
$post_id7 = $this->factory->post->create();
|
||||
$post_id7 = self::$factory->post->create();
|
||||
add_post_meta( $post_id7, 'foo', rand_str() );
|
||||
add_post_meta( $post_id7, 'froo', rand_str() );
|
||||
add_post_meta( $post_id7, 'baz', rand_str() );
|
||||
@@ -499,7 +499,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 30681
|
||||
*/
|
||||
public function test_meta_query_compare_exists() {
|
||||
$posts = $this->factory->post->create_many( 3 );
|
||||
$posts = self::$factory->post->create_many( 3 );
|
||||
add_post_meta( $posts[0], 'foo', 'bar' );
|
||||
add_post_meta( $posts[2], 'foo', 'baz' );
|
||||
|
||||
@@ -520,7 +520,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 30681
|
||||
*/
|
||||
public function test_meta_query_compare_exists_with_value_should_convert_to_equals() {
|
||||
$posts = $this->factory->post->create_many( 3 );
|
||||
$posts = self::$factory->post->create_many( 3 );
|
||||
add_post_meta( $posts[0], 'foo', 'bar' );
|
||||
add_post_meta( $posts[2], 'foo', 'baz' );
|
||||
|
||||
@@ -542,7 +542,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 30681
|
||||
*/
|
||||
public function test_meta_query_compare_not_exists_should_ignore_value() {
|
||||
$posts = $this->factory->post->create_many( 3 );
|
||||
$posts = self::$factory->post->create_many( 3 );
|
||||
add_post_meta( $posts[0], 'foo', 'bar' );
|
||||
add_post_meta( $posts[2], 'foo', 'baz' );
|
||||
|
||||
@@ -564,15 +564,15 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 18158
|
||||
*/
|
||||
public function test_meta_query_compare_not_exists() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
add_post_meta( $post_id, 'foo', rand_str() );
|
||||
$post_id2 = $this->factory->post->create();
|
||||
$post_id2 = self::$factory->post->create();
|
||||
add_post_meta( $post_id2, 'bar', rand_str() );
|
||||
$post_id3 = $this->factory->post->create();
|
||||
$post_id3 = self::$factory->post->create();
|
||||
add_post_meta( $post_id3, 'bar', rand_str() );
|
||||
$post_id4 = $this->factory->post->create();
|
||||
$post_id4 = self::$factory->post->create();
|
||||
add_post_meta( $post_id4, 'baz', rand_str() );
|
||||
$post_id5 = $this->factory->post->create();
|
||||
$post_id5 = self::$factory->post->create();
|
||||
add_post_meta( $post_id5, 'foo', rand_str() );
|
||||
|
||||
$query = new WP_Query( array(
|
||||
@@ -636,7 +636,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 29062
|
||||
*/
|
||||
public function test_meta_query_compare_not_exists_with_another_condition_relation_or() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
update_post_meta( $posts[0], 'color', 'orange' );
|
||||
update_post_meta( $posts[1], 'color', 'blue' );
|
||||
update_post_meta( $posts[1], 'vegetable', 'onion' );
|
||||
@@ -672,7 +672,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 24093
|
||||
*/
|
||||
public function test_meta_query_relation_or_compare_equals() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
add_post_meta( $posts[0], 'color', 'orange' );
|
||||
add_post_meta( $posts[1], 'color', 'blue' );
|
||||
add_post_meta( $posts[1], 'vegetable', 'onion' );
|
||||
@@ -705,7 +705,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 24093
|
||||
*/
|
||||
public function test_meta_query_relation_or_compare_equals_different_keys() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
add_post_meta( $posts[0], 'color', 'orange' );
|
||||
add_post_meta( $posts[1], 'color', 'blue' );
|
||||
add_post_meta( $posts[1], 'vegetable', 'onion' );
|
||||
@@ -738,7 +738,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 24093
|
||||
*/
|
||||
public function test_meta_query_relation_or_compare_equals_and_in() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
add_post_meta( $posts[0], 'color', 'orange' );
|
||||
add_post_meta( $posts[1], 'color', 'blue' );
|
||||
add_post_meta( $posts[1], 'vegetable', 'onion' );
|
||||
@@ -771,7 +771,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 24093
|
||||
*/
|
||||
public function test_meta_query_relation_or_compare_equals_and_like() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
add_post_meta( $posts[0], 'color', 'orange' );
|
||||
add_post_meta( $posts[1], 'color', 'blue' );
|
||||
add_post_meta( $posts[1], 'vegetable', 'onion' );
|
||||
@@ -804,7 +804,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 24093
|
||||
*/
|
||||
public function test_meta_query_relation_or_compare_equals_and_between() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
add_post_meta( $posts[0], 'number_of_colors', '2' );
|
||||
add_post_meta( $posts[1], 'number_of_colors', '5' );
|
||||
add_post_meta( $posts[1], 'vegetable', 'onion' );
|
||||
@@ -838,7 +838,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 24093
|
||||
*/
|
||||
public function test_meta_query_relation_and_compare_in_same_keys() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
add_post_meta( $posts[0], 'color', 'orange' );
|
||||
add_post_meta( $posts[1], 'color', 'blue' );
|
||||
add_post_meta( $posts[1], 'vegetable', 'onion' );
|
||||
@@ -873,7 +873,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 24093
|
||||
*/
|
||||
public function test_meta_query_relation_and_compare_in_different_keys() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
add_post_meta( $posts[0], 'color', 'orange' );
|
||||
add_post_meta( $posts[1], 'color', 'blue' );
|
||||
add_post_meta( $posts[1], 'vegetable', 'onion' );
|
||||
@@ -908,7 +908,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 24093
|
||||
*/
|
||||
public function test_meta_query_relation_and_compare_not_equals() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
add_post_meta( $posts[0], 'color', 'orange' );
|
||||
add_post_meta( $posts[1], 'color', 'blue' );
|
||||
add_post_meta( $posts[1], 'vegetable', 'onion' );
|
||||
@@ -942,7 +942,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 24093
|
||||
*/
|
||||
public function test_meta_query_relation_and_compare_not_equals_different_keys() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
|
||||
// !shallot, but orange.
|
||||
add_post_meta( $posts[0], 'color', 'orange' );
|
||||
@@ -983,7 +983,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 24093
|
||||
*/
|
||||
public function test_meta_query_relation_and_compare_not_equals_not_in() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
add_post_meta( $posts[0], 'color', 'orange' );
|
||||
add_post_meta( $posts[1], 'color', 'blue' );
|
||||
add_post_meta( $posts[1], 'vegetable', 'onion' );
|
||||
@@ -1017,7 +1017,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 24093
|
||||
*/
|
||||
public function test_meta_query_relation_and_compare_not_equals_and_not_like() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
add_post_meta( $posts[0], 'color', 'orange' );
|
||||
add_post_meta( $posts[1], 'color', 'blue' );
|
||||
add_post_meta( $posts[1], 'vegetable', 'onion' );
|
||||
@@ -1051,10 +1051,10 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 23033
|
||||
*/
|
||||
public function test_meta_query_decimal_results() {
|
||||
$post_1 = $this->factory->post->create();
|
||||
$post_2 = $this->factory->post->create();
|
||||
$post_3 = $this->factory->post->create();
|
||||
$post_4 = $this->factory->post->create();
|
||||
$post_1 = self::$factory->post->create();
|
||||
$post_2 = self::$factory->post->create();
|
||||
$post_3 = self::$factory->post->create();
|
||||
$post_4 = self::$factory->post->create();
|
||||
|
||||
update_post_meta( $post_1, 'decimal_value', '-0.3' );
|
||||
update_post_meta( $post_2, 'decimal_value', '0.23409844' );
|
||||
@@ -1226,7 +1226,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 29604
|
||||
*/
|
||||
public function test_meta_query_with_orderby_meta_value_relation_or() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
update_post_meta( $posts[0], 'foo', 5 );
|
||||
update_post_meta( $posts[1], 'foo', 6 );
|
||||
update_post_meta( $posts[2], 'foo', 4 );
|
||||
@@ -1265,7 +1265,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 29604
|
||||
*/
|
||||
public function test_meta_query_with_orderby_meta_value_relation_and() {
|
||||
$posts = $this->factory->post->create_many( 4 );
|
||||
$posts = self::$factory->post->create_many( 4 );
|
||||
update_post_meta( $posts[0], 'foo', 5 );
|
||||
update_post_meta( $posts[1], 'foo', 6 );
|
||||
update_post_meta( $posts[2], 'foo', 4 );
|
||||
@@ -1308,9 +1308,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 29642
|
||||
*/
|
||||
public function test_meta_query_nested() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', 'bar' );
|
||||
add_post_meta( $p2, 'foo2', 'bar' );
|
||||
@@ -1349,9 +1349,9 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 29642
|
||||
*/
|
||||
public function test_meta_query_nested_two_levels_deep() {
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
add_post_meta( $p1, 'foo', 'bar' );
|
||||
add_post_meta( $p3, 'foo2', 'bar' );
|
||||
@@ -1394,15 +1394,15 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_meta_between_not_between() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
add_post_meta( $post_id, 'time', 500 );
|
||||
$post_id2 = $this->factory->post->create();
|
||||
$post_id2 = self::$factory->post->create();
|
||||
add_post_meta( $post_id2, 'time', 1001 );
|
||||
$post_id3 = $this->factory->post->create();
|
||||
$post_id3 = self::$factory->post->create();
|
||||
add_post_meta( $post_id3, 'time', 0 );
|
||||
$post_id4 = $this->factory->post->create();
|
||||
$post_id4 = self::$factory->post->create();
|
||||
add_post_meta( $post_id4, 'time', 1 );
|
||||
$post_id5 = $this->factory->post->create();
|
||||
$post_id5 = self::$factory->post->create();
|
||||
add_post_meta( $post_id5, 'time', 1000 );
|
||||
|
||||
$args = array(
|
||||
@@ -1443,15 +1443,15 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_meta_default_compare() {
|
||||
// compare should default to IN when meta_value is an array
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
add_post_meta( $post_id, 'foo', 'bar' );
|
||||
$post_id2 = $this->factory->post->create();
|
||||
$post_id2 = self::$factory->post->create();
|
||||
add_post_meta( $post_id2, 'bar', 'baz' );
|
||||
$post_id3 = $this->factory->post->create();
|
||||
$post_id3 = self::$factory->post->create();
|
||||
add_post_meta( $post_id3, 'foo', 'baz' );
|
||||
$post_id4 = $this->factory->post->create();
|
||||
$post_id4 = self::$factory->post->create();
|
||||
add_post_meta( $post_id4, 'baz', 'bar' );
|
||||
$post_id5 = $this->factory->post->create();
|
||||
$post_id5 = self::$factory->post->create();
|
||||
add_post_meta( $post_id5, 'foo', rand_str() );
|
||||
|
||||
$posts = get_posts( array(
|
||||
@@ -1482,12 +1482,12 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 17264
|
||||
*/
|
||||
public function test_duplicate_posts_when_no_key() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
add_post_meta( $post_id, 'city', 'Lorem' );
|
||||
add_post_meta( $post_id, 'address', '123 Lorem St.' );
|
||||
$post_id2 = $this->factory->post->create();
|
||||
$post_id2 = self::$factory->post->create();
|
||||
add_post_meta( $post_id2, 'city', 'Lorem' );
|
||||
$post_id3 = $this->factory->post->create();
|
||||
$post_id3 = self::$factory->post->create();
|
||||
add_post_meta( $post_id3, 'city', 'Loren' );
|
||||
|
||||
$args = array(
|
||||
@@ -1513,19 +1513,19 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 15292
|
||||
*/
|
||||
public function test_empty_meta_value() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$factory->post->create();
|
||||
add_post_meta( $post_id, 'foo', '0' );
|
||||
add_post_meta( $post_id, 'bar', 0 );
|
||||
$post_id2 = $this->factory->post->create();
|
||||
$post_id2 = self::$factory->post->create();
|
||||
add_post_meta( $post_id2, 'foo', 1 );
|
||||
$post_id3 = $this->factory->post->create();
|
||||
$post_id3 = self::$factory->post->create();
|
||||
add_post_meta( $post_id3, 'baz', 0 );
|
||||
$post_id4 = $this->factory->post->create();
|
||||
$post_id4 = self::$factory->post->create();
|
||||
add_post_meta( $post_id4, 'baz', 0 );
|
||||
$post_id5 = $this->factory->post->create();
|
||||
$post_id5 = self::$factory->post->create();
|
||||
add_post_meta( $post_id5, 'baz', 0 );
|
||||
add_post_meta( $post_id5, 'bar', '0' );
|
||||
$post_id6 = $this->factory->post->create();
|
||||
$post_id6 = self::$factory->post->create();
|
||||
add_post_meta( $post_id6, 'baz', 0 );
|
||||
|
||||
$q = new WP_Query( array( 'meta_key' => 'foo', 'meta_value' => '0' ) );
|
||||
@@ -1577,7 +1577,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 31045
|
||||
*/
|
||||
public function test_orderby_clause_key() {
|
||||
$posts = $this->factory->post->create_many( 3 );
|
||||
$posts = self::$factory->post->create_many( 3 );
|
||||
add_post_meta( $posts[0], 'foo', 'aaa' );
|
||||
add_post_meta( $posts[1], 'foo', 'zzz' );
|
||||
add_post_meta( $posts[2], 'foo', 'jjj' );
|
||||
@@ -1601,13 +1601,13 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 31045
|
||||
*/
|
||||
public function test_orderby_clause_key_as_secondary_sort() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_date' => '2015-01-28 03:00:00',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_date' => '2015-01-28 05:00:00',
|
||||
) );
|
||||
$p3 = $this->factory->post->create( array(
|
||||
$p3 = self::$factory->post->create( array(
|
||||
'post_date' => '2015-01-28 03:00:00',
|
||||
) );
|
||||
|
||||
@@ -1636,7 +1636,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase {
|
||||
* @ticket 31045
|
||||
*/
|
||||
public function test_orderby_more_than_one_clause_key() {
|
||||
$posts = $this->factory->post->create_many( 3 );
|
||||
$posts = self::$factory->post->create_many( 3 );
|
||||
|
||||
add_post_meta( $posts[0], 'foo', 'jjj' );
|
||||
add_post_meta( $posts[1], 'foo', 'zzz' );
|
||||
|
||||
@@ -211,7 +211,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
|
||||
public function test_single_post_with_nonpublic_status_should_not_be_shown_to_logged_out_users() {
|
||||
register_post_type( 'foo_pt' );
|
||||
register_post_status( 'foo_ps', array( 'public' => false ) );
|
||||
$p = $this->factory->post->create( array( 'post_status' => 'foo_ps' ) );
|
||||
$p = self::$factory->post->create( array( 'post_status' => 'foo_ps' ) );
|
||||
|
||||
$q = new WP_Query( array(
|
||||
'p' => $p,
|
||||
@@ -223,7 +223,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
|
||||
public function test_single_post_with_nonpublic_and_protected_status_should_not_be_shown_for_user_who_cannot_edit_others_posts() {
|
||||
register_post_type( 'foo_pt' );
|
||||
register_post_status( 'foo_ps', array( 'public' => false, 'protected' => true ) );
|
||||
$p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) );
|
||||
$p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) );
|
||||
|
||||
wp_set_current_user( self::$author_user_id );
|
||||
|
||||
@@ -237,7 +237,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
|
||||
public function test_single_post_with_nonpublic_and_protected_status_should_be_shown_for_user_who_can_edit_others_posts() {
|
||||
register_post_type( 'foo_pt' );
|
||||
register_post_status( 'foo_ps', array( 'public' => false, 'protected' => true ) );
|
||||
$p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) );
|
||||
$p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) );
|
||||
|
||||
wp_set_current_user( self::$editor_user_id );
|
||||
|
||||
@@ -251,7 +251,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
|
||||
public function test_single_post_with_nonpublic_and_private_status_should_not_be_shown_for_user_who_cannot_edit_others_posts() {
|
||||
register_post_type( 'foo_pt' );
|
||||
register_post_status( 'foo_ps', array( 'public' => false, 'private' => true ) );
|
||||
$p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) );
|
||||
$p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$editor_user_id ) );
|
||||
|
||||
wp_set_current_user( self::$author_user_id );
|
||||
|
||||
@@ -265,7 +265,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
|
||||
public function test_single_post_with_nonpublic_and_private_status_should_be_shown_for_user_who_can_edit_others_posts() {
|
||||
register_post_type( 'foo_pt' );
|
||||
register_post_status( 'foo_ps', array( 'public' => false, 'private' => true ) );
|
||||
$p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) );
|
||||
$p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) );
|
||||
|
||||
wp_set_current_user( self::$editor_user_id );
|
||||
|
||||
@@ -279,7 +279,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
|
||||
public function test_single_post_with_nonpublic_and_protected_status_should_not_be_shown_for_any_user() {
|
||||
register_post_type( 'foo_pt' );
|
||||
register_post_status( 'foo_ps', array( 'public' => false ) );
|
||||
$p = $this->factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) );
|
||||
$p = self::$factory->post->create( array( 'post_status' => 'foo_ps', 'post_author' => self::$author_user_id ) );
|
||||
|
||||
wp_set_current_user( self::$editor_user_id );
|
||||
|
||||
@@ -294,8 +294,8 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
|
||||
* @ticket 29167
|
||||
*/
|
||||
public function test_specific_post_should_be_returned_if_trash_is_one_of_the_requested_post_statuses() {
|
||||
$p1 = $this->factory->post->create( array( 'post_status' => 'trash' ) );
|
||||
$p2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
|
||||
$p1 = self::$factory->post->create( array( 'post_status' => 'trash' ) );
|
||||
$p2 = self::$factory->post->create( array( 'post_status' => 'publish' ) );
|
||||
|
||||
$q = new WP_Query( array(
|
||||
'p' => $p1,
|
||||
|
||||
@@ -456,17 +456,17 @@ class Tests_Query_Results extends WP_UnitTestCase {
|
||||
* @ticket 16854
|
||||
*/
|
||||
function test_query_author_vars() {
|
||||
$author_1 = $this->factory->user->create( array( 'user_login' => 'admin1', 'user_pass' => rand_str(), 'role' => 'author' ) );
|
||||
$post_1 = $this->factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) );
|
||||
$author_1 = self::$factory->user->create( array( 'user_login' => 'admin1', 'user_pass' => rand_str(), 'role' => 'author' ) );
|
||||
$post_1 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) );
|
||||
|
||||
$author_2 = $this->factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );
|
||||
$post_2 = $this->factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) );
|
||||
$author_2 = self::$factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );
|
||||
$post_2 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) );
|
||||
|
||||
$author_3 = $this->factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );
|
||||
$post_3 = $this->factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) );
|
||||
$author_3 = self::$factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );
|
||||
$post_3 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) );
|
||||
|
||||
$author_4 = $this->factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );
|
||||
$post_4 = $this->factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) );
|
||||
$author_4 = self::$factory->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );
|
||||
$post_4 = self::$factory->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) );
|
||||
|
||||
$posts = $this->q->query( array(
|
||||
'author' => '',
|
||||
@@ -623,9 +623,9 @@ class Tests_Query_Results extends WP_UnitTestCase {
|
||||
* @ticket 20308
|
||||
*/
|
||||
function test_post_password() {
|
||||
$one = (string) $this->factory->post->create( array( 'post_password' => '' ) );
|
||||
$two = (string) $this->factory->post->create( array( 'post_password' => 'burrito' ) );
|
||||
$three = (string) $this->factory->post->create( array( 'post_password' => 'burrito' ) );
|
||||
$one = (string) self::$factory->post->create( array( 'post_password' => '' ) );
|
||||
$two = (string) self::$factory->post->create( array( 'post_password' => 'burrito' ) );
|
||||
$three = (string) self::$factory->post->create( array( 'post_password' => 'burrito' ) );
|
||||
|
||||
$args = array( 'post__in' => array( $one, $two, $three ), 'fields' => 'ids' );
|
||||
|
||||
@@ -665,9 +665,9 @@ class Tests_Query_Results extends WP_UnitTestCase {
|
||||
function test_duplicate_slug_in_hierarchical_post_type() {
|
||||
register_post_type( 'handbook', array( 'hierarchical' => true ) );
|
||||
|
||||
$post_1 = $this->factory->post->create( array( 'post_title' => 'Getting Started', 'post_type' => 'handbook' ) );
|
||||
$post_2 = $this->factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) );
|
||||
$post_3 = $this->factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_2, 'post_type' => 'handbook' ) );
|
||||
$post_1 = self::$factory->post->create( array( 'post_title' => 'Getting Started', 'post_type' => 'handbook' ) );
|
||||
$post_2 = self::$factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) );
|
||||
$post_3 = self::$factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_2, 'post_type' => 'handbook' ) );
|
||||
|
||||
$result = $this->q->query( array( 'handbook' => 'getting-started', 'post_type' => 'handbook' ) );
|
||||
$this->assertCount( 1, $result );
|
||||
@@ -679,8 +679,8 @@ class Tests_Query_Results extends WP_UnitTestCase {
|
||||
function test_child_post_in_hierarchical_post_type_with_default_permalinks() {
|
||||
register_post_type( 'handbook', array( 'hierarchical' => true ) );
|
||||
|
||||
$post_1 = $this->factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) );
|
||||
$post_2 = $this->factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_1, 'post_type' => 'handbook' ) );
|
||||
$post_1 = self::$factory->post->create( array( 'post_title' => 'Contributing to the WordPress Codex', 'post_type' => 'handbook' ) );
|
||||
$post_2 = self::$factory->post->create( array( 'post_title' => 'Getting Started', 'post_parent' => $post_1, 'post_type' => 'handbook' ) );
|
||||
|
||||
$this->assertContains( 'contributing-to-the-wordpress-codex/getting-started', get_permalink( $post_2 ) );
|
||||
|
||||
@@ -690,7 +690,7 @@ class Tests_Query_Results extends WP_UnitTestCase {
|
||||
|
||||
function test_title() {
|
||||
$title = 'Tacos are Cool';
|
||||
$post_id = $this->factory->post->create( array(
|
||||
$post_id = self::$factory->post->create( array(
|
||||
'post_title' => $title,
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'publish'
|
||||
|
||||
@@ -31,8 +31,8 @@ class Tests_Query_Search extends WP_UnitTestCase {
|
||||
|
||||
function test_search_order_title_relevance() {
|
||||
foreach ( range( 1, 7 ) as $i )
|
||||
$this->factory->post->create( array( 'post_content' => $i . rand_str() . ' about', 'post_type' => $this->post_type ) );
|
||||
$post_id = $this->factory->post->create( array( 'post_title' => 'About', 'post_type' => $this->post_type ) );
|
||||
self::$factory->post->create( array( 'post_content' => $i . rand_str() . ' about', 'post_type' => $this->post_type ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_title' => 'About', 'post_type' => $this->post_type ) );
|
||||
|
||||
$posts = $this->get_search_results( 'About' );
|
||||
$this->assertEquals( $post_id, reset( $posts )->ID );
|
||||
@@ -63,11 +63,11 @@ class Tests_Query_Search extends WP_UnitTestCase {
|
||||
* @ticket 33988
|
||||
*/
|
||||
public function test_s_should_exclude_term_prefixed_with_dash() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_status' => 'publish',
|
||||
'post_content' => 'This post has foo but also bar',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_status' => 'publish',
|
||||
'post_content' => 'This post has only foo',
|
||||
) );
|
||||
@@ -84,11 +84,11 @@ class Tests_Query_Search extends WP_UnitTestCase {
|
||||
* @ticket 33988
|
||||
*/
|
||||
public function test_s_should_exclude_first_term_if_prefixed_with_dash() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_status' => 'publish',
|
||||
'post_content' => 'This post has foo but also bar',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_status' => 'publish',
|
||||
'post_content' => 'This post has only bar',
|
||||
) );
|
||||
@@ -105,15 +105,15 @@ class Tests_Query_Search extends WP_UnitTestCase {
|
||||
* @ticket 33988
|
||||
*/
|
||||
public function test_s_should_not_exclude_for_dashes_in_the_middle_of_words() {
|
||||
$p1 = $this->factory->post->create( array(
|
||||
$p1 = self::$factory->post->create( array(
|
||||
'post_status' => 'publish',
|
||||
'post_content' => 'This post has foo but also bar',
|
||||
) );
|
||||
$p2 = $this->factory->post->create( array(
|
||||
$p2 = self::$factory->post->create( array(
|
||||
'post_status' => 'publish',
|
||||
'post_content' => 'This post has only bar',
|
||||
) );
|
||||
$p3 = $this->factory->post->create( array(
|
||||
$p3 = self::$factory->post->create( array(
|
||||
'post_status' => 'publish',
|
||||
'post_content' => 'This post has only foo-bar',
|
||||
) );
|
||||
|
||||
@@ -39,7 +39,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_id() {
|
||||
$p = $this->factory->post->create_and_get();
|
||||
$p = self::$factory->post->create_and_get();
|
||||
setup_postdata( $p );
|
||||
|
||||
$this->assertNotEmpty( $p->ID );
|
||||
@@ -50,7 +50,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
* @ticket 30970
|
||||
*/
|
||||
public function test_setup_by_id() {
|
||||
$p = $this->factory->post->create_and_get();
|
||||
$p = self::$factory->post->create_and_get();
|
||||
setup_postdata( $p->ID );
|
||||
|
||||
$this->assertSame( $p->ID, $GLOBALS['id'] );
|
||||
@@ -72,7 +72,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
* @ticket 30970
|
||||
*/
|
||||
public function test_setup_by_postish_object() {
|
||||
$p = $this->factory->post->create();
|
||||
$p = self::$factory->post->create();
|
||||
|
||||
$post = new stdClass();
|
||||
$post->ID = $p;
|
||||
@@ -82,8 +82,8 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_authordata() {
|
||||
$u = $this->factory->user->create_and_get();
|
||||
$p = $this->factory->post->create_and_get( array(
|
||||
$u = self::$factory->user->create_and_get();
|
||||
$p = self::$factory->post->create_and_get( array(
|
||||
'post_author' => $u->ID,
|
||||
) );
|
||||
setup_postdata( $p );
|
||||
@@ -93,7 +93,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_currentday() {
|
||||
$p = $this->factory->post->create_and_get( array(
|
||||
$p = self::$factory->post->create_and_get( array(
|
||||
'post_date' => '1980-09-09 06:30:00',
|
||||
) );
|
||||
setup_postdata( $p );
|
||||
@@ -102,7 +102,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_currentmonth() {
|
||||
$p = $this->factory->post->create_and_get( array(
|
||||
$p = self::$factory->post->create_and_get( array(
|
||||
'post_date' => '1980-09-09 06:30:00',
|
||||
) );
|
||||
setup_postdata( $p );
|
||||
@@ -111,14 +111,14 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_secondary_query_post_vars() {
|
||||
$users = $this->factory->user->create_many( 2 );
|
||||
$users = self::$factory->user->create_many( 2 );
|
||||
|
||||
$post1 = $this->factory->post->create_and_get( array(
|
||||
$post1 = self::$factory->post->create_and_get( array(
|
||||
'post_author' => $users[0],
|
||||
'post_date' => '2012-02-02 02:00:00',
|
||||
) );
|
||||
|
||||
$post2 = $this->factory->post->create_and_get( array(
|
||||
$post2 = self::$factory->post->create_and_get( array(
|
||||
'post_author' => $users[1],
|
||||
'post_date' => '2013-03-03 03:00:00',
|
||||
) );
|
||||
@@ -157,7 +157,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_single_page() {
|
||||
$post = $this->factory->post->create_and_get( array(
|
||||
$post = self::$factory->post->create_and_get( array(
|
||||
'post_content' => 'Page 0',
|
||||
) );
|
||||
setup_postdata( $post );
|
||||
@@ -168,7 +168,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_multi_page() {
|
||||
$post = $this->factory->post->create_and_get( array(
|
||||
$post = self::$factory->post->create_and_get( array(
|
||||
'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
|
||||
) );
|
||||
setup_postdata( $post );
|
||||
@@ -182,7 +182,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
* @ticket 16746
|
||||
*/
|
||||
public function test_nextpage_at_start_of_content() {
|
||||
$post = $this->factory->post->create_and_get( array(
|
||||
$post = self::$factory->post->create_and_get( array(
|
||||
'post_content' => '<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
|
||||
) );
|
||||
setup_postdata( $post );
|
||||
@@ -193,7 +193,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_trim_nextpage_linebreaks() {
|
||||
$post = $this->factory->post->create_and_get( array(
|
||||
$post = self::$factory->post->create_and_get( array(
|
||||
'post_content' => "Page 0\n<!--nextpage-->\nPage 1\nhas a line break\n<!--nextpage-->Page 2<!--nextpage-->\n\nPage 3",
|
||||
) );
|
||||
setup_postdata( $post );
|
||||
@@ -205,10 +205,10 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
* @ticket 25349
|
||||
*/
|
||||
public function test_secondary_query_nextpage() {
|
||||
$post1 = $this->factory->post->create( array(
|
||||
$post1 = self::$factory->post->create( array(
|
||||
'post_content' => 'Post 1 Page 1<!--nextpage-->Post 1 Page 2',
|
||||
) );
|
||||
$post2 = $this->factory->post->create( array(
|
||||
$post2 = self::$factory->post->create( array(
|
||||
'post_content' => 'Post 2 Page 1<!--nextpage-->Post 2 Page 2',
|
||||
) );
|
||||
|
||||
@@ -237,7 +237,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_page_from_wp_query() {
|
||||
$page = $this->factory->post->create_and_get( array(
|
||||
$page = self::$factory->post->create_and_get( array(
|
||||
'post_type' => 'page',
|
||||
) );
|
||||
|
||||
@@ -250,7 +250,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_page_when_on_page() {
|
||||
$page = $this->factory->post->create_and_get( array(
|
||||
$page = self::$factory->post->create_and_get( array(
|
||||
'post_type' => 'page',
|
||||
) );
|
||||
$this->go_to( get_permalink( $page ) );
|
||||
@@ -263,7 +263,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
* @ticket 20904
|
||||
*/
|
||||
public function test_secondary_query_page() {
|
||||
$post = $this->factory->post->create_and_get();
|
||||
$post = self::$factory->post->create_and_get();
|
||||
$this->go_to( '/?page=3' );
|
||||
setup_postdata( $post );
|
||||
|
||||
@@ -271,7 +271,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
$this->assertSame( 3, $GLOBALS['page'] );
|
||||
|
||||
// Secondary loop.
|
||||
$posts = $this->factory->post->create_many( 5 );
|
||||
$posts = self::$factory->post->create_many( 5 );
|
||||
$q = new WP_Query( array(
|
||||
'page' => 4,
|
||||
'posts_per_page' => 1,
|
||||
@@ -294,7 +294,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
* @ticket 20904
|
||||
*/
|
||||
public function test_more_when_on_setup_post() {
|
||||
$post = $this->factory->post->create_and_get();
|
||||
$post = self::$factory->post->create_and_get();
|
||||
$this->go_to( get_permalink( $post ) );
|
||||
setup_postdata( $post );
|
||||
|
||||
@@ -307,8 +307,8 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
* $more should not be true when the set-up post is not the same as the current post.
|
||||
*/
|
||||
public function test_more_when_on_single() {
|
||||
$post1 = $this->factory->post->create_and_get();
|
||||
$post2 = $this->factory->post->create_and_get();
|
||||
$post1 = self::$factory->post->create_and_get();
|
||||
$post2 = self::$factory->post->create_and_get();
|
||||
$this->go_to( get_permalink( $post1 ) );
|
||||
setup_postdata( $post2 );
|
||||
|
||||
@@ -321,8 +321,8 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
* $more should not be true when the set-up post is not the same as the current page.
|
||||
*/
|
||||
public function test_more_when_on_page() {
|
||||
$post = $this->factory->post->create_and_get();
|
||||
$page = $this->factory->post->create_and_get( array(
|
||||
$post = self::$factory->post->create_and_get();
|
||||
$page = self::$factory->post->create_and_get( array(
|
||||
'post_type' => 'page',
|
||||
) );
|
||||
$this->go_to( get_permalink( $page ) );
|
||||
@@ -335,7 +335,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
* @ticket 20904
|
||||
*/
|
||||
public function test_more_when_on_feed() {
|
||||
$post = $this->factory->post->create_and_get();
|
||||
$post = self::$factory->post->create_and_get();
|
||||
$this->go_to( '/?feed=rss' );
|
||||
setup_postdata( $post );
|
||||
|
||||
@@ -347,7 +347,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
* @ticket 25349
|
||||
*/
|
||||
public function test_secondary_query_more() {
|
||||
$post = $this->factory->post->create_and_get();
|
||||
$post = self::$factory->post->create_and_get();
|
||||
$this->go_to( get_permalink( $post ) );
|
||||
setup_postdata( $post );
|
||||
|
||||
@@ -379,10 +379,10 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
* global $post should use the content of $a_post rather then the global post.
|
||||
*/
|
||||
function test_setup_postdata_loop() {
|
||||
$post_id = $this->factory->post->create( array( 'post_content' => 'global post' ) );
|
||||
$post_id = self::$factory->post->create( array( 'post_content' => 'global post' ) );
|
||||
$GLOBALS['wp_query']->post = $GLOBALS['post'] = get_post( $post_id );
|
||||
|
||||
$ids = $this->factory->post->create_many(5);
|
||||
$ids = self::$factory->post->create_many(5);
|
||||
foreach ( $ids as $id ) {
|
||||
$page = get_post( $id );
|
||||
if ( $page ) {
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
*/
|
||||
class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
public function test_tax_query_single_query_single_term_field_slug() {
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
wp_set_post_terms( $p1, $t, 'category' );
|
||||
|
||||
@@ -33,13 +33,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_single_query_single_term_field_name() {
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
wp_set_post_terms( $p1, $t, 'category' );
|
||||
|
||||
@@ -65,13 +65,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
public function test_field_name_should_work_for_names_with_spaces() {
|
||||
register_taxonomy( 'wptests_tax', 'post' );
|
||||
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo Bar',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
wp_set_object_terms( $p1, $t, 'wptests_tax' );
|
||||
|
||||
@@ -90,13 +90,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_single_query_single_term_field_term_taxonomy_id() {
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
$tt_ids = wp_set_post_terms( $p1, $t, 'category' );
|
||||
|
||||
@@ -117,13 +117,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_single_query_single_term_field_term_id() {
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
wp_set_post_terms( $p1, $t, 'category' );
|
||||
|
||||
@@ -144,13 +144,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_single_query_single_term_operator_in() {
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
wp_set_post_terms( $p1, $t, 'category' );
|
||||
|
||||
@@ -172,13 +172,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_single_query_single_term_operator_not_in() {
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
wp_set_post_terms( $p1, $t, 'category' );
|
||||
|
||||
@@ -200,13 +200,13 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_single_query_single_term_operator_and() {
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
|
||||
wp_set_post_terms( $p1, $t, 'category' );
|
||||
|
||||
@@ -228,19 +228,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_single_query_multiple_terms_operator_in() {
|
||||
$t1 = $this->factory->term->create( array(
|
||||
$t1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$t2 = $this->factory->term->create( array(
|
||||
$t2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'bar',
|
||||
'name' => 'Bar',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_post_terms( $p1, $t1, 'category' );
|
||||
wp_set_post_terms( $p2, $t2, 'category' );
|
||||
@@ -263,19 +263,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_single_query_multiple_terms_operator_not_in() {
|
||||
$t1 = $this->factory->term->create( array(
|
||||
$t1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$t2 = $this->factory->term->create( array(
|
||||
$t2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'bar',
|
||||
'name' => 'Bar',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_post_terms( $p1, $t1, 'category' );
|
||||
wp_set_post_terms( $p2, $t2, 'category' );
|
||||
@@ -301,19 +301,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
* @ticket 18105
|
||||
*/
|
||||
public function test_tax_query_single_query_multiple_queries_operator_not_in() {
|
||||
$t1 = $this->factory->term->create( array(
|
||||
$t1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$t2 = $this->factory->term->create( array(
|
||||
$t2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'bar',
|
||||
'name' => 'Bar',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_post_terms( $p1, $t1, 'category' );
|
||||
wp_set_post_terms( $p2, $t2, 'category' );
|
||||
@@ -343,19 +343,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_single_query_multiple_terms_operator_and() {
|
||||
$t1 = $this->factory->term->create( array(
|
||||
$t1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$t2 = $this->factory->term->create( array(
|
||||
$t2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'bar',
|
||||
'name' => 'Bar',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_object_terms( $p1, $t1, 'category' );
|
||||
wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' );
|
||||
@@ -384,12 +384,12 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
register_taxonomy( 'wptests_tax1', 'post' );
|
||||
register_taxonomy( 'wptests_tax2', 'post' );
|
||||
|
||||
$t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
|
||||
$t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
|
||||
$t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
|
||||
$t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
|
||||
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
|
||||
wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
|
||||
@@ -416,12 +416,12 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
register_taxonomy( 'wptests_tax1', 'post' );
|
||||
register_taxonomy( 'wptests_tax2', 'post' );
|
||||
|
||||
$t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
|
||||
$t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
|
||||
$t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
|
||||
$t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
|
||||
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
|
||||
wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
|
||||
@@ -448,12 +448,12 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
register_taxonomy( 'wptests_tax1', 'post' );
|
||||
register_taxonomy( 'wptests_tax2', 'post' );
|
||||
|
||||
$t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
|
||||
$t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
|
||||
$t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
|
||||
$t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
|
||||
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
|
||||
wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
|
||||
@@ -481,12 +481,12 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
register_taxonomy( 'wptests_tax1', 'post' );
|
||||
register_taxonomy( 'wptests_tax2', 'post' );
|
||||
|
||||
$t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
|
||||
$t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
|
||||
$t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
|
||||
$t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
|
||||
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
|
||||
wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
|
||||
@@ -506,19 +506,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_multiple_queries_relation_and() {
|
||||
$t1 = $this->factory->term->create( array(
|
||||
$t1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$t2 = $this->factory->term->create( array(
|
||||
$t2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'bar',
|
||||
'name' => 'Bar',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_object_terms( $p1, $t1, 'category' );
|
||||
wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' );
|
||||
@@ -546,19 +546,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_multiple_queries_relation_or() {
|
||||
$t1 = $this->factory->term->create( array(
|
||||
$t1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$t2 = $this->factory->term->create( array(
|
||||
$t2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'bar',
|
||||
'name' => 'Bar',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_object_terms( $p1, $t1, 'category' );
|
||||
wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' );
|
||||
@@ -586,19 +586,19 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_multiple_queries_different_taxonomies() {
|
||||
$t1 = $this->factory->term->create( array(
|
||||
$t1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'post_tag',
|
||||
'slug' => 'foo',
|
||||
'name' => 'Foo',
|
||||
) );
|
||||
$t2 = $this->factory->term->create( array(
|
||||
$t2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'bar',
|
||||
'name' => 'Bar',
|
||||
) );
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_object_terms( $p1, $t1, 'post_tag' );
|
||||
wp_set_object_terms( $p2, $t2, 'category' );
|
||||
@@ -632,22 +632,22 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
register_taxonomy( 'foo', 'post' );
|
||||
register_taxonomy( 'bar', 'post' );
|
||||
|
||||
$foo_term_1 = $this->factory->term->create( array(
|
||||
$foo_term_1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'foo',
|
||||
) );
|
||||
$foo_term_2 = $this->factory->term->create( array(
|
||||
$foo_term_2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'foo',
|
||||
) );
|
||||
$bar_term_1 = $this->factory->term->create( array(
|
||||
$bar_term_1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'bar',
|
||||
) );
|
||||
$bar_term_2 = $this->factory->term->create( array(
|
||||
$bar_term_2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'bar',
|
||||
) );
|
||||
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' );
|
||||
wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' );
|
||||
@@ -704,22 +704,22 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
register_taxonomy( 'foo', 'post' );
|
||||
register_taxonomy( 'bar', 'post' );
|
||||
|
||||
$foo_term_1 = $this->factory->term->create( array(
|
||||
$foo_term_1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'foo',
|
||||
) );
|
||||
$foo_term_2 = $this->factory->term->create( array(
|
||||
$foo_term_2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'foo',
|
||||
) );
|
||||
$bar_term_1 = $this->factory->term->create( array(
|
||||
$bar_term_1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'bar',
|
||||
) );
|
||||
$bar_term_2 = $this->factory->term->create( array(
|
||||
$bar_term_2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'bar',
|
||||
) );
|
||||
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
|
||||
wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' );
|
||||
wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' );
|
||||
@@ -768,23 +768,23 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
register_taxonomy( 'foo', 'post' );
|
||||
register_taxonomy( 'bar', 'post' );
|
||||
|
||||
$foo_term_1 = $this->factory->term->create( array(
|
||||
$foo_term_1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'foo',
|
||||
) );
|
||||
$foo_term_2 = $this->factory->term->create( array(
|
||||
$foo_term_2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'foo',
|
||||
) );
|
||||
$bar_term_1 = $this->factory->term->create( array(
|
||||
$bar_term_1 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'bar',
|
||||
) );
|
||||
$bar_term_2 = $this->factory->term->create( array(
|
||||
$bar_term_2 = self::$factory->term->create( array(
|
||||
'taxonomy' => 'bar',
|
||||
) );
|
||||
|
||||
$p1 = $this->factory->post->create();
|
||||
$p2 = $this->factory->post->create();
|
||||
$p3 = $this->factory->post->create();
|
||||
$p4 = $this->factory->post->create();
|
||||
$p1 = self::$factory->post->create();
|
||||
$p2 = self::$factory->post->create();
|
||||
$p3 = self::$factory->post->create();
|
||||
$p4 = self::$factory->post->create();
|
||||
|
||||
wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' );
|
||||
wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' );
|
||||
@@ -840,7 +840,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
public function test_tax_query_relation_or_both_clauses_empty_terms() {
|
||||
// An empty tax query should return an empty array, not all posts.
|
||||
|
||||
$this->factory->post->create_many( 2 );
|
||||
self::$factory->post->create_many( 2 );
|
||||
|
||||
$query = new WP_Query( array(
|
||||
'fields' => 'ids',
|
||||
@@ -873,7 +873,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
public function test_tax_query_relation_or_one_clause_empty_terms() {
|
||||
// An empty tax query should return an empty array, not all posts.
|
||||
|
||||
$this->factory->post->create_many( 2 );
|
||||
self::$factory->post->create_many( 2 );
|
||||
|
||||
$query = new WP_Query( array(
|
||||
'fields' => 'ids',
|
||||
@@ -901,15 +901,15 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_include_children() {
|
||||
$cat_a = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Australia' ) );
|
||||
$cat_b = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Sydney', 'parent' => $cat_a ) );
|
||||
$cat_c = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'East Syndney', 'parent' => $cat_b ) );
|
||||
$cat_d = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'West Syndney', 'parent' => $cat_b ) );
|
||||
$cat_a = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Australia' ) );
|
||||
$cat_b = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Sydney', 'parent' => $cat_a ) );
|
||||
$cat_c = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'East Syndney', 'parent' => $cat_b ) );
|
||||
$cat_d = self::$factory->term->create( array( 'taxonomy' => 'category', 'name' => 'West Syndney', 'parent' => $cat_b ) );
|
||||
|
||||
$post_a = $this->factory->post->create( array( 'post_category' => array( $cat_a ) ) );
|
||||
$post_b = $this->factory->post->create( array( 'post_category' => array( $cat_b ) ) );
|
||||
$post_c = $this->factory->post->create( array( 'post_category' => array( $cat_c ) ) );
|
||||
$post_d = $this->factory->post->create( array( 'post_category' => array( $cat_d ) ) );
|
||||
$post_a = self::$factory->post->create( array( 'post_category' => array( $cat_a ) ) );
|
||||
$post_b = self::$factory->post->create( array( 'post_category' => array( $cat_b ) ) );
|
||||
$post_c = self::$factory->post->create( array( 'post_category' => array( $cat_c ) ) );
|
||||
$post_d = self::$factory->post->create( array( 'post_category' => array( $cat_d ) ) );
|
||||
|
||||
$posts = get_posts( array(
|
||||
'fields' => 'ids',
|
||||
@@ -1009,8 +1009,8 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
$q = new WP_Query();
|
||||
|
||||
register_taxonomy_for_object_type( 'post_tag', 'attachment:image' );
|
||||
$tag_id = $this->factory->term->create( array( 'slug' => rand_str(), 'name' => rand_str() ) );
|
||||
$image_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
|
||||
$tag_id = self::$factory->term->create( array( 'slug' => rand_str(), 'name' => rand_str() ) );
|
||||
$image_id = self::$factory->attachment->create_object( 'image.jpg', 0, array(
|
||||
'post_mime_type' => 'image/jpeg',
|
||||
'post_type' => 'attachment'
|
||||
) );
|
||||
@@ -1035,8 +1035,8 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_tax_query_no_taxonomy() {
|
||||
$cat_id = $this->factory->category->create( array( 'name' => 'alpha' ) );
|
||||
$this->factory->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $cat_id ) ) );
|
||||
$cat_id = self::$factory->category->create( array( 'name' => 'alpha' ) );
|
||||
self::$factory->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $cat_id ) ) );
|
||||
|
||||
$response1 = new WP_Query( array(
|
||||
'tax_query' => array(
|
||||
@@ -1076,7 +1076,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
public function test_term_taxonomy_id_field_no_taxonomy() {
|
||||
$q = new WP_Query();
|
||||
|
||||
$posts = $this->factory->post->create_many( 5 );
|
||||
$posts = self::$factory->post->create_many( 5 );
|
||||
|
||||
$cats = $tags = array();
|
||||
|
||||
@@ -1155,10 +1155,10 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_populate_taxonomy_query_var_from_tax_query() {
|
||||
register_taxonomy( 'foo', 'post' );
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'foo',
|
||||
) );
|
||||
$c = $this->factory->term->create( array(
|
||||
$c = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
) );
|
||||
|
||||
@@ -1191,7 +1191,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
public function test_populate_taxonomy_query_var_from_tax_query_taxonomy_already_set() {
|
||||
register_taxonomy( 'foo', 'post' );
|
||||
register_taxonomy( 'foo1', 'post' );
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'foo',
|
||||
) );
|
||||
|
||||
@@ -1213,7 +1213,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
|
||||
public function test_populate_term_query_var_from_tax_query() {
|
||||
register_taxonomy( 'foo', 'post' );
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'foo',
|
||||
'slug' => 'bar',
|
||||
) );
|
||||
@@ -1235,7 +1235,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
|
||||
public function test_populate_term_id_query_var_from_tax_query() {
|
||||
register_taxonomy( 'foo', 'post' );
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'foo',
|
||||
'slug' => 'bar',
|
||||
) );
|
||||
@@ -1260,10 +1260,10 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_populate_cat_category_name_query_var_from_tax_query() {
|
||||
register_taxonomy( 'foo', 'post' );
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'foo',
|
||||
) );
|
||||
$c = $this->factory->term->create( array(
|
||||
$c = self::$factory->term->create( array(
|
||||
'taxonomy' => 'category',
|
||||
'slug' => 'bar',
|
||||
) );
|
||||
@@ -1301,10 +1301,10 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
|
||||
*/
|
||||
public function test_populate_tag_id_query_var_from_tax_query() {
|
||||
register_taxonomy( 'foo', 'post' );
|
||||
$t = $this->factory->term->create( array(
|
||||
$t = self::$factory->term->create( array(
|
||||
'taxonomy' => 'foo',
|
||||
) );
|
||||
$tag = $this->factory->term->create( array(
|
||||
$tag = self::$factory->term->create( array(
|
||||
'taxonomy' => 'post_tag',
|
||||
'slug' => 'bar',
|
||||
) );
|
||||
|
||||
Reference in New Issue
Block a user