Merge pull request #197 from pratik-joshi/CRM-12130
[civicrm-core.git] / tests / phpunit / WebTest / Campaign / CampaignDescriptionTest.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
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Campaign_CampaignDescriptionTest extends CiviSeleniumTestCase {
30
31 protected $captureScreenshotOnFailure = TRUE;
32 protected $screenshotPath = '/var/www/api.dev.civicrm.org/public/sc';
33 protected $screenshotUrl = 'http://api.dev.civicrm.org/sc/';
34
35 protected function setUp() {
36 parent::setUp();
37 }
38
39 function testCreateCampaign() {
40
41
42 $this->webtestLogin();
43
44 // Create new group
45 $title = substr(sha1(rand()), 0, 7);
46 $groupName = $this->WebtestAddGroup();
47
48 // Enable CiviCampaign module if necessary
49 $this->enableComponents(array('CiviCampaign'));
50
51 //Creating a new Campaign
52 $this->openCivipage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom');
53
54 $campaignTitle = "Campaign $title";
55 $this->type("title", $campaignTitle);
56
57 // select the campaign type
58 $this->select("campaign_type_id", "value=2");
59
60 // fill in the description
61 $campaignDescription = "This is a test campaign line 1 \n This is a test campaign line 2 \n This is a test campaign line 3";
62 $this->type("description", $campaignDescription);
63
64 // include groups for the campaign
65 $this->addSelection("includeGroups-f", "label=$groupName");
66 $this->click("//option[@value=4]");
67 $this->click("add");
68
69 // fill the end date for campaign
70 $this->webtestFillDate("end_date", "+1 year");
71
72 // select campaign status
73 $this->select("status_id", "value=2");
74
75 // click save
76 $this->click("_qf_Campaign_upload-bottom");
77 $this->waitForPageToLoad($this->getTimeoutMsec());
78
79 $this->assertElementContainsText('crm-notification-container', "Campaign Campaign $title has been saved.",
80 "Status message didn't show up after saving campaign!"
81 );
82
83 //Opening Edit Page of the created Campaign
84 $this->waitForElementPresent("//div[@id='campaignList']/div[@class='dataTables_wrapper']/table/tbody//tr/td[text()='{$campaignTitle}']/../td[13]/span/a[text()='Edit']");
85 $this->click("//div[@id='campaignList']/div[@class='dataTables_wrapper']/table/tbody//tr/td[text()='{$campaignTitle}']/../td[13]/span/a[text()='Edit']");
86 $this->waitForPageToLoad($this->getTimeoutMsec());
87
88 //Checking for Proper description present
89 $this->waitForElementPresent("//textarea[@id='description']");
90 $fetchedVaue = $this->getValue('description');
91 $this->assertEquals($campaignDescription, $fetchedVaue);
92 }
93 }
94
95