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

CRM-21227 Fix test following merge of PR #10435 #11032

Merged
merged 1 commit into from
Sep 28, 2017

Conversation

seamuslee001
Copy link
Contributor

@seamuslee001 seamuslee001 commented Sep 27, 2017

Overview

Test has started to fail i believe due to PR #10435 see https://test.civicrm.org/job/CiviCRM-Core-PR/17314/testReport/(root)/CRM_Core_Page_HookTest/testFormsCallBuildFormOnce/ as an example

Before

Test fails

After

Test passes

Technical Details

The PR made some changes to how $defaults is populated from requests which has made some cascading effects

ping @eileenmcnaughton @monishdeb


@@ -117,7 +117,7 @@ public function setDefaultValues() {
$defaults['contact_types_a'] .= '__' . $defaults['contact_sub_type_a'];
}

$defaults['contact_types_b'] = $defaults['contact_type_b'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just changing to be the same as L115 but for contact_type_b

@@ -154,7 +154,7 @@ public function buildQuickForm() {
public function setDefaultValues() {
if (isset($this->_id)) {
$defaults = array_merge($this->_values,
CRM_Badge_BAO_Layout::getDecodedData($this->_values['data']));
CRM_Badge_BAO_Layout::getDecodedData(CRM_Utils_Array::value('data', $this->_values, '[]')));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks for data in $this->_values and passes an empty json_encoded array as the default value (getDecodedData does a jsonDecode

@@ -60,8 +60,8 @@ public function preProcess() {
$this->_rgid = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
$contactTypes = civicrm_api3('Contact', 'getOptions', array('field' => "contact_type"));
$contactType = CRM_Utils_Request::retrieve('contact_type', 'String', $this, FALSE, 0);
if (in_array($contactType, $contactTypes['values'])) {
$this->_contactType = $contactTypes['values'][$contactType];
if (CRM_Utils_Array::value($contactType, $contactTypes['values'])) {
Copy link
Contributor

@mickadoo mickadoo Sep 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change here? It changes the logic from asking:
"is $contactType in the array $values"
to
"is $values[$contactType] truthy?"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mickadoo Michael if you look at how old L64 was crafted it was using it as a Key whereas in_array checks on the value so somewhere we stuffed up. I'm not sure if should be on the key or not

Copy link
Contributor

@eileenmcnaughton eileenmcnaughton Sep 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the effect here is that IF contactType is passed in via the URL we accept it if valid. If not we calculate from the rule.

Perhaps keep this & change lower down

Remove

    elseif (!empty($contactType)) {
      throw new CRM_Core_Exception('Contact Type is Not valid');
    }

& replace with

    if (!$this->_rgid && !$this->_contactType) {
      CRM_Core_Session::setStatus('Contact Type could not be determined, assuming Individual');
     $this->_contactType = 'Individual';
}

Or we could throw an exception - but I can't see why we don't just use a default

@@ -83,8 +83,7 @@ public function preProcess() {
public function buildQuickForm() {
parent::buildQuickForm();
$this->setPageTitle(ts('Financial Batch'));

if (isset($this->_id)) {
if (!empty($this->_id)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine - although I think it would be better to define the property on the class

@JoeMurray
Copy link
Contributor

Jenkins, please test this

@JoeMurray
Copy link
Contributor

Jenkins, test this please

@eileenmcnaughton
Copy link
Contributor

I'm going to merge this because it does fix some tests & I don't think the question about contactTypes is a blocker

@eileenmcnaughton eileenmcnaughton merged commit 4bd2c4e into civicrm:master Sep 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants