From da85ef7e7e3da3472b709a0f05f2dfc741036914 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Thu, 5 Jan 2017 15:13:29 +0100 Subject: [PATCH] Tests: fix date comparison failure on PHP 7.1 Since PHP 7.1, DateTime constructor incorporates microseconds [1]. This causes the testCreateIssueWithRareFields() case to fail comparing the last_updated field, as the reference DateTime object now contains microseconds whereas the underlying database fields does not (see failed Travis build [2]). 1) IssueAddTest::testCreateIssueWithRareFields Failed asserting that two DateTime objects are equal. --- Expected +++ Actual @@ @@ -2017-01-05T12:28:55.533798+0000 +2017-01-05T12:28:55.000000+0000 The DateTime is now initialized from time() instead, so the microseconds are set to 0. Fixes #22114 [1] http://php.net/manual/en/migration71.incompatible.php [2] https://travis-ci.org/mantisbt/mantisbt/jobs/189164182 --- tests/soap/IssueAddTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/soap/IssueAddTest.php b/tests/soap/IssueAddTest.php index d894e1f87a..bc4ca2dfcf 100644 --- a/tests/soap/IssueAddTest.php +++ b/tests/soap/IssueAddTest.php @@ -135,7 +135,7 @@ public function testCreateIssueWithRareFields() { $t_issue_to_add['target_version'] = 'target version'; $t_issue_to_add['sticky'] = true; - $t_dt = new DateTime(); + $t_dt = DateTime::createFromFormat( 'U', time() ); $t_issue_to_add['last_updated'] = $t_dt->format( DateTime::ISO8601 ); $t_issue_id = $this->client->mc_issue_add( $this->userName, $this->password, $t_issue_to_add );