DeleteOrphanedMessagesUpdateTest.php in Message Digest 8
File
tests/src/Functional/Update/DeleteOrphanedMessagesUpdateTest.php
View source
<?php
namespace Drupal\Tests\message_digest\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
class DeleteOrphanedMessagesUpdateTest extends UpdatePathTestBase {
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
$this->root . '/core/modules/system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../fixtures/update/message-digest-update-common.php',
__DIR__ . '/../../../fixtures/update/message-digest-post-update-delete-orphaned-messages.php',
];
}
public function testUpdate() {
$this
->assertRowCount(3);
$this
->runUpdates();
$this
->assertRowCount(1);
$ids = \Drupal::database()
->select('message_digest', 'md')
->fields('md', [
'id',
])
->execute()
->fetchCol();
$id = reset($ids);
$this
->assertEquals(3, $id);
}
protected function assertRowCount($expected_count) {
$actual_count = \Drupal::database()
->select('message_digest', 'md')
->countQuery()
->execute()
->fetchField();
$this
->assertEquals($expected_count, $actual_count);
}
}