| @@ 1089-1104 (lines=16) @@ | ||
| 1086 | /** |
|
| 1087 | * @ticket 31001 |
|
| 1088 | */ |
|
| 1089 | public function test_validate_date_values_should_process_array_value_for_year() |
|
| 1090 | { |
|
| 1091 | $p1 = self::factory()->post->create(array( 'post_date' => '2015-01-12 00:00:00' )); |
|
| 1092 | $p2 = self::factory()->post->create(array( 'post_date' => '2013-01-12 00:00:00' )); |
|
| 1093 | ||
| 1094 | $q = new WP_Query( |
|
| 1095 | array( |
|
| 1096 | 'date_query' => array( |
|
| 1097 | array( |
|
| 1098 | 'compare' => 'BETWEEN', |
|
| 1099 | 'year' => array( 2012, 2014 ), |
|
| 1100 | ), |
|
| 1101 | ), |
|
| 1102 | 'fields' => 'ids', |
|
| 1103 | ) |
|
| 1104 | ); |
|
| 1105 | ||
| 1106 | $this->assertEquals(array( $p2 ), $q->posts); |
|
| 1107 | } |
|
| @@ 1112-1127 (lines=16) @@ | ||
| 1109 | /** |
|
| 1110 | * @ticket 31001 |
|
| 1111 | */ |
|
| 1112 | public function test_validate_date_values_should_process_array_value_for_day() |
|
| 1113 | { |
|
| 1114 | $p1 = self::factory()->post->create(array( 'post_date' => '2015-01-12 00:00:00' )); |
|
| 1115 | $p2 = self::factory()->post->create(array( 'post_date' => '2015-01-10 00:00:00' )); |
|
| 1116 | ||
| 1117 | $q = new WP_Query( |
|
| 1118 | array( |
|
| 1119 | 'date_query' => array( |
|
| 1120 | array( |
|
| 1121 | 'compare' => 'BETWEEN', |
|
| 1122 | 'day' => array( 9, 11 ), |
|
| 1123 | ), |
|
| 1124 | ), |
|
| 1125 | 'fields' => 'ids', |
|
| 1126 | ) |
|
| 1127 | ); |
|
| 1128 | ||
| 1129 | $this->assertEquals(array( $p2 ), $q->posts); |
|
| 1130 | } |
|
| @@ 1136-1152 (lines=17) @@ | ||
| 1133 | * @ticket 31001 |
|
| 1134 | * @expectedIncorrectUsage WP_Date_Query |
|
| 1135 | */ |
|
| 1136 | public function test_validate_date_values_should_process_array_value_for_day_when_values_are_invalid() |
|
| 1137 | { |
|
| 1138 | $p1 = self::factory()->post->create(array( 'post_date' => '2015-01-12 00:00:00' )); |
|
| 1139 | $p2 = self::factory()->post->create(array( 'post_date' => '2015-01-10 00:00:00' )); |
|
| 1140 | ||
| 1141 | $q = new WP_Query( |
|
| 1142 | array( |
|
| 1143 | 'date_query' => array( |
|
| 1144 | array( |
|
| 1145 | 'compare' => 'BETWEEN', |
|
| 1146 | 'day' => array( 9, 32 ), |
|
| 1147 | ), |
|
| 1148 | ), |
|
| 1149 | 'fields' => 'ids', |
|
| 1150 | ) |
|
| 1151 | ); |
|
| 1152 | ||
| 1153 | // MySQL ignores the invalid clause. |
|
| 1154 | $this->assertEquals(array( $p1, $p2 ), $q->posts); |
|
| 1155 | } |
|