* Class CRM_Core_DAOTest
*/
class CRM_Core_DAOTest extends CiviUnitTestCase {
- /**
- * @return array
- */
- function get_info() {
- return array(
- 'name' => 'DAO',
- 'description' => 'Test core DAO functions',
- 'group' => 'Core',
- );
- }
- function testGetReferenceColumns() {
+ public function testGetReferenceColumns() {
// choose CRM_Core_DAO_Email as an arbitrary example
$emailRefs = CRM_Core_DAO_Email::getReferenceColumns();
$refsByTarget = array();
$this->assertEquals('CRM_Core_Reference_Basic', get_class($contactRef));
}
- function testGetReferencesToTable() {
+ public function testGetReferencesToTable() {
$refs = CRM_Core_DAO::getReferencesToTable(CRM_Financial_DAO_FinancialType::getTableName());
$refsBySource = array();
foreach ($refs as $refSpec) {
$this->assertEquals('CRM_Core_Reference_Dynamic', get_class($genericRef));
}
- function testFindReferences() {
+ public function testFindReferences() {
$params = array(
'first_name' => 'Testy',
'last_name' => 'McScallion',
/**
* @return array
*/
- function composeQueryExamples() {
+ public function composeQueryExamples() {
$cases = array();
// $cases[] = array('Input-SQL', 'Input-Params', 'Expected-SQL');
/**
* @dataProvider composeQueryExamples
+ * @param $inputSql
+ * @param $inputParams
+ * @param $expectSql
*/
- function testComposeQuery($inputSql, $inputParams, $expectSql) {
+ public function testComposeQuery($inputSql, $inputParams, $expectSql) {
$actualSql = CRM_Core_DAO::composeQuery($inputSql, $inputParams);
$this->assertEquals($expectSql, $actualSql);
}
// 'SELECT * FROM whatever WHERE name = %1 AND title = %3 AND year LIKE '%2012'
// $params[3] = array('Bob', 'String');
// i.e. the place holder should be unique and should not contain in any other operational use in query
- function testComposeQueryFailure() {
+ public function testComposeQueryFailure() {
$cases[] = array(
'SELECT * FROM whatever WHERE name = %1 AND title = %2 AND year LIKE \'%2012\' ',
array(
/**
* @return array
*/
- function sqlNameDataProvider() {
+ public function sqlNameDataProvider() {
return array(
array('this is a long string', 30, FALSE, 'this is a long string'),
-
- array('this is an even longer string which is exactly 60 character', 60, FALSE, 'this is an even longer string which is exactly 60 character'),
- array('this is an even longer string which is exactly 60 character', 60, TRUE , 'this is an even longer string which is exactly 60 character'),
-
- array('this is an even longer string which is a bit more than 60 character', 60, FALSE, 'this is an even longer string which is a bit more than 60 ch'),
- array('this is an even longer string which is a bit more than 60 character', 60, TRUE , 'this is an even longer string which is a bit more th_c1cbd519'),
+ array(
+ 'this is an even longer string which is exactly 60 character',
+ 60,
+ FALSE,
+ 'this is an even longer string which is exactly 60 character'
+ ),
+ array(
+ 'this is an even longer string which is exactly 60 character',
+ 60,
+ TRUE,
+ 'this is an even longer string which is exactly 60 character'
+ ),
+ array(
+ 'this is an even longer string which is a bit more than 60 character',
+ 60,
+ FALSE,
+ 'this is an even longer string which is a bit more than 60 ch'
+ ),
+ array(
+ 'this is an even longer string which is a bit more than 60 character',
+ 60,
+ TRUE,
+ 'this is an even longer string which is a bit more th_c1cbd519'
+ ),
);
}
/**
* @dataProvider sqlNameDataProvider
+ * @param $inputData
+ * @param $length
+ * @param $makeRandom
+ * @param $expectedResult
*/
- function testShortenSQLName($inputData, $length, $makeRandom, $expectedResult) {
+ public function testShortenSQLName($inputData, $length, $makeRandom, $expectedResult) {
$this->assertEquals($expectedResult, CRM_Core_DAO::shortenSQLName($inputData, $length, $makeRandom));
}
- function testFindById() {
+ public function testFindById() {
$params = $this->sampleContact('Individual', 4);
$existing_contact = CRM_Contact_BAO_Contact::add($params);
$contact = CRM_Contact_BAO_Contact::findById($existing_contact->id);