diff --git a/core/modules/comment/src/Tests/Update/CommentUpdateTest.php b/core/modules/comment/src/Tests/Update/CommentUpdateTest.php index 3db9c4a67b..bf4baff3ca 100644 --- a/core/modules/comment/src/Tests/Update/CommentUpdateTest.php +++ b/core/modules/comment/src/Tests/Update/CommentUpdateTest.php @@ -2,6 +2,7 @@ namespace Drupal\comment\Tests\Update; +use Drupal\Core\Database\Database; use Drupal\system\Tests\Update\UpdatePathTestBase; /** @@ -71,4 +72,29 @@ public function testPublishedEntityKey() { $this->assertTrue(\Drupal::database()->schema()->indexExists('comment_field_data', 'comment__status_comment_type')); } + /** + * Tests whether the 'entity_type' column is required. + * + * @see comment_update_8204() + */ + public function testCommentEntityTypeRequired() { + $this->assertEqual(2, Database::getConnection()->query('SELECT count(*) FROM {comment_field_data}')->fetchField()); + if (Database::getConnection()->driver() === 'mysql') { + $table_description = \Drupal::database() + ->query('DESCRIBE comment_field_data') + ->fetchAllAssoc('Field'); + $this->assertEqual($table_description['entity_type']->Null, 'YES'); + } + + $this->runUpdates(); + + $this->assertEqual(2, Database::getConnection()->query('SELECT count(*) FROM {comment_field_data}')->fetchField()); + if (Database::getConnection()->driver() === 'mysql') { + $table_description = \Drupal::database() + ->query('DESCRIBE comment_field_data') + ->fetchAllAssoc('Field'); + $this->assertEqual($table_description['entity_type']->Null, 'NO'); + } + } + }