Merge pull request #140 from dlobo/CRM-12111
[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 $this->open($this->sboxPath);
35 // Log in using webtestLogin() method
36 $this->webtestLogin();
37 // create contact
38 $firstName = substr(sha1(rand()), 0, 7);
39 $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
40 $contactName = "Memberson, {$firstName}";
41 $displayName = "{$firstName} Memberson";
42
43 // add membership type
44 $membershipTypes = $this->webtestAddMembershipType();
45
46 // now add membership
47 $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
48
49 // select contact
50 $this->webtestFillAutocomplete($contactName);
51
52 // fill in Membership Organization
53 $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
54
55 // select membership type
56 $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
57
58 // fill in Source
59 $this->type("source", "Membership StandaloneAddTest Webtest");
60
61 // Let Join Date and Start Date stay default
62 $this->click("_qf_Membership_upload");
63
64 //View Membership
65 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
66 $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']");
67 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
68 $expected = array(
69 'Membership Type' => $membershipTypes['membership_type'],
70 'Status' => 'New',
71 'Source' => 'Membership StandaloneAddTest Webtest',
72 );
73 $this->webtestVerifyTabularData($expected);
74
75 // now edit and update type and status
76 $this->click("crm-membership-edit-button-top");
77 $this->waitForElementPresent("_qf_Membership_upload-bottom");
78 $this->click('is_override');
79 $this->waitForElementPresent('status_id');
80 $this->select('status_id', 'label=Current');
81 $this->select('membership_type_id[0]', 'label=Default Organization');
82 $this->select('membership_type_id[1]', 'label=General');
83 $this->click('_qf_Membership_upload-bottom');
84
85 $this->waitForElementPresent("access");
86
87 // Use activity search to find the expected activities
88 $this->openCiviPage('activity/search', 'reset=1', "_qf_Search_refresh");
89
90 $this->type("sort_name", $contactName);
91 $this->click('activity_type_id[35]');
92 $this->click('activity_type_id[36]');
93 $this->click("_qf_Search_refresh");
94 $this->waitForPageToLoad($this->getTimeoutMsec());
95
96 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[2][text()='Change Membership Status']"));
97 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[3][text()='Status changed from New to Current']"));
98 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[5]/a[text()='{$contactName}']"));
99 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[3]/td[2][text()='Change Membership Type']"));
100 $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']"));
101 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[3]/td[5]/a[text()='{$contactName}']"));
102 }
103 }