mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-09 15:14:37 +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:
@@ -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' );
|
||||
|
||||
Reference in New Issue
Block a user