Commit 8e9545dd authored by Vincent Petry's avatar Vincent Petry Committed by Thomas Müller
Browse files

Fix unit tests that failed due to microseconds (#26502)

Since PHP 7.1.0RC4 the DateTime object populates the microsecond part.
Since databased usually don't store this, comparing the result with the
original date would fail.

This fixes the assertions by comparing the dates using a format that
doesn't contain the microseconds part.
parent 850ad9c4
...@@ -107,8 +107,8 @@ class ManagerTest extends TestCase { ...@@ -107,8 +107,8 @@ class ManagerTest extends TestCase {
$this->assertSame($comment->getVerb(), 'comment'); $this->assertSame($comment->getVerb(), 'comment');
$this->assertSame($comment->getObjectType(), 'files'); $this->assertSame($comment->getObjectType(), 'files');
$this->assertSame($comment->getObjectId(), 'file64'); $this->assertSame($comment->getObjectId(), 'file64');
$this->assertEquals($comment->getCreationDateTime(), $creationDT); $this->assertEquals($comment->getCreationDateTime()->format(\DateTime::ISO8601), $creationDT->format(\DateTime::ISO8601));
$this->assertEquals($comment->getLatestChildDateTime(), $latestChildDT); $this->assertEquals($comment->getLatestChildDateTime()->format(\DateTime::ISO8601), $latestChildDT->format(\DateTime::ISO8601));
} }
/** /**
...@@ -369,7 +369,7 @@ class ManagerTest extends TestCase { ...@@ -369,7 +369,7 @@ class ManagerTest extends TestCase {
$loadedComment = $manager->get($comment->getId()); $loadedComment = $manager->get($comment->getId());
$this->assertSame($comment->getMessage(), $loadedComment->getMessage()); $this->assertSame($comment->getMessage(), $loadedComment->getMessage());
$this->assertEquals($comment->getCreationDateTime(), $loadedComment->getCreationDateTime()); $this->assertEquals($comment->getCreationDateTime()->format(\DateTime::ISO8601), $loadedComment->getCreationDateTime()->format(\DateTime::ISO8601));
} }
public function testSaveUpdate() { public function testSaveUpdate() {
...@@ -573,7 +573,7 @@ class ManagerTest extends TestCase { ...@@ -573,7 +573,7 @@ class ManagerTest extends TestCase {
$dateTimeGet = $manager->getReadMark('robot', '36', $user); $dateTimeGet = $manager->getReadMark('robot', '36', $user);
$this->assertEquals($dateTimeGet, $dateTimeSet); $this->assertEquals($dateTimeGet->format(\DateTime::ISO8601), $dateTimeSet->format(\DateTime::ISO8601));
} }
public function testSetMarkReadUpdate() { public function testSetMarkReadUpdate() {
......
...@@ -744,7 +744,7 @@ class DefaultShareProviderTest extends TestCase { ...@@ -744,7 +744,7 @@ class DefaultShareProviderTest extends TestCase {
$this->assertSame($path, $share2->getNode()); $this->assertSame($path, $share2->getNode());
$this->assertSame('password', $share2->getPassword()); $this->assertSame('password', $share2->getPassword());
$this->assertSame('token', $share2->getToken()); $this->assertSame('token', $share2->getToken());
$this->assertEquals($expireDate, $share2->getExpirationDate()); $this->assertEquals($expireDate->format(\DateTime::ISO8601), $share2->getExpirationDate()->format(\DateTime::ISO8601));
} }
public function testGetShareByToken() { public function testGetShareByToken() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment