Skip to content
Merged
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
Prev Previous commit
Cover expire_date with unit tests
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos authored and backportbot-nextcloud[bot] committed May 3, 2023
commit a597bf347dd2048ec35bc04b6b4a4fbfd80fafa0
30 changes: 28 additions & 2 deletions tests/lib/Comments/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,15 +516,41 @@ public function testSaveUpdate() {
->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')
);
}


Expand Down