| | 1398 | |
| | 1399 | /** |
| | 1400 | * @ticket 52187 |
| | 1401 | */ |
| | 1402 | public function test_insert_empty_post_date_and_post_date_gmt() { |
| | 1403 | $post_id = self::factory()->post->create(); |
| | 1404 | $post = get_post( $post_id ); |
| | 1405 | $this->assertEqualsWithDelta( strtotime( date( 'Y-m-d H:i:s' ) ), strtotime( $post->post_date ), 2, 'The dates should be equal' ); |
| | 1406 | } |
| | 1407 | |
| | 1408 | /** |
| | 1409 | * @ticket 52187 |
| | 1410 | */ |
| | 1411 | public function test_insert_empty_post_date_and_invalid_post_date_gmt() { |
| | 1412 | $post_id = self::factory()->post->create( |
| | 1413 | array( |
| | 1414 | 'post_date' => '', |
| | 1415 | 'post_date_gmt' => '2020-12-41 10:10:10', |
| | 1416 | ) |
| | 1417 | ); |
| | 1418 | $post = get_post( $post_id ); |
| | 1419 | $this->assertEquals( '1970-01-01 00:00:00', $post->post_date ); |
| | 1420 | } |
| | 1421 | |
| | 1422 | /** |
| | 1423 | * @ticket 52187 |
| | 1424 | */ |
| | 1425 | /* |
| | 1426 | public function test_wp_resolve_post_date() { |
| | 1427 | // Both parameters empty, should return "now" date, hence the delta |
| | 1428 | $this->assertEqualsWithDelta( strtotime( date( 'Y-m-d H:i:s' ) ), strtotime( wp_resolve_post_date() ), 2, 'The dates should be equal' ); |
| | 1429 | |
| | 1430 | $post_date = '2020-12-29 10:15:27'; |
| | 1431 | $this->assertEquals( $post_date, wp_resolve_post_date( $post_date ) ); |
| | 1432 | |
| | 1433 | $post_date = '2020-12-41 10:15:27'; |
| | 1434 | $this->assertEquals( false, wp_resolve_post_date( $post_date ) ); |
| | 1435 | |
| | 1436 | $post_date_gmt = '2020-12-29 10:15:27'; |
| | 1437 | $this->assertEquals( get_date_from_gmt( $post_date_gmt ), wp_resolve_post_date( '', $post_date_gmt ) ); |
| | 1438 | |
| | 1439 | $post_date_gmt = '2020-12-41 10:15:27'; |
| | 1440 | $this->assertEquals( '1970-01-01 00:00:00', wp_resolve_post_date( '', $post_date_gmt ) ); |
| | 1441 | } |
| | 1442 | */ |