summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2023-04-26 13:17:37 -0300
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-05-03 08:36:27 +0000
commit77bcc6f26e3fbac67ef786469f9065cddc63a3b4 (patch)
treeb508b4cc34fe52ad5286c129d9ac15eec4633f9f /tests
parentf13aa710766b3f3a73b5a270772d70ed8bb53c69 (diff)
downloadnextcloud-server-77bcc6f26e3fbac67ef786469f9065cddc63a3b4.tar.gz
nextcloud-server-77bcc6f26e3fbac67ef786469f9065cddc63a3b4.zip
Cover expire_date with unit tests
Signed-off-by: Vitor Mattos <vitor@php.rio>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Comments/ManagerTest.php30
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/lib/Comments/ManagerTest.php b/tests/lib/Comments/ManagerTest.php
index 1af460e6f1b..1d08f0f5085 100644
--- a/tests/lib/Comments/ManagerTest.php
+++ b/tests/lib/Comments/ManagerTest.php
@@ -516,15 +516,41 @@ class ManagerTest extends TestCase {
->setActor('users', 'alice')
->setObject('files', 'file64')
->setMessage('very beautiful, I am impressed!')
- ->setVerb('comment');
+ ->setVerb('comment')
+ ->setExpireDate(new \DateTime('+2 hours'));
$manager->save($comment);
- $comment->setMessage('very beautiful, I am really so much impressed!');
+ $loadedComment = $manager->get($comment->getId());
+ // Compare current object with database values
+ $this->assertSame($comment->getMessage(), $loadedComment->getMessage());
+ $this->assertSame(
+ $comment->getExpireDate()->format('Y-m-d H:i:s'),
+ $loadedComment->getExpireDate()->format('Y-m-d H:i:s')
+ );
+
+ // Preserve the original comment to compare after update
+ $original = clone $comment;
+
+ // Update values
+ $comment->setMessage('very beautiful, I am really so much impressed!')
+ ->setExpireDate(new \DateTime('+1 hours'));
$manager->save($comment);
$loadedComment = $manager->get($comment->getId());
+ // Compare current object with database values
$this->assertSame($comment->getMessage(), $loadedComment->getMessage());
+ $this->assertSame(
+ $comment->getExpireDate()->format('Y-m-d H:i:s'),
+ $loadedComment->getExpireDate()->format('Y-m-d H:i:s')
+ );
+
+ // Compare original object with database values
+ $this->assertNotSame($original->getMessage(), $loadedComment->getMessage());
+ $this->assertNotSame(
+ $original->getExpireDate()->format('Y-m-d H:i:s'),
+ $loadedComment->getExpireDate()->format('Y-m-d H:i:s')
+ );
}