Same name in other branches
- 2.x tests/src/Functional/EntityCloneCustomBlockTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneCustomBlockTest
Creat ea block and test a clone.
@group entity_clone
Hierarchy
- class \Drupal\Tests\entity_clone\Functional\EntityCloneCustomBlockTest extends \Drupal\Tests\block_content\Functional\BlockContentTestBase uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of EntityCloneCustomBlockTest
File
-
tests/
src/ Functional/ EntityCloneCustomBlockTest.php, line 14
Namespace
Drupal\Tests\entity_clone\FunctionalView source
class EntityCloneCustomBlockTest extends BlockContentTestBase {
use StringTranslationTrait;
/**
* Modules to enable.
*
* Enable dummy module that implements hook_block_insert() for exceptions and
* field_ui to edit display settings.
*
* @var array
*/
protected static $modules = [
'entity_clone',
'block',
'block_content',
];
/**
* Theme to enable by default.
*
* @var string
*/
protected $defaultTheme = 'claro';
/**
* Permissions to grant admin user.
*
* @var array
*/
protected $permissions = [
'administer blocks',
'clone block_content entity',
];
/**
* Sets the test up.
*/
protected function setUp() : void {
parent::setUp();
$this->drupalLogin($this->adminUser);
}
/**
* Test custom block entity clone.
*/
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.');
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
EntityCloneCustomBlockTest::$defaultTheme | protected | property | Theme to enable by default. |
EntityCloneCustomBlockTest::$modules | protected static | property | Modules to enable. |
EntityCloneCustomBlockTest::$permissions | protected | property | Permissions to grant admin user. |
EntityCloneCustomBlockTest::setUp | protected | function | Sets the test up. |
EntityCloneCustomBlockTest::testCustomBlockEntityClone | public | function | Test custom block entity clone. |