public function DeleteOrphanedMessagesUpdateTest::testUpdate in Message Digest 8
Tests the post-update hook.
File
- tests/
src/ Functional/ Update/ DeleteOrphanedMessagesUpdateTest.php, line 30
Class
- DeleteOrphanedMessagesUpdateTest
- Tests the post-update hook that cleans up orphaned messages.
Namespace
Drupal\Tests\message_digest\Functional\UpdateCode
public function testUpdate() {
// There should be three rows in the message_digest table before executing
// the update.
$this
->assertRowCount(3);
// One of the rows contains an orphaned reference to a deleted user, and
// another row an orphaned reference to a deleted message, so 1 row should
// remain after running the updates.
$this
->runUpdates();
$this
->assertRowCount(1);
// Check that the correct row remains. The correct row has the ID '3'.
$ids = \Drupal::database()
->select('message_digest', 'md')
->fields('md', [
'id',
])
->execute()
->fetchCol();
$id = reset($ids);
$this
->assertEquals(3, $id);
}