protected function setUp() {
    parent::setUp();

    $this->drupalPlaceBlock('system_breadcrumb_block');
    $this->drupalPlaceBlock('local_actions_block');
    $this->drupalPlaceBlock('page_title_block');

    // Create and login administrative user.
    $this->adminUser = $this->drupalCreateUser([
      'access site-wide contact form',
      'administer contact forms',
      'administer users',
      'administer account settings',
      'administer contact_message fields',
      'administer contact_message form display',
      'administer contact_message display',
    ]);
    $this->drupalLogin($this->adminUser);
  }
Exemple #2
0
  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::Setup();
    // Create and login administrative user.
    $admin_user = $this->drupalCreateUser(array(
      'administer contact forms',
    ));
    $this->drupalLogin($admin_user);
    // Create first valid contact form.
    $mail = '*****@*****.**';
    $this->addContactForm('test_id', 'test_label', $mail, '', TRUE);
    $this->assertText(t('Contact form test_label has been added.'));
    $this->drupalLogout();

    // Ensure that anonymous can submit site-wide contact form.
    user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form'));
    $this->drupalGet('contact');
    $this->assertText(t('Your email address'));
    // Submit contact form few times.
    for ($i = 1; $i <= 5; $i++) {
      $this->submitContact($this->randomMachineName(), $mail, $this->randomMachineName(), 'test_id', $this->randomMachineName());
      $this->assertText(t('Your message has been sent.'));
    }
  }