Skip to content

Commit 402225f

Browse files
committed
test: add try/finally and value assertions for preserveDates test
1 parent 49aa318 commit 402225f

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

tests/e2e/Adapter/Scopes/DocumentTests.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,20 +1547,26 @@ public function testIncreaseDecreasePreserveDates(Document $document): void
15471547

15481548
$database->setPreserveDates(true);
15491549

1550-
$before = $database->getDocument('increase_decrease', $document->getId());
1551-
$updatedAt = $before->getUpdatedAt();
1552-
1553-
$database->increaseDocumentAttribute('increase_decrease', $document->getId(), 'increase', 1);
1550+
try {
1551+
$before = $database->getDocument('increase_decrease', $document->getId());
1552+
$updatedAt = $before->getUpdatedAt();
1553+
$increase = $before->getAttribute('increase');
1554+
$decrease = $before->getAttribute('decrease');
15541555

1555-
$after = $database->getDocument('increase_decrease', $document->getId());
1556-
$this->assertSame($updatedAt, $after->getUpdatedAt());
1556+
$database->increaseDocumentAttribute('increase_decrease', $document->getId(), 'increase', 1);
15571557

1558-
$database->decreaseDocumentAttribute('increase_decrease', $document->getId(), 'decrease', 1);
1558+
$after = $database->getDocument('increase_decrease', $document->getId());
1559+
$this->assertSame($increase + 1, $after->getAttribute('increase'));
1560+
$this->assertSame($updatedAt, $after->getUpdatedAt());
15591561

1560-
$after = $database->getDocument('increase_decrease', $document->getId());
1561-
$this->assertSame($updatedAt, $after->getUpdatedAt());
1562+
$database->decreaseDocumentAttribute('increase_decrease', $document->getId(), 'decrease', 1);
15621563

1563-
$database->setPreserveDates(false);
1564+
$after = $database->getDocument('increase_decrease', $document->getId());
1565+
$this->assertSame($decrease - 1, $after->getAttribute('decrease'));
1566+
$this->assertSame($updatedAt, $after->getUpdatedAt());
1567+
} finally {
1568+
$database->setPreserveDates(false);
1569+
}
15641570
}
15651571

15661572
/**

0 commit comments

Comments
 (0)