Same name in other branches
- 2.x tests/src/Functional/EntityCloneContactTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneContactTest
Create an contact form and test a clone.
@group entity_clone
Hierarchy
- class \Drupal\Tests\entity_clone\Functional\EntityCloneContactTest extends \Drupal\Tests\BrowserTestBase uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of EntityCloneContactTest
Fichier
-
tests/
src/ Functional/ EntityCloneContactTest.php, line 14
Namespace
Drupal\Tests\entity_clone\FunctionalView source
class EntityCloneContactTest extends BrowserTestBase {
use StringTranslationTrait;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'entity_clone',
'contact',
];
/**
* Theme to enable by default.
*
* @var string
*/
protected $defaultTheme = 'claro';
/**
* Permissions to grant admin user.
*
* @var array
*/
protected $permissions = [
'administer contact forms',
'clone contact_form entity',
];
/**
* An administrative user with permission to configure contact forms settings.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* Sets the test up.
*/
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this->drupalCreateUser($this->permissions);
$this->drupalLogin($this->adminUser);
}
/**
* Test contact form entity clone.
*/
public function testContactFormsEntityClone() {
$edit = [
'label' => 'Test contact form for clone',
'id' => 'test_contact_form_for_clone',
'recipients' => 'test@recipient.com',
];
$this->drupalGet('admin/structure/contact/add');
$this->submitForm($edit, $this->t('Save'));
$contact_forms = \Drupal::entityTypeManager()->getStorage('contact_form')
->loadByProperties([
'id' => $edit['id'],
]);
$contact_form = reset($contact_forms);
$edit = [
'label' => 'Test contact form cloned',
'id' => 'test_contact_form_cloned',
];
$this->drupalGet('entity_clone/contact_form/' . $contact_form->id());
$this->submitForm($edit, $this->t('Clone'));
$contact_forms = \Drupal::entityTypeManager()->getStorage('contact_form')
->loadByProperties([
'id' => $edit['id'],
]);
$contact_form = reset($contact_forms);
$this->assertInstanceOf(ContactForm::class, $contact_form, 'Test contact form cloned found in database.');
$edit = [
'id' => 'test_contact_form_clone_with_a_really_long_name_that_is_longer_than_the_bundle_max_length',
'label' => 'Test contact form clone with a really long name that is longer than the bundle max length',
];
$this->drupalGet('entity_clone/contact_form/' . $contact_form->id());
$this->submitForm($edit, $this->t('Clone'));
$this->assertSession()
->pageTextContains('New Id cannot be longer than 32 characters');
}
}
Members
Titre Trier par ordre décroissant | Modifiers | Object type | Résumé |
---|---|---|---|
EntityCloneContactTest::$adminUser | protected | property | An administrative user with permission to configure contact forms settings. |
EntityCloneContactTest::$defaultTheme | protected | property | Theme to enable by default. |
EntityCloneContactTest::$modules | protected static | property | Modules to enable. |
EntityCloneContactTest::$permissions | protected | property | Permissions to grant admin user. |
EntityCloneContactTest::setUp | protected | function | Sets the test up. |
EntityCloneContactTest::testContactFormsEntityClone | public | function | Test contact form entity clone. |