Fixed some contribution pages
[civicrm-core.git] / tests / phpunit / WebTest / Member / EditMembershipTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 */
26
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Member_EditMembershipTest extends CiviSeleniumTestCase {
29 protected function setUp() {
30 parent::setUp();
31 }
32
33 function testEditMembershipActivityTypes() {
34 // Log in using webtestLogin() method
35 $this->webtestLogin();
36 // create contact
37 $firstName = substr(sha1(rand()), 0, 7);
38 $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
39 $contactName = "Memberson, {$firstName}";
40 $displayName = "{$firstName} Memberson";
41
42 // add membership type
43 $membershipTypes = $this->webtestAddMembershipType();
44
45 // now add membership
46 $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
47
48 // select contact
49 $this->webtestFillAutocomplete($contactName);
50
51 // fill in Membership Organization
52 $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
53
54 // select membership type
55 $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
56
57 // fill in Source
58 $this->type("source", "Membership StandaloneAddTest Webtest");
59
60 // Let Join Date and Start Date stay default
61 $this->click("_qf_Membership_upload");
62
63 //View Membership
64 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
65 $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']");
66 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
67 $expected = array(
68 'Membership Type' => $membershipTypes['membership_type'],
69 'Status' => 'New',
70 'Source' => 'Membership StandaloneAddTest Webtest',
71 );
72 $this->webtestVerifyTabularData($expected);
73
74 // now edit and update type and status
75 $this->click("crm-membership-edit-button-top");
76 $this->waitForElementPresent("_qf_Membership_upload-bottom");
77 $this->click('is_override');
78 $this->waitForElementPresent('status_id');
79 $this->select('status_id', 'label=Current');
80 $this->select('membership_type_id[0]', 'label=Default Organization');
81 $this->select('membership_type_id[1]', 'label=General');
82 $this->click('_qf_Membership_upload-bottom');
83
84 $this->waitForElementPresent("access");
85
86 // Use activity search to find the expected activities
87 $this->openCiviPage('activity/search', 'reset=1', "_qf_Search_refresh");
88
89 $this->type("sort_name", $contactName);
90 $this->click('activity_type_id[35]');
91 $this->click('activity_type_id[36]');
92 $this->click("_qf_Search_refresh");
93 $this->waitForPageToLoad($this->getTimeoutMsec());
94
95 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[2][text()='Change Membership Status']"));
96 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[3][text()='Status changed from New to Current']"));
97 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[5]/a[text()='{$contactName}']"));
98 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[3]/td[2][text()='Change Membership Type']"));
99 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[3]/td[3][text()='Type changed from {$membershipTypes['membership_type']} to General']"));
100 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[3]/td[5]/a[text()='{$contactName}']"));
101 }
102 }