class CommentStringIdEntitiesTest
Same name and namespace in other branches
- 11.x core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php \Drupal\Tests\comment\Kernel\CommentStringIdEntitiesTest
- 10 core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php \Drupal\Tests\comment\Kernel\CommentStringIdEntitiesTest
- 8.9.x core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php \Drupal\Tests\comment\Kernel\CommentStringIdEntitiesTest
Tests that comment fields cannot be added to entities with non-integer IDs.
@group comment
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\comment\Kernel\CommentStringIdEntitiesTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of CommentStringIdEntitiesTest
File
-
core/
modules/ comment/ tests/ src/ Kernel/ CommentStringIdEntitiesTest.php, line 14
Namespace
Drupal\Tests\comment\KernelView source
class CommentStringIdEntitiesTest extends KernelTestBase {
/**
* Modules to install.
*
* @var array
*/
protected static $modules = [
'comment',
'user',
'field',
'field_ui',
'entity_test',
'text',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('comment');
$this->installEntitySchema('entity_test_string_id');
$this->installSchema('comment', [
'comment_entity_statistics',
]);
// Create the comment body field storage.
$this->installConfig([
'field',
]);
}
/**
* Tests that comment fields cannot be added entities with non-integer IDs.
*/
public function testCommentFieldNonStringId() {
$this->expectException(\UnexpectedValueException::class);
$bundle = CommentType::create([
'id' => 'foo',
'label' => 'foo',
'description' => '',
'target_entity_type_id' => 'entity_test_string_id',
]);
$bundle->save();
$field_storage = FieldStorageConfig::create([
'field_name' => 'foo',
'entity_type' => 'entity_test_string_id',
'settings' => [
'comment_type' => 'entity_test_string_id',
],
'type' => 'comment',
]);
$field_storage->save();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.