Unit Tests: after [35225], make factory a method/getter on WP_UnitTestCase and add magic methods for BC for every plugin that is extending WP_UnitTestCase and accessing the $factory instance prop.

Props nerrad, wonderboymusic.
See #30017, #33968.



git-svn-id: https://develop.svn.wordpress.org/trunk@35242 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-10-17 18:02:16 +00:00
parent 5a0fd03f95
commit b757b37551
170 changed files with 2516 additions and 2507 deletions
+20 -20
View File
@@ -125,9 +125,9 @@ class Tests_Tax_Query extends WP_UnitTestCase {
}
public function test_transform_query_resulting_field_sanitized() {
$t1 = self::$factory->category->create( array( 'slug' => 'foo', ) );
$t2 = self::$factory->category->create( array( 'slug' => 'bar', ) );
$p = self::$factory->post->create();
$t1 = self::factory()->category->create( array( 'slug' => 'foo', ) );
$t2 = self::factory()->category->create( array( 'slug' => 'bar', ) );
$p = self::factory()->post->create();
wp_set_post_categories( $p, $t1 );
$tq1 = new WP_Tax_Query( array(
@@ -150,8 +150,8 @@ class Tests_Tax_Query extends WP_UnitTestCase {
}
public function test_transform_query_field_slug() {
$t1 = self::$factory->category->create( array( 'slug' => 'foo', ) );
$p = self::$factory->post->create();
$t1 = self::factory()->category->create( array( 'slug' => 'foo', ) );
$p = self::factory()->post->create();
$tt_ids = wp_set_post_categories( $p, $t1 );
$tq = new WP_Tax_Query( array(
@@ -168,8 +168,8 @@ class Tests_Tax_Query extends WP_UnitTestCase {
}
public function test_transform_query_field_name() {
$t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
$p = self::$factory->post->create();
$t1 = self::factory()->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
$p = self::factory()->post->create();
$tt_ids = wp_set_post_categories( $p, $t1 );
$tq = new WP_Tax_Query( array(
@@ -186,8 +186,8 @@ class Tests_Tax_Query extends WP_UnitTestCase {
}
public function test_transform_query_field_term_taxonomy_id() {
$t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
$p = self::$factory->post->create();
$t1 = self::factory()->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
$p = self::factory()->post->create();
$tt_ids = wp_set_post_categories( $p, $t1 );
$tq = new WP_Tax_Query( array(
@@ -204,8 +204,8 @@ class Tests_Tax_Query extends WP_UnitTestCase {
}
public function test_transform_query_field_term_taxonomy_default() {
$t1 = self::$factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
$p = self::$factory->post->create();
$t1 = self::factory()->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
$p = self::factory()->post->create();
$tt_ids = wp_set_post_categories( $p, $t1 );
$tq = new WP_Tax_Query( array(
@@ -240,13 +240,13 @@ class Tests_Tax_Query extends WP_UnitTestCase {
public function test_get_sql_relation_or_operator_in() {
register_taxonomy( 'wptests_tax', 'post' );
$t1 = self::$factory->term->create( array(
$t1 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
) );
$t2 = self::$factory->term->create( array(
$t2 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
) );
$t3 = self::$factory->term->create( array(
$t3 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
) );
@@ -284,13 +284,13 @@ class Tests_Tax_Query extends WP_UnitTestCase {
public function test_get_sql_relation_and_operator_in() {
register_taxonomy( 'wptests_tax', 'post' );
$t1 = self::$factory->term->create( array(
$t1 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
) );
$t2 = self::$factory->term->create( array(
$t2 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
) );
$t3 = self::$factory->term->create( array(
$t3 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
) );
@@ -327,13 +327,13 @@ class Tests_Tax_Query extends WP_UnitTestCase {
public function test_get_sql_nested_relation_or_operator_in() {
register_taxonomy( 'wptests_tax', 'post' );
$t1 = self::$factory->term->create( array(
$t1 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
) );
$t2 = self::$factory->term->create( array(
$t2 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
) );
$t3 = self::$factory->term->create( array(
$t3 = self::factory()->term->create( array(
'taxonomy' => 'wptests_tax',
) );