Same name in other branches
- 8.x-1.x tests/src/Functional/EntityCloneCustomBlockTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneCustomBlockTest::testCustomBlockEntityClone()
Test custom block entity clone.
Fichier
-
tests/
src/ Functional/ EntityCloneCustomBlockTest.php, line 53
Classe
- EntityCloneCustomBlockTest
- Creat ea block and test a clone.
Namespace
Drupal\Tests\entity_clone\FunctionalCode
public function testCustomBlockEntityClone() {
$edit = [];
$edit['info[0][value]'] = 'Test block ready to clone';
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalGet('block/add/basic');
$this->submitForm($edit, $this->t('Save'));
$blocks = \Drupal::entityTypeManager()->getStorage('block_content')
->loadByProperties([
'info' => $edit['info[0][value]'],
]);
$block = reset($blocks);
$this->assertInstanceOf(BlockContent::class, $block, 'Test Block for clone found in database.');
$this->drupalGet('entity_clone/block_content/' . $block->id());
$this->submitForm([], $this->t('Clone'));
$blocks = \Drupal::entityTypeManager()->getStorage('block_content')
->loadByProperties([
'info' => $edit['info[0][value]'] . ' - Cloned',
'body' => $edit['body[0][value]'],
]);
$block = reset($blocks);
$this->assertInstanceOf(BlockContent::class, $block, 'Test Block cloned found in database.');
}