From 51c24f5e8f45d1aba848d9b2d0e4fef2ab9847ad Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 26 May 2021 08:23:08 +1200 Subject: [PATCH] See how many tests fail with this check --- tests/phpunit/CRM/Activity/BAO/ActivityTest.php | 8 ++++++-- tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php | 4 +++- tests/phpunit/CiviTest/CiviUnitTestCase.php | 7 +++++-- tests/phpunit/api/v3/SyntaxConformanceTest.php | 10 ++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php index dc541e69cbc4..253f84dfdaba 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php @@ -172,13 +172,17 @@ public function testRetrieve() { } /** - * Test Assigning a target contact but then the logged in user cannot see the contact + * Test Assigning a target contact but then the logged in user cannot see the + * contact + * + * @throws \CiviCRM_API3_Exception + * @throws \CRM_Core_Exception */ public function testTargetContactNotavaliable() { $contactId = $this->individualCreate(); $params = [ 'first_name' => 'liz', - 'last_name' => 'hurleey', + 'last_name' => 'Hurley', ]; $targetContactId = $this->individualCreate($params); diff --git a/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php b/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php index e372ff01245e..80954c6d7e96 100644 --- a/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php @@ -148,10 +148,12 @@ public function testIPNPaymentRecurSuccess(): void { /** * Test IPN response updates contribution_recur & contribution for first & second contribution. * + * @throws \API_Exception * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception + * @throws \Civi\API\Exception\UnauthorizedException */ - public function testIPNPaymentMembershipRecurSuccess() { + public function testIPNPaymentMembershipRecurSuccess(): void { $durationUnit = 'year'; $this->setupMembershipRecurringPaymentProcessorTransaction(['duration_unit' => $durationUnit, 'frequency_unit' => $durationUnit]); $this->callAPISuccessGetSingle('membership_payment', []); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index e2ca637ae026..8f18e1f4b212 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -26,6 +26,7 @@ * . */ +use Civi\Api4\Contribution; use Civi\Api4\OptionGroup; use Civi\Api4\RelationshipType; use Civi\Payment\System; @@ -152,7 +153,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @var bool */ - protected $isValidateFinancialsOnPostAssert = FALSE; + protected $isValidateFinancialsOnPostAssert = TRUE; /** * Should location types be checked to ensure primary addresses are correctly assigned after each test. @@ -3630,10 +3631,12 @@ protected function validateAllPayments() { /** * Validate all created contributions. * + * @throws \API_Exception * @throws \CRM_Core_Exception + * @throws \Civi\API\Exception\UnauthorizedException */ protected function validateAllContributions(): void { - $contributions = $this->callAPISuccess('Contribution', 'get', ['return' => ['tax_amount', 'total_amount']])['values']; + $contributions = Contribution::get(FALSE)->setSelect(['total_amount', 'tax_amount'])->execute(); foreach ($contributions as $contribution) { $lineItems = $this->callAPISuccess('LineItem', 'get', ['contribution_id' => $contribution['id']])['values']; $total = 0; diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index 21a70740dd9b..5b197e69fa3b 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -24,6 +24,16 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { protected $_apiversion = 3; + /** + * Do not check financial entities in this test class. + * + * The class uses lots of crud to do things by-passing + * BAO logic & entities are often not valid as a result. + * + * @var bool + */ + protected $isValidateFinancialsOnPostAssert = FALSE; + /** * @var array * e.g. $this->deletes['CRM_Contact_DAO_Contact'][] = $contactID;