diff options
Diffstat (limited to 'tests/phpunit/tests/term')
-rw-r--r-- | tests/phpunit/tests/term/cache.php | 2 | ||||
-rw-r--r-- | tests/phpunit/tests/term/meta.php | 64 | ||||
-rw-r--r-- | tests/phpunit/tests/term/wpGenerateTagCloud.php | 4 | ||||
-rw-r--r-- | tests/phpunit/tests/term/wpGetObjectTerms.php | 5 | ||||
-rw-r--r-- | tests/phpunit/tests/term/wpTaxonomy.php | 2 |
5 files changed, 45 insertions, 32 deletions
diff --git a/tests/phpunit/tests/term/cache.php b/tests/phpunit/tests/term/cache.php index 99a73f7823..76eff31adf 100644 --- a/tests/phpunit/tests/term/cache.php +++ b/tests/phpunit/tests/term/cache.php @@ -222,6 +222,8 @@ class Tests_Term_Cache extends WP_UnitTestCase { update_term_cache( $terms ); + $this->assertNotEmpty( $terms ); + foreach ( $terms as $term ) { $this->assertSame( $p, $term->object_id ); } diff --git a/tests/phpunit/tests/term/meta.php b/tests/phpunit/tests/term/meta.php index 248d190917..a1eed9d335 100644 --- a/tests/phpunit/tests/term/meta.php +++ b/tests/phpunit/tests/term/meta.php @@ -132,26 +132,26 @@ class Tests_Term_Meta extends WP_UnitTestCase { $this->go_to( get_permalink( $p ) ); remove_action( 'pre_get_posts', array( $this, 'set_cache_results' ) ); - if ( have_posts() ) { - while ( have_posts() ) { - the_post(); - - // First request will hit the database. - $num_queries = get_num_queries(); - $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) ); - ++$num_queries; - $this->assertSame( $num_queries, get_num_queries() ); - - // Second and third requests should be in cache. - $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) ); - $this->assertSame( 'bar', get_term_meta( $terms[2], 'foo', true ) ); - $this->assertSame( $num_queries, get_num_queries() ); - - // Querying a term not primed should result in a hit. - ++$num_queries; - $this->assertSame( 'bar', get_term_meta( $orphan_term, 'foo', true ) ); - $this->assertSame( $num_queries, get_num_queries() ); - } + $this->assertTrue( have_posts() ); + + while ( have_posts() ) { + the_post(); + + // First request will hit the database. + $num_queries = get_num_queries(); + $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) ); + ++$num_queries; + $this->assertSame( $num_queries, get_num_queries() ); + + // Second and third requests should be in cache. + $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) ); + $this->assertSame( 'bar', get_term_meta( $terms[2], 'foo', true ) ); + $this->assertSame( $num_queries, get_num_queries() ); + + // Querying a term not primed should result in a hit. + ++$num_queries; + $this->assertSame( 'bar', get_term_meta( $orphan_term, 'foo', true ) ); + $this->assertSame( $num_queries, get_num_queries() ); } } @@ -201,20 +201,20 @@ class Tests_Term_Meta extends WP_UnitTestCase { ) ); - if ( $q->have_posts() ) { - while ( $q->have_posts() ) { - $q->the_post(); + $this->assertTrue( $q->have_posts() ); - // Requests will hit the database. - $num_queries = get_num_queries(); - $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) ); - ++$num_queries; - $this->assertSame( $num_queries, get_num_queries() ); + while ( $q->have_posts() ) { + $q->the_post(); - $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) ); - ++$num_queries; - $this->assertSame( $num_queries, get_num_queries() ); - } + // Requests will hit the database. + $num_queries = get_num_queries(); + $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) ); + ++$num_queries; + $this->assertSame( $num_queries, get_num_queries() ); + + $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) ); + ++$num_queries; + $this->assertSame( $num_queries, get_num_queries() ); } } diff --git a/tests/phpunit/tests/term/wpGenerateTagCloud.php b/tests/phpunit/tests/term/wpGenerateTagCloud.php index 62de4a0c26..4b7a27fb47 100644 --- a/tests/phpunit/tests/term/wpGenerateTagCloud.php +++ b/tests/phpunit/tests/term/wpGenerateTagCloud.php @@ -156,6 +156,8 @@ class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { ) ); + $this->assertNotEmpty( $tags ); + foreach ( $tags as $tag ) { $this->assertStringContainsString( '>' . $tag->name . '<', $found ); } @@ -187,6 +189,8 @@ class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { $this->assertMatchesRegularExpression( "|^<ul class='wp-tag-cloud' role='list'>|", $found ); $this->assertMatchesRegularExpression( "|</ul>\n|", $found ); + $this->assertNotEmpty( $tags ); + foreach ( $tags as $tag ) { $this->assertStringContainsString( '>' . $tag->name . '<', $found ); } diff --git a/tests/phpunit/tests/term/wpGetObjectTerms.php b/tests/phpunit/tests/term/wpGetObjectTerms.php index 948ba1e1c3..128e4a19a8 100644 --- a/tests/phpunit/tests/term/wpGetObjectTerms.php +++ b/tests/phpunit/tests/term/wpGetObjectTerms.php @@ -110,6 +110,9 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { add_filter( 'wp_get_object_terms', array( $this, 'filter_get_object_terms' ) ); $terms = wp_get_object_terms( $post_id, $this->taxonomy ); remove_filter( 'wp_get_object_terms', array( $this, 'filter_get_object_terms' ) ); + + $this->assertNotEmpty( $terms ); + foreach ( $terms as $term ) { $this->assertIsObject( $term ); } @@ -845,6 +848,8 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { ) ); + $this->assertNotEmpty( $found ); + foreach ( $found as $f ) { $this->assertSame( $p, $f->object_id ); } diff --git a/tests/phpunit/tests/term/wpTaxonomy.php b/tests/phpunit/tests/term/wpTaxonomy.php index 4106e60f3b..845497ad06 100644 --- a/tests/phpunit/tests/term/wpTaxonomy.php +++ b/tests/phpunit/tests/term/wpTaxonomy.php @@ -7,6 +7,8 @@ class Tests_WP_Taxonomy extends WP_UnitTestCase { public function test_instances() { global $wp_taxonomies; + $this->assertNotEmpty( $wp_taxonomies ); + foreach ( $wp_taxonomies as $taxonomy ) { $this->assertInstanceOf( 'WP_Taxonomy', $taxonomy ); } |