From 8692199bb57943f08501c1be72cbcb46c2e85aa9 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 17 Oct 2014 00:40:06 +0000 Subject: [PATCH] Add expectedIncorrectUsage flags for unit tests that generate invalid dates. Since [29925], passing an invalid date to WP_Date_Query will generate a _doing_it_wrong() notice. The current changeset adds the `@expectedIncorrectUsage` flag to those existing unit tests that generate invalid dates, such as those that test canonical redirect and is_404() conditionals. Fixes #25834. git-svn-id: https://develop.svn.wordpress.org/trunk@29932 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/canonical.php | 6 ++++-- tests/phpunit/tests/query/conditionals.php | 3 +++ tests/phpunit/tests/query/results.php | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/canonical.php b/tests/phpunit/tests/canonical.php index fe6e22fb93..b7aa49c1cc 100644 --- a/tests/phpunit/tests/canonical.php +++ b/tests/phpunit/tests/canonical.php @@ -106,7 +106,9 @@ class Tests_Canonical extends WP_UnitTestCase { /** * @dataProvider data */ - function test($test_url, $expected, $ticket = 0) { + function test( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) { + $this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, (array) $expected_doing_it_wrong ); + if ( $ticket ) $this->knownWPBug( $ticket ); @@ -246,7 +248,7 @@ class Tests_Canonical extends WP_UnitTestCase { array( '/?year=2008', '/2008/'), array( '/2012/13/', '/2012/'), - array( '/2012/11/51/', '/2012/11/'), + array( '/2012/11/51/', '/2012/11/', 0, array( 'WP_Date_Query' ) ), // Authors array( '/?author=%d', '/author/canonical-author/' ), diff --git a/tests/phpunit/tests/query/conditionals.php b/tests/phpunit/tests/query/conditionals.php index 0f0931b385..70d5a7df17 100644 --- a/tests/phpunit/tests/query/conditionals.php +++ b/tests/phpunit/tests/query/conditionals.php @@ -603,6 +603,9 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', + /** + * @expectedIncorrectUsage WP_Date_Query + */ function test_bad_dates() { $this->go_to( '/2013/13/13/' ); $this->assertQueryTrue( 'is_404' ); diff --git a/tests/phpunit/tests/query/results.php b/tests/phpunit/tests/query/results.php index 9a3e89d264..f65afdf486 100644 --- a/tests/phpunit/tests/query/results.php +++ b/tests/phpunit/tests/query/results.php @@ -573,7 +573,13 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertFalse( $this->q->is_day ); $this->assertFalse( $this->q->is_month ); $this->assertTrue( $this->q->is_year ); + } + /** + * @ticket 10935 + * @expectedIncorrectUsage WP_Date_Query + */ + public function test_query_is_date_with_bad_date() { $this->q->query( array( 'year' => '2007', 'monthnum' => '01',