summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-12-05 20:06:28 +0000
committerAlex Pott2014-12-05 20:06:28 +0000
commit60950f36333faf63d56ef6b0d6cec80d03e1d411 (patch)
tree246c91566f0ad93fe5d50fdadac54a4a8a435c66
parenta8a42e62312dd66f6f4d748ddc8fefba9e0db4a4 (diff)
Issue #2383573 by tibbsa: Clean-up Contact module Test members - ensure property definition and use of camelCase naming convention
-rw-r--r--core/modules/contact/src/Tests/ContactPersonalTest.php102
-rw-r--r--core/modules/contact/src/Tests/Views/ContactFieldsTest.php10
2 files changed, 56 insertions, 56 deletions
diff --git a/core/modules/contact/src/Tests/ContactPersonalTest.php b/core/modules/contact/src/Tests/ContactPersonalTest.php
index 2e091c5..2fbab6e 100644
--- a/core/modules/contact/src/Tests/ContactPersonalTest.php
+++ b/core/modules/contact/src/Tests/ContactPersonalTest.php
@@ -37,69 +37,69 @@ class ContactPersonalTest extends WebTestBase {
/**
* A user with some administrative permissions.
*
- * @var object
+ * @var \Drupal\user\UserInterface
*/
- private $admin_user;
+ private $adminUser;
/**
* A user with 'access user contact forms' permission.
*
- * @var object
+ * @var \Drupal\user\UserInterface
*/
- private $web_user;
+ private $webUser;
/**
* A user without any permissions.
*
- * @var object
+ * @var \Drupal\user\UserInterface
*/
- private $contact_user;
+ private $contactUser;
protected function setUp() {
parent::setUp();
// Create an admin user.
- $this->admin_user = $this->drupalCreateUser(array('administer contact forms', 'administer users', 'administer account settings', 'access site reports'));
+ $this->adminUser = $this->drupalCreateUser(array('administer contact forms', 'administer users', 'administer account settings', 'access site reports'));
// Create some normal users with their contact forms enabled by default.
\Drupal::config('contact.settings')->set('user_default_enabled', TRUE)->save();
- $this->web_user = $this->drupalCreateUser(array('access user contact forms'));
- $this->contact_user = $this->drupalCreateUser();
+ $this->webUser = $this->drupalCreateUser(array('access user contact forms'));
+ $this->contactUser = $this->drupalCreateUser();
}
/**
* Tests that mails for contact messages are correctly sent.
*/
function testSendPersonalContactMessage() {
- $this->drupalLogin($this->web_user);
+ $this->drupalLogin($this->webUser);
- $message = $this->submitPersonalContact($this->contact_user);
+ $message = $this->submitPersonalContact($this->contactUser);
$mails = $this->drupalGetMails();
$this->assertEqual(1, count($mails));
$mail = $mails[0];
- $this->assertEqual($mail['to'], $this->contact_user->getEmail());
+ $this->assertEqual($mail['to'], $this->contactUser->getEmail());
$this->assertEqual($mail['from'], \Drupal::config('system.site')->get('mail'));
- $this->assertEqual($mail['reply-to'], $this->web_user->getEmail());
+ $this->assertEqual($mail['reply-to'], $this->webUser->getEmail());
$this->assertEqual($mail['key'], 'user_mail');
$variables = array(
'!site-name' => \Drupal::config('system.site')->get('name'),
'!subject' => $message['subject[0][value]'],
- '!recipient-name' => $this->contact_user->getUsername(),
+ '!recipient-name' => $this->contactUser->getUsername(),
);
$this->assertEqual($mail['subject'], t('[!site-name] !subject', $variables), 'Subject is in sent message.');
$this->assertTrue(strpos($mail['body'], t('Hello !recipient-name,', $variables)) !== FALSE, 'Recipient name is in sent message.');
- $this->assertTrue(strpos($mail['body'], $this->web_user->getUsername()) !== FALSE, 'Sender name is in sent message.');
+ $this->assertTrue(strpos($mail['body'], $this->webUser->getUsername()) !== FALSE, 'Sender name is in sent message.');
$this->assertTrue(strpos($mail['body'], $message['message[0][value]']) !== FALSE, 'Message body is in sent message.');
// Check there was no problems raised during sending.
$this->drupalLogout();
- $this->drupalLogin($this->admin_user);
+ $this->drupalLogin($this->adminUser);
// Verify that the correct watchdog message has been logged.
$this->drupalGet('/admin/reports/dblog');
$placeholders = array(
- '@sender_name' => $this->web_user->username,
- '@sender_email' => $this->web_user->getEmail(),
- '@recipient_name' => $this->contact_user->getUsername()
+ '@sender_name' => $this->webUser->username,
+ '@sender_email' => $this->webUser->getEmail(),
+ '@recipient_name' => $this->contactUser->getUsername()
);
$this->assertText(String::format('@sender_name (@sender_email) sent @recipient_name an email.', $placeholders));
}
@@ -109,25 +109,25 @@ class ContactPersonalTest extends WebTestBase {
*/
function testPersonalContactAccess() {
// Test allowed access to admin user's contact form.
- $this->drupalLogin($this->web_user);
- $this->drupalGet('user/' . $this->admin_user->id() . '/contact');
+ $this->drupalLogin($this->webUser);
+ $this->drupalGet('user/' . $this->adminUser->id() . '/contact');
$this->assertResponse(200);
// Check the page title is properly displayed.
- $this->assertRaw(t('Contact @username', array('@username' => $this->admin_user->getUsername())));
+ $this->assertRaw(t('Contact @username', array('@username' => $this->adminUser->getUsername())));
// Test denied access to admin user's own contact form.
$this->drupalLogout();
- $this->drupalLogin($this->admin_user);
- $this->drupalGet('user/' . $this->admin_user->id() . '/contact');
+ $this->drupalLogin($this->adminUser);
+ $this->drupalGet('user/' . $this->adminUser->id() . '/contact');
$this->assertResponse(403);
// Test allowed access to user with contact form enabled.
- $this->drupalLogin($this->web_user);
- $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
+ $this->drupalLogin($this->webUser);
+ $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
$this->assertResponse(200);
// Test denied access to the user's own contact form.
- $this->drupalGet('user/' . $this->web_user->id() . '/contact');
+ $this->drupalGet('user/' . $this->webUser->id() . '/contact');
$this->assertResponse(403);
// Test always denied access to the anonymous user contact form.
@@ -137,22 +137,22 @@ class ContactPersonalTest extends WebTestBase {
// Test that anonymous users can access the contact form.
$this->drupalLogout();
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access user contact forms'));
- $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
+ $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
$this->assertResponse(200);
// Test that anonymous users can access admin user's contact form.
- $this->drupalGet('user/' . $this->admin_user->id() . '/contact');
+ $this->drupalGet('user/' . $this->adminUser->id() . '/contact');
$this->assertResponse(200);
// Revoke the personal contact permission for the anonymous user.
user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access user contact forms'));
- $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
+ $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
$this->assertResponse(403);
- $this->drupalGet('user/' . $this->admin_user->id() . '/contact');
+ $this->drupalGet('user/' . $this->adminUser->id() . '/contact');
$this->assertResponse(403);
// Disable the personal contact form.
- $this->drupalLogin($this->admin_user);
+ $this->drupalLogin($this->adminUser);
$edit = array('contact_default_status' => FALSE);
$this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'), 'Setting successfully saved.');
@@ -160,40 +160,40 @@ class ContactPersonalTest extends WebTestBase {
// Re-create our contacted user with personal contact forms disabled by
// default.
- $this->contact_user = $this->drupalCreateUser();
+ $this->contactUser = $this->drupalCreateUser();
// Test denied access to a user with contact form disabled.
- $this->drupalLogin($this->web_user);
- $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
+ $this->drupalLogin($this->webUser);
+ $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
$this->assertResponse(403);
// Test allowed access for admin user to a user with contact form disabled.
- $this->drupalLogin($this->admin_user);
- $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
+ $this->drupalLogin($this->adminUser);
+ $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
$this->assertResponse(200);
// Re-create our contacted user as a blocked user.
- $this->contact_user = $this->drupalCreateUser();
- $this->contact_user->block();
- $this->contact_user->save();
+ $this->contactUser = $this->drupalCreateUser();
+ $this->contactUser->block();
+ $this->contactUser->save();
// Test that blocked users can still be contacted by admin.
- $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
+ $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
$this->assertResponse(200);
// Test that blocked users cannot be contacted by non-admins.
- $this->drupalLogin($this->web_user);
- $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
+ $this->drupalLogin($this->webUser);
+ $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
$this->assertResponse(403);
// Test enabling and disabling the contact page through the user profile
// form.
- $this->drupalGet('user/' . $this->web_user->id() . '/edit');
+ $this->drupalGet('user/' . $this->webUser->id() . '/edit');
$this->assertNoFieldChecked('edit-contact--2');
- $this->assertFalse(\Drupal::service('user.data')->get('contact', $this->web_user->id(), 'enabled'), 'Personal contact form disabled');
+ $this->assertFalse(\Drupal::service('user.data')->get('contact', $this->webUser->id(), 'enabled'), 'Personal contact form disabled');
$this->drupalPostForm(NULL, array('contact' => TRUE), t('Save'));
$this->assertFieldChecked('edit-contact--2');
- $this->assertTrue(\Drupal::service('user.data')->get('contact', $this->web_user->id(), 'enabled'), 'Personal contact form enabled');
+ $this->assertTrue(\Drupal::service('user.data')->get('contact', $this->webUser->id(), 'enabled'), 'Personal contact form enabled');
}
/**
@@ -208,21 +208,21 @@ class ContactPersonalTest extends WebTestBase {
$num_records_flood = db_query("SELECT COUNT(*) FROM {flood}")->fetchField();
$this->assertIdentical($num_records_flood, '0', 'Flood table emptied.');
- $this->drupalLogin($this->web_user);
+ $this->drupalLogin($this->webUser);
// Submit contact form with correct values and check flood interval.
for ($i = 0; $i < $flood_limit; $i++) {
- $this->submitPersonalContact($this->contact_user);
+ $this->submitPersonalContact($this->contactUser);
$this->assertText(t('Your message has been sent.'), 'Message sent.');
}
// Submit contact form one over limit.
- $this->drupalGet('user/' . $this->contact_user->id(). '/contact');
+ $this->drupalGet('user/' . $this->contactUser->id(). '/contact');
$this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => \Drupal::service('date.formatter')->formatInterval(\Drupal::config('contact.settings')->get('flood.interval')))), 'Normal user denied access to flooded contact form.');
// Test that the admin user can still access the contact form even though
// the flood limit was reached.
- $this->drupalLogin($this->admin_user);
+ $this->drupalLogin($this->adminUser);
$this->assertNoText('Try again later.', 'Admin user not denied access to flooded contact form.');
}
@@ -248,7 +248,7 @@ class ContactPersonalTest extends WebTestBase {
* (optional) The value the contact field should be set too.
*/
protected function checkContactAccess($response, $contact_value = NULL) {
- $this->drupalLogin($this->admin_user);
+ $this->drupalLogin($this->adminUser);
$this->drupalGet('admin/people/create');
if (\Drupal::config('contact.settings')->get('user_default_enabled', TRUE)) {
$this->assertFieldChecked('edit-contact--2');
diff --git a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php
index 5441526..014e968 100644
--- a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php
+++ b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php
@@ -28,17 +28,17 @@ class ContactFieldsTest extends ViewTestBase {
*
* @var \Drupal\field\Entity\FieldStorageConfig
*/
- protected $field_storage;
+ protected $fieldStorage;
protected function setUp() {
parent::setUp();
- $this->field_storage = entity_create('field_storage_config', array(
+ $this->fieldStorage = entity_create('field_storage_config', array(
'field_name' => strtolower($this->randomMachineName()),
'entity_type' => 'contact_message',
'type' => 'text'
));
- $this->field_storage->save();
+ $this->fieldStorage->save();
entity_create('contact_form', array(
'id' => 'contact_message',
@@ -46,7 +46,7 @@ class ContactFieldsTest extends ViewTestBase {
))->save();
entity_create('field_config', array(
- 'field_storage' => $this->field_storage,
+ 'field_storage' => $this->fieldStorage,
'bundle' => 'contact_message',
))->save();
@@ -59,7 +59,7 @@ class ContactFieldsTest extends ViewTestBase {
public function testViewsData() {
// Test that the field is not exposed to views, since contact_message
// entities have no storage.
- $table_name = 'contact_message__' . $this->field_storage->getName();
+ $table_name = 'contact_message__' . $this->fieldStorage->getName();
$data = $this->container->get('views.views_data')->get($table_name);
$this->assertFalse($data, 'The field is not exposed to Views.');
}