Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test improvements #15720

Merged
merged 2 commits into from
Nov 4, 2019
Merged

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Sub-commit of #15719 as relates to test cleanup & improvements

Before

Tests customQueryTest

After

tests the search via BAO_Contact_Query

Technical Details

Convert customQueryTest to test the BAO_Contact_Query

While I understand the theory of unit tests is to test low level chunks of code that relates in many
ways to WELL-DESIGNED chunks. In the case of the query object it is more important to
ensure the results experienced by the user are correct - this converts the existing test
to a more end-to-end test on the CRM_Contact_BAO_Query object acting correctly.

Comments

@seamuslee001 sub-commit

While I understand the theory of unit tests is to test low level chunks of code that relates in many
ways to WELL-DESIGNED chunks. In the case of the query object it is more important to
ensure the results experienced by the user are correct - this converts the existing test
to a more end-to-end test on the CRM_Contact_BAO_Query object acting correctly.
@civibot
Copy link

civibot bot commented Nov 4, 2019

(Standard links)

@civibot civibot bot added the master label Nov 4, 2019
@seamuslee001
Copy link
Contributor

So i did a grep for CRM_Core_BAO_CustomQuery

api/v3/utils.php:  if (!array_key_exists($entity, CRM_Core_BAO_CustomQuery::$extendsMap)) {
api/v3/utils.php:    if (isset($params['custom']) && empty(CRM_Core_BAO_CustomQuery::$extendsMap[$entity])) {
CRM/Core/BAO/CustomField.php:          $fields[$dao->id]['extends_table'] = array_key_exists($dao->extends, CRM_Core_BAO_CustomQuery::$extendsMap) ? CRM_Core_BAO_CustomQuery::$extendsMap[$dao->extends] : '';
CRM/Core/BAO/CustomQuery.php:class CRM_Core_BAO_CustomQuery {
CRM/Contact/BAO/Query.php:      $this->_customQuery = new CRM_Core_BAO_CustomQuery($this->_cfIDs, TRUE, $this->_locationSpecificCustomFields);
CRM/Contact/BAO/Query.php:      $customQuery = new CRM_Core_BAO_CustomQuery($addressCustomFieldIds);
CRM/Contact/BAO/Query.php:        $this->_customQuery = new CRM_Core_BAO_CustomQuery($this->_cfIDs, TRUE, $this->_locationSpecificCustomFields);
CRM/Report/Form.php:    $mapper = CRM_Core_BAO_CustomQuery::$extendsMap;
tests/phpunit/api/v3/SyntaxConformanceTest.php:    $entities = CRM_Core_BAO_CustomQuery::$extendsMap;
tests/phpunit/api/v3/SyntaxConformanceTest.php:    if (!isset(CRM_Core_BAO_CustomQuery::$extendsMap[$entityName])) {
tests/phpunit/CRM/Core/BAO/CustomQueryTest.php:class CRM_Core_BAO_CustomQueryTest extends CiviUnitTestCase {
tests/phpunit/CRM/Core/BAO/CustomQueryTest.php:    $queryObj = new CRM_Core_BAO_CustomQuery($params);
tests/phpunit/CRM/Core/BAO/CustomQueryTest.php:    $queryObj = new CRM_Core_BAO_CustomQuery($params);
tests/phpunit/CRM/Core/BAO/CustomQueryTest.php:      $queryObj = new CRM_Core_BAO_CustomQuery($params);
tests/phpunit/CRM/Core/BAO/CustomQueryTest.php:      $queryObj = new CRM_Core_BAO_CustomQuery($params);
tests/phpunit/CRM/Core/BAO/CustomQueryTest.php:      $queryObj = new CRM_Core_BAO_CustomQuery($params);
tests/phpunit/CRM/Core/BAO/CustomQueryTest.php:    $queryObj = new CRM_Core_BAO_CustomQuery($params);

So the only time we are going to be passing in any parameters to that object outside of the current test set up is when we are going via the CRM_Contact_BAO_Query class so it makes sense to change that in the test set up because that is testing more actual code paths as this is only test only adding merge on pass if Jenkins is ok with it

@eileenmcnaughton eileenmcnaughton merged commit 9f4a97a into civicrm:master Nov 4, 2019
@eileenmcnaughton eileenmcnaughton deleted the test_clean branch November 4, 2019 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants