| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.7 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
| 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 | |
| 29 | /** |
| 30 | * Class WebTest_Contact_TagAddTest |
| 31 | */ |
| 32 | class WebTest_Contact_TagAddTest extends CiviSeleniumTestCase { |
| 33 | |
| 34 | protected function setUp() { |
| 35 | parent::setUp(); |
| 36 | } |
| 37 | |
| 38 | public function testAddTag() { |
| 39 | $this->webtestLogin(); |
| 40 | |
| 41 | $this->openCiviPage("admin/tag", "action=add&reset=1", "_qf_Tag_next"); |
| 42 | |
| 43 | // take a tag name |
| 44 | $tagName = 'tag_' . substr(sha1(rand()), 0, 7); |
| 45 | |
| 46 | // fill tag name |
| 47 | $this->type("name", $tagName); |
| 48 | |
| 49 | // fill description |
| 50 | $this->type("description", "Adding new tag."); |
| 51 | |
| 52 | // select used for contact |
| 53 | $this->select("used_for", "value=civicrm_contact"); |
| 54 | |
| 55 | // check reserved |
| 56 | $this->click("is_reserved"); |
| 57 | |
| 58 | // Clicking save. |
| 59 | $this->click("_qf_Tag_next"); |
| 60 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 61 | |
| 62 | // Is status message correct? |
| 63 | $this->assertTrue($this->isTextPresent("The tag '$tagName' has been saved.")); |
| 64 | |
| 65 | // sort by ID desc |
| 66 | $this->click("xpath=//div[@id='cat']/div/table/thead/tr/th[2]/div[text()='ID']"); |
| 67 | $this->waitForElementPresent("css=table.display tbody tr td"); |
| 68 | |
| 69 | // verify text |
| 70 | $this->assertTrue($this->isTextPresent($tagName), 'Missing text: ' . $tagName); |
| 71 | $this->assertTrue($this->isTextPresent('Adding new tag.'), 'Missing text: ' . 'Adding new tag.'); |
| 72 | $this->assertTrue($this->isTextPresent('Contacts'), 'Missing text: ' . 'Contacts'); |
| 73 | $this->assertTrue($this->isTextPresent('Edit'), 'Missing text: ' . 'Edit'); |
| 74 | } |
| 75 | |
| 76 | public function testAddTagSet() { |
| 77 | $this->webtestLogin(); |
| 78 | |
| 79 | $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1"); |
| 80 | |
| 81 | // take a tagset name |
| 82 | $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7); |
| 83 | |
| 84 | // fill tagset name |
| 85 | $this->type("name", $tagSetName); |
| 86 | |
| 87 | // fill description |
| 88 | $this->type("description", "Adding new tag set."); |
| 89 | |
| 90 | // select used for contact |
| 91 | $this->select("used_for", "value=civicrm_contact"); |
| 92 | |
| 93 | // check reserved |
| 94 | $this->click("is_reserved"); |
| 95 | |
| 96 | // Clicking save. |
| 97 | $this->click("_qf_Tag_next"); |
| 98 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 99 | |
| 100 | // Is status message correct? |
| 101 | $this->assertTrue($this->isTextPresent("The tag '$tagSetName' has been saved.")); |
| 102 | |
| 103 | // sort by ID desc |
| 104 | $this->click("xpath=//table[@class='display dataTable no-footer']/thead/tr/th[2]/div[text()='ID']"); |
| 105 | $this->waitForElementPresent("css=table.display tbody tr td"); |
| 106 | |
| 107 | // verify text |
| 108 | $this->assertTrue($this->isTextPresent($tagSetName), 'Missing text: ' . $tagSetName); |
| 109 | $this->assertTrue($this->isTextPresent('Adding new tag set.'), 'Missing text: ' . 'Adding new tag set.'); |
| 110 | $this->assertTrue($this->isTextPresent('Contacts'), 'Missing text: ' . 'Contacts'); |
| 111 | $this->assertTrue($this->isTextPresent('Edit'), 'Missing text: ' . 'Edit'); |
| 112 | } |
| 113 | |
| 114 | } |