function BlockContentSaveTest::testBlockContentSaveOnInsert

Same name in other branches
  1. 8.9.x core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php \Drupal\Tests\block_content\Functional\BlockContentSaveTest::testBlockContentSaveOnInsert()
  2. 10 core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php \Drupal\Tests\block_content\Functional\BlockContentSaveTest::testBlockContentSaveOnInsert()
  3. 11.x core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php \Drupal\Tests\block_content\Functional\BlockContentSaveTest::testBlockContentSaveOnInsert()

Tests saving a block on block insert.

This test ensures that a block has been fully saved when hook_block_content_insert() is invoked, so that the block can be saved again in a hook implementation without errors.

See also

block_test_block_insert()

File

core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php, line 103

Class

BlockContentSaveTest
Tests $block_content->save() for saving content.

Namespace

Drupal\Tests\block_content\Functional

Code

public function testBlockContentSaveOnInsert() {
    // block_content_test_block_content_insert() triggers a save on insert if the
    // title equals 'new'.
    $block = $this->createBlockContent('new');
    $this->assertEquals('BlockContent ' . $block->id(), $block->label(), 'Custom block saved on block insert.');
}

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