BulkFormTest.php in Contact Storage 8
File
tests/src/Functional/BulkFormTest.php
View source
<?php
namespace Drupal\Tests\contact_storage\Functional;
use Drupal\Core\Session\AccountInterface;
use Drupal\views\Tests\ViewTestData;
class BulkFormTest extends ContactStorageTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'contact_storage',
'contact_test_views',
'language',
];
public static $testViews = [
'test_contact_message_bulk_form',
];
protected function setUp() {
parent::Setup();
$admin_user = $this
->drupalCreateUser([
'administer contact forms',
]);
$this
->drupalLogin($admin_user);
$mail = 'simpletest@example.com';
$this
->addContactForm('test_id', 'test_label', $mail, TRUE);
$this
->assertText('Contact form test_label has been added.');
$this
->drupalLogout();
user_role_grant_permissions(AccountInterface::ANONYMOUS_ROLE, [
'access site-wide contact form',
]);
$this
->drupalGet('contact');
$this
->assertText('Your email address');
for ($i = 1; $i <= 5; $i++) {
$this
->submitContact($this
->randomMachineName(), $mail, $this
->randomMachineName(), 'test_id', $this
->randomMachineName());
$this
->assertText('Your message has been sent.');
}
}
public function testBulkDeletion() {
$this
->drupalGet('contact');
ViewTestData::createTestViews(get_class($this), [
'contact_test_views',
]);
$this
->drupalLogin($this
->drupalCreateUser([
'administer contact forms',
]));
$this
->drupalGet('test-contact-message-bulk-form');
$elements = $this
->xpath('//select[@id="edit-action"]//option');
$this
->assertIdentical(count($elements), 1, 'All contact message operations are found.');
$this
->drupalPostForm('test-contact-message-bulk-form', [], t('Apply to selected items'));
$this
->assertText('No message selected.');
}
}