Changeset 42343 for trunk/tests/phpunit/tests/query/date.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query/date.php
r38398 r42343 53 53 54 54 public function _get_query_result( $args = array() ) { 55 $args = wp_parse_args( $args, array( 56 'post_status' => 'any', // For the future post 57 'posts_per_page' => '-1', // To make sure results are accurate 58 'orderby' => 'ID', // Same order they were created 59 'order' => 'ASC', 60 ) ); 55 $args = wp_parse_args( 56 $args, array( 57 'post_status' => 'any', // For the future post 58 'posts_per_page' => '-1', // To make sure results are accurate 59 'orderby' => 'ID', // Same order they were created 60 'order' => 'ASC', 61 ) 62 ); 61 63 62 64 return $this->q->query( $args ); … … 64 66 65 67 public function test_simple_year_expecting_results() { 66 $posts = $this->_get_query_result( array( 67 'year' => 2008, 68 ) ); 68 $posts = $this->_get_query_result( 69 array( 70 'year' => 2008, 71 ) 72 ); 69 73 70 74 $expected_dates = array( … … 78 82 79 83 public function test_simple_year_expecting_noresults() { 80 $posts = $this->_get_query_result( array( 81 'year' => 2000, 82 ) ); 84 $posts = $this->_get_query_result( 85 array( 86 'year' => 2000, 87 ) 88 ); 83 89 84 90 $this->assertCount( 0, $posts ); … … 86 92 87 93 public function test_simple_m_with_year_expecting_results() { 88 $posts = $this->_get_query_result( array( 89 'm' => '2007', 90 ) ); 94 $posts = $this->_get_query_result( 95 array( 96 'm' => '2007', 97 ) 98 ); 91 99 92 100 $expected_dates = array( … … 100 108 101 109 public function test_simple_m_with_year_expecting_noresults() { 102 $posts = $this->_get_query_result( array( 103 'm' => '1999', 104 ) ); 110 $posts = $this->_get_query_result( 111 array( 112 'm' => '1999', 113 ) 114 ); 105 115 106 116 $this->assertCount( 0, $posts ); … … 108 118 109 119 public function test_simple_m_with_yearmonth_expecting_results() { 110 $posts = $this->_get_query_result( array( 111 'm' => '202504', 112 ) ); 120 $posts = $this->_get_query_result( 121 array( 122 'm' => '202504', 123 ) 124 ); 113 125 114 126 $expected_dates = array( … … 121 133 122 134 public function test_simple_m_with_yearmonth_expecting_noresults() { 123 $posts = $this->_get_query_result( array( 124 'm' => '202502', 125 ) ); 135 $posts = $this->_get_query_result( 136 array( 137 'm' => '202502', 138 ) 139 ); 126 140 127 141 $this->assertCount( 0, $posts ); … … 129 143 130 144 public function test_simple_m_with_yearmonthday_expecting_results() { 131 $posts = $this->_get_query_result( array( 132 'm' => '20250420', 133 ) ); 145 $posts = $this->_get_query_result( 146 array( 147 'm' => '20250420', 148 ) 149 ); 134 150 135 151 $expected_dates = array( … … 142 158 143 159 public function test_simple_m_with_yearmonthday_expecting_noresults() { 144 $posts = $this->_get_query_result( array( 145 'm' => '20250419', 146 ) ); 160 $posts = $this->_get_query_result( 161 array( 162 'm' => '20250419', 163 ) 164 ); 147 165 148 166 $this->assertCount( 0, $posts ); … … 150 168 151 169 public function test_simple_m_with_yearmonthdayhour_expecting_results() { 152 $posts = $this->_get_query_result( array( 153 'm' => '2025042010', 154 ) ); 170 $posts = $this->_get_query_result( 171 array( 172 'm' => '2025042010', 173 ) 174 ); 155 175 156 176 $expected_dates = array( … … 163 183 164 184 public function test_simple_m_with_yearmonthdayhour_expecting_noresults() { 165 $posts = $this->_get_query_result( array( 166 'm' => '2025042009', 167 ) ); 185 $posts = $this->_get_query_result( 186 array( 187 'm' => '2025042009', 188 ) 189 ); 168 190 169 191 $this->assertCount( 0, $posts ); … … 174 196 */ 175 197 public function test_simple_m_with_yearmonthdayhourminute_expecting_results() { 176 $posts = $this->_get_query_result( array( 177 'm' => '202504201013', 178 ) ); 198 $posts = $this->_get_query_result( 199 array( 200 'm' => '202504201013', 201 ) 202 ); 179 203 180 204 $expected_dates = array( … … 190 214 */ 191 215 public function test_simple_m_with_yearmonthdayhourminute_expecting_noresults() { 192 $posts = $this->_get_query_result( array( 193 'm' => '202504201012', 194 ) ); 216 $posts = $this->_get_query_result( 217 array( 218 'm' => '202504201012', 219 ) 220 ); 195 221 196 222 $this->assertCount( 0, $posts ); … … 201 227 */ 202 228 public function test_simple_m_with_yearmonthdayhourminutesecond_expecting_results() { 203 $posts = $this->_get_query_result( array( 204 'm' => '20250420101301', 205 ) ); 229 $posts = $this->_get_query_result( 230 array( 231 'm' => '20250420101301', 232 ) 233 ); 206 234 207 235 $expected_dates = array( … … 216 244 */ 217 245 public function test_simple_m_with_yearmonthdayhourminutesecond_expecting_noresults() { 218 $posts = $this->_get_query_result( array( 219 'm' => '20250420101302', 220 ) ); 246 $posts = $this->_get_query_result( 247 array( 248 'm' => '20250420101302', 249 ) 250 ); 221 251 222 252 $this->assertCount( 0, $posts ); … … 227 257 */ 228 258 public function test_simple_m_with_yearmonthdayhourminutesecond_and_dashes_expecting_results() { 229 $posts = $this->_get_query_result( array( 230 'm' => '2025-04-20 10:13:00', 231 ) ); 259 $posts = $this->_get_query_result( 260 array( 261 'm' => '2025-04-20 10:13:00', 262 ) 263 ); 232 264 233 265 $expected_dates = array( … … 242 274 */ 243 275 public function test_simple_m_with_yearmonthdayhourminutesecond_and_dashesletters_expecting_results() { 244 $posts = $this->_get_query_result( array( 245 'm' => 'alpha2025-04-20 10:13:00', 246 ) ); 276 $posts = $this->_get_query_result( 277 array( 278 'm' => 'alpha2025-04-20 10:13:00', 279 ) 280 ); 247 281 248 282 $expected_dates = array( … … 257 291 */ 258 292 public function test_non_scalar_m_should_be_discarded() { 259 $expected = $this->_get_query_result( ); 260 $posts = $this->_get_query_result( array( 261 'm' => array( '1234' ), // ignored 262 ) ); 293 $expected = $this->_get_query_result(); 294 $posts = $this->_get_query_result( 295 array( 296 'm' => array( '1234' ), // ignored 297 ) 298 ); 263 299 264 300 $this->assertEquals( $expected, $posts ); … … 266 302 267 303 public function test_simple_monthnum_expecting_results() { 268 $posts = $this->_get_query_result( array( 269 'monthnum' => 5, 270 ) ); 304 $posts = $this->_get_query_result( 305 array( 306 'monthnum' => 5, 307 ) 308 ); 271 309 272 310 $expected_dates = array( … … 282 320 283 321 public function test_simple_monthnum_expecting_noresults() { 284 $posts = $this->_get_query_result( array( 285 'monthnum' => 8, 286 ) ); 322 $posts = $this->_get_query_result( 323 array( 324 'monthnum' => 8, 325 ) 326 ); 287 327 288 328 $this->assertCount( 0, $posts ); … … 290 330 291 331 public function test_simple_w_as_in_week_expecting_results() { 292 $posts = $this->_get_query_result( array( 293 'w' => 24, 294 ) ); 332 $posts = $this->_get_query_result( 333 array( 334 'w' => 24, 335 ) 336 ); 295 337 296 338 $expected_dates = array( … … 304 346 305 347 public function test_simple_w_as_in_week_expecting_noresults() { 306 $posts = $this->_get_query_result( array( 307 'w' => 2, 308 ) ); 348 $posts = $this->_get_query_result( 349 array( 350 'w' => 2, 351 ) 352 ); 309 353 310 354 $this->assertCount( 0, $posts ); … … 312 356 313 357 public function test_simple_day_expecting_results() { 314 $posts = $this->_get_query_result( array( 315 'day' => 22, 316 ) ); 358 $posts = $this->_get_query_result( 359 array( 360 'day' => 22, 361 ) 362 ); 317 363 318 364 $expected_dates = array( … … 325 371 326 372 public function test_simple_day_expecting_noresults() { 327 $posts = $this->_get_query_result( array( 328 'day' => 30, 329 ) ); 373 $posts = $this->_get_query_result( 374 array( 375 'day' => 30, 376 ) 377 ); 330 378 331 379 $this->assertCount( 0, $posts ); … … 333 381 334 382 public function test_simple_hour_expecting_results() { 335 $posts = $this->_get_query_result( array( 336 'hour' => 21, 337 ) ); 383 $posts = $this->_get_query_result( 384 array( 385 'hour' => 21, 386 ) 387 ); 338 388 339 389 $expected_dates = array( … … 345 395 346 396 public function test_simple_hour_expecting_noresults() { 347 $posts = $this->_get_query_result( array( 348 'hour' => 2, 349 ) ); 397 $posts = $this->_get_query_result( 398 array( 399 'hour' => 2, 400 ) 401 ); 350 402 351 403 $this->assertCount( 0, $posts ); … … 353 405 354 406 public function test_simple_minute_expecting_results() { 355 $posts = $this->_get_query_result( array( 356 'minute' => 32, 357 ) ); 407 $posts = $this->_get_query_result( 408 array( 409 'minute' => 32, 410 ) 411 ); 358 412 359 413 $expected_dates = array( … … 366 420 367 421 public function test_simple_minute_expecting_noresults() { 368 $posts = $this->_get_query_result( array( 369 'minute' => 1, 370 ) ); 422 $posts = $this->_get_query_result( 423 array( 424 'minute' => 1, 425 ) 426 ); 371 427 372 428 $this->assertCount( 0, $posts ); … … 374 430 375 431 public function test_simple_second_expecting_results() { 376 $posts = $this->_get_query_result( array( 377 'second' => 30, 378 ) ); 432 $posts = $this->_get_query_result( 433 array( 434 'second' => 30, 435 ) 436 ); 379 437 380 438 $expected_dates = array( … … 386 444 387 445 public function test_simple_second_expecting_noresults() { 388 $posts = $this->_get_query_result( array( 389 'second' => 50, 390 ) ); 446 $posts = $this->_get_query_result( 447 array( 448 'second' => 50, 449 ) 450 ); 391 451 392 452 $this->assertCount( 0, $posts );
Note: See TracChangeset
for help on using the changeset viewer.