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

Replace CRM_Core_Exception aliases - tests dir #24535

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 5 additions & 25 deletions tests/phpunit/CRM/Activity/BAO/ActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase {
/**
* Set up for test.
*
* @throws \CiviCRM_API3_Exception
* @throws \CRM_Core_Exception
*/
public function setUp():void {
parent::setUp();
Expand All @@ -30,7 +30,7 @@ public function setUp():void {
/**
* Clean up after tests.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function tearDown(): void {
Expand Down Expand Up @@ -252,7 +252,6 @@ public function testActivitySelectorNoTargets() {
* deleteActivity($params) method deletes activity for given params.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testDeleteActivity() {
$contactId = $this->individualCreate();
Expand Down Expand Up @@ -362,7 +361,6 @@ public function testDeleteActivityTarget() {
* for given activity id.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testDeleteActivityAssignment(): void {
$contactId = $this->individualCreate();
Expand Down Expand Up @@ -1077,7 +1075,6 @@ public function testByActivityDateAndStatus(): void {
* @param $expected
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testActivityRelativeDateFilter($params, $expected): void {
$thisYear = date('Y');
Expand Down Expand Up @@ -1138,7 +1135,6 @@ public function getActivityDateData() {
* CRM-20308: Test from email address when a 'copy of Activity' event occur
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testEmailAddressOfActivityCopy() {
// Case 1: assert the 'From' Email Address of source Actvity Contact ID
Expand Down Expand Up @@ -1218,9 +1214,7 @@ protected function setUpForActivityDashboardTests() {
}

/**
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testSendEmailBasic(): void {
$contactId = $this->getContactID();
Expand Down Expand Up @@ -1312,9 +1306,7 @@ protected function getContactID(): int {
* This is different from SentEmailBasic to try to help prevent code that
* assumes an email always has tokens in it.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function testSendEmailBasicWithoutAnyTokens(): void {
Expand Down Expand Up @@ -1358,9 +1350,7 @@ public function testSendEmailBasicWithoutAnyTokens(): void {
}

/**
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testSendEmailWithCampaign(): void {
// Create a contact and contactDetails array.
Expand Down Expand Up @@ -1415,9 +1405,7 @@ public function testSendSMSWithoutPermission(): void {
/**
* Test that a sms does not send when a phone number is not available.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function testSendSmsNoPhoneNumber(): void {
Expand All @@ -1426,9 +1414,7 @@ public function testSendSmsNoPhoneNumber(): void {
}

/**
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function testSendSmsLandLinePhoneNumber(): void {
Expand All @@ -1439,9 +1425,7 @@ public function testSendSmsLandLinePhoneNumber(): void {
/**
* Test successful SMS send.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function testSendSmsMobilePhoneNumber(): void {
Expand Down Expand Up @@ -1481,9 +1465,7 @@ public function testSendSMSMobileInToProviderParamWithDoNotSMS(): void {
* @param array $additionalContactParams additional contact creation params
*
* @return array
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function createSendSmsTest(bool $expectSuccess = TRUE, int $phoneType = 0, bool $passPhoneTypeInContactDetails = FALSE, array $additionalContactParams = []): array {
Expand Down Expand Up @@ -1699,7 +1681,6 @@ public function testSendEmailWillReplaceTokensUniquelyForEachContact(): void {
* 3 recipients and an attachment.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testSendEmailWillReplaceTokensUniquelyForEachContact3(): void {
$contactId1 = $this->individualCreate(['last_name' => 'Red']);
Expand Down Expand Up @@ -1933,7 +1914,7 @@ protected function setShowCaseActivitiesInCore(bool $val) {
* @param array $do_first
* @param array $do_second
*
* @throws \CiviCRM_API3_Exception
* @throws \CRM_Core_Exception
*/
public function testTargetAssigneeVariations(array $do_first, array $do_second) {
// Originally wanted to put this in setUp() but it broke other tests.
Expand Down Expand Up @@ -2002,7 +1983,6 @@ public function testTargetAssigneeVariations(array $do_first, array $do_second)
* @param array $do_second
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testTargetAssigneeVariationsWithScalars(array $do_first, array $do_second) {
// Originally wanted to put this in setUp() but it broke other tests.
Expand Down Expand Up @@ -2596,7 +2576,7 @@ public function targetAndAssigneeProvider():array {
/**
* @param $activityId
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
protected function validateActivity($activityId): void {
Expand All @@ -2620,7 +2600,7 @@ protected function validateActivity($activityId): void {
* @param $contactDetails
*
* @return array
* @throws \CiviCRM_API3_Exception
* @throws \CRM_Core_Exception
*/
protected function createMobilePhone(int $contactId, bool $passPhoneTypeInContactDetails, $contactDetails): array {
$phone = civicrm_api3('Phone', 'create', [
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/CRM/Activity/Form/ActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ public function testActivityTypeAssignment() {
* way to do it.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testInboundEmailDisplaysWithLineBreaks(): void {
// Change label
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/CRM/Activity/Form/ActivityViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public function tearDown(): void {
* after preProcess().
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testActivityViewPreProcess(): void {
// create activity
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/CRM/Activity/Form/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function tearDown(): void {
* Test submitted the search form.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testSearch(): void {

Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/CRM/Activity/Form/Task/PDFLetterCommonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public function setUp(): void {
* Test create a document with basic tokens.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testCreateDocumentBasicTokens(): void {
CRM_Core_BAO_ConfigSetting::enableComponent('CiviCase');
Expand Down Expand Up @@ -121,7 +120,6 @@ public function testCreateDocumentCustomFieldTokens() {
* Unknown tokens are removed at the very end.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testCreateDocumentUnknownTokens(): void {
$activity = $this->activityCreate();
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/CRM/Activity/Selector/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class CRM_Activity_Selector_SearchTest extends CiviUnitTestCase {
* Test activity search applies a permission based component filter.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testActivitySearchComponentPermission() {
$this->activityCreate(['activity_type_id' => 'Contribution']);
Expand Down
7 changes: 2 additions & 5 deletions tests/phpunit/CRM/Batch/Form/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase {

/**
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function setUp(): void {
parent::setUp();
Expand Down Expand Up @@ -176,7 +175,6 @@ public function tearDown(): void {
*
* @param string $thousandSeparator
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*
Expand Down Expand Up @@ -256,7 +254,6 @@ public function testProcessContribution($thousandSeparator): void {
/**
* CRM-18000 - Test start_date, end_date after renewal
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
Expand Down Expand Up @@ -307,7 +304,7 @@ public function testMembershipRenewalDates(): void {
* Data provider for test process membership.
*
* @return array
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function getMembershipData(): array {
Expand Down Expand Up @@ -424,7 +421,7 @@ public function getContributionData($thousandSeparator = '.') {
* Create a campaign.
*
* @return mixed
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
private function createCampaign(): int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testConstructorEquivalence() {
/**
* Basic canary test fetching a specific example.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function testExampleGet() {
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CRM/Contact/BAO/ContactType/ContactTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function setUp(): void {
/**
* Cleanup contact types.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function tearDown(): void {
Expand Down Expand Up @@ -103,7 +103,7 @@ public function testGetMethodsInvalid() {
/**
* Test function for getting contact types.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
*/
public function testContactTypeInfo() {
$blahType = ['is_active' => 0, 'name' => 'blah', 'label' => 'blah blah', 'parent_id:name' => 'Individual', 'icon' => 'fa-random'];
Expand Down
8 changes: 2 additions & 6 deletions tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ class CRM_Contact_BAO_GroupContactCacheTest extends CiviUnitTestCase {
/**
* Manually add and remove contacts from a smart group.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testManualAddRemove(): void {
[$group, $living, $deceased] = $this->setupSmartGroup();
Expand Down Expand Up @@ -63,9 +61,7 @@ public function testManualAddRemove(): void {
* Allow removing contact from a parent group even if contact is in a child
* group. (CRM-8858).
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testRemoveFromParentSmartGroup(): void {
// Create $c1, $c2, $c3
Expand Down Expand Up @@ -186,7 +182,7 @@ public function testOpportunisticRefreshChangeIfCacheDateFieldStale(): void {
* Test the opportunistic refresh cache function does refresh expired entries
* if mode is deterministic.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
*/
public function testOpportunisticRefreshNoChangeWithDeterministicSetting(): void {
[, , $deceased] = $this->setupSmartGroup();
Expand Down Expand Up @@ -291,7 +287,7 @@ protected function setupSmartGroup(): array {
);
return [$group, $living, $deceased];
}
catch (CRM_Core_Exception | API_Exception | CiviCRM_API3_Exception $e) {
catch (CRM_Core_Exception | CRM_Core_Exception | CRM_Core_Exception $e) {
$this->fail('failed test setup' . $e->getMessage());
}
// unreachable but it cheers up IDE analysis.
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Contact/BAO/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function testNestedGroup(): void {
/**
* Test that parents as criteria don't cause loops.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
*/
public function testGroupWithParentInCriteria(): void {
$parentGroupID = Group::create()->setValues([
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/CRM/Contact/Form/Search/Custom/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class CRM_Contact_Form_Search_Custom_GroupTest extends CiviUnitTestCase {

/**
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function tearDown(): void {
$this->quickCleanup([
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/CRM/Contact/Form/Task/EmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ public function testDomainEmailGeneration(): void {
/**
* Test email uses signature.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function testPostProcessWithSignature(): void {
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/CRM/Contact/Form/Task/SMSCommonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ protected function setUp(): void {
/**
* Test to ensure SMS Activity QuickForm displays the right phone numbers.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function testQuickFormMobileNumbersDisplay() {
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/CRM/Contact/Import/Form/DataSourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function testBuildForm(): void {
* This test mimics a scenario where the form is submitted more than once
* and the user_job is updated to reflect the new data source.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
*/
public function testDataSources(): void {
Expand Down Expand Up @@ -122,7 +121,6 @@ public function testDataSources(): void {
* @param array $sqlFormValues
*
* @return CRM_Contact_Import_Form_DataSource
* @throws \API_Exception
* @throws \CRM_Core_Exception
*/
private function submitDataSourceForm(array $sqlFormValues): CRM_Contact_Import_Form_DataSource {
Expand Down
Loading