You are here

public function BlockContentSaveTest::testBlockContentSaveOnInsert in Drupal 8

Same name and namespace in other branches
  1. 9 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 101

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
    ->assertEqual($block
    ->label(), 'BlockContent ' . $block
    ->id(), 'Custom block saved on block insert.');
}