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

[NFC] [TEST] cleanup, more use of return in ActivityTest #20633

Merged
merged 1 commit into from
Jun 18, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

[NFC] [TEST] cleanup, more use of return in ActivityTest

Before

old

After

new

Technical Details

I removed some old patterns, added 'return' and removed some redundancy & a test that never actually tested anything

This is one of our earliest test suites & there is a lot in there that is a bit repetitive of this class and others

Comments

@civibot
Copy link

civibot bot commented Jun 17, 2021

(Standard links)

@civibot civibot bot added the master label Jun 17, 2021
];

$this->callAPISuccess('Activity', 'create', $params);
$this->callAPISuccessGetSingle('Activity', ['id' => $activity['id']]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test never actually does what it says on the box (ie it doesn't check the source) - which SyntaxConformance does

$this->assertEquals("custom string", $result['values'][0]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);

$this->assertEquals($this->test_activity_type_value, $result['values'][0]['activity_type_id']);
$this->assertEquals('test activity type id', $result['values'][0]['subject']);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not clear why these two lines are removed?

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 pulled out some of the stuff that is repeated in test after test due to apparent copy & paste

'id' => $result['id'],
]);
$this->assertEquals("custom string", $result['values'][$result['id']]['custom_' . $ids['custom_field_id']]);
$this->assertEquals("2009-10-18 00:00:00", $result['values'][$result['id']]['activity_date_time']);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also this date one?

@@ -1218,28 +1206,27 @@ public function testActivityUpdateCheckCoreFields() {
$params['assignee_contact_id'] = [$contact3 => $contact3];
$params['target_contact_id'] = [$contact4 => $contact4];

$result = $this->callAPISuccess('activity', 'create', $params);

$this->assertEquals($activityId, $result['id'], ' in line ' . __LINE__);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also this one?

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 - in this case - the call to activity create was removed by accident

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually no - it was right to remove it - it's not doing an update - it's creating a random other activity that is not checked

@@ -1285,36 +1272,12 @@ public function testActivityUpdateWithStatus() {
'activity_name' => 'Test activity type',
];

$result = $this->callAPISuccess('activity', 'create', $params);
$this->assertEquals($result['id'], $activity['id']);
Copy link
Contributor

Choose a reason for hiding this comment

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

And this one although params are backwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in this case just the redundant assert is removed

@colemanw colemanw merged commit a81c61f into civicrm:master Jun 18, 2021
@colemanw colemanw deleted the ret3 branch June 18, 2021 00:23
@demeritcowboy
Copy link
Contributor

Ok thanks for the clarification.

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.

3 participants