webtestLogin(); // Add a new membership type $memTypeParams = $this->addMembershipType(); $firstName = substr(sha1(rand()), 0, 7); $email = "$firstName.Anderson@example.com"; $this->webtestAddContact($firstName, 'Anderson', $email); $this->waitForElementPresent('css=li#tab_member a'); $this->click('css=li#tab_member a'); $this->waitForElementPresent('link=Add Membership'); $this->click('link=Add Membership'); $this->waitForElementPresent('_qf_Membership_cancel-bottom'); $this->select('membership_type_id[0]', "label={$memTypeParams['member_of_contact']}"); $this->select('membership_type_id[1]', "label={$memTypeParams['membership_type']}"); // Fill join date $this->webtestFillDate('join_date', "1 March 2008"); // Override status $this->check('is_override'); $this->select('status_id', "label=Current"); // Clicking save. $this->click('_qf_Membership_upload'); $this->waitForPageToLoad($this->getTimeoutMsec()); // Is status message correct? $this->assertElementContainsText('crm-notification-container', "{$memTypeParams['membership_type']} membership for $firstName Anderson has been added.", "Status message didn't show up after saving!" ); // click through to the membership view screen $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]"); $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); $this->webtestVerifyTabularData( array( 'Membership Type' => "{$memTypeParams['membership_type']}", 'Status' => 'Current', 'Member Since' => 'March 1st, 2008', 'Start date' => 'March 1st, 2008', 'End date' => 'February 28th, 2009', ) ); } function addMembershipType() { $membershipTitle = substr(sha1(rand()), 0, 7); $membershipOrg = $membershipTitle . ' memorg'; $this->webtestAddOrganization($membershipOrg, TRUE); $title = "Membership Type " . substr(sha1(rand()), 0, 7); $memTypeParams = array( 'membership_type' => $title, 'member_of_contact' => $membershipOrg, 'financial_type' => 2, 'relationship_type' => '4_b_a', ); $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse'); $this->click("link=Add Membership Type"); $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); // New membership type $this->type('name', $memTypeParams['membership_type']); $this->type('member_of_contact', $membershipTitle); $this->click('member_of_contact'); $this->waitForElementPresent("css=div.ac_results-inner li"); $this->click("css=div.ac_results-inner li"); // Membership fees $this->type('minimum_fee', '100'); $this->select( 'financial_type_id', "value={$memTypeParams['financial_type']}" ); // Duration for which the membership will be active $this->type('duration_interval', 1); $this->select('duration_unit', "label=year"); // Membership period type $this->select('period_type', "label=rolling"); $this->click('relationship_type_id', "value={$memTypeParams['relationship_type']}"); // Clicking save $this->click('_qf_MembershipType_upload-bottom'); $this->waitForElementPresent('link=Add Membership Type'); $this->assertElementContainsText('crm-notification-container', "The membership type '$title' has been saved."); return $memTypeParams; } }