Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions tests/phpunit/tests/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,13 +816,16 @@ public function test_use_block_editor_for_post() {
}

/**
* The purpose of this test is to ensure that invalid dates do not
* cause PHP errors when wp_insert_post() is called, and that the
* posts are not actually "inserted" (created).
*
* @ticket 26798
*
* @dataProvider data_wp_insert_post_handle_malformed_post_date
*
* The purpose of this test is to ensure that invalid dates do not
* cause PHP errors when wp_insert_post() is called, and that the
* posts are not actually "inserted" (created).
* @param string $input The input post_date value.
* @param bool $expected Whether the post is expected to be inserted.
*/
public function test_wp_insert_post_handle_malformed_post_date( $input, $expected ) {
$post = array(
Expand All @@ -842,9 +845,16 @@ public function test_wp_insert_post_handle_malformed_post_date( $input, $expecte
}

/**
* @ticket 26798
* Data provider for test_wp_insert_post_handle_malformed_post_date().
*
* @return array[] {
* Arguments passed to test.
*
* @type string $input The input post_date value.
* @type bool $expected Whether the post is expected to be inserted.
* }
*/
public function data_wp_insert_post_handle_malformed_post_date() {
public static function data_wp_insert_post_handle_malformed_post_date() {
return array(
array(
'2012-01-01',
Expand Down Expand Up @@ -940,12 +950,15 @@ public function data_wp_insert_post_handle_malformed_post_date() {
}

/**
* Tests the regex inside of wp_resolve_post_date(), with
* the emphasis on the date format (not the time).
*
* @ticket 26798
*
* @dataProvider data_wp_resolve_post_date_regex
*
* Tests the regex inside of wp_resolve_post_date(), with
* the emphasis on the date format (not the time).
* @param string $date The input post_date value.
* @param string|false $expected The expected resolved post date, or false if invalid
*/
public function test_wp_resolve_post_date_regex( $date, $expected ) {
// Attempt to resolve post date.
Expand All @@ -956,9 +969,16 @@ public function test_wp_resolve_post_date_regex( $date, $expected ) {
}

/**
* @ticket 26798
* Data provider for test_wp_resolve_post_date_regex().
*
* @return array[] {
* Arguments passed to test.
*
* @type string $date The input post_date value.
* @type string|false $expected The expected resolved post date, or false if invalid
* }
*/
public function data_wp_resolve_post_date_regex() {
public static function data_wp_resolve_post_date_regex() {
return array(
array(
'2012-01-01',
Expand Down
Loading