X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FCiviTest%2FCiviDBAssert.php;h=91e859da2a4b19e3bcef6dbd7eca41d8a45d1afc;hb=d78cc635c03d2678c6ef8e11712a009a48088013;hp=9926770b62d781e3fdd4ff2f7de9e0cf1bedf204;hpb=1761553f7e28866ef0c0a9f54abbb222487cea5c;p=civicrm-core.git diff --git a/tests/phpunit/CiviTest/CiviDBAssert.php b/tests/phpunit/CiviTest/CiviDBAssert.php index 9926770b62..91e859da2a 100644 --- a/tests/phpunit/CiviTest/CiviDBAssert.php +++ b/tests/phpunit/CiviTest/CiviDBAssert.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * @@ -43,15 +43,20 @@ class CiviDBAssert { * @match array Associative array of field name => expected value. Empty if asserting * that a DELETE occurred * @delete boolean True if we're checking that a DELETE action occurred. + * @param $testCase + * @param $daoName + * @param $id + * @param $match + * @param bool $delete */ - function assertDBState(&$testCase, $daoName, $id, $match, $delete = FALSE) { + public function assertDBState(&$testCase, $daoName, $id, $match, $delete = FALSE) { if (empty($id)) { // adding this here since developers forget to check for an id // and hence we get the first value in the db $testCase->fail('ID not populated. Please fix your assertDBState usage!!!'); } - $object = new $daoName(); + $object = new $daoName(); $object->id = $id; $verifiedCount = 0; @@ -90,8 +95,15 @@ class CiviDBAssert { /** * Request a record from the DB by seachColumn+searchValue. Success if a record is found. + * @param $testCase + * @param $daoName + * @param $searchValue + * @param $returnColumn + * @param $searchColumn + * @param $message + * @return null|string */ - function assertDBNotNull(&$testCase, $daoName, $searchValue, $returnColumn, $searchColumn, $message) { + public function assertDBNotNull(&$testCase, $daoName, $searchValue, $returnColumn, $searchColumn, $message) { if (empty($searchValue)) { $testCase->fail("empty value passed to assertDBNotNull"); } @@ -103,16 +115,26 @@ class CiviDBAssert { /** * Request a record from the DB by seachColumn+searchValue. Success if returnColumn value is NULL. + * @param $testCase + * @param $daoName + * @param $searchValue + * @param $returnColumn + * @param $searchColumn + * @param $message */ - function assertDBNull(&$testCase, $daoName, $searchValue, $returnColumn, $searchColumn, $message) { + public function assertDBNull(&$testCase, $daoName, $searchValue, $returnColumn, $searchColumn, $message) { $value = CRM_Core_DAO::getFieldValue($daoName, $searchValue, $returnColumn, $searchColumn); $testCase->assertNull($value, $message); } /** * Request a record from the DB by id. Success if row not found. + * @param $testCase + * @param $daoName + * @param $id + * @param $message */ - function assertDBRowNotExist(&$testCase, $daoName, $id, $message) { + public function assertDBRowNotExist(&$testCase, $daoName, $id, $message) { $value = CRM_Core_DAO::getFieldValue($daoName, $id, 'id', 'id'); $testCase->assertNull($value, $message); } @@ -128,7 +150,8 @@ class CiviDBAssert { * @param $expectedValue * @param string $message */ - function assertDBCompareValue(&$testCase, $daoName, $searchValue, $returnColumn, $searchColumn, + public function assertDBCompareValue( + &$testCase, $daoName, $searchValue, $returnColumn, $searchColumn, $expectedValue, $message ) { $value = CRM_Core_DAO::getFieldValue($daoName, $searchValue, $returnColumn, $searchColumn); @@ -137,13 +160,16 @@ class CiviDBAssert { /** * Compare all values in a single retrieved DB record to an array of expected values + * @param $testCase + * @param $daoName + * @param $searchParams + * @param $expectedValues */ - function assertDBCompareValues(&$testCase, $daoName, $searchParams, $expectedValues) { + public function assertDBCompareValues(&$testCase, $daoName, $searchParams, $expectedValues) { //get the values from db $dbValues = array(); CRM_Core_DAO::commonRetrieve($daoName, $searchParams, $dbValues); - // compare db values with expected values self::assertAttributesEquals($testCase, $expectedValues, $dbValues); } @@ -153,7 +179,7 @@ class CiviDBAssert { * @param $expectedValues * @param $actualValues */ - function assertAttributesEquals(&$testCase, &$expectedValues, &$actualValues) { + public function assertAttributesEquals(&$testCase, &$expectedValues, &$actualValues) { foreach ($expectedValues as $paramName => $paramValue) { if (isset($actualValues[$paramName])) { $testCase->assertEquals($paramValue, $actualValues[$paramName]); @@ -163,4 +189,5 @@ class CiviDBAssert { } } } + }