INFRA-132 - Drupal.Classes.ClassDeclaration
[civicrm-core.git] / tests / phpunit / WebTest / Member / FixedMembershipTypeTest.php
index 68e3e92a94e60b91db3a061af49a6c4623d9d201..487e2d1fbce6ff75febdc6d8dbe5ed377722f72a 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
 */
 
 require_once 'CiviTest/CiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Member_FixedMembershipTypeTest
+ */
 class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase {
 
   protected function setUp() {
     parent::setUp();
   }
 
-  function testMembershipTypeScenario1() {
+  public function testMembershipTypeScenario1() {
     // Scenario 1
     // Rollover Date < Start Date
     // Join Date > Rollover Date and Join Date < Start Date
@@ -55,10 +59,10 @@ class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase {
     $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
 
     $this->type('name', "Membership Type $title");
-    $this->select2('member_of_contact_id',$title);
+    $this->select2('member_of_contact_id', $title);
 
     $this->type('minimum_fee', '100');
-    $this->select( 'financial_type_id', 'value=2' );
+    $this->select('financial_type_id', 'value=2');
     $this->type('duration_interval', 1);
     $this->select('duration_unit', "label=year");
 
@@ -74,7 +78,7 @@ class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase {
 
     $this->click('_qf_MembershipType_upload-bottom');
     $this->waitForElementPresent('link=Add Membership Type');
-    $this->waitForText('crm-notification-container',"The membership type 'Membership Type $title' has been saved.");
+    $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
 
     $this->openCiviPage("contact/add", "reset=1&ct=Individual");
 
@@ -116,10 +120,10 @@ class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase {
     require_once 'CRM/Core/Config.php';
     require_once 'CRM/Utils/Array.php';
     require_once 'CRM/Utils/Date.php';
-    $currentYear  = date('Y');
+    $currentYear = date('Y');
     $currentMonth = date('m');
     $previousYear = $currentYear - 1;
-    $nextYear     = $currentYear + 1;
+    $nextYear = $currentYear + 1;
 
     $todayDate = date('Y-m-d');
 
@@ -134,7 +138,10 @@ class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase {
 
     $configVars = new CRM_Core_Config_Variables();
     foreach (array(
-      'joinDate', 'startDate', 'endDate') as $date) {
+               'joinDate',
+               'startDate',
+               'endDate',
+             ) as $date) {
       $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull);
     }
 
@@ -161,11 +168,11 @@ SELECT end_event_adjust_interval
 
     // Clicking save.
     $this->click('_qf_Membership_upload');
-    $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // page was loaded
     $this->waitForTextPresent($sourceText);
 
+    $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
     // Is status message correct?
     $this->assertTrue($this->isTextPresent("Membership Type $title membership for $firstName $lastName has been added."),
       "Status message didn't show up after saving!"
@@ -187,7 +194,7 @@ SELECT end_event_adjust_interval
     );
   }
 
-  function testMembershipTypeScenario2() {
+  public function testMembershipTypeScenario2() {
     // Scenario 2
     // Rollover Date < Join Date
 
@@ -210,10 +217,10 @@ SELECT end_event_adjust_interval
     $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
 
     $this->type('name', "Membership Type $title");
-    $this->select2('member_of_contact_id',$title);
+    $this->select2('member_of_contact_id', $title);
 
     $this->type('minimum_fee', '100');
-    $this->select( 'financial_type_id', 'value=2' );
+    $this->select('financial_type_id', 'value=2');
 
     $this->type('duration_interval', 2);
     $this->select('duration_unit', "label=year");
@@ -229,7 +236,7 @@ SELECT end_event_adjust_interval
 
     $this->click('_qf_MembershipType_upload-bottom');
     $this->waitForElementPresent('link=Add Membership Type');
-    $this->waitForText('crm-notification-container',"The membership type 'Membership Type $title' has been saved.");
+    $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
 
     $this->openCiviPage("contact/add", "reset=1&ct=Individual");
 
@@ -274,7 +281,7 @@ SELECT end_event_adjust_interval
     require_once 'CRM/Core/Config.php';
     require_once 'CRM/Utils/Array.php';
     require_once 'CRM/Utils/Date.php';
-    $currentYear  = date('Y');
+    $currentYear = date('Y');
     $currentMonth = date('m');
     $previousYear = $currentYear - 1;
 
@@ -290,7 +297,10 @@ SELECT end_event_adjust_interval
     $endDate = date('Y-m-d', mktime(0, 0, 0, 8, 31, $currentYear + 2));
     $configVars = new CRM_Core_Config_Variables();
     foreach (array(
-      'joinDate', 'startDate', 'endDate') as $date) {
+               'joinDate',
+               'startDate',
+               'endDate',
+             ) as $date) {
       $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull);
     }
 
@@ -317,7 +327,7 @@ SELECT end_event_adjust_interval
 
     // Clicking save.
     $this->click('_qf_Membership_upload');
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
 
     // page was loaded
     $this->waitForTextPresent($sourceText);
@@ -343,7 +353,7 @@ SELECT end_event_adjust_interval
     );
   }
 
-  function testMembershipTypeScenario3() {
+  public function testMembershipTypeScenario3() {
     // Scenario 3
     // Standard Fixed scenario - Jan 1 Fixed Period Start and October 31 rollover
     // Join Date is later than Rollover Date
@@ -367,10 +377,10 @@ SELECT end_event_adjust_interval
     $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
 
     $this->type('name', "Membership Type $title");
-    $this->select2('member_of_contact_id',$title);
+    $this->select2('member_of_contact_id', $title);
 
     $this->type('minimum_fee', '100');
-    $this->select( 'financial_type_id', 'value=2' );
+    $this->select('financial_type_id', 'value=2');
     $this->type('duration_interval', 1);
     $this->select('duration_unit', "label=year");
 
@@ -385,7 +395,7 @@ SELECT end_event_adjust_interval
     $this->click('_qf_MembershipType_upload-bottom');
     $this->waitForElementPresent('link=Add Membership Type');
 
-    $this->waitForText('crm-notification-container',"The membership type 'Membership Type $title' has been saved.");
+    $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
     $this->openCiviPage("contact/add", "reset=1&ct=Individual");
 
     $firstName = "John_" . substr(sha1(rand()), 0, 7);
@@ -429,17 +439,20 @@ SELECT end_event_adjust_interval
     require_once 'CRM/Core/Config.php';
     require_once 'CRM/Utils/Array.php';
     require_once 'CRM/Utils/Date.php';
-    $currentYear  = date('Y');
+    $currentYear = date('Y');
     $currentMonth = date('m');
     $previousYear = $currentYear - 1;
-    $nextYear     = $currentYear + 1;
-    $todayDate    = date('Y-m-d');
-    $joinDate     = date('Y-m-d', mktime(0, 0, 0, 11, 15, $currentYear));
-    $startDate    = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear));
-    $endDate      = date('Y-m-d', mktime(0, 0, 0, 12, 31, $nextYear));
-    $configVars   = new CRM_Core_Config_Variables();
+    $nextYear = $currentYear + 1;
+    $todayDate = date('Y-m-d');
+    $joinDate = date('Y-m-d', mktime(0, 0, 0, 11, 15, $currentYear));
+    $startDate = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear));
+    $endDate = date('Y-m-d', mktime(0, 0, 0, 12, 31, $nextYear));
+    $configVars = new CRM_Core_Config_Variables();
     foreach (array(
-      'joinDate', 'startDate', 'endDate') as $date) {
+               'joinDate',
+               'startDate',
+               'endDate',
+             ) as $date) {
       $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull);
     }
 
@@ -466,7 +479,7 @@ SELECT end_event_adjust_interval
 
     // Clicking save.
     $this->click('_qf_Membership_upload');
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
 
     // page was loaded
     $this->waitForTextPresent($sourceText);
@@ -492,7 +505,7 @@ SELECT end_event_adjust_interval
     );
   }
 
-  function testMembershipTypeScenario4() {
+  public function testMembershipTypeScenario4() {
     // Scenario 4
     // Standard Fixed scenario - Jan 1 Fixed Period Start and October 31 rollover
     // Join Date is earlier than Rollover Date
@@ -516,10 +529,10 @@ SELECT end_event_adjust_interval
     $this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
 
     $this->type('name', "Membership Type $title");
-    $this->select2('member_of_contact_id',$title);
+    $this->select2('member_of_contact_id', $title);
 
     $this->type('minimum_fee', '100');
-    $this->select( 'financial_type_id', 'value=2' );
+    $this->select('financial_type_id', 'value=2');
     $this->type('duration_interval', 1);
     $this->select('duration_unit', "label=year");
 
@@ -534,7 +547,7 @@ SELECT end_event_adjust_interval
 
     $this->click('_qf_MembershipType_upload-bottom');
     $this->waitForElementPresent('link=Add Membership Type');
-    $this->waitForText('crm-notification-container',"The membership type 'Membership Type $title' has been saved.");
+    $this->waitForText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");
 
     $this->openCiviPage("contact/add", "reset=1&ct=Individual");
 
@@ -577,20 +590,23 @@ SELECT end_event_adjust_interval
     require_once 'CRM/Core/Config.php';
     require_once 'CRM/Utils/Array.php';
     require_once 'CRM/Utils/Date.php';
-    $currentYear  = date('Y');
+    $currentYear = date('Y');
     $currentMonth = date('m');
-    $nextYear     = $currentYear + 1;
-    $todayDate    = date('Y-m-d');
+    $nextYear = $currentYear + 1;
+    $todayDate = date('Y-m-d');
 
     // the member-since date we will type in to membership form
     $joinDate = date('Y-m-d', mktime(0, 0, 0, 1, 15, $currentYear));
 
     // expected calc'd start and end dates
-    $startDate  = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear));
-    $endDate    = date('Y-m-d', mktime(0, 0, 0, 12, 31, $currentYear));
+    $startDate = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear));
+    $endDate = date('Y-m-d', mktime(0, 0, 0, 12, 31, $currentYear));
     $configVars = new CRM_Core_Config_Variables();
     foreach (array(
-      'joinDate', 'startDate', 'endDate') as $date) {
+               'joinDate',
+               'startDate',
+               'endDate',
+             ) as $date) {
       $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull);
     }
 
@@ -617,7 +633,7 @@ SELECT end_event_adjust_interval
 
     // Clicking save.
     $this->click('_qf_Membership_upload');
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
 
     // page was loaded
     $this->waitForTextPresent($sourceText);
@@ -642,5 +658,5 @@ SELECT end_event_adjust_interval
       )
     );
   }
-}
 
+}