Merge branch 'rcsheets-docstring-cleanup'
[civicrm-core.git] / tests / phpunit / WebTest / Campaign / CampaignDescriptionTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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_Campaign_CampaignDescriptionTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testCreateCampaign() {
35
36 $this->webtestLogin();
37
38 // Create new group
39 $title = substr(sha1(rand()), 0, 7);
40 $groupName = $this->WebtestAddGroup();
41
42 // Enable CiviCampaign module if necessary
43 $this->enableComponents(array('CiviCampaign'));
44
45 //Creating a new Campaign
46 $this->openCivipage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom');
47
48 $campaignTitle = "Campaign $title";
49 $this->type("title", $campaignTitle);
50
51 // select the campaign type
52 $this->select("campaign_type_id", "value=2");
53
54 // fill in the description
55 $campaignDescription = "This is a test campaign line 1 \n This is a test campaign line 2 \n This is a test campaign line 3";
56 $this->type("description", $campaignDescription);
57
58 // include groups for the campaign
59 $this->addSelection("includeGroups-f", "label=$groupName");
60 $this->click("//option[@value=4]");
61 $this->click("add");
62
63 // fill the end date for campaign
64 $this->webtestFillDate("end_date", "+1 year");
65
66 // select campaign status
67 $this->select("status_id", "value=2");
68
69 // click save
70 $this->click("_qf_Campaign_upload-bottom");
71 $this->waitForPageToLoad($this->getTimeoutMsec());
72
73 $this->waitForText('crm-notification-container', "Campaign $title");
74
75 //Opening Edit Page of the created Campaign
76 $this->waitForElementPresent("//div[@id='campaignList']/div[@class='dataTables_wrapper']/table/tbody//tr/td[text()='{$campaignTitle}']/../td[13]/span/a[text()='Edit']");
77 $this->clickLink("//div[@id='campaignList']/div[@class='dataTables_wrapper']/table/tbody//tr/td[text()='{$campaignTitle}']/../td[13]/span/a[text()='Edit']", "//textarea[@id='description']");
78 $fetchedVaue = $this->getValue('description');
79 $this->assertEquals($campaignDescription, $fetchedVaue);
80 }
81
82 function testAjaxCustomGroupLoad() {
83 $this->webtestLogin();
84
85 $this->enableComponents(array('CiviCampaign'));
86 $triggerElement = array('name' => 'campaign_type_id', 'type' => 'select');
87 $customSets = array(
88 array('entity' => 'Campaign', 'subEntity' => 'Referral Program', 'triggerElement' => $triggerElement),
89 array('entity' => 'Campaign', 'subEntity' => 'Constituent Engagement', 'triggerElement' => $triggerElement)
90 );
91
92 $pageUrl = array('url' => 'campaign/add', 'args' => 'reset=1');
93 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
94 }
95 }