X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FWebTest%2FContact%2FSearchBuilderTest.php;h=b9f7c237fb4a8a8c8637d85e7ac92b4bf280efa0;hb=34b568c4f00791aa48c724b9c1e7bba247e80930;hp=d6abae116eb14bc8ca942ea603dc292c9ab01120;hpb=8f6ae60501d5d64ddbc6269648e71247dee0ce1b;p=civicrm-core.git diff --git a/tests/phpunit/WebTest/Contact/SearchBuilderTest.php b/tests/phpunit/WebTest/Contact/SearchBuilderTest.php index d6abae116e..b9f7c237fb 100644 --- a/tests/phpunit/WebTest/Contact/SearchBuilderTest.php +++ b/tests/phpunit/WebTest/Contact/SearchBuilderTest.php @@ -1,7 +1,7 @@ webtestLogin(); $groupName = $this->WebtestAddGroup(); @@ -50,14 +50,14 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { $this->waitForPageToLoad(); // We should get no results. But check the options are all still set - $this->waitForTextPresent('No matches found'); + $this->waitForTextPresent('No matches found for:'); foreach (array($groupName, 'United States', 'Male') as $i => $label) { $this->waitForElementPresent("//span[@id='crm_search_value_1_$i']/select/option[2]"); $this->assertSelectedLabel("//span[@id='crm_search_value_1_$i']/select", $label); } } - function testSearchBuilderRLIKE() { + public function testSearchBuilderRLIKE() { $this->webtestLogin(); // Adding contact @@ -75,7 +75,7 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { /** * @param null $firstName */ - function createDetailContact($firstName = NULL) { + public function createDetailContact($firstName = NULL) { if (!$firstName) { $firstName = substr(sha1(rand()), 0, 7); @@ -112,7 +112,7 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { $this->assertTrue($this->isTextPresent("$firstName adv$firstName")); } - function testSearchBuilderContacts() { + public function testSearchBuilderContacts() { $this->webtestLogin(); //Individual @@ -166,8 +166,8 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { $this->click("_qf_Contact_upload_view"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->_searchBuilder('Email', NULL, NULL, 'IS NULL'); - $this->type("xpath=//*[@id='Builder-rows-per-page-select']", '100'); - $this->waitForElementPresent("xpath=//*[@id='Builder-rows-per-page-select']"); + $this->type('CRM_Contact_Form_Search_Builder-rows-per-page-select', '100'); + $this->waitForElementPresent('CRM_Contact_Form_Search_Builder-rows-per-page-select'); $names = array( 1 => $firstName1, 2 => $firstName2, @@ -183,8 +183,8 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { } //searching contacts whose phone field is not empty $this->_searchBuilder('Phone', NULL, $firstName, 'IS NOT EMPTY'); - $this->type("xpath=//*[@id='Builder-rows-per-page-select']", '100'); - $this->waitForElementPresent("xpath=//*[@id='Builder-rows-per-page-select']"); + $this->type('CRM_Contact_Form_Search_Builder-rows-per-page-select', '100'); + $this->waitForElementPresent('CRM_Contact_Form_Search_Builder-rows-per-page-select'); $this->assertTrue($this->isTextPresent($firstName)); $firstName4 = "AB" . substr(sha1(rand()), 0, 7); @@ -219,7 +219,7 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { * @param string $op * @param null $count */ - function _searchBuilder($field, $fieldValue = NULL, $name = NULL, $op = '=', $count = NULL) { + public function _searchBuilder($field, $fieldValue = NULL, $name = NULL, $op = '=', $count = NULL) { // search builder using contacts(not using contactType) $this->openCiviPage("contact/search/builder", "reset=1"); $this->enterValues(1, 1, 'Contacts', $field, NULL, $op, "$fieldValue"); @@ -239,7 +239,7 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { /** * Enter form values in a Search Builder row */ - function enterValues($set, $row, $entity, $field, $loc, $op, $value = '') { + public function enterValues($set, $row, $entity, $field, $loc, $op, $value = '') { if ($set > 1 && $row == 1) { $this->click('addBlock'); } @@ -285,7 +285,7 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { * @param null $count * @param $field */ - function _advancedSearch($fieldValue = NULL, $name = NULL, $contactType = NULL, $count = NULL, $field) { + public function _advancedSearch($fieldValue = NULL, $name = NULL, $contactType = NULL, $count = NULL, $field) { //advanced search by selecting the contactType $this->openCiviPage("contact/search/advanced", "reset=1"); if (isset($contactType)) { @@ -307,7 +307,7 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { } else { $this->click("location"); - $this->waitForElementPresent("xpath=//div[@id='location']/table/tbody/tr[2]/td/table/tbody/tr[4]/td[2]/select"); + $this->waitForElementPresent("$field"); if ($contactType == 'Individual') { $this->type("$field", $fieldValue); } @@ -332,12 +332,12 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { /** * @param $contactType - * @param $name + * @param string $name * @param $email * @param null $streetName * @param null $postalCode */ - function _createContact($contactType, $name, $email, $streetName = NULL, $postalCode = NULL) { + public function _createContact($contactType, $name, $email, $streetName = NULL, $postalCode = NULL) { $this->openCiviPage('contact/add', array('reset' => 1, 'ct' => $contactType), '_qf_Contact_cancel'); if ($contactType == 'Individual') { @@ -375,12 +375,7 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { * Webtest for CRM-12148 * */ - function testSearchBuilderfinancialType() { - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. + public function testSearchBuilderfinancialType() { $this->webtestLogin(); // add financial type @@ -404,8 +399,7 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { $financialType = $financialTypeName2; } // create new contact using dialog - $firstName = substr(sha1(rand()), 0, 7); - $this->webtestNewDialogContact($firstName, 'Contributor', $firstName . '@example.com'); + $this->createDialogContact(); $this->select('financial_type_id', $financialType); $this->type('total_amount', 100 * $i); $this->clickLink('_qf_Contribution_upload_new', '_qf_Contribution_upload_new'); @@ -413,15 +407,14 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { $this->openCiviPage("contact/search/builder", "reset=1", "_qf_Builder_refresh"); $this->enterValues(1, 1, 'Contribution', 'Financial Type', NULL, '=', array($financialTypeName1)); - $this->click('_qf_Builder_refresh'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink('_qf_Builder_refresh'); $this->assertTrue($this->isTextPresent('3 Contacts'), 'Missing text: ' . '3 Contacts'); $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']"); $this->enterValues(1, 1, 'Contribution', 'Financial Type', NULL, '=', array($financialTypeName2)); - $this->click('_qf_Builder_refresh'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink('_qf_Builder_refresh'); + $this->assertTrue($this->isTextPresent('3 Contacts'), 'Missing text: ' . '3 Contacts'); $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']"); @@ -429,8 +422,8 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { $financialTypeName1, $financialTypeName2 )); - $this->click('_qf_Builder_refresh'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink('_qf_Builder_refresh'); + $this->assertTrue($this->isTextPresent('6 Contacts'), 'Missing text: ' . '6 Contacts'); } @@ -438,7 +431,7 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { * Webtest for CRM-12588 * */ - function testSearchBuilderMembershipType() { + public function testSearchBuilderMembershipType() { $this->webtestLogin(); // create first contact