Issue #2212869 by hellboy2k8, leevingo, naveenvalecha, Grimreaper, subhojit777, poojasharmaece, kellyimagined, ZeiP, kostyashupenko, andypost, jibran: Extend ContactAuthenticatedUserTest for anonymous user
parent
bae3b3d7a6
commit
0e005bbca7
|
@ -1,35 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\Tests\contact\Functional;
|
|
||||||
|
|
||||||
use Drupal\Tests\BrowserTestBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests contact form textfields are present if authenticated.
|
|
||||||
*
|
|
||||||
* @group contact
|
|
||||||
*/
|
|
||||||
class ContactAuthenticatedUserTest extends BrowserTestBase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Modules to enable.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public static $modules = ['contact'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests that name and email fields are not present for authenticated users.
|
|
||||||
*/
|
|
||||||
public function testContactSiteWideTextfieldsLoggedInTestCase() {
|
|
||||||
$this->drupalLogin($this->drupalCreateUser(['access site-wide contact form']));
|
|
||||||
$this->drupalGet('contact');
|
|
||||||
|
|
||||||
// Ensure that there is no textfield for name.
|
|
||||||
$this->assertFalse($this->xpath('//input[@name=:name]', [':name' => 'name']));
|
|
||||||
|
|
||||||
// Ensure that there is no textfield for email.
|
|
||||||
$this->assertFalse($this->xpath('//input[@name=:name]', [':name' => 'mail']));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -44,6 +44,27 @@ class ContactSitewideTest extends BrowserTestBase {
|
||||||
* Tests configuration options and the site-wide contact form.
|
* Tests configuration options and the site-wide contact form.
|
||||||
*/
|
*/
|
||||||
public function testSiteWideContact() {
|
public function testSiteWideContact() {
|
||||||
|
// Tests name and email fields for authenticated and anonymous users.
|
||||||
|
$this->drupalLogin($this->drupalCreateUser(['access site-wide contact form']));
|
||||||
|
$this->drupalGet('contact');
|
||||||
|
|
||||||
|
// Ensure that there is no textfield for name.
|
||||||
|
$this->assertFalse($this->xpath('//input[@name=:name]', [':name' => 'name']));
|
||||||
|
|
||||||
|
// Ensure that there is no textfield for email.
|
||||||
|
$this->assertFalse($this->xpath('//input[@name=:name]', [':name' => 'mail']));
|
||||||
|
|
||||||
|
// Logout and retrieve the page as an anonymous user
|
||||||
|
$this->drupalLogout();
|
||||||
|
user_role_grant_permissions('anonymous', ['access site-wide contact form']);
|
||||||
|
$this->drupalGet('contact');
|
||||||
|
|
||||||
|
// Ensure that there is textfield for name.
|
||||||
|
$this->assertTrue($this->xpath('//input[@name=:name]', [':name' => 'name']));
|
||||||
|
|
||||||
|
// Ensure that there is textfield for email.
|
||||||
|
$this->assertTrue($this->xpath('//input[@name=:name]', [':name' => 'mail']));
|
||||||
|
|
||||||
// Create and log in administrative user.
|
// Create and log in administrative user.
|
||||||
$admin_user = $this->drupalCreateUser([
|
$admin_user = $this->drupalCreateUser([
|
||||||
'access site-wide contact form',
|
'access site-wide contact form',
|
||||||
|
|
Loading…
Reference in New Issue