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

Deduplicate setting of mailSent message #12694

Merged
merged 1 commit into from
Sep 2, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Minor refactor of code around setting submit status message, adds a test

Before

Code less logically grouped

After

Code more logically grouped.

Technical Details

This is a small refactor aimed at bringing code that is logically related together. There is a loop that iterates through

   foreach ($this->_memTypeSelected as $memType) {

and creates memberships. It is an obvious candidate for extraction but it also turns out that loop builds up the $createdMemberships array for the sole purpose of setting the message for the form user. It seems fairly clear to me that every time we see

        $createdMemberships[$memType] = $membership;

What we should really see is some variant of

$this->addStatusMessage(

Comments

#12693 contains the a superset of this change but this is intended to be legible amount

@civibot
Copy link

civibot bot commented Aug 20, 2018

(Standard links)

@@ -545,6 +546,14 @@ public function testSubmit($thousandSeparator) {
'Receipt text',
));
$this->mut->stop();
$this->assertEquals([
[
'text' => 'AnnualFixed membership for Mr. Anthony Anderson II has been added. The new membership End Date is December 31st, ' . date('Y') . '. A membership confirmation and receipt has been sent to anthony_anderson@civicrm.org.',
Copy link
Member

Choose a reason for hiding this comment

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

Is this one of those tests that will fail once a year on Dec 31?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can cope with the once a year ones - it's the once a month ones that bother me

Copy link
Member

Choose a reason for hiding this comment

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

What's the expected behavior? That an annual membership beginning Dec 31 expires this year or next? Why not set the start date and end date in the test and avoid these quirks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK - I've hard-coded the month to Feb which should keep it reliable I think - never 31 Dec

Copy link
Member

@colemanw colemanw left a comment

Choose a reason for hiding this comment

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

I've tested this and can confirm the membership messages still display as expected after the change. However I have a question about the test. See code comment.

@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton eileenmcnaughton merged commit 1108490 into civicrm:master Sep 2, 2018
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.

3 participants