Permalink
Browse files

Merge branch '2.1' of github.com:cakephp/cakephp into 2.1

  • Loading branch information...
2 parents 97f48dc + dd5c605 commit 028ba27522892f7ab6a746ec7bd435b475e3e3fb @ceeram ceeram committed Feb 10, 2012
@@ -425,6 +425,7 @@ public function getOptionParser() {
)->addArgument('name', array(
'help' => __d('cake_console', 'Application directory to make, if it starts with "/" the path is absolute.')
))->addOption('empty', array(
+ 'boolean' => true,
'help' => __d('cake_console', 'Create empty files in each of the directories. Good if you are using git')
))->addOption('skel', array(
'default' => current(App::core('Console')) . 'Templates' . DS . 'skel',
@@ -405,7 +405,7 @@ public function execute($sql, $options = array(), $params = array()) {
if ($options['log']) {
$this->took = round((microtime(true) - $t) * 1000, 0);
$this->numRows = $this->affected = $this->lastAffected();
- $this->logQuery($sql);
+ $this->logQuery($sql, $params);
}
return $this->_result;
@@ -894,11 +894,12 @@ public function showLog($sorted = false) {
* @param string $sql SQL statement
* @return void
*/
- public function logQuery($sql) {
+ public function logQuery($sql, $params = array()) {
$this->_queriesCnt++;
$this->_queriesTime += $this->took;
$this->_queriesLog[] = array(
'query' => $sql,
+ 'params' => $params,
'affected' => $this->affected,
'numRows' => $this->numRows,
'took' => $this->took
@@ -48,13 +48,13 @@ public static function suite() {
$suite->addTestFile($path . 'AllEventTest.php');
$suite->addTestFile($path . 'AllHelpersTest.php');
$suite->addTestFile($path . 'AllLogTest.php');
- $suite->addTestFile($path . 'AllI18nTest.php');
$suite->addTestFile($path . 'Model' . DS . 'ModelTest.php');
$suite->addTestFile($path . 'AllRoutingTest.php');
$suite->addTestFile($path . 'AllNetworkTest.php');
$suite->addTestFile($path . 'AllTestSuiteTest.php');;
$suite->addTestFile($path . 'AllUtilityTest.php');
$suite->addTestFile($path . 'AllViewTest.php');
+ $suite->addTestFile($path . 'AllI18nTest.php');
return $suite;
}
}
@@ -90,19 +90,39 @@ public function testBake() {
'Config' . DS . 'Schema',
'Console',
'Console' . DS . 'Command',
+ 'Console' . DS . 'Templates',
'Console' . DS . 'Command' . DS . 'Task',
'Controller',
+ 'Controller' . DS. 'Component',
+ 'Locale',
'Model',
- 'View',
- 'View' . DS . 'Helper',
+ 'Model' . DS. 'Behavior',
+ 'Model' . DS. 'Datasource',
+ 'Plugin',
'Test',
'Test' . DS . 'Case',
+ 'Test' . DS . 'Case' . DS . 'Controller',
+ 'Test' . DS . 'Case' . DS . 'Controller' . DS . 'Component',
'Test' . DS . 'Case' . DS . 'Model',
+ 'Test' . DS . 'Case' . DS . 'Model' . DS . 'Behavior',
'Test' . DS . 'Fixture',
+ 'Vendor',
+ 'View',
+ 'View' . DS . 'Helper',
'tmp',
+ 'tmp' . DS . 'cache',
+ 'tmp' . DS . 'cache' . DS . 'models',
+ 'tmp' . DS . 'cache' . DS . 'persistent',
+ 'tmp' . DS . 'cache' . DS . 'views',
+ 'tmp' . DS . 'logs',
+ 'tmp' . DS . 'sessions',
+ 'tmp' . DS . 'tests',
'webroot',
- 'webroot' . DS . 'js',
'webroot' . DS . 'css',
+ 'webroot' . DS . 'files',
+ 'webroot' . DS . 'img',
+ 'webroot' . DS . 'js',
+
);
foreach ($dirs as $dir) {
$this->assertTrue(is_dir($path . DS . $dir), 'Missing ' . $dir);
@@ -169,15 +189,26 @@ public function testBakeEmptyFlag() {
$empty = array(
'Console' . DS . 'Command' . DS . 'Task' => 'empty',
'Controller' . DS . 'Component' => 'empty',
+ 'Lib' => 'empty',
'Model' . DS . 'Behavior' => 'empty',
- 'View' . DS . 'Helper' => 'AppHelper.php',
- 'View' . DS . 'Errors' => 'empty',
- 'View' . DS . 'Scaffolds' => 'empty',
+ 'Model' . DS . 'Datasource' => 'empty',
+ 'Plugin' => 'empty',
'Test' . DS . 'Case' . DS . 'Model' . DS . 'Behavior' => 'empty',
'Test' . DS . 'Case' . DS . 'Controller' . DS . 'Component' => 'empty',
'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' => 'empty',
'Test' . DS . 'Fixture' => 'empty',
- 'webroot' . DS . 'js' => 'empty'
+ 'Vendor' => 'empty',
+ 'View' . DS . 'Elements' => 'empty',
+ 'View' . DS . 'Errors' => 'empty',
+ 'View' . DS . 'Scaffolds' => 'empty',
+ 'tmp' . DS . 'cache' . DS . 'models' => 'empty',
+ 'tmp' . DS . 'cache' . DS . 'persistent' => 'empty',
+ 'tmp' . DS . 'cache' . DS . 'views' => 'empty',
+ 'tmp' . DS . 'logs' => 'empty',
+ 'tmp' . DS . 'sessions' => 'empty',
+ 'tmp' . DS . 'tests' => 'empty',
+ 'webroot' . DS . 'js' => 'empty',
+ 'webroot' . DS . 'files' => 'empty'
);
foreach ($empty as $dir => $file) {
@@ -2525,6 +2525,7 @@ public function testPoNoTranslationNeeded () {
* @return void
*/
public function testPoQuotedString () {
+ Configure::write('Config.language', 'po');
$expected = 'this is a "quoted string" (translated)';
$this->assertEquals($expected, __('this is a "quoted string"'));
}
@@ -651,14 +651,32 @@ public function testGetLog() {
$this->testDb->logQuery('Query 2');
$log = $this->testDb->getLog();
+ $expected = array('query' => 'Query 1', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => '');
- $expected = array('query' => 'Query 1', 'affected' => '', 'numRows' => '', 'took' => '');
$this->assertEquals($log['log'][0], $expected);
- $expected = array('query' => 'Query 2', 'affected' => '', 'numRows' => '', 'took' => '');
+ $expected = array('query' => 'Query 2', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => '');
$this->assertEquals($log['log'][1], $expected);
$expected = array('query' => 'Error 1', 'affected' => '', 'numRows' => '', 'took' => '');
}
+
+/**
+ * test getting the query log as an array, setting bind params.
+ *
+ * @return void
+ */
+ public function testGetLogParams() {
+ $this->testDb->logQuery('Query 1', array(1,2,'abc'));
+ $this->testDb->logQuery('Query 2', array('field1' => 1, 'field2' => 'abc'));
+
+ $log = $this->testDb->getLog();
+ $expected = array('query' => 'Query 1', 'params' => array(1,2,'abc'), 'affected' => '', 'numRows' => '', 'took' => '');
+ $this->assertEquals($log['log'][0], $expected);
+ $expected = array('query' => 'Query 2', 'params' => array('field1' => 1, 'field2' => 'abc'), 'affected' => '', 'numRows' => '', 'took' => '');
+ $this->assertEquals($log['log'][1], $expected);
+ }
+
+
/**
* test that query() returns boolean values from operations like CREATE TABLE
*
@@ -797,32 +815,32 @@ function testLastError() {
* @return void
**/
public function testTransactionLogging() {
- $conn = $this->getMock('MockPDO');
- $db = new DboTestSource;
- $db->setConnection($conn);
- $conn->expects($this->exactly(2))->method('beginTransaction')
- ->will($this->returnValue(true));
- $conn->expects($this->once())->method('commit')->will($this->returnValue(true));
- $conn->expects($this->once())->method('rollback')->will($this->returnValue(true));
-
- $db->begin();
- $log = $db->getLog();
- $expected = array('query' => 'BEGIN', 'affected' => '', 'numRows' => '', 'took' => '');
- $this->assertEquals($expected, $log['log'][0]);
-
- $db->commit();
- $expected = array('query' => 'COMMIT', 'affected' => '', 'numRows' => '', 'took' => '');
- $log = $db->getLog();
- $this->assertEquals($expected, $log['log'][0]);
-
- $db->begin();
- $expected = array('query' => 'BEGIN', 'affected' => '', 'numRows' => '', 'took' => '');
- $log = $db->getLog();
- $this->assertEquals($expected, $log['log'][0]);
-
- $db->rollback();
- $expected = array('query' => 'ROLLBACK', 'affected' => '', 'numRows' => '', 'took' => '');
- $log = $db->getLog();
- $this->assertEquals($expected, $log['log'][0]);
+ $conn = $this->getMock('MockPDO');
+ $db = new DboTestSource;
+ $db->setConnection($conn);
+ $conn->expects($this->exactly(2))->method('beginTransaction')
+ ->will($this->returnValue(true));
+ $conn->expects($this->once())->method('commit')->will($this->returnValue(true));
+ $conn->expects($this->once())->method('rollback')->will($this->returnValue(true));
+
+ $db->begin();
+ $log = $db->getLog();
+ $expected = array('query' => 'BEGIN', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => '');
+ $this->assertEquals($expected, $log['log'][0]);
+
+ $db->commit();
+ $expected = array('query' => 'COMMIT', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => '');
+ $log = $db->getLog();
+ $this->assertEquals($expected, $log['log'][0]);
+
+ $db->begin();
+ $expected = array('query' => 'BEGIN', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => '');
+ $log = $db->getLog();
+ $this->assertEquals($expected, $log['log'][0]);
+
+ $db->rollback();
+ $expected = array('query' => 'ROLLBACK', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => '');
+ $log = $db->getLog();
+ $this->assertEquals($expected, $log['log'][0]);
}
}
Oops, something went wrong.

0 comments on commit 028ba27

Please sign in to comment.