From f0be539ab293fe193f7160994a4e4c7b25334f5e Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 12 Jan 2015 20:44:34 +1300 Subject: [PATCH] a few random comment fixes in the test suite --- .../Subscriber/DynamicFKAuthorizationTest.php | 1 + .../phpunit/CiviTest/CiviSeleniumTestCase.php | 10 +++++++ tests/phpunit/CiviTest/CiviUnitTestCase.php | 20 +++++++++----- tests/phpunit/EnvTests.php | 3 +++ tests/phpunit/api/v3/ActionScheduleTest.php | 6 +++-- tests/phpunit/api/v3/ActivityContactTest.php | 9 ++++--- tests/phpunit/api/v3/AttachmentTest.php | 26 +++++++++++++++++++ tests/phpunit/api/v3/MailingABTest.php | 8 ++++++ .../api/v3/TaxContributionPageTest.php | 6 +++-- 9 files changed, 76 insertions(+), 13 deletions(-) diff --git a/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php b/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php index 124d08f0bb..8d82c8e482 100644 --- a/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php +++ b/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php @@ -188,6 +188,7 @@ class DynamicFKAuthorizationTest extends \CiviUnitTestCase { * @param $entity * @param $action * @param array $params + * @param $expectedError * @dataProvider badDataProvider */ public function testBad($entity, $action, $params, $expectedError) { diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index fbf336cf04..8f80e4aa04 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -1696,6 +1696,16 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { /** * Add new Financial Account + * @param $financialAccountTitle + * @param bool $financialAccountDescription + * @param bool $accountingCode + * @param bool $firstName + * @param bool $financialAccountType + * @param bool $taxDeductible + * @param bool $isActive + * @param bool $isTax + * @param bool $taxRate + * @param bool $isDefault */ function _testAddFinancialAccount( $financialAccountTitle, diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index ba2f62e639..696f38329a 100755 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -194,6 +194,13 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { } } + /** + * Override to run the test and assert its state. + * @return mixed + * @throws \Exception + * @throws \PHPUnit_Framework_IncompleteTest + * @throws \PHPUnit_Framework_SkippedTest + */ protected function runTest() { try { return parent::runTest(); @@ -2002,23 +2009,23 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { * * @param array $params * Parameters. + * @return array */ public function activityTypeCreate($params) { - $result = $this->callAPISuccess('ActivityType', 'create', $params); - return $result; - } + return $this->callAPISuccess('ActivityType', 'create', $params); + } /** * Delete activity type * * @param int $activityTypeId * Id of the activity type. + * @return array */ public function activityTypeDelete($activityTypeId) { $params['activity_type_id'] = $activityTypeId; - $result = $this->callAPISuccess('ActivityType', 'delete', $params); - return $result; - } + return $this->callAPISuccess('ActivityType', 'delete', $params); + } /** * Create custom group @@ -2480,6 +2487,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { return TRUE; } } + return FALSE; } /** diff --git a/tests/phpunit/EnvTests.php b/tests/phpunit/EnvTests.php index 45b53bd627..9894dd7288 100644 --- a/tests/phpunit/EnvTests.php +++ b/tests/phpunit/EnvTests.php @@ -11,6 +11,9 @@ * (eg "MyFirstTest::testFoo"). */ class EnvTests extends \PHPUnit_Framework_TestSuite { + /** + * @return \EnvTests + */ public static function suite() { require_once 'CRM/Core/ClassLoader.php'; CRM_Core_ClassLoader::singleton()->register(); diff --git a/tests/phpunit/api/v3/ActionScheduleTest.php b/tests/phpunit/api/v3/ActionScheduleTest.php index 2cd3fa224b..e403dd2deb 100644 --- a/tests/phpunit/api/v3/ActionScheduleTest.php +++ b/tests/phpunit/api/v3/ActionScheduleTest.php @@ -85,14 +85,16 @@ class api_v3_ActionScheduleTest extends CiviUnitTestCase { 'subject' => 'this case should fail', 'scheduled_date_time' => date('Ymd'), ); - $result = $this->callAPIFailure('activity', 'create', $params); + $this->callAPIFailure('activity', 'create', $params); } + /** + * + */ public function testActionScheduleWithScheduledDatesCreate() { $oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule'); $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); - $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $scheduledStatus = CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name'); $mappingId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionMapping', 'activity_type', 'id', 'entity_value'); $activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', "Meeting", 'name'); diff --git a/tests/phpunit/api/v3/ActivityContactTest.php b/tests/phpunit/api/v3/ActivityContactTest.php index 8de021d7f1..8e77611cc5 100644 --- a/tests/phpunit/api/v3/ActivityContactTest.php +++ b/tests/phpunit/api/v3/ActivityContactTest.php @@ -79,12 +79,15 @@ class api_v3_ActivityContactTest extends CiviUnitTestCase { $this->assertEquals(0, $get['count'], 'ActivityContact not successfully deleted'); } + /** + * + */ public function testGetActivitiesByContact() { - $result = $this->callAPISuccess('ActivityContact', 'Get', array('contact_id' => $this->_contactID)); + $this->callAPISuccess('ActivityContact', 'Get', array('contact_id' => $this->_contactID)); } - public function testGetPartitipantsByActivity() { - $result = $this->callAPISuccess('ActivityContact', 'Get', array('activity_id' => $this->_activityID)); + public function testGetParticipantsByActivity() { + $this->callAPISuccess('ActivityContact', 'Get', array('activity_id' => $this->_activityID)); } /** diff --git a/tests/phpunit/api/v3/AttachmentTest.php b/tests/phpunit/api/v3/AttachmentTest.php index c80f89d0cf..d0e852c33d 100644 --- a/tests/phpunit/api/v3/AttachmentTest.php +++ b/tests/phpunit/api/v3/AttachmentTest.php @@ -40,6 +40,9 @@ require_once 'CiviTest/CiviUnitTestCase.php'; class api_v3_AttachmentTest extends CiviUnitTestCase { protected static $filePrefix = NULL; + /** + * @return string + */ public static function getFilePrefix() { if (!self::$filePrefix) { self::$filePrefix = "test_" . CRM_Utils_String::createRandom(5, CRM_Utils_String::ALPHANUMERIC) . '_'; @@ -62,6 +65,9 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { \Civi\Core\Container::singleton(TRUE); } + /** + * @return array + */ public function okCreateProvider() { $cases = array(); // array($entityClass, $createParams, $expectedContent) @@ -103,6 +109,9 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { return $cases; } + /** + * @return array + */ public function badCreateProvider() { $cases = array(); // array($entityClass, $createParams, $expectedError) @@ -163,6 +172,9 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { return $cases; } + /** + * @return array + */ public function badUpdateProvider() { $cases = array(); // array($entityClass, $createParams, $updateParams, $expectedError) @@ -192,6 +204,9 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { return $cases; } + /** + * @return array + */ public function okGetProvider() { $cases = array(); // array($getParams, $expectedNames) @@ -236,6 +251,9 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { return $cases; } + /** + * @return array + */ public function badGetProvider() { $cases = array(); // array($getParams, $expectedNames) @@ -534,6 +552,10 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { $this->assertAttachmentExistence(FALSE, $createResults['delme']['second']); } + /** + * @param $exists + * @param array $apiResult + */ protected function assertAttachmentExistence($exists, $apiResult) { $fileId = $apiResult['id']; $this->assertTrue(is_numeric($fileId)); @@ -546,6 +568,10 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { )); } + /** + * @param $name + * @return string + */ protected function tmpFile($name) { $tmpDir = sys_get_temp_dir(); $this->assertTrue($tmpDir && is_dir($tmpDir), 'Tmp dir must exist: ' . $tmpDir); diff --git a/tests/phpunit/api/v3/MailingABTest.php b/tests/phpunit/api/v3/MailingABTest.php index 45353cf791..6a19c5de2e 100755 --- a/tests/phpunit/api/v3/MailingABTest.php +++ b/tests/phpunit/api/v3/MailingABTest.php @@ -95,6 +95,9 @@ class api_v3_MailingABTest extends CiviUnitTestCase { )); } + /** + * @return array + */ public function groupPctProvider() { $cases = array(); // array(int $totalSize, int $groupPct, int $expectedCountA, $expectedCountB, $expectedCountC) $cases[] = array(400, 7, 28, 28, 344); @@ -167,6 +170,11 @@ class api_v3_MailingABTest extends CiviUnitTestCase { $this->assertEquals($expectedCountC, $countC, "check mailing recipients C in line " . __LINE__); } + /** + * @param $expectedA + * @param $expectedB + * @param $expectedC + */ protected function assertJobCounts($expectedA, $expectedB, $expectedC) { $this->assertDBQuery($expectedA, 'SELECT count(*) FROM civicrm_mailing_job WHERE mailing_id = %1', array( 1 => array( diff --git a/tests/phpunit/api/v3/TaxContributionPageTest.php b/tests/phpunit/api/v3/TaxContributionPageTest.php index ec1ba0bf33..844ab878a0 100644 --- a/tests/phpunit/api/v3/TaxContributionPageTest.php +++ b/tests/phpunit/api/v3/TaxContributionPageTest.php @@ -503,8 +503,8 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase { } /** - * @param array $params * @param int $financialTypeId + * @return int */ public function _getFinancialAccountId($financialTypeId) { $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' ")); @@ -520,7 +520,9 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase { return CRM_Utils_Array::value('financial_account_id', $result); } - ///////////////// civicrm_contribution_delete methods + /** + * + */ public function testDeleteContribution() { $contributionID = $this->contributionCreate($this->_individualId, $this->financialtypeID, 'dfsdf', 12389); $params = array( -- 2.25.1