function CommentHostnameUpdateTest::testCommentUpdate8600

Tests comment_update_8600().

See also

comment_update_8600

File

core/modules/comment/tests/src/Functional/Update/CommentHostnameUpdateTest.php, line 30

Class

CommentHostnameUpdateTest
Tests that comment hostname settings are properly updated.

Namespace

Drupal\Tests\comment\Functional\Update

Code

public function testCommentUpdate8600() {
    
    /** @var \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface $manager */
    $manager = $this->container
        ->get('entity.definition_update_manager');
    
    /** @var \Drupal\Core\Field\BaseFieldDefinition $definition */
    $definition = $manager->getFieldStorageDefinition('hostname', 'comment');
    // Check that 'hostname' base field doesn't have a default value callback.
    $this->assertNull($definition->getDefaultValueCallback());
    $this->runUpdates();
    $definition = $manager->getFieldStorageDefinition('hostname', 'comment');
    // Check that 'hostname' base field default value callback was set.
    $this->assertEquals(Comment::class . '::getDefaultHostname', $definition->getDefaultValueCallback());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.