public function CommentStringIdEntitiesTest::testCommentFieldNonStringId in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php \Drupal\comment\Tests\CommentStringIdEntitiesTest::testCommentFieldNonStringId()
Tests that comment fields cannot be added entities with non-integer IDs.
File
- core/
modules/ comment/ src/ Tests/ CommentStringIdEntitiesTest.php, line 45 - Contains \Drupal\comment\Tests\CommentStringIdEntitiesTest.
Class
- CommentStringIdEntitiesTest
- Tests that comment fields cannot be added to entities with non-integer IDs.
Namespace
Drupal\comment\TestsCode
public function testCommentFieldNonStringId() {
try {
$bundle = CommentType::create(array(
'id' => 'foo',
'label' => 'foo',
'description' => '',
'target_entity_type_id' => 'entity_test_string_id',
));
$bundle
->save();
$field_storage = entity_create('field_storage_config', array(
'field_name' => 'foo',
'entity_type' => 'entity_test_string_id',
'settings' => array(
'comment_type' => 'entity_test_string_id',
),
'type' => 'comment',
));
$field_storage
->save();
$this
->fail('Did not throw an exception as expected.');
} catch (\UnexpectedValueException $e) {
$this
->pass('Exception thrown when trying to create comment field on Entity Type with string ID.');
}
}