Changeset 48924 for trunk/tests/phpunit/tests/general/template.php
- Timestamp:
- 08/31/2020 10:41:02 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/general/template.php
r48907 r48924 416 416 $this->custom_logo_id = $this->_make_attachment( $upload ); 417 417 return $this->custom_logo_id; 418 }419 420 /**421 * Test get_the_modified_time422 *423 * @ticket 37059424 *425 * @since 4.6.0426 */427 function test_get_the_modified_time_default() {428 $details = array(429 'post_date' => '2016-01-21 15:34:36',430 'post_date_gmt' => '2016-01-21 15:34:36',431 );432 $post_id = $this->factory->post->create( $details );433 $post = get_post( $post_id );434 435 $GLOBALS['post'] = $post;436 437 $expected = '1453390476';438 $format = 'G';439 $actual = get_the_modified_time( $format );440 $this->assertEquals( $expected, $actual );441 }442 443 /**444 * Test get_the_modified_time failures are filtered445 *446 * @ticket 37059447 *448 * @since 4.6.0449 */450 function test_get_the_modified_time_failures_are_filtered() {451 // Remove global post object.452 $GLOBALS['post'] = null;453 454 $expected = 'filtered modified time failure result';455 add_filter( 'get_the_modified_time', array( $this, '_filter_get_the_modified_time_failure' ) );456 $actual = get_the_modified_time();457 $this->assertEquals( $expected, $actual );458 remove_filter( 'get_the_modified_time', array( $this, '_filter_get_the_modified_time_failure' ) );459 }460 461 function _filter_get_the_modified_time_failure( $the_time ) {462 $expected = false;463 $actual = $the_time;464 $this->assertEquals( $expected, $actual );465 466 if ( false === $the_time ) {467 return 'filtered modified time failure result';468 }469 return $the_time;470 }471 472 /**473 * Test get_the_modified_time with post_id parameter.474 *475 * @ticket 37059476 *477 * @since 4.6.0478 */479 function test_get_the_modified_date_with_post_id() {480 $details = array(481 'post_date' => '2016-01-21 15:34:36',482 'post_date_gmt' => '2016-01-21 15:34:36',483 );484 $post_id = $this->factory->post->create( $details );485 $format = 'Y-m-d';486 $expected = '2016-01-21';487 $actual = get_the_modified_date( $format, $post_id );488 $this->assertEquals( $expected, $actual );489 }490 491 /**492 * Test get_the_modified_date493 *494 * @ticket 37059495 *496 * @since 4.6.0497 */498 function test_get_the_modified_date_default() {499 $details = array(500 'post_date' => '2016-01-21 15:34:36',501 'post_date_gmt' => '2016-01-21 15:34:36',502 );503 $post_id = $this->factory->post->create( $details );504 $post = get_post( $post_id );505 506 $GLOBALS['post'] = $post;507 508 $expected = '2016-01-21';509 $format = 'Y-m-d';510 $actual = get_the_modified_date( $format );511 $this->assertEquals( $expected, $actual );512 }513 514 /**515 * Test get_the_modified_date failures are filtered516 *517 * @ticket 37059518 *519 * @since 4.6.0520 */521 function test_get_the_modified_date_failures_are_filtered() {522 // Remove global post object.523 $GLOBALS['post'] = null;524 525 $expected = 'filtered modified date failure result';526 add_filter( 'get_the_modified_date', array( $this, '_filter_get_the_modified_date_failure' ) );527 $actual = get_the_modified_date();528 $this->assertEquals( $expected, $actual );529 remove_filter( 'get_the_modified_date', array( $this, '_filter_get_the_modified_date_failure' ) );530 }531 532 function _filter_get_the_modified_date_failure( $the_date ) {533 $expected = false;534 $actual = $the_date;535 $this->assertEquals( $expected, $actual );536 537 if ( false === $the_date ) {538 return 'filtered modified date failure result';539 }540 return $the_date;541 }542 543 /**544 * Test get_the_modified_time with post_id parameter.545 *546 * @ticket 37059547 *548 * @since 4.6.0549 */550 function test_get_the_modified_time_with_post_id() {551 $details = array(552 'post_date' => '2016-01-21 15:34:36',553 'post_date_gmt' => '2016-01-21 15:34:36',554 );555 $post_id = $this->factory->post->create( $details );556 $format = 'G';557 $expected = '1453390476';558 $actual = get_the_modified_time( $format, $post_id );559 $this->assertEquals( $expected, $actual );560 418 } 561 419
Note: See TracChangeset
for help on using the changeset viewer.