<?php
-require_once 'CiviTest/CiviUnitTestCase.php';
-
/**
* Class CRM_Core_DAOTest
*/
/**
* @dataProvider composeQueryExamples
+ * @param $inputSql
+ * @param $inputParams
+ * @param $expectSql
*/
public function testComposeQuery($inputSql, $inputParams, $expectSql) {
$actualSql = CRM_Core_DAO::composeQuery($inputSql, $inputParams);
$this->assertEquals($expectSql, $actualSql);
}
- // CASE: Two params where the %2 is already present in the query
- // NOTE: This case should rightly FAIL, as using strstr in the replace mechanism will turn
- // the query into: SELECT * FROM whatever WHERE name = 'Alice' AND title = 'Bob' AND year LIKE ''Bob'012'
- // So, to avoid such ERROR, the query should be framed like:
- // '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
+ /**
+ * CASE: Two params where the %2 is already present in the query
+ * NOTE: This case should rightly FAIL, as using strstr in the replace mechanism will turn
+ * the query into: SELECT * FROM whatever WHERE name = 'Alice' AND title = 'Bob' AND year LIKE ''Bob'012'
+ * So, to avoid such ERROR, the query should be framed like:
+ * '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
+ */
public function testComposeQueryFailure() {
$cases[] = array(
'SELECT * FROM whatever WHERE name = %1 AND title = %2 AND year LIKE \'%2012\' ',
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
*/
public function testShortenSQLName($inputData, $length, $makeRandom, $expectedResult) {
$this->assertEquals($expectedResult, CRM_Core_DAO::shortenSQLName($inputData, $length, $makeRandom));
}
$this->assertTrue($exception_thrown);
}
+
}