add autogenerated comment blocks to tests dir
[civicrm-core.git] / tests / phpunit / WebTest / Profile / ProfileGroupSubscriptionTest.php
index 6f22496e88991fd286610e0651240665ec756d0b..4667ed98723a0cbaecb0969577e235e7164ef13c 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  +--------------------------------------------------------------------+
 */
 
-
 require_once 'CiviTest/CiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Profile_ProfileGroupSubscriptionTest
+ */
 class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase {
 
   protected function setUp() {
@@ -37,7 +40,7 @@ class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase
 
     // Add new profile.
     $this->openCiviPage('admin/uf/group', 'reset=1');
-    
+
     $this->click('newCiviCRMProfile-top');
 
     $this->waitForElementPresent('_qf_Group_next-bottom');
@@ -45,6 +48,7 @@ class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase
     //Name of profile
     $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7);
     $this->type('title', $profileTitle);
+    $this->click('uf_group_type_Profile');
 
     //Drupal user account registration option
     $this->click('CIVICRM_QFID_0_8');
@@ -55,7 +59,7 @@ class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase
     //Proximity search options
     $this->click('CIVICRM_QFID_0_14');
 
-    // enable maping for contact
+    // enable mapping for contact
     $this->click('is_map');
 
     // include a link in the listings to Edit profile fields
@@ -69,7 +73,7 @@ class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     //check for  profile create
-    $this->assertElementContainsText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
+    $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
 
     //Add email field to profile
     $this->click('field_name[0]');
@@ -105,37 +109,37 @@ class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase
     $this->assertElementContainsText('crm-profile-block', 'Group(s)', "Groups field was not found.");
 
     //fill the subscription form
-    $radomEmail = substr(sha1(rand()), 0, 7) . "@example.com";
+    $randomEmail = substr(sha1(rand()), 0, 7) . "@example.com";
 
-    $this->type("email-Primary", $radomEmail);
+    $this->type("email-Primary", $randomEmail);
 
     // check advisory group ( may be we should create a separate group to test this)
     $this->click("group_3");
-    
+
     $this->click('_qf_Edit_next');
 
-    $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // assert for subscription message
-    $this->assertElementContainsText('messages', "Your subscription request has been submitted for group ", "Subscription message is not shown");
 
+    $this->isTextPresent("Your subscription request has been submitted for");
     //check if profile is saved
-    $this->assertElementContainsText('css=span.msg-text', 'Your information has been saved.', 'Profile is not saved');
+    $this->waitForText('crm-notification-container','Your information has been saved.');
 
     // delete the profile
     $this->openCiviPage('admin/uf/group', 'reset=1');
     $this->_testdeleteProfile($profileTitle);
   }
 
+  /**
+   * @param $profileTitle
+   */
   function _testdeleteProfile($profileTitle) {
-    //$this->click("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td[1]/span[text() = '$profileTitle']/../following-sibling::td[4]/span[2][text()='more']");
-    $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td[1]/span[text() = '$profileTitle']/../following-sibling::td[4]/span[2][text()='more']/ul/li[4]/a[text()='Delete']");
-    $this->click("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td[1]/span[text() = '$profileTitle']/../following-sibling::td[4]/span[2][text()='more']/ul/li[4]/a[text()='Delete']");
+    $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td/span[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul/li[4]/a[text()='Delete']");
+    $this->click("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td/span[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul/li[4]/a[text()='Delete']");
     $this->waitForElementPresent('_qf_Group_next-bottom');
     $this->click('_qf_Group_next-bottom');
     $this->waitForElementPresent('newCiviCRMProfile-bottom');
-    $this->assertElementContainsText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been deleted.");
+    $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been deleted.");
   }
 }
 
-