From efbefeb71a969f563aa83ba9d746e2ac82cd6dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 13 Oct 2010 22:40:45 -0430 Subject: [PATCH 001/378] Stating migration to PDO, a driver is available if listed as available by PDO --- cake/libs/model/datasources/dbo/dbo_mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index cff28d572..69770db61 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -574,7 +574,7 @@ class DboMysql extends DboMysqlBase { * @return boolean */ function enabled() { - return extension_loaded('mysql'); + return in_array('mysql', PDO::getAvailableDrivers()); } /** * Disconnects from database. From b8479459d6ecc17d36445894382465fc6688a656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 14 Oct 2010 01:10:51 -0430 Subject: [PATCH 002/378] Inital work for connecting to mysql using PDO and gettng the table list, testing is easier as it now uses mocks --- cake/libs/model/datasources/dbo/dbo_mysql.php | 58 +++++++++++++------ .../model/datasources/dbo/dbo_mysql.test.php | 26 ++++++++- 2 files changed, 64 insertions(+), 20 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 69770db61..671c32659 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -539,6 +539,15 @@ class DboMysql extends DboMysqlBase { 'port' => '3306' ); + protected $_errors = array(); + +/** + * Reference to the PDO object connection + * + * @var PDO $_connection + */ + protected $_connection = null; + /** * Connects to the database using options in the given configuration array. * @@ -547,27 +556,31 @@ class DboMysql extends DboMysqlBase { function connect() { $config = $this->config; $this->connected = false; - - if (!$config['persistent']) { - $this->connection = mysql_connect($config['host'] . ':' . $config['port'], $config['login'], $config['password'], true); - $config['connect'] = 'mysql_connect'; - } else { - $this->connection = mysql_pconnect($config['host'] . ':' . $config['port'], $config['login'], $config['password']); - } - - if (mysql_select_db($config['database'], $this->connection)) { + try { + $flags = array(PDO::ATTR_PERSISTENT => $config['persistent']); + if (!empty($config['encoding'])) { + $flags[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $config['encoding']; + } + $this->_connection = new PDO( + "mysql:{$config['host']}:{$config['port']};dbname={$config['database']}", + $config['login'], + $config['password'], + $flags + ); $this->connected = true; + } catch (PDOException $e) { + $this->errors[] = $e->getMessage(); } - if (!empty($config['encoding'])) { - $this->setEncoding($config['encoding']); - } - - $this->_useAlias = (bool)version_compare(mysql_get_server_info($this->connection), "4.1", ">="); + //$this->_useAlias = (bool)version_compare(mysql_get_server_info($this->connection), "4.1", ">="); return $this->connected; } + public function getConnection() { + return $this->_connection; + } + /** * Check whether the MySQL extension is installed/loaded * @@ -593,10 +606,17 @@ class DboMysql extends DboMysqlBase { * Executes given SQL statement. * * @param string $sql SQL statement - * @return resource Result resource identifier + * @param array $params list of params to be bound to query + * @return PDOStatement if query executes with no problem, false otherwise */ - protected function _execute($sql) { - return mysql_query($sql, $this->connection); + protected function _execute($sql, $params = array()) { + $query = $this->_connection->prepare($sql); + $query->setFetchMode(PDO::FETCH_LAZY); + if (!$query->execute($params)) { + $this->errors[] = $query->errorInfo(); + return false; + } + return $query; } /** @@ -609,14 +629,14 @@ class DboMysql extends DboMysqlBase { if ($cache != null) { return $cache; } - $result = $this->_execute('SHOW TABLES FROM ' . $this->name($this->config['database']) . ';'); + $result = $this->_execute('SHOW TABLES FROM ' . $this->config['database']); if (!$result) { return array(); } else { $tables = array(); - while ($line = mysql_fetch_row($result)) { + while ($line = $result->fetch()) { $tables[] = $line[0]; } parent::listSources($tables); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 82ac17c23..11d81938c 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -158,7 +158,7 @@ class MysqlTestModel extends Model { * @subpackage cake.tests.cases.libs.model.datasources.dbo */ class DboMysqlTest extends CakeTestCase { - public $fixtures = array('core.binary_test'); + //public $fixtures = array('core.binary_test'); /** * The Dbo instance to be tested * @@ -838,4 +838,28 @@ class DboMysqlTest extends CakeTestCase { $this->db->execute($this->db->dropSchema($schema)); } +/** + * Tests that listSources method sends the correct query and parses the result accordingly + * @return void + */ + public function testListSources() { + $db = $this->getMock('DboMysql', array('connect', '_execute')); + $queryResult = $this->getMock('PDOStatement'); + $db->expects($this->once()) + ->method('_execute') + ->with('SHOW TABLES FROM cake') + ->will($this->returnValue($queryResult)); + $queryResult->expects($this->at(0)) + ->method('fetch') + ->will($this->returnValue(array('cake_table'))); + $queryResult->expects($this->at(1)) + ->method('fetch') + ->will($this->returnValue(array('another_table'))); + $queryResult->expects($this->at(2)) + ->method('fetch') + ->will($this->returnValue(null)); + + $tables = $db->listSources(); + $this->assertEqual($tables, array('cake_table', 'another_table')); + } } From 09e06d52b9b6cef4402d23f17b99bf3ec4b2f9cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 14 Oct 2010 23:15:17 -0430 Subject: [PATCH 003/378] Implementing DboMysql::getVersion() --- cake/libs/model/datasources/dbo/dbo_mysql.php | 13 +++++++++-- .../model/datasources/dbo/dbo_mysql.test.php | 22 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 671c32659..6f7ca6e55 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -796,8 +796,17 @@ class DboMysql extends DboMysqlBase { * * @return string The database encoding */ - function getEncoding() { - return mysql_client_encoding($this->connection); + public function getEncoding() { + return $this->_execute('SHOW VARIABLES LIKE ?', array('character_set_client'))->fetchObject()->Value; + } + +/** + * Gets the version string of the database server + * + * @return string The database encoding + */ + public function getVersion() { + return $this->_execute('SELECT VERSION() as mysql_version')->fetchObject()->mysql_version; } /** diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 11d81938c..cf4ebf6df 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -862,4 +862,26 @@ class DboMysqlTest extends CakeTestCase { $tables = $db->listSources(); $this->assertEqual($tables, array('cake_table', 'another_table')); } + +/** + * Tests that getVersion method sends the correct query for getting the mysql version + * @return void + */ + public function testGetVersion() { + $db = $this->getMock('DboMysql', array('connect', '_execute')); + $queryResult = $this->getMock('PDOStatement'); + + $db->expects($this->once()) + ->method('_execute') + ->with('SELECT VERSION() as mysql_version') + ->will($this->returnValue($queryResult)); + $result = new StdClass; + $result->mysql_version = '5.1'; + $queryResult->expects($this->once()) + ->method('fetchObject') + ->will($this->returnValue($result)); + + $version = $db->getVersion(); + $this->assertEqual('5.1', $version); + } } From dc362d1a38123fbda9d3b9ad69f27cb645dd6e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 14 Oct 2010 23:18:07 -0430 Subject: [PATCH 004/378] Adding test for DboMysql::getEncoding() --- .../model/datasources/dbo/dbo_mysql.test.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index cf4ebf6df..01db0d5db 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -884,4 +884,26 @@ class DboMysqlTest extends CakeTestCase { $version = $db->getVersion(); $this->assertEqual('5.1', $version); } + +/** + * Tests that getVersion method sends the correct query for getting the client encoding + * @return void + */ + public function testGetEncoding() { + $db = $this->getMock('DboMysql', array('connect', '_execute')); + $queryResult = $this->getMock('PDOStatement'); + + $db->expects($this->once()) + ->method('_execute') + ->with('SHOW VARIABLES LIKE ?', array('character_set_client')) + ->will($this->returnValue($queryResult)); + $result = new StdClass; + $result->Value = 'utf-8'; + $queryResult->expects($this->once()) + ->method('fetchObject') + ->will($this->returnValue($result)); + + $encoding = $db->getEncoding(); + $this->assertEqual('utf-8', $encoding); + } } From 52023085f4ba830954f92840dd38a6c949459d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 14 Oct 2010 23:32:07 -0430 Subject: [PATCH 005/378] Using the PDO conenction inside DboMysql::getCharsetName() --- cake/libs/model/datasources/dbo/dbo_mysql.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 6f7ca6e55..02d8b2229 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -815,11 +815,12 @@ class DboMysql extends DboMysqlBase { * @param string $name Collation name * @return string Character set name */ - function getCharsetName($name) { - if ((bool)version_compare(mysql_get_server_info($this->connection), "5", ">=")) { - $cols = $this->query('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME= ' . $this->value($name) . ';'); - if (isset($cols[0]['COLLATIONS']['CHARACTER_SET_NAME'])) { - return $cols[0]['COLLATIONS']['CHARACTER_SET_NAME']; + public function getCharsetName($name) { + if ((bool)version_compare($this->getVersion(), "5", ">=")) { + $r = $this->_execute('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME = ?', array($name)); + $cols = $r->fetchArray(); + if (isset($cols['COLLATIONS']['CHARACTER_SET_NAME'])) { + return $cols['COLLATIONS']['CHARACTER_SET_NAME']; } } return false; From 52ea8fb42e7c1cbb3cff0a72c79412835f6756b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 15 Oct 2010 16:07:51 -0430 Subject: [PATCH 006/378] Fixing mysql connection string --- cake/libs/model/datasources/dbo/dbo_mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 02d8b2229..7efccc975 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -562,7 +562,7 @@ class DboMysql extends DboMysqlBase { $flags[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $config['encoding']; } $this->_connection = new PDO( - "mysql:{$config['host']}:{$config['port']};dbname={$config['database']}", + "mysql:{$config['host']};port={$config['port']};dbname={$config['database']}", $config['login'], $config['password'], $flags From 70ed9a7b1227126e9c54048a00b1269d7e531e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 15 Oct 2010 17:02:37 -0430 Subject: [PATCH 007/378] Fixing DboMysql::index() method --- cake/libs/model/datasources/dbo/dbo_mysql.php | 26 ++++++--------- cake/libs/model/datasources/dbo_source.php | 4 +-- .../model/datasources/dbo/dbo_mysql.test.php | 32 +++++++++++-------- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 7efccc975..bd8b46505 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -250,23 +250,19 @@ class DboMysqlBase extends DboSource { $index = array(); $table = $this->fullTableName($model); if ($table) { - $indexes = $this->query('SHOW INDEX FROM ' . $table); - if (isset($indexes[0]['STATISTICS'])) { - $keys = Set::extract($indexes, '{n}.STATISTICS'); - } else { - $keys = Set::extract($indexes, '{n}.0'); - } - foreach ($keys as $i => $key) { - if (!isset($index[$key['Key_name']])) { + $indices = $this->_execute('SHOW INDEX FROM ' . $table); + + while ($idx = $indices->fetch()) { + if (!isset($index[$idx->Key_name]['column'])) { $col = array(); - $index[$key['Key_name']]['column'] = $key['Column_name']; - $index[$key['Key_name']]['unique'] = intval($key['Non_unique'] == 0); + $index[$idx->Key_name]['column'] = $idx->Column_name; + $index[$idx->Key_name]['unique'] = intval($idx->Non_unique == 0); } else { - if (!is_array($index[$key['Key_name']]['column'])) { - $col[] = $index[$key['Key_name']]['column']; + if (!empty($index[$idx->Key_name]['column']) && !is_array($index[$idx->Key_name]['column'])) { + $col[] = $index[$idx->Key_name]['column']; } - $col[] = $key['Column_name']; - $index[$key['Key_name']]['column'] = $col; + $col[] = $idx->Column_name; + $index[$idx->Key_name]['column'] = $col; } } } @@ -539,8 +535,6 @@ class DboMysql extends DboMysqlBase { 'port' => '3306' ); - protected $_errors = array(); - /** * Reference to the PDO object connection * diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index dd515976b..3be595e84 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -218,9 +218,9 @@ class DboSource extends DataSource { * @param string $sql SQL statement * @return boolean */ - public function rawQuery($sql) { + public function rawQuery($sql, $params = array()) { $this->took = $this->error = $this->numRows = false; - return $this->execute($sql); + return $this->execute($sql, $params); } /** diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 01db0d5db..8999fdeb4 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -194,6 +194,7 @@ class DboMysqlTest extends CakeTestCase { /** * Test Dbo value method * + * @group quoting */ public function testQuoting() { $result = $this->Dbo->fields($this->model); @@ -252,16 +253,17 @@ class DboMysqlTest extends CakeTestCase { /** * test that localized floats don't cause trouble. * + * @group quoting * @return void */ function testLocalizedFloats() { $restore = setlocale(LC_ALL, null); setlocale(LC_ALL, 'de_DE'); - $result = $this->db->value(3.141593, 'float'); + $result = $this->Dbo->value(3.141593, 'float'); $this->assertEqual((string)$result, '3.141593'); - $result = $this->db->value(3.141593); + $result = $this->Dbo->value(3.141593); $this->assertEqual((string)$result, '3.141593'); setlocale(LC_ALL, $restore); @@ -270,13 +272,14 @@ class DboMysqlTest extends CakeTestCase { /** * testTinyintCasting method * - * @access public + * * @return void */ function testTinyintCasting() { + $this->skipIf(true, 'Is this a test over the DBO?'); $this->Dbo->cacheSources = false; $tableName = 'tinyint_' . uniqid(); - $this->Dbo->query('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); + $this->Dbo->execute('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); $this->model = new CakeTestModel(array( 'name' => 'Tinyint', 'table' => $tableName, 'ds' => 'test' @@ -316,35 +319,36 @@ class DboMysqlTest extends CakeTestCase { $this->Dbo->cacheSources = false; $name = $this->Dbo->fullTableName('simple'); - $this->Dbo->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); + $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); $expected = array('PRIMARY' => array('column' => 'id', 'unique' => 1)); $result = $this->Dbo->index('simple', false); + $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEqual($expected, $result); - $this->Dbo->query('DROP TABLE ' . $name); + $name = $this->Dbo->fullTableName('with_a_key'); - $this->Dbo->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ));'); + $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ));'); $expected = array( 'PRIMARY' => array('column' => 'id', 'unique' => 1), 'pointless_bool' => array('column' => 'bool', 'unique' => 0), ); $result = $this->Dbo->index('with_a_key', false); + $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEqual($expected, $result); - $this->Dbo->query('DROP TABLE ' . $name); $name = $this->Dbo->fullTableName('with_two_keys'); - $this->Dbo->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ));'); + $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ));'); $expected = array( 'PRIMARY' => array('column' => 'id', 'unique' => 1), 'pointless_bool' => array('column' => 'bool', 'unique' => 0), 'pointless_small_int' => array('column' => 'small_int', 'unique' => 0), ); $result = $this->Dbo->index('with_two_keys', false); + $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEqual($expected, $result); - $this->Dbo->query('DROP TABLE ' . $name); $name = $this->Dbo->fullTableName('with_compound_keys'); - $this->Dbo->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ), KEY `one_way` ( `bool`, `small_int` ));'); + $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ), KEY `one_way` ( `bool`, `small_int` ));'); $expected = array( 'PRIMARY' => array('column' => 'id', 'unique' => 1), 'pointless_bool' => array('column' => 'bool', 'unique' => 0), @@ -352,11 +356,11 @@ class DboMysqlTest extends CakeTestCase { 'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0), ); $result = $this->Dbo->index('with_compound_keys', false); + $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEqual($expected, $result); - $this->Dbo->query('DROP TABLE ' . $name); $name = $this->Dbo->fullTableName('with_multiple_compound_keys'); - $this->Dbo->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ), KEY `one_way` ( `bool`, `small_int` ), KEY `other_way` ( `small_int`, `bool` ));'); + $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ), KEY `one_way` ( `bool`, `small_int` ), KEY `other_way` ( `small_int`, `bool` ));'); $expected = array( 'PRIMARY' => array('column' => 'id', 'unique' => 1), 'pointless_bool' => array('column' => 'bool', 'unique' => 0), @@ -365,8 +369,8 @@ class DboMysqlTest extends CakeTestCase { 'other_way' => array('column' => array('small_int', 'bool'), 'unique' => 0), ); $result = $this->Dbo->index('with_multiple_compound_keys', false); + $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEqual($expected, $result); - $this->Dbo->query('DROP TABLE ' . $name); } /** From 0fb2ac0285418f91c2257a8a33d962067c4c246d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 15 Oct 2010 17:03:59 -0430 Subject: [PATCH 008/378] Chaging implementation of DboMysql::getVersion(), improving connection options --- cake/libs/model/datasources/dbo/dbo_mysql.php | 9 ++++++--- .../model/datasources/dbo/dbo_mysql.test.php | 17 ++--------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index bd8b46505..992e68f94 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -551,7 +551,10 @@ class DboMysql extends DboMysqlBase { $config = $this->config; $this->connected = false; try { - $flags = array(PDO::ATTR_PERSISTENT => $config['persistent']); + $flags = array( + PDO::ATTR_PERSISTENT => $config['persistent'], + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true + ); if (!empty($config['encoding'])) { $flags[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $config['encoding']; } @@ -566,7 +569,7 @@ class DboMysql extends DboMysqlBase { $this->errors[] = $e->getMessage(); } - //$this->_useAlias = (bool)version_compare(mysql_get_server_info($this->connection), "4.1", ">="); + $this->_useAlias = (bool)version_compare($this->getVersion(), "4.1", ">="); return $this->connected; } @@ -800,7 +803,7 @@ class DboMysql extends DboMysqlBase { * @return string The database encoding */ public function getVersion() { - return $this->_execute('SELECT VERSION() as mysql_version')->fetchObject()->mysql_version; + return $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION); } /** diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 8999fdeb4..6ac99b0e1 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -872,21 +872,8 @@ class DboMysqlTest extends CakeTestCase { * @return void */ public function testGetVersion() { - $db = $this->getMock('DboMysql', array('connect', '_execute')); - $queryResult = $this->getMock('PDOStatement'); - - $db->expects($this->once()) - ->method('_execute') - ->with('SELECT VERSION() as mysql_version') - ->will($this->returnValue($queryResult)); - $result = new StdClass; - $result->mysql_version = '5.1'; - $queryResult->expects($this->once()) - ->method('fetchObject') - ->will($this->returnValue($result)); - - $version = $db->getVersion(); - $this->assertEqual('5.1', $version); + $version = $this->Dbo->getVersion(); + $this->assertTrue(is_string($version)); } /** From bd856c7ef9d17014c178602177f455984ae07658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 15 Oct 2010 17:04:49 -0430 Subject: [PATCH 009/378] Fixing value quoting in DboMysql --- cake/libs/model/datasources/dbo/dbo_mysql.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 992e68f94..d66e6d0c8 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -656,10 +656,10 @@ class DboMysql extends DboMysqlBase { return $parent; } if ($data === null || (is_array($data) && empty($data))) { - return 'NULL'; + return $this->_connection->quote($data, PDO::PARAM_NULL); } if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') { - return "''"; + return $this->_connection->quote($data, PDO::PARAM_STR); } if (empty($column)) { $column = $this->introspectType($data); @@ -684,7 +684,7 @@ class DboMysql extends DboMysqlBase { return $data; } default: - return "'" . mysql_real_escape_string($data, $this->connection) . "'"; + return $this->_connection->quote($data, PDO::PARAM_STR); break; } } From c54448d20530ffe329e3bd788128ee0d41c4d3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 15 Oct 2010 17:05:30 -0430 Subject: [PATCH 010/378] Initial steps toward getting complete query results in DboMysql using PDO --- cake/libs/model/datasources/dbo/dbo_mysql.php | 12 ++++++++---- cake/libs/model/datasources/dbo_source.php | 10 +++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index d66e6d0c8..0ee13dcbf 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -695,8 +695,12 @@ class DboMysql extends DboMysqlBase { * @return string Error message with error number */ function lastError() { - if (mysql_errno($this->connection)) { - return mysql_errno($this->connection).': '.mysql_error($this->connection); + if ($this->hasResult()) { + $error = $this->_result->errorInfo(); + if (empty($error)) { + $error; + } + return $error[1] . ': ' . $error[2]; } return null; } @@ -708,8 +712,8 @@ class DboMysql extends DboMysqlBase { * @return integer Number of affected rows */ function lastAffected() { - if ($this->_result) { - return mysql_affected_rows($this->connection); + if ($this->hasResult()) { + return $this->_result->rowCount(); } return null; } diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 3be595e84..8731aa865 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -235,20 +235,20 @@ class DboSource extends DataSource { * - log - Whether or not the query should be logged to the memory log. * * @param string $sql + * @param array $params values to be bided to the query * @param array $options * @return mixed Resource or object representing the result set, or false on failure */ - public function execute($sql, $options = array()) { + public function execute($sql, $params = array(), $options = array()) { $defaults = array('stats' => true, 'log' => $this->fullDebug); $options = array_merge($defaults, $options); $t = microtime(true); - $this->_result = $this->_execute($sql); + $this->_result = $this->_execute($sql, $params); if ($options['stats']) { $this->took = round((microtime(true) - $t) * 1000, 0); $this->affected = $this->lastAffected(); - $this->error = $this->lastError(); - $this->numRows = $this->lastNumRows(); + //$this->numRows = $this->lastNumRows(); } if ($options['log']) { @@ -576,7 +576,7 @@ class DboSource extends DataSource { * @return boolean True if the result is valid else false */ public function hasResult() { - return is_resource($this->_result); + return is_a($this->_result, 'PDOStatement'); } /** From 5e80cf8ff78adb4656ef4f533ff0ea43da9e1bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 15 Oct 2010 17:27:36 -0430 Subject: [PATCH 011/378] Improving DboMysql::index() --- cake/libs/model/datasources/dbo/dbo_mysql.php | 5 ++++- .../model/datasources/dbo/dbo_mysql.test.php | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 0ee13dcbf..bb8e9c9c4 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -249,10 +249,13 @@ class DboMysqlBase extends DboSource { function index($model) { $index = array(); $table = $this->fullTableName($model); + $old = version_compare($this->getVersion(), '4.1', '<='); if ($table) { $indices = $this->_execute('SHOW INDEX FROM ' . $table); - while ($idx = $indices->fetch()) { + if ($old) { + $idx = (object) current((array)$idx); + } if (!isset($index[$idx->Key_name]['column'])) { $col = array(); $index[$idx->Key_name]['column'] = $idx->Column_name; diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 6ac99b0e1..b381f9e7a 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -313,6 +313,7 @@ class DboMysqlTest extends CakeTestCase { /** * testIndexDetection method * + * @group indices * @return void */ public function testIndexDetection() { @@ -376,7 +377,6 @@ class DboMysqlTest extends CakeTestCase { /** * testBuildColumn method * - * @access public * @return void */ function testBuildColumn() { @@ -413,12 +413,13 @@ class DboMysqlTest extends CakeTestCase { * MySQL 4.x returns index data in a different format, * Using a mock ensure that MySQL 4.x output is properly parsed. * + * @group indices * @return void */ function testIndexOnMySQL4Output() { $name = $this->Dbo->fullTableName('simple'); - $mockDbo = $this->getMock('DboMysql', array('query')); + $mockDbo = $this->getMock('DboMysql', array('connect', '_execute', 'getVersion')); $columnData = array( array('0' => array( 'Table' => 'with_compound_keys', @@ -491,10 +492,17 @@ class DboMysqlTest extends CakeTestCase { 'Comment' => '' )) ); + + $mockDbo->expects($this->once())->method('getVersion')->will($this->returnValue('4.1')); + $resultMock = $this->getMock('PDOStatement', array('fetch')); $mockDbo->expects($this->once()) - ->method('query') + ->method('_execute') ->with('SHOW INDEX FROM ' . $name) - ->will($this->returnValue($columnData)); + ->will($this->returnValue($resultMock)); + + foreach ($columnData as $i => $data) { + $resultMock->expects($this->at($i))->method('fetch')->will($this->returnValue((object) $data)); + } $result = $mockDbo->index($name, false); $expected = array( @@ -556,7 +564,7 @@ class DboMysqlTest extends CakeTestCase { /** * testAlterSchemaIndexes method * - * @access public + * @group indices * @return void */ function testAlterSchemaIndexes() { From 526205b546658c00bd94e0257809c81258ad2955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 15 Oct 2010 18:41:17 -0430 Subject: [PATCH 012/378] Fixing test case in DboMysql --- .../model/datasources/dbo/dbo_mysql.test.php | 57 ++++++++++++++----- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index b381f9e7a..418f17a25 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -262,7 +262,7 @@ class DboMysqlTest extends CakeTestCase { $result = $this->Dbo->value(3.141593, 'float'); $this->assertEqual((string)$result, '3.141593'); - + $result = $this->Dbo->value(3.141593); $this->assertEqual((string)$result, '3.141593'); @@ -325,7 +325,7 @@ class DboMysqlTest extends CakeTestCase { $result = $this->Dbo->index('simple', false); $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEqual($expected, $result); - + $name = $this->Dbo->fullTableName('with_a_key'); $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ));'); @@ -499,7 +499,7 @@ class DboMysqlTest extends CakeTestCase { ->method('_execute') ->with('SHOW INDEX FROM ' . $name) ->will($this->returnValue($resultMock)); - + foreach ($columnData as $i => $data) { $resultMock->expects($this->at($i))->method('fetch')->will($this->returnValue((object) $data)); } @@ -580,7 +580,15 @@ class DboMysqlTest extends CakeTestCase { 'group1' => array('type' => 'integer', 'null' => true), 'group2' => array('type' => 'integer', 'null' => true) ))); - $this->Dbo->query($this->Dbo->createSchema($schema1)); + $result = $this->Dbo->createSchema($schema1); + $this->assertContains('`id` int(11) DEFAULT 0 NOT NULL,', $result); + $this->assertContains('`name` varchar(50) NOT NULL,', $result); + $this->assertContains('`group1` int(11) DEFAULT NULL', $result); + $this->assertContains('`group2` int(11) DEFAULT NULL', $result); + + //Test that the string is syntactically correct + $query = $this->Dbo->getConnection()->prepare($result); + $this->assertEquals($result, $query->queryString); $schema2 = new CakeSchema(array( 'name' => 'AlterTest2', @@ -596,10 +604,17 @@ class DboMysqlTest extends CakeTestCase { 'compound_idx' => array('column' => array('group1', 'group2'), 'unique' => 0), 'PRIMARY' => array('column' => 'id', 'unique' => 1)) ))); - $this->Dbo->query($this->Dbo->alterSchema($schema2->compare($schema1))); - $indexes = $this->Dbo->index('altertest'); - $this->assertEqual($schema2->tables['altertest']['indexes'], $indexes); + $result = $this->Dbo->alterSchema($schema2->compare($schema1)); + $this->assertContains('ALTER TABLE `altertest`', $result); + $this->assertContains('ADD KEY name_idx (`name`),', $result); + $this->assertContains('ADD KEY group_idx (`group1`),', $result); + $this->assertContains('ADD KEY compound_idx (`group1`, `group2`),', $result); + $this->assertContains('ADD PRIMARY KEY (`id`);', $result); + + //Test that the string is syntactically correct + $query = $this->Dbo->getConnection()->prepare($result); + $this->assertEquals($result, $query->queryString); // Change three indexes, delete one and add another one $schema3 = new CakeSchema(array( @@ -617,22 +632,36 @@ class DboMysqlTest extends CakeTestCase { 'id_name_idx' => array('column' => array('id', 'name'), 'unique' => 0)) ))); - $this->Dbo->query($this->Dbo->alterSchema($schema3->compare($schema2))); + $result = $this->Dbo->alterSchema($schema3->compare($schema2)); + $this->assertContains('ALTER TABLE `altertest`', $result); + $this->assertContains('DROP PRIMARY KEY,', $result); + $this->assertContains('DROP KEY name_idx,', $result); + $this->assertContains('DROP KEY group_idx,', $result); + $this->assertContains('DROP KEY compound_idx,', $result); + $this->assertContains('ADD KEY id_name_idx (`id`, `name`),', $result); + $this->assertContains('ADD UNIQUE KEY name_idx (`name`),', $result); + $this->assertContains('ADD KEY group_idx (`group2`),', $result); + $this->assertContains('ADD KEY compound_idx (`group2`, `group1`);', $result); - $indexes = $this->Dbo->index('altertest'); - $this->assertEqual($schema3->tables['altertest']['indexes'], $indexes); + $query = $this->Dbo->getConnection()->prepare($result); + $this->assertEquals($result, $query->queryString); // Compare us to ourself. $this->assertEqual($schema3->compare($schema3), array()); // Drop the indexes - $this->Dbo->query($this->Dbo->alterSchema($schema1->compare($schema3))); + $result = $this->Dbo->alterSchema($schema1->compare($schema3)); - $indexes = $this->Dbo->index('altertest'); - $this->assertEqual(array(), $indexes); + $this->assertContains('ALTER TABLE `altertest`', $result); + $this->assertContains('DROP KEY name_idx,', $result); + $this->assertContains('DROP KEY group_idx,', $result); + $this->assertContains('DROP KEY compound_idx,', $result); + $this->assertContains('DROP KEY id_name_idx;', $result); - $this->Dbo->query($this->Dbo->dropSchema($schema1)); + $query = $this->Dbo->getConnection()->prepare($result); + $this->assertEquals($result, $query->queryString); } + /** * test saving and retrieval of blobs * From 7a7659d063fefc41703d817e941c8e646169294c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 15 Oct 2010 19:01:28 -0430 Subject: [PATCH 013/378] Removing DboMysqlBase as the inner driver selection will be delegated to PDO, extracting _execute() and adding it to DboSource --- cake/libs/model/datasources/dbo/dbo_mysql.php | 623 +++++++++--------- cake/libs/model/datasources/dbo_source.php | 19 + 2 files changed, 314 insertions(+), 328 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index bb8e9c9c4..625446ac5 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -19,19 +19,42 @@ */ /** - * Provides common base for MySQL & MySQLi connections + * MySQL DBO driver object + * + * Provides connection and SQL generation for MySQL RDMS * * @package cake * @subpackage cake.cake.libs.model.datasources.dbo */ -class DboMysqlBase extends DboSource { +class DboMysql extends DboSource { /** - * Description property. + * Datasource description * * @var string */ - public $description = "MySQL DBO Base Driver"; + public $description = "MySQL DBO Driver"; + +/** + * Base configuration settings for MySQL driver + * + * @var array + */ + protected $_baseConfig = array( + 'persistent' => true, + 'host' => 'localhost', + 'login' => 'root', + 'password' => '', + 'database' => 'cake', + 'port' => '3306' + ); + +/** + * Reference to the PDO object connection + * + * @var PDO $_connection + */ + protected $_connection = null; /** * Start quote @@ -110,6 +133,274 @@ class DboMysqlBase extends DboSource { 'boolean' => array('name' => 'tinyint', 'limit' => '1') ); +/** + * Connects to the database using options in the given configuration array. + * + * @return boolean True if the database could be connected, else false + */ + function connect() { + $config = $this->config; + $this->connected = false; + try { + $flags = array( + PDO::ATTR_PERSISTENT => $config['persistent'], + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true + ); + if (!empty($config['encoding'])) { + $flags[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $config['encoding']; + } + $this->_connection = new PDO( + "mysql:{$config['host']};port={$config['port']};dbname={$config['database']}", + $config['login'], + $config['password'], + $flags + ); + $this->connected = true; + } catch (PDOException $e) { + $this->errors[] = $e->getMessage(); + } + + $this->_useAlias = (bool)version_compare($this->getVersion(), "4.1", ">="); + + return $this->connected; + } + + public function getConnection() { + return $this->_connection; + } + +/** + * Check whether the MySQL extension is installed/loaded + * + * @return boolean + */ + function enabled() { + return in_array('mysql', PDO::getAvailableDrivers()); + } +/** + * Disconnects from database. + * + * @return boolean True if the database could be disconnected, else false + */ + function disconnect() { + if (isset($this->results) && is_resource($this->results)) { + mysql_free_result($this->results); + } + $this->connected = !@mysql_close($this->connection); + return !$this->connected; + } + +/** + * Returns an array of sources (tables) in the database. + * + * @return array Array of tablenames in the database + */ + function listSources() { + $cache = parent::listSources(); + if ($cache != null) { + return $cache; + } + $result = $this->_execute('SHOW TABLES FROM ' . $this->config['database']); + + if (!$result) { + return array(); + } else { + $tables = array(); + + while ($line = $result->fetch()) { + $tables[] = $line[0]; + } + parent::listSources($tables); + return $tables; + } + } + +/** + * Returns a quoted and escaped string of $data for use in an SQL statement. + * + * @param string $data String to be prepared for use in an SQL statement + * @param string $column The column into which this data will be inserted + * @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided + * @return string Quoted and escaped data + */ + function value($data, $column = null, $safe = false) { + $parent = parent::value($data, $column, $safe); + + if ($parent != null) { + return $parent; + } + if ($data === null || (is_array($data) && empty($data))) { + return $this->_connection->quote($data, PDO::PARAM_NULL); + } + if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') { + return $this->_connection->quote($data, PDO::PARAM_STR); + } + if (empty($column)) { + $column = $this->introspectType($data); + } + + switch ($column) { + case 'boolean': + return $this->boolean((bool)$data); + break; + case 'integer': + case 'float': + if ($data === '') { + return 'NULL'; + } + if (is_float($data)) { + return sprintf('%F', $data); + } + if ((is_int($data) || $data === '0') || ( + is_numeric($data) && strpos($data, ',') === false && + $data[0] != '0' && strpos($data, 'e') === false) + ) { + return $data; + } + default: + return $this->_connection->quote($data, PDO::PARAM_STR); + break; + } + } + +/** + * Returns a formatted error message from previous database operation. + * + * @return string Error message with error number + */ + function lastError() { + if ($this->hasResult()) { + $error = $this->_result->errorInfo(); + if (empty($error)) { + $error; + } + return $error[1] . ': ' . $error[2]; + } + return null; + } + +/** + * Returns number of affected rows in previous database operation. If no previous operation exists, + * this returns false. + * + * @return integer Number of affected rows + */ + function lastAffected() { + if ($this->hasResult()) { + return $this->_result->rowCount(); + } + return null; + } + +/** + * Returns number of rows in previous resultset. If no previous resultset exists, + * this returns false. + * + * @return integer Number of rows in resultset + */ + function lastNumRows() { + if ($this->hasResult()) { + return mysql_num_rows($this->_result); + } + return null; + } + +/** + * Returns the ID generated from the previous INSERT operation. + * + * @param unknown_type $source + * @return in + */ + function lastInsertId($source = null) { + $id = $this->fetchRow('SELECT LAST_INSERT_ID() AS insertID', false); + if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0]['insertID'])) { + return $id[0]['insertID']; + } + + return null; + } + +/** + * Enter description here... + * + * @param unknown_type $results + */ + function resultSet(&$results) { + if (isset($this->results) && is_resource($this->results) && $this->results != $results) { + mysql_free_result($this->results); + } + $this->results =& $results; + $this->map = array(); + $numFields = mysql_num_fields($results); + $index = 0; + $j = 0; + + while ($j < $numFields) { + $column = mysql_fetch_field($results, $j); + if (!empty($column->table) && strpos($column->name, $this->virtualFieldSeparator) === false) { + $this->map[$index++] = array($column->table, $column->name); + } else { + $this->map[$index++] = array(0, $column->name); + } + $j++; + } + } + +/** + * Fetches the next row from the current result set + * + * @return unknown + */ + function fetchResult() { + if ($row = mysql_fetch_row($this->results)) { + $resultRow = array(); + $i = 0; + foreach ($row as $index => $field) { + list($table, $column) = $this->map[$index]; + $resultRow[$table][$column] = $row[$index]; + $i++; + } + return $resultRow; + } else { + return false; + } + } + +/** + * Gets the database encoding + * + * @return string The database encoding + */ + public function getEncoding() { + return $this->_execute('SHOW VARIABLES LIKE ?', array('character_set_client'))->fetchObject()->Value; + } + +/** + * Gets the version string of the database server + * + * @return string The database encoding + */ + public function getVersion() { + return $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION); + } + +/** + * Query charset by collation + * + * @param string $name Collation name + * @return string Character set name + */ + public function getCharsetName($name) { + if ((bool)version_compare($this->getVersion(), "5", ">=")) { + $r = $this->_execute('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME = ?', array($name)); + $cols = $r->fetchArray(); + if (isset($cols['COLLATIONS']['CHARACTER_SET_NAME'])) { + return $cols['COLLATIONS']['CHARACTER_SET_NAME']; + } + } + return false; + } + /** * Returns an array of the fields in given table name. * @@ -506,327 +797,3 @@ class DboMysqlBase extends DboSource { return 'text'; } } - -/** - * MySQL DBO driver object - * - * Provides connection and SQL generation for MySQL RDMS - * - * @package cake - * @subpackage cake.cake.libs.model.datasources.dbo - */ -class DboMysql extends DboMysqlBase { - -/** - * Datasource description - * - * @var string - */ - public $description = "MySQL DBO Driver"; - -/** - * Base configuration settings for MySQL driver - * - * @var array - */ - protected $_baseConfig = array( - 'persistent' => true, - 'host' => 'localhost', - 'login' => 'root', - 'password' => '', - 'database' => 'cake', - 'port' => '3306' - ); - -/** - * Reference to the PDO object connection - * - * @var PDO $_connection - */ - protected $_connection = null; - -/** - * Connects to the database using options in the given configuration array. - * - * @return boolean True if the database could be connected, else false - */ - function connect() { - $config = $this->config; - $this->connected = false; - try { - $flags = array( - PDO::ATTR_PERSISTENT => $config['persistent'], - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true - ); - if (!empty($config['encoding'])) { - $flags[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $config['encoding']; - } - $this->_connection = new PDO( - "mysql:{$config['host']};port={$config['port']};dbname={$config['database']}", - $config['login'], - $config['password'], - $flags - ); - $this->connected = true; - } catch (PDOException $e) { - $this->errors[] = $e->getMessage(); - } - - $this->_useAlias = (bool)version_compare($this->getVersion(), "4.1", ">="); - - return $this->connected; - } - - public function getConnection() { - return $this->_connection; - } - -/** - * Check whether the MySQL extension is installed/loaded - * - * @return boolean - */ - function enabled() { - return in_array('mysql', PDO::getAvailableDrivers()); - } -/** - * Disconnects from database. - * - * @return boolean True if the database could be disconnected, else false - */ - function disconnect() { - if (isset($this->results) && is_resource($this->results)) { - mysql_free_result($this->results); - } - $this->connected = !@mysql_close($this->connection); - return !$this->connected; - } - -/** - * Executes given SQL statement. - * - * @param string $sql SQL statement - * @param array $params list of params to be bound to query - * @return PDOStatement if query executes with no problem, false otherwise - */ - protected function _execute($sql, $params = array()) { - $query = $this->_connection->prepare($sql); - $query->setFetchMode(PDO::FETCH_LAZY); - if (!$query->execute($params)) { - $this->errors[] = $query->errorInfo(); - return false; - } - return $query; - } - -/** - * Returns an array of sources (tables) in the database. - * - * @return array Array of tablenames in the database - */ - function listSources() { - $cache = parent::listSources(); - if ($cache != null) { - return $cache; - } - $result = $this->_execute('SHOW TABLES FROM ' . $this->config['database']); - - if (!$result) { - return array(); - } else { - $tables = array(); - - while ($line = $result->fetch()) { - $tables[] = $line[0]; - } - parent::listSources($tables); - return $tables; - } - } - -/** - * Returns a quoted and escaped string of $data for use in an SQL statement. - * - * @param string $data String to be prepared for use in an SQL statement - * @param string $column The column into which this data will be inserted - * @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided - * @return string Quoted and escaped data - */ - function value($data, $column = null, $safe = false) { - $parent = parent::value($data, $column, $safe); - - if ($parent != null) { - return $parent; - } - if ($data === null || (is_array($data) && empty($data))) { - return $this->_connection->quote($data, PDO::PARAM_NULL); - } - if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') { - return $this->_connection->quote($data, PDO::PARAM_STR); - } - if (empty($column)) { - $column = $this->introspectType($data); - } - - switch ($column) { - case 'boolean': - return $this->boolean((bool)$data); - break; - case 'integer': - case 'float': - if ($data === '') { - return 'NULL'; - } - if (is_float($data)) { - return sprintf('%F', $data); - } - if ((is_int($data) || $data === '0') || ( - is_numeric($data) && strpos($data, ',') === false && - $data[0] != '0' && strpos($data, 'e') === false) - ) { - return $data; - } - default: - return $this->_connection->quote($data, PDO::PARAM_STR); - break; - } - } - -/** - * Returns a formatted error message from previous database operation. - * - * @return string Error message with error number - */ - function lastError() { - if ($this->hasResult()) { - $error = $this->_result->errorInfo(); - if (empty($error)) { - $error; - } - return $error[1] . ': ' . $error[2]; - } - return null; - } - -/** - * Returns number of affected rows in previous database operation. If no previous operation exists, - * this returns false. - * - * @return integer Number of affected rows - */ - function lastAffected() { - if ($this->hasResult()) { - return $this->_result->rowCount(); - } - return null; - } - -/** - * Returns number of rows in previous resultset. If no previous resultset exists, - * this returns false. - * - * @return integer Number of rows in resultset - */ - function lastNumRows() { - if ($this->hasResult()) { - return mysql_num_rows($this->_result); - } - return null; - } - -/** - * Returns the ID generated from the previous INSERT operation. - * - * @param unknown_type $source - * @return in - */ - function lastInsertId($source = null) { - $id = $this->fetchRow('SELECT LAST_INSERT_ID() AS insertID', false); - if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0]['insertID'])) { - return $id[0]['insertID']; - } - - return null; - } - -/** - * Enter description here... - * - * @param unknown_type $results - */ - function resultSet(&$results) { - if (isset($this->results) && is_resource($this->results) && $this->results != $results) { - mysql_free_result($this->results); - } - $this->results =& $results; - $this->map = array(); - $numFields = mysql_num_fields($results); - $index = 0; - $j = 0; - - while ($j < $numFields) { - $column = mysql_fetch_field($results, $j); - if (!empty($column->table) && strpos($column->name, $this->virtualFieldSeparator) === false) { - $this->map[$index++] = array($column->table, $column->name); - } else { - $this->map[$index++] = array(0, $column->name); - } - $j++; - } - } - -/** - * Fetches the next row from the current result set - * - * @return unknown - */ - function fetchResult() { - if ($row = mysql_fetch_row($this->results)) { - $resultRow = array(); - $i = 0; - foreach ($row as $index => $field) { - list($table, $column) = $this->map[$index]; - $resultRow[$table][$column] = $row[$index]; - $i++; - } - return $resultRow; - } else { - return false; - } - } - -/** - * Gets the database encoding - * - * @return string The database encoding - */ - public function getEncoding() { - return $this->_execute('SHOW VARIABLES LIKE ?', array('character_set_client'))->fetchObject()->Value; - } - -/** - * Gets the version string of the database server - * - * @return string The database encoding - */ - public function getVersion() { - return $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION); - } - -/** - * Query charset by collation - * - * @param string $name Collation name - * @return string Character set name - */ - public function getCharsetName($name) { - if ((bool)version_compare($this->getVersion(), "5", ">=")) { - $r = $this->_execute('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME = ?', array($name)); - $cols = $r->fetchArray(); - if (isset($cols['COLLATIONS']['CHARACTER_SET_NAME'])) { - return $cols['COLLATIONS']['CHARACTER_SET_NAME']; - } - } - return false; - } -} diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 8731aa865..2ea57ee62 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -262,6 +262,25 @@ class DboSource extends DataSource { return $this->_result; } +/** + * Executes given SQL statement. + * + * @param string $sql SQL statement + * @param array $params list of params to be bound to query + * @return PDOStatement if query executes with no problem, false otherwise + */ + protected function _execute($sql, $params = array()) { + $query = $this->_connection->prepare($sql); + $query->setFetchMode(PDO::FETCH_LAZY); + if (!$query->execute($params)) { + debug($query->errorInfo()); + $this->error = $this->lastError(); + return false; + } + + return $query; + } + /** * DataSource Query abstraction * From 21f5707be7557bc44aed3d033bd8d57210e76985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 15 Oct 2010 19:17:52 -0430 Subject: [PATCH 014/378] Implementing disconnection in DboMysql --- cake/libs/model/datasources/dbo/dbo_mysql.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 625446ac5..087f28038 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -183,10 +183,11 @@ class DboMysql extends DboSource { * @return boolean True if the database could be disconnected, else false */ function disconnect() { - if (isset($this->results) && is_resource($this->results)) { - mysql_free_result($this->results); + if (is_a($this->_result, 'PDOStatement')) { + $this->_result->closeCursor(); } - $this->connected = !@mysql_close($this->connection); + unset($this->_connection); + $this->connected = false; return !$this->connected; } From a5f3f95e3a994bba6a286e5cad34627837e86316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sat, 16 Oct 2010 09:32:01 -0430 Subject: [PATCH 015/378] Simplifying DboMysql::getCharsetName() --- cake/libs/model/datasources/dbo/dbo_mysql.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 087f28038..25865e0bb 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -394,9 +394,10 @@ class DboMysql extends DboSource { public function getCharsetName($name) { if ((bool)version_compare($this->getVersion(), "5", ">=")) { $r = $this->_execute('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME = ?', array($name)); - $cols = $r->fetchArray(); - if (isset($cols['COLLATIONS']['CHARACTER_SET_NAME'])) { - return $cols['COLLATIONS']['CHARACTER_SET_NAME']; + $cols = $r->fetch(); + + if (isset($cols['CHARACTER_SET_NAME'])) { + return $cols['CHARACTER_SET_NAME']; } } return false; From f772527445530d2c05cd12b8ece011d7c989232a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sat, 16 Oct 2010 09:34:29 -0430 Subject: [PATCH 016/378] Using PDO method to get lastInsertId --- cake/libs/model/datasources/dbo/dbo_mysql.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 25865e0bb..beb0f64af 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -313,12 +313,7 @@ class DboMysql extends DboSource { * @return in */ function lastInsertId($source = null) { - $id = $this->fetchRow('SELECT LAST_INSERT_ID() AS insertID', false); - if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0]['insertID'])) { - return $id[0]['insertID']; - } - - return null; + return $this->_connection->lastInsertId(); } /** From cb16605805ae85d6df7eca3ec6cd83acd415dda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sat, 16 Oct 2010 10:22:50 -0430 Subject: [PATCH 017/378] Fetching result rows PDO style --- cake/libs/model/datasources/dbo/dbo_mysql.php | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index beb0f64af..b4aca017d 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -317,26 +317,26 @@ class DboMysql extends DboSource { } /** - * Enter description here... + * Builds a map of the columns contained in a result * - * @param unknown_type $results + * @param PDOStatement $results */ - function resultSet(&$results) { - if (isset($this->results) && is_resource($this->results) && $this->results != $results) { - mysql_free_result($this->results); - } - $this->results =& $results; + function resultSet($results) { + //if (isset($this->results) && is_resource($this->results) && $this->results != $results) { + // mysql_free_result($this->results); + //} + $this->results = $results; $this->map = array(); - $numFields = mysql_num_fields($results); + $numFields = $results->columnCount(); $index = 0; $j = 0; while ($j < $numFields) { - $column = mysql_fetch_field($results, $j); - if (!empty($column->table) && strpos($column->name, $this->virtualFieldSeparator) === false) { - $this->map[$index++] = array($column->table, $column->name); + $column = $results->getColumnMeta($j); + if (!empty($column['table']) && strpos($column['name'], $this->virtualFieldSeparator) === false) { + $this->map[$index++] = array($column['table'], $column['name']); } else { - $this->map[$index++] = array(0, $column->name); + $this->map[$index++] = array(0, $column['name']); } $j++; } @@ -345,16 +345,15 @@ class DboMysql extends DboSource { /** * Fetches the next row from the current result set * - * @return unknown + * @return mixed array with results fetched and mapped to column names or false if there is no results left to fetch */ function fetchResult() { - if ($row = mysql_fetch_row($this->results)) { + if ($row = $this->results->fetch()) { $resultRow = array(); - $i = 0; - foreach ($row as $index => $field) { - list($table, $column) = $this->map[$index]; - $resultRow[$table][$column] = $row[$index]; - $i++; + + foreach ($this->map as $col => $meta) { + list($table, $column) = $meta; + $resultRow[$table][$column] = $row->{$meta[1]}; } return $resultRow; } else { From e03cbcb1676842faa625cca3e582e6035ae1f100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sat, 16 Oct 2010 10:23:13 -0430 Subject: [PATCH 018/378] Fixing model describing and making pass testBlobSaving --- cake/libs/model/datasources/dbo/dbo_mysql.php | 44 ++++++++----------- .../model/datasources/dbo/dbo_mysql.test.php | 6 ++- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index b4aca017d..9b0c2cff2 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -400,42 +400,36 @@ class DboMysql extends DboSource { /** * Returns an array of the fields in given table name. * - * @param string $tableName Name of database table to inspect + * @param mixed $tableName Name of database table to inspect or model instance * @return array Fields in table. Keys are name and type */ - function describe(&$model) { + function describe($model) { $cache = parent::describe($model); if ($cache != null) { return $cache; } $fields = false; - $cols = $this->query('SHOW FULL COLUMNS FROM ' . $this->fullTableName($model)); + $cols = $this->_execute('SHOW FULL COLUMNS FROM ' . $this->fullTableName($model)); foreach ($cols as $column) { - $colKey = array_keys($column); - if (isset($column[$colKey[0]]) && !isset($column[0])) { - $column[0] = $column[$colKey[0]]; + $fields[$column->Field] = array( + 'type' => $this->column($column->Type), + 'null' => ($column->Null == 'YES' ? true : false), + 'default' => $column->Default, + 'length' => $this->length($column->Type), + ); + if (!empty($column->Key) && isset($this->index[$column->Key])) { + $fields[$column->Field]['key'] = $this->index[$column->Key]; } - if (isset($column[0])) { - $fields[$column[0]['Field']] = array( - 'type' => $this->column($column[0]['Type']), - 'null' => ($column[0]['Null'] == 'YES' ? true : false), - 'default' => $column[0]['Default'], - 'length' => $this->length($column[0]['Type']), - ); - if (!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) { - $fields[$column[0]['Field']]['key'] = $this->index[$column[0]['Key']]; + foreach ($this->fieldParameters as $name => $value) { + if (!empty($column->{$value['column']})) { + $fields[$column->Field][$name] = $column[0][$value['column']]; } - foreach ($this->fieldParameters as $name => $value) { - if (!empty($column[0][$value['column']])) { - $fields[$column[0]['Field']][$name] = $column[0][$value['column']]; - } - } - if (isset($fields[$column[0]['Field']]['collate'])) { - $charset = $this->getCharsetName($fields[$column[0]['Field']]['collate']); - if ($charset) { - $fields[$column[0]['Field']]['charset'] = $charset; - } + } + if (isset($fields[$column->Field]['collate'])) { + $charset = $this->getCharsetName($fields[$column->Field]['collate']); + if ($charset) { + $fields[$column->Field]['charset'] = $charset; } } } diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 418f17a25..76d294d7e 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -158,7 +158,8 @@ class MysqlTestModel extends Model { * @subpackage cake.tests.cases.libs.model.datasources.dbo */ class DboMysqlTest extends CakeTestCase { - //public $fixtures = array('core.binary_test'); + public $fixtures = array('core.binary_test'); + public $autoFixtures = false; /** * The Dbo instance to be tested * @@ -668,13 +669,14 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testBlobSaving() { + $this->loadFixtures('BinaryTest'); $this->Dbo->cacheSources = false; $data = "GIF87ab Ò4A¿¿¿ˇˇˇ,b ¢îè©ÀÌ#¥⁄ã≥fi:¯Ü‚Héá¶jV∂ÓúÎL≥çÀóËıÎ…>ï≈ vFE%ÒâLFI<†µw˝±≈£7˘ç^H“≤« >Éâ*∑ÇnÖA•Ù|flêèj£:=ÿ6óUàµ5'∂®àA¬ñ∆ˆGE(gt’≈àÚyÁó«7 ‚VìöÇ√˙Ç™ k”:;kÀAõ{*¡€Î˚˚[;;"; - $model = new AppModel(array('name' => 'BinaryTest', 'ds' => 'test')); + $model = new CakeTestModel(array('name' => 'BinaryTest', 'ds' => 'test')); $model->save(compact('data')); $result = $model->find('first'); From 84283ed6f3ecd895cfa39b762ec28373d65dab5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sat, 16 Oct 2010 13:28:18 -0430 Subject: [PATCH 019/378] Fixing DboMysql::listDetailedSources() --- cake/libs/model/datasources/dbo/dbo_mysql.php | 19 +++++++++------ .../model/datasources/dbo/dbo_mysql.test.php | 24 +++++++++---------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 9b0c2cff2..af2d6ebee 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -707,6 +707,7 @@ class DboMysql extends DboSource { $values = implode(', ', $values); $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values}"); } + /** * Returns an detailed array of sources (tables) in the database. * @@ -715,20 +716,24 @@ class DboMysql extends DboSource { */ function listDetailedSources($name = null) { $condition = ''; + $params = array(); if (is_string($name)) { - $condition = ' LIKE ' . $this->value($name); + $condition = ' WHERE name = ?' ; + $params = array($name); } - $result = $this->query('SHOW TABLE STATUS FROM ' . $this->name($this->config['database']) . $condition . ';'); + $result = $this->_execute('SHOW TABLE STATUS ' . $condition, $params); + if (!$result) { return array(); } else { $tables = array(); - foreach ($result as $row) { - $tables[$row['TABLES']['Name']] = $row['TABLES']; - if (!empty($row['TABLES']['Collation'])) { - $charset = $this->getCharsetName($row['TABLES']['Collation']); + while ($row = $result->fetch()) { + $tables[$row->Name] = (array) $row; + unset($tables[$row->Name]['queryString']); + if (!empty($row->Collation)) { + $charset = $this->getCharsetName($row->Collation); if ($charset) { - $tables[$row['TABLES']['Name']]['charset'] = $charset; + $tables[$row->Name]['charset'] = $charset; } } } diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 76d294d7e..32471c21f 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -705,7 +705,7 @@ class DboMysqlTest extends CakeTestCase { ) ) )); - $this->Dbo->query($this->Dbo->createSchema($schema1)); + $this->Dbo->rawQuery($this->Dbo->createSchema($schema1)); $schema2 = new CakeSchema(array( 'name' => 'AlterTest1', 'connection' => 'test', @@ -720,17 +720,17 @@ class DboMysqlTest extends CakeTestCase { ) )); $result = $this->Dbo->alterSchema($schema2->compare($schema1)); - $this->assertPattern('/DEFAULT CHARSET=utf8/', $result); - $this->assertPattern('/ENGINE=InnoDB/', $result); - $this->assertPattern('/COLLATE=utf8_general_ci/', $result); + $this->assertContains('DEFAULT CHARSET=utf8', $result); + $this->assertContains('ENGINE=InnoDB', $result); + $this->assertContains('COLLATE=utf8_general_ci', $result); - $this->Dbo->query($result); + $this->Dbo->rawQuery($result); $result = $this->Dbo->listDetailedSources('altertest'); $this->assertEqual($result['Collation'], 'utf8_general_ci'); $this->assertEqual($result['Engine'], 'InnoDB'); $this->assertEqual($result['charset'], 'utf8'); - $this->Dbo->query($this->Dbo->dropSchema($schema1)); + $this->Dbo->rawQuery($this->Dbo->dropSchema($schema1)); } /** @@ -739,7 +739,7 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testAlteringTwoTables() { - $schema1 =& new CakeSchema(array( + $schema1 = new CakeSchema(array( 'name' => 'AlterTest1', 'connection' => 'test', 'altertest' => array( @@ -751,7 +751,7 @@ class DboMysqlTest extends CakeTestCase { 'name' => array('type' => 'string', 'null' => false, 'length' => 50), ) )); - $schema2 =& new CakeSchema(array( + $schema2 = new CakeSchema(array( 'name' => 'AlterTest1', 'connection' => 'test', 'altertest' => array( @@ -776,23 +776,23 @@ class DboMysqlTest extends CakeTestCase { function testReadTableParameters() { $this->Dbo->cacheSources = $this->Dbo->testing = false; $tableName = 'tinyint_' . uniqid(); - $this->Dbo->query('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'); + $this->Dbo->rawQuery('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'); $result = $this->Dbo->readTableParameters($tableName); + $this->Dbo->rawQuery('DROP TABLE ' . $this->Dbo->fullTableName($tableName)); $expected = array( 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci', 'engine' => 'InnoDB'); $this->assertEqual($result, $expected); - $this->Dbo->query('DROP TABLE ' . $this->Dbo->fullTableName($tableName)); - $this->Dbo->query('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci;'); + $this->Dbo->rawQuery('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci;'); $result = $this->Dbo->readTableParameters($tableName); + $this->Dbo->rawQuery('DROP TABLE ' . $this->Dbo->fullTableName($tableName)); $expected = array( 'charset' => 'cp1250', 'collate' => 'cp1250_general_ci', 'engine' => 'MyISAM'); $this->assertEqual($result, $expected); - $this->Dbo->query('DROP TABLE ' . $this->Dbo->fullTableName($tableName)); } /** From 17f24719ee1208c726e71b6262f45e764dc44f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sat, 16 Oct 2010 13:32:59 -0430 Subject: [PATCH 020/378] Replacing reference assignation for normal assignation in test case --- .../tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 32471c21f..69122556b 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -852,7 +852,7 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testDescribeGettingFieldParameters() { - $schema =& new CakeSchema(array( + $schema = new CakeSchema(array( 'connection' => 'test', 'testdescribes' => array( 'id' => array('type' => 'integer', 'key' => 'primary'), @@ -872,7 +872,7 @@ class DboMysqlTest extends CakeTestCase { )); $this->db->execute($this->db->createSchema($schema)); - $model =& new CakeTestModel(array('table' => 'testdescribes', 'name' => 'Testdescribes')); + $model = new CakeTestModel(array('table' => 'testdescribes', 'name' => 'Testdescribes')); $result = $this->db->describe($model); $this->assertEqual($result['stringy']['collate'], 'cp1250_general_ci'); $this->assertEqual($result['stringy']['charset'], 'cp1250'); From 88a2fb5058d7c04865fb8c6feec07438f5b8c2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sat, 16 Oct 2010 13:44:16 -0430 Subject: [PATCH 021/378] Fixing bug in DboMysql::describe() --- cake/libs/model/datasources/dbo/dbo_mysql.php | 2 +- .../cases/libs/model/datasources/dbo/dbo_mysql.test.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index af2d6ebee..5b812e8a1 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -423,7 +423,7 @@ class DboMysql extends DboSource { } foreach ($this->fieldParameters as $name => $value) { if (!empty($column->{$value['column']})) { - $fields[$column->Field][$name] = $column[0][$value['column']]; + $fields[$column->Field][$name] = $column->{$value['column']}; } } if (isset($fields[$column->Field]['collate'])) { diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 69122556b..59476def0 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -835,7 +835,8 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testVirtualFieldSeparators() { - $model =& new CakeTestModel(array('table' => 'binary_tests', 'ds' => 'test', 'name' => 'BinaryTest')); + $this->loadFixtures('BinaryTest'); + $model = new CakeTestModel(array('table' => 'binary_tests', 'ds' => 'test', 'name' => 'BinaryTest')); $model->virtualFields = array( 'other__field' => 'SUM(id)' ); @@ -870,15 +871,15 @@ class DboMysqlTest extends CakeTestCase { ) ) )); - $this->db->execute($this->db->createSchema($schema)); + $this->db->execute($this->db->createSchema($schema)); $model = new CakeTestModel(array('table' => 'testdescribes', 'name' => 'Testdescribes')); $result = $this->db->describe($model); + $this->db->execute($this->db->dropSchema($schema)); + $this->assertEqual($result['stringy']['collate'], 'cp1250_general_ci'); $this->assertEqual($result['stringy']['charset'], 'cp1250'); $this->assertEqual($result['other_col']['comment'], 'Test Comment'); - - $this->db->execute($this->db->dropSchema($schema)); } /** From d83c95cf46a40368f8b5db827428eeceb38a169a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sat, 16 Oct 2010 14:01:01 -0430 Subject: [PATCH 022/378] Fixing bug in DboMysql::value() --- cake/libs/model/datasources/dbo/dbo_mysql.php | 2 +- .../cases/libs/model/datasources/dbo/dbo_mysql.test.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 5b812e8a1..178015f35 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -231,7 +231,7 @@ class DboMysql extends DboSource { return $parent; } if ($data === null || (is_array($data) && empty($data))) { - return $this->_connection->quote($data, PDO::PARAM_NULL); + return 'NULL'; } if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') { return $this->_connection->quote($data, PDO::PARAM_STR); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 59476def0..0d879e215 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -277,10 +277,9 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testTinyintCasting() { - $this->skipIf(true, 'Is this a test over the DBO?'); $this->Dbo->cacheSources = false; $tableName = 'tinyint_' . uniqid(); - $this->Dbo->execute('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); + $this->Dbo->rawQuery('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); $this->model = new CakeTestModel(array( 'name' => 'Tinyint', 'table' => $tableName, 'ds' => 'test' @@ -308,7 +307,7 @@ class DboMysqlTest extends CakeTestCase { $this->assertIdentical($result['Tinyint']['small_int'], '0'); $this->model->deleteAll(true); - $this->Dbo->query('DROP TABLE ' . $this->Dbo->fullTableName($tableName)); + $this->Dbo->rawQuery('DROP TABLE ' . $this->Dbo->fullTableName($tableName)); } /** From 082873721cf6cd24e3b85235d6caceb32fee6597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sat, 16 Oct 2010 20:28:07 -0430 Subject: [PATCH 023/378] Changing param order in execute() to maintain compatibility, making all tests pass --- cake/libs/model/datasources/dbo_source.php | 12 +++++++----- .../cases/libs/model/datasources/dbo_source.test.php | 8 ++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index cccc1b8ba..b9d2ec33b 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -235,11 +235,11 @@ class DboSource extends DataSource { * - log - Whether or not the query should be logged to the memory log. * * @param string $sql - * @param array $params values to be bided to the query * @param array $options + * @param array $params values to be bided to the query * @return mixed Resource or object representing the result set, or false on failure */ - public function execute($sql, $params = array(), $options = array()) { + public function execute($sql, $options = array(), $params = array()) { $defaults = array('stats' => true, 'log' => $this->fullDebug); $options = array_merge($defaults, $options); @@ -267,17 +267,19 @@ class DboSource extends DataSource { * * @param string $sql SQL statement * @param array $params list of params to be bound to query - * @return PDOStatement if query executes with no problem, false otherwise + * @return PDOStatement if query executes with no problem, true as the result of a succesfull + * query returning no rows, suchs as a CREATE statement, false otherwise */ protected function _execute($sql, $params = array()) { $query = $this->_connection->prepare($sql); $query->setFetchMode(PDO::FETCH_LAZY); if (!$query->execute($params)) { - debug($query->errorInfo()); $this->error = $this->lastError(); return false; } - + if (!$query->columnCount()) { + return true; + } return $query; } diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 3cf6777cf..8eca739b1 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -4220,11 +4220,11 @@ class DboSourceTest extends CakeTestCase { $name = $this->db->fullTableName('test_query'); $query = "CREATE TABLE {$name} (name varchar(10));"; $result = $this->db->query($query); - $this->assertTrue($result, 'Query did not return a boolean. %s'); + $this->assertTrue($result, 'Query did not return a boolean'); $query = "DROP TABLE {$name};"; - $result = $this->db->fetchAll($query); - $this->assertTrue($result, 'Query did not return a boolean. %s'); + $result = $this->db->query($query); + $this->assertTrue($result, 'Query did not return a boolean'); } /** @@ -4563,7 +4563,7 @@ class DboSourceTest extends CakeTestCase { ConnectionManager::create('test_no_queryAssociation', array( 'datasource' => 'data' )); - $Article =& ClassRegistry::init('Article'); + $Article = ClassRegistry::init('Article'); $Article->Comment->useDbConfig = 'test_no_queryAssociation'; $result = $Article->find('all'); $this->assertTrue(is_array($result)); From 642bfe35760ee3e0d9dd3324c0f13b73e84465fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 10:15:40 -0430 Subject: [PATCH 024/378] Fixing some problem on fetching result data with multiple columns with same name --- cake/libs/model/datasources/dbo/dbo_mysql.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 178015f35..707d0cbeb 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -350,10 +350,9 @@ class DboMysql extends DboSource { function fetchResult() { if ($row = $this->results->fetch()) { $resultRow = array(); - foreach ($this->map as $col => $meta) { list($table, $column) = $meta; - $resultRow[$table][$column] = $row->{$meta[1]}; + $resultRow[$table][$column] = $row[$col]; } return $resultRow; } else { From 183e9c92dfb353f5b5993a370c03d015f1679a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 10:18:46 -0430 Subject: [PATCH 025/378] Removing some asignations by reference --- .../model/datasources/dbo_source.test.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 8eca739b1..0b40997ae 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -2048,7 +2048,7 @@ class DboSourceTest extends CakeTestCase { * @return void */ function testGenerateAssociationQueryHasManyAndAggregateFunction() { - $this->Model =& new TestModel5(); + $this->Model = new TestModel5(); $this->Model->schema(); $this->_buildRelatedModels($this->Model); @@ -4319,7 +4319,7 @@ class DboSourceTest extends CakeTestCase { * @return void */ function testVirtualFieldsInConditions() { - $Article =& ClassRegistry::init('Article'); + $Article = ClassRegistry::init('Article'); $Article->virtualFields = array( 'this_moment' => 'NOW()', 'two' => '1 + 1', @@ -4353,7 +4353,7 @@ class DboSourceTest extends CakeTestCase { * @return void */ function testConditionsWithComplexVirtualFields() { - $Article =& ClassRegistry::init('Article'); + $Article = ClassRegistry::init('Article'); $Article->virtualFields = array( 'distance' => 'ACOS(SIN(20 * PI() / 180) * SIN(Article.latitude * PI() / 180) @@ -4376,7 +4376,7 @@ class DboSourceTest extends CakeTestCase { * @return void */ function testVirtualFieldsInOrder() { - $Article =& ClassRegistry::init('Article'); + $Article = ClassRegistry::init('Article'); $Article->virtualFields = array( 'this_moment' => 'NOW()', 'two' => '1 + 1', @@ -4398,7 +4398,7 @@ class DboSourceTest extends CakeTestCase { * @return void */ function testVirtualFieldsInCalculate() { - $Article =& ClassRegistry::init('Article'); + $Article = ClassRegistry::init('Article'); $Article->virtualFields = array( 'this_moment' => 'NOW()', 'two' => '1 + 1', @@ -4447,9 +4447,9 @@ class DboSourceTest extends CakeTestCase { function testVirtualFieldsComplexRead() { $this->loadFixtures('DataTest', 'Article', 'Comment'); - $Article =& ClassRegistry::init('Article'); + $Article = ClassRegistry::init('Article'); $commentTable = $this->db->fullTableName('comments'); - $Article =& ClassRegistry::init('Article'); + $Article = ClassRegistry::init('Article'); $Article->virtualFields = array( 'comment_count' => 'SELECT COUNT(*) FROM ' . $commentTable . ' AS Comment WHERE Article.id = Comment.article_id' @@ -4458,7 +4458,7 @@ class DboSourceTest extends CakeTestCase { $this->assertTrue(count($result) > 0); $this->assertTrue($result[0]['Article']['comment_count'] > 0); - $DataTest =& ClassRegistry::init('DataTest'); + $DataTest = ClassRegistry::init('DataTest'); $DataTest->virtualFields = array( 'complicated' => 'ACOS(SIN(20 * PI() / 180) * SIN(DataTest.float * PI() / 180) @@ -4478,7 +4478,7 @@ class DboSourceTest extends CakeTestCase { * @return void */ function testFieldsWithComplexVirtualFields() { - $Article =& new Article(); + $Article = new Article(); $Article->virtualFields = array( 'distance' => 'ACOS(SIN(20 * PI() / 180) * SIN(Article.latitude * PI() / 180) @@ -4505,7 +4505,7 @@ class DboSourceTest extends CakeTestCase { * @return void */ function testReadVirtualFieldsWithNewLines() { - $Article =& new Article(); + $Article = new Article(); $Article->recursive = 1; $Article->virtualFields = array( 'test' => ' @@ -4523,7 +4523,7 @@ class DboSourceTest extends CakeTestCase { * @return void */ function testVirtualFieldsInGroup() { - $Article =& ClassRegistry::init('Article'); + $Article = ClassRegistry::init('Article'); $Article->virtualFields = array( 'this_year' => 'YEAR(Article.created)' ); @@ -4540,7 +4540,7 @@ class DboSourceTest extends CakeTestCase { * @return void */ function testFullTablePermutations() { - $Article =& ClassRegistry::init('Article'); + $Article = ClassRegistry::init('Article'); $result = $this->testDb->fullTableName($Article, false); $this->assertEqual($result, 'articles'); From 65a641af23f35120e92a9d56de050e31aac591f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 10:29:01 -0430 Subject: [PATCH 026/378] Improving fetchAll method to accept an array of aprameters to be bound to the query, so now it is possible to use proper prepared statements --- cake/libs/model/datasources/dbo_source.php | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index b9d2ec33b..80e121b0f 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -373,8 +373,7 @@ class DboSource extends DataSource { } else { $cache = true; } - $args[1] = array_map(array(&$this, 'value'), $args[1]); - return $this->fetchAll(String::insert($args[0], $args[1]), $cache); + return $this->fetchAll($args[0], $args[1], array('cache' => $cache)); } } } @@ -407,16 +406,31 @@ class DboSource extends DataSource { * Returns an array of all result rows for a given SQL query. * Returns false if no rows matched. * + * + * ### Options + * + * - cache - Returns the cached version of the query, if exists and stores the result in cache + * * @param string $sql SQL statement - * @param boolean $cache Enables returning/storing cached query results + * @param array $params parameters to be bound as values for the SQL statement + * @param array $options additional options for the query. * @return array Array of resultset rows, or false if no rows matched */ - public function fetchAll($sql, $cache = true, $modelName = null) { + public function fetchAll($sql, $params = array(), $options = array()) { + if (is_string($options)) { + $options = array('modelName' => $options); + } + if (is_bool($params)) { + $options['cache'] = $params; + $params = array(); + } + $defaults = array('cache' => true); + $options = $options + $defaults; + $cache = $options['cache']; if ($cache && ($cached = $this->getQueryCache($sql)) !== false) { return $cached; } - - if ($this->execute($sql)) { + if ($this->execute($sql, array(), $params)) { $out = array(); $first = $this->fetchRow(); From 097191213b0443ac8313f55109106aa51aaff63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 10:32:02 -0430 Subject: [PATCH 027/378] Removing use of third parameter of fetchAll() --- cake/libs/model/datasources/dbo_source.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 80e121b0f..9f26b378c 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -832,7 +832,7 @@ class DboSource extends DataSource { $query = $this->generateAssociationQuery($model, $null, null, null, null, $queryData, false, $null); - $resultSet = $this->fetchAll($query, $model->cacheQueries, $model->alias); + $resultSet = $this->fetchAll($query, $model->cacheQueries); if ($resultSet === false) { $model->onError(); @@ -1001,7 +1001,7 @@ class DboSource extends DataSource { $q = $this->insertQueryData($query, null, $association, $assocData, $model, $linkModel, $stack); if ($q != false) { - $fetch = $this->fetchAll($q, $model->cacheQueries, $model->alias); + $fetch = $this->fetchAll($q, $model->cacheQueries); } else { $fetch = null; } @@ -1013,7 +1013,7 @@ class DboSource extends DataSource { if ($type !== 'hasAndBelongsToMany') { $q = $this->insertQueryData($query, $resultSet[$i], $association, $assocData, $model, $linkModel, $stack); if ($q != false) { - $fetch = $this->fetchAll($q, $model->cacheQueries, $model->alias); + $fetch = $this->fetchAll($q, $model->cacheQueries); } else { $fetch = null; } @@ -1088,7 +1088,7 @@ class DboSource extends DataSource { if (count($ids) > 1) { $query = str_replace('= (', 'IN (', $query); } - return $this->fetchAll($query, $model->cacheQueries, $model->alias); + return $this->fetchAll($query, $model->cacheQueries); } /** From 7e2fe43ee3fd4e4772e93f7df266ac69240d71d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 10:51:54 -0430 Subject: [PATCH 028/378] FIxing query caching to take in account bound parameters --- cake/libs/model/datasources/dbo_source.php | 19 ++++++++++------- .../cases/libs/model/model_read.test.php | 21 +++---------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 9f26b378c..de060fb44 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -427,7 +427,7 @@ class DboSource extends DataSource { $defaults = array('cache' => true); $options = $options + $defaults; $cache = $options['cache']; - if ($cache && ($cached = $this->getQueryCache($sql)) !== false) { + if ($cache && ($cached = $this->getQueryCache($sql, $params)) !== false) { return $cached; } if ($this->execute($sql, array(), $params)) { @@ -443,7 +443,7 @@ class DboSource extends DataSource { } if ($cache) { - $this->_writeQueryCache($sql, $out); + $this->_writeQueryCache($sql, $out, $params); } if (empty($out) && is_bool($this->_result)) { return $this->_result; @@ -2902,11 +2902,12 @@ class DboSource extends DataSource { * * @param string $sql SQL query * @param mixed $data result of $sql query + * @param array $params query params bound as values * @return void */ - protected function _writeQueryCache($sql, $data) { - if (strpos(trim(strtolower($sql)), 'select') !== false) { - $this->_queryCache[$sql] = $data; + protected function _writeQueryCache($sql, $data, $params = array()) { + if (preg_match('/^\s*select/i', $sql)) { + $this->_queryCache[$sql][serialize($params)] = $data; } } @@ -2914,11 +2915,15 @@ class DboSource extends DataSource { * Returns the result for a sql query if it is already cached * * @param string $sql SQL query + * @param array $params query params bound as values * @return mixed results for query if it is cached, false otherwise */ - public function getQueryCache($sql = null) { + public function getQueryCache($sql, $params = array()) { if (isset($this->_queryCache[$sql]) && preg_match('/^\s*select/i', $sql)) { - return $this->_queryCache[$sql]; + $serialized = serialize($params); + if (isset($this->_queryCache[$sql][$serialized])) { + return $this->_queryCache[$sql][$serialized]; + } } return false; } diff --git a/cake/tests/cases/libs/model/model_read.test.php b/cake/tests/cases/libs/model/model_read.test.php index 1eb3b13f6..68dc9ce31 100755 --- a/cake/tests/cases/libs/model/model_read.test.php +++ b/cake/tests/cases/libs/model/model_read.test.php @@ -279,13 +279,6 @@ class ModelReadTest extends BaseModelTest { $this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag'); $Article = new Article(); - $finalQuery = 'SELECT title, published FROM '; - $finalQuery .= $this->db->fullTableName('articles'); - $finalQuery .= ' WHERE ' . $this->db->fullTableName('articles'); - $finalQuery .= '.id = ' . $this->db->value(1); - $finalQuery .= ' AND ' . $this->db->fullTableName('articles'); - $finalQuery .= '.published = ' . $this->db->value('Y'); - $query = 'SELECT title, published FROM '; $query .= $this->db->fullTableName('articles'); $query .= ' WHERE ' . $this->db->fullTableName('articles'); @@ -305,14 +298,9 @@ class ModelReadTest extends BaseModelTest { } $this->assertEqual($result, $expected); - $result = $this->db->getQueryCache($finalQuery); + $result = $this->db->getQueryCache($query, $params); $this->assertFalse(empty($result)); - $finalQuery = 'SELECT id, created FROM '; - $finalQuery .= $this->db->fullTableName('articles'); - $finalQuery .= ' WHERE ' . $this->db->fullTableName('articles'); - $finalQuery .= '.title = ' . $this->db->value('First Article'); - $query = 'SELECT id, created FROM '; $query .= $this->db->fullTableName('articles'); $query .= ' WHERE ' . $this->db->fullTableName('articles') . '.title = ?'; @@ -324,7 +312,7 @@ class ModelReadTest extends BaseModelTest { isset($result[0][$this->db->fullTableName('articles', false)]) || isset($result[0][0]) ); - $result = $this->db->getQueryCache($finalQuery); + $result = $this->db->getQueryCache($query, $params); $this->assertTrue(empty($result)); $query = 'SELECT title FROM '; @@ -345,10 +333,7 @@ class ModelReadTest extends BaseModelTest { $params = array('First? Article', 'Y'); $Article->query($query, $params); - $expected = 'SELECT title FROM '; - $expected .= $this->db->fullTableName('articles'); - $expected .= " WHERE title = 'First? Article' AND published = 'Y'"; - $result = $this->db->getQueryCache($expected); + $result = $this->db->getQueryCache($query, $params); $this->assertFalse($result === false); } From c016f1d97bc806c4c0268d842f44523d802c06b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 11:28:11 -0430 Subject: [PATCH 029/378] Impriving documentation --- cake/libs/model/datasources/dbo/dbo_mysql.php | 14 ++++++-------- cake/libs/model/datasources/dbo_source.php | 4 +++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 707d0cbeb..75eb18e80 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -267,17 +267,15 @@ class DboMysql extends DboSource { /** * Returns a formatted error message from previous database operation. * + * @param PDOStatement $query the query to extract the error from if any * @return string Error message with error number */ - function lastError() { - if ($this->hasResult()) { - $error = $this->_result->errorInfo(); - if (empty($error)) { - $error; - } - return $error[1] . ': ' . $error[2]; + function lastError(PDOStatement $query = null) { + $error = $query->errorInfo(); + if (empty($error[2])) { + return null; } - return null; + return $error[1] . ': ' . $error[2]; } /** diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index de060fb44..cb64234c3 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -242,6 +242,7 @@ class DboSource extends DataSource { public function execute($sql, $options = array(), $params = array()) { $defaults = array('stats' => true, 'log' => $this->fullDebug); $options = array_merge($defaults, $options); + $this->error = null; $t = microtime(true); $this->_result = $this->_execute($sql, $params); @@ -274,7 +275,8 @@ class DboSource extends DataSource { $query = $this->_connection->prepare($sql); $query->setFetchMode(PDO::FETCH_LAZY); if (!$query->execute($params)) { - $this->error = $this->lastError(); + $this->_results = $query; + $this->error = $this->lastError($query); return false; } if (!$query->columnCount()) { From 78717ab45c0ef1eb373baea43268573e0788bab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 11:29:49 -0430 Subject: [PATCH 030/378] Fixing some test cases --- .../tests/cases/libs/model/model_integration.test.php | 11 ++++++----- cake/tests/cases/libs/model/model_write.test.php | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cake/tests/cases/libs/model/model_integration.test.php b/cake/tests/cases/libs/model/model_integration.test.php index 5790ec344..292929b46 100644 --- a/cake/tests/cases/libs/model/model_integration.test.php +++ b/cake/tests/cases/libs/model/model_integration.test.php @@ -184,7 +184,7 @@ class ModelIntegrationTest extends BaseModelTest { */ function testPkInHabtmLinkModel() { //Test Nonconformant Models - $this->loadFixtures('Content', 'ContentAccount', 'Account', 'JoinC', 'JoinAC'); + $this->loadFixtures('Content', 'ContentAccount', 'Account', 'JoinC', 'JoinAC', 'ItemsPortfolio'); $TestModel = new Content(); $this->assertEqual($TestModel->ContentAccount->primaryKey, 'iContentAccountsId'); @@ -1867,7 +1867,7 @@ class ModelIntegrationTest extends BaseModelTest { * @return void */ function testCreation() { - $this->loadFixtures('Article', 'ArticleFeaturedsTags'); + $this->loadFixtures('Article', 'ArticleFeaturedsTags', 'User', 'Featured'); $TestModel = new Test(); $result = $TestModel->create(); $expected = array('Test' => array('notes' => 'write some notes here')); @@ -1882,9 +1882,10 @@ class ModelIntegrationTest extends BaseModelTest { } else { $intLength = 11; } - foreach (array('collate', 'charset') as $type) { - unset($result['user'][$type]); - unset($result['password'][$type]); + foreach (array('collate', 'charset', 'comment') as $type) { + foreach ($result as $i => $r) { + unset($result[$i][$type]); + } } $expected = array( diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index fcf7c8e8f..28c331dad 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -1015,6 +1015,7 @@ class ModelWriteTest extends BaseModelTest { * @return void */ function testSaveFromXml() { + $this->markTestSkipped('This feature needs to be fixed or dropped'); $this->loadFixtures('Article'); App::import('Core', 'Xml'); From cbdfb3f76e885c52534d4577f61a9d567ce47526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 11:49:17 -0430 Subject: [PATCH 031/378] Removing all references to mysqli --- cake/console/libs/tasks/db_config.php | 2 +- .../skel/config/database.php.default | 3 +- .../libs/model/datasources/dbo/dbo_mysqli.php | 336 ------------------ .../libs/model/connection_manager.test.php | 1 - .../model/datasources/dbo/dbo_mysqli.test.php | 330 ----------------- 5 files changed, 2 insertions(+), 670 deletions(-) delete mode 100644 cake/libs/model/datasources/dbo/dbo_mysqli.php delete mode 100644 cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php diff --git a/cake/console/libs/tasks/db_config.php b/cake/console/libs/tasks/db_config.php index c62cbe1f3..c58e34556 100644 --- a/cake/console/libs/tasks/db_config.php +++ b/cake/console/libs/tasks/db_config.php @@ -100,7 +100,7 @@ class DbConfigTask extends Shell { } } - $driver = $this->in('Driver:', array('db2', 'firebird', 'mssql', 'mysql', 'mysqli', 'odbc', 'oracle', 'postgres', 'sqlite', 'sybase'), 'mysql'); + $driver = $this->in('Driver:', array('db2', 'firebird', 'mssql', 'mysql', 'odbc', 'oracle', 'postgres', 'sqlite', 'sybase'), 'mysql'); $persistent = $this->in('Persistent Connection?', array('y', 'n'), 'n'); if (strtolower($persistent) == 'n') { diff --git a/cake/console/templates/skel/config/database.php.default b/cake/console/templates/skel/config/database.php.default index 2a605e498..8c7e39661 100644 --- a/cake/console/templates/skel/config/database.php.default +++ b/cake/console/templates/skel/config/database.php.default @@ -31,7 +31,6 @@ * * driver => The name of a supported driver; valid options are as follows: * mysql - MySQL 4 & 5, - * mysqli - MySQL 4 & 5 Improved Interface (PHP5 only), * sqlite - SQLite (PHP5 only), * postgres - PostgreSQL 7 and higher, * mssql - Microsoft SQL Server 2000 and higher, @@ -67,7 +66,7 @@ * 'public', DB2 defaults to empty. * * encoding => - * For MySQL, MySQLi, Postgres and DB2, specifies the character encoding to use when connecting to the + * For MySQL, Postgres and DB2, specifies the character encoding to use when connecting to the * database. Uses database default. * */ diff --git a/cake/libs/model/datasources/dbo/dbo_mysqli.php b/cake/libs/model/datasources/dbo/dbo_mysqli.php deleted file mode 100644 index 7c6cdfd5d..000000000 --- a/cake/libs/model/datasources/dbo/dbo_mysqli.php +++ /dev/null @@ -1,336 +0,0 @@ - true, - 'host' => 'localhost', - 'login' => 'root', - 'password' => '', - 'database' => 'cake', - 'port' => '3306' - ); - -/** - * Connects to the database using options in the given configuration array. - * - * @return boolean True if the database could be connected, else false - */ - function connect() { - $config = $this->config; - $this->connected = false; - - if (is_numeric($config['port'])) { - $config['socket'] = null; - } else { - $config['socket'] = $config['port']; - $config['port'] = null; - } - - $this->connection = mysqli_connect($config['host'], $config['login'], $config['password'], $config['database'], $config['port'], $config['socket']); - - if ($this->connection !== false) { - $this->connected = true; - } - - $this->_useAlias = (bool)version_compare(mysqli_get_server_info($this->connection), "4.1", ">="); - - if (!empty($config['encoding'])) { - $this->setEncoding($config['encoding']); - } - return $this->connected; - } - -/** - * Check that MySQLi is installed/enabled - * - * @return boolean - */ - function enabled() { - return extension_loaded('mysqli'); - } -/** - * Disconnects from database. - * - * @return boolean True if the database could be disconnected, else false - */ - function disconnect() { - if (isset($this->results) && is_resource($this->results)) { - mysqli_free_result($this->results); - } - $this->connected = !@mysqli_close($this->connection); - return !$this->connected; - } - -/** - * Executes given SQL statement. - * - * @param string $sql SQL statement - * @return resource Result resource identifier - */ - protected function _execute($sql) { - if (preg_match('/^\s*call/i', $sql)) { - return $this->_executeProcedure($sql); - } - return mysqli_query($this->connection, $sql); - } - -/** - * Executes given SQL statement (procedure call). - * - * @param string $sql SQL statement (procedure call) - * @return resource Result resource identifier for first recordset - */ - protected function _executeProcedure($sql) { - $answer = mysqli_multi_query($this->connection, $sql); - - $firstResult = mysqli_store_result($this->connection); - - if (mysqli_more_results($this->connection)) { - while ($lastResult = mysqli_next_result($this->connection)); - } - return $firstResult; - } - -/** - * Returns an array of sources (tables) in the database. - * - * @return array Array of tablenames in the database - */ - function listSources() { - $cache = parent::listSources(); - if ($cache !== null) { - return $cache; - } - $result = $this->_execute('SHOW TABLES FROM ' . $this->name($this->config['database']) . ';'); - - if (!$result) { - return array(); - } - - $tables = array(); - - while ($line = mysqli_fetch_row($result)) { - $tables[] = $line[0]; - } - parent::listSources($tables); - return $tables; - } - -/** - * Returns a quoted and escaped string of $data for use in an SQL statement. - * - * @param string $data String to be prepared for use in an SQL statement - * @param string $column The column into which this data will be inserted - * @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided - * @return string Quoted and escaped data - */ - function value($data, $column = null, $safe = false) { - $parent = parent::value($data, $column, $safe); - - if ($parent != null) { - return $parent; - } - if ($data === null || (is_array($data) && empty($data))) { - return 'NULL'; - } - if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') { - return "''"; - } - if (empty($column)) { - $column = $this->introspectType($data); - } - - switch ($column) { - case 'boolean': - return $this->boolean((bool)$data); - break; - case 'integer' : - case 'float' : - case null : - if ($data === '') { - return 'NULL'; - } - if ((is_int($data) || is_float($data) || $data === '0') || ( - is_numeric($data) && strpos($data, ',') === false && - $data[0] != '0' && strpos($data, 'e') === false)) { - return $data; - } - default: - $data = "'" . mysqli_real_escape_string($this->connection, $data) . "'"; - break; - } - - return $data; - } - -/** - * Returns a formatted error message from previous database operation. - * - * @return string Error message with error number - */ - function lastError() { - if (mysqli_errno($this->connection)) { - return mysqli_errno($this->connection).': '.mysqli_error($this->connection); - } - return null; - } - -/** - * Returns number of affected rows in previous database operation. If no previous operation exists, - * this returns false. - * - * @return integer Number of affected rows - */ - function lastAffected() { - if ($this->_result) { - return mysqli_affected_rows($this->connection); - } - return null; - } - -/** - * Returns number of rows in previous resultset. If no previous resultset exists, - * this returns false. - * - * @return integer Number of rows in resultset - */ - function lastNumRows() { - if ($this->hasResult()) { - return mysqli_num_rows($this->_result); - } - return null; - } - -/** - * Returns the ID generated from the previous INSERT operation. - * - * @param unknown_type $source - * @return in - */ - function lastInsertId($source = null) { - $id = $this->fetchRow('SELECT LAST_INSERT_ID() AS insertID', false); - if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0]['insertID'])) { - return $id[0]['insertID']; - } - return null; - } - -/** - * Enter description here... - * - * @param unknown_type $results - */ - function resultSet(&$results) { - if (isset($this->results) && is_resource($this->results) && $this->results != $results) { - mysqli_free_result($this->results); - } - $this->results =& $results; - $this->map = array(); - $numFields = mysqli_num_fields($results); - $index = 0; - $j = 0; - while ($j < $numFields) { - $column = mysqli_fetch_field_direct($results, $j); - if (!empty($column->table)) { - $this->map[$index++] = array($column->table, $column->name); - } else { - $this->map[$index++] = array(0, $column->name); - } - $j++; - } - } - -/** - * Fetches the next row from the current result set - * - * @return unknown - */ - function fetchResult() { - if ($row = mysqli_fetch_row($this->results)) { - $resultRow = array(); - foreach ($row as $index => $field) { - $table = $column = null; - if (count($this->map[$index]) === 2) { - list($table, $column) = $this->map[$index]; - } - $resultRow[$table][$column] = $row[$index]; - } - return $resultRow; - } - return false; - } - -/** - * Gets the database encoding - * - * @return string The database encoding - */ - function getEncoding() { - return mysqli_client_encoding($this->connection); - } - -/** - * Query charset by collation - * - * @param string $name Collation name - * @return string Character set name - */ - function getCharsetName($name) { - if ((bool)version_compare(mysqli_get_server_info($this->connection), "5", ">=")) { - $cols = $this->query('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME= ' . $this->value($name) . ';'); - if (isset($cols[0]['COLLATIONS']['CHARACTER_SET_NAME'])) { - return $cols[0]['COLLATIONS']['CHARACTER_SET_NAME']; - } - } - return false; - } - -/** - * Checks if the result is valid - * - * @return boolean True if the result is valid, else false - */ - function hasResult() { - return is_object($this->_result); - } -} diff --git a/cake/tests/cases/libs/model/connection_manager.test.php b/cake/tests/cases/libs/model/connection_manager.test.php index d8e8b848f..04212fa4a 100644 --- a/cake/tests/cases/libs/model/connection_manager.test.php +++ b/cake/tests/cases/libs/model/connection_manager.test.php @@ -226,7 +226,6 @@ class ConnectionManagerTest extends CakeTestCase { function testLoadDataSource() { $connections = array( array('classname' => 'DboMysql', 'filename' => 'dbo' . DS . 'dbo_mysql'), - array('classname' => 'DboMysqli', 'filename' => 'dbo' . DS . 'dbo_mysqli'), array('classname' => 'DboMssql', 'filename' => 'dbo' . DS . 'dbo_mssql'), array('classname' => 'DboOracle', 'filename' => 'dbo' . DS . 'dbo_oracle'), ); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php deleted file mode 100644 index 3a162f9ee..000000000 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php +++ /dev/null @@ -1,330 +0,0 @@ -testing) { - $this->simulated[] = $sql; - return null; - } - return parent::_execute($sql); - } - -/** - * getLastQuery method - * - * @access public - * @return void - */ - function getLastQuery() { - return $this->simulated[count($this->simulated) - 1]; - } -} - -/** - * MysqliTestModel class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class MysqliTestModel extends Model { - -/** - * name property - * - * @var string 'MysqlTestModel' - * @access public - */ - public $name = 'MysqliTestModel'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - return array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'), - 'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''), - 'last_login'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); - } -} - -/** - * DboMysqliTest class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources.dbo - */ -class DboMysqliTest extends CakeTestCase { - public $fixtures = array('core.datatype'); -/** - * The Dbo instance to be tested - * - * @var DboSource - * @access public - */ - public $Dbo = null; - -/** - * Sets up a Dbo class instance for testing - * - */ - public function setUp() { - $this->Dbo = ConnectionManager::getDataSource('test'); - if ($this->Dbo->config['driver'] !== 'mysqli') { - $this->markTestSkipped('The MySQLi extension is not available.'); - } - $this->model = new MysqliTestModel(); - } - -/** - * Sets up a Dbo class instance for testing - * - */ - public function tearDown() { - unset($this->model); - ClassRegistry::flush(); - } - -/** - * testIndexDetection method - * - * @return void - */ - public function testIndexDetection() { - $this->Dbo->cacheSources = false; - - $name = $this->Dbo->fullTableName('simple'); - $this->Dbo->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); - $expected = array('PRIMARY' => array('column' => 'id', 'unique' => 1)); - $result = $this->Dbo->index($name, false); - $this->assertEqual($expected, $result); - $this->Dbo->query('DROP TABLE ' . $name); - - $name = $this->Dbo->fullTableName('with_a_key'); - $this->Dbo->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ));'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'pointless_bool' => array('column' => 'bool', 'unique' => 0), - ); - $result = $this->Dbo->index($name, false); - $this->assertEqual($expected, $result); - $this->Dbo->query('DROP TABLE ' . $name); - - $name = $this->Dbo->fullTableName('with_two_keys'); - $this->Dbo->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ));'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'pointless_bool' => array('column' => 'bool', 'unique' => 0), - 'pointless_small_int' => array('column' => 'small_int', 'unique' => 0), - ); - $result = $this->Dbo->index($name, false); - $this->assertEqual($expected, $result); - $this->Dbo->query('DROP TABLE ' . $name); - - $name = $this->Dbo->fullTableName('with_compound_keys'); - $this->Dbo->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ), KEY `one_way` ( `bool`, `small_int` ));'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'pointless_bool' => array('column' => 'bool', 'unique' => 0), - 'pointless_small_int' => array('column' => 'small_int', 'unique' => 0), - 'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0), - ); - $result = $this->Dbo->index($name, false); - $this->assertEqual($expected, $result); - $this->Dbo->query('DROP TABLE ' . $name); - - $name = $this->Dbo->fullTableName('with_multiple_compound_keys'); - $this->Dbo->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ), KEY `one_way` ( `bool`, `small_int` ), KEY `other_way` ( `small_int`, `bool` ));'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'pointless_bool' => array('column' => 'bool', 'unique' => 0), - 'pointless_small_int' => array('column' => 'small_int', 'unique' => 0), - 'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0), - 'other_way' => array('column' => array('small_int', 'bool'), 'unique' => 0), - ); - $result = $this->Dbo->index($name, false); - $this->assertEqual($expected, $result); - $this->Dbo->query('DROP TABLE ' . $name); - } - -/** - * testColumn method - * - * @return void - */ - public function testColumn() { - $result = $this->Dbo->column('varchar(50)'); - $expected = 'string'; - $this->assertEqual($result, $expected); - - $result = $this->Dbo->column('text'); - $expected = 'text'; - $this->assertEqual($result, $expected); - - $result = $this->Dbo->column('int(11)'); - $expected = 'integer'; - $this->assertEqual($result, $expected); - - $result = $this->Dbo->column('int(11) unsigned'); - $expected = 'integer'; - $this->assertEqual($result, $expected); - - $result = $this->Dbo->column('tinyint(1)'); - $expected = 'boolean'; - $this->assertEqual($result, $expected); - - $result = $this->Dbo->column('boolean'); - $expected = 'boolean'; - $this->assertEqual($result, $expected); - - $result = $this->Dbo->column('float'); - $expected = 'float'; - $this->assertEqual($result, $expected); - - $result = $this->Dbo->column('float unsigned'); - $expected = 'float'; - $this->assertEqual($result, $expected); - - $result = $this->Dbo->column('double unsigned'); - $expected = 'float'; - $this->assertEqual($result, $expected); - - $result = $this->Dbo->column('decimal(14,7) unsigned'); - $expected = 'float'; - $this->assertEqual($result, $expected); - } - -/** - * test transaction commands. - * - * @return void - */ - public function testTransactions() { - $this->Dbo->testing = false; - $result = $this->Dbo->begin($this->model); - $this->assertTrue($result); - - $log = $this->Dbo->getLog(); - $beginSqlCalls = Set::extract('/.[query=START TRANSACTION]', $log['log']); - $this->assertEqual(1, count($beginSqlCalls)); - - $result = $this->Dbo->commit($this->model); - $this->assertTrue($result); - } -/** - * test that float values are correctly identified - * - * @return void - */ - function testFloatParsing() { - $model =& new Model(array('ds' => 'test', 'table' => 'datatypes', 'name' => 'Datatype')); - $result = $this->Dbo->describe($model); - $this->assertEqual((string)$result['float_field']['length'], '5,2'); - } - -/** - * test that tableParameters like collation, charset and engine are functioning. - * - * @access public - * @return void - */ - function testReadTableParameters() { - $table = 'tinyint' . uniqid(); - $this->Dbo->cacheSources = $this->Dbo->testing = false; - $this->Dbo->query('CREATE TABLE ' . $this->Dbo->fullTableName($table) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'); - $result = $this->Dbo->readTableParameters($table); - $expected = array( - 'charset' => 'utf8', - 'collate' => 'utf8_unicode_ci', - 'engine' => 'InnoDB'); - $this->assertEqual($result, $expected); - - $this->Dbo->query('DROP TABLE ' . $this->Dbo->fullTableName($table)); - $this->Dbo->query('CREATE TABLE ' . $this->Dbo->fullTableName($table) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci;'); - $result = $this->Dbo->readTableParameters($table); - $expected = array( - 'charset' => 'cp1250', - 'collate' => 'cp1250_general_ci', - 'engine' => 'MyISAM'); - $this->assertEqual($result, $expected); - $this->Dbo->query('DROP TABLE ' . $this->Dbo->fullTableName($table)); - } -} From f215cd01f19102d23de42eb0f762397731934015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 15:25:04 -0430 Subject: [PATCH 032/378] Fixing tests for CakeSchema --- .../cases/libs/model/cake_schema.test.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cake/tests/cases/libs/model/cake_schema.test.php b/cake/tests/cases/libs/model/cake_schema.test.php index 0be67982d..d9cc0978e 100644 --- a/cake/tests/cases/libs/model/cake_schema.test.php +++ b/cake/tests/cases/libs/model/cake_schema.test.php @@ -210,7 +210,7 @@ class TestAppSchema extends CakeSchema { */ public $datatypes = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'float_field' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => ''), + 'float_field' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => '', 'collate' => null, 'comment' => null), 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), 'tableParameters' => array() ); @@ -523,6 +523,7 @@ class CakeSchemaTest extends CakeTestCase { */ function setUp() { parent::setUp(); + ConnectionManager::getDataSource('test')->cacheSources = false; $this->Schema = new TestAppSchema(); } @@ -581,14 +582,14 @@ class CakeSchemaTest extends CakeTestCase { $this->Schema->tables['datatypes']['float_field'] ); - $db =& ConnectionManager::getDataSource('test'); + $db = ConnectionManager::getDataSource('test'); $config = $db->config; $config['prefix'] = 'schema_test_prefix_'; ConnectionManager::create('schema_prefix', $config); $read = $this->Schema->read(array('connection' => 'schema_prefix', 'models' => false)); $this->assertTrue(empty($read['tables'])); - $SchemaPost =& ClassRegistry::init('SchemaPost'); + $SchemaPost = ClassRegistry::init('SchemaPost'); $SchemaPost->table = 'sts'; $SchemaPost->tablePrefix = 'po'; $read = $this->Schema->read(array( @@ -612,9 +613,9 @@ class CakeSchemaTest extends CakeTestCase { * @return void */ function testSchemaReadWithTablePrefix() { - $model =& new SchemaPrefixAuthUser(); + $model = new SchemaPrefixAuthUser(); - $Schema =& new CakeSchema(); + $Schema = new CakeSchema(); $read = $Schema->read(array( 'connection' => 'test', 'name' => 'TestApp', @@ -636,7 +637,7 @@ class CakeSchemaTest extends CakeTestCase { 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) )); - $Schema =& new CakeSchema(); + $Schema = new CakeSchema(); $Schema->plugin = 'TestPlugin'; $read = $Schema->read(array( 'connection' => 'test', @@ -670,7 +671,7 @@ class CakeSchemaTest extends CakeTestCase { return; } - $db2 =& ConnectionManager::getDataSource('test2'); + $db2 = ConnectionManager::getDataSource('test2'); $fixture = new SchemaCrossDatabaseFixture(); $fixture->create($db2); $fixture->insert($db2); @@ -910,7 +911,7 @@ class CakeSchemaTest extends CakeTestCase { * @return void */ function testSchemaLoading() { - $Other =& $this->Schema->load(array('name' => 'MyOtherApp', 'path' => TMP . 'tests')); + $Other = $this->Schema->load(array('name' => 'MyOtherApp', 'path' => TMP . 'tests')); $this->assertEqual($Other->name, 'MyOtherApp'); $this->assertEqual($Other->tables, $this->Schema->tables); } @@ -924,7 +925,7 @@ class CakeSchemaTest extends CakeTestCase { App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) )); - $Other =& $this->Schema->load(array('name' => 'TestPluginApp', 'plugin' => 'TestPlugin')); + $Other = $this->Schema->load(array('name' => 'TestPluginApp', 'plugin' => 'TestPlugin')); $this->assertEqual($Other->name, 'TestPluginApp'); $this->assertEqual(array_keys($Other->tables), array('acos')); @@ -938,10 +939,10 @@ class CakeSchemaTest extends CakeTestCase { * @return void */ function testSchemaCreateTable() { - $db =& ConnectionManager::getDataSource('test'); + $db = ConnectionManager::getDataSource('test'); $db->cacheSources = false; - $Schema =& new CakeSchema(array( + $Schema = new CakeSchema(array( 'connection' => 'test', 'testdescribes' => array( 'id' => array('type' => 'integer', 'key' => 'primary'), From ee4add9c32cb9087c9453017a001eff795b56d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 15:53:44 -0430 Subject: [PATCH 033/378] Fixing test case --- cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 0d879e215..00cca0662 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -842,7 +842,7 @@ class DboMysqlTest extends CakeTestCase { $this->db->virtualFieldSeparator = '_$_'; $result = $this->db->fields($model, null, array('data', 'other__field')); - $expected = array('`BinaryTest`.`data`', '(SUM(id)) AS BinaryTest_$_other__field'); + $expected = array('`BinaryTest`.`data`', '(SUM(id)) AS `BinaryTest_$_other__field`'); $this->assertEqual($result, $expected); } From 10646ba2adeae5483bb686ddc4493fd1f893b17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 16:07:40 -0430 Subject: [PATCH 034/378] Removing duplicate assignation of same object that didn't make much sense --- cake/libs/model/datasources/dbo/dbo_mysql.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 75eb18e80..40bf6c485 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -320,10 +320,6 @@ class DboMysql extends DboSource { * @param PDOStatement $results */ function resultSet($results) { - //if (isset($this->results) && is_resource($this->results) && $this->results != $results) { - // mysql_free_result($this->results); - //} - $this->results = $results; $this->map = array(); $numFields = $results->columnCount(); $index = 0; @@ -346,7 +342,7 @@ class DboMysql extends DboSource { * @return mixed array with results fetched and mapped to column names or false if there is no results left to fetch */ function fetchResult() { - if ($row = $this->results->fetch()) { + if ($row = $this->_result->fetch()) { $resultRow = array(); foreach ($this->map as $col => $meta) { list($table, $column) = $meta; From bcc1417e5dbcdd9f371ed280c4b983c892e10e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 18:36:35 -0430 Subject: [PATCH 035/378] Making database stats dependent of fullDebug Leaving lastNumRows commented out until some bugs are solved --- cake/libs/model/datasources/dbo/dbo_mysql.php | 6 +++++- cake/libs/model/datasources/dbo_source.php | 10 +++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 40bf6c485..1d5706cfc 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -299,7 +299,11 @@ class DboMysql extends DboSource { */ function lastNumRows() { if ($this->hasResult()) { - return mysql_num_rows($this->_result); + $i = 0; + foreach ($this->_result as $row) { + $i++; + } + return $i; } return null; } diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index cb64234c3..76305f5a6 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -230,8 +230,6 @@ class DboSource extends DataSource { * * ### Options * - * - stats - Collect meta data stats for this query. Stats include time take, rows affected, - * any errors, and number of rows returned. Defaults to `true`. * - log - Whether or not the query should be logged to the memory log. * * @param string $sql @@ -240,19 +238,17 @@ class DboSource extends DataSource { * @return mixed Resource or object representing the result set, or false on failure */ public function execute($sql, $options = array(), $params = array()) { - $defaults = array('stats' => true, 'log' => $this->fullDebug); + $defaults = array('log' => $this->fullDebug); $options = array_merge($defaults, $options); $this->error = null; $t = microtime(true); $this->_result = $this->_execute($sql, $params); - if ($options['stats']) { + + if ($options['log']) { $this->took = round((microtime(true) - $t) * 1000, 0); $this->affected = $this->lastAffected(); //$this->numRows = $this->lastNumRows(); - } - - if ($options['log']) { $this->logQuery($sql); } From 122cb1ec5beff07c3993a0ff5b9be97c839f8205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 18:58:03 -0430 Subject: [PATCH 036/378] Removing mor assignments by reference --- cake/libs/model/behaviors/tree.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cake/libs/model/behaviors/tree.php b/cake/libs/model/behaviors/tree.php index 51510538d..991d4fd1a 100644 --- a/cake/libs/model/behaviors/tree.php +++ b/cake/libs/model/behaviors/tree.php @@ -65,7 +65,7 @@ class TreeBehavior extends ModelBehavior { if (in_array($settings['scope'], $Model->getAssociated('belongsTo'))) { $data = $Model->getAssociated($settings['scope']); - $parent =& $Model->{$settings['scope']}; + $parent = $Model->{$settings['scope']}; $settings['scope'] = $Model->alias . '.' . $data['foreignKey'] . ' = ' . $parent->alias . '.' . $parent->primaryKey; $settings['recursive'] = 0; } @@ -599,7 +599,7 @@ class TreeBehavior extends ModelBehavior { $this->_setParent($Model, $array[$Model->alias][$parent]); } } else { - $db =& ConnectionManager::getDataSource($Model->useDbConfig); + $db = ConnectionManager::getDataSource($Model->useDbConfig); foreach ($Model->find('all', array('conditions' => $scope, 'fields' => array($Model->primaryKey, $parent), 'order' => $left)) as $array) { $path = $this->getPath($Model, $array[$Model->alias][$Model->primaryKey]); if ($path == null || count($path) < 2) { @@ -702,7 +702,7 @@ class TreeBehavior extends ModelBehavior { $parentNode[$right] = $node[$right] + 1; } - $db =& ConnectionManager::getDataSource($Model->useDbConfig); + $db = ConnectionManager::getDataSource($Model->useDbConfig); $Model->updateAll( array($parent => $db->value($node[$parent], $parent)), array($Model->escapeField($parent) => $node[$Model->primaryKey]) @@ -888,7 +888,7 @@ class TreeBehavior extends ModelBehavior { * @access private */ function __getMax($Model, $scope, $right, $recursive = -1, $created = false) { - $db =& ConnectionManager::getDataSource($Model->useDbConfig); + $db = ConnectionManager::getDataSource($Model->useDbConfig); if ($created) { if (is_string($scope)) { $scope .= " AND {$Model->alias}.{$Model->primaryKey} <> "; @@ -916,7 +916,7 @@ class TreeBehavior extends ModelBehavior { * @access private */ function __getMin($Model, $scope, $left, $recursive = -1) { - $db =& ConnectionManager::getDataSource($Model->useDbConfig); + $db = ConnectionManager::getDataSource($Model->useDbConfig); $name = $Model->alias . '.' . $left; list($edge) = array_values($Model->find('first', array( 'conditions' => $scope, From 28685dc234caf81cacea0a1430a39a1b176cadc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 19:20:21 -0430 Subject: [PATCH 037/378] More replacements of assignation by reference --- cake/libs/model/datasources/dbo_source.php | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 76305f5a6..98c6cc390 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -645,7 +645,7 @@ class DboSource extends DataSource { if (PHP_SAPI != 'cli') { App::import('Core', 'View'); $controller = null; - $View =& new View($controller, false); + $View = new View($controller, false); $View->set('logs', array($this->configKeyName => $log)); echo $View->element('sql_dump', array('_forced_from_dbo_' => true)); } else { @@ -817,7 +817,7 @@ class DboSource extends DataSource { foreach ($_associations as $type) { foreach ($model->{$type} as $assoc => $assocData) { - $linkModel =& $model->{$assoc}; + $linkModel = $model->{$assoc}; $external = isset($assocData['external']); if ($model->useDbConfig == $linkModel->useDbConfig) { @@ -842,16 +842,16 @@ class DboSource extends DataSource { if ($model->recursive > -1) { foreach ($_associations as $type) { foreach ($model->{$type} as $assoc => $assocData) { - $linkModel =& $model->{$assoc}; + $linkModel = $model->{$assoc}; if (empty($linkedModels[$type . '/' . $assoc])) { if ($model->useDbConfig == $linkModel->useDbConfig) { - $db =& $this; + $db = $this; } else { - $db =& ConnectionManager::getDataSource($linkModel->useDbConfig); + $db = ConnectionManager::getDataSource($linkModel->useDbConfig); } } elseif ($model->recursive > 1 && ($type == 'belongsTo' || $type == 'hasOne')) { - $db =& $this; + $db = $this; } if (isset($db) && method_exists($db, 'queryAssociation')) { @@ -957,14 +957,14 @@ class DboSource extends DataSource { if ($recursive > 0) { foreach ($linkModel->associations() as $type1) { foreach ($linkModel->{$type1} as $assoc1 => $assocData1) { - $deepModel =& $linkModel->{$assoc1}; + $deepModel = $linkModel->{$assoc1}; $tmpStack = $stack; $tmpStack[] = $assoc1; if ($linkModel->useDbConfig === $deepModel->useDbConfig) { - $db =& $this; + $db = $this; } else { - $db =& ConnectionManager::getDataSource($deepModel->useDbConfig); + $db = ConnectionManager::getDataSource($deepModel->useDbConfig); } $db->queryAssociation($linkModel, $deepModel, $type1, $assoc1, $assocData1, $queryData, true, $fetch, $recursive - 1, $tmpStack); } @@ -1026,15 +1026,15 @@ class DboSource extends DataSource { if ($recursive > 0) { foreach ($linkModel->associations() as $type1) { foreach ($linkModel->{$type1} as $assoc1 => $assocData1) { - $deepModel =& $linkModel->{$assoc1}; + $deepModel = $linkModel->{$assoc1}; if (($type1 === 'belongsTo') || ($deepModel->alias === $model->alias && $type === 'belongsTo') || ($deepModel->alias != $model->alias)) { $tmpStack = $stack; $tmpStack[] = $assoc1; if ($linkModel->useDbConfig == $deepModel->useDbConfig) { - $db =& $this; + $db = $this; } else { - $db =& ConnectionManager::getDataSource($deepModel->useDbConfig); + $db = ConnectionManager::getDataSource($deepModel->useDbConfig); } $db->queryAssociation($linkModel, $deepModel, $type1, $assoc1, $assocData1, $queryData, true, $fetch, $recursive - 1, $tmpStack); } From f3d3ee92f2c637868dba6eeaca61c0407f18580f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 23:36:34 -0430 Subject: [PATCH 038/378] Implementing basic connection to postgres using PDO --- .../model/datasources/dbo/dbo_postgres.php | 61 +++++++------------ 1 file changed, 21 insertions(+), 40 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 7b37f5412..4fa0749fa 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -112,23 +112,30 @@ class DboPostgres extends DboSource { */ function connect() { $config = $this->config; - $conn = "host='{$config['host']}' port='{$config['port']}' dbname='{$config['database']}' "; - $conn .= "user='{$config['login']}' password='{$config['password']}'"; - - if (!$config['persistent']) { - $this->connection = pg_connect($conn, PGSQL_CONNECT_FORCE_NEW); - } else { - $this->connection = pg_pconnect($conn); - } $this->connected = false; + try { + $flags = array( + PDO::ATTR_PERSISTENT => $config['persistent'] + ); + if (!empty($config['encoding'])) { + $flags[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET search_path TO ' . $config['schema']; + } + $this->_connection = new PDO( + "pgsql:host={$config['host']};port={$config['port']};dbname={$config['database']}", + $config['login'], + $config['password'], + $flags + ); + + if (!empty($config['encoding'])) { + $this->setEncoding($config['encoding']); + } - if ($this->connection) { $this->connected = true; - $this->_execute("SET search_path TO " . $config['schema']); - } - if (!empty($config['encoding'])) { - $this->setEncoding($config['encoding']); + } catch (PDOException $e) { + $this->errors[] = $e->getMessage(); } + return $this->connected; } @@ -138,33 +145,7 @@ class DboPostgres extends DboSource { * @return boolean */ function enabled() { - return extension_loaded('pgsql'); - } -/** - * Disconnects from database. - * - * @return boolean True if the database could be disconnected, else false - */ - function disconnect() { - if ($this->hasResult()) { - pg_free_result($this->_result); - } - if (is_resource($this->connection)) { - $this->connected = !pg_close($this->connection); - } else { - $this->connected = false; - } - return !$this->connected; - } - -/** - * Executes given SQL statement. - * - * @param string $sql SQL statement - * @return resource Result resource identifier - */ - function _execute($sql) { - return pg_query($this->connection, $sql); + return in_array('pgsql', PDO::getAvailableDrivers()); } /** From 159776fc002b2d67001d299c22c5985ce4c8df9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 23:37:56 -0430 Subject: [PATCH 039/378] Refactoring possible common code to DboSource, now that PDO abstract disconnection from source --- cake/libs/model/datasources/dbo/dbo_mysql.php | 17 -------------- cake/libs/model/datasources/dbo_source.php | 23 +++++++++++++++++-- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 1d5706cfc..3feb3bc7e 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -165,10 +165,6 @@ class DboMysql extends DboSource { return $this->connected; } - public function getConnection() { - return $this->_connection; - } - /** * Check whether the MySQL extension is installed/loaded * @@ -177,19 +173,6 @@ class DboMysql extends DboSource { function enabled() { return in_array('mysql', PDO::getAvailableDrivers()); } -/** - * Disconnects from database. - * - * @return boolean True if the database could be disconnected, else false - */ - function disconnect() { - if (is_a($this->_result, 'PDOStatement')) { - $this->_result->closeCursor(); - } - unset($this->_connection); - $this->connected = false; - return !$this->connected; - } /** * Returns an array of sources (tables) in the database. diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 98c6cc390..5c5378b30 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -160,9 +160,28 @@ class DboSource extends DataSource { } /** - * Prepares a value, or an array of values for database queries by quoting and escaping them. + * Disconnects from database. * - * @param mixed $data A value or an array of values to prepare. + * @return boolean True if the database could be disconnected, else false + */ + function disconnect() { + if (is_a($this->_result, 'PDOStatement')) { + $this->_result->closeCursor(); + } + unset($this->_connection); + $this->connected = false; + return !$this->connected; + } + + public function getConnection() { + return $this->_connection; + } + + +/** + * Returns a quoted and escaped string of $data for use in an SQL statement. + * + * @param string $data String to be prepared for use in an SQL statement * @param string $column The column into which this data will be inserted * @param boolean $read Value to be used in READ or WRITE context * @return mixed Prepared value or array of values. From d9c9a32ff3d2994d7c4a0557b9be15f082cbc4f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 23:38:55 -0430 Subject: [PATCH 040/378] Refactoring DboSource::value() so postgres and mysq behavior is the same, updating test case --- cake/libs/model/datasources/dbo/dbo_mysql.php | 48 ---------------- .../model/datasources/dbo/dbo_postgres.php | 55 ------------------- cake/libs/model/datasources/dbo_source.php | 48 ++++++++++++++-- .../datasources/dbo/dbo_postgres.test.php | 44 +++++++-------- 4 files changed, 64 insertions(+), 131 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 3feb3bc7e..6930b1b36 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -199,54 +199,6 @@ class DboMysql extends DboSource { } } -/** - * Returns a quoted and escaped string of $data for use in an SQL statement. - * - * @param string $data String to be prepared for use in an SQL statement - * @param string $column The column into which this data will be inserted - * @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided - * @return string Quoted and escaped data - */ - function value($data, $column = null, $safe = false) { - $parent = parent::value($data, $column, $safe); - - if ($parent != null) { - return $parent; - } - if ($data === null || (is_array($data) && empty($data))) { - return 'NULL'; - } - if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') { - return $this->_connection->quote($data, PDO::PARAM_STR); - } - if (empty($column)) { - $column = $this->introspectType($data); - } - - switch ($column) { - case 'boolean': - return $this->boolean((bool)$data); - break; - case 'integer': - case 'float': - if ($data === '') { - return 'NULL'; - } - if (is_float($data)) { - return sprintf('%F', $data); - } - if ((is_int($data) || $data === '0') || ( - is_numeric($data) && strpos($data, ',') === false && - $data[0] != '0' && strpos($data, 'e') === false) - ) { - return $data; - } - default: - return $this->_connection->quote($data, PDO::PARAM_STR); - break; - } - } - /** * Returns a formatted error message from previous database operation. * diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 4fa0749fa..038bd1adb 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -256,61 +256,6 @@ class DboPostgres extends DboSource { return $fields; } -/** - * Returns a quoted and escaped string of $data for use in an SQL statement. - * - * @param string $data String to be prepared for use in an SQL statement - * @param string $column The column into which this data will be inserted - * @param boolean $read Value to be used in READ or WRITE context - * @return string Quoted and escaped - * @todo Add logic that formats/escapes data based on column type - */ - function value($data, $column = null, $read = true) { - - $parent = parent::value($data, $column); - if ($parent != null) { - return $parent; - } - - if ($data === null || (is_array($data) && empty($data))) { - return 'NULL'; - } - if (empty($column)) { - $column = $this->introspectType($data); - } - - switch($column) { - case 'binary': - $data = pg_escape_bytea($data); - break; - case 'boolean': - if ($data === true || $data === 't' || $data === 'true') { - return 'TRUE'; - } elseif ($data === false || $data === 'f' || $data === 'false') { - return 'FALSE'; - } - return (!empty($data) ? 'TRUE' : 'FALSE'); - break; - case 'float': - if (is_float($data)) { - $data = sprintf('%F', $data); - } - case 'inet': - case 'integer': - case 'date': - case 'datetime': - case 'timestamp': - case 'time': - if ($data === '') { - return $read ? 'NULL' : 'DEFAULT'; - } - default: - $data = pg_escape_string($data); - break; - } - return "'" . $data . "'"; - } - /** * Returns a formatted error message from previous database operation. * diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 5c5378b30..0fc5be0b9 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -183,14 +183,14 @@ class DboSource extends DataSource { * * @param string $data String to be prepared for use in an SQL statement * @param string $column The column into which this data will be inserted - * @param boolean $read Value to be used in READ or WRITE context - * @return mixed Prepared value or array of values. + * @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided + * @return string Quoted and escaped data */ - public function value($data, $column = null, $read = true) { + function value($data, $column = null, $safe = false) { if (is_array($data) && !empty($data)) { return array_map( array(&$this, 'value'), - $data, array_fill(0, count($data), $column), array_fill(0, count($data), $read) + $data, array_fill(0, count($data), $column), array_fill(0, count($data), $safe) ); } elseif (is_object($data) && isset($data->type)) { if ($data->type == 'identifier') { @@ -200,11 +200,46 @@ class DboSource extends DataSource { } } elseif (in_array($data, array('{$__cakeID__$}', '{$__cakeForeignKey__$}'), true)) { return $data; - } else { - return null; + } + + if ($data === null || (is_array($data) && empty($data))) { + return 'NULL'; + } + if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') { + return $this->_connection->quote($data, PDO::PARAM_STR); + } + if (empty($column)) { + $column = $this->introspectType($data); + } + + switch ($column) { + case 'binary': + $data = $this->_connection->quote($data, PDO::PARAM_LOB); + break; + case 'boolean': + return $this->boolean($data); + break; + case 'integer': + case 'float': + if ($data === '') { + return 'NULL'; + } + if (is_float($data)) { + return sprintf('%F', $data); + } + if ((is_int($data) || $data === '0') || ( + is_numeric($data) && strpos($data, ',') === false && + $data[0] != '0' && strpos($data, 'e') === false) + ) { + return $data; + } + default: + return $this->_connection->quote($data, PDO::PARAM_STR); + break; } } + /** * Returns an object to represent a database identifier in a query * @@ -462,6 +497,7 @@ class DboSource extends DataSource { if ($cache) { $this->_writeQueryCache($sql, $out, $params); } + if (empty($out) && is_bool($this->_result)) { return $this->_result; } diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 2dff85b3e..cb72d3858 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -330,30 +330,30 @@ class DboPostgresTest extends CakeTestCase { * @return void */ function testValueQuoting() { - $this->assertIdentical($this->db2->value(1.2, 'float'), "'1.200000'"); - $this->assertEqual($this->db2->value('1,2', 'float'), "'1,2'"); + $this->assertEqual($this->Dbo->value(1.2, 'float'), "1.200000"); + $this->assertEqual($this->Dbo->value('1,2', 'float'), "'1,2'"); - $this->assertEqual($this->Dbo2->value('0', 'integer'), "'0'"); - $this->assertEqual($this->Dbo2->value('', 'integer'), 'NULL'); - $this->assertEqual($this->Dbo2->value('', 'float'), 'NULL'); - $this->assertEqual($this->Dbo2->value('', 'integer', false), "DEFAULT"); - $this->assertEqual($this->Dbo2->value('', 'float', false), "DEFAULT"); - $this->assertEqual($this->Dbo2->value('0.0', 'float'), "'0.0'"); + $this->assertEqual($this->Dbo->value('0', 'integer'), "0"); + $this->assertEqual($this->Dbo->value('', 'integer'), 'NULL'); + $this->assertEqual($this->Dbo->value('', 'float'), 'NULL'); + $this->assertEqual($this->Dbo->value('', 'integer', false), "NULL"); + $this->assertEqual($this->Dbo->value('', 'float', false), "NULL"); + $this->assertEqual($this->Dbo->value('0.0', 'float'), "'0.0'"); - $this->assertEqual($this->Dbo2->value('t', 'boolean'), "TRUE"); - $this->assertEqual($this->Dbo2->value('f', 'boolean'), "FALSE"); - $this->assertEqual($this->Dbo2->value(true), "TRUE"); - $this->assertEqual($this->Dbo2->value(false), "FALSE"); - $this->assertEqual($this->Dbo2->value('t'), "'t'"); - $this->assertEqual($this->Dbo2->value('f'), "'f'"); - $this->assertEqual($this->Dbo2->value('true', 'boolean'), 'TRUE'); - $this->assertEqual($this->Dbo2->value('false', 'boolean'), 'FALSE'); - $this->assertEqual($this->Dbo2->value('', 'boolean'), 'FALSE'); - $this->assertEqual($this->Dbo2->value(0, 'boolean'), 'FALSE'); - $this->assertEqual($this->Dbo2->value(1, 'boolean'), 'TRUE'); - $this->assertEqual($this->Dbo2->value('1', 'boolean'), 'TRUE'); - $this->assertEqual($this->Dbo2->value(null, 'boolean'), "NULL"); - $this->assertEqual($this->Dbo2->value(array()), "NULL"); + $this->assertEqual($this->Dbo->value('t', 'boolean'), true); + $this->assertEqual($this->Dbo->value('f', 'boolean'), false); + $this->assertEqual($this->Dbo->value(true), true); + $this->assertEqual($this->Dbo->value(false), false); + $this->assertEqual($this->Dbo->value('t'), "'t'"); + $this->assertEqual($this->Dbo->value('f'), "'f'"); + $this->assertEqual($this->Dbo->value('true', 'boolean'), true); + $this->assertEqual($this->Dbo->value('false', 'boolean'), false); + $this->assertEqual($this->Dbo->value('', 'boolean'), false); + $this->assertEqual($this->Dbo->value(0, 'boolean'), false); + $this->assertEqual($this->Dbo->value(1, 'boolean'), true); + $this->assertEqual($this->Dbo->value('1', 'boolean'), true); + $this->assertEqual($this->Dbo->value(null, 'boolean'), "NULL"); + $this->assertEqual($this->Dbo->value(array()), "NULL"); } /** From 16463229e5bddc0174cdd3638707899527d11f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 23:39:53 -0430 Subject: [PATCH 041/378] Fixing return value of DboSource::boolean() --- cake/libs/model/datasources/dbo_source.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 0fc5be0b9..90e9f34e6 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -2612,7 +2612,7 @@ class DboSource extends DataSource { * Translates between PHP boolean values and Database (faked) boolean values * * @param mixed $data Value to be translated - * @return mixed Converted boolean value + * @return int Converted boolean value */ public function boolean($data) { if ($data === true || $data === false) { @@ -2621,7 +2621,7 @@ class DboSource extends DataSource { } return 0; } else { - return !empty($data); + return (int) !empty($data); } } From 6778d4b56566301ee244f37802dbb6b7fb39cf44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 23:42:12 -0430 Subject: [PATCH 042/378] Updating test case for floats --- .../cases/libs/model/datasources/dbo/dbo_postgres.test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index cb72d3858..35316fdd0 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -366,10 +366,10 @@ class DboPostgresTest extends CakeTestCase { setlocale(LC_ALL, 'de_DE'); $result = $this->db->value(3.141593, 'float'); - $this->assertEqual((string)$result, "'3.141593'"); + $this->assertEqual((string)$result, "3.141593"); $result = $this->db->value(3.14); - $this->assertEqual((string)$result, "'3.140000'"); + $this->assertEqual((string)$result, "3.140000"); setlocale(LC_ALL, $restore); } From aedf69dee1054918f4de8b80222ca05424a3e115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 17 Oct 2010 23:55:11 -0430 Subject: [PATCH 043/378] More refactoring to DboSource::value() --- cake/libs/model/datasources/dbo_source.php | 15 +++++++-------- .../model/datasources/dbo/dbo_postgres.test.php | 16 ++++++++-------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 90e9f34e6..27c49b0fb 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -205,22 +205,22 @@ class DboSource extends DataSource { if ($data === null || (is_array($data) && empty($data))) { return 'NULL'; } - if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') { - return $this->_connection->quote($data, PDO::PARAM_STR); - } + if (empty($column)) { $column = $this->introspectType($data); } switch ($column) { case 'binary': - $data = $this->_connection->quote($data, PDO::PARAM_LOB); + return $this->_connection->quote($data, PDO::PARAM_LOB); break; case 'boolean': return $this->boolean($data); break; - case 'integer': - case 'float': + case 'string': + case 'text': + return $this->_connection->quote($data, PDO::PARAM_STR); + default: if ($data === '') { return 'NULL'; } @@ -233,8 +233,7 @@ class DboSource extends DataSource { ) { return $data; } - default: - return $this->_connection->quote($data, PDO::PARAM_STR); + return $this->_connection->quote($data); break; } } diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 35316fdd0..32036841c 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -380,17 +380,17 @@ class DboPostgresTest extends CakeTestCase { * @return void */ function testDateAndTimeAsNull() { - $this->assertEqual($this->Dbo2->value(null, 'date'), 'NULL'); - $this->assertEqual($this->Dbo2->value('', 'date'), 'NULL'); + $this->assertEqual($this->Dbo->value(null, 'date'), 'NULL'); + $this->assertEqual($this->Dbo->value('', 'date'), 'NULL'); - $this->assertEqual($this->Dbo2->value('', 'datetime'), 'NULL'); - $this->assertEqual($this->Dbo2->value(null, 'datetime'), 'NULL'); + $this->assertEqual($this->Dbo->value('', 'datetime'), 'NULL'); + $this->assertEqual($this->Dbo->value(null, 'datetime'), 'NULL'); - $this->assertEqual($this->Dbo2->value('', 'timestamp'), 'NULL'); - $this->assertEqual($this->Dbo2->value(null, 'timestamp'), 'NULL'); + $this->assertEqual($this->Dbo->value('', 'timestamp'), 'NULL'); + $this->assertEqual($this->Dbo->value(null, 'timestamp'), 'NULL'); - $this->assertEqual($this->Dbo2->value('', 'time'), 'NULL'); - $this->assertEqual($this->Dbo2->value(null, 'time'), 'NULL'); + $this->assertEqual($this->Dbo->value('', 'time'), 'NULL'); + $this->assertEqual($this->Dbo->value(null, 'time'), 'NULL'); } /** From 5c87daf08304fb7fb9e4500d7996990206641260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 18 Oct 2010 00:08:34 -0430 Subject: [PATCH 044/378] Implementing listSources for postgres --- cake/libs/model/datasources/dbo/dbo_postgres.php | 6 +++--- .../cases/libs/model/datasources/dbo/dbo_postgres.test.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 038bd1adb..b6885569a 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -161,8 +161,8 @@ class DboPostgres extends DboSource { } $schema = $this->config['schema']; - $sql = "SELECT table_name as name FROM INFORMATION_SCHEMA.tables WHERE table_schema = '{$schema}';"; - $result = $this->fetchAll($sql, false); + $sql = "SELECT table_name as name FROM INFORMATION_SCHEMA.tables WHERE table_schema = ?"; + $result = $this->_execute($sql, array($schema)); if (!$result) { return array(); @@ -170,7 +170,7 @@ class DboPostgres extends DboSource { $tables = array(); foreach ($result as $item) { - $tables[] = $item[0]['name']; + $tables[] = $item->Name; } parent::listSources($tables); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 32036841c..ca73d4876 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -427,7 +427,7 @@ class DboPostgresTest extends CakeTestCase { $db2 = clone $db1; $db2->connect(); - $this->assertNotEqual($db1->connection, $db2->connection); + $this->assertNotSame($db1->getConnection(), $db2->getConnection()); $table = $db1->fullTableName('users', false); $password = '5f4dcc3b5aa765d61d8327deb882cf99'; From ab9c8904adc65e7cdbd5c1aa06ca929a47d43eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 18 Oct 2010 00:08:58 -0430 Subject: [PATCH 045/378] Implementing lastInsertId for postgres --- cake/libs/model/datasources/dbo/dbo_postgres.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index b6885569a..1580b2932 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -294,8 +294,7 @@ class DboPostgres extends DboSource { */ function lastInsertId($source, $field = 'id') { $seq = $this->getSequence($source, $field); - $data = $this->fetchRow("SELECT currval('{$seq}') as max"); - return $data[0]['max']; + return $this->_connection->lastInsertId($seq); } /** From c1ca039582e4afbb7c7472fd65c31027d70e9224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 18 Oct 2010 00:11:24 -0430 Subject: [PATCH 046/378] Fixing typo in listSources --- cake/libs/model/datasources/dbo/dbo_postgres.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 1580b2932..faaeeab96 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -170,7 +170,7 @@ class DboPostgres extends DboSource { $tables = array(); foreach ($result as $item) { - $tables[] = $item->Name; + $tables[] = $item->name; } parent::listSources($tables); From ad22bc31c7b4fca89576868b570d48af025f8488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 18 Oct 2010 00:23:19 -0430 Subject: [PATCH 047/378] Updating DboPosgres::describe() to use PDO --- .../model/datasources/dbo/dbo_postgres.php | 84 ++++++++----------- 1 file changed, 37 insertions(+), 47 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index faaeeab96..dd7ab861e 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -190,61 +190,51 @@ class DboPostgres extends DboSource { $this->_sequenceMap[$table] = array(); if ($fields === null) { - $cols = $this->fetchAll( + $cols = $this->_execute( "SELECT DISTINCT column_name AS name, data_type AS type, is_nullable AS null, column_default AS default, ordinal_position AS position, character_maximum_length AS char_length, character_octet_length AS oct_length FROM information_schema.columns - WHERE table_name = " . $this->value($table) . " AND table_schema = " . - $this->value($this->config['schema'])." ORDER BY position", - false + WHERE table_name = ? AND table_schema = ? ORDER BY position", + array($table, $this->config['schema']) ); - foreach ($cols as $column) { - $colKey = array_keys($column); - - if (isset($column[$colKey[0]]) && !isset($column[0])) { - $column[0] = $column[$colKey[0]]; - } - - if (isset($column[0])) { - $c = $column[0]; - - if (!empty($c['char_length'])) { - $length = intval($c['char_length']); - } elseif (!empty($c['oct_length'])) { - if ($c['type'] == 'character varying') { - $length = null; - $c['type'] = 'text'; - } else { - $length = intval($c['oct_length']); - } + foreach ($cols as $c) { + $type = $c->type; + if (!empty($c->char_length)) { + $length = intval($c->char_length); + } elseif (!empty($c->oct_length)) { + if ($c->type == 'character varying') { + $length = null; + $type = 'text'; } else { - $length = $this->length($c['type']); + $length = intval($c->oct_length); } - $fields[$c['name']] = array( - 'type' => $this->column($c['type']), - 'null' => ($c['null'] == 'NO' ? false : true), - 'default' => preg_replace( - "/^'(.*)'$/", - "$1", - preg_replace('/::.*/', '', $c['default']) - ), - 'length' => $length - ); - if ($c['name'] == $model->primaryKey) { - $fields[$c['name']]['key'] = 'primary'; - if ($fields[$c['name']]['type'] !== 'string') { - $fields[$c['name']]['length'] = 11; - } + } else { + $length = $this->length($c->type); + } + $fields[$c->name] = array( + 'type' => $this->column($type), + 'null' => ($c->null == 'NO' ? false : true), + 'default' => preg_replace( + "/^'(.*)'$/", + "$1", + preg_replace('/::.*/', '', $c->default) + ), + 'length' => $length + ); + if ($c->name == $model->primaryKey) { + $fields[$c->name]['key'] = 'primary'; + if ($fields[$c->name]['type'] !== 'string') { + $fields[$c->name]['length'] = 11; } - if ( - $fields[$c['name']]['default'] == 'NULL' || - preg_match('/nextval\([\'"]?([\w.]+)/', $c['default'], $seq) - ) { - $fields[$c['name']]['default'] = null; - if (!empty($seq) && isset($seq[1])) { - $this->_sequenceMap[$table][$c['name']] = $seq[1]; - } + } + if ( + $fields[$c->name]['default'] == 'NULL' || + preg_match('/nextval\([\'"]?([\w.]+)/', $c->default, $seq) + ) { + $fields[$c->name]['default'] = null; + if (!empty($seq) && isset($seq[1])) { + $this->_sequenceMap[$table][$c->default] = $seq[1]; } } } From edd448f0b89a99339de079a4ddd01f71ccf3519d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 18 Oct 2010 00:38:48 -0430 Subject: [PATCH 048/378] Implementing resultSet and fetchResult in DboPostgres --- .../model/datasources/dbo/dbo_postgres.php | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index dd7ab861e..af3778a9a 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -696,20 +696,18 @@ class DboPostgres extends DboSource { * @param unknown_type $results */ function resultSet(&$results) { - $this->results =& $results; $this->map = array(); - $num_fields = pg_num_fields($results); + $numFields = $results->columnCount(); $index = 0; $j = 0; - while ($j < $num_fields) { - $columnName = pg_field_name($results, $j); - - if (strpos($columnName, '__')) { - $parts = explode('__', $columnName); - $this->map[$index++] = array($parts[0], $parts[1]); + while ($j < $numFields) { + $column = $results->getColumnMeta($j); + if (strpos($column['name'], '__')) { + list($table, $name) = explode('__', $column['name']); + $this->map[$index++] = array($table, $name, $column['native_type']); } else { - $this->map[$index++] = array(0, $columnName); + $this->map[$index++] = array(0, $column['name'], $column['native_type']); } $j++; } @@ -721,12 +719,11 @@ class DboPostgres extends DboSource { * @return unknown */ function fetchResult() { - if ($row = pg_fetch_row($this->results)) { + if ($row = $this->_result->fetch()) { $resultRow = array(); - foreach ($row as $index => $field) { - list($table, $column) = $this->map[$index]; - $type = pg_field_type($this->results, $index); + foreach ($this->map as $index => $meta) { + list($table, $column, $type) = $meta; switch ($type) { case 'bool': @@ -734,7 +731,7 @@ class DboPostgres extends DboSource { break; case 'binary': case 'bytea': - $resultRow[$table][$column] = pg_unescape_bytea($row[$index]); + $resultRow[$table][$column] = stream_get_contents($row[$index]); break; default: $resultRow[$table][$column] = $row[$index]; From 3f0c79f7f935f83601445f62249ee7ac28be67c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 19 Oct 2010 00:15:32 -0430 Subject: [PATCH 049/378] Fixing some problems in in DboPostgres::connect() --- cake/libs/model/datasources/dbo/dbo_postgres.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index af3778a9a..98ec313a4 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -117,9 +117,6 @@ class DboPostgres extends DboSource { $flags = array( PDO::ATTR_PERSISTENT => $config['persistent'] ); - if (!empty($config['encoding'])) { - $flags[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET search_path TO ' . $config['schema']; - } $this->_connection = new PDO( "pgsql:host={$config['host']};port={$config['port']};dbname={$config['database']}", $config['login'], @@ -127,11 +124,13 @@ class DboPostgres extends DboSource { $flags ); + $this->connected = true; if (!empty($config['encoding'])) { $this->setEncoding($config['encoding']); } - - $this->connected = true; + if (!empty($config['schema'])) { + $this->_execute('SET search_path TO ' . $config['schema']); + } } catch (PDOException $e) { $this->errors[] = $e->getMessage(); } From d0fc2fd1717725373d47f1ecc46cbfca137f8690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 19 Oct 2010 00:48:08 -0430 Subject: [PATCH 050/378] Fixing describing of table columns for postgres --- cake/libs/model/datasources/dbo/dbo_postgres.php | 6 +++--- .../libs/model/datasources/dbo/dbo_postgres.test.php | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 98ec313a4..f3bf33841 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -199,15 +199,15 @@ class DboPostgres extends DboSource { foreach ($cols as $c) { $type = $c->type; - if (!empty($c->char_length)) { - $length = intval($c->char_length); - } elseif (!empty($c->oct_length)) { + if (!empty($c->oct_length) && $c->char_length === null) { if ($c->type == 'character varying') { $length = null; $type = 'text'; } else { $length = intval($c->oct_length); } + } elseif (!empty($c->char_length)) { + $length = intval($c->char_length); } else { $length = $this->length($c->type); } diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index ca73d4876..d8c3dadb7 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -556,12 +556,12 @@ class DboPostgresTest extends CakeTestCase { $db1 = ConnectionManager::getDataSource('test'); $db1->cacheSources = false; $db1->reconnect(array('persistent' => false)); - $db1->query('CREATE TABLE ' . $db1->fullTableName('datatypes') . ' ( + $db1->rawQuery('CREATE TABLE ' . $db1->fullTableName('datatypes') . ' ( id serial NOT NULL, "varchar" character varying(40) NOT NULL, "full_length" character varying NOT NULL, "timestamp" timestamp without time zone, - date date, + "date" date, CONSTRAINT test_data_types_pkey PRIMARY KEY (id) )'); $model = new Model(array('name' => 'Datatype', 'ds' => 'test')); @@ -570,21 +570,21 @@ class DboPostgresTest extends CakeTestCase { 'connection' => 'test', 'models' => array('Datatype') )); - $schema->tables = array('datatypes' => $result['tables']['datatypes']); + + $schema->tables = array('datatypes' => $result['tables']['missing']['datatypes']); $result = $db1->createSchema($schema, 'datatypes'); + $db1->rawQuery('DROP TABLE ' . $db1->fullTableName('datatypes')); $this->assertNoPattern('/timestamp DEFAULT/', $result); $this->assertPattern('/\"full_length\"\s*text\s.*,/', $result); $this->assertPattern('/timestamp\s*,/', $result); - $db1->query('DROP TABLE ' . $db1->fullTableName('datatypes')); - $db1->query($result); $result2 = $schema->read(array( 'connection' => 'test', 'models' => array('Datatype') )); - $schema->tables = array('datatypes' => $result2['tables']['datatypes']); + $schema->tables = array('datatypes' => $result2['tables']['missing']['datatypes']); $result2 = $db1->createSchema($schema, 'datatypes'); $this->assertEqual($result, $result2); From 09487f830c9ef34e7c27047d0069b85ad40d5444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 20 Oct 2010 23:29:07 -0430 Subject: [PATCH 051/378] Preventing false positive in queries returning fields but havinf Count(*) inside them in DboPostgres --- cake/libs/model/datasources/dbo/dbo_postgres.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index f3bf33841..db264f710 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -361,7 +361,7 @@ class DboPostgres extends DboSource { } $count = count($fields); - if ($count >= 1 && strpos($fields[0], 'COUNT(*)') === false) { + if ($count >= 1 && !preg_match('/^\s*COUNT\(/', $fields[0])) { $result = array(); for ($i = 0; $i < $count; $i++) { if (!preg_match('/^.+\\(.*\\)/', $fields[$i]) && !preg_match('/\s+AS\s+/', $fields[$i])) { From 0ffe6de9e447cfa03bd032205ea84412a2ad98b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 20 Oct 2010 23:57:00 -0430 Subject: [PATCH 052/378] Allowing multiple sql sentences to be executed only for creting or altering databases --- cake/libs/model/datasources/dbo_source.php | 9 +++++++++ .../libs/model/datasources/dbo/dbo_postgres.test.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 27c49b0fb..3939512bd 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -321,6 +321,15 @@ class DboSource extends DataSource { * query returning no rows, suchs as a CREATE statement, false otherwise */ protected function _execute($sql, $params = array()) { + $sql = trim($sql); + if (preg_match('/^CREATE|^ALTER|^DROP/i', $sql)) { + $statements = array_filter(explode(';', $sql)); + if (count($statements) > 1) { + $result = array_map(array($this, '_execute'), $statements); + return array_search(false, $result) === false; + } + } + $query = $this->_connection->prepare($sql); $query->setFetchMode(PDO::FETCH_LAZY); if (!$query->execute($params)) { diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index d8c3dadb7..f82e49c1f 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -691,7 +691,7 @@ class DboPostgresTest extends CakeTestCase { 'group2' => array('type' => 'integer', 'null' => true) ) )); - $this->Dbo->query($this->Dbo->createSchema($schema1)); + $this->Dbo->rawQuery($this->Dbo->createSchema($schema1)); $schema2 = new CakeSchema(array( 'name' => 'AlterTest2', From ba1eb626789a2685d54ee0ce8068c6c53f10f327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 20 Oct 2010 23:59:44 -0430 Subject: [PATCH 053/378] Calling right method in DboPostgres::trucante --- cake/libs/model/datasources/dbo/dbo_postgres.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index db264f710..6ed32b0f8 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -318,9 +318,9 @@ class DboPostgres extends DboSource { if (isset($this->_sequenceMap[$table]) && $reset !== 1) { foreach ($this->_sequenceMap[$table] as $field => $sequence) { if ($reset === 0) { - $this->execute("ALTER SEQUENCE \"{$sequence}\" RESTART WITH 1"); + $this->_execute("ALTER SEQUENCE \"{$sequence}\" RESTART WITH 1"); } elseif ($reset === -1) { - $this->execute("DROP SEQUENCE IF EXISTS \"{$sequence}\""); + $this->_execute("DROP SEQUENCE IF EXISTS \"{$sequence}\""); } } } From 226284434666cb5452b000a6e6c514eaad7f7adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 21 Oct 2010 00:01:36 -0430 Subject: [PATCH 054/378] Implementing set encoding in DboPostgres --- cake/libs/model/datasources/dbo/dbo_postgres.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 6ed32b0f8..8a01a4d30 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -773,7 +773,10 @@ class DboPostgres extends DboSource { * @return boolean True on success, false on failure */ function setEncoding($enc) { - return pg_set_client_encoding($this->connection, $enc) == 0; + if ($this->_execute('SET NAMES ?', array($enc))) { + return true; + } + return false; } /** From 88289f071e5f3d4faaca2b7568884a776f5f1ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 21 Oct 2010 00:21:10 -0430 Subject: [PATCH 055/378] Restarting sequences by default qhen calling DboSource::truncate(), removing option to drop the sequence as it does not match behavior from other dbos --- cake/libs/model/datasources/dbo/dbo_postgres.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 8a01a4d30..157f1d02e 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -308,20 +308,16 @@ class DboPostgres extends DboSource { * Deletes all the records in a table and drops all associated auto-increment sequences * * @param mixed $table A string or model class representing the table to be truncated - * @param integer $reset If -1, sequences are dropped, if 0 (default), sequences are reset, + * @param boolean $reset true for resseting the sequence, false to leave it as is. * and if 1, sequences are not modified * @return boolean SQL TRUNCATE TABLE statement, false if not applicable. */ - public function truncate($table, $reset = 0) { + public function truncate($table, $reset = true) { if (parent::truncate($table)) { $table = $this->fullTableName($table, false); - if (isset($this->_sequenceMap[$table]) && $reset !== 1) { + if (isset($this->_sequenceMap[$table]) && $reset) { foreach ($this->_sequenceMap[$table] as $field => $sequence) { - if ($reset === 0) { - $this->_execute("ALTER SEQUENCE \"{$sequence}\" RESTART WITH 1"); - } elseif ($reset === -1) { - $this->_execute("DROP SEQUENCE IF EXISTS \"{$sequence}\""); - } + $this->_execute("ALTER SEQUENCE \"{$sequence}\" RESTART WITH 1"); } } return true; From c7763b316eb2371e16cdce5d3e835955dd10f820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 21 Oct 2010 20:34:11 -0430 Subject: [PATCH 056/378] Fixing some boolean issues in DboPostgres --- .../model/datasources/dbo/dbo_postgres.php | 21 ++++++++++++------- cake/libs/model/datasources/dbo_source.php | 2 +- .../cases/libs/model/model_read.test.php | 4 ++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 157f1d02e..ddc00b1f2 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -742,24 +742,29 @@ class DboPostgres extends DboSource { /** * Translates between PHP boolean values and PostgreSQL boolean values * - * @param mixed $data Value to be translated - * @param boolean $quote True to quote value, false otherwise - * @return mixed Converted boolean value + * @param mixed $data Value to be translated + * @param boolean $quote true to quote a boolean to be used in a query, flase to return the boolean value + * @return boolean Converted boolean value */ function boolean($data, $quote = true) { switch (true) { case ($data === true || $data === false): - return $data; + $result = $data; case ($data === 't' || $data === 'f'): - return ($data === 't'); + $result = ($data === 't'); case ($data === 'true' || $data === 'false'): - return ($data === 'true'); + $result = ($data === 'true'); case ($data === 'TRUE' || $data === 'FALSE'): - return ($data === 'TRUE'); + $result = ($data === 'TRUE'); default: - return (bool)$data; + $result = (bool)$data; break; } + + if ($quote) { + $result = ($result) ? 'TRUE' : 'FALSE'; + } + return $result; } /** diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 3939512bd..607387f72 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -215,7 +215,7 @@ class DboSource extends DataSource { return $this->_connection->quote($data, PDO::PARAM_LOB); break; case 'boolean': - return $this->boolean($data); + return $this->_connection->quote($this->boolean($data), PDO::PARAM_BOOL); break; case 'string': case 'text': diff --git a/cake/tests/cases/libs/model/model_read.test.php b/cake/tests/cases/libs/model/model_read.test.php index 68dc9ce31..37a037a89 100755 --- a/cake/tests/cases/libs/model/model_read.test.php +++ b/cake/tests/cases/libs/model/model_read.test.php @@ -57,8 +57,8 @@ class ModelReadTest extends BaseModelTest { $result = $Something->JoinThing->find('all', array('conditions' => array('something_else_id' => 2))); - $this->assertEqual($result[0]['JoinThing']['doomed'], '1'); - $this->assertEqual($result[1]['JoinThing']['doomed'], '0'); + $this->assertEqual((bool)$result[0]['JoinThing']['doomed'], true); + $this->assertEqual((bool)$result[1]['JoinThing']['doomed'], false); $result = $Something->find('first'); $this->assertEqual(count($result['SomethingElse']), 2); From 139702e91c86e0a5637bd6ddaeb94ef6036d254f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 21 Oct 2010 20:48:26 -0430 Subject: [PATCH 057/378] Moving methods from Dbo's to the parent class as PDO already abstract what they do --- cake/libs/model/datasources/dbo/dbo_mysql.php | 44 ------------------- .../model/datasources/dbo/dbo_postgres.php | 29 ------------ cake/libs/model/datasources/dbo_source.php | 44 +++++++++++++++++++ 3 files changed, 44 insertions(+), 73 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 6930b1b36..81a3564b4 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -199,50 +199,6 @@ class DboMysql extends DboSource { } } -/** - * Returns a formatted error message from previous database operation. - * - * @param PDOStatement $query the query to extract the error from if any - * @return string Error message with error number - */ - function lastError(PDOStatement $query = null) { - $error = $query->errorInfo(); - if (empty($error[2])) { - return null; - } - return $error[1] . ': ' . $error[2]; - } - -/** - * Returns number of affected rows in previous database operation. If no previous operation exists, - * this returns false. - * - * @return integer Number of affected rows - */ - function lastAffected() { - if ($this->hasResult()) { - return $this->_result->rowCount(); - } - return null; - } - -/** - * Returns number of rows in previous resultset. If no previous resultset exists, - * this returns false. - * - * @return integer Number of rows in resultset - */ - function lastNumRows() { - if ($this->hasResult()) { - $i = 0; - foreach ($this->_result as $row) { - $i++; - } - return $i; - } - return null; - } - /** * Returns the ID generated from the previous INSERT operation. * diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index ddc00b1f2..edd22607f 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -245,35 +245,6 @@ class DboPostgres extends DboSource { return $fields; } -/** - * Returns a formatted error message from previous database operation. - * - * @return string Error message - */ - function lastError() { - $error = pg_last_error($this->connection); - return ($error) ? $error : null; - } - -/** - * Returns number of affected rows in previous database operation. If no previous operation exists, this returns false. - * - * @return integer Number of affected rows - */ - function lastAffected() { - return ($this->_result) ? pg_affected_rows($this->_result) : false; - } - -/** - * Returns number of rows in previous resultset. If no previous resultset exists, - * this returns false. - * - * @return integer Number of rows in resultset - */ - function lastNumRows() { - return ($this->_result) ? pg_num_rows($this->_result) : false; - } - /** * Returns the ID generated from the previous INSERT operation. * diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 607387f72..038a11551 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -343,6 +343,50 @@ class DboSource extends DataSource { return $query; } +/** + * Returns a formatted error message from previous database operation. + * + * @param PDOStatement $query the query to extract the error from if any + * @return string Error message with error number + */ + function lastError(PDOStatement $query = null) { + $error = $query->errorInfo(); + if (empty($error[2])) { + return null; + } + return $error[1] . ': ' . $error[2]; + } + +/** + * Returns number of affected rows in previous database operation. If no previous operation exists, + * this returns false. + * + * @return integer Number of affected rows + */ + function lastAffected() { + if ($this->hasResult()) { + return $this->_result->rowCount(); + } + return null; + } + +/** + * Returns number of rows in previous resultset. If no previous resultset exists, + * this returns false. + * + * @return integer Number of rows in resultset + */ + function lastNumRows() { + if ($this->hasResult()) { + $i = 0; + foreach ($this->_result as $row) { + $i++; + } + return $i; + } + return null; + } + /** * DataSource Query abstraction * From 1acb619e757f191d7d6f870643e968af044da8c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 24 Oct 2010 19:59:54 -0430 Subject: [PATCH 058/378] Implementing DboSource::insertMulti so it uses prepared statements, also changing internal uses of this method to reflect the new api, this brings as consequence a better abstracttion for datasources in model and fixtures, but breaks BC --- cake/libs/model/datasources/dbo/dbo_mysql.php | 16 ---------------- cake/libs/model/datasources/dbo_source.php | 15 +++++++++------ cake/libs/model/model.php | 11 +++-------- .../libs/model/behavior_collection.test.php | 1 + cake/tests/cases/libs/model/model_read.test.php | 4 ++-- cake/tests/lib/cake_test_fixture.php | 4 ++-- 6 files changed, 17 insertions(+), 34 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 81a3564b4..7e8eef21b 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -580,22 +580,6 @@ class DboMysql extends DboSource { return $alter; } -/** - * Inserts multiple values into a table - * - * @param string $table - * @param string $fields - * @param array $values - */ - function insertMulti($table, $fields, $values) { - $table = $this->fullTableName($table); - if (is_array($fields)) { - $fields = implode(', ', array_map(array(&$this, 'name'), $fields)); - } - $values = implode(', ', $values); - $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values}"); - } - /** * Returns an detailed array of sources (tables) in the database. * diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 038a11551..8dde0531f 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -291,8 +291,7 @@ class DboSource extends DataSource { * @return mixed Resource or object representing the result set, or false on failure */ public function execute($sql, $options = array(), $params = array()) { - $defaults = array('log' => $this->fullDebug); - $options = array_merge($defaults, $options); + $options = $options + array('log' => $this->fullDebug); $this->error = null; $t = microtime(true); @@ -2686,13 +2685,17 @@ class DboSource extends DataSource { */ public function insertMulti($table, $fields, $values) { $table = $this->fullTableName($table); - if (is_array($fields)) { - $fields = implode(', ', array_map(array(&$this, 'name'), $fields)); - } + $holder = implode(',', array_fill(0, count($fields), '?')); + $fields = implode(', ', array_map(array(&$this, 'name'), $fields)); + $count = count($values); + $sql = "INSERT INTO {$table} ({$fields}) VALUES ({$holder})"; + $statement = $this->_connection->prepare($sql); for ($x = 0; $x < $count; $x++) { - $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}"); + $statement->execute($values[$x]); + $statement->closeCursor(); } + return true; } /** diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index c4b693a0c..d6954b97d 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1459,15 +1459,11 @@ class Model extends Object { foreach ((array)$data as $row) { if ((is_string($row) && (strlen($row) == 36 || strlen($row) == 16)) || is_numeric($row)) { - $values = array( - $db->value($id, $this->getColumnType($this->primaryKey)), - $db->value($row) - ); + $values = array($id, $row); if ($isUUID && $primaryAdded) { - $values[] = $db->value(String::uuid()); + $values[] = String::uuid(); } - $values = implode(',', $values); - $newValues[] = "({$values})"; + $newValues[] = $values; unset($values); } elseif (isset($row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) { $newData[] = $row; @@ -1506,7 +1502,6 @@ class Model extends Object { } if (!empty($newValues)) { - $fields = implode(',', $fields); $db->insertMulti($this->{$join}, $fields, $newValues); } } diff --git a/cake/tests/cases/libs/model/behavior_collection.test.php b/cake/tests/cases/libs/model/behavior_collection.test.php index a40fee525..92c8fff5e 100644 --- a/cake/tests/cases/libs/model/behavior_collection.test.php +++ b/cake/tests/cases/libs/model/behavior_collection.test.php @@ -546,6 +546,7 @@ class BehaviorCollectionTest extends CakeTestCase { */ function testBehaviorToggling() { $Apple = new Apple(); + $expected = $Apple->find('all'); $this->assertIdentical($Apple->Behaviors->enabled(), array()); $Apple->Behaviors->init('Apple', array('Test' => array('key' => 'value'))); diff --git a/cake/tests/cases/libs/model/model_read.test.php b/cake/tests/cases/libs/model/model_read.test.php index 37a037a89..7e0484700 100755 --- a/cake/tests/cases/libs/model/model_read.test.php +++ b/cake/tests/cases/libs/model/model_read.test.php @@ -5076,7 +5076,7 @@ class ModelReadTest extends BaseModelTest { 'typ' => 2 ))); - $this->assertEqual($result, $expected); + $this->assertEqual($expected, $result); } /** @@ -5646,7 +5646,7 @@ class ModelReadTest extends BaseModelTest { 'name' => 'computer' )))))); - $this->assertIdentical($result, $expected); + $this->assertEquals($result, $expected); } /** diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index eeeae5c9d..fee5721b6 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -163,13 +163,13 @@ class CakeTestFixture { * @return boolean on success or if there are no records to insert, or false on failure */ public function insert(&$db) { + $this->truncate($db); if (!isset($this->_insert)) { $values = array(); - if (isset($this->records) && !empty($this->records)) { foreach ($this->records as $record) { $fields = array_keys($record); - $values[] = '(' . implode(', ', array_map(array(&$db, 'value'), array_values($record))) . ')'; + $values[] = array_values($record); } return $db->insertMulti($this->table, $fields, $values); } From 2ec9a49f173d8dbaefdb31a63092702ce61a0072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 24 Oct 2010 20:01:33 -0430 Subject: [PATCH 059/378] Resolving yet more problems with booleans in postgres --- cake/libs/model/datasources/dbo/dbo_postgres.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index edd22607f..bbe7d5623 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -728,14 +728,14 @@ class DboPostgres extends DboSource { case ($data === 'TRUE' || $data === 'FALSE'): $result = ($data === 'TRUE'); default: - $result = (bool)$data; + $result = (bool) $data; break; } if ($quote) { $result = ($result) ? 'TRUE' : 'FALSE'; } - return $result; + return (int) $result; } /** From f00f4eae0fc6e256c5180938941bfb08829e353b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 24 Oct 2010 20:02:11 -0430 Subject: [PATCH 060/378] Implementing getClientEncoding using postgres --- cake/libs/model/datasources/dbo/dbo_postgres.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index bbe7d5623..32b89d80f 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -757,7 +757,7 @@ class DboPostgres extends DboSource { * @return string The database encoding */ function getEncoding() { - return pg_client_encoding($this->connection); + $cosa = $this->_execute('SHOW client_encoding')->fetch(); } /** From 49ed8ede8eb5ff1f8266c98adfdd843cb8fd0d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 25 Oct 2010 19:45:46 -0430 Subject: [PATCH 061/378] Trucating tables in postgres now correctly resets the associated sequences --- .../model/datasources/dbo/dbo_postgres.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 32b89d80f..a58c1a077 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -221,10 +221,12 @@ class DboPostgres extends DboSource { ), 'length' => $length ); - if ($c->name == $model->primaryKey) { - $fields[$c->name]['key'] = 'primary'; - if ($fields[$c->name]['type'] !== 'string') { - $fields[$c->name]['length'] = 11; + if ($model instanceof Model) { + if ($c->name == $model->primaryKey) { + $fields[$c->name]['key'] = 'primary'; + if ($fields[$c->name]['type'] !== 'string') { + $fields[$c->name]['length'] = 11; + } } } if ( @@ -284,8 +286,14 @@ class DboPostgres extends DboSource { * @return boolean SQL TRUNCATE TABLE statement, false if not applicable. */ public function truncate($table, $reset = true) { + $table = $this->fullTableName($table, false); + if (!isset($this->_sequenceMap[$table])) { + $cache = $this->cacheSources; + $this->cacheSources = false; + $this->describe($table); + $this->cacheSources = $cache; + } if (parent::truncate($table)) { - $table = $this->fullTableName($table, false); if (isset($this->_sequenceMap[$table]) && $reset) { foreach ($this->_sequenceMap[$table] as $field => $sequence) { $this->_execute("ALTER SEQUENCE \"{$sequence}\" RESTART WITH 1"); From a6b67207178ac6910512c7aaf18835c2051abc32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 25 Oct 2010 19:46:23 -0430 Subject: [PATCH 062/378] Fixing bug in boolean conversion for postgres --- cake/libs/model/datasources/dbo/dbo_postgres.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index a58c1a077..eeaaec1b6 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -741,7 +741,7 @@ class DboPostgres extends DboSource { } if ($quote) { - $result = ($result) ? 'TRUE' : 'FALSE'; + return ($result) ? 'TRUE' : 'FALSE'; } return (int) $result; } From f027bf0f7b1652d9989f27123f60981744085143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 25 Oct 2010 19:47:00 -0430 Subject: [PATCH 063/378] Fixing some errors in tests --- cake/tests/cases/libs/model/model_write.test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index 13c6fa8b9..74b90f31a 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -203,8 +203,8 @@ class ModelWriteTest extends BaseModelTest { $TestModel->create(array()); $TestModel->save(); $result = $TestModel->findById($TestModel->id); - $this->assertIdentical($result['DataTest']['count'], '0'); - $this->assertIdentical($result['DataTest']['float'], '0'); + $this->assertEquals($result['DataTest']['count'], 0); + $this->assertEquals($result['DataTest']['float'], 0); } /** @@ -288,20 +288,20 @@ class ModelWriteTest extends BaseModelTest { )); $result = $TestModel->findById(1); - $this->assertIdentical($result['Syfile']['item_count'], '2'); + $this->assertEquals($result['Syfile']['item_count'], 2); $TestModel2->delete(1); $result = $TestModel->findById(1); - $this->assertIdentical($result['Syfile']['item_count'], '1'); + $this->assertEquals($result['Syfile']['item_count'], 1); $TestModel2->id = 2; $TestModel2->saveField('syfile_id', 1); $result = $TestModel->findById(1); - $this->assertIdentical($result['Syfile']['item_count'], '2'); + $this->assertEquals($result['Syfile']['item_count'], 2); $result = $TestModel->findById(2); - $this->assertIdentical($result['Syfile']['item_count'], '0'); + $this->assertEquals($result['Syfile']['item_count'], 0); } /** From cec3512835cfcef3e9ad5bf1b9a986b80627312f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 25 Oct 2010 19:47:32 -0430 Subject: [PATCH 064/378] Fixing more errors in tests related to type casting --- cake/tests/cases/libs/model/model_write.test.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index 74b90f31a..4ced3b61b 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -439,7 +439,7 @@ class ModelWriteTest extends BaseModelTest { * @return void */ function testSaveWithCounterCacheScope() { - $this->loadFixtures('Syfile', 'Item'); + $this->loadFixtures('Syfile', 'Item', 'Image', 'ItemsPortfolio', 'Portfolio'); $TestModel = new Syfile(); $TestModel2 = new Item(); $TestModel2->belongsTo['Syfile']['counterCache'] = true; @@ -455,12 +455,13 @@ class ModelWriteTest extends BaseModelTest { )); $result = $TestModel->findById(1); - $this->assertIdentical($result['Syfile']['item_count'], '1'); + debug($result); + $this->assertEquals($result['Syfile']['item_count'], 1); $TestModel2->id = 1; $TestModel2->saveField('published', true); $result = $TestModel->findById(1); - $this->assertIdentical($result['Syfile']['item_count'], '2'); + $this->assertEquals($result['Syfile']['item_count'], 2); $TestModel2->save(array( 'id' => 1, @@ -469,7 +470,7 @@ class ModelWriteTest extends BaseModelTest { )); $result = $TestModel->findById(1); - $this->assertIdentical($result['Syfile']['item_count'], '1'); + $this->assertEquals($result['Syfile']['item_count'], 1); } /** @@ -2416,7 +2417,7 @@ class ModelWriteTest extends BaseModelTest { * @return void */ function testSaveAll() { - $this->loadFixtures('Post', 'Author', 'Comment', 'Attachment'); + $this->loadFixtures('Post', 'Author', 'Comment', 'Attachment', 'Article', 'User'); $TestModel = new Post(); $result = $TestModel->find('all'); @@ -2556,7 +2557,7 @@ class ModelWriteTest extends BaseModelTest { * @return void */ function testSaveAllHabtm() { - $this->loadFixtures('Article', 'Tag', 'Comment', 'User'); + $this->loadFixtures('Article', 'Tag', 'Comment', 'User', 'ArticlesTag'); $data = array( 'Article' => array( 'user_id' => 1, From 2eb0392b8a98df485915010e8c7131b53b7ddfd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 25 Oct 2010 19:47:53 -0430 Subject: [PATCH 065/378] Removing forced trucation of tables in fixture loading, it was not really needed --- cake/tests/lib/cake_test_fixture.php | 1 - 1 file changed, 1 deletion(-) diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index fee5721b6..b7676cf5c 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -163,7 +163,6 @@ class CakeTestFixture { * @return boolean on success or if there are no records to insert, or false on failure */ public function insert(&$db) { - $this->truncate($db); if (!isset($this->_insert)) { $values = array(); if (isset($this->records) && !empty($this->records)) { From 25c213e976762361f554f8446b8338f9bab629e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 25 Oct 2010 20:25:07 -0430 Subject: [PATCH 066/378] Preventing zero length of fields using prostgres --- cake/libs/model/datasources/dbo/dbo_postgres.php | 3 +++ cake/tests/cases/libs/model/model_write.test.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index eeaaec1b6..63b069199 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -211,6 +211,9 @@ class DboPostgres extends DboSource { } else { $length = $this->length($c->type); } + if (empty($length)) { + $length = null; + } $fields[$c->name] = array( 'type' => $this->column($type), 'null' => ($c->null == 'NO' ? false : true), diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index 4ced3b61b..c4115b2e3 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -455,7 +455,7 @@ class ModelWriteTest extends BaseModelTest { )); $result = $TestModel->findById(1); - debug($result); + $this->assertEquals($result['Syfile']['item_count'], 1); $TestModel2->id = 1; From f94f79e14639a187479cbe18d3194213f6c5c7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 25 Oct 2010 23:40:24 -0430 Subject: [PATCH 067/378] Initial steps to start using virtual fields in TranslateBehavior, this will ease Dbo abstraction --- cake/libs/model/behaviors/translate.php | 67 ++++++++----------------- 1 file changed, 21 insertions(+), 46 deletions(-) diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index 99f4004e9..d50c64325 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -113,39 +113,16 @@ class TranslateBehavior extends ModelBehavior { ); return $query; } - $autoFields = false; - if (empty($query['fields'])) { - $query['fields'] = array($model->alias.'.*'); - - $recursive = $model->recursive; - if (isset($query['recursive'])) { - $recursive = $query['recursive']; - } - - if ($recursive >= 0) { - foreach (array('hasOne', 'belongsTo') as $type) { - foreach ($model->{$type} as $key => $value) { - - if (empty($value['fields'])) { - $query['fields'][] = $key.'.*'; - } else { - foreach ($value['fields'] as $field) { - $query['fields'][] = $key.'.'.$field; - } - } - } - } - } - $autoFields = true; - } $fields = array_merge($this->settings[$model->alias], $this->runtime[$model->alias]['fields']); $addFields = array(); - if (is_array($query['fields'])) { + if (empty($query['fields'])) { + $addFields = $fields; + } else if (is_array($query['fields'])) { foreach ($fields as $key => $value) { $field = (is_numeric($key)) ? $value : $key; - if (in_array($model->alias.'.*', $query['fields']) || $autoFields || in_array($model->alias.'.'.$field, $query['fields']) || in_array($field, $query['fields'])) { + if (in_array($model->alias.'.*', $query['fields']) || in_array($model->alias.'.'.$field, $query['fields']) || in_array($field, $query['fields'])) { $addFields[] = $field; } } @@ -153,17 +130,17 @@ class TranslateBehavior extends ModelBehavior { if ($addFields) { foreach ($addFields as $field) { - foreach (array($field, $model->alias.'.'.$field) as $_field) { - $key = array_search($_field, $query['fields']); - - if ($key !== false) { - unset($query['fields'][$key]); - } - } + // foreach (array($field, $model->alias.'.'.$field) as $_field) { + // $key = array_search($_field, $query['fields']); + // + // if ($key !== false) { + // unset($query['fields'][$key]); + // } + // } if (is_array($locale)) { foreach ($locale as $_locale) { - $query['fields'][] = 'I18n__'.$field.'__'.$_locale.'.content'; + $model->virtualFields['_i18n_'.$field.'_'.$_locale] = 'COALESCE('. 'I18n__'.$field.'__'.$_locale.'.content, NULL)'; $query['joins'][] = array( 'type' => 'LEFT', 'alias' => 'I18n__'.$field.'__'.$_locale, @@ -177,7 +154,7 @@ class TranslateBehavior extends ModelBehavior { ); } } else { - $query['fields'][] = 'I18n__'.$field.'.content'; + $model->virtualFields['_i18n_'.$field] = 'COALESCE('. 'I18n__'.$field.'.content, NULL)'; $query['joins'][] = array( 'type' => 'LEFT', 'alias' => 'I18n__'.$field, @@ -197,9 +174,6 @@ class TranslateBehavior extends ModelBehavior { } } } - if (is_array($query['fields'])) { - $query['fields'] = array_merge($query['fields']); - } $this->runtime[$model->alias]['beforeFind'] = $addFields; return $query; } @@ -221,10 +195,10 @@ class TranslateBehavior extends ModelBehavior { } $beforeFind = $this->runtime[$model->alias]['beforeFind']; - foreach ($results as $key => $row) { - $results[$key][$model->alias]['locale'] = (is_array($locale)) ? @$locale[0] : $locale; + foreach ($results as $key => &$row) { + $results[$key][$model->alias]['locale'] = (is_array($locale)) ? current($locale) : $locale; - foreach ($beforeFind as $field) { + foreach ($beforeFind as $_f => $field) { if (is_array($locale)) { foreach ($locale as $_locale) { if (!isset($results[$key][$model->alias][$field]) && !empty($results[$key]['I18n__'.$field.'__'.$_locale]['content'])) { @@ -238,11 +212,12 @@ class TranslateBehavior extends ModelBehavior { } } else { $value = ''; - if (!empty($results[$key]['I18n__'.$field]['content'])) { - $value = $results[$key]['I18n__'.$field]['content']; + if (!empty($row[$model->alias]['_i18n_' . $field])) { + $value = $row[$model->alias]['_i18n_' . $field]; } - $results[$key][$model->alias][$field] = $value; - unset($results[$key]['I18n__'.$field]); + $aliasField = is_numeric($_f) ? $field : $_f; + $row[$model->alias][$aliasField] = $value; + unset($row[$model->alias]['_i18n_' . $field]); } } } From e989f71b99c6a1dca68fb980b4e2128692bdc705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2010 17:49:43 -0430 Subject: [PATCH 068/378] making a backup of model virtual fields in traslate behavrio to avoid side effects --- cake/libs/model/behaviors/translate.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index d50c64325..9aa85feca 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -87,6 +87,7 @@ class TranslateBehavior extends ModelBehavior { * @return array Modified query */ public function beforeFind(&$model, $query) { + $this->runtime[$model->alias]['virtualFields'] = $model->virtualFields; $locale = $this->_getLocale($model); if (empty($locale)) { return $query; @@ -128,6 +129,7 @@ class TranslateBehavior extends ModelBehavior { } } + $this->runtime[$model->alias]['virtualFields'] = $model->virtualFields; if ($addFields) { foreach ($addFields as $field) { // foreach (array($field, $model->alias.'.'.$field) as $_field) { From 90274ef859838ba36a8a255faf94d055a7cf644d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2010 17:50:37 -0430 Subject: [PATCH 069/378] restoring commented code to make more tests pass --- cake/libs/model/behaviors/translate.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index 9aa85feca..8d8be9f8f 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -132,13 +132,13 @@ class TranslateBehavior extends ModelBehavior { $this->runtime[$model->alias]['virtualFields'] = $model->virtualFields; if ($addFields) { foreach ($addFields as $field) { - // foreach (array($field, $model->alias.'.'.$field) as $_field) { - // $key = array_search($_field, $query['fields']); - // - // if ($key !== false) { - // unset($query['fields'][$key]); - // } - // } + foreach (array($field, $model->alias.'.'.$field) as $_field) { + $key = array_search($_field, (array)$query['fields']); + + if ($key !== false) { + unset($query['fields'][$key]); + } + } if (is_array($locale)) { foreach ($locale as $_locale) { From 02635696d7b86d4b8986d8cba90fa947b02f2f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2010 17:51:29 -0430 Subject: [PATCH 070/378] Removing function from created virtual fields in translate behavior as it was not needed --- cake/libs/model/behaviors/translate.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index 8d8be9f8f..90a0c5fd6 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -142,7 +142,10 @@ class TranslateBehavior extends ModelBehavior { if (is_array($locale)) { foreach ($locale as $_locale) { - $model->virtualFields['_i18n_'.$field.'_'.$_locale] = 'COALESCE('. 'I18n__'.$field.'__'.$_locale.'.content, NULL)'; + $model->virtualFields['i18n_'.$field.'_'.$_locale] = 'I18n__'.$field.'__'.$_locale.'.content'; + if (!empty($query['fields'])) { + $query['fields'][] = 'i18n_'.$field.'_'.$_locale; + } $query['joins'][] = array( 'type' => 'LEFT', 'alias' => 'I18n__'.$field.'__'.$_locale, @@ -156,7 +159,10 @@ class TranslateBehavior extends ModelBehavior { ); } } else { - $model->virtualFields['_i18n_'.$field] = 'COALESCE('. 'I18n__'.$field.'.content, NULL)'; + $model->virtualFields['i18n_'.$field] = 'I18n__'.$field.'.content'; + if (!empty($query['fields'])) { + $query['fields'][] = 'i18n_'.$field; + } $query['joins'][] = array( 'type' => 'LEFT', 'alias' => 'I18n__'.$field, @@ -189,7 +195,8 @@ class TranslateBehavior extends ModelBehavior { * @return array Modified results */ public function afterFind(&$model, $results, $primary) { - $this->runtime[$model->alias]['fields'] = array(); + $model->virtualFields = $this->runtime[$model->alias]['virtualFields']; + $this->runtime[$model->alias]['virtualFields'] = $this->runtime[$model->alias]['fields'] = array(); $locale = $this->_getLocale($model); if (empty($locale) || empty($results) || empty($this->runtime[$model->alias]['beforeFind'])) { From 9f27fa7dfbd58b39044b6824b916600f0f09ec42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2010 17:52:40 -0430 Subject: [PATCH 071/378] Fixing parsing of translated data after switching to virtualFields --- cake/libs/model/behaviors/translate.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index 90a0c5fd6..44336462a 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -206,27 +206,28 @@ class TranslateBehavior extends ModelBehavior { foreach ($results as $key => &$row) { $results[$key][$model->alias]['locale'] = (is_array($locale)) ? current($locale) : $locale; - foreach ($beforeFind as $_f => $field) { + $aliasField = is_numeric($_f) ? $field : $_f; + if (is_array($locale)) { foreach ($locale as $_locale) { - if (!isset($results[$key][$model->alias][$field]) && !empty($results[$key]['I18n__'.$field.'__'.$_locale]['content'])) { - $results[$key][$model->alias][$field] = $results[$key]['I18n__'.$field.'__'.$_locale]['content']; + if (!isset($row[$model->alias][$aliasField]) && !empty($row[$model->alias]['i18n_'.$field.'_'.$_locale])) { + $row[$model->alias][$aliasField] = $row[$model->alias]['i18n_'.$field.'_'.$_locale]; + $row[$model->alias]['locale'] = $_locale; } - unset($results[$key]['I18n__'.$field.'__'.$_locale]); + unset($row[$model->alias]['i18n_'.$field.'_'.$_locale]); } - if (!isset($results[$key][$model->alias][$field])) { - $results[$key][$model->alias][$field] = ''; + if (!isset($row[$model->alias][$aliasField])) { + $row[$model->alias][$aliasField] = ''; } } else { $value = ''; - if (!empty($row[$model->alias]['_i18n_' . $field])) { - $value = $row[$model->alias]['_i18n_' . $field]; + if (!empty($row[$model->alias]['i18n_' . $field])) { + $value = $row[$model->alias]['i18n_' . $field]; } - $aliasField = is_numeric($_f) ? $field : $_f; $row[$model->alias][$aliasField] = $value; - unset($row[$model->alias]['_i18n_' . $field]); + unset($row[$model->alias]['i18n_' . $field]); } } } From 16524bc72f6e64cacfb87dd8fdb4e2c8a26b4a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2010 17:53:33 -0430 Subject: [PATCH 072/378] Fixing test case for translate behavior --- cake/tests/cases/libs/model/behaviors/translate.test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/tests/cases/libs/model/behaviors/translate.test.php b/cake/tests/cases/libs/model/behaviors/translate.test.php index aa833dc33..907907c9b 100644 --- a/cake/tests/cases/libs/model/behaviors/translate.test.php +++ b/cake/tests/cases/libs/model/behaviors/translate.test.php @@ -313,17 +313,17 @@ class TranslateBehaviorTest extends CakeTestCase { $result = $TestModel->find('all', array('fields' => array('TranslatedItem.title'))); $expected = array( array( - 'TranslatedItem' => array('id' => 1, 'locale' => 'eng', 'title' => 'Title #1'), + 'TranslatedItem' => array('id' => 1, 'locale' => 'eng', 'title' => 'Title #1', 'slug' => 'first_translated'), 'Title' => array(array('foreign_key' => 1, 'content' => 'Title #1')), 'Content' => array(array('foreign_key' => 1, 'content' => 'Content #1')) ), array( - 'TranslatedItem' => array('id' => 2, 'locale' => 'eng', 'title' => 'Title #2'), + 'TranslatedItem' => array('id' => 2, 'locale' => 'eng', 'title' => 'Title #2', 'slug' => 'second_translated'), 'Title' => array(array('foreign_key' => 2, 'content' => 'Title #2')), 'Content' => array(array('foreign_key' => 2, 'content' => 'Content #2')) ), array( - 'TranslatedItem' => array('id' => 3, 'locale' => 'eng', 'title' => 'Title #3'), + 'TranslatedItem' => array('id' => 3, 'locale' => 'eng', 'title' => 'Title #3','slug' => 'third_translated'), 'Title' => array(array('foreign_key' => 3, 'content' => 'Title #3')), 'Content' => array(array('foreign_key' => 3, 'content' => 'Content #3')) ) From cc32ac89040e9efe03ac23e1cd0407b67748d715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2010 17:55:50 -0430 Subject: [PATCH 073/378] Simplifying tests for translatable behavior as they were hard to understand --- .../libs/model/behaviors/translate.test.php | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/cake/tests/cases/libs/model/behaviors/translate.test.php b/cake/tests/cases/libs/model/behaviors/translate.test.php index 907907c9b..51c9052d5 100644 --- a/cake/tests/cases/libs/model/behaviors/translate.test.php +++ b/cake/tests/cases/libs/model/behaviors/translate.test.php @@ -185,6 +185,7 @@ class TranslateBehaviorTest extends CakeTestCase { $TestModel = new TranslatedItem(); $TestModel->locale = 'eng'; + $result = $TestModel->read(null, 1); $expected = array( 'TranslatedItem' => array( @@ -342,16 +343,7 @@ class TranslateBehaviorTest extends CakeTestCase { $TestModel = new TranslatedItem(); $TestModel->locale = array('deu', 'eng', 'cze'); - $delete = array( - array('locale' => 'deu'), - array('foreign_key' => 1, 'field' => 'title', 'locale' => 'eng'), - array('foreign_key' => 1, 'field' => 'content', 'locale' => 'cze'), - array('foreign_key' => 2, 'field' => 'title', 'locale' => 'cze'), - array('foreign_key' => 2, 'field' => 'content', 'locale' => 'eng'), - array('foreign_key' => 3, 'field' => 'title') - ); - $I18nModel = ClassRegistry::getObject('TranslateTestModel'); - $I18nModel->deleteAll(array('or' => $delete)); + $result = $TestModel->read(null, 1); $expected = array( @@ -359,8 +351,8 @@ class TranslateBehaviorTest extends CakeTestCase { 'id' => 1, 'slug' => 'first_translated', 'locale' => 'deu', - 'title' => 'Titulek #1', - 'content' => 'Content #1' + 'title' => 'Titel #1', + 'content' => 'Inhalt #1' ) ); $this->assertEqual($result, $expected); @@ -371,28 +363,29 @@ class TranslateBehaviorTest extends CakeTestCase { 'TranslatedItem' => array( 'slug' => 'first_translated', 'locale' => 'deu', - 'title' => 'Titulek #1', - 'content' => 'Content #1' + 'content' => 'Inhalt #1', + 'title' => 'Titel #1' ) ), array( 'TranslatedItem' => array( 'slug' => 'second_translated', 'locale' => 'deu', - 'title' => 'Title #2', - 'content' => 'Obsah #2' + 'title' => 'Titel #2', + 'content' => 'Inhalt #2' ) ), array( 'TranslatedItem' => array( 'slug' => 'third_translated', 'locale' => 'deu', - 'title' => '', - 'content' => 'Content #3' + 'title' => 'Titel #3', + 'content' => 'Inhalt #3' ) ) ); - $this->assertEqual($result, $expected); + + $this->assertEquals($result, $expected); } /** From ce490b1df2e0095aa2c20b89c765b3800a9d91d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2010 18:22:13 -0430 Subject: [PATCH 074/378] Fixing issues with translatable field aliasing in TranslateBehavior --- cake/libs/model/behaviors/translate.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index 44336462a..8f9256dfa 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -131,8 +131,10 @@ class TranslateBehavior extends ModelBehavior { $this->runtime[$model->alias]['virtualFields'] = $model->virtualFields; if ($addFields) { - foreach ($addFields as $field) { - foreach (array($field, $model->alias.'.'.$field) as $_field) { + foreach ($addFields as $_f => $field) { + $aliasField = is_numeric($_f) ? $field : $_f; + + foreach (array($aliasField, $model->alias.'.'.$aliasField) as $_field) { $key = array_search($_field, (array)$query['fields']); if ($key !== false) { @@ -153,7 +155,7 @@ class TranslateBehavior extends ModelBehavior { 'conditions' => array( $model->alias . '.' . $model->primaryKey => $db->identifier("I18n__{$field}__{$_locale}.foreign_key"), 'I18n__'.$field.'__'.$_locale.'.model' => $model->name, - 'I18n__'.$field.'__'.$_locale.'.'.$RuntimeModel->displayField => $field, + 'I18n__'.$field.'__'.$_locale.'.'.$RuntimeModel->displayField => $aliasField, 'I18n__'.$field.'__'.$_locale.'.locale' => $_locale ) ); @@ -170,7 +172,7 @@ class TranslateBehavior extends ModelBehavior { 'conditions' => array( $model->alias . '.' . $model->primaryKey => $db->identifier("I18n__{$field}.foreign_key"), 'I18n__'.$field.'.model' => $model->name, - 'I18n__'.$field.'.'.$RuntimeModel->displayField => $field + 'I18n__'.$field.'.'.$RuntimeModel->displayField => $aliasField ) ); From ff9748c6ba069d22f1effb9507d03c4c0c03cbc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2010 20:34:25 -0430 Subject: [PATCH 075/378] Adding some workaround in traslate behavior tests for postgres, all tests passing now --- .../libs/model/behaviors/translate.test.php | 2 ++ cake/tests/fixtures/translate_fixture.php | 36 +++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/cake/tests/cases/libs/model/behaviors/translate.test.php b/cake/tests/cases/libs/model/behaviors/translate.test.php index 51c9052d5..ee13fe3bb 100644 --- a/cake/tests/cases/libs/model/behaviors/translate.test.php +++ b/cake/tests/cases/libs/model/behaviors/translate.test.php @@ -633,6 +633,8 @@ class TranslateBehaviorTest extends CakeTestCase { $translations = array('title' => 'Title', 'content' => 'Content'); $TestModel->bindTranslation($translations, false); $result = $TestModel->read(null, 1); + $result['Title'] = Set::sort($result['Title'], '{n}.id', 'asc'); + $result['Content'] = Set::sort($result['Content'], '{n}.id', 'asc'); $expected = array( 'TranslatedItem' => array('id' => 1, 'slug' => 'first_translated', 'locale' => 'cze', 'title' => 'Titulek #1', 'content' => 'Upraveny obsah #1'), 'Title' => array( diff --git a/cake/tests/fixtures/translate_fixture.php b/cake/tests/fixtures/translate_fixture.php index c056d3e8c..bc7926a4d 100644 --- a/cake/tests/fixtures/translate_fixture.php +++ b/cake/tests/fixtures/translate_fixture.php @@ -64,23 +64,23 @@ class TranslateFixture extends CakeTestFixture { * @access public */ public $records = array( - array('id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Title #1'), - array('id' => 2, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Content #1'), - array('id' => 3, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titel #1'), - array('id' => 4, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Inhalt #1'), - array('id' => 5, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titulek #1'), - array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Obsah #1'), - array('id' => 7, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Title #2'), - array('id' => 8, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'content', 'content' => 'Content #2'), - array('id' => 9, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Titel #2'), - array('id' => 10, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'content', 'content' => 'Inhalt #2'), - array('id' => 11, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Titulek #2'), - array('id' => 12, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'content', 'content' => 'Obsah #2'), - array('id' => 13, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'title', 'content' => 'Title #3'), - array('id' => 14, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'content', 'content' => 'Content #3'), - array('id' => 15, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'title', 'content' => 'Titel #3'), - array('id' => 16, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'content', 'content' => 'Inhalt #3'), - array('id' => 17, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'title', 'content' => 'Titulek #3'), - array('id' => 18, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'content', 'content' => 'Obsah #3') + array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Title #1'), + array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Content #1'), + array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titel #1'), + array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Inhalt #1'), + array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titulek #1'), + array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Obsah #1'), + array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Title #2'), + array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'content', 'content' => 'Content #2'), + array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Titel #2'), + array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'content', 'content' => 'Inhalt #2'), + array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Titulek #2'), + array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 2, 'field' => 'content', 'content' => 'Obsah #2'), + array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'title', 'content' => 'Title #3'), + array('locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'content', 'content' => 'Content #3'), + array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'title', 'content' => 'Titel #3'), + array('locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'content', 'content' => 'Inhalt #3'), + array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'title', 'content' => 'Titulek #3'), + array('locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 3, 'field' => 'content', 'content' => 'Obsah #3') ); } From b3d8a619a3d5de7bd3177750033091f35f828719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2010 21:46:29 -0430 Subject: [PATCH 076/378] Updating test for booleans in postgres --- .../model/datasources/dbo/dbo_postgres.php | 4 ++++ .../datasources/dbo/dbo_postgres.test.php | 20 +++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 63b069199..313036ac5 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -732,12 +732,16 @@ class DboPostgres extends DboSource { switch (true) { case ($data === true || $data === false): $result = $data; + break; case ($data === 't' || $data === 'f'): $result = ($data === 't'); + break; case ($data === 'true' || $data === 'false'): $result = ($data === 'true'); + break; case ($data === 'TRUE' || $data === 'FALSE'): $result = ($data === 'TRUE'); + break; default: $result = (bool) $data; break; diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index f82e49c1f..049ca1d9a 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -340,18 +340,18 @@ class DboPostgresTest extends CakeTestCase { $this->assertEqual($this->Dbo->value('', 'float', false), "NULL"); $this->assertEqual($this->Dbo->value('0.0', 'float'), "'0.0'"); - $this->assertEqual($this->Dbo->value('t', 'boolean'), true); - $this->assertEqual($this->Dbo->value('f', 'boolean'), false); - $this->assertEqual($this->Dbo->value(true), true); - $this->assertEqual($this->Dbo->value(false), false); + $this->assertEqual($this->Dbo->value('t', 'boolean'), "'TRUE'"); + $this->assertEqual($this->Dbo->value('f', 'boolean'), "'FALSE'"); + $this->assertEqual($this->Dbo->value(true), "'TRUE'"); + $this->assertEqual($this->Dbo->value(false), "'FALSE'"); $this->assertEqual($this->Dbo->value('t'), "'t'"); $this->assertEqual($this->Dbo->value('f'), "'f'"); - $this->assertEqual($this->Dbo->value('true', 'boolean'), true); - $this->assertEqual($this->Dbo->value('false', 'boolean'), false); - $this->assertEqual($this->Dbo->value('', 'boolean'), false); - $this->assertEqual($this->Dbo->value(0, 'boolean'), false); - $this->assertEqual($this->Dbo->value(1, 'boolean'), true); - $this->assertEqual($this->Dbo->value('1', 'boolean'), true); + $this->assertEqual($this->Dbo->value('true', 'boolean'), "'TRUE'"); + $this->assertEqual($this->Dbo->value('false', 'boolean'), "'FALSE'"); + $this->assertEqual($this->Dbo->value('', 'boolean'), "'FALSE'"); + $this->assertEqual($this->Dbo->value(0, 'boolean'), "'FALSE'"); + $this->assertEqual($this->Dbo->value(1, 'boolean'), "'TRUE'"); + $this->assertEqual($this->Dbo->value('1', 'boolean'), "'TRUE'"); $this->assertEqual($this->Dbo->value(null, 'boolean'), "NULL"); $this->assertEqual($this->Dbo->value(array()), "NULL"); } From eb49181c483f7a87e0f22c2d19cd6b844c00b649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2010 21:49:03 -0430 Subject: [PATCH 077/378] Bringing more boolean tests up to date in postgres --- .../datasources/dbo/dbo_postgres.test.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 049ca1d9a..6df1aeee8 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -400,19 +400,19 @@ class DboPostgresTest extends CakeTestCase { * @return void */ function testBooleanNormalization() { - $this->assertTrue($this->Dbo2->boolean('t')); - $this->assertTrue($this->Dbo2->boolean('true')); - $this->assertTrue($this->Dbo2->boolean('TRUE')); - $this->assertTrue($this->Dbo2->boolean(true)); - $this->assertTrue($this->Dbo2->boolean(1)); - $this->assertTrue($this->Dbo2->boolean(" ")); + $this->assertEquals(1, $this->Dbo2->boolean('t', false)); + $this->assertEquals(1, $this->Dbo2->boolean('true', false)); + $this->assertEquals(1, $this->Dbo2->boolean('TRUE', false)); + $this->assertEquals(1, $this->Dbo2->boolean(true, false)); + $this->assertEquals(1, $this->Dbo2->boolean(1, false)); + $this->assertEquals(1, $this->Dbo2->boolean(" ", false)); - $this->assertFalse($this->Dbo2->boolean('f')); - $this->assertFalse($this->Dbo2->boolean('false')); - $this->assertFalse($this->Dbo2->boolean('FALSE')); - $this->assertFalse($this->Dbo2->boolean(false)); - $this->assertFalse($this->Dbo2->boolean(0)); - $this->assertFalse($this->Dbo2->boolean('')); + $this->assertEquals(0, $this->Dbo2->boolean('f', false)); + $this->assertEquals(0, $this->Dbo2->boolean('false', false)); + $this->assertEquals(0, $this->Dbo2->boolean('FALSE', false)); + $this->assertEquals(0, $this->Dbo2->boolean(false, false)); + $this->assertEquals(0, $this->Dbo2->boolean(0, false)); + $this->assertEquals(0, $this->Dbo2->boolean('', false)); } /** From 8d80188c6c6899a5cdab515fb114460c465f2f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2010 21:59:48 -0430 Subject: [PATCH 078/378] Updating more tests with boolean handling, maybe in the near future fixing this for both mysql and postgres is coming --- .../datasources/dbo/dbo_postgres.test.php | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 6df1aeee8..3cbd18f68 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -602,25 +602,25 @@ class DboPostgresTest extends CakeTestCase { $this->Dbo->query('CREATE INDEX pointless_bool ON ' . $name . '("bool")'); $this->Dbo->query('CREATE UNIQUE INDEX char_index ON ' . $name . '("small_char")'); $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => true), - 'pointless_bool' => array('column' => 'bool', 'unique' => false), - 'char_index' => array('column' => 'small_char', 'unique' => true), + 'PRIMARY' => array('column' => 'id', 'unique' => 1), + 'pointless_bool' => array('column' => 'bool', 'unique' => 0), + 'char_index' => array('column' => 'small_char', 'unique' => 1), ); $result = $this->Dbo->index($name); + $this->Dbo->query('DROP TABLE ' . $name); $this->assertEqual($expected, $result); - $this->Dbo->query('DROP TABLE ' . $name); $name = $this->Dbo->fullTableName('index_test_2', false); $this->Dbo->query('CREATE TABLE ' . $name . ' ("id" serial NOT NULL PRIMARY KEY, "bool" integer, "small_char" varchar(50), "description" varchar(40) )'); $this->Dbo->query('CREATE UNIQUE INDEX multi_col ON ' . $name . '("small_char", "bool")'); $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => true), - 'multi_col' => array('column' => array('small_char', 'bool'), 'unique' => true), + 'PRIMARY' => array('column' => 'id', 'unique' => 1), + 'multi_col' => array('column' => array('small_char', 'bool'), 'unique' => 1), ); $result = $this->Dbo->index($name); - $this->assertEqual($expected, $result); $this->Dbo->query('DROP TABLE ' . $name); + $this->assertEqual($expected, $result); } /** @@ -697,15 +697,15 @@ class DboPostgresTest extends CakeTestCase { 'name' => 'AlterTest2', 'connection' => 'test', 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - 'group1' => array('type' => 'integer', 'null' => true), - 'group2' => array('type' => 'integer', 'null' => true), + 'id' => array('type' => 'integer', 'null' => 0, 'default' => 0), + 'name' => array('type' => 'string', 'null' => 0, 'length' => 50), + 'group1' => array('type' => 'integer', 'null' => 1), + 'group2' => array('type' => 'integer', 'null' => 1), 'indexes' => array( - 'name_idx' => array('column' => 'name', 'unique' => false), - 'group_idx' => array('column' => 'group1', 'unique' => false), - 'compound_idx' => array('column' => array('group1', 'group2'), 'unique' => false), - 'PRIMARY' => array('column' => 'id', 'unique' => true) + 'name_idx' => array('column' => 'name', 'unique' => 0), + 'group_idx' => array('column' => 'group1', 'unique' => 0), + 'compound_idx' => array('column' => array('group1', 'group2'), 'unique' => 0), + 'PRIMARY' => array('column' => 'id', 'unique' => 1) ) ) )); @@ -719,15 +719,15 @@ class DboPostgresTest extends CakeTestCase { 'name' => 'AlterTest3', 'connection' => 'test', 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - 'group1' => array('type' => 'integer', 'null' => true), - 'group2' => array('type' => 'integer', 'null' => true), + 'id' => array('type' => 'integer', 'null' => 0, 'default' => 0), + 'name' => array('type' => 'string', 'null' => 0, 'length' => 50), + 'group1' => array('type' => 'integer', 'null' => 1), + 'group2' => array('type' => 'integer', 'null' => 1), 'indexes' => array( - 'name_idx' => array('column' => 'name', 'unique' => true), - 'group_idx' => array('column' => 'group2', 'unique' => false), - 'compound_idx' => array('column' => array('group2', 'group1'), 'unique' => false), - 'another_idx' => array('column' => array('group1', 'name'), 'unique' => false)) + 'name_idx' => array('column' => 'name', 'unique' => 1), + 'group_idx' => array('column' => 'group2', 'unique' => 0), + 'compound_idx' => array('column' => array('group2', 'group1'), 'unique' => 0), + 'another_idx' => array('column' => array('group1', 'name'), 'unique' => 0)) ))); $this->Dbo->query($this->Dbo->alterSchema($schema3->compare($schema2))); From 146af7faa58b5f4ed26b3ebfbb7de6cdec72157e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 3 Nov 2010 19:14:22 -0430 Subject: [PATCH 079/378] Stating to move quoting test out from dbosource into mysql test --- .../model/datasources/dbo/dbo_mysql.test.php | 200 +-- .../model/datasources/dbo_source.test.php | 1266 ---------------- cake/tests/cases/libs/model/models.php | 1306 +++++++++++++++++ 3 files changed, 1372 insertions(+), 1400 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 00cca0662..7a3527d35 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -18,138 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Core', array('Model', 'DataSource', 'DboSource', 'DboMysql')); - -/** - * DboMysqlTestDb class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class DboMysqlTestDb extends DboMysql { - -/** - * simulated property - * - * @var array - * @access public - */ - public $simulated = array(); - -/** - * testing property - * - * @var bool true - * @access public - */ - public $testing = true; - -/** - * execute method - * - * @param mixed $sql - * @access protected - * @return void - */ - function _execute($sql) { - if ($this->testing) { - $this->simulated[] = $sql; - return null; - } - return parent::_execute($sql); - } - -/** - * getLastQuery method - * - * @access public - * @return void - */ - function getLastQuery() { - return $this->simulated[count($this->simulated) - 1]; - } -} - -/** - * MysqlTestModel class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class MysqlTestModel extends Model { - -/** - * name property - * - * @var string 'MysqlTestModel' - * @access public - */ - public $name = 'MysqlTestModel'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * find method - * - * @param mixed $conditions - * @param mixed $fields - * @param mixed $order - * @param mixed $recursive - * @access public - * @return void - */ - function find($conditions = null, $fields = null, $order = null, $recursive = null) { - return $conditions; - } - -/** - * findAll method - * - * @param mixed $conditions - * @param mixed $fields - * @param mixed $order - * @param mixed $recursive - * @access public - * @return void - */ - function findAll($conditions = null, $fields = null, $order = null, $recursive = null) { - return $conditions; - } - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - return array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'), - 'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''), - 'last_login'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); - } -} +App::import('Model', 'App'); +require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php'; /** * DboMysqlTest class @@ -158,8 +28,26 @@ class MysqlTestModel extends Model { * @subpackage cake.tests.cases.libs.model.datasources.dbo */ class DboMysqlTest extends CakeTestCase { - public $fixtures = array('core.binary_test'); +/** + * autoFixtures property + * + * @var bool false + * @access public + */ public $autoFixtures = false; + +/** + * fixtures property + * + * @var array + * @access public + */ + public $fixtures = array( + 'core.apple', 'core.article', 'core.articles_tag', 'core.attachment', 'core.comment', + 'core.sample', 'core.tag', 'core.user', 'core.post', 'core.author', 'core.data_test', + 'core.binary_test' + ); + /** * The Dbo instance to be tested * @@ -238,7 +126,7 @@ class DboMysqlTest extends CakeTestCase { $result = $this->Dbo->value('', 'integer'); $this->assertEqual($expected, $result); - $expected = 0; + $expected = "'0'"; $result = $this->Dbo->value('', 'boolean'); $this->assertEqual($expected, $result); @@ -936,4 +824,48 @@ class DboMysqlTest extends CakeTestCase { $encoding = $db->getEncoding(); $this->assertEqual('utf-8', $encoding); } + +/** + * testFieldDoubleEscaping method + * + * @access public + * @return void + */ + function testFieldDoubleEscaping() { + $test = $this->getMock('DboMysql', array('connect', '_execute', 'execute')); + $this->Model = $this->getMock('Article2', array('getDataSource')); + $this->Model->alias = 'Article'; + $this->Model->expects($this->any()) + ->method('getDataSource') + ->will($this->returnValue($test)); + + $this->assertEqual($this->Model->escapeField(), '`Article`.`id`'); + $result = $test->fields($this->Model, null, $this->Model->escapeField()); + $this->assertEqual($result, array('`Article`.`id`')); + + $test->expects($this->at(0))->method('execute') + ->with('SELECT `Article`.`id` FROM `articles` AS `Article` WHERE 1 = 1'); + + $result = $test->read($this->Model, array( + 'fields' => $this->Model->escapeField(), + 'conditions' => null, + 'recursive' => -1 + )); + + $test->startQuote = '['; + $test->endQuote = ']'; + $this->assertEqual($this->Model->escapeField(), '[Article].[id]'); + + $result = $test->fields($this->Model, null, $this->Model->escapeField()); + $this->assertEqual($result, array('[Article].[id]')); + + $test->expects($this->at(0))->method('execute') + ->with('SELECT [Article].[id] FROM [' . $test->fullTableName('articles', false) . '] AS [Article] WHERE 1 = 1'); + $result = $test->read($this->Model, array( + 'fields' => $this->Model->escapeField(), + 'conditions' => null, + 'recursive' => -1 + )); + } + } diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index c704f838d..797a7ad15 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -23,1230 +23,6 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) { App::import('Model', array('Model', 'DataSource', 'DboSource', 'DboMysql', 'App')); require_once dirname(dirname(__FILE__)) . DS . 'models.php'; -/** - * TestModel class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class TestModel extends CakeTestModel { - -/** - * name property - * - * @var string 'TestModel' - * @access public - */ - public $name = 'TestModel'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * schema property - * - * @var array - * @access protected - */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '11'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'), - 'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => '155'), - 'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); - -/** - * find method - * - * @param mixed $conditions - * @param mixed $fields - * @param mixed $order - * @param mixed $recursive - * @access public - * @return void - */ - function find($conditions = null, $fields = null, $order = null, $recursive = null) { - return array($conditions, $fields); - } - -/** - * findAll method - * - * @param mixed $conditions - * @param mixed $fields - * @param mixed $order - * @param mixed $recursive - * @access public - * @return void - */ - function findAll($conditions = null, $fields = null, $order = null, $recursive = null) { - return $conditions; - } -} - -/** - * TestModel2 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class TestModel2 extends CakeTestModel { - -/** - * name property - * - * @var string 'TestModel2' - * @access public - */ - public $name = 'TestModel2'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; -} - -/** - * TestModel4 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class TestModel3 extends CakeTestModel { - -/** - * name property - * - * @var string 'TestModel3' - * @access public - */ - public $name = 'TestModel3'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; -} - -/** - * TestModel4 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class TestModel4 extends CakeTestModel { - -/** - * name property - * - * @var string 'TestModel4' - * @access public - */ - public $name = 'TestModel4'; - -/** - * table property - * - * @var string 'test_model4' - * @access public - */ - public $table = 'test_model4'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * belongsTo property - * - * @var array - * @access public - */ - public $belongsTo = array( - 'TestModel4Parent' => array( - 'className' => 'TestModel4', - 'foreignKey' => 'parent_id' - ) - ); - -/** - * hasOne property - * - * @var array - * @access public - */ - public $hasOne = array( - 'TestModel5' => array( - 'className' => 'TestModel5', - 'foreignKey' => 'test_model4_id' - ) - ); - -/** - * hasAndBelongsToMany property - * - * @var array - * @access public - */ - public $hasAndBelongsToMany = array('TestModel7' => array( - 'className' => 'TestModel7', - 'joinTable' => 'test_model4_test_model7', - 'foreignKey' => 'test_model4_id', - 'associationForeignKey' => 'test_model7_id', - 'with' => 'TestModel4TestModel7' - )); - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); - } - return $this->_schema; - } -} - -/** - * TestModel4TestModel7 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class TestModel4TestModel7 extends CakeTestModel { - -/** - * name property - * - * @var string 'TestModel4TestModel7' - * @access public - */ - public $name = 'TestModel4TestModel7'; - -/** - * table property - * - * @var string 'test_model4_test_model7' - * @access public - */ - public $table = 'test_model4_test_model7'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'test_model4_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'test_model7_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8') - ); - } - return $this->_schema; - } -} - -/** - * TestModel5 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class TestModel5 extends CakeTestModel { - -/** - * name property - * - * @var string 'TestModel5' - * @access public - */ - public $name = 'TestModel5'; - -/** - * table property - * - * @var string 'test_model5' - * @access public - */ - public $table = 'test_model5'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * belongsTo property - * - * @var array - * @access public - */ - public $belongsTo = array('TestModel4' => array( - 'className' => 'TestModel4', - 'foreignKey' => 'test_model4_id' - )); - -/** - * hasMany property - * - * @var array - * @access public - */ - public $hasMany = array('TestModel6' => array( - 'className' => 'TestModel6', - 'foreignKey' => 'test_model5_id' - )); - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'test_model4_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); - } - return $this->_schema; - } -} - -/** - * TestModel6 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class TestModel6 extends CakeTestModel { - -/** - * name property - * - * @var string 'TestModel6' - * @access public - */ - public $name = 'TestModel6'; - -/** - * table property - * - * @var string 'test_model6' - * @access public - */ - public $table = 'test_model6'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * belongsTo property - * - * @var array - * @access public - */ - public $belongsTo = array('TestModel5' => array( - 'className' => 'TestModel5', - 'foreignKey' => 'test_model5_id' - )); - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'test_model5_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); - } - return $this->_schema; - } -} - -/** - * TestModel7 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class TestModel7 extends CakeTestModel { - -/** - * name property - * - * @var string 'TestModel7' - * @access public - */ - public $name = 'TestModel7'; - -/** - * table property - * - * @var string 'test_model7' - * @access public - */ - public $table = 'test_model7'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); - } - return $this->_schema; - } -} - -/** - * TestModel8 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class TestModel8 extends CakeTestModel { - -/** - * name property - * - * @var string 'TestModel8' - * @access public - */ - public $name = 'TestModel8'; - -/** - * table property - * - * @var string 'test_model8' - * @access public - */ - public $table = 'test_model8'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * hasOne property - * - * @var array - * @access public - */ - public $hasOne = array( - 'TestModel9' => array( - 'className' => 'TestModel9', - 'foreignKey' => 'test_model8_id', - 'conditions' => 'TestModel9.name != \'mariano\'' - ) - ); - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'test_model9_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); - } - return $this->_schema; - } -} - -/** - * TestModel9 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class TestModel9 extends CakeTestModel { - -/** - * name property - * - * @var string 'TestModel9' - * @access public - */ - public $name = 'TestModel9'; - -/** - * table property - * - * @var string 'test_model9' - * @access public - */ - public $table = 'test_model9'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * belongsTo property - * - * @var array - * @access public - */ - public $belongsTo = array('TestModel8' => array( - 'className' => 'TestModel8', - 'foreignKey' => 'test_model8_id', - 'conditions' => 'TestModel8.name != \'larry\'' - )); - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'test_model8_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '11'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); - } - return $this->_schema; - } -} - -/** - * Level class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class Level extends CakeTestModel { - -/** - * name property - * - * @var string 'Level' - * @access public - */ - public $name = 'Level'; - -/** - * table property - * - * @var string 'level' - * @access public - */ - public $table = 'level'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * hasMany property - * - * @var array - * @access public - */ - public $hasMany = array( - 'Group'=> array( - 'className' => 'Group' - ), - 'User2' => array( - 'className' => 'User2' - ) - ); - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'), - ); - } - return $this->_schema; - } -} - -/** - * Group class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class Group extends CakeTestModel { - -/** - * name property - * - * @var string 'Group' - * @access public - */ - public $name = 'Group'; - -/** - * table property - * - * @var string 'group' - * @access public - */ - public $table = 'group'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * belongsTo property - * - * @var array - * @access public - */ - public $belongsTo = array('Level'); - -/** - * hasMany property - * - * @var array - * @access public - */ - public $hasMany = array('Category2', 'User2'); - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'level_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'), - ); - } - return $this->_schema; - } - -} - -/** - * User2 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class User2 extends CakeTestModel { - -/** - * name property - * - * @var string 'User2' - * @access public - */ - public $name = 'User2'; - -/** - * table property - * - * @var string 'user' - * @access public - */ - public $table = 'user'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * belongsTo property - * - * @var array - * @access public - */ - public $belongsTo = array( - 'Group' => array( - 'className' => 'Group' - ), - 'Level' => array( - 'className' => 'Level' - ) - ); - -/** - * hasMany property - * - * @var array - * @access public - */ - public $hasMany = array( - 'Article2' => array( - 'className' => 'Article2' - ), - ); - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'group_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'level_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'), - ); - } - return $this->_schema; - } -} - -/** - * Category2 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class Category2 extends CakeTestModel { - -/** - * name property - * - * @var string 'Category2' - * @access public - */ - public $name = 'Category2'; - -/** - * table property - * - * @var string 'category' - * @access public - */ - public $table = 'category'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * belongsTo property - * - * @var array - * @access public - */ - public $belongsTo = array( - 'Group' => array( - 'className' => 'Group', - 'foreignKey' => 'group_id' - ), - 'ParentCat' => array( - 'className' => 'Category2', - 'foreignKey' => 'parent_id' - ) - ); - -/** - * hasMany property - * - * @var array - * @access public - */ - public $hasMany = array( - 'ChildCat' => array( - 'className' => 'Category2', - 'foreignKey' => 'parent_id' - ), - 'Article2' => array( - 'className' => 'Article2', - 'order'=>'Article2.published_date DESC', - 'foreignKey' => 'category_id', - 'limit'=>'3') - ); - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), - 'group_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), - 'parent_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), - 'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), - 'icon' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), - 'description' => array('type' => 'text', 'null' => false, 'default' => '', 'length' => null), - - ); - } - return $this->_schema; - } -} - -/** - * Article2 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class Article2 extends CakeTestModel { - -/** - * name property - * - * @var string 'Article2' - * @access public - */ - public $name = 'Article2'; - -/** - * table property - * - * @var string 'article' - * @access public - */ - public $table = 'article'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * belongsTo property - * - * @var array - * @access public - */ - public $belongsTo = array( - 'Category2' => array('className' => 'Category2'), - 'User2' => array('className' => 'User2') - ); - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), - 'category_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'rate_count' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'rate_sum' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'viewed' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'version' => array('type' => 'string', 'null' => true, 'default' => '', 'length' => '45'), - 'title' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '200'), - 'intro' => array('text' => 'string', 'null' => true, 'default' => '', 'length' => null), - 'comments' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '4'), - 'body' => array('text' => 'string', 'null' => true, 'default' => '', 'length' => null), - 'isdraft' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'), - 'allow_comments' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'), - 'moderate_comments' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'), - 'published' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'), - 'multipage' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'), - 'published_date' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null), - 'modified' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null) - ); - } - return $this->_schema; - } -} - -/** - * CategoryFeatured2 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class CategoryFeatured2 extends CakeTestModel { - -/** - * name property - * - * @var string 'CategoryFeatured2' - * @access public - */ - public $name = 'CategoryFeatured2'; - -/** - * table property - * - * @var string 'category_featured' - * @access public - */ - public $table = 'category_featured'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), - 'parent_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), - 'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), - 'icon' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), - 'description' => array('text' => 'string', 'null' => false, 'default' => '', 'length' => null) - ); - } - return $this->_schema; - } -} - -/** - * Featured2 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class Featured2 extends CakeTestModel { - -/** - * name property - * - * @var string 'Featured2' - * @access public - */ - public $name = 'Featured2'; - -/** - * table property - * - * @var string 'featured2' - * @access public - */ - public $table = 'featured2'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * belongsTo property - * - * @var array - * @access public - */ - public $belongsTo = array( - 'CategoryFeatured2' => array( - 'className' => 'CategoryFeatured2' - ) - ); - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'article_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'category_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20') - ); - } - return $this->_schema; - } -} - -/** - * Comment2 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class Comment2 extends CakeTestModel { - -/** - * name property - * - * @var string 'Comment2' - * @access public - */ - public $name = 'Comment2'; - -/** - * table property - * - * @var string 'comment' - * @access public - */ - public $table = 'comment'; - -/** - * belongsTo property - * - * @var array - * @access public - */ - public $belongsTo = array('ArticleFeatured2', 'User2'); - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'article_featured_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20') - ); - } - return $this->_schema; - } -} - -/** - * ArticleFeatured2 class - * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources - */ -class ArticleFeatured2 extends CakeTestModel { - -/** - * name property - * - * @var string 'ArticleFeatured2' - * @access public - */ - public $name = 'ArticleFeatured2'; - -/** - * table property - * - * @var string 'article_featured' - * @access public - */ - public $table = 'article_featured'; - -/** - * useTable property - * - * @var bool false - * @access public - */ - public $useTable = false; - -/** - * belongsTo property - * - * @var array - * @access public - */ - public $belongsTo = array( - 'CategoryFeatured2' => array('className' => 'CategoryFeatured2'), - 'User2' => array('className' => 'User2') - ); - -/** - * hasOne property - * - * @var array - * @access public - */ - public $hasOne = array( - 'Featured2' => array('className' => 'Featured2') - ); - -/** - * hasMany property - * - * @var array - * @access public - */ - public $hasMany = array( - 'Comment2' => array('className'=>'Comment2', 'dependent' => true) - ); - -/** - * schema method - * - * @access public - * @return void - */ - function schema() { - if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'category_featured_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'title' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'), - 'body' => array('text' => 'string', 'null' => true, 'default' => '', 'length' => null), - 'published' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'), - 'published_date' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null), - 'modified' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null) - ); - } - return $this->_schema; - } -} - /** * DboSourceTest class * @@ -1341,48 +117,6 @@ class DboSourceTest extends CakeTestCase { unset($this->Model); } -/** - * testFieldDoubleEscaping method - * - * @access public - * @return void - */ - function testFieldDoubleEscaping() { - $config = array_merge($this->__config, array('driver' => 'test')); - $test = ConnectionManager::create('quoteTest', $config); - $test->simulated = array(); - - $this->Model = new Article2(array('alias' => 'Article', 'ds' => 'quoteTest')); - $this->Model->setDataSource('quoteTest'); - - $this->assertEqual($this->Model->escapeField(), '`Article`.`id`'); - $result = $test->fields($this->Model, null, $this->Model->escapeField()); - $this->assertEqual($result, array('`Article`.`id`')); - - $result = $test->read($this->Model, array( - 'fields' => $this->Model->escapeField(), - 'conditions' => null, - 'recursive' => -1 - )); - $this->assertEqual(trim($test->simulated[0]), 'SELECT `Article`.`id` FROM `' . $this->testDb->fullTableName('article', false) . '` AS `Article` WHERE 1 = 1'); - - $test->startQuote = '['; - $test->endQuote = ']'; - $this->assertEqual($this->Model->escapeField(), '[Article].[id]'); - - $result = $test->fields($this->Model, null, $this->Model->escapeField()); - $this->assertEqual($result, array('[Article].[id]')); - - $result = $test->read($this->Model, array( - 'fields' => $this->Model->escapeField(), - 'conditions' => null, - 'recursive' => -1 - )); - $this->assertEqual(trim($test->simulated[1]), 'SELECT [Article].[id] FROM [' . $this->testDb->fullTableName('article', false) . '] AS [Article] WHERE 1 = 1'); - - ClassRegistry::removeObject('Article'); - } - /** * testGenerateAssociationQuerySelfJoin method * diff --git a/cake/tests/cases/libs/model/models.php b/cake/tests/cases/libs/model/models.php index 8770e2c01..7bbbb2219 100644 --- a/cake/tests/cases/libs/model/models.php +++ b/cake/tests/cases/libs/model/models.php @@ -3583,3 +3583,1309 @@ class GroupUpdateAll extends CakeTestModel { public $useTable = 'group_update_all'; } + +/** + * TestModel class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class TestModel extends CakeTestModel { + +/** + * name property + * + * @var string 'TestModel' + * @access public + */ + public $name = 'TestModel'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * schema property + * + * @var array + * @access protected + */ + protected $_schema = array( + 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), + 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '11'), + 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), + 'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), + 'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'), + 'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), + 'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), + 'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), + 'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), + 'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), + 'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), + 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), + 'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => '155'), + 'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), + 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), + 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) + ); + +/** + * find method + * + * @param mixed $conditions + * @param mixed $fields + * @param mixed $order + * @param mixed $recursive + * @access public + * @return void + */ + function find($conditions = null, $fields = null, $order = null, $recursive = null) { + return array($conditions, $fields); + } + +/** + * findAll method + * + * @param mixed $conditions + * @param mixed $fields + * @param mixed $order + * @param mixed $recursive + * @access public + * @return void + */ + function findAll($conditions = null, $fields = null, $order = null, $recursive = null) { + return $conditions; + } +} + +/** + * TestModel2 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class TestModel2 extends CakeTestModel { + +/** + * name property + * + * @var string 'TestModel2' + * @access public + */ + public $name = 'TestModel2'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; +} + +/** + * TestModel4 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class TestModel3 extends CakeTestModel { + +/** + * name property + * + * @var string 'TestModel3' + * @access public + */ + public $name = 'TestModel3'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; +} + +/** + * TestModel4 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class TestModel4 extends CakeTestModel { + +/** + * name property + * + * @var string 'TestModel4' + * @access public + */ + public $name = 'TestModel4'; + +/** + * table property + * + * @var string 'test_model4' + * @access public + */ + public $table = 'test_model4'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * belongsTo property + * + * @var array + * @access public + */ + public $belongsTo = array( + 'TestModel4Parent' => array( + 'className' => 'TestModel4', + 'foreignKey' => 'parent_id' + ) + ); + +/** + * hasOne property + * + * @var array + * @access public + */ + public $hasOne = array( + 'TestModel5' => array( + 'className' => 'TestModel5', + 'foreignKey' => 'test_model4_id' + ) + ); + +/** + * hasAndBelongsToMany property + * + * @var array + * @access public + */ + public $hasAndBelongsToMany = array('TestModel7' => array( + 'className' => 'TestModel7', + 'joinTable' => 'test_model4_test_model7', + 'foreignKey' => 'test_model4_id', + 'associationForeignKey' => 'test_model7_id', + 'with' => 'TestModel4TestModel7' + )); + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), + 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), + 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) + ); + } + return $this->_schema; + } +} + +/** + * TestModel4TestModel7 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class TestModel4TestModel7 extends CakeTestModel { + +/** + * name property + * + * @var string 'TestModel4TestModel7' + * @access public + */ + public $name = 'TestModel4TestModel7'; + +/** + * table property + * + * @var string 'test_model4_test_model7' + * @access public + */ + public $table = 'test_model4_test_model7'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'test_model4_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), + 'test_model7_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8') + ); + } + return $this->_schema; + } +} + +/** + * TestModel5 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class TestModel5 extends CakeTestModel { + +/** + * name property + * + * @var string 'TestModel5' + * @access public + */ + public $name = 'TestModel5'; + +/** + * table property + * + * @var string 'test_model5' + * @access public + */ + public $table = 'test_model5'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * belongsTo property + * + * @var array + * @access public + */ + public $belongsTo = array('TestModel4' => array( + 'className' => 'TestModel4', + 'foreignKey' => 'test_model4_id' + )); + +/** + * hasMany property + * + * @var array + * @access public + */ + public $hasMany = array('TestModel6' => array( + 'className' => 'TestModel6', + 'foreignKey' => 'test_model5_id' + )); + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), + 'test_model4_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), + 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), + 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) + ); + } + return $this->_schema; + } +} + +/** + * TestModel6 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class TestModel6 extends CakeTestModel { + +/** + * name property + * + * @var string 'TestModel6' + * @access public + */ + public $name = 'TestModel6'; + +/** + * table property + * + * @var string 'test_model6' + * @access public + */ + public $table = 'test_model6'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * belongsTo property + * + * @var array + * @access public + */ + public $belongsTo = array('TestModel5' => array( + 'className' => 'TestModel5', + 'foreignKey' => 'test_model5_id' + )); + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), + 'test_model5_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), + 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), + 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) + ); + } + return $this->_schema; + } +} + +/** + * TestModel7 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class TestModel7 extends CakeTestModel { + +/** + * name property + * + * @var string 'TestModel7' + * @access public + */ + public $name = 'TestModel7'; + +/** + * table property + * + * @var string 'test_model7' + * @access public + */ + public $table = 'test_model7'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), + 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), + 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) + ); + } + return $this->_schema; + } +} + +/** + * TestModel8 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class TestModel8 extends CakeTestModel { + +/** + * name property + * + * @var string 'TestModel8' + * @access public + */ + public $name = 'TestModel8'; + +/** + * table property + * + * @var string 'test_model8' + * @access public + */ + public $table = 'test_model8'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * hasOne property + * + * @var array + * @access public + */ + public $hasOne = array( + 'TestModel9' => array( + 'className' => 'TestModel9', + 'foreignKey' => 'test_model8_id', + 'conditions' => 'TestModel9.name != \'mariano\'' + ) + ); + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), + 'test_model9_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), + 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), + 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) + ); + } + return $this->_schema; + } +} + +/** + * TestModel9 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class TestModel9 extends CakeTestModel { + +/** + * name property + * + * @var string 'TestModel9' + * @access public + */ + public $name = 'TestModel9'; + +/** + * table property + * + * @var string 'test_model9' + * @access public + */ + public $table = 'test_model9'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * belongsTo property + * + * @var array + * @access public + */ + public $belongsTo = array('TestModel8' => array( + 'className' => 'TestModel8', + 'foreignKey' => 'test_model8_id', + 'conditions' => 'TestModel8.name != \'larry\'' + )); + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), + 'test_model8_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '11'), + 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), + 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) + ); + } + return $this->_schema; + } +} + +/** + * Level class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class Level extends CakeTestModel { + +/** + * name property + * + * @var string 'Level' + * @access public + */ + public $name = 'Level'; + +/** + * table property + * + * @var string 'level' + * @access public + */ + public $table = 'level'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * hasMany property + * + * @var array + * @access public + */ + public $hasMany = array( + 'Group'=> array( + 'className' => 'Group' + ), + 'User2' => array( + 'className' => 'User2' + ) + ); + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), + 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'), + ); + } + return $this->_schema; + } +} + +/** + * Group class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class Group extends CakeTestModel { + +/** + * name property + * + * @var string 'Group' + * @access public + */ + public $name = 'Group'; + +/** + * table property + * + * @var string 'group' + * @access public + */ + public $table = 'group'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * belongsTo property + * + * @var array + * @access public + */ + public $belongsTo = array('Level'); + +/** + * hasMany property + * + * @var array + * @access public + */ + public $hasMany = array('Category2', 'User2'); + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), + 'level_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), + 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'), + ); + } + return $this->_schema; + } + +} + +/** + * User2 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class User2 extends CakeTestModel { + +/** + * name property + * + * @var string 'User2' + * @access public + */ + public $name = 'User2'; + +/** + * table property + * + * @var string 'user' + * @access public + */ + public $table = 'user'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * belongsTo property + * + * @var array + * @access public + */ + public $belongsTo = array( + 'Group' => array( + 'className' => 'Group' + ), + 'Level' => array( + 'className' => 'Level' + ) + ); + +/** + * hasMany property + * + * @var array + * @access public + */ + public $hasMany = array( + 'Article2' => array( + 'className' => 'Article2' + ), + ); + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), + 'group_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), + 'level_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), + 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'), + ); + } + return $this->_schema; + } +} + +/** + * Category2 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class Category2 extends CakeTestModel { + +/** + * name property + * + * @var string 'Category2' + * @access public + */ + public $name = 'Category2'; + +/** + * table property + * + * @var string 'category' + * @access public + */ + public $table = 'category'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * belongsTo property + * + * @var array + * @access public + */ + public $belongsTo = array( + 'Group' => array( + 'className' => 'Group', + 'foreignKey' => 'group_id' + ), + 'ParentCat' => array( + 'className' => 'Category2', + 'foreignKey' => 'parent_id' + ) + ); + +/** + * hasMany property + * + * @var array + * @access public + */ + public $hasMany = array( + 'ChildCat' => array( + 'className' => 'Category2', + 'foreignKey' => 'parent_id' + ), + 'Article2' => array( + 'className' => 'Article2', + 'order'=>'Article2.published_date DESC', + 'foreignKey' => 'category_id', + 'limit'=>'3') + ); + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), + 'group_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), + 'parent_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), + 'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), + 'icon' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), + 'description' => array('type' => 'text', 'null' => false, 'default' => '', 'length' => null), + + ); + } + return $this->_schema; + } +} + +/** + * Article2 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class Article2 extends CakeTestModel { + +/** + * name property + * + * @var string 'Article2' + * @access public + */ + public $name = 'Article2'; + +/** + * table property + * + * @var string 'article' + * @access public + */ + public $table = 'articles'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * belongsTo property + * + * @var array + * @access public + */ + public $belongsTo = array( + 'Category2' => array('className' => 'Category2'), + 'User2' => array('className' => 'User2') + ); + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), + 'category_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), + 'rate_count' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), + 'rate_sum' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), + 'viewed' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), + 'version' => array('type' => 'string', 'null' => true, 'default' => '', 'length' => '45'), + 'title' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '200'), + 'intro' => array('text' => 'string', 'null' => true, 'default' => '', 'length' => null), + 'comments' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '4'), + 'body' => array('text' => 'string', 'null' => true, 'default' => '', 'length' => null), + 'isdraft' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'), + 'allow_comments' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'), + 'moderate_comments' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'), + 'published' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'), + 'multipage' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'), + 'published_date' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null), + 'modified' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null) + ); + } + return $this->_schema; + } +} + +/** + * CategoryFeatured2 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class CategoryFeatured2 extends CakeTestModel { + +/** + * name property + * + * @var string 'CategoryFeatured2' + * @access public + */ + public $name = 'CategoryFeatured2'; + +/** + * table property + * + * @var string 'category_featured' + * @access public + */ + public $table = 'category_featured'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), + 'parent_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), + 'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), + 'icon' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), + 'description' => array('text' => 'string', 'null' => false, 'default' => '', 'length' => null) + ); + } + return $this->_schema; + } +} + +/** + * Featured2 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class Featured2 extends CakeTestModel { + +/** + * name property + * + * @var string 'Featured2' + * @access public + */ + public $name = 'Featured2'; + +/** + * table property + * + * @var string 'featured2' + * @access public + */ + public $table = 'featured2'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * belongsTo property + * + * @var array + * @access public + */ + public $belongsTo = array( + 'CategoryFeatured2' => array( + 'className' => 'CategoryFeatured2' + ) + ); + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), + 'article_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), + 'category_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), + 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20') + ); + } + return $this->_schema; + } +} + +/** + * Comment2 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class Comment2 extends CakeTestModel { + +/** + * name property + * + * @var string 'Comment2' + * @access public + */ + public $name = 'Comment2'; + +/** + * table property + * + * @var string 'comment' + * @access public + */ + public $table = 'comment'; + +/** + * belongsTo property + * + * @var array + * @access public + */ + public $belongsTo = array('ArticleFeatured2', 'User2'); + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), + 'article_featured_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), + 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20') + ); + } + return $this->_schema; + } +} + +/** + * ArticleFeatured2 class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class ArticleFeatured2 extends CakeTestModel { + +/** + * name property + * + * @var string 'ArticleFeatured2' + * @access public + */ + public $name = 'ArticleFeatured2'; + +/** + * table property + * + * @var string 'article_featured' + * @access public + */ + public $table = 'article_featured'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * belongsTo property + * + * @var array + * @access public + */ + public $belongsTo = array( + 'CategoryFeatured2' => array('className' => 'CategoryFeatured2'), + 'User2' => array('className' => 'User2') + ); + +/** + * hasOne property + * + * @var array + * @access public + */ + public $hasOne = array( + 'Featured2' => array('className' => 'Featured2') + ); + +/** + * hasMany property + * + * @var array + * @access public + */ + public $hasMany = array( + 'Comment2' => array('className'=>'Comment2', 'dependent' => true) + ); + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + if (!isset($this->_schema)) { + $this->_schema = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), + 'category_featured_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), + 'title' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'), + 'body' => array('text' => 'string', 'null' => true, 'default' => '', 'length' => null), + 'published' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'), + 'published_date' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null), + 'modified' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null) + ); + } + return $this->_schema; + } +} + +/** + * MysqlTestModel class + * + * @package cake + * @subpackage cake.tests.cases.libs.model.datasources + */ +class MysqlTestModel extends Model { + +/** + * name property + * + * @var string 'MysqlTestModel' + * @access public + */ + public $name = 'MysqlTestModel'; + +/** + * useTable property + * + * @var bool false + * @access public + */ + public $useTable = false; + +/** + * find method + * + * @param mixed $conditions + * @param mixed $fields + * @param mixed $order + * @param mixed $recursive + * @access public + * @return void + */ + function find($conditions = null, $fields = null, $order = null, $recursive = null) { + return $conditions; + } + +/** + * findAll method + * + * @param mixed $conditions + * @param mixed $fields + * @param mixed $order + * @param mixed $recursive + * @access public + * @return void + */ + function findAll($conditions = null, $fields = null, $order = null, $recursive = null) { + return $conditions; + } + +/** + * schema method + * + * @access public + * @return void + */ + function schema() { + return array( + 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), + 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'), + 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), + 'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), + 'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'), + 'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), + 'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), + 'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), + 'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), + 'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), + 'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), + 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), + 'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''), + 'last_login'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), + 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), + 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) + ); + } +} \ No newline at end of file From 605a6b17a5f87e6b0106adf30336c3e9fee7020e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 3 Nov 2010 19:18:51 -0430 Subject: [PATCH 080/378] Moving another method out of DboSourceTest --- .../model/datasources/dbo/dbo_mysql.test.php | 134 +++++++++++++++++ .../model/datasources/dbo_source.test.php | 135 ------------------ 2 files changed, 134 insertions(+), 135 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 7a3527d35..89fa47b77 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -868,4 +868,138 @@ class DboMysqlTest extends CakeTestCase { )); } +/** + * testGenerateAssociationQuerySelfJoin method + * + * @return void + */ + function testGenerateAssociationQuerySelfJoin() { + $this->testDb = $this->getMock('DboMysql', array('connect', '_execute', 'execute')); + $this->startTime = microtime(true); + $this->Model = new Article2(); + $this->_buildRelatedModels($this->Model); + $this->_buildRelatedModels($this->Model->Category2); + $this->Model->Category2->ChildCat = new Category2(); + $this->Model->Category2->ParentCat = new Category2(); + + $queryData = array(); + + foreach ($this->Model->Category2->associations() as $type) { + foreach ($this->Model->Category2->{$type} as $assoc => $assocData) { + $linkModel = $this->Model->Category2->{$assoc}; + $external = isset($assocData['external']); + + if ($this->Model->Category2->alias == $linkModel->alias && $type != 'hasAndBelongsToMany' && $type != 'hasMany') { + $result = $this->testDb->generateAssociationQuery($this->Model->Category2, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null); + $this->assertFalse(empty($result)); + } else { + if ($this->Model->Category2->useDbConfig == $linkModel->useDbConfig) { + $result = $this->testDb->generateAssociationQuery($this->Model->Category2, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null); + $this->assertFalse(empty($result)); + } + } + } + } + + $query = $this->testDb->generateAssociationQuery($this->Model->Category2, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+(.+)FROM(.+)`Category2`\.`group_id`\s+=\s+`Group`\.`id`\)\s+LEFT JOIN(.+)WHERE\s+1 = 1\s*$/', $query); + + $this->Model = new TestModel4(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type' => 'belongsTo', 'model' => 'TestModel4Parent'); + $queryData = array(); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $_queryData = $queryData; + $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertTrue($result); + + $expected = array( + 'conditions' => array(), + 'fields' => array( + '`TestModel4`.`id`', + '`TestModel4`.`name`', + '`TestModel4`.`created`', + '`TestModel4`.`updated`', + '`TestModel4Parent`.`id`', + '`TestModel4Parent`.`name`', + '`TestModel4Parent`.`created`', + '`TestModel4Parent`.`updated`' + ), + 'joins' => array( + array( + 'table' => '`test_model4`', + 'alias' => 'TestModel4Parent', + 'type' => 'LEFT', + 'conditions' => '`TestModel4`.`parent_id` = `TestModel4Parent`.`id`' + ) + ), + 'order' => array(), + 'limit' => array(), + 'offset' => array(), + 'group' => array() + ); + $this->assertEqual($queryData, $expected); + + $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel4Parent`\.`id`, `TestModel4Parent`\.`name`, `TestModel4Parent`\.`created`, `TestModel4Parent`\.`updated`\s+/', $result); + $this->assertPattern('/FROM\s+`test_model4` AS `TestModel4`\s+LEFT JOIN\s+`test_model4` AS `TestModel4Parent`/', $result); + $this->assertPattern('/\s+ON\s+\(`TestModel4`.`parent_id` = `TestModel4Parent`.`id`\)\s+WHERE/', $result); + $this->assertPattern('/\s+WHERE\s+1 = 1\s+$/', $result); + + $params['assocData']['type'] = 'INNER'; + $this->Model->belongsTo['TestModel4Parent']['type'] = 'INNER'; + $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $_queryData, $params['external'], $resultSet); + $this->assertTrue($result); + $this->assertEqual($_queryData['joins'][0]['type'], 'INNER'); + } + +/** + * buildRelatedModels method + * + * @param mixed $model + * @access protected + * @return void + */ + function _buildRelatedModels(&$model) { + foreach ($model->associations() as $type) { + foreach ($model->{$type} as $assoc => $assocData) { + if (is_string($assocData)) { + $className = $assocData; + } elseif (isset($assocData['className'])) { + $className = $assocData['className']; + } + $model->$className = new $className(); + $model->$className->schema(); + } + } + } + +/** + * &_prepareAssociationQuery method + * + * @param mixed $model + * @param mixed $queryData + * @param mixed $binding + * @access public + * @return void + */ + function &_prepareAssociationQuery(&$model, &$queryData, $binding) { + $type = $binding['type']; + $assoc = $binding['model']; + $assocData = $model->{$type}[$assoc]; + $className = $assocData['className']; + + $linkModel = $model->{$className}; + $external = isset($assocData['external']); + $queryData = $this->testDb->__scrubQueryData($queryData); + + $result = array_merge(array('linkModel' => &$linkModel), compact('type', 'assoc', 'assocData', 'external')); + return $result; + } } diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 797a7ad15..6080cab91 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -117,97 +117,6 @@ class DboSourceTest extends CakeTestCase { unset($this->Model); } -/** - * testGenerateAssociationQuerySelfJoin method - * - * @access public - * @return void - */ - function testGenerateAssociationQuerySelfJoin() { - $this->startTime = microtime(true); - $this->Model = new Article2(); - $this->_buildRelatedModels($this->Model); - $this->_buildRelatedModels($this->Model->Category2); - $this->Model->Category2->ChildCat = new Category2(); - $this->Model->Category2->ParentCat = new Category2(); - - $queryData = array(); - - foreach ($this->Model->Category2->associations() as $type) { - foreach ($this->Model->Category2->{$type} as $assoc => $assocData) { - $linkModel = $this->Model->Category2->{$assoc}; - $external = isset($assocData['external']); - - if ($this->Model->Category2->alias == $linkModel->alias && $type != 'hasAndBelongsToMany' && $type != 'hasMany') { - $result = $this->testDb->generateAssociationQuery($this->Model->Category2, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null); - $this->assertFalse(empty($result)); - } else { - if ($this->Model->Category2->useDbConfig == $linkModel->useDbConfig) { - $result = $this->testDb->generateAssociationQuery($this->Model->Category2, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null); - $this->assertFalse(empty($result)); - } - } - } - } - - $query = $this->testDb->generateAssociationQuery($this->Model->Category2, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+(.+)FROM(.+)`Category2`\.`group_id`\s+=\s+`Group`\.`id`\)\s+LEFT JOIN(.+)WHERE\s+1 = 1\s*$/', $query); - - $this->Model = new TestModel4(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type' => 'belongsTo', 'model' => 'TestModel4Parent'); - $queryData = array(); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $_queryData = $queryData; - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertTrue($result); - - $expected = array( - 'conditions' => array(), - 'fields' => array( - '`TestModel4`.`id`', - '`TestModel4`.`name`', - '`TestModel4`.`created`', - '`TestModel4`.`updated`', - '`TestModel4Parent`.`id`', - '`TestModel4Parent`.`name`', - '`TestModel4Parent`.`created`', - '`TestModel4Parent`.`updated`' - ), - 'joins' => array( - array( - 'table' => '`test_model4`', - 'alias' => 'TestModel4Parent', - 'type' => 'LEFT', - 'conditions' => '`TestModel4`.`parent_id` = `TestModel4Parent`.`id`' - ) - ), - 'order' => array(), - 'limit' => array(), - 'offset' => array(), - 'group' => array() - ); - $this->assertEqual($queryData, $expected); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel4Parent`\.`id`, `TestModel4Parent`\.`name`, `TestModel4Parent`\.`created`, `TestModel4Parent`\.`updated`\s+/', $result); - $this->assertPattern('/FROM\s+`test_model4` AS `TestModel4`\s+LEFT JOIN\s+`test_model4` AS `TestModel4Parent`/', $result); - $this->assertPattern('/\s+ON\s+\(`TestModel4`.`parent_id` = `TestModel4Parent`.`id`\)\s+WHERE/', $result); - $this->assertPattern('/\s+WHERE\s+1 = 1\s+$/', $result); - - $params['assocData']['type'] = 'INNER'; - $this->Model->belongsTo['TestModel4Parent']['type'] = 'INNER'; - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $_queryData, $params['external'], $resultSet); - $this->assertTrue($result); - $this->assertEqual($_queryData['joins'][0]['type'], 'INNER'); - } - /** * testGenerateInnerJoinAssociationQuery method * @@ -932,50 +841,6 @@ class DboSourceTest extends CakeTestCase { $this->Model->hasAndBelongsToMany['TestModel7'] = $__backup; } -/** - * buildRelatedModels method - * - * @param mixed $model - * @access protected - * @return void - */ - function _buildRelatedModels(&$model) { - foreach ($model->associations() as $type) { - foreach ($model->{$type} as $assoc => $assocData) { - if (is_string($assocData)) { - $className = $assocData; - } elseif (isset($assocData['className'])) { - $className = $assocData['className']; - } - $model->$className = new $className(); - $model->$className->schema(); - } - } - } - -/** - * &_prepareAssociationQuery method - * - * @param mixed $model - * @param mixed $queryData - * @param mixed $binding - * @access public - * @return void - */ - function &_prepareAssociationQuery(&$model, &$queryData, $binding) { - $type = $binding['type']; - $assoc = $binding['model']; - $assocData = $model->{$type}[$assoc]; - $className = $assocData['className']; - - $linkModel = $model->{$className}; - $external = isset($assocData['external']); - $queryData = $this->testDb->__scrubQueryData($queryData); - - $result = array_merge(array('linkModel' => &$linkModel), compact('type', 'assoc', 'assocData', 'external')); - return $result; - } - /** * testSelectDistict method * From f2f378ca7381628e1865fda91525de0e9f9e8714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 3 Nov 2010 19:35:15 -0430 Subject: [PATCH 081/378] Moving testGenerateInnerJoinAssociationQuery out from DboSourceTest --- .../model/datasources/dbo/dbo_mysql.test.php | 29 +++++++++++++++++++ .../model/datasources/dbo_source.test.php | 24 --------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 89fa47b77..669b6a65a 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -1002,4 +1002,33 @@ class DboMysqlTest extends CakeTestCase { $result = array_merge(array('linkModel' => &$linkModel), compact('type', 'assoc', 'assocData', 'external')); return $result; } + +/** + * testGenerateInnerJoinAssociationQuery method + * + * @access public + * @return void + */ + function testGenerateInnerJoinAssociationQuery() { + $test = $this->getMock('DboMysql', array('connect', '_execute', 'execute')); + $this->Model = $this->getMock('TestModel9', array('getDataSource')); + $this->Model->expects($this->any()) + ->method('getDataSource') + ->will($this->returnValue($test)); + + $this->Model->TestModel8 = $this->getMock('TestModel8', array('getDataSource')); + $this->Model->TestModel8->expects($this->any()) + ->method('getDataSource') + ->will($this->returnValue($test)); + + $test->expects($this->at(0))->method('execute') + ->with(new PHPUnit_Framework_Constraint_PCREMatch('/`TestModel9` LEFT JOIN `test_model8`/')); + + $test->expects($this->at(1))->method('execute') + ->with(new PHPUnit_Framework_Constraint_PCREMatch('/`TestModel9` INNER JOIN `test_model8`/')); + + $test->read($this->Model, array('recursive' => 1)); + $this->Model->belongsTo['TestModel8']['type'] = 'INNER'; + $test->read($this->Model, array('recursive' => 1)); + } } diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 6080cab91..43a0d5dd6 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -117,30 +117,6 @@ class DboSourceTest extends CakeTestCase { unset($this->Model); } -/** - * testGenerateInnerJoinAssociationQuery method - * - * @access public - * @return void - */ - function testGenerateInnerJoinAssociationQuery() { - $this->Model = new TestModel9(); - $test = ConnectionManager::create('test2', $this->__config); - $this->Model->setDataSource('test2'); - $this->Model->TestModel8 = new TestModel8(); - $this->Model->TestModel8->setDataSource('test2'); - - $this->testDb->read($this->Model, array('recursive' => 1)); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/`TestModel9` LEFT JOIN `' . $this->testDb->fullTableName('test_model8', false) . '`/', $result); - - $this->Model->belongsTo['TestModel8']['type'] = 'INNER'; - $this->testDb->read($this->Model, array('recursive' => 1)); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/`TestModel9` INNER JOIN `' . $this->testDb->fullTableName('test_model8', false) . '`/', $result); - - } - /** * testGenerateAssociationQuerySelfJoinWithConditionsInHasOneBinding method * From 86f1309a54ea9b137322fd610324c1222cbfcbca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 3 Nov 2010 19:40:09 -0430 Subject: [PATCH 082/378] iMoving a couple of methods out from DboSourceTest --- .../model/datasources/dbo/dbo_mysql.test.php | 57 ++++++++++++++++++- .../model/datasources/dbo_source.test.php | 55 ------------------ 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 669b6a65a..64ba35e5e 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -997,7 +997,7 @@ class DboMysqlTest extends CakeTestCase { $linkModel = $model->{$className}; $external = isset($assocData['external']); - $queryData = $this->testDb->__scrubQueryData($queryData); + $queryData = $this->Dbo->__scrubQueryData($queryData); $result = array_merge(array('linkModel' => &$linkModel), compact('type', 'assoc', 'assocData', 'external')); return $result; @@ -1031,4 +1031,59 @@ class DboMysqlTest extends CakeTestCase { $this->Model->belongsTo['TestModel8']['type'] = 'INNER'; $test->read($this->Model, array('recursive' => 1)); } + +/** + * testGenerateAssociationQuerySelfJoinWithConditionsInHasOneBinding method + * + * @access public + * @return void + */ + function testGenerateAssociationQuerySelfJoinWithConditionsInHasOneBinding() { + $this->Model = new TestModel8(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type' => 'hasOne', 'model' => 'TestModel9'); + $queryData = array(); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + $_queryData = $queryData; + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertTrue($result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel8`\.`id`, `TestModel8`\.`test_model9_id`, `TestModel8`\.`name`, `TestModel8`\.`created`, `TestModel8`\.`updated`, `TestModel9`\.`id`, `TestModel9`\.`test_model8_id`, `TestModel9`\.`name`, `TestModel9`\.`created`, `TestModel9`\.`updated`\s+/', $result); + $this->assertPattern('/FROM\s+`test_model8` AS `TestModel8`\s+LEFT JOIN\s+`test_model9` AS `TestModel9`/', $result); + $this->assertPattern('/\s+ON\s+\(`TestModel9`\.`name` != \'mariano\'\s+AND\s+`TestModel9`.`test_model8_id` = `TestModel8`.`id`\)\s+WHERE/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); + } + +/** + * testGenerateAssociationQuerySelfJoinWithConditionsInBelongsToBinding method + * + * @access public + * @return void + */ + function testGenerateAssociationQuerySelfJoinWithConditionsInBelongsToBinding() { + $this->Model = new TestModel9(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type' => 'belongsTo', 'model' => 'TestModel8'); + $queryData = array(); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertTrue($result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel9`\.`id`, `TestModel9`\.`test_model8_id`, `TestModel9`\.`name`, `TestModel9`\.`created`, `TestModel9`\.`updated`, `TestModel8`\.`id`, `TestModel8`\.`test_model9_id`, `TestModel8`\.`name`, `TestModel8`\.`created`, `TestModel8`\.`updated`\s+/', $result); + $this->assertPattern('/FROM\s+`test_model9` AS `TestModel9`\s+LEFT JOIN\s+`test_model8` AS `TestModel8`/', $result); + $this->assertPattern('/\s+ON\s+\(`TestModel8`\.`name` != \'larry\'\s+AND\s+`TestModel9`.`test_model8_id` = `TestModel8`.`id`\)\s+WHERE/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); + } } diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 43a0d5dd6..b86405c73 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -117,61 +117,6 @@ class DboSourceTest extends CakeTestCase { unset($this->Model); } -/** - * testGenerateAssociationQuerySelfJoinWithConditionsInHasOneBinding method - * - * @access public - * @return void - */ - function testGenerateAssociationQuerySelfJoinWithConditionsInHasOneBinding() { - $this->Model = new TestModel8(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type' => 'hasOne', 'model' => 'TestModel9'); - $queryData = array(); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - $_queryData = $queryData; - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertTrue($result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel8`\.`id`, `TestModel8`\.`test_model9_id`, `TestModel8`\.`name`, `TestModel8`\.`created`, `TestModel8`\.`updated`, `TestModel9`\.`id`, `TestModel9`\.`test_model8_id`, `TestModel9`\.`name`, `TestModel9`\.`created`, `TestModel9`\.`updated`\s+/', $result); - $this->assertPattern('/FROM\s+`test_model8` AS `TestModel8`\s+LEFT JOIN\s+`test_model9` AS `TestModel9`/', $result); - $this->assertPattern('/\s+ON\s+\(`TestModel9`\.`name` != \'mariano\'\s+AND\s+`TestModel9`.`test_model8_id` = `TestModel8`.`id`\)\s+WHERE/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - } - -/** - * testGenerateAssociationQuerySelfJoinWithConditionsInBelongsToBinding method - * - * @access public - * @return void - */ - function testGenerateAssociationQuerySelfJoinWithConditionsInBelongsToBinding() { - $this->Model = new TestModel9(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type' => 'belongsTo', 'model' => 'TestModel8'); - $queryData = array(); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertTrue($result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel9`\.`id`, `TestModel9`\.`test_model8_id`, `TestModel9`\.`name`, `TestModel9`\.`created`, `TestModel9`\.`updated`, `TestModel8`\.`id`, `TestModel8`\.`test_model9_id`, `TestModel8`\.`name`, `TestModel8`\.`created`, `TestModel8`\.`updated`\s+/', $result); - $this->assertPattern('/FROM\s+`test_model9` AS `TestModel9`\s+LEFT JOIN\s+`test_model8` AS `TestModel8`/', $result); - $this->assertPattern('/\s+ON\s+\(`TestModel8`\.`name` != \'larry\'\s+AND\s+`TestModel9`.`test_model8_id` = `TestModel8`.`id`\)\s+WHERE/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - } - /** * testGenerateAssociationQuerySelfJoinWithConditions method * From a39adf213e196df25f7904c8a1d75c465ed457f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 3 Nov 2010 19:40:48 -0430 Subject: [PATCH 083/378] Adding missign option to testsuite shell --- cake/console/shells/testsuite.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cake/console/shells/testsuite.php b/cake/console/shells/testsuite.php index 5a91d3717..dacf09dd0 100644 --- a/cake/console/shells/testsuite.php +++ b/cake/console/shells/testsuite.php @@ -99,9 +99,12 @@ class TestSuiteShell extends Shell { ))->addOption('stderr', array( 'help' => __('Write to STDERR instead of STDOUT.'), 'boolean' => true - ))->addOption('stop-on-failure', array( + ))->addOption('stop-on-error', array( 'help' => __('Stop execution upon first error or failure.'), 'boolean' => true + ))->addOption('stop-on-failure', array( + 'help' => __('Stop execution upon first failure.'), + 'boolean' => true ))->addOption('stop-on-skipped ', array( 'help' => __('Stop execution upon first skipped test.'), 'boolean' => true From 6028705c721b6876e22628ef6a836b00d4b945ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 3 Nov 2010 19:52:49 -0430 Subject: [PATCH 084/378] Moving more methods out from DboSourceTest --- cake/libs/model/datasources/dbo_source.php | 2 +- .../model/datasources/dbo/dbo_mysql.test.php | 672 +++++++++++++++++- .../model/datasources/dbo_source.test.php | 656 ----------------- 3 files changed, 666 insertions(+), 664 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index c21a5c713..afd42a5c0 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -934,7 +934,7 @@ class DboSource extends DataSource { } } - $query = $this->generateAssociationQuery($model, $null, null, null, null, $queryData, false, $null); + $query = trim($this->generateAssociationQuery($model, $null, null, null, null, $queryData, false, $null)); $resultSet = $this->fetchAll($query, $model->cacheQueries); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 64ba35e5e..6b597ab91 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -874,7 +874,7 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testGenerateAssociationQuerySelfJoin() { - $this->testDb = $this->getMock('DboMysql', array('connect', '_execute', 'execute')); + $this->Dbo = $this->getMock('DboMysql', array('connect', '_execute', 'execute')); $this->startTime = microtime(true); $this->Model = new Article2(); $this->_buildRelatedModels($this->Model); @@ -890,18 +890,18 @@ class DboMysqlTest extends CakeTestCase { $external = isset($assocData['external']); if ($this->Model->Category2->alias == $linkModel->alias && $type != 'hasAndBelongsToMany' && $type != 'hasMany') { - $result = $this->testDb->generateAssociationQuery($this->Model->Category2, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null); + $result = $this->Dbo->generateAssociationQuery($this->Model->Category2, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null); $this->assertFalse(empty($result)); } else { if ($this->Model->Category2->useDbConfig == $linkModel->useDbConfig) { - $result = $this->testDb->generateAssociationQuery($this->Model->Category2, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null); + $result = $this->Dbo->generateAssociationQuery($this->Model->Category2, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null); $this->assertFalse(empty($result)); } } } } - $query = $this->testDb->generateAssociationQuery($this->Model->Category2, $null, null, null, null, $queryData, false, $null); + $query = $this->Dbo->generateAssociationQuery($this->Model->Category2, $null, null, null, null, $queryData, false, $null); $this->assertPattern('/^SELECT\s+(.+)FROM(.+)`Category2`\.`group_id`\s+=\s+`Group`\.`id`\)\s+LEFT JOIN(.+)WHERE\s+1 = 1\s*$/', $query); $this->Model = new TestModel4(); @@ -916,7 +916,7 @@ class DboMysqlTest extends CakeTestCase { $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); $_queryData = $queryData; - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); $this->assertTrue($result); $expected = array( @@ -946,7 +946,7 @@ class DboMysqlTest extends CakeTestCase { ); $this->assertEqual($queryData, $expected); - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel4Parent`\.`id`, `TestModel4Parent`\.`name`, `TestModel4Parent`\.`created`, `TestModel4Parent`\.`updated`\s+/', $result); $this->assertPattern('/FROM\s+`test_model4` AS `TestModel4`\s+LEFT JOIN\s+`test_model4` AS `TestModel4Parent`/', $result); $this->assertPattern('/\s+ON\s+\(`TestModel4`.`parent_id` = `TestModel4Parent`.`id`\)\s+WHERE/', $result); @@ -954,7 +954,7 @@ class DboMysqlTest extends CakeTestCase { $params['assocData']['type'] = 'INNER'; $this->Model->belongsTo['TestModel4Parent']['type'] = 'INNER'; - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $_queryData, $params['external'], $resultSet); + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $_queryData, $params['external'], $resultSet); $this->assertTrue($result); $this->assertEqual($_queryData['joins'][0]['type'], 'INNER'); } @@ -1086,4 +1086,662 @@ class DboMysqlTest extends CakeTestCase { $this->assertPattern('/\s+ON\s+\(`TestModel8`\.`name` != \'larry\'\s+AND\s+`TestModel9`.`test_model8_id` = `TestModel8`.`id`\)\s+WHERE/', $result); $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); } + +/** + * testGenerateAssociationQuerySelfJoinWithConditions method + * + * @access public + * @return void + */ + function testGenerateAssociationQuerySelfJoinWithConditions() { + $this->Model = new TestModel4(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type' => 'belongsTo', 'model' => 'TestModel4Parent'); + $queryData = array('conditions' => array('TestModel4Parent.name !=' => 'mariano')); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertTrue($result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel4Parent`\.`id`, `TestModel4Parent`\.`name`, `TestModel4Parent`\.`created`, `TestModel4Parent`\.`updated`\s+/', $result); + $this->assertPattern('/FROM\s+`test_model4` AS `TestModel4`\s+LEFT JOIN\s+`test_model4` AS `TestModel4Parent`/', $result); + $this->assertPattern('/\s+ON\s+\(`TestModel4`.`parent_id` = `TestModel4Parent`.`id`\)\s+WHERE/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?`TestModel4Parent`.`name`\s+!=\s+\'mariano\'(?:\))?\s*$/', $result); + + $this->Featured2 = new Featured2(); + $this->Featured2->schema(); + + $this->Featured2->bindModel(array( + 'belongsTo' => array( + 'ArticleFeatured2' => array( + 'conditions' => 'ArticleFeatured2.published = \'Y\'', + 'fields' => 'id, title, user_id, published' + ) + ) + )); + + $this->_buildRelatedModels($this->Featured2); + + $binding = array('type' => 'belongsTo', 'model' => 'ArticleFeatured2'); + $queryData = array('conditions' => array()); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Featured2, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Featured2, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertTrue($result); + $result = $this->Dbo->generateAssociationQuery($this->Featured2, $null, null, null, null, $queryData, false, $null); + + $this->assertPattern( + '/^SELECT\s+`Featured2`\.`id`, `Featured2`\.`article_id`, `Featured2`\.`category_id`, `Featured2`\.`name`,\s+'. + '`ArticleFeatured2`\.`id`, `ArticleFeatured2`\.`title`, `ArticleFeatured2`\.`user_id`, `ArticleFeatured2`\.`published`\s+' . + 'FROM\s+`featured2` AS `Featured2`\s+LEFT JOIN\s+`article_featured` AS `ArticleFeatured2`' . + '\s+ON\s+\(`ArticleFeatured2`.`published` = \'Y\'\s+AND\s+`Featured2`\.`article_featured2_id` = `ArticleFeatured2`\.`id`\)' . + '\s+WHERE\s+1\s+=\s+1\s*$/', + $result + ); + } + +/** + * testGenerateAssociationQueryHasOne method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryHasOne() { + $this->Model = new TestModel4(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type' => 'hasOne', 'model' => 'TestModel5'); + + $queryData = array(); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertTrue($result); + + $result = $this->Dbo->buildJoinStatement($queryData['joins'][0]); + $expected = ' LEFT JOIN `test_model5` AS `TestModel5` ON (`TestModel5`.`test_model4_id` = `TestModel4`.`id`)'; + $this->assertEqual(trim($result), trim($expected)); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model4` AS `TestModel4`\s+LEFT JOIN\s+/', $result); + $this->assertPattern('/`test_model5` AS `TestModel5`\s+ON\s+\(`TestModel5`.`test_model4_id` = `TestModel4`.`id`\)\s+WHERE/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?\s*1 = 1\s*(?:\))?\s*$/', $result); + } + +/** + * testGenerateAssociationQueryHasOneWithConditions method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryHasOneWithConditions() { + $this->Model = new TestModel4(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type' => 'hasOne', 'model' => 'TestModel5'); + + $queryData = array('conditions' => array('TestModel5.name !=' => 'mariano')); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertTrue($result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + + $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model4` AS `TestModel4`\s+LEFT JOIN\s+`test_model5` AS `TestModel5`/', $result); + $this->assertPattern('/\s+ON\s+\(`TestModel5`.`test_model4_id`\s+=\s+`TestModel4`.`id`\)\s+WHERE/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?\s*`TestModel5`.`name`\s+!=\s+\'mariano\'\s*(?:\))?\s*$/', $result); + } + +/** + * testGenerateAssociationQueryBelongsTo method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryBelongsTo() { + $this->Model = new TestModel5(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type'=>'belongsTo', 'model'=>'TestModel4'); + $queryData = array(); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertTrue($result); + + $result = $this->Dbo->buildJoinStatement($queryData['joins'][0]); + $expected = ' LEFT JOIN `test_model4` AS `TestModel4` ON (`TestModel5`.`test_model4_id` = `TestModel4`.`id`)'; + $this->assertEqual(trim($result), trim($expected)); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`, `TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+LEFT JOIN\s+`test_model4` AS `TestModel4`/', $result); + $this->assertPattern('/\s+ON\s+\(`TestModel5`.`test_model4_id` = `TestModel4`.`id`\)\s+WHERE\s+/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?\s*1 = 1\s*(?:\))?\s*$/', $result); + } + +/** + * testGenerateAssociationQueryBelongsToWithConditions method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryBelongsToWithConditions() { + $this->Model = new TestModel5(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type' => 'belongsTo', 'model' => 'TestModel4'); + $queryData = array('conditions' => array('TestModel5.name !=' => 'mariano')); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertTrue($result); + + $result = $this->Dbo->buildJoinStatement($queryData['joins'][0]); + $expected = ' LEFT JOIN `test_model4` AS `TestModel4` ON (`TestModel5`.`test_model4_id` = `TestModel4`.`id`)'; + $this->assertEqual(trim($result), trim($expected)); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`, `TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+LEFT JOIN\s+`test_model4` AS `TestModel4`/', $result); + $this->assertPattern('/\s+ON\s+\(`TestModel5`.`test_model4_id` = `TestModel4`.`id`\)\s+WHERE\s+/', $result); + $this->assertPattern('/\s+WHERE\s+`TestModel5`.`name` != \'mariano\'\s*$/', $result); + } + +/** + * testGenerateAssociationQueryHasMany method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryHasMany() { + $this->Model = new TestModel5(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $queryData = array(); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + + $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE/', $result); + $this->assertPattern('/\s+WHERE\s+`TestModel6`.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?\s*1 = 1\s*(?:\))?\s*$/', $result); + } + +/** + * testGenerateAssociationQueryHasManyWithLimit method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryHasManyWithLimit() { + $this->Model = new TestModel5(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $this->Model->hasMany['TestModel6']['limit'] = 2; + + $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $queryData = array(); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern( + '/^SELECT\s+' . + '`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+'. + 'FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+' . + '`TestModel6`.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)\s*'. + 'LIMIT \d*'. + '\s*$/', $result + ); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern( + '/^SELECT\s+'. + '`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+'. + 'FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+'. + '(?:\()?\s*1 = 1\s*(?:\))?'. + '\s*$/', $result + ); + } + +/** + * testGenerateAssociationQueryHasManyWithConditions method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryHasManyWithConditions() { + $this->Model = new TestModel5(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $queryData = array('conditions' => array('TestModel5.name !=' => 'mariano')); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); + $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?`TestModel5`.`name`\s+!=\s+\'mariano\'(?:\))?\s*$/', $result); + } + +/** + * testGenerateAssociationQueryHasManyWithOffsetAndLimit method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryHasManyWithOffsetAndLimit() { + $this->Model = new TestModel5(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $__backup = $this->Model->hasMany['TestModel6']; + + $this->Model->hasMany['TestModel6']['offset'] = 2; + $this->Model->hasMany['TestModel6']['limit'] = 5; + + $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $queryData = array(); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + + $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); + $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); + $this->assertPattern('/\s+LIMIT 2,\s*5\s*$/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); + + $this->Model->hasMany['TestModel6'] = $__backup; + } + +/** + * testGenerateAssociationQueryHasManyWithPageAndLimit method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryHasManyWithPageAndLimit() { + $this->Model = new TestModel5(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $__backup = $this->Model->hasMany['TestModel6']; + + $this->Model->hasMany['TestModel6']['page'] = 2; + $this->Model->hasMany['TestModel6']['limit'] = 5; + + $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $queryData = array(); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); + $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); + $this->assertPattern('/\s+LIMIT 5,\s*5\s*$/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); + + $this->Model->hasMany['TestModel6'] = $__backup; + } + +/** + * testGenerateAssociationQueryHasManyWithFields method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryHasManyWithFields() { + $this->Model = new TestModel5(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $queryData = array('fields' => array('`TestModel5`.`name`')); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); + $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel5`\.`name`, `TestModel5`\.`id`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); + + $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $queryData = array('fields' => array('`TestModel5`.`id`, `TestModel5`.`name`')); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); + $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`name`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); + + $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $queryData = array('fields' => array('`TestModel5`.`name`', '`TestModel5`.`created`')); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); + $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`id`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); + + $this->Model->hasMany['TestModel6']['fields'] = array('name'); + + $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $queryData = array('fields' => array('`TestModel5`.`id`', '`TestModel5`.`name`')); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern('/^SELECT\s+`TestModel6`\.`name`, `TestModel6`\.`test_model5_id`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); + $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`name`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); + + unset($this->Model->hasMany['TestModel6']['fields']); + + $this->Model->hasMany['TestModel6']['fields'] = array('id', 'name'); + + $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $queryData = array('fields' => array('`TestModel5`.`id`', '`TestModel5`.`name`')); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`name`, `TestModel6`\.`test_model5_id`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); + $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`name`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); + + unset($this->Model->hasMany['TestModel6']['fields']); + + $this->Model->hasMany['TestModel6']['fields'] = array('test_model5_id', 'name'); + + $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $queryData = array('fields' => array('`TestModel5`.`id`', '`TestModel5`.`name`')); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern('/^SELECT\s+`TestModel6`\.`test_model5_id`, `TestModel6`\.`name`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); + $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`name`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); + + unset($this->Model->hasMany['TestModel6']['fields']); + } + +/** + * test generateAssociationQuery with a hasMany and an aggregate function. + * + * @return void + */ + function testGenerateAssociationQueryHasManyAndAggregateFunction() { + $this->Model = new TestModel5(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $queryData = array('fields' => array('MIN(TestModel5.test_model4_id)')); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + $this->Model->recursive = 0; + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, $params['type'], $params['assoc'], $params['assocData'], $queryData, false, $resultSet); + $this->assertPattern('/^SELECT\s+MIN\(`TestModel5`\.`test_model4_id`\)\s+FROM/', $result); + } + +/** + * testGenerateAssociationQueryHasAndBelongsToMany method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryHasAndBelongsToMany() { + $this->Model = new TestModel4(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type' => 'hasAndBelongsToMany', 'model' => 'TestModel7'); + $queryData = array(); + $resultSet = null; + $null = null; + + $params = $this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern('/^SELECT\s+`TestModel7`\.`id`, `TestModel7`\.`name`, `TestModel7`\.`created`, `TestModel7`\.`updated`, `TestModel4TestModel7`\.`test_model4_id`, `TestModel4TestModel7`\.`test_model7_id`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model7` AS `TestModel7`\s+JOIN\s+`' . $this->Dbo->fullTableName('test_model4_test_model7', false) . '`/', $result); + $this->assertPattern('/\s+ON\s+\(`TestModel4TestModel7`\.`test_model4_id`\s+=\s+{\$__cakeID__\$}\s+AND/', $result); + $this->assertPattern('/\s+AND\s+`TestModel4TestModel7`\.`test_model7_id`\s+=\s+`TestModel7`\.`id`\)/', $result); + $this->assertPattern('/WHERE\s+(?:\()?1 = 1(?:\))?\s*$/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model4` AS `TestModel4`\s+WHERE/', $result); + $this->assertPattern('/\s+WHERE\s+(?:\()?1 = 1(?:\))?\s*$/', $result); + } + +/** + * testGenerateAssociationQueryHasAndBelongsToManyWithConditions method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryHasAndBelongsToManyWithConditions() { + $this->Model = new TestModel4(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $binding = array('type'=>'hasAndBelongsToMany', 'model'=>'TestModel7'); + $queryData = array('conditions' => array('TestModel4.name !=' => 'mariano')); + $resultSet = null; + $null = null; + + $params = $this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern('/^SELECT\s+`TestModel7`\.`id`, `TestModel7`\.`name`, `TestModel7`\.`created`, `TestModel7`\.`updated`, `TestModel4TestModel7`\.`test_model4_id`, `TestModel4TestModel7`\.`test_model7_id`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model7`\s+AS\s+`TestModel7`\s+JOIN\s+`test_model4_test_model7`\s+AS\s+`TestModel4TestModel7`/', $result); + $this->assertPattern('/\s+ON\s+\(`TestModel4TestModel7`\.`test_model4_id`\s+=\s+{\$__cakeID__\$}/', $result); + $this->assertPattern('/\s+AND\s+`TestModel4TestModel7`\.`test_model7_id`\s+=\s+`TestModel7`\.`id`\)\s+WHERE\s+/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model4` AS `TestModel4`\s+WHERE\s+(?:\()?`TestModel4`.`name`\s+!=\s+\'mariano\'(?:\))?\s*$/', $result); + } + +/** + * testGenerateAssociationQueryHasAndBelongsToManyWithOffsetAndLimit method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryHasAndBelongsToManyWithOffsetAndLimit() { + $this->Model = new TestModel4(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $__backup = $this->Model->hasAndBelongsToMany['TestModel7']; + + $this->Model->hasAndBelongsToMany['TestModel7']['offset'] = 2; + $this->Model->hasAndBelongsToMany['TestModel7']['limit'] = 5; + + $binding = array('type'=>'hasAndBelongsToMany', 'model'=>'TestModel7'); + $queryData = array(); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern('/^SELECT\s+`TestModel7`\.`id`, `TestModel7`\.`name`, `TestModel7`\.`created`, `TestModel7`\.`updated`, `TestModel4TestModel7`\.`test_model4_id`, `TestModel4TestModel7`\.`test_model7_id`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model7`\s+AS\s+`TestModel7`\s+JOIN\s+`test_model4_test_model7`\s+AS\s+`TestModel4TestModel7`/', $result); + $this->assertPattern('/\s+ON\s+\(`TestModel4TestModel7`\.`test_model4_id`\s+=\s+{\$__cakeID__\$}\s+/', $result); + $this->assertPattern('/\s+AND\s+`TestModel4TestModel7`\.`test_model7_id`\s+=\s+`TestModel7`\.`id`\)\s+WHERE\s+/', $result); + $this->assertPattern('/\s+(?:\()?1\s+=\s+1(?:\))?\s*\s+LIMIT 2,\s*5\s*$/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model4` AS `TestModel4`\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); + + $this->Model->hasAndBelongsToMany['TestModel7'] = $__backup; + } + +/** + * testGenerateAssociationQueryHasAndBelongsToManyWithPageAndLimit method + * + * @access public + * @return void + */ + function testGenerateAssociationQueryHasAndBelongsToManyWithPageAndLimit() { + $this->Model = new TestModel4(); + $this->Model->schema(); + $this->_buildRelatedModels($this->Model); + + $__backup = $this->Model->hasAndBelongsToMany['TestModel7']; + + $this->Model->hasAndBelongsToMany['TestModel7']['page'] = 2; + $this->Model->hasAndBelongsToMany['TestModel7']['limit'] = 5; + + $binding = array('type'=>'hasAndBelongsToMany', 'model'=>'TestModel7'); + $queryData = array(); + $resultSet = null; + $null = null; + + $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $this->assertPattern('/^SELECT\s+`TestModel7`\.`id`, `TestModel7`\.`name`, `TestModel7`\.`created`, `TestModel7`\.`updated`, `TestModel4TestModel7`\.`test_model4_id`, `TestModel4TestModel7`\.`test_model7_id`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model7`\s+AS\s+`TestModel7`\s+JOIN\s+`test_model4_test_model7`\s+AS\s+`TestModel4TestModel7`/', $result); + $this->assertPattern('/\s+ON\s+\(`TestModel4TestModel7`\.`test_model4_id`\s+=\s+{\$__cakeID__\$}/', $result); + $this->assertPattern('/\s+AND\s+`TestModel4TestModel7`\.`test_model7_id`\s+=\s+`TestModel7`\.`id`\)\s+WHERE\s+/', $result); + $this->assertPattern('/\s+(?:\()?1\s+=\s+1(?:\))?\s*\s+LIMIT 5,\s*5\s*$/', $result); + + $result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); + $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result); + $this->assertPattern('/\s+FROM\s+`test_model4` AS `TestModel4`\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); + + $this->Model->hasAndBelongsToMany['TestModel7'] = $__backup; + } + +/** + * testSelectDistict method + * + * @access public + * @return void + */ + function testSelectDistict() { + $this->Model = new TestModel4(); + $result = $this->Dbo->fields($this->Model, 'Vendor', "DISTINCT Vendor.id, Vendor.name"); + $expected = array('DISTINCT `Vendor`.`id`', '`Vendor`.`name`'); + $this->assertEqual($result, $expected); + } } diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index b86405c73..4488c1e24 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -117,662 +117,6 @@ class DboSourceTest extends CakeTestCase { unset($this->Model); } -/** - * testGenerateAssociationQuerySelfJoinWithConditions method - * - * @access public - * @return void - */ - function testGenerateAssociationQuerySelfJoinWithConditions() { - $this->Model = new TestModel4(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type' => 'belongsTo', 'model' => 'TestModel4Parent'); - $queryData = array('conditions' => array('TestModel4Parent.name !=' => 'mariano')); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertTrue($result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel4Parent`\.`id`, `TestModel4Parent`\.`name`, `TestModel4Parent`\.`created`, `TestModel4Parent`\.`updated`\s+/', $result); - $this->assertPattern('/FROM\s+`test_model4` AS `TestModel4`\s+LEFT JOIN\s+`test_model4` AS `TestModel4Parent`/', $result); - $this->assertPattern('/\s+ON\s+\(`TestModel4`.`parent_id` = `TestModel4Parent`.`id`\)\s+WHERE/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?`TestModel4Parent`.`name`\s+!=\s+\'mariano\'(?:\))?\s*$/', $result); - - $this->Featured2 = new Featured2(); - $this->Featured2->schema(); - - $this->Featured2->bindModel(array( - 'belongsTo' => array( - 'ArticleFeatured2' => array( - 'conditions' => 'ArticleFeatured2.published = \'Y\'', - 'fields' => 'id, title, user_id, published' - ) - ) - )); - - $this->_buildRelatedModels($this->Featured2); - - $binding = array('type' => 'belongsTo', 'model' => 'ArticleFeatured2'); - $queryData = array('conditions' => array()); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Featured2, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Featured2, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertTrue($result); - $result = $this->testDb->generateAssociationQuery($this->Featured2, $null, null, null, null, $queryData, false, $null); - - $this->assertPattern( - '/^SELECT\s+`Featured2`\.`id`, `Featured2`\.`article_id`, `Featured2`\.`category_id`, `Featured2`\.`name`,\s+'. - '`ArticleFeatured2`\.`id`, `ArticleFeatured2`\.`title`, `ArticleFeatured2`\.`user_id`, `ArticleFeatured2`\.`published`\s+' . - 'FROM\s+`featured2` AS `Featured2`\s+LEFT JOIN\s+`article_featured` AS `ArticleFeatured2`' . - '\s+ON\s+\(`ArticleFeatured2`.`published` = \'Y\'\s+AND\s+`Featured2`\.`article_featured2_id` = `ArticleFeatured2`\.`id`\)' . - '\s+WHERE\s+1\s+=\s+1\s*$/', - $result - ); - } - -/** - * testGenerateAssociationQueryHasOne method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryHasOne() { - $this->Model = new TestModel4(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type' => 'hasOne', 'model' => 'TestModel5'); - - $queryData = array(); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertTrue($result); - - $result = $this->testDb->buildJoinStatement($queryData['joins'][0]); - $expected = ' LEFT JOIN `test_model5` AS `TestModel5` ON (`TestModel5`.`test_model4_id` = `TestModel4`.`id`)'; - $this->assertEqual(trim($result), trim($expected)); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model4` AS `TestModel4`\s+LEFT JOIN\s+/', $result); - $this->assertPattern('/`test_model5` AS `TestModel5`\s+ON\s+\(`TestModel5`.`test_model4_id` = `TestModel4`.`id`\)\s+WHERE/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?\s*1 = 1\s*(?:\))?\s*$/', $result); - } - -/** - * testGenerateAssociationQueryHasOneWithConditions method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryHasOneWithConditions() { - $this->Model = new TestModel4(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type' => 'hasOne', 'model' => 'TestModel5'); - - $queryData = array('conditions' => array('TestModel5.name !=' => 'mariano')); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertTrue($result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - - $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model4` AS `TestModel4`\s+LEFT JOIN\s+`test_model5` AS `TestModel5`/', $result); - $this->assertPattern('/\s+ON\s+\(`TestModel5`.`test_model4_id`\s+=\s+`TestModel4`.`id`\)\s+WHERE/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?\s*`TestModel5`.`name`\s+!=\s+\'mariano\'\s*(?:\))?\s*$/', $result); - } - -/** - * testGenerateAssociationQueryBelongsTo method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryBelongsTo() { - $this->Model = new TestModel5(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type'=>'belongsTo', 'model'=>'TestModel4'); - $queryData = array(); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertTrue($result); - - $result = $this->testDb->buildJoinStatement($queryData['joins'][0]); - $expected = ' LEFT JOIN `test_model4` AS `TestModel4` ON (`TestModel5`.`test_model4_id` = `TestModel4`.`id`)'; - $this->assertEqual(trim($result), trim($expected)); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`, `TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+LEFT JOIN\s+`test_model4` AS `TestModel4`/', $result); - $this->assertPattern('/\s+ON\s+\(`TestModel5`.`test_model4_id` = `TestModel4`.`id`\)\s+WHERE\s+/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?\s*1 = 1\s*(?:\))?\s*$/', $result); - } - -/** - * testGenerateAssociationQueryBelongsToWithConditions method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryBelongsToWithConditions() { - $this->Model = new TestModel5(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type' => 'belongsTo', 'model' => 'TestModel4'); - $queryData = array('conditions' => array('TestModel5.name !=' => 'mariano')); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertTrue($result); - - $result = $this->testDb->buildJoinStatement($queryData['joins'][0]); - $expected = ' LEFT JOIN `test_model4` AS `TestModel4` ON (`TestModel5`.`test_model4_id` = `TestModel4`.`id`)'; - $this->assertEqual(trim($result), trim($expected)); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`, `TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+LEFT JOIN\s+`test_model4` AS `TestModel4`/', $result); - $this->assertPattern('/\s+ON\s+\(`TestModel5`.`test_model4_id` = `TestModel4`.`id`\)\s+WHERE\s+/', $result); - $this->assertPattern('/\s+WHERE\s+`TestModel5`.`name` != \'mariano\'\s*$/', $result); - } - -/** - * testGenerateAssociationQueryHasMany method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryHasMany() { - $this->Model = new TestModel5(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array(); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - - $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE/', $result); - $this->assertPattern('/\s+WHERE\s+`TestModel6`.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?\s*1 = 1\s*(?:\))?\s*$/', $result); - } - -/** - * testGenerateAssociationQueryHasManyWithLimit method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryHasManyWithLimit() { - $this->Model = new TestModel5(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $this->Model->hasMany['TestModel6']['limit'] = 2; - - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array(); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern( - '/^SELECT\s+' . - '`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+'. - 'FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+' . - '`TestModel6`.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)\s*'. - 'LIMIT \d*'. - '\s*$/', $result - ); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern( - '/^SELECT\s+'. - '`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+'. - 'FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+'. - '(?:\()?\s*1 = 1\s*(?:\))?'. - '\s*$/', $result - ); - } - -/** - * testGenerateAssociationQueryHasManyWithConditions method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryHasManyWithConditions() { - $this->Model = new TestModel5(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('conditions' => array('TestModel5.name !=' => 'mariano')); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); - $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?`TestModel5`.`name`\s+!=\s+\'mariano\'(?:\))?\s*$/', $result); - } - -/** - * testGenerateAssociationQueryHasManyWithOffsetAndLimit method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryHasManyWithOffsetAndLimit() { - $this->Model = new TestModel5(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $__backup = $this->Model->hasMany['TestModel6']; - - $this->Model->hasMany['TestModel6']['offset'] = 2; - $this->Model->hasMany['TestModel6']['limit'] = 5; - - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array(); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - - $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); - $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); - $this->assertPattern('/\s+LIMIT 2,\s*5\s*$/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - - $this->Model->hasMany['TestModel6'] = $__backup; - } - -/** - * testGenerateAssociationQueryHasManyWithPageAndLimit method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryHasManyWithPageAndLimit() { - $this->Model = new TestModel5(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $__backup = $this->Model->hasMany['TestModel6']; - - $this->Model->hasMany['TestModel6']['page'] = 2; - $this->Model->hasMany['TestModel6']['limit'] = 5; - - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array(); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); - $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); - $this->assertPattern('/\s+LIMIT 5,\s*5\s*$/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - - $this->Model->hasMany['TestModel6'] = $__backup; - } - -/** - * testGenerateAssociationQueryHasManyWithFields method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryHasManyWithFields() { - $this->Model = new TestModel5(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('`TestModel5`.`name`')); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); - $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel5`\.`name`, `TestModel5`\.`id`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('`TestModel5`.`id`, `TestModel5`.`name`')); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); - $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`name`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('`TestModel5`.`name`', '`TestModel5`.`created`')); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); - $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`id`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - - $this->Model->hasMany['TestModel6']['fields'] = array('name'); - - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('`TestModel5`.`id`', '`TestModel5`.`name`')); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern('/^SELECT\s+`TestModel6`\.`name`, `TestModel6`\.`test_model5_id`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); - $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`name`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - - unset($this->Model->hasMany['TestModel6']['fields']); - - $this->Model->hasMany['TestModel6']['fields'] = array('id', 'name'); - - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('`TestModel5`.`id`', '`TestModel5`.`name`')); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern('/^SELECT\s+`TestModel6`\.`id`, `TestModel6`\.`name`, `TestModel6`\.`test_model5_id`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); - $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`name`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - - unset($this->Model->hasMany['TestModel6']['fields']); - - $this->Model->hasMany['TestModel6']['fields'] = array('test_model5_id', 'name'); - - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('`TestModel5`.`id`', '`TestModel5`.`name`')); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern('/^SELECT\s+`TestModel6`\.`test_model5_id`, `TestModel6`\.`name`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model6` AS `TestModel6`\s+WHERE\s+/', $result); - $this->assertPattern('/WHERE\s+(?:\()?`TestModel6`\.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)(?:\))?/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel5`\.`id`, `TestModel5`\.`name`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - - unset($this->Model->hasMany['TestModel6']['fields']); - } - -/** - * test generateAssociationQuery with a hasMany and an aggregate function. - * - * @return void - */ - function testGenerateAssociationQueryHasManyAndAggregateFunction() { - $this->Model = new TestModel5(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('MIN(TestModel5.test_model4_id)')); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - $this->Model->recursive = 0; - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, $params['type'], $params['assoc'], $params['assocData'], $queryData, false, $resultSet); - $this->assertPattern('/^SELECT\s+MIN\(`TestModel5`\.`test_model4_id`\)\s+FROM/', $result); - } - -/** - * testGenerateAssociationQueryHasAndBelongsToMany method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryHasAndBelongsToMany() { - $this->Model = new TestModel4(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type' => 'hasAndBelongsToMany', 'model' => 'TestModel7'); - $queryData = array(); - $resultSet = null; - $null = null; - - $params = $this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern('/^SELECT\s+`TestModel7`\.`id`, `TestModel7`\.`name`, `TestModel7`\.`created`, `TestModel7`\.`updated`, `TestModel4TestModel7`\.`test_model4_id`, `TestModel4TestModel7`\.`test_model7_id`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model7` AS `TestModel7`\s+JOIN\s+`' . $this->testDb->fullTableName('test_model4_test_model7', false) . '`/', $result); - $this->assertPattern('/\s+ON\s+\(`TestModel4TestModel7`\.`test_model4_id`\s+=\s+{\$__cakeID__\$}\s+AND/', $result); - $this->assertPattern('/\s+AND\s+`TestModel4TestModel7`\.`test_model7_id`\s+=\s+`TestModel7`\.`id`\)/', $result); - $this->assertPattern('/WHERE\s+(?:\()?1 = 1(?:\))?\s*$/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model4` AS `TestModel4`\s+WHERE/', $result); - $this->assertPattern('/\s+WHERE\s+(?:\()?1 = 1(?:\))?\s*$/', $result); - } - -/** - * testGenerateAssociationQueryHasAndBelongsToManyWithConditions method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryHasAndBelongsToManyWithConditions() { - $this->Model = new TestModel4(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $binding = array('type'=>'hasAndBelongsToMany', 'model'=>'TestModel7'); - $queryData = array('conditions' => array('TestModel4.name !=' => 'mariano')); - $resultSet = null; - $null = null; - - $params = $this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern('/^SELECT\s+`TestModel7`\.`id`, `TestModel7`\.`name`, `TestModel7`\.`created`, `TestModel7`\.`updated`, `TestModel4TestModel7`\.`test_model4_id`, `TestModel4TestModel7`\.`test_model7_id`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model7`\s+AS\s+`TestModel7`\s+JOIN\s+`test_model4_test_model7`\s+AS\s+`TestModel4TestModel7`/', $result); - $this->assertPattern('/\s+ON\s+\(`TestModel4TestModel7`\.`test_model4_id`\s+=\s+{\$__cakeID__\$}/', $result); - $this->assertPattern('/\s+AND\s+`TestModel4TestModel7`\.`test_model7_id`\s+=\s+`TestModel7`\.`id`\)\s+WHERE\s+/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model4` AS `TestModel4`\s+WHERE\s+(?:\()?`TestModel4`.`name`\s+!=\s+\'mariano\'(?:\))?\s*$/', $result); - } - -/** - * testGenerateAssociationQueryHasAndBelongsToManyWithOffsetAndLimit method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryHasAndBelongsToManyWithOffsetAndLimit() { - $this->Model = new TestModel4(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $__backup = $this->Model->hasAndBelongsToMany['TestModel7']; - - $this->Model->hasAndBelongsToMany['TestModel7']['offset'] = 2; - $this->Model->hasAndBelongsToMany['TestModel7']['limit'] = 5; - - $binding = array('type'=>'hasAndBelongsToMany', 'model'=>'TestModel7'); - $queryData = array(); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern('/^SELECT\s+`TestModel7`\.`id`, `TestModel7`\.`name`, `TestModel7`\.`created`, `TestModel7`\.`updated`, `TestModel4TestModel7`\.`test_model4_id`, `TestModel4TestModel7`\.`test_model7_id`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model7`\s+AS\s+`TestModel7`\s+JOIN\s+`test_model4_test_model7`\s+AS\s+`TestModel4TestModel7`/', $result); - $this->assertPattern('/\s+ON\s+\(`TestModel4TestModel7`\.`test_model4_id`\s+=\s+{\$__cakeID__\$}\s+/', $result); - $this->assertPattern('/\s+AND\s+`TestModel4TestModel7`\.`test_model7_id`\s+=\s+`TestModel7`\.`id`\)\s+WHERE\s+/', $result); - $this->assertPattern('/\s+(?:\()?1\s+=\s+1(?:\))?\s*\s+LIMIT 2,\s*5\s*$/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model4` AS `TestModel4`\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - - $this->Model->hasAndBelongsToMany['TestModel7'] = $__backup; - } - -/** - * testGenerateAssociationQueryHasAndBelongsToManyWithPageAndLimit method - * - * @access public - * @return void - */ - function testGenerateAssociationQueryHasAndBelongsToManyWithPageAndLimit() { - $this->Model = new TestModel4(); - $this->Model->schema(); - $this->_buildRelatedModels($this->Model); - - $__backup = $this->Model->hasAndBelongsToMany['TestModel7']; - - $this->Model->hasAndBelongsToMany['TestModel7']['page'] = 2; - $this->Model->hasAndBelongsToMany['TestModel7']['limit'] = 5; - - $binding = array('type'=>'hasAndBelongsToMany', 'model'=>'TestModel7'); - $queryData = array(); - $resultSet = null; - $null = null; - - $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); - - $result = $this->testDb->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); - $this->assertPattern('/^SELECT\s+`TestModel7`\.`id`, `TestModel7`\.`name`, `TestModel7`\.`created`, `TestModel7`\.`updated`, `TestModel4TestModel7`\.`test_model4_id`, `TestModel4TestModel7`\.`test_model7_id`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model7`\s+AS\s+`TestModel7`\s+JOIN\s+`test_model4_test_model7`\s+AS\s+`TestModel4TestModel7`/', $result); - $this->assertPattern('/\s+ON\s+\(`TestModel4TestModel7`\.`test_model4_id`\s+=\s+{\$__cakeID__\$}/', $result); - $this->assertPattern('/\s+AND\s+`TestModel4TestModel7`\.`test_model7_id`\s+=\s+`TestModel7`\.`id`\)\s+WHERE\s+/', $result); - $this->assertPattern('/\s+(?:\()?1\s+=\s+1(?:\))?\s*\s+LIMIT 5,\s*5\s*$/', $result); - - $result = $this->testDb->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null); - $this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model4` AS `TestModel4`\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - - $this->Model->hasAndBelongsToMany['TestModel7'] = $__backup; - } - -/** - * testSelectDistict method - * - * @access public - * @return void - */ - function testSelectDistict() { - $result = $this->testDb->fields($this->Model, 'Vendor', "DISTINCT Vendor.id, Vendor.name"); - $expected = array('DISTINCT `Vendor`.`id`', '`Vendor`.`name`'); - $this->assertEqual($result, $expected); - } /** * test that booleans and null make logical condition strings. From 3a8016b875551e22251341f51a1e98e0be9e3dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 3 Nov 2010 19:59:15 -0430 Subject: [PATCH 085/378] Even more methods containing quoting specific to mysql out of DboSource --- .../model/datasources/dbo/dbo_mysql.test.php | 713 ++++++++++++++++++ .../model/datasources/dbo_source.test.php | 710 ----------------- 2 files changed, 713 insertions(+), 710 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 6b597ab91..835176bc8 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -1744,4 +1744,717 @@ class DboMysqlTest extends CakeTestCase { $expected = array('DISTINCT `Vendor`.`id`', '`Vendor`.`name`'); $this->assertEqual($result, $expected); } + +/** + * testStringConditionsParsing method + * + * @access public + * @return void + */ + function testStringConditionsParsing() { + $result = $this->Dbo->conditions("ProjectBid.project_id = Project.id"); + $expected = " WHERE `ProjectBid`.`project_id` = `Project`.`id`"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions("Candy.name LIKE 'a' AND HardCandy.name LIKE 'c'"); + $expected = " WHERE `Candy`.`name` LIKE 'a' AND `HardCandy`.`name` LIKE 'c'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions("HardCandy.name LIKE 'a' AND Candy.name LIKE 'c'"); + $expected = " WHERE `HardCandy`.`name` LIKE 'a' AND `Candy`.`name` LIKE 'c'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions("Post.title = '1.1'"); + $expected = " WHERE `Post`.`title` = '1.1'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions("User.id != 0 AND User.user LIKE '%arr%'"); + $expected = " WHERE `User`.`id` != 0 AND `User`.`user` LIKE '%arr%'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions("SUM(Post.comments_count) > 500"); + $expected = " WHERE SUM(`Post`.`comments_count`) > 500"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions("(Post.created < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(Post.created), MONTH(Post.created)"); + $expected = " WHERE (`Post`.`created` < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(`Post`.`created`), MONTH(`Post`.`created`)"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions("score BETWEEN 90.1 AND 95.7"); + $expected = " WHERE score BETWEEN 90.1 AND 95.7"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('score' => array(2=>1, 2, 10))); + $expected = " WHERE score IN (1, 2, 10)"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions("Aro.rght = Aro.lft + 1.1"); + $expected = " WHERE `Aro`.`rght` = `Aro`.`lft` + 1.1"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions("(Post.created < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(Post.created), MONTH(Post.created)"); + $expected = " WHERE (`Post`.`created` < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(`Post`.`created`), MONTH(`Post`.`created`)"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions('Sportstaette.sportstaette LIKE "%ru%" AND Sportstaette.sportstaettenart_id = 2'); + $expected = ' WHERE `Sportstaette`.`sportstaette` LIKE "%ru%" AND `Sportstaette`.`sportstaettenart_id` = 2'; + $this->assertPattern('/\s*WHERE\s+`Sportstaette`\.`sportstaette`\s+LIKE\s+"%ru%"\s+AND\s+`Sports/', $result); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions('Sportstaette.sportstaettenart_id = 2 AND Sportstaette.sportstaette LIKE "%ru%"'); + $expected = ' WHERE `Sportstaette`.`sportstaettenart_id` = 2 AND `Sportstaette`.`sportstaette` LIKE "%ru%"'; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions('SUM(Post.comments_count) > 500 AND NOT Post.title IS NULL AND NOT Post.extended_title IS NULL'); + $expected = ' WHERE SUM(`Post`.`comments_count`) > 500 AND NOT `Post`.`title` IS NULL AND NOT `Post`.`extended_title` IS NULL'; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions('NOT Post.title IS NULL AND NOT Post.extended_title IS NULL AND SUM(Post.comments_count) > 500'); + $expected = ' WHERE NOT `Post`.`title` IS NULL AND NOT `Post`.`extended_title` IS NULL AND SUM(`Post`.`comments_count`) > 500'; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions('NOT Post.extended_title IS NULL AND NOT Post.title IS NULL AND Post.title != "" AND SPOON(SUM(Post.comments_count) + 1.1) > 500'); + $expected = ' WHERE NOT `Post`.`extended_title` IS NULL AND NOT `Post`.`title` IS NULL AND `Post`.`title` != "" AND SPOON(SUM(`Post`.`comments_count`) + 1.1) > 500'; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions('NOT Post.title_extended IS NULL AND NOT Post.title IS NULL AND Post.title_extended != Post.title'); + $expected = ' WHERE NOT `Post`.`title_extended` IS NULL AND NOT `Post`.`title` IS NULL AND `Post`.`title_extended` != `Post`.`title`'; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions("Comment.id = 'a'"); + $expected = " WHERE `Comment`.`id` = 'a'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions("lower(Article.title) LIKE 'a%'"); + $expected = " WHERE lower(`Article`.`title`) LIKE 'a%'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions('((MATCH(Video.title) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 2) + (MATCH(Video.description) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 0.4) + (MATCH(Video.tags) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 1.5))'); + $expected = ' WHERE ((MATCH(`Video`.`title`) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 2) + (MATCH(`Video`.`description`) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 0.4) + (MATCH(`Video`.`tags`) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 1.5))'; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions('DATEDIFF(NOW(),Article.published) < 1 && Article.live=1'); + $expected = " WHERE DATEDIFF(NOW(),`Article`.`published`) < 1 && `Article`.`live`=1"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions('file = "index.html"'); + $expected = ' WHERE file = "index.html"'; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions("file = 'index.html'"); + $expected = " WHERE file = 'index.html'"; + $this->assertEqual($result, $expected); + + $letter = $letter = 'd.a'; + $conditions = array('Company.name like ' => $letter . '%'); + $result = $this->Dbo->conditions($conditions); + $expected = " WHERE `Company`.`name` like 'd.a%'"; + $this->assertEqual($result, $expected); + + $conditions = array('Artist.name' => 'JUDY and MARY'); + $result = $this->Dbo->conditions($conditions); + $expected = " WHERE `Artist`.`name` = 'JUDY and MARY'"; + $this->assertEqual($result, $expected); + + $conditions = array('Artist.name' => 'JUDY AND MARY'); + $result = $this->Dbo->conditions($conditions); + $expected = " WHERE `Artist`.`name` = 'JUDY AND MARY'"; + $this->assertEqual($result, $expected); + } + +/** + * testQuotesInStringConditions method + * + * @access public + * @return void + */ + function testQuotesInStringConditions() { + $result = $this->Dbo->conditions('Member.email = \'mariano@cricava.com\''); + $expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\''; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions('Member.email = "mariano@cricava.com"'); + $expected = ' WHERE `Member`.`email` = "mariano@cricava.com"'; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions('Member.email = \'mariano@cricava.com\' AND Member.user LIKE \'mariano.iglesias%\''); + $expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\' AND `Member`.`user` LIKE \'mariano.iglesias%\''; + $this->assertEqual($result, $expected); + + + $result = $this->Dbo->conditions('Member.email = "mariano@cricava.com" AND Member.user LIKE "mariano.iglesias%"'); + $expected = ' WHERE `Member`.`email` = "mariano@cricava.com" AND `Member`.`user` LIKE "mariano.iglesias%"'; + $this->assertEqual($result, $expected); + } + +/** + * testParenthesisInStringConditions method + * + * @access public + * @return void + */ + function testParenthesisInStringConditions() { + $result = $this->Dbo->conditions('Member.name = \'(lu\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(lu\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \')lu\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\)lu\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \'va(lu\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \'va)lu\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\)lu\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \'va(lu)\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\)\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \'va(lu)e\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\)e\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \'(mariano)\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\)\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \'(mariano)iglesias\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\)iglesias\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \'(mariano) iglesias\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\) iglesias\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \'(mariano word) iglesias\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano word\) iglesias\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \'(mariano.iglesias)\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano.iglesias\)\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \'Mariano Iglesias (mariano.iglesias)\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\)\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \'Mariano Iglesias (mariano.iglesias) CakePHP\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\) CakePHP\'$/', $result); + + $result = $this->Dbo->conditions('Member.name = \'(mariano.iglesias) CakePHP\''); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano.iglesias\) CakePHP\'$/', $result); + } + +/** + * testParenthesisInArrayConditions method + * + * @access public + * @return void + */ + function testParenthesisInArrayConditions() { + $result = $this->Dbo->conditions(array('Member.name' => '(lu')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(lu\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => ')lu')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\)lu\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => 'va(lu')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => 'va)lu')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\)lu\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => 'va(lu)')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\)\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => 'va(lu)e')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\)e\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => '(mariano)')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\)\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => '(mariano)iglesias')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\)iglesias\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => '(mariano) iglesias')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\) iglesias\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => '(mariano word) iglesias')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano word\) iglesias\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => '(mariano.iglesias)')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano.iglesias\)\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => 'Mariano Iglesias (mariano.iglesias)')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\)\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => 'Mariano Iglesias (mariano.iglesias) CakePHP')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\) CakePHP\'$/', $result); + + $result = $this->Dbo->conditions(array('Member.name' => '(mariano.iglesias) CakePHP')); + $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano.iglesias\) CakePHP\'$/', $result); + } + +/** + * testArrayConditionsParsing method + * + * @access public + * @return void + */ + function testArrayConditionsParsing() { + $this->loadFixtures('Post', 'Author'); + $result = $this->Dbo->conditions(array('Stereo.type' => 'in dash speakers')); + $this->assertPattern("/^\s+WHERE\s+`Stereo`.`type`\s+=\s+'in dash speakers'/", $result); + + $result = $this->Dbo->conditions(array('Candy.name LIKE' => 'a', 'HardCandy.name LIKE' => 'c')); + $this->assertPattern("/^\s+WHERE\s+`Candy`.`name` LIKE\s+'a'\s+AND\s+`HardCandy`.`name`\s+LIKE\s+'c'/", $result); + + $result = $this->Dbo->conditions(array('HardCandy.name LIKE' => 'a', 'Candy.name LIKE' => 'c')); + $expected = " WHERE `HardCandy`.`name` LIKE 'a' AND `Candy`.`name` LIKE 'c'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('HardCandy.name LIKE' => 'a%', 'Candy.name LIKE' => '%c%')); + $expected = " WHERE `HardCandy`.`name` LIKE 'a%' AND `Candy`.`name` LIKE '%c%'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('HardCandy.name LIKE' => 'to be or%', 'Candy.name LIKE' => '%not to be%')); + $expected = " WHERE `HardCandy`.`name` LIKE 'to be or%' AND `Candy`.`name` LIKE '%not to be%'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('score BETWEEN ? AND ?' => array(90.1, 95.7))); + $expected = " WHERE `score` BETWEEN 90.100000 AND 95.700000"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('Post.title' => 1.1)); + $expected = " WHERE `Post`.`title` = 1.100000"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('Post.title' => 1.1), true, true, new Post()); + $expected = " WHERE `Post`.`title` = '1.1'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('SUM(Post.comments_count) >' => '500')); + $expected = " WHERE SUM(`Post`.`comments_count`) > '500'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('MAX(Post.rating) >' => '50')); + $expected = " WHERE MAX(`Post`.`rating`) > '50'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('title LIKE' => '%hello')); + $expected = " WHERE `title` LIKE '%hello'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('Post.name' => 'mad(g)ik')); + $expected = " WHERE `Post`.`name` = 'mad(g)ik'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('score' => array(1, 2, 10))); + $expected = " WHERE score IN (1, 2, 10)"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('score' => array())); + $expected = " WHERE `score` IS NULL"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('score !=' => array())); + $expected = " WHERE `score` IS NOT NULL"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('score !=' => '20')); + $expected = " WHERE `score` != '20'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('score >' => '20')); + $expected = " WHERE `score` > '20'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('client_id >' => '20'), true, true, new TestModel()); + $expected = " WHERE `client_id` > 20"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('OR' => array( + array('User.user' => 'mariano'), + array('User.user' => 'nate') + ))); + + $expected = " WHERE ((`User`.`user` = 'mariano') OR (`User`.`user` = 'nate'))"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('or' => array( + 'score BETWEEN ? AND ?' => array('4', '5'), 'rating >' => '20' + ))); + $expected = " WHERE ((`score` BETWEEN '4' AND '5') OR (`rating` > '20'))"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('or' => array( + 'score BETWEEN ? AND ?' => array('4', '5'), array('score >' => '20') + ))); + $expected = " WHERE ((`score` BETWEEN '4' AND '5') OR (`score` > '20'))"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('and' => array( + 'score BETWEEN ? AND ?' => array('4', '5'), array('score >' => '20') + ))); + $expected = " WHERE ((`score` BETWEEN '4' AND '5') AND (`score` > '20'))"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array( + 'published' => 1, 'or' => array('score >' => '2', array('score >' => '20')) + )); + $expected = " WHERE `published` = 1 AND ((`score` > '2') OR (`score` > '20'))"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array(array('Project.removed' => false))); + $expected = " WHERE `Project`.`removed` = '0'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array(array('Project.removed' => true))); + $expected = " WHERE `Project`.`removed` = '1'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array(array('Project.removed' => null))); + $expected = " WHERE `Project`.`removed` IS NULL"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array(array('Project.removed !=' => null))); + $expected = " WHERE `Project`.`removed` IS NOT NULL"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('(Usergroup.permissions) & 4' => 4)); + $expected = " WHERE (`Usergroup`.`permissions`) & 4 = 4"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('((Usergroup.permissions) & 4)' => 4)); + $expected = " WHERE ((`Usergroup`.`permissions`) & 4) = 4"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('Post.modified >=' => 'DATE_SUB(NOW(), INTERVAL 7 DAY)')); + $expected = " WHERE `Post`.`modified` >= 'DATE_SUB(NOW(), INTERVAL 7 DAY)'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('Post.modified >= DATE_SUB(NOW(), INTERVAL 7 DAY)')); + $expected = " WHERE `Post`.`modified` >= DATE_SUB(NOW(), INTERVAL 7 DAY)"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array( + 'NOT' => array('Course.id' => null, 'Course.vet' => 'N', 'level_of_education_id' => array(912,999)), + 'Enrollment.yearcompleted >' => '0') + ); + $this->assertPattern('/^\s*WHERE\s+\(NOT\s+\(`Course`\.`id` IS NULL\)\s+AND NOT\s+\(`Course`\.`vet`\s+=\s+\'N\'\)\s+AND NOT\s+\(level_of_education_id IN \(912, 999\)\)\)\s+AND\s+`Enrollment`\.`yearcompleted`\s+>\s+\'0\'\s*$/', $result); + + $result = $this->Dbo->conditions(array('id <>' => '8')); + $this->assertPattern('/^\s*WHERE\s+`id`\s+<>\s+\'8\'\s*$/', $result); + + $result = $this->Dbo->conditions(array('TestModel.field =' => 'gribe$@()lu')); + $expected = " WHERE `TestModel`.`field` = 'gribe$@()lu'"; + $this->assertEqual($result, $expected); + + $conditions['NOT'] = array('Listing.expiration BETWEEN ? AND ?' => array("1", "100")); + $conditions[0]['OR'] = array( + "Listing.title LIKE" => "%term%", + "Listing.description LIKE" => "%term%" + ); + $conditions[1]['OR'] = array( + "Listing.title LIKE" => "%term_2%", + "Listing.description LIKE" => "%term_2%" + ); + $result = $this->Dbo->conditions($conditions); + $expected = " WHERE NOT (`Listing`.`expiration` BETWEEN '1' AND '100') AND" . + " ((`Listing`.`title` LIKE '%term%') OR (`Listing`.`description` LIKE '%term%')) AND" . + " ((`Listing`.`title` LIKE '%term_2%') OR (`Listing`.`description` LIKE '%term_2%'))"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('MD5(CONCAT(Reg.email,Reg.id))' => 'blah')); + $expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) = 'blah'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array( + 'MD5(CONCAT(Reg.email,Reg.id))' => array('blah', 'blahblah') + )); + $expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) IN ('blah', 'blahblah')"; + $this->assertEqual($result, $expected); + + $conditions = array('id' => array(2, 5, 6, 9, 12, 45, 78, 43, 76)); + $result = $this->Dbo->conditions($conditions); + $expected = " WHERE id IN (2, 5, 6, 9, 12, 45, 78, 43, 76)"; + $this->assertEqual($result, $expected); + + $conditions = array('title' => 'user(s)'); + $result = $this->Dbo->conditions($conditions); + $expected = " WHERE `title` = 'user(s)'"; + $this->assertEqual($result, $expected); + + $conditions = array('title' => 'user(s) data'); + $result = $this->Dbo->conditions($conditions); + $expected = " WHERE `title` = 'user(s) data'"; + $this->assertEqual($result, $expected); + + $conditions = array('title' => 'user(s,arg) data'); + $result = $this->Dbo->conditions($conditions); + $expected = " WHERE `title` = 'user(s,arg) data'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array("Book.book_name" => 'Java(TM)')); + $expected = " WHERE `Book`.`book_name` = 'Java(TM)'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array("Book.book_name" => 'Java(TM) ')); + $expected = " WHERE `Book`.`book_name` = 'Java(TM) '"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array("Book.id" => 0)); + $expected = " WHERE `Book`.`id` = 0"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array("Book.id" => NULL)); + $expected = " WHERE `Book`.`id` IS NULL"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('Listing.beds >=' => 0)); + $expected = " WHERE `Listing`.`beds` >= 0"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array( + 'ASCII(SUBSTRING(keyword, 1, 1)) BETWEEN ? AND ?' => array(65, 90) + )); + $expected = ' WHERE ASCII(SUBSTRING(keyword, 1, 1)) BETWEEN 65 AND 90'; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('or' => array( + '? BETWEEN Model.field1 AND Model.field2' => '2009-03-04' + ))); + $expected = " WHERE '2009-03-04' BETWEEN Model.field1 AND Model.field2"; + $this->assertEqual($result, $expected); + } + +/** + * testArrayConditionsParsingComplexKeys method + * + * @access public + * @return void + */ + function testArrayConditionsParsingComplexKeys() { + $result = $this->Dbo->conditions(array( + 'CAST(Book.created AS DATE)' => '2008-08-02' + )); + $expected = " WHERE CAST(`Book`.`created` AS DATE) = '2008-08-02'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array( + 'CAST(Book.created AS DATE) <=' => '2008-08-02' + )); + $expected = " WHERE CAST(`Book`.`created` AS DATE) <= '2008-08-02'"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array( + '(Stats.clicks * 100) / Stats.views >' => 50 + )); + $expected = " WHERE (`Stats`.`clicks` * 100) / `Stats`.`views` > 50"; + $this->assertEqual($result, $expected); + } + +/** + * testMixedConditionsParsing method + * + * @access public + * @return void + */ + function testMixedConditionsParsing() { + $conditions[] = 'User.first_name = \'Firstname\''; + $conditions[] = array('User.last_name' => 'Lastname'); + $result = $this->Dbo->conditions($conditions); + $expected = " WHERE `User`.`first_name` = 'Firstname' AND `User`.`last_name` = 'Lastname'"; + $this->assertEqual($result, $expected); + + $conditions = array( + 'Thread.project_id' => 5, + 'Thread.buyer_id' => 14, + '1=1 GROUP BY Thread.project_id' + ); + $result = $this->Dbo->conditions($conditions); + $this->assertPattern('/^\s*WHERE\s+`Thread`.`project_id`\s*=\s*5\s+AND\s+`Thread`.`buyer_id`\s*=\s*14\s+AND\s+1\s*=\s*1\s+GROUP BY `Thread`.`project_id`$/', $result); + } + +/** + * testConditionsOptionalArguments method + * + * @access public + * @return void + */ + function testConditionsOptionalArguments() { + $result = $this->Dbo->conditions( array('Member.name' => 'Mariano'), true, false); + $this->assertPattern('/^\s*`Member`.`name`\s*=\s*\'Mariano\'\s*$/', $result); + + $result = $this->Dbo->conditions( array(), true, false); + $this->assertPattern('/^\s*1\s*=\s*1\s*$/', $result); + } + +/** + * testConditionsWithModel + * + * @access public + * @return void + */ + function testConditionsWithModel() { + $this->Model = new Article2(); + + $result = $this->Dbo->conditions(array('Article2.viewed >=' => 0), true, true, $this->Model); + $expected = " WHERE `Article2`.`viewed` >= 0"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('Article2.viewed >=' => '0'), true, true, $this->Model); + $expected = " WHERE `Article2`.`viewed` >= 0"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('Article2.viewed >=' => '1'), true, true, $this->Model); + $expected = " WHERE `Article2`.`viewed` >= 1"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array(0, 10)), true, true, $this->Model); + $expected = " WHERE `Article2`.`rate_sum` BETWEEN 0 AND 10"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array('0', '10')), true, true, $this->Model); + $expected = " WHERE `Article2`.`rate_sum` BETWEEN 0 AND 10"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array('1', '10')), true, true, $this->Model); + $expected = " WHERE `Article2`.`rate_sum` BETWEEN 1 AND 10"; + $this->assertEqual($result, $expected); + } + +/** + * testFieldParsing method + * + * @access public + * @return void + */ + function testFieldParsing() { + $this->Model = new TestModel(); + $result = $this->Dbo->fields($this->Model, 'Vendor', "Vendor.id, COUNT(Model.vendor_id) AS `Vendor`.`count`"); + $expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`'); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, 'Vendor', "`Vendor`.`id`, COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`"); + $expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`'); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, 'Post', "CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name, Node.created"); + $expected = array("CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", "`Node`.`created`"); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, null, 'round( (3.55441 * fooField), 3 ) AS test'); + $this->assertEqual($result, array('round( (3.55441 * fooField), 3 ) AS test')); + + $result = $this->Dbo->fields($this->Model, null, 'ROUND(`Rating`.`rate_total` / `Rating`.`rate_count`,2) AS rating'); + $this->assertEqual($result, array('ROUND(`Rating`.`rate_total` / `Rating`.`rate_count`,2) AS rating')); + + $result = $this->Dbo->fields($this->Model, null, 'ROUND(Rating.rate_total / Rating.rate_count,2) AS rating'); + $this->assertEqual($result, array('ROUND(Rating.rate_total / Rating.rate_count,2) AS rating')); + + $result = $this->Dbo->fields($this->Model, 'Post', "Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name"); + $expected = array("`Node`.`created`", "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name"); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, 'Post', "2.2,COUNT(*), SUM(Something.else) as sum, Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name,Post.title,Post.1,1.1"); + $expected = array( + '2.2', 'COUNT(*)', 'SUM(`Something`.`else`) as sum', '`Node`.`created`', + "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", '`Post`.`title`', '`Post`.`1`', '1.1' + ); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, null, "(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`"); + $expected = array("(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`"); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, 'Post'); + $expected = array( + '`Post`.`id`', '`Post`.`client_id`', '`Post`.`name`', '`Post`.`login`', + '`Post`.`passwd`', '`Post`.`addr_1`', '`Post`.`addr_2`', '`Post`.`zip_code`', + '`Post`.`city`', '`Post`.`country`', '`Post`.`phone`', '`Post`.`fax`', + '`Post`.`url`', '`Post`.`email`', '`Post`.`comments`', '`Post`.`last_login`', + '`Post`.`created`', '`Post`.`updated`' + ); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, 'Other'); + $expected = array( + '`Other`.`id`', '`Other`.`client_id`', '`Other`.`name`', '`Other`.`login`', + '`Other`.`passwd`', '`Other`.`addr_1`', '`Other`.`addr_2`', '`Other`.`zip_code`', + '`Other`.`city`', '`Other`.`country`', '`Other`.`phone`', '`Other`.`fax`', + '`Other`.`url`', '`Other`.`email`', '`Other`.`comments`', '`Other`.`last_login`', + '`Other`.`created`', '`Other`.`updated`' + ); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, null, array(), false); + $expected = array('id', 'client_id', 'name', 'login', 'passwd', 'addr_1', 'addr_2', 'zip_code', 'city', 'country', 'phone', 'fax', 'url', 'email', 'comments', 'last_login', 'created', 'updated'); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, null, 'COUNT(*)'); + $expected = array('COUNT(*)'); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, null, 'SUM(Thread.unread_buyer) AS ' . $this->Dbo->name('sum_unread_buyer')); + $expected = array('SUM(`Thread`.`unread_buyer`) AS `sum_unread_buyer`'); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, null, 'name, count(*)'); + $expected = array('`TestModel`.`name`', 'count(*)'); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, null, 'count(*), name'); + $expected = array('count(*)', '`TestModel`.`name`'); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields( + $this->Model, null, 'field1, field2, field3, count(*), name' + ); + $expected = array( + '`TestModel`.`field1`', '`TestModel`.`field2`', + '`TestModel`.`field3`', 'count(*)', '`TestModel`.`name`' + ); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, null, array('dayofyear(now())')); + $expected = array('dayofyear(now())'); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, null, array('MAX(Model.field) As Max')); + $expected = array('MAX(`Model`.`field`) As Max'); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, null, array('Model.field AS AnotherName')); + $expected = array('`Model`.`field` AS `AnotherName`'); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, null, array('field AS AnotherName')); + $expected = array('`field` AS `AnotherName`'); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, null, array( + 'TestModel.field AS AnotherName' + )); + $expected = array('`TestModel`.`field` AS `AnotherName`'); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fields($this->Model, 'Foo', array( + 'id', 'title', '(user_count + discussion_count + post_count) AS score' + )); + $expected = array( + '`Foo`.`id`', + '`Foo`.`title`', + '(user_count + discussion_count + post_count) AS score' + ); + $this->assertEqual($result, $expected); + } + +/** + * test that fields() will accept objects made from DboSource::expression + * + * @return void + */ + function testFieldsWithExpression() { + $this->Model = new TestModel; + $expression = $this->Dbo->expression("CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col"); + $result = $this->Dbo->fields($this->Model, null, array("id", $expression)); + $expected = array( + '`TestModel`.`id`', + "CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col" + ); + $this->assertEqual($result, $expected); + } } diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 4488c1e24..f095f2ad1 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -142,716 +142,6 @@ class DboSourceTest extends CakeTestCase { $result = $this->testDb->conditions(' ', '" " conditions failed %s'); $this->assertEqual($result, ' WHERE 1 = 1'); } -/** - * testStringConditionsParsing method - * - * @access public - * @return void - */ - function testStringConditionsParsing() { - $result = $this->testDb->conditions("ProjectBid.project_id = Project.id"); - $expected = " WHERE `ProjectBid`.`project_id` = `Project`.`id`"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions("Candy.name LIKE 'a' AND HardCandy.name LIKE 'c'"); - $expected = " WHERE `Candy`.`name` LIKE 'a' AND `HardCandy`.`name` LIKE 'c'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions("HardCandy.name LIKE 'a' AND Candy.name LIKE 'c'"); - $expected = " WHERE `HardCandy`.`name` LIKE 'a' AND `Candy`.`name` LIKE 'c'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions("Post.title = '1.1'"); - $expected = " WHERE `Post`.`title` = '1.1'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions("User.id != 0 AND User.user LIKE '%arr%'"); - $expected = " WHERE `User`.`id` != 0 AND `User`.`user` LIKE '%arr%'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions("SUM(Post.comments_count) > 500"); - $expected = " WHERE SUM(`Post`.`comments_count`) > 500"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions("(Post.created < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(Post.created), MONTH(Post.created)"); - $expected = " WHERE (`Post`.`created` < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(`Post`.`created`), MONTH(`Post`.`created`)"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions("score BETWEEN 90.1 AND 95.7"); - $expected = " WHERE score BETWEEN 90.1 AND 95.7"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('score' => array(2=>1, 2, 10))); - $expected = " WHERE score IN (1, 2, 10)"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions("Aro.rght = Aro.lft + 1.1"); - $expected = " WHERE `Aro`.`rght` = `Aro`.`lft` + 1.1"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions("(Post.created < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(Post.created), MONTH(Post.created)"); - $expected = " WHERE (`Post`.`created` < '" . date('Y-m-d H:i:s') . "') GROUP BY YEAR(`Post`.`created`), MONTH(`Post`.`created`)"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions('Sportstaette.sportstaette LIKE "%ru%" AND Sportstaette.sportstaettenart_id = 2'); - $expected = ' WHERE `Sportstaette`.`sportstaette` LIKE "%ru%" AND `Sportstaette`.`sportstaettenart_id` = 2'; - $this->assertPattern('/\s*WHERE\s+`Sportstaette`\.`sportstaette`\s+LIKE\s+"%ru%"\s+AND\s+`Sports/', $result); - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions('Sportstaette.sportstaettenart_id = 2 AND Sportstaette.sportstaette LIKE "%ru%"'); - $expected = ' WHERE `Sportstaette`.`sportstaettenart_id` = 2 AND `Sportstaette`.`sportstaette` LIKE "%ru%"'; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions('SUM(Post.comments_count) > 500 AND NOT Post.title IS NULL AND NOT Post.extended_title IS NULL'); - $expected = ' WHERE SUM(`Post`.`comments_count`) > 500 AND NOT `Post`.`title` IS NULL AND NOT `Post`.`extended_title` IS NULL'; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions('NOT Post.title IS NULL AND NOT Post.extended_title IS NULL AND SUM(Post.comments_count) > 500'); - $expected = ' WHERE NOT `Post`.`title` IS NULL AND NOT `Post`.`extended_title` IS NULL AND SUM(`Post`.`comments_count`) > 500'; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions('NOT Post.extended_title IS NULL AND NOT Post.title IS NULL AND Post.title != "" AND SPOON(SUM(Post.comments_count) + 1.1) > 500'); - $expected = ' WHERE NOT `Post`.`extended_title` IS NULL AND NOT `Post`.`title` IS NULL AND `Post`.`title` != "" AND SPOON(SUM(`Post`.`comments_count`) + 1.1) > 500'; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions('NOT Post.title_extended IS NULL AND NOT Post.title IS NULL AND Post.title_extended != Post.title'); - $expected = ' WHERE NOT `Post`.`title_extended` IS NULL AND NOT `Post`.`title` IS NULL AND `Post`.`title_extended` != `Post`.`title`'; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions("Comment.id = 'a'"); - $expected = " WHERE `Comment`.`id` = 'a'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions("lower(Article.title) LIKE 'a%'"); - $expected = " WHERE lower(`Article`.`title`) LIKE 'a%'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions('((MATCH(Video.title) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 2) + (MATCH(Video.description) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 0.4) + (MATCH(Video.tags) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 1.5))'); - $expected = ' WHERE ((MATCH(`Video`.`title`) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 2) + (MATCH(`Video`.`description`) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 0.4) + (MATCH(`Video`.`tags`) AGAINST(\'My Search*\' IN BOOLEAN MODE) * 1.5))'; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions('DATEDIFF(NOW(),Article.published) < 1 && Article.live=1'); - $expected = " WHERE DATEDIFF(NOW(),`Article`.`published`) < 1 && `Article`.`live`=1"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions('file = "index.html"'); - $expected = ' WHERE file = "index.html"'; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions("file = 'index.html'"); - $expected = " WHERE file = 'index.html'"; - $this->assertEqual($result, $expected); - - $letter = $letter = 'd.a'; - $conditions = array('Company.name like ' => $letter . '%'); - $result = $this->testDb->conditions($conditions); - $expected = " WHERE `Company`.`name` like 'd.a%'"; - $this->assertEqual($result, $expected); - - $conditions = array('Artist.name' => 'JUDY and MARY'); - $result = $this->testDb->conditions($conditions); - $expected = " WHERE `Artist`.`name` = 'JUDY and MARY'"; - $this->assertEqual($result, $expected); - - $conditions = array('Artist.name' => 'JUDY AND MARY'); - $result = $this->testDb->conditions($conditions); - $expected = " WHERE `Artist`.`name` = 'JUDY AND MARY'"; - $this->assertEqual($result, $expected); - } - -/** - * testQuotesInStringConditions method - * - * @access public - * @return void - */ - function testQuotesInStringConditions() { - $result = $this->testDb->conditions('Member.email = \'mariano@cricava.com\''); - $expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\''; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions('Member.email = "mariano@cricava.com"'); - $expected = ' WHERE `Member`.`email` = "mariano@cricava.com"'; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions('Member.email = \'mariano@cricava.com\' AND Member.user LIKE \'mariano.iglesias%\''); - $expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\' AND `Member`.`user` LIKE \'mariano.iglesias%\''; - $this->assertEqual($result, $expected); - - - $result = $this->testDb->conditions('Member.email = "mariano@cricava.com" AND Member.user LIKE "mariano.iglesias%"'); - $expected = ' WHERE `Member`.`email` = "mariano@cricava.com" AND `Member`.`user` LIKE "mariano.iglesias%"'; - $this->assertEqual($result, $expected); - } - -/** - * testParenthesisInStringConditions method - * - * @access public - * @return void - */ - function testParenthesisInStringConditions() { - $result = $this->testDb->conditions('Member.name = \'(lu\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(lu\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \')lu\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\)lu\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \'va(lu\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \'va)lu\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\)lu\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \'va(lu)\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\)\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \'va(lu)e\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\)e\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \'(mariano)\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\)\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \'(mariano)iglesias\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\)iglesias\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \'(mariano) iglesias\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\) iglesias\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \'(mariano word) iglesias\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano word\) iglesias\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \'(mariano.iglesias)\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano.iglesias\)\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \'Mariano Iglesias (mariano.iglesias)\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\)\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \'Mariano Iglesias (mariano.iglesias) CakePHP\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\) CakePHP\'$/', $result); - - $result = $this->testDb->conditions('Member.name = \'(mariano.iglesias) CakePHP\''); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano.iglesias\) CakePHP\'$/', $result); - } - -/** - * testParenthesisInArrayConditions method - * - * @access public - * @return void - */ - function testParenthesisInArrayConditions() { - $result = $this->testDb->conditions(array('Member.name' => '(lu')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(lu\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => ')lu')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\)lu\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => 'va(lu')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => 'va)lu')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\)lu\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => 'va(lu)')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\)\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => 'va(lu)e')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\)e\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => '(mariano)')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\)\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => '(mariano)iglesias')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\)iglesias\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => '(mariano) iglesias')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\) iglesias\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => '(mariano word) iglesias')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano word\) iglesias\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => '(mariano.iglesias)')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano.iglesias\)\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => 'Mariano Iglesias (mariano.iglesias)')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\)\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => 'Mariano Iglesias (mariano.iglesias) CakePHP')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\) CakePHP\'$/', $result); - - $result = $this->testDb->conditions(array('Member.name' => '(mariano.iglesias) CakePHP')); - $this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano.iglesias\) CakePHP\'$/', $result); - } - -/** - * testArrayConditionsParsing method - * - * @access public - * @return void - */ - function testArrayConditionsParsing() { - $this->loadFixtures('Post', 'Author'); - $result = $this->testDb->conditions(array('Stereo.type' => 'in dash speakers')); - $this->assertPattern("/^\s+WHERE\s+`Stereo`.`type`\s+=\s+'in dash speakers'/", $result); - - $result = $this->testDb->conditions(array('Candy.name LIKE' => 'a', 'HardCandy.name LIKE' => 'c')); - $this->assertPattern("/^\s+WHERE\s+`Candy`.`name` LIKE\s+'a'\s+AND\s+`HardCandy`.`name`\s+LIKE\s+'c'/", $result); - - $result = $this->testDb->conditions(array('HardCandy.name LIKE' => 'a', 'Candy.name LIKE' => 'c')); - $expected = " WHERE `HardCandy`.`name` LIKE 'a' AND `Candy`.`name` LIKE 'c'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('HardCandy.name LIKE' => 'a%', 'Candy.name LIKE' => '%c%')); - $expected = " WHERE `HardCandy`.`name` LIKE 'a%' AND `Candy`.`name` LIKE '%c%'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('HardCandy.name LIKE' => 'to be or%', 'Candy.name LIKE' => '%not to be%')); - $expected = " WHERE `HardCandy`.`name` LIKE 'to be or%' AND `Candy`.`name` LIKE '%not to be%'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('score BETWEEN ? AND ?' => array(90.1, 95.7))); - $expected = " WHERE `score` BETWEEN 90.100000 AND 95.700000"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('Post.title' => 1.1)); - $expected = " WHERE `Post`.`title` = 1.100000"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('Post.title' => 1.1), true, true, new Post()); - $expected = " WHERE `Post`.`title` = '1.1'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('SUM(Post.comments_count) >' => '500')); - $expected = " WHERE SUM(`Post`.`comments_count`) > '500'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('MAX(Post.rating) >' => '50')); - $expected = " WHERE MAX(`Post`.`rating`) > '50'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('title LIKE' => '%hello')); - $expected = " WHERE `title` LIKE '%hello'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('Post.name' => 'mad(g)ik')); - $expected = " WHERE `Post`.`name` = 'mad(g)ik'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('score' => array(1, 2, 10))); - $expected = " WHERE score IN (1, 2, 10)"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('score' => array())); - $expected = " WHERE `score` IS NULL"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('score !=' => array())); - $expected = " WHERE `score` IS NOT NULL"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('score !=' => '20')); - $expected = " WHERE `score` != '20'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('score >' => '20')); - $expected = " WHERE `score` > '20'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('client_id >' => '20'), true, true, new TestModel()); - $expected = " WHERE `client_id` > 20"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('OR' => array( - array('User.user' => 'mariano'), - array('User.user' => 'nate') - ))); - - $expected = " WHERE ((`User`.`user` = 'mariano') OR (`User`.`user` = 'nate'))"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('or' => array( - 'score BETWEEN ? AND ?' => array('4', '5'), 'rating >' => '20' - ))); - $expected = " WHERE ((`score` BETWEEN '4' AND '5') OR (`rating` > '20'))"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('or' => array( - 'score BETWEEN ? AND ?' => array('4', '5'), array('score >' => '20') - ))); - $expected = " WHERE ((`score` BETWEEN '4' AND '5') OR (`score` > '20'))"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('and' => array( - 'score BETWEEN ? AND ?' => array('4', '5'), array('score >' => '20') - ))); - $expected = " WHERE ((`score` BETWEEN '4' AND '5') AND (`score` > '20'))"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array( - 'published' => 1, 'or' => array('score >' => '2', array('score >' => '20')) - )); - $expected = " WHERE `published` = 1 AND ((`score` > '2') OR (`score` > '20'))"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array(array('Project.removed' => false))); - $expected = " WHERE `Project`.`removed` = 0"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array(array('Project.removed' => true))); - $expected = " WHERE `Project`.`removed` = 1"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array(array('Project.removed' => null))); - $expected = " WHERE `Project`.`removed` IS NULL"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array(array('Project.removed !=' => null))); - $expected = " WHERE `Project`.`removed` IS NOT NULL"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('(Usergroup.permissions) & 4' => 4)); - $expected = " WHERE (`Usergroup`.`permissions`) & 4 = 4"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('((Usergroup.permissions) & 4)' => 4)); - $expected = " WHERE ((`Usergroup`.`permissions`) & 4) = 4"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('Post.modified >=' => 'DATE_SUB(NOW(), INTERVAL 7 DAY)')); - $expected = " WHERE `Post`.`modified` >= 'DATE_SUB(NOW(), INTERVAL 7 DAY)'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('Post.modified >= DATE_SUB(NOW(), INTERVAL 7 DAY)')); - $expected = " WHERE `Post`.`modified` >= DATE_SUB(NOW(), INTERVAL 7 DAY)"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array( - 'NOT' => array('Course.id' => null, 'Course.vet' => 'N', 'level_of_education_id' => array(912,999)), - 'Enrollment.yearcompleted >' => '0') - ); - $this->assertPattern('/^\s*WHERE\s+\(NOT\s+\(`Course`\.`id` IS NULL\)\s+AND NOT\s+\(`Course`\.`vet`\s+=\s+\'N\'\)\s+AND NOT\s+\(level_of_education_id IN \(912, 999\)\)\)\s+AND\s+`Enrollment`\.`yearcompleted`\s+>\s+\'0\'\s*$/', $result); - - $result = $this->testDb->conditions(array('id <>' => '8')); - $this->assertPattern('/^\s*WHERE\s+`id`\s+<>\s+\'8\'\s*$/', $result); - - $result = $this->testDb->conditions(array('TestModel.field =' => 'gribe$@()lu')); - $expected = " WHERE `TestModel`.`field` = 'gribe$@()lu'"; - $this->assertEqual($result, $expected); - - $conditions['NOT'] = array('Listing.expiration BETWEEN ? AND ?' => array("1", "100")); - $conditions[0]['OR'] = array( - "Listing.title LIKE" => "%term%", - "Listing.description LIKE" => "%term%" - ); - $conditions[1]['OR'] = array( - "Listing.title LIKE" => "%term_2%", - "Listing.description LIKE" => "%term_2%" - ); - $result = $this->testDb->conditions($conditions); - $expected = " WHERE NOT (`Listing`.`expiration` BETWEEN '1' AND '100') AND" . - " ((`Listing`.`title` LIKE '%term%') OR (`Listing`.`description` LIKE '%term%')) AND" . - " ((`Listing`.`title` LIKE '%term_2%') OR (`Listing`.`description` LIKE '%term_2%'))"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('MD5(CONCAT(Reg.email,Reg.id))' => 'blah')); - $expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) = 'blah'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array( - 'MD5(CONCAT(Reg.email,Reg.id))' => array('blah', 'blahblah') - )); - $expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) IN ('blah', 'blahblah')"; - $this->assertEqual($result, $expected); - - $conditions = array('id' => array(2, 5, 6, 9, 12, 45, 78, 43, 76)); - $result = $this->testDb->conditions($conditions); - $expected = " WHERE id IN (2, 5, 6, 9, 12, 45, 78, 43, 76)"; - $this->assertEqual($result, $expected); - - $conditions = array('title' => 'user(s)'); - $result = $this->testDb->conditions($conditions); - $expected = " WHERE `title` = 'user(s)'"; - $this->assertEqual($result, $expected); - - $conditions = array('title' => 'user(s) data'); - $result = $this->testDb->conditions($conditions); - $expected = " WHERE `title` = 'user(s) data'"; - $this->assertEqual($result, $expected); - - $conditions = array('title' => 'user(s,arg) data'); - $result = $this->testDb->conditions($conditions); - $expected = " WHERE `title` = 'user(s,arg) data'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array("Book.book_name" => 'Java(TM)')); - $expected = " WHERE `Book`.`book_name` = 'Java(TM)'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array("Book.book_name" => 'Java(TM) ')); - $expected = " WHERE `Book`.`book_name` = 'Java(TM) '"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array("Book.id" => 0)); - $expected = " WHERE `Book`.`id` = 0"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array("Book.id" => NULL)); - $expected = " WHERE `Book`.`id` IS NULL"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('Listing.beds >=' => 0)); - $expected = " WHERE `Listing`.`beds` >= 0"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array( - 'ASCII(SUBSTRING(keyword, 1, 1)) BETWEEN ? AND ?' => array(65, 90) - )); - $expected = ' WHERE ASCII(SUBSTRING(keyword, 1, 1)) BETWEEN 65 AND 90'; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('or' => array( - '? BETWEEN Model.field1 AND Model.field2' => '2009-03-04' - ))); - $expected = " WHERE '2009-03-04' BETWEEN Model.field1 AND Model.field2"; - $this->assertEqual($result, $expected); - } - -/** - * testArrayConditionsParsingComplexKeys method - * - * @access public - * @return void - */ - function testArrayConditionsParsingComplexKeys() { - $result = $this->testDb->conditions(array( - 'CAST(Book.created AS DATE)' => '2008-08-02' - )); - $expected = " WHERE CAST(`Book`.`created` AS DATE) = '2008-08-02'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array( - 'CAST(Book.created AS DATE) <=' => '2008-08-02' - )); - $expected = " WHERE CAST(`Book`.`created` AS DATE) <= '2008-08-02'"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array( - '(Stats.clicks * 100) / Stats.views >' => 50 - )); - $expected = " WHERE (`Stats`.`clicks` * 100) / `Stats`.`views` > 50"; - $this->assertEqual($result, $expected); - } - -/** - * testMixedConditionsParsing method - * - * @access public - * @return void - */ - function testMixedConditionsParsing() { - $conditions[] = 'User.first_name = \'Firstname\''; - $conditions[] = array('User.last_name' => 'Lastname'); - $result = $this->testDb->conditions($conditions); - $expected = " WHERE `User`.`first_name` = 'Firstname' AND `User`.`last_name` = 'Lastname'"; - $this->assertEqual($result, $expected); - - $conditions = array( - 'Thread.project_id' => 5, - 'Thread.buyer_id' => 14, - '1=1 GROUP BY Thread.project_id' - ); - $result = $this->testDb->conditions($conditions); - $this->assertPattern('/^\s*WHERE\s+`Thread`.`project_id`\s*=\s*5\s+AND\s+`Thread`.`buyer_id`\s*=\s*14\s+AND\s+1\s*=\s*1\s+GROUP BY `Thread`.`project_id`$/', $result); - } - -/** - * testConditionsOptionalArguments method - * - * @access public - * @return void - */ - function testConditionsOptionalArguments() { - $result = $this->testDb->conditions( array('Member.name' => 'Mariano'), true, false); - $this->assertPattern('/^\s*`Member`.`name`\s*=\s*\'Mariano\'\s*$/', $result); - - $result = $this->testDb->conditions( array(), true, false); - $this->assertPattern('/^\s*1\s*=\s*1\s*$/', $result); - } - -/** - * testConditionsWithModel - * - * @access public - * @return void - */ - function testConditionsWithModel() { - $this->Model = new Article2(); - - $result = $this->testDb->conditions(array('Article2.viewed >=' => 0), true, true, $this->Model); - $expected = " WHERE `Article2`.`viewed` >= 0"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('Article2.viewed >=' => '0'), true, true, $this->Model); - $expected = " WHERE `Article2`.`viewed` >= 0"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('Article2.viewed >=' => '1'), true, true, $this->Model); - $expected = " WHERE `Article2`.`viewed` >= 1"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array(0, 10)), true, true, $this->Model); - $expected = " WHERE `Article2`.`rate_sum` BETWEEN 0 AND 10"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array('0', '10')), true, true, $this->Model); - $expected = " WHERE `Article2`.`rate_sum` BETWEEN 0 AND 10"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array('1', '10')), true, true, $this->Model); - $expected = " WHERE `Article2`.`rate_sum` BETWEEN 1 AND 10"; - $this->assertEqual($result, $expected); - } - -/** - * testFieldParsing method - * - * @access public - * @return void - */ - function testFieldParsing() { - $result = $this->testDb->fields($this->Model, 'Vendor', "Vendor.id, COUNT(Model.vendor_id) AS `Vendor`.`count`"); - $expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`'); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, 'Vendor', "`Vendor`.`id`, COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`"); - $expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`'); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, 'Post', "CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name, Node.created"); - $expected = array("CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", "`Node`.`created`"); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, null, 'round( (3.55441 * fooField), 3 ) AS test'); - $this->assertEqual($result, array('round( (3.55441 * fooField), 3 ) AS test')); - - $result = $this->testDb->fields($this->Model, null, 'ROUND(`Rating`.`rate_total` / `Rating`.`rate_count`,2) AS rating'); - $this->assertEqual($result, array('ROUND(`Rating`.`rate_total` / `Rating`.`rate_count`,2) AS rating')); - - $result = $this->testDb->fields($this->Model, null, 'ROUND(Rating.rate_total / Rating.rate_count,2) AS rating'); - $this->assertEqual($result, array('ROUND(Rating.rate_total / Rating.rate_count,2) AS rating')); - - $result = $this->testDb->fields($this->Model, 'Post', "Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name"); - $expected = array("`Node`.`created`", "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name"); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, 'Post', "2.2,COUNT(*), SUM(Something.else) as sum, Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name,Post.title,Post.1,1.1"); - $expected = array( - '2.2', 'COUNT(*)', 'SUM(`Something`.`else`) as sum', '`Node`.`created`', - "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", '`Post`.`title`', '`Post`.`1`', '1.1' - ); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, null, "(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`"); - $expected = array("(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`"); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, 'Post'); - $expected = array( - '`Post`.`id`', '`Post`.`client_id`', '`Post`.`name`', '`Post`.`login`', - '`Post`.`passwd`', '`Post`.`addr_1`', '`Post`.`addr_2`', '`Post`.`zip_code`', - '`Post`.`city`', '`Post`.`country`', '`Post`.`phone`', '`Post`.`fax`', - '`Post`.`url`', '`Post`.`email`', '`Post`.`comments`', '`Post`.`last_login`', - '`Post`.`created`', '`Post`.`updated`' - ); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, 'Other'); - $expected = array( - '`Other`.`id`', '`Other`.`client_id`', '`Other`.`name`', '`Other`.`login`', - '`Other`.`passwd`', '`Other`.`addr_1`', '`Other`.`addr_2`', '`Other`.`zip_code`', - '`Other`.`city`', '`Other`.`country`', '`Other`.`phone`', '`Other`.`fax`', - '`Other`.`url`', '`Other`.`email`', '`Other`.`comments`', '`Other`.`last_login`', - '`Other`.`created`', '`Other`.`updated`' - ); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, null, array(), false); - $expected = array('id', 'client_id', 'name', 'login', 'passwd', 'addr_1', 'addr_2', 'zip_code', 'city', 'country', 'phone', 'fax', 'url', 'email', 'comments', 'last_login', 'created', 'updated'); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, null, 'COUNT(*)'); - $expected = array('COUNT(*)'); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, null, 'SUM(Thread.unread_buyer) AS ' . $this->testDb->name('sum_unread_buyer')); - $expected = array('SUM(`Thread`.`unread_buyer`) AS `sum_unread_buyer`'); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, null, 'name, count(*)'); - $expected = array('`TestModel`.`name`', 'count(*)'); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, null, 'count(*), name'); - $expected = array('count(*)', '`TestModel`.`name`'); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields( - $this->Model, null, 'field1, field2, field3, count(*), name' - ); - $expected = array( - '`TestModel`.`field1`', '`TestModel`.`field2`', - '`TestModel`.`field3`', 'count(*)', '`TestModel`.`name`' - ); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, null, array('dayofyear(now())')); - $expected = array('dayofyear(now())'); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, null, array('MAX(Model.field) As Max')); - $expected = array('MAX(`Model`.`field`) As Max'); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, null, array('Model.field AS AnotherName')); - $expected = array('`Model`.`field` AS `AnotherName`'); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, null, array('field AS AnotherName')); - $expected = array('`field` AS `AnotherName`'); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, null, array( - 'TestModel.field AS AnotherName' - )); - $expected = array('`TestModel`.`field` AS `AnotherName`'); - $this->assertEqual($result, $expected); - - $result = $this->testDb->fields($this->Model, 'Foo', array( - 'id', 'title', '(user_count + discussion_count + post_count) AS score' - )); - $expected = array( - '`Foo`.`id`', - '`Foo`.`title`', - '(user_count + discussion_count + post_count) AS score' - ); - $this->assertEqual($result, $expected); - } - -/** - * test that fields() will accept objects made from DboSource::expression - * - * @return void - */ - function testFieldsWithExpression() { - $expression = $this->testDb->expression("CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col"); - $result = $this->testDb->fields($this->Model, null, array("id", $expression)); - $expected = array( - '`TestModel`.`id`', - "CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col" - ); - $this->assertEqual($result, $expected); - } /** * test that order() will accept objects made from DboSource::expression From 47c6132b245fdb5318b9af9d81e5dbeeec8e3e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 9 Nov 2010 01:25:05 -0430 Subject: [PATCH 086/378] cleaning up some tests, adding missing parameters in DboSource to match declaration on DataSource --- cake/libs/model/datasources/datasource.php | 4 ++-- cake/libs/model/datasources/dbo/dbo_mysql.php | 2 +- cake/libs/model/datasources/dbo_source.php | 4 ++-- .../model/datasources/dbo/dbo_mysql.test.php | 12 +++++------ .../datasources/dbo/dbo_postgres.test.php | 6 +++--- .../model/datasources/dbo_source.test.php | 20 +++++++++---------- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index 85c0b1f59..391e1bf65 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -263,7 +263,7 @@ class DataSource extends Object { * @param Model $model * @return array Array of Metadata for the $model */ - public function describe(&$model) { + public function describe($model) { if ($this->cacheSources === false) { return null; } @@ -556,7 +556,7 @@ class DataSource extends Object { * @param string $key Key name to make * @return string Key name for model. */ - public function resolveKey(&$model, $key) { + public function resolveKey($model, $key) { return $model->alias . $key; } diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 7e8eef21b..102e4890f 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -179,7 +179,7 @@ class DboMysql extends DboSource { * * @return array Array of tablenames in the database */ - function listSources() { + function listSources($data = null) { $cache = parent::listSources(); if ($cache != null) { return $cache; diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index afd42a5c0..e9f14e522 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -362,7 +362,7 @@ class DboSource extends DataSource { * * @return integer Number of affected rows */ - function lastAffected() { + function lastAffected($source = null) { if ($this->hasResult()) { return $this->_result->rowCount(); } @@ -375,7 +375,7 @@ class DboSource extends DataSource { * * @return integer Number of rows in resultset */ - function lastNumRows() { + function lastNumRows($source = null) { if ($this->hasResult()) { $i = 0; foreach ($this->_result as $row) { diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 835176bc8..e8b3a7d08 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -650,7 +650,7 @@ class DboMysqlTest extends CakeTestCase { 'field_two' => array('type' => 'string', 'null' => false, 'length' => 50), ) )); - $result = $this->db->alterSchema($schema2->compare($schema1)); + $result = $this->Dbo->alterSchema($schema2->compare($schema1)); $this->assertEqual(2, substr_count($result, 'field_two'), 'Too many fields'); } @@ -728,8 +728,8 @@ class DboMysqlTest extends CakeTestCase { 'other__field' => 'SUM(id)' ); - $this->db->virtualFieldSeparator = '_$_'; - $result = $this->db->fields($model, null, array('data', 'other__field')); + $this->Dbo->virtualFieldSeparator = '_$_'; + $result = $this->Dbo->fields($model, null, array('data', 'other__field')); $expected = array('`BinaryTest`.`data`', '(SUM(id)) AS `BinaryTest_$_other__field`'); $this->assertEqual($result, $expected); } @@ -759,10 +759,10 @@ class DboMysqlTest extends CakeTestCase { ) )); - $this->db->execute($this->db->createSchema($schema)); + $this->Dbo->execute($this->Dbo->createSchema($schema)); $model = new CakeTestModel(array('table' => 'testdescribes', 'name' => 'Testdescribes')); - $result = $this->db->describe($model); - $this->db->execute($this->db->dropSchema($schema)); + $result = $this->Dbo->describe($model); + $this->Dbo->execute($this->Dbo->dropSchema($schema)); $this->assertEqual($result['stringy']['collate'], 'cp1250_general_ci'); $this->assertEqual($result['stringy']['charset'], 'cp1250'); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 3cbd18f68..b44d50104 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -807,7 +807,7 @@ class DboPostgresTest extends CakeTestCase { */ function testUpdateAllWithNonQualifiedConditions() { $this->loadFixtures('Article'); - $Article =& new Article(); + $Article = new Article(); $result = $Article->updateAll(array('title' => "'Awesome'"), array('title' => 'Third Article')); $this->assertTrue($result); @@ -823,7 +823,7 @@ class DboPostgresTest extends CakeTestCase { * @return void */ function testAlteringTwoTables() { - $schema1 =& new CakeSchema(array( + $schema1 = new CakeSchema(array( 'name' => 'AlterTest1', 'connection' => 'test', 'altertest' => array( @@ -835,7 +835,7 @@ class DboPostgresTest extends CakeTestCase { 'name' => array('type' => 'string', 'null' => false, 'length' => 50), ) )); - $schema2 =& new CakeSchema(array( + $schema2 = new CakeSchema(array( 'name' => 'AlterTest1', 'connection' => 'test', 'altertest' => array( diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index f095f2ad1..93301e31f 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -992,36 +992,36 @@ class DboSourceTest extends CakeTestCase { // EMPTY STRING $result = $this->testDb->value('', 'boolean'); - $this->assertEqual($result, 0); + $this->assertEqual($result, "'0'"); // BOOLEAN $result = $this->testDb->value('true', 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); $result = $this->testDb->value('false', 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); $result = $this->testDb->value(true, 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); $result = $this->testDb->value(false, 'boolean'); - $this->assertEqual($result, 0); + $this->assertEqual($result, "'0'"); $result = $this->testDb->value(1, 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); $result = $this->testDb->value(0, 'boolean'); - $this->assertEqual($result, 0); + $this->assertEqual($result, "'0'"); $result = $this->testDb->value('abc', 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); $result = $this->testDb->value(1.234, 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); $result = $this->testDb->value('1.234e05', 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); // NUMBERS $result = $this->testDb->value(123, 'integer'); From 66779eecfa2bde86d192de0cb7af013b1e950647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 9 Nov 2010 01:26:15 -0430 Subject: [PATCH 087/378] Moving some more method out of DboSourceTest --- .../model/datasources/dbo/dbo_mysql.test.php | 388 ++++++++++++++++ .../model/datasources/dbo_source.test.php | 420 ------------------ 2 files changed, 388 insertions(+), 420 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index e8b3a7d08..02e59e118 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -2457,4 +2457,392 @@ class DboMysqlTest extends CakeTestCase { ); $this->assertEqual($result, $expected); } + +/** + * testRenderStatement method + * + * @access public + * @return void + */ + function testRenderStatement() { + $result = $this->Dbo->renderStatement('select', array( + 'fields' => 'id', 'table' => 'table', 'conditions' => 'WHERE 1=1', + 'alias' => '', 'joins' => '', 'order' => '', 'limit' => '', 'group' => '' + )); + $this->assertPattern('/^\s*SELECT\s+id\s+FROM\s+table\s+WHERE\s+1=1\s*$/', $result); + + $result = $this->Dbo->renderStatement('update', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => '')); + $this->assertPattern('/^\s*UPDATE\s+table\s+SET\s+value=2\s+WHERE\s+1=1\s*$/', $result); + + $result = $this->Dbo->renderStatement('update', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => 'alias', 'joins' => '')); + $this->assertPattern('/^\s*UPDATE\s+table\s+AS\s+alias\s+SET\s+value=2\s+WHERE\s+1=1\s*$/', $result); + + $result = $this->Dbo->renderStatement('delete', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => '')); + $this->assertPattern('/^\s*DELETE\s+FROM\s+table\s+WHERE\s+1=1\s*$/', $result); + + $result = $this->Dbo->renderStatement('delete', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => 'alias', 'joins' => '')); + $this->assertPattern('/^\s*DELETE\s+alias\s+FROM\s+table\s+AS\s+alias\s+WHERE\s+1=1\s*$/', $result); + } + +/** + * testSchema method + * + * @access public + * @return void + */ + function testSchema() { + $Schema = new CakeSchema(); + $Schema->tables = array('table' => array(), 'anotherTable' => array()); + + $this->expectError(); + $result = $this->Dbo->dropSchema(null); + $this->assertTrue($result === null); + + $result = $this->Dbo->dropSchema($Schema, 'non_existing'); + $this->assertTrue(empty($result)); + + $result = $this->Dbo->dropSchema($Schema, 'table'); + $this->assertPattern('/^\s*DROP TABLE IF EXISTS\s+' . $this->Dbo->fullTableName('table') . ';\s*$/s', $result); + } + +/** + * testOrderParsing method + * + * @access public + * @return void + */ + function testOrderParsing() { + $result = $this->Dbo->order("ADDTIME(Event.time_begin, '-06:00:00') ASC"); + $expected = " ORDER BY ADDTIME(`Event`.`time_begin`, '-06:00:00') ASC"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->order("title, id"); + $this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC,\s+`id`\s+ASC\s*$/', $result); + + $result = $this->Dbo->order("title desc, id desc"); + $this->assertPattern('/^\s*ORDER BY\s+`title`\s+desc,\s+`id`\s+desc\s*$/', $result); + + $result = $this->Dbo->order(array("title desc, id desc")); + $this->assertPattern('/^\s*ORDER BY\s+`title`\s+desc,\s+`id`\s+desc\s*$/', $result); + + $result = $this->Dbo->order(array("title", "id")); + $this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC,\s+`id`\s+ASC\s*$/', $result); + + $result = $this->Dbo->order(array(array('title'), array('id'))); + $this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC,\s+`id`\s+ASC\s*$/', $result); + + $result = $this->Dbo->order(array("Post.title" => 'asc', "Post.id" => 'desc')); + $this->assertPattern('/^\s*ORDER BY\s+`Post`.`title`\s+asc,\s+`Post`.`id`\s+desc\s*$/', $result); + + $result = $this->Dbo->order(array(array("Post.title" => 'asc', "Post.id" => 'desc'))); + $this->assertPattern('/^\s*ORDER BY\s+`Post`.`title`\s+asc,\s+`Post`.`id`\s+desc\s*$/', $result); + + $result = $this->Dbo->order(array("title")); + $this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC\s*$/', $result); + + $result = $this->Dbo->order(array(array("title"))); + $this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC\s*$/', $result); + + $result = $this->Dbo->order("Dealer.id = 7 desc, Dealer.id = 3 desc, Dealer.title asc"); + $expected = " ORDER BY `Dealer`.`id` = 7 desc, `Dealer`.`id` = 3 desc, `Dealer`.`title` asc"; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->order(array("Page.name" => "='test' DESC")); + $this->assertPattern("/^\s*ORDER BY\s+`Page`\.`name`\s*='test'\s+DESC\s*$/", $result); + + $result = $this->Dbo->order("Page.name = 'view' DESC"); + $this->assertPattern("/^\s*ORDER BY\s+`Page`\.`name`\s*=\s*'view'\s+DESC\s*$/", $result); + + $result = $this->Dbo->order("(Post.views)"); + $this->assertPattern("/^\s*ORDER BY\s+\(`Post`\.`views`\)\s+ASC\s*$/", $result); + + $result = $this->Dbo->order("(Post.views)*Post.views"); + $this->assertPattern("/^\s*ORDER BY\s+\(`Post`\.`views`\)\*`Post`\.`views`\s+ASC\s*$/", $result); + + $result = $this->Dbo->order("(Post.views) * Post.views"); + $this->assertPattern("/^\s*ORDER BY\s+\(`Post`\.`views`\) \* `Post`\.`views`\s+ASC\s*$/", $result); + + $result = $this->Dbo->order("(Model.field1 + Model.field2) * Model.field3"); + $this->assertPattern("/^\s*ORDER BY\s+\(`Model`\.`field1` \+ `Model`\.`field2`\) \* `Model`\.`field3`\s+ASC\s*$/", $result); + + $result = $this->Dbo->order("Model.name+0 ASC"); + $this->assertPattern("/^\s*ORDER BY\s+`Model`\.`name`\+0\s+ASC\s*$/", $result); + + $result = $this->Dbo->order("Anuncio.destaque & 2 DESC"); + $expected = ' ORDER BY `Anuncio`.`destaque` & 2 DESC'; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->order("3963.191 * id"); + $expected = ' ORDER BY 3963.191 * id ASC'; + $this->assertEqual($result, $expected); + + $result = $this->Dbo->order(array('Property.sale_price IS NULL')); + $expected = ' ORDER BY `Property`.`sale_price` IS NULL ASC'; + $this->assertEqual($result, $expected); + } + +/** + * testComplexSortExpression method + * + * @return void + */ + public function testComplexSortExpression() { + $result = $this->Dbo->order(array('(Model.field > 100) DESC', 'Model.field ASC')); + $this->assertPattern("/^\s*ORDER BY\s+\(`Model`\.`field`\s+>\s+100\)\s+DESC,\s+`Model`\.`field`\s+ASC\s*$/", $result); + } + +/** + * testCalculations method + * + * @access public + * @return void + */ + function testCalculations() { + $result = $this->Dbo->calculate($this->Model, 'count'); + $this->assertEqual($result, 'COUNT(*) AS `count`'); + + $result = $this->Dbo->calculate($this->Model, 'count', array('id')); + $this->assertEqual($result, 'COUNT(`id`) AS `count`'); + + $result = $this->Dbo->calculate( + $this->Model, + 'count', + array($this->Dbo->expression('DISTINCT id')) + ); + $this->assertEqual($result, 'COUNT(DISTINCT id) AS `count`'); + + $result = $this->Dbo->calculate($this->Model, 'count', array('id', 'id_count')); + $this->assertEqual($result, 'COUNT(`id`) AS `id_count`'); + + $result = $this->Dbo->calculate($this->Model, 'count', array('Model.id', 'id_count')); + $this->assertEqual($result, 'COUNT(`Model`.`id`) AS `id_count`'); + + $result = $this->Dbo->calculate($this->Model, 'max', array('id')); + $this->assertEqual($result, 'MAX(`id`) AS `id`'); + + $result = $this->Dbo->calculate($this->Model, 'max', array('Model.id', 'id')); + $this->assertEqual($result, 'MAX(`Model`.`id`) AS `id`'); + + $result = $this->Dbo->calculate($this->Model, 'max', array('`Model`.`id`', 'id')); + $this->assertEqual($result, 'MAX(`Model`.`id`) AS `id`'); + + $result = $this->Dbo->calculate($this->Model, 'min', array('`Model`.`id`', 'id')); + $this->assertEqual($result, 'MIN(`Model`.`id`) AS `id`'); + + $result = $this->Dbo->calculate($this->Model, 'min', 'left'); + $this->assertEqual($result, 'MIN(`left`) AS `left`'); + } + +/** + * testLength method + * + * @access public + * @return void + */ + function testLength() { + $result = $this->Dbo->length('varchar(255)'); + $expected = 255; + $this->assertIdentical($result, $expected); + + $result = $this->Dbo->length('int(11)'); + $expected = 11; + $this->assertIdentical($result, $expected); + + $result = $this->Dbo->length('float(5,3)'); + $expected = '5,3'; + $this->assertIdentical($result, $expected); + + $result = $this->Dbo->length('decimal(5,2)'); + $expected = '5,2'; + $this->assertIdentical($result, $expected); + + $result = $this->Dbo->length("enum('test','me','now')"); + $expected = 4; + $this->assertIdentical($result, $expected); + + $result = $this->Dbo->length("set('a','b','cd')"); + $expected = 2; + $this->assertIdentical($result, $expected); + + $this->expectError(); + $result = $this->Dbo->length(false); + $this->assertTrue($result === null); + + $result = $this->Dbo->length('datetime'); + $expected = null; + $this->assertIdentical($result, $expected); + + $result = $this->Dbo->length('text'); + $expected = null; + $this->assertIdentical($result, $expected); + } + +/** + * testBuildIndex method + * + * @access public + * @return void + */ + function testBuildIndex() { + $data = array( + 'PRIMARY' => array('column' => 'id') + ); + $result = $this->Dbo->buildIndex($data); + $expected = array('PRIMARY KEY (`id`)'); + $this->assertIdentical($result, $expected); + + $data = array( + 'MyIndex' => array('column' => 'id', 'unique' => true) + ); + $result = $this->Dbo->buildIndex($data); + $expected = array('UNIQUE KEY `MyIndex` (`id`)'); + $this->assertEqual($result, $expected); + + $data = array( + 'MyIndex' => array('column' => array('id', 'name'), 'unique' => true) + ); + $result = $this->Dbo->buildIndex($data); + $expected = array('UNIQUE KEY `MyIndex` (`id`, `name`)'); + $this->assertEqual($result, $expected); + } + +/** + * testBuildColumn method + * + * @access public + * @return void + */ + function testBuildColumn2() { + $this->expectError(); + $data = array( + 'name' => 'testName', + 'type' => 'varchar(255)', + 'default', + 'null' => true, + 'key' + ); + $this->Dbo->buildColumn($data); + + $data = array( + 'name' => 'testName', + 'type' => 'string', + 'length' => 255, + 'default', + 'null' => true, + 'key' + ); + $result = $this->Dbo->buildColumn($data); + $expected = '`testName` varchar(255) DEFAULT NULL'; + $this->assertEqual($result, $expected); + + $data = array( + 'name' => 'int_field', + 'type' => 'integer', + 'default' => '', + 'null' => false, + ); + $restore = $this->Dbo->columns; + + $this->Dbo->columns = array('integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'), ); + $result = $this->Dbo->buildColumn($data); + $expected = '`int_field` int(11) NOT NULL'; + $this->assertEqual($result, $expected); + + $this->Dbo->fieldParameters['param'] = array( + 'value' => 'COLLATE', + 'quote' => false, + 'join' => ' ', + 'column' => 'Collate', + 'position' => 'beforeDefault', + 'options' => array('GOOD', 'OK') + ); + $data = array( + 'name' => 'int_field', + 'type' => 'integer', + 'default' => '', + 'null' => false, + 'param' => 'BAD' + ); + $result = $this->Dbo->buildColumn($data); + $expected = '`int_field` int(11) NOT NULL'; + $this->assertEqual($result, $expected); + + $data = array( + 'name' => 'int_field', + 'type' => 'integer', + 'default' => '', + 'null' => false, + 'param' => 'GOOD' + ); + $result = $this->Dbo->buildColumn($data); + $expected = '`int_field` int(11) COLLATE GOOD NOT NULL'; + $this->assertEqual($result, $expected); + + $this->Dbo->columns = $restore; + + $data = array( + 'name' => 'created', + 'type' => 'timestamp', + 'default' => 'current_timestamp', + 'null' => false, + ); + $result = $this->Dbo->buildColumn($data); + $expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL'; + $this->assertEqual($result, $expected); + + $data = array( + 'name' => 'created', + 'type' => 'timestamp', + 'default' => 'CURRENT_TIMESTAMP', + 'null' => true, + ); + $result = $this->Dbo->buildColumn($data); + $expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP'; + $this->assertEqual($result, $expected); + + $data = array( + 'name' => 'modified', + 'type' => 'timestamp', + 'null' => true, + ); + $result = $this->Dbo->buildColumn($data); + $expected = '`modified` timestamp NULL'; + $this->assertEqual($result, $expected); + + $data = array( + 'name' => 'modified', + 'type' => 'timestamp', + 'default' => null, + 'null' => true, + ); + $result = $this->Dbo->buildColumn($data); + $expected = '`modified` timestamp NULL'; + $this->assertEqual($result, $expected); + } + +/** + * test hasAny() + * + * @return void + */ + function testHasAny() { + $this->Dbo = $this->getMock('DboMysql', array('connect', '_execute', 'execute', 'value')); + $this->Model = $this->getMock('TestModel', array('getDataSource')); + $this->Model->expects($this->any()) + ->method('getDataSource') + ->will($this->returnValue($this->Dbo)); + + $this->Dbo->expects($this->at(0))->method('value') + ->with('harry') + ->will($this->returnValue("'harry'")); + + $this->Dbo->expects($this->at(1))->method('execute') + ->with('SELECT COUNT(`TestModel`.`id`) AS count FROM `test_models` AS `TestModel` WHERE `TestModel`.`name` = \'harry\''); + $this->Dbo->expects($this->at(2))->method('execute') + ->with('SELECT COUNT(`TestModel`.`id`) AS count FROM `test_models` AS `TestModel` WHERE 1 = 1'); + + $this->Dbo->hasAny($this->Model, array('TestModel.name' => 'harry')); + $this->Dbo->hasAny($this->Model, array()); + + } } diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 93301e31f..016487177 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -429,96 +429,6 @@ class DboSourceTest extends CakeTestCase { $this->assertEqual($data, $expected); } -/** - * testRenderStatement method - * - * @access public - * @return void - */ - function testRenderStatement() { - $result = $this->testDb->renderStatement('select', array( - 'fields' => 'id', 'table' => 'table', 'conditions' => 'WHERE 1=1', - 'alias' => '', 'joins' => '', 'order' => '', 'limit' => '', 'group' => '' - )); - $this->assertPattern('/^\s*SELECT\s+id\s+FROM\s+table\s+WHERE\s+1=1\s*$/', $result); - - $result = $this->testDb->renderStatement('update', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => '')); - $this->assertPattern('/^\s*UPDATE\s+table\s+SET\s+value=2\s+WHERE\s+1=1\s*$/', $result); - - $result = $this->testDb->renderStatement('update', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => 'alias', 'joins' => '')); - $this->assertPattern('/^\s*UPDATE\s+table\s+AS\s+alias\s+SET\s+value=2\s+WHERE\s+1=1\s*$/', $result); - - $result = $this->testDb->renderStatement('delete', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => '')); - $this->assertPattern('/^\s*DELETE\s+FROM\s+table\s+WHERE\s+1=1\s*$/', $result); - - $result = $this->testDb->renderStatement('delete', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => 'alias', 'joins' => '')); - $this->assertPattern('/^\s*DELETE\s+alias\s+FROM\s+table\s+AS\s+alias\s+WHERE\s+1=1\s*$/', $result); - } - -/** - * testStatements method - * - * @access public - * @return void - */ - function testStatements() { - $this->loadFixtures('Article', 'User', 'Comment', 'Tag', 'Attachment', 'ArticlesTag'); - $Article = new Article(); - - $result = $this->testDb->update($Article, array('field1'), array('value1')); - $this->assertFalse($result); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/^\s*UPDATE\s+' . $this->testDb->fullTableName('articles') . '\s+SET\s+`field1`\s*=\s*\'value1\'\s+WHERE\s+1 = 1\s*$/', $result); - - $result = $this->testDb->update($Article, array('field1'), array('2'), '2=2'); - $this->assertFalse($result); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/^\s*UPDATE\s+' . $this->testDb->fullTableName('articles') . ' AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+SET\s+`Article`\.`field1`\s*=\s*2\s+WHERE\s+2\s*=\s*2\s*$/', $result); - - $result = $this->testDb->delete($Article); - $this->assertTrue($result); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/^\s*DELETE\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+WHERE\s+1 = 1\s*$/', $result); - - $result = $this->testDb->delete($Article, true); - $this->assertTrue($result); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+1\s*=\s*1\s*$/', $result); - - $result = $this->testDb->delete($Article, '2=2'); - $this->assertTrue($result); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+2\s*=\s*2\s*$/', $result); - - $result = $this->testDb->hasAny($Article, '1=2'); - $this->assertFalse($result); - - $result = $this->testDb->insertMulti('articles', array('field'), array('(1)', '(2)')); - $this->assertNull($result); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/^\s*INSERT INTO\s+' . $this->testDb->fullTableName('articles') . '\s+\(`field`\)\s+VALUES\s+\(1\),\s*\(2\)\s*$/', $result); - } - -/** - * testSchema method - * - * @access public - * @return void - */ - function testSchema() { - $Schema = new CakeSchema(); - $Schema->tables = array('table' => array(), 'anotherTable' => array()); - - $this->expectError(); - $result = $this->testDb->dropSchema(null); - $this->assertTrue($result === null); - - $result = $this->testDb->dropSchema($Schema, 'non_existing'); - $this->assertTrue(empty($result)); - - $result = $this->testDb->dropSchema($Schema, 'table'); - $this->assertPattern('/^\s*DROP TABLE IF EXISTS\s+' . $this->testDb->fullTableName('table') . ';\s*$/s', $result); - } /** * testMagicMethodQuerying method @@ -592,336 +502,6 @@ class DboSourceTest extends CakeTestCase { $this->assertFalse($result); } -/** - * testOrderParsing method - * - * @access public - * @return void - */ - function testOrderParsing() { - $result = $this->testDb->order("ADDTIME(Event.time_begin, '-06:00:00') ASC"); - $expected = " ORDER BY ADDTIME(`Event`.`time_begin`, '-06:00:00') ASC"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->order("title, id"); - $this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC,\s+`id`\s+ASC\s*$/', $result); - - $result = $this->testDb->order("title desc, id desc"); - $this->assertPattern('/^\s*ORDER BY\s+`title`\s+desc,\s+`id`\s+desc\s*$/', $result); - - $result = $this->testDb->order(array("title desc, id desc")); - $this->assertPattern('/^\s*ORDER BY\s+`title`\s+desc,\s+`id`\s+desc\s*$/', $result); - - $result = $this->testDb->order(array("title", "id")); - $this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC,\s+`id`\s+ASC\s*$/', $result); - - $result = $this->testDb->order(array(array('title'), array('id'))); - $this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC,\s+`id`\s+ASC\s*$/', $result); - - $result = $this->testDb->order(array("Post.title" => 'asc', "Post.id" => 'desc')); - $this->assertPattern('/^\s*ORDER BY\s+`Post`.`title`\s+asc,\s+`Post`.`id`\s+desc\s*$/', $result); - - $result = $this->testDb->order(array(array("Post.title" => 'asc', "Post.id" => 'desc'))); - $this->assertPattern('/^\s*ORDER BY\s+`Post`.`title`\s+asc,\s+`Post`.`id`\s+desc\s*$/', $result); - - $result = $this->testDb->order(array("title")); - $this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC\s*$/', $result); - - $result = $this->testDb->order(array(array("title"))); - $this->assertPattern('/^\s*ORDER BY\s+`title`\s+ASC\s*$/', $result); - - $result = $this->testDb->order("Dealer.id = 7 desc, Dealer.id = 3 desc, Dealer.title asc"); - $expected = " ORDER BY `Dealer`.`id` = 7 desc, `Dealer`.`id` = 3 desc, `Dealer`.`title` asc"; - $this->assertEqual($result, $expected); - - $result = $this->testDb->order(array("Page.name" => "='test' DESC")); - $this->assertPattern("/^\s*ORDER BY\s+`Page`\.`name`\s*='test'\s+DESC\s*$/", $result); - - $result = $this->testDb->order("Page.name = 'view' DESC"); - $this->assertPattern("/^\s*ORDER BY\s+`Page`\.`name`\s*=\s*'view'\s+DESC\s*$/", $result); - - $result = $this->testDb->order("(Post.views)"); - $this->assertPattern("/^\s*ORDER BY\s+\(`Post`\.`views`\)\s+ASC\s*$/", $result); - - $result = $this->testDb->order("(Post.views)*Post.views"); - $this->assertPattern("/^\s*ORDER BY\s+\(`Post`\.`views`\)\*`Post`\.`views`\s+ASC\s*$/", $result); - - $result = $this->testDb->order("(Post.views) * Post.views"); - $this->assertPattern("/^\s*ORDER BY\s+\(`Post`\.`views`\) \* `Post`\.`views`\s+ASC\s*$/", $result); - - $result = $this->testDb->order("(Model.field1 + Model.field2) * Model.field3"); - $this->assertPattern("/^\s*ORDER BY\s+\(`Model`\.`field1` \+ `Model`\.`field2`\) \* `Model`\.`field3`\s+ASC\s*$/", $result); - - $result = $this->testDb->order("Model.name+0 ASC"); - $this->assertPattern("/^\s*ORDER BY\s+`Model`\.`name`\+0\s+ASC\s*$/", $result); - - $result = $this->testDb->order("Anuncio.destaque & 2 DESC"); - $expected = ' ORDER BY `Anuncio`.`destaque` & 2 DESC'; - $this->assertEqual($result, $expected); - - $result = $this->testDb->order("3963.191 * id"); - $expected = ' ORDER BY 3963.191 * id ASC'; - $this->assertEqual($result, $expected); - - $result = $this->testDb->order(array('Property.sale_price IS NULL')); - $expected = ' ORDER BY `Property`.`sale_price` IS NULL ASC'; - $this->assertEqual($result, $expected); - } - -/** - * testComplexSortExpression method - * - * @return void - */ - public function testComplexSortExpression() { - $result = $this->testDb->order(array('(Model.field > 100) DESC', 'Model.field ASC')); - $this->assertPattern("/^\s*ORDER BY\s+\(`Model`\.`field`\s+>\s+100\)\s+DESC,\s+`Model`\.`field`\s+ASC\s*$/", $result); - } - -/** - * testCalculations method - * - * @access public - * @return void - */ - function testCalculations() { - $result = $this->testDb->calculate($this->Model, 'count'); - $this->assertEqual($result, 'COUNT(*) AS `count`'); - - $result = $this->testDb->calculate($this->Model, 'count', array('id')); - $this->assertEqual($result, 'COUNT(`id`) AS `count`'); - - $result = $this->testDb->calculate( - $this->Model, - 'count', - array($this->testDb->expression('DISTINCT id')) - ); - $this->assertEqual($result, 'COUNT(DISTINCT id) AS `count`'); - - $result = $this->testDb->calculate($this->Model, 'count', array('id', 'id_count')); - $this->assertEqual($result, 'COUNT(`id`) AS `id_count`'); - - $result = $this->testDb->calculate($this->Model, 'count', array('Model.id', 'id_count')); - $this->assertEqual($result, 'COUNT(`Model`.`id`) AS `id_count`'); - - $result = $this->testDb->calculate($this->Model, 'max', array('id')); - $this->assertEqual($result, 'MAX(`id`) AS `id`'); - - $result = $this->testDb->calculate($this->Model, 'max', array('Model.id', 'id')); - $this->assertEqual($result, 'MAX(`Model`.`id`) AS `id`'); - - $result = $this->testDb->calculate($this->Model, 'max', array('`Model`.`id`', 'id')); - $this->assertEqual($result, 'MAX(`Model`.`id`) AS `id`'); - - $result = $this->testDb->calculate($this->Model, 'min', array('`Model`.`id`', 'id')); - $this->assertEqual($result, 'MIN(`Model`.`id`) AS `id`'); - - $result = $this->testDb->calculate($this->Model, 'min', 'left'); - $this->assertEqual($result, 'MIN(`left`) AS `left`'); - } - -/** - * testLength method - * - * @access public - * @return void - */ - function testLength() { - $result = $this->testDb->length('varchar(255)'); - $expected = 255; - $this->assertIdentical($result, $expected); - - $result = $this->testDb->length('int(11)'); - $expected = 11; - $this->assertIdentical($result, $expected); - - $result = $this->testDb->length('float(5,3)'); - $expected = '5,3'; - $this->assertIdentical($result, $expected); - - $result = $this->testDb->length('decimal(5,2)'); - $expected = '5,2'; - $this->assertIdentical($result, $expected); - - $result = $this->testDb->length("enum('test','me','now')"); - $expected = 4; - $this->assertIdentical($result, $expected); - - $result = $this->testDb->length("set('a','b','cd')"); - $expected = 2; - $this->assertIdentical($result, $expected); - - $this->expectError(); - $result = $this->testDb->length(false); - $this->assertTrue($result === null); - - $result = $this->testDb->length('datetime'); - $expected = null; - $this->assertIdentical($result, $expected); - - $result = $this->testDb->length('text'); - $expected = null; - $this->assertIdentical($result, $expected); - } - -/** - * testBuildIndex method - * - * @access public - * @return void - */ - function testBuildIndex() { - $data = array( - 'PRIMARY' => array('column' => 'id') - ); - $result = $this->testDb->buildIndex($data); - $expected = array('PRIMARY KEY (`id`)'); - $this->assertIdentical($result, $expected); - - $data = array( - 'MyIndex' => array('column' => 'id', 'unique' => true) - ); - $result = $this->testDb->buildIndex($data); - $expected = array('UNIQUE KEY `MyIndex` (`id`)'); - $this->assertEqual($result, $expected); - - $data = array( - 'MyIndex' => array('column' => array('id', 'name'), 'unique' => true) - ); - $result = $this->testDb->buildIndex($data); - $expected = array('UNIQUE KEY `MyIndex` (`id`, `name`)'); - $this->assertEqual($result, $expected); - } - -/** - * testBuildColumn method - * - * @access public - * @return void - */ - function testBuildColumn() { - $this->expectError(); - $data = array( - 'name' => 'testName', - 'type' => 'varchar(255)', - 'default', - 'null' => true, - 'key' - ); - $this->testDb->buildColumn($data); - - $data = array( - 'name' => 'testName', - 'type' => 'string', - 'length' => 255, - 'default', - 'null' => true, - 'key' - ); - $result = $this->testDb->buildColumn($data); - $expected = '`testName` varchar(255) DEFAULT NULL'; - $this->assertEqual($result, $expected); - - $data = array( - 'name' => 'int_field', - 'type' => 'integer', - 'default' => '', - 'null' => false, - ); - $restore = $this->testDb->columns; - - $this->testDb->columns = array('integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'), ); - $result = $this->testDb->buildColumn($data); - $expected = '`int_field` int(11) NOT NULL'; - $this->assertEqual($result, $expected); - - $this->testDb->fieldParameters['param'] = array( - 'value' => 'COLLATE', - 'quote' => false, - 'join' => ' ', - 'column' => 'Collate', - 'position' => 'beforeDefault', - 'options' => array('GOOD', 'OK') - ); - $data = array( - 'name' => 'int_field', - 'type' => 'integer', - 'default' => '', - 'null' => false, - 'param' => 'BAD' - ); - $result = $this->testDb->buildColumn($data); - $expected = '`int_field` int(11) NOT NULL'; - $this->assertEqual($result, $expected); - - $data = array( - 'name' => 'int_field', - 'type' => 'integer', - 'default' => '', - 'null' => false, - 'param' => 'GOOD' - ); - $result = $this->testDb->buildColumn($data); - $expected = '`int_field` int(11) COLLATE GOOD NOT NULL'; - $this->assertEqual($result, $expected); - - $this->testDb->columns = $restore; - - $data = array( - 'name' => 'created', - 'type' => 'timestamp', - 'default' => 'current_timestamp', - 'null' => false, - ); - $result = $this->db->buildColumn($data); - $expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL'; - $this->assertEqual($result, $expected); - - $data = array( - 'name' => 'created', - 'type' => 'timestamp', - 'default' => 'CURRENT_TIMESTAMP', - 'null' => true, - ); - $result = $this->db->buildColumn($data); - $expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP'; - $this->assertEqual($result, $expected); - - $data = array( - 'name' => 'modified', - 'type' => 'timestamp', - 'null' => true, - ); - $result = $this->db->buildColumn($data); - $expected = '`modified` timestamp NULL'; - $this->assertEqual($result, $expected); - - $data = array( - 'name' => 'modified', - 'type' => 'timestamp', - 'default' => null, - 'null' => true, - ); - $result = $this->db->buildColumn($data); - $expected = '`modified` timestamp NULL'; - $this->assertEqual($result, $expected); - } - -/** - * test hasAny() - * - * @return void - */ - function testHasAny() { - $this->testDb->hasAny($this->Model, array()); - $expected = 'SELECT COUNT(`TestModel`.`id`) AS count FROM `test_models` AS `TestModel` WHERE 1 = 1'; - $this->assertEqual(end($this->testDb->simulated), $expected); - - $this->testDb->hasAny($this->Model, array('TestModel.name' => 'harry')); - $expected = "SELECT COUNT(`TestModel`.`id`) AS count FROM `test_models` AS `TestModel` WHERE `TestModel`.`name` = 'harry'"; - $this->assertEqual(end($this->testDb->simulated), $expected); - } - /** * testIntrospectType method * From 539b90749a9d40f5a81dde8d189c5112234b7cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 9 Nov 2010 01:38:13 -0430 Subject: [PATCH 088/378] Moving more methods out of DboSourceTest --- .../model/datasources/dbo/dbo_mysql.test.php | 176 +++++++++++++++++- .../model/datasources/dbo_source.test.php | 127 ------------- 2 files changed, 175 insertions(+), 128 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 02e59e118..da2f2a721 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -2845,4 +2845,178 @@ class DboMysqlTest extends CakeTestCase { $this->Dbo->hasAny($this->Model, array()); } -} + + +/** + * testStatements method + * + * @access public + * @return void + */ + function testStatements() { + $this->skipIf(true, 'Fix me'); + $this->loadFixtures('Article', 'User', 'Comment', 'Tag', 'Attachment', 'ArticlesTag'); + $Article = new Article(); + //$this->testDb = $this->getMock('DboMysql', array('connect', 'execute', '_execute')); + + $result = $this->testDb->update($Article, array('field1'), array('value1')); + $this->assertFalse($result); + $result = $this->testDb->getLastQuery(); + $this->assertPattern('/^\s*UPDATE\s+' . $this->testDb->fullTableName('articles') . '\s+SET\s+`field1`\s*=\s*\'value1\'\s+WHERE\s+1 = 1\s*$/', $result); + + $result = $this->testDb->update($Article, array('field1'), array('2'), '2=2'); + $this->assertFalse($result); + $result = $this->testDb->getLastQuery(); + $this->assertPattern('/^\s*UPDATE\s+' . $this->testDb->fullTableName('articles') . ' AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+SET\s+`Article`\.`field1`\s*=\s*2\s+WHERE\s+2\s*=\s*2\s*$/', $result); + + $result = $this->testDb->delete($Article); + $this->assertTrue($result); + $result = $this->testDb->getLastQuery(); + $this->assertPattern('/^\s*DELETE\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+WHERE\s+1 = 1\s*$/', $result); + + $result = $this->testDb->delete($Article, true); + $this->assertTrue($result); + $result = $this->testDb->getLastQuery(); + $this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+1\s*=\s*1\s*$/', $result); + + $result = $this->testDb->delete($Article, '2=2'); + $this->assertTrue($result); + $result = $this->testDb->getLastQuery(); + $this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+2\s*=\s*2\s*$/', $result); + + $result = $this->testDb->hasAny($Article, '1=2'); + $this->assertFalse($result); + + $result = $this->testDb->insertMulti('articles', array('field'), array('(1)', '(2)')); + $this->assertNull($result); + $result = $this->testDb->getLastQuery(); + $this->assertPattern('/^\s*INSERT INTO\s+' . $this->testDb->fullTableName('articles') . '\s+\(`field`\)\s+VALUES\s+\(1\),\s*\(2\)\s*$/', $result); + } + +/** + * test fields generating usable virtual fields to use in query + * + * @return void + */ + function testVirtualFields() { + $this->loadFixtures('Article', 'Comment'); + $this->Dbo->virtualFieldSeparator = '__'; + $Article = ClassRegistry::init('Article'); + $Article->virtualFields = array( + 'this_moment' => 'NOW()', + 'two' => '1 + 1', + 'comment_count' => 'SELECT COUNT(*) FROM ' . $this->Dbo->fullTableName('comments') . + ' WHERE Article.id = ' . $this->Dbo->fullTableName('comments') . '.article_id' + ); + $result = $this->Dbo->fields($Article); + $expected = array( + '`Article`.`id`', + '`Article`.`user_id`', + '`Article`.`title`', + '`Article`.`body`', + '`Article`.`published`', + '`Article`.`created`', + '`Article`.`updated`', + '(NOW()) AS `Article__this_moment`', + '(1 + 1) AS `Article__two`', + '(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `Article__comment_count`' + ); + $this->assertEqual($expected, $result); + + $result = $this->Dbo->fields($Article, null, array('this_moment', 'title')); + $expected = array( + '`Article`.`title`', + '(NOW()) AS `Article__this_moment`', + ); + $this->assertEqual($expected, $result); + + $result = $this->Dbo->fields($Article, null, array('Article.title', 'Article.this_moment')); + $expected = array( + '`Article`.`title`', + '(NOW()) AS `Article__this_moment`', + ); + $this->assertEqual($expected, $result); + + $result = $this->Dbo->fields($Article, null, array('Article.this_moment', 'Article.title')); + $expected = array( + '`Article`.`title`', + '(NOW()) AS `Article__this_moment`', + ); + $this->assertEqual($expected, $result); + + $result = $this->Dbo->fields($Article, null, array('Article.*')); + $expected = array( + '`Article`.*', + '(NOW()) AS `Article__this_moment`', + '(1 + 1) AS `Article__two`', + '(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `Article__comment_count`' + ); + $this->assertEqual($expected, $result); + + $result = $this->Dbo->fields($Article, null, array('*')); + $expected = array( + '*', + '(NOW()) AS `Article__this_moment`', + '(1 + 1) AS `Article__two`', + '(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `Article__comment_count`' + ); + $this->assertEqual($expected, $result); + } + +/** + * test conditions to generate query conditions for virtual fields + * + * @return void + */ + function testVirtualFieldsInConditions() { + $Article = ClassRegistry::init('Article'); + $Article->virtualFields = array( + 'this_moment' => 'NOW()', + 'two' => '1 + 1', + 'comment_count' => 'SELECT COUNT(*) FROM ' . $this->Dbo->fullTableName('comments') . + ' WHERE Article.id = ' . $this->Dbo->fullTableName('comments') . '.article_id' + ); + $conditions = array('two' => 2); + $result = $this->Dbo->conditions($conditions, true, false, $Article); + $expected = '(1 + 1) = 2'; + $this->assertEqual($expected, $result); + + $conditions = array('this_moment BETWEEN ? AND ?' => array(1,2)); + $expected = 'NOW() BETWEEN 1 AND 2'; + $result = $this->Dbo->conditions($conditions, true, false, $Article); + $this->assertEqual($expected, $result); + + $conditions = array('comment_count >' => 5); + $expected = '(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) > 5'; + $result = $this->Dbo->conditions($conditions, true, false, $Article); + $this->assertEqual($expected, $result); + + $conditions = array('NOT' => array('two' => 2)); + $result = $this->Dbo->conditions($conditions, true, false, $Article); + $expected = 'NOT ((1 + 1) = 2)'; + $this->assertEqual($expected, $result); + } + +/** + * test that virtualFields with complex functions and aliases work. + * + * @return void + */ + function testConditionsWithComplexVirtualFields() { + $Article = ClassRegistry::init('Article'); + $Article->virtualFields = array( + 'distance' => 'ACOS(SIN(20 * PI() / 180) + * SIN(Article.latitude * PI() / 180) + + COS(20 * PI() / 180) + * COS(Article.latitude * PI() / 180) + * COS((50 - Article.longitude) * PI() / 180) + ) * 180 / PI() * 60 * 1.1515 * 1.609344' + ); + $conditions = array('distance >=' => 20); + $result = $this->Dbo->conditions($conditions, true, true, $Article); + + $this->assertPattern('/\) >= 20/', $result); + $this->assertPattern('/[`\'"]Article[`\'"].[`\'"]latitude[`\'"]/', $result); + $this->assertPattern('/[`\'"]Article[`\'"].[`\'"]longitude[`\'"]/', $result); + } +} \ No newline at end of file diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 016487177..b2a3bee7b 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -977,133 +977,6 @@ class DboSourceTest extends CakeTestCase { $this->assertPattern('/Took:/s', $contents); } -/** - * test fields generating usable virtual fields to use in query - * - * @return void - */ - function testVirtualFields() { - $this->loadFixtures('Article'); - - $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( - 'this_moment' => 'NOW()', - 'two' => '1 + 1', - 'comment_count' => 'SELECT COUNT(*) FROM ' . $this->db->fullTableName('comments') . - ' WHERE Article.id = ' . $this->db->fullTableName('comments') . '.article_id' - ); - $result = $this->db->fields($Article); - $expected = array( - '`Article`.`id`', - '`Article`.`user_id`', - '`Article`.`title`', - '`Article`.`body`', - '`Article`.`published`', - '`Article`.`created`', - '`Article`.`updated`', - '(NOW()) AS `Article__this_moment`', - '(1 + 1) AS `Article__two`', - '(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `Article__comment_count`' - ); - $this->assertEqual($expected, $result); - - $result = $this->db->fields($Article, null, array('this_moment', 'title')); - $expected = array( - '`Article`.`title`', - '(NOW()) AS `Article__this_moment`', - ); - $this->assertEqual($expected, $result); - - $result = $this->db->fields($Article, null, array('Article.title', 'Article.this_moment')); - $expected = array( - '`Article`.`title`', - '(NOW()) AS `Article__this_moment`', - ); - $this->assertEqual($expected, $result); - - $result = $this->db->fields($Article, null, array('Article.this_moment', 'Article.title')); - $expected = array( - '`Article`.`title`', - '(NOW()) AS `Article__this_moment`', - ); - $this->assertEqual($expected, $result); - - $result = $this->db->fields($Article, null, array('Article.*')); - $expected = array( - '`Article`.*', - '(NOW()) AS `Article__this_moment`', - '(1 + 1) AS `Article__two`', - '(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `Article__comment_count`' - ); - $this->assertEqual($expected, $result); - - $result = $this->db->fields($Article, null, array('*')); - $expected = array( - '*', - '(NOW()) AS `Article__this_moment`', - '(1 + 1) AS `Article__two`', - '(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `Article__comment_count`' - ); - $this->assertEqual($expected, $result); - } - -/** - * test conditions to generate query conditions for virtual fields - * - * @return void - */ - function testVirtualFieldsInConditions() { - $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( - 'this_moment' => 'NOW()', - 'two' => '1 + 1', - 'comment_count' => 'SELECT COUNT(*) FROM ' . $this->db->fullTableName('comments') . - ' WHERE Article.id = ' . $this->db->fullTableName('comments') . '.article_id' - ); - $conditions = array('two' => 2); - $result = $this->db->conditions($conditions, true, false, $Article); - $expected = '(1 + 1) = 2'; - $this->assertEqual($expected, $result); - - $conditions = array('this_moment BETWEEN ? AND ?' => array(1,2)); - $expected = 'NOW() BETWEEN 1 AND 2'; - $result = $this->db->conditions($conditions, true, false, $Article); - $this->assertEqual($expected, $result); - - $conditions = array('comment_count >' => 5); - $expected = '(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) > 5'; - $result = $this->db->conditions($conditions, true, false, $Article); - $this->assertEqual($expected, $result); - - $conditions = array('NOT' => array('two' => 2)); - $result = $this->db->conditions($conditions, true, false, $Article); - $expected = 'NOT ((1 + 1) = 2)'; - $this->assertEqual($expected, $result); - } - -/** - * test that virtualFields with complex functions and aliases work. - * - * @return void - */ - function testConditionsWithComplexVirtualFields() { - $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( - 'distance' => 'ACOS(SIN(20 * PI() / 180) - * SIN(Article.latitude * PI() / 180) - + COS(20 * PI() / 180) - * COS(Article.latitude * PI() / 180) - * COS((50 - Article.longitude) * PI() / 180) - ) * 180 / PI() * 60 * 1.1515 * 1.609344' - ); - $conditions = array('distance >=' => 20); - $result = $this->db->conditions($conditions, true, true, $Article); - - $this->assertPattern('/\) >= 20/', $result); - $this->assertPattern('/[`\'"]Article[`\'"].[`\'"]latitude[`\'"]/', $result); - $this->assertPattern('/[`\'"]Article[`\'"].[`\'"]longitude[`\'"]/', $result); - } - /** * test order to generate query order clause for virtual fields * From b20becc0b7999816802b90580449626dfaf47a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 9 Nov 2010 01:43:23 -0430 Subject: [PATCH 089/378] Extracting remaning methods with Mysql specific syntax out of DboSourceTest --- .../model/datasources/dbo/dbo_mysql.test.php | 85 ++++++++++++++++++ .../model/datasources/dbo_source.test.php | 87 +------------------ 2 files changed, 86 insertions(+), 86 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index da2f2a721..3fbddc4a4 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -3019,4 +3019,89 @@ class DboMysqlTest extends CakeTestCase { $this->assertPattern('/[`\'"]Article[`\'"].[`\'"]latitude[`\'"]/', $result); $this->assertPattern('/[`\'"]Article[`\'"].[`\'"]longitude[`\'"]/', $result); } + +/** + * test calculate to generate claculate statements on virtual fields + * + * @return void + */ + function testVirtualFieldsInCalculate() { + $Article = ClassRegistry::init('Article'); + $Article->virtualFields = array( + 'this_moment' => 'NOW()', + 'two' => '1 + 1', + 'comment_count' => 'SELECT COUNT(*) FROM ' . $this->Dbo->fullTableName('comments') . + ' WHERE Article.id = ' . $this->Dbo->fullTableName('comments'). '.article_id' + ); + + $result = $this->Dbo->calculate($Article, 'count', array('this_moment')); + $expected = 'COUNT(NOW()) AS `count`'; + $this->assertEqual($expected, $result); + + $result = $this->Dbo->calculate($Article, 'max', array('comment_count')); + $expected = 'MAX(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `comment_count`'; + $this->assertEqual($expected, $result); + } + +/** + * test reading virtual fields containing newlines when recursive > 0 + * + * @return void + */ + function testReadVirtualFieldsWithNewLines() { + $Article = new Article(); + $Article->recursive = 1; + $Article->virtualFields = array( + 'test' => ' + User.id + User.id + ' + ); + $result = $this->Dbo->fields($Article, null, array()); + $result = $this->Dbo->fields($Article, $Article->alias, $result); + $this->assertPattern('/[`\"]User[`\"]\.[`\"]id[`\"] \+ [`\"]User[`\"]\.[`\"]id[`\"]/', $result[7]); + } + +/** + * test group to generate GROUP BY statements on virtual fields + * + * @return void + */ + function testVirtualFieldsInGroup() { + $Article = ClassRegistry::init('Article'); + $Article->virtualFields = array( + 'this_year' => 'YEAR(Article.created)' + ); + + $result = $this->Dbo->group('this_year', $Article); + + $expected = " GROUP BY (YEAR(`Article`.`created`))"; + $this->assertEqual($expected, $result); + } + +/** + * test that virtualFields with complex functions and aliases work. + * + * @return void + */ + function testFieldsWithComplexVirtualFields() { + $Article = new Article(); + $Article->virtualFields = array( + 'distance' => 'ACOS(SIN(20 * PI() / 180) + * SIN(Article.latitude * PI() / 180) + + COS(20 * PI() / 180) + * COS(Article.latitude * PI() / 180) + * COS((50 - Article.longitude) * PI() / 180) + ) * 180 / PI() * 60 * 1.1515 * 1.609344' + ); + + $fields = array('id', 'distance'); + $result = $this->Dbo->fields($Article, null, $fields); + $qs = $this->Dbo->startQuote; + $qe = $this->Dbo->endQuote; + + $this->assertEqual($result[0], "{$qs}Article{$qe}.{$qs}id{$qe}"); + $this->assertPattern('/Article__distance/', $result[1]); + $this->assertPattern('/[`\'"]Article[`\'"].[`\'"]latitude[`\'"]/', $result[1]); + $this->assertPattern('/[`\'"]Article[`\'"].[`\'"]longitude[`\'"]/', $result[1]); + } } \ No newline at end of file diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index b2a3bee7b..a934aee5d 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -999,29 +999,6 @@ class DboSourceTest extends CakeTestCase { $this->assertEqual($expected, $result); } -/** - * test calculate to generate claculate statements on virtual fields - * - * @return void - */ - function testVirtualFieldsInCalculate() { - $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( - 'this_moment' => 'NOW()', - 'two' => '1 + 1', - 'comment_count' => 'SELECT COUNT(*) FROM ' . $this->db->fullTableName('comments') . - ' WHERE Article.id = ' . $this->db->fullTableName('comments'). '.article_id' - ); - - $result = $this->db->calculate($Article, 'count', array('this_moment')); - $expected = 'COUNT(NOW()) AS `count`'; - $this->assertEqual($expected, $result); - - $result = $this->db->calculate($Article, 'max', array('comment_count')); - $expected = 'MAX(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `comment_count`'; - $this->assertEqual($expected, $result); - } - /** * test a full example of using virtual fields * @@ -1079,68 +1056,6 @@ class DboSourceTest extends CakeTestCase { $this->assertTrue($result[0]['DataTest']['complicated'] > 0); } -/** - * test that virtualFields with complex functions and aliases work. - * - * @return void - */ - function testFieldsWithComplexVirtualFields() { - $Article = new Article(); - $Article->virtualFields = array( - 'distance' => 'ACOS(SIN(20 * PI() / 180) - * SIN(Article.latitude * PI() / 180) - + COS(20 * PI() / 180) - * COS(Article.latitude * PI() / 180) - * COS((50 - Article.longitude) * PI() / 180) - ) * 180 / PI() * 60 * 1.1515 * 1.609344' - ); - - $fields = array('id', 'distance'); - $result = $this->db->fields($Article, null, $fields); - $qs = $this->db->startQuote; - $qe = $this->db->endQuote; - - $this->assertEqual($result[0], "{$qs}Article{$qe}.{$qs}id{$qe}"); - $this->assertPattern('/Article__distance/', $result[1]); - $this->assertPattern('/[`\'"]Article[`\'"].[`\'"]latitude[`\'"]/', $result[1]); - $this->assertPattern('/[`\'"]Article[`\'"].[`\'"]longitude[`\'"]/', $result[1]); - } - -/** - * test reading virtual fields containing newlines when recursive > 0 - * - * @return void - */ - function testReadVirtualFieldsWithNewLines() { - $Article = new Article(); - $Article->recursive = 1; - $Article->virtualFields = array( - 'test' => ' - User.id + User.id - ' - ); - $result = $this->db->fields($Article, null, array()); - $result = $this->db->fields($Article, $Article->alias, $result); - $this->assertPattern('/[`\"]User[`\"]\.[`\"]id[`\"] \+ [`\"]User[`\"]\.[`\"]id[`\"]/', $result[7]); - } - -/** - * test group to generate GROUP BY statements on virtual fields - * - * @return void - */ - function testVirtualFieldsInGroup() { - $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( - 'this_year' => 'YEAR(Article.created)' - ); - - $result = $this->db->group('this_year', $Article); - - $expected = " GROUP BY (YEAR(`Article`.`created`))"; - $this->assertEqual($expected, $result); - } - /** * test the permutations of fullTableName() * @@ -1185,7 +1100,7 @@ class DboSourceTest extends CakeTestCase { $this->testDb->cacheMethods = false; $this->assertTrue(empty($this->testDb->methodCache['fields']), 'Cache not empty'); - $Article =& ClassRegistry::init('Article'); + $Article = ClassRegistry::init('Article'); $this->testDb->fields($Article, null, array('title', 'body', 'published')); $this->assertTrue(empty($this->testDb->methodCache['fields']), 'Cache not empty'); } From b46b8613833cca4233d95d0ea15c326dc88e4444 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 9 Nov 2010 18:54:33 -0200 Subject: [PATCH 090/378] Removed unsed variable. --- cake/libs/cake_socket.php | 1 - 1 file changed, 1 deletion(-) diff --git a/cake/libs/cake_socket.php b/cake/libs/cake_socket.php index 3bcb7ca0a..e07b9837f 100644 --- a/cake/libs/cake_socket.php +++ b/cake/libs/cake_socket.php @@ -112,7 +112,6 @@ class CakeSocket { } if ($this->config['persistent'] == true) { - $tmp = null; $this->connection = @pfsockopen($scheme.$this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']); } else { $this->connection = @fsockopen($scheme.$this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']); From fb5495fad55c6590f1673af9616ee1109c94e6da Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 9 Nov 2010 18:58:29 -0200 Subject: [PATCH 091/378] Throws an exception on fail in connect. --- cake/libs/cake_socket.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cake/libs/cake_socket.php b/cake/libs/cake_socket.php index e07b9837f..612d42e21 100644 --- a/cake/libs/cake_socket.php +++ b/cake/libs/cake_socket.php @@ -100,6 +100,7 @@ class CakeSocket { * Connect the socket to the given host and port. * * @return boolean Success + * @throws Exception */ public function connect() { if ($this->connection != null) { @@ -119,6 +120,7 @@ class CakeSocket { if (!empty($errNum) || !empty($errStr)) { $this->setLastError($errStr, $errNum); + throw new Exception($errStr, $errNum); } $this->connected = is_resource($this->connection); From 8c29847c8f262406879a3483860434e9d015203d Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 9 Nov 2010 19:07:29 -0200 Subject: [PATCH 092/378] Simplified the CakeSocket and fixed some phpdocs. --- cake/libs/cake_socket.php | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/cake/libs/cake_socket.php b/cake/libs/cake_socket.php index 612d42e21..531c3b43a 100644 --- a/cake/libs/cake_socket.php +++ b/cake/libs/cake_socket.php @@ -138,9 +138,8 @@ class CakeSocket { public function host() { if (Validation::ip($this->config['host'])) { return gethostbyaddr($this->config['host']); - } else { - return gethostbyaddr($this->address()); } + return gethostbyaddr($this->address()); } /** @@ -151,9 +150,8 @@ class CakeSocket { public function address() { if (Validation::ip($this->config['host'])) { return $this->config['host']; - } else { - return gethostbyname($this->config['host']); } + return gethostbyname($this->config['host']); } /** @@ -164,9 +162,8 @@ class CakeSocket { public function addresses() { if (Validation::ip($this->config['host'])) { return array($this->config['host']); - } else { - return gethostbynamel($this->config['host']); } + return gethostbynamel($this->config['host']); } /** @@ -177,9 +174,8 @@ class CakeSocket { public function lastError() { if (!empty($this->lastError)) { return $this->lastError['num'] . ': ' . $this->lastError['str']; - } else { - return null; } + return null; } /** @@ -187,6 +183,7 @@ class CakeSocket { * * @param integer $errNum Error code * @param string $errStr Error string + * @return void */ public function setLastError($errNum, $errStr) { $this->lastError = array('num' => $errNum, 'str' => $errStr); @@ -230,17 +227,8 @@ class CakeSocket { return false; } return $buffer; - } else { - return false; } - } - -/** - * Abort socket operation. - * - * @return boolean Success - */ - public function abort() { + return false; } /** @@ -273,6 +261,7 @@ class CakeSocket { /** * Resets the state of this Socket instance to it's initial state (before Object::__construct got executed) * + * @param array $state Array with key and values to reset * @return boolean True on success */ public function reset($state = null) { From 2bed6622fec146234ead490323485b256d792b6b Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 9 Nov 2010 21:00:57 -0200 Subject: [PATCH 093/378] Added tests to thown in connect. --- cake/tests/cases/libs/cake_socket.test.php | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cake/tests/cases/libs/cake_socket.test.php b/cake/tests/cases/libs/cake_socket.test.php index 48b304060..c14afbff6 100644 --- a/cake/tests/cases/libs/cake_socket.test.php +++ b/cake/tests/cases/libs/cake_socket.test.php @@ -101,6 +101,30 @@ class CakeSocketTest extends CakeTestCase { $this->assertTrue($this->Socket->connected); } +/** + * data provider function for testInvalidConnection + * + * @return array + */ + public static function invalidConnections() { + return array( + array(array('host' => 'invalid.host')), + array(array('host' => '127.0.0.1', 'port' => '70000')) + ); + } + +/** + * testInvalidConnection method + * + * @dataProvider invalidConnections + * @expectedException Exception + * return void + */ + public function testInvalidConnection($data) { + $this->Socket->config = array_merge($this->Socket->config, $data); + $this->Socket->connect(); + } + /** * testSocketHost method * From c6dd77de6f778dd7b4d7e48e7f78067336f1fcba Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 9 Nov 2010 21:04:52 -0200 Subject: [PATCH 094/378] Removed unsed attribute. --- cake/libs/http_socket.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 9848446c4..2a2c6333e 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -30,14 +30,6 @@ App::import('Core', array('CakeSocket', 'Set', 'Router')); */ class HttpSocket extends CakeSocket { -/** - * Object description - * - * @var string - * @access public - */ - public $description = 'HTTP-based DataSource Interface'; - /** * When one activates the $quirksMode by setting it to true, all checks meant to * enforce RFC 2616 (HTTP/1.1 specs). From 8a4faa1e6921c5853507bd0be525bf5aaa063deb Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 9 Nov 2010 21:12:40 -0200 Subject: [PATCH 095/378] Updated doc to avoid E_STRICT messages. --- cake/libs/http_socket.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 2a2c6333e..3dea7ad28 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -138,12 +138,12 @@ class HttpSocket extends CakeSocket { * You can use a url string to set the url and use default configurations for * all other options: * - * `$http =& new HttpSockect('http://cakephp.org/');` + * `$http = new HttpSockect('http://cakephp.org/');` * * Or use an array to configure multiple options: * * {{{ - * $http =& new HttpSocket(array( + * $http = new HttpSocket(array( * 'host' => 'cakephp.org', * 'timeout' => 20 * )); From ef2a7d4608e5f531775d4b8fc5d77403858ca833 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 9 Nov 2010 21:28:11 -0200 Subject: [PATCH 096/378] Replaced trigger_error by throw Exception. --- cake/libs/http_socket.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 3dea7ad28..b25020530 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -532,6 +532,7 @@ class HttpSocket extends CakeSocket { * * @param string $body A string continaing the chunked body to decode. * @return mixed Array of response headers and body or false. + * @throws Exception */ protected function _decodeChunkedBody($body) { if (!is_string($body)) { @@ -544,8 +545,7 @@ class HttpSocket extends CakeSocket { while ($chunkLength !== 0) { if (!preg_match("/^([0-9a-f]+) *(?:;(.+)=(.+))?\r\n/iU", $body, $match)) { if (!$this->quirksMode) { - trigger_error(__('HttpSocket::_decodeChunkedBody - Could not parse malformed chunk. Activate quirks mode to do this.'), E_USER_WARNING); - return false; + throw new Exception(__('HttpSocket::_decodeChunkedBody - Could not parse malformed chunk. Activate quirks mode to do this.')); } break; } @@ -794,6 +794,7 @@ class HttpSocket extends CakeSocket { * @param array $request Needs to contain a 'uri' key. Should also contain a 'method' key, otherwise defaults to GET. * @param string $versionToken The version token to use, defaults to HTTP/1.1 * @return string Request line + * @throws Exception */ protected function _buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') { $asteriskMethods = array('OPTIONS'); @@ -801,8 +802,7 @@ class HttpSocket extends CakeSocket { if (is_string($request)) { $isValid = preg_match("/(.+) (.+) (.+)\r\n/U", $request, $match); if (!$this->quirksMode && (!$isValid || ($match[2] == '*' && !in_array($match[3], $asteriskMethods)))) { - trigger_error(__('HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.'), E_USER_WARNING); - return false; + throw new Exception(__('HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.')); } return $request; } elseif (!is_array($request)) { @@ -816,8 +816,7 @@ class HttpSocket extends CakeSocket { $request['uri'] = $this->_buildUri($request['uri'], '/%path?%query'); if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) { - trigger_error(sprintf(__('HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.'), join(',', $asteriskMethods)), E_USER_WARNING); - return false; + throw new Exception(sprintf(__('HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.'), join(',', $asteriskMethods))); } return $request['method'].' '.$request['uri'].' '.$versionToken.$this->lineBreak; } From 777afb6d3ebf201b06a27b77c0ba5c594ee87f8e Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 9 Nov 2010 23:03:43 -0200 Subject: [PATCH 097/378] separeted auth from HttpSocket. Refs #880 --- cake/libs/http/basic_method.php | 42 ++++++++++++++++ cake/libs/http_socket.php | 32 +++++++++--- .../cases/libs/http/basic_method.test.php | 49 +++++++++++++++++++ cake/tests/cases/libs/http_socket.test.php | 3 ++ 4 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 cake/libs/http/basic_method.php create mode 100644 cake/tests/cases/libs/http/basic_method.test.php diff --git a/cake/libs/http/basic_method.php b/cake/libs/http/basic_method.php new file mode 100644 index 000000000..da7951c6c --- /dev/null +++ b/cake/libs/http/basic_method.php @@ -0,0 +1,42 @@ +request['auth']['user'], $http->request['auth']['pass'])) { + $http->request['header']['Authorization'] = 'Basic ' . base64_encode($http->request['auth']['user'] . ':' . $http->request['auth']['pass']); + } + } + +} diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index b25020530..3def34cea 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -236,12 +236,7 @@ class HttpSocket extends CakeSocket { $this->request['header'] = array_merge(compact('Host'), $this->request['header']); } - if (isset($this->request['auth']['user']) && isset($this->request['auth']['pass'])) { - $this->request['header']['Authorization'] = $this->request['auth']['method'] . " " . base64_encode($this->request['auth']['user'] . ":" . $this->request['auth']['pass']); - } - if (isset($this->request['uri']['user']) && isset($this->request['uri']['pass'])) { - $this->request['header']['Authorization'] = $this->request['auth']['method'] . " " . base64_encode($this->request['uri']['user'] . ":" . $this->request['uri']['pass']); - } + $this->_setAuth(); if (is_array($this->request['body'])) { $this->request['body'] = $this->_httpSerialize($this->request['body']); @@ -439,6 +434,31 @@ class HttpSocket extends CakeSocket { return $this->_buildUri($url); } +/** + * Set authentication in request + * + * @return void + * @throws Exception + */ + protected function _setAuth() { + if (empty($this->request['auth']['method'])) { + if (isset($this->request['uri']['user'], $this->request['uri']['pass'])) { + $this->request['auth'] = array( + 'method' => 'Basic', + 'user' => $this->request['uri']['user'], + 'pass' => $this->request['uri']['pass'] + ); + } else { + return; + } + } + $authClass = Inflector::camelize($this->request['auth']['method']) . 'Method'; + if (!App::import('Lib', 'http/' . $authClass)) { + throw new Exception(__('Authentication method unknown.')); + } + $authClass::authentication($this); + } + /** * Parses the given message and breaks it down in parts. * diff --git a/cake/tests/cases/libs/http/basic_method.test.php b/cake/tests/cases/libs/http/basic_method.test.php new file mode 100644 index 000000000..c9d487f70 --- /dev/null +++ b/cake/tests/cases/libs/http/basic_method.test.php @@ -0,0 +1,49 @@ + + * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice + * + * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests + * @package cake + * @subpackage cake.tests.cases.libs.http + * @since CakePHP(tm) v 2.0.0 + * @license MIT License (http://www.opensource.org/licenses/mit-license.php) + */ + +App::import('Core', 'HttpSocket'); +App::import('Lib', 'http/BasicMethod'); + +/** + * BasicMethodTest class + * + * @package cake + * @subpackage cake.tests.cases.libs.http + */ +class BasicMethodTest extends CakeTestCase { + +/** + * testAuthentication method + * + * @return void + */ + public function testAuthentication() { + $http = new HttpSocket(); + $http->request['auth'] = array( + 'method' => 'Basic', + 'user' => 'mark', + 'pass' => 'secret' + ); + + BasicMethod::authentication($http); + $this->assertEqual($http->request['header']['Authorization'], 'Basic bWFyazpzZWNyZXQ='); + } + +} \ No newline at end of file diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 5b3f79e0c..beb0fc0c5 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -694,14 +694,17 @@ class HttpSocketTest extends CakeTestCase { $socket->get('http://mark:secret@example.com/test'); $this->assertEqual($socket->request['uri']['user'], 'mark'); $this->assertEqual($socket->request['uri']['pass'], 'secret'); + $this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); $socket->get('/test2'); $this->assertEqual($socket->request['auth']['user'], 'mark'); $this->assertEqual($socket->request['auth']['pass'], 'secret'); + $this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); $socket->get('/test3'); $this->assertEqual($socket->request['auth']['user'], 'mark'); $this->assertEqual($socket->request['auth']['pass'], 'secret'); + $this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); } /** From d46f95335730387577806b234a1a922b963d86fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 10 Nov 2010 23:10:13 -0430 Subject: [PATCH 098/378] Changing test case to reflect that stats option was removed from DboSource::execute and merged into "log" option --- cake/tests/cases/libs/model/datasources/dbo_source.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index a934aee5d..16d7e6cc5 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -934,7 +934,7 @@ class DboSourceTest extends CakeTestCase { $query = 'SELECT * FROM ' . $this->testDb->fullTableName('articles') . ' WHERE 1 = 1'; $this->db->took = null; $this->db->affected = null; - $result = $this->db->execute($query, array('stats' => false)); + $result = $this->db->execute($query, array('log' => false)); $this->assertNotNull($result, 'No query performed! %s'); $this->assertNull($this->db->took, 'Stats were set %s'); $this->assertNull($this->db->affected, 'Stats were set %s'); From 106379b7efafa36ef39bd3b02404ca71f05ddf42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 10 Nov 2010 23:31:54 -0430 Subject: [PATCH 099/378] Removing all methods with mysql syntax or dependent on anyway of this Dbo out form DboSourceTest. --- .../model/datasources/dbo/dbo_mysql.test.php | 348 +++++++++++++++++- .../model/datasources/dbo_source.test.php | 306 +-------------- 2 files changed, 329 insertions(+), 325 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 3fbddc4a4..ea73c627d 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -2857,40 +2857,40 @@ class DboMysqlTest extends CakeTestCase { $this->skipIf(true, 'Fix me'); $this->loadFixtures('Article', 'User', 'Comment', 'Tag', 'Attachment', 'ArticlesTag'); $Article = new Article(); - //$this->testDb = $this->getMock('DboMysql', array('connect', 'execute', '_execute')); + //$this->Dbo = $this->getMock('DboMysql', array('connect', 'execute', '_execute')); - $result = $this->testDb->update($Article, array('field1'), array('value1')); + $result = $this->Dbo->update($Article, array('field1'), array('value1')); $this->assertFalse($result); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/^\s*UPDATE\s+' . $this->testDb->fullTableName('articles') . '\s+SET\s+`field1`\s*=\s*\'value1\'\s+WHERE\s+1 = 1\s*$/', $result); + $result = $this->Dbo->getLastQuery(); + $this->assertPattern('/^\s*UPDATE\s+' . $this->Dbo->fullTableName('articles') . '\s+SET\s+`field1`\s*=\s*\'value1\'\s+WHERE\s+1 = 1\s*$/', $result); - $result = $this->testDb->update($Article, array('field1'), array('2'), '2=2'); + $result = $this->Dbo->update($Article, array('field1'), array('2'), '2=2'); $this->assertFalse($result); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/^\s*UPDATE\s+' . $this->testDb->fullTableName('articles') . ' AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+SET\s+`Article`\.`field1`\s*=\s*2\s+WHERE\s+2\s*=\s*2\s*$/', $result); + $result = $this->Dbo->getLastQuery(); + $this->assertPattern('/^\s*UPDATE\s+' . $this->Dbo->fullTableName('articles') . ' AS `Article`\s+LEFT JOIN\s+' . $this->Dbo->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+SET\s+`Article`\.`field1`\s*=\s*2\s+WHERE\s+2\s*=\s*2\s*$/', $result); - $result = $this->testDb->delete($Article); + $result = $this->Dbo->delete($Article); $this->assertTrue($result); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/^\s*DELETE\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+WHERE\s+1 = 1\s*$/', $result); + $result = $this->Dbo->getLastQuery(); + $this->assertPattern('/^\s*DELETE\s+FROM\s+' . $this->Dbo->fullTableName('articles') . '\s+WHERE\s+1 = 1\s*$/', $result); - $result = $this->testDb->delete($Article, true); + $result = $this->Dbo->delete($Article, true); $this->assertTrue($result); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+1\s*=\s*1\s*$/', $result); + $result = $this->Dbo->getLastQuery(); + $this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->Dbo->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->Dbo->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+1\s*=\s*1\s*$/', $result); - $result = $this->testDb->delete($Article, '2=2'); + $result = $this->Dbo->delete($Article, '2=2'); $this->assertTrue($result); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+2\s*=\s*2\s*$/', $result); + $result = $this->Dbo->getLastQuery(); + $this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->Dbo->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->Dbo->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+2\s*=\s*2\s*$/', $result); - $result = $this->testDb->hasAny($Article, '1=2'); + $result = $this->Dbo->hasAny($Article, '1=2'); $this->assertFalse($result); - $result = $this->testDb->insertMulti('articles', array('field'), array('(1)', '(2)')); + $result = $this->Dbo->insertMulti('articles', array('field'), array('(1)', '(2)')); $this->assertNull($result); - $result = $this->testDb->getLastQuery(); - $this->assertPattern('/^\s*INSERT INTO\s+' . $this->testDb->fullTableName('articles') . '\s+\(`field`\)\s+VALUES\s+\(1\),\s*\(2\)\s*$/', $result); + $result = $this->Dbo->getLastQuery(); + $this->assertPattern('/^\s*INSERT INTO\s+' . $this->Dbo->fullTableName('articles') . '\s+\(`field`\)\s+VALUES\s+\(1\),\s*\(2\)\s*$/', $result); } /** @@ -3104,4 +3104,312 @@ class DboMysqlTest extends CakeTestCase { $this->assertPattern('/[`\'"]Article[`\'"].[`\'"]latitude[`\'"]/', $result[1]); $this->assertPattern('/[`\'"]Article[`\'"].[`\'"]longitude[`\'"]/', $result[1]); } + +/** + * test that execute runs queries. + * + * @return void + */ + function testExecute() { + $query = 'SELECT * FROM ' . $this->Dbo->fullTableName('articles') . ' WHERE 1 = 1'; + $this->Dbo->took = null; + $this->Dbo->affected = null; + $result = $this->Dbo->execute($query, array('log' => false)); + $this->assertNotNull($result, 'No query performed! %s'); + $this->assertNull($this->Dbo->took, 'Stats were set %s'); + $this->assertNull($this->Dbo->affected, 'Stats were set %s'); + + $result = $this->Dbo->execute($query); + $this->assertNotNull($result, 'No query performed! %s'); + $this->assertNotNull($this->Dbo->took, 'Stats were not set %s'); + $this->assertNotNull($this->Dbo->affected, 'Stats were not set %s'); + } + +/** + * test a full example of using virtual fields + * + * @return void + */ + function testVirtualFieldsFetch() { + $this->loadFixtures('Article', 'Comment'); + + $Article = ClassRegistry::init('Article'); + $Article->virtualFields = array( + 'comment_count' => 'SELECT COUNT(*) FROM ' . $this->Dbo->fullTableName('comments') . + ' WHERE Article.id = ' . $this->Dbo->fullTableName('comments') . '.article_id' + ); + + $conditions = array('comment_count >' => 2); + $query = 'SELECT ' . join(',',$this->Dbo->fields($Article, null, array('id', 'comment_count'))) . + ' FROM ' . $this->Dbo->fullTableName($Article) . ' Article ' . $this->Dbo->conditions($conditions, true, true, $Article); + $result = $this->Dbo->fetchAll($query); + $expected = array(array( + 'Article' => array('id' => 1, 'comment_count' => 4) + )); + $this->assertEqual($expected, $result); + } + +/** + * test reading complex virtualFields with subqueries. + * + * @return void + */ + function testVirtualFieldsComplexRead() { + $this->loadFixtures('DataTest', 'Article', 'Comment', 'User', 'Tag'); + + $Article = ClassRegistry::init('Article'); + $commentTable = $this->Dbo->fullTableName('comments'); + $Article = ClassRegistry::init('Article'); + $Article->virtualFields = array( + 'comment_count' => 'SELECT COUNT(*) FROM ' . $commentTable . + ' AS Comment WHERE Article.id = Comment.article_id' + ); + $result = $Article->find('all'); + $this->assertTrue(count($result) > 0); + $this->assertTrue($result[0]['Article']['comment_count'] > 0); + + $DataTest = ClassRegistry::init('DataTest'); + $DataTest->virtualFields = array( + 'complicated' => 'ACOS(SIN(20 * PI() / 180) + * SIN(DataTest.float * PI() / 180) + + COS(20 * PI() / 180) + * COS(DataTest.count * PI() / 180) + * COS((50 - DataTest.float) * PI() / 180) + ) * 180 / PI() * 60 * 1.1515 * 1.609344' + ); + $result = $DataTest->find('all'); + $this->assertTrue(count($result) > 0); + $this->assertTrue($result[0]['DataTest']['complicated'] > 0); + } + +/** + * testIntrospectType method + * + * @access public + * @return void + */ + function testIntrospectType() { + $this->assertEqual($this->Dbo->introspectType(0), 'integer'); + $this->assertEqual($this->Dbo->introspectType(2), 'integer'); + $this->assertEqual($this->Dbo->introspectType('2'), 'string'); + $this->assertEqual($this->Dbo->introspectType('2.2'), 'string'); + $this->assertEqual($this->Dbo->introspectType(2.2), 'float'); + $this->assertEqual($this->Dbo->introspectType('stringme'), 'string'); + $this->assertEqual($this->Dbo->introspectType('0stringme'), 'string'); + + $data = array(2.2); + $this->assertEqual($this->Dbo->introspectType($data), 'float'); + + $data = array('2.2'); + $this->assertEqual($this->Dbo->introspectType($data), 'float'); + + $data = array(2); + $this->assertEqual($this->Dbo->introspectType($data), 'integer'); + + $data = array('2'); + $this->assertEqual($this->Dbo->introspectType($data), 'integer'); + + $data = array('string'); + $this->assertEqual($this->Dbo->introspectType($data), 'string'); + + $data = array(2.2, '2.2'); + $this->assertEqual($this->Dbo->introspectType($data), 'float'); + + $data = array(2, '2'); + $this->assertEqual($this->Dbo->introspectType($data), 'integer'); + + $data = array('string one', 'string two'); + $this->assertEqual($this->Dbo->introspectType($data), 'string'); + + $data = array('2.2', 3); + $this->assertEqual($this->Dbo->introspectType($data), 'integer'); + + $data = array('2.2', '0stringme'); + $this->assertEqual($this->Dbo->introspectType($data), 'string'); + + $data = array(2.2, 3); + $this->assertEqual($this->Dbo->introspectType($data), 'integer'); + + $data = array(2.2, '0stringme'); + $this->assertEqual($this->Dbo->introspectType($data), 'string'); + + $data = array(2, 'stringme'); + $this->assertEqual($this->Dbo->introspectType($data), 'string'); + + $data = array(2, '2.2', 'stringgme'); + $this->assertEqual($this->Dbo->introspectType($data), 'string'); + + $data = array(2, '2.2'); + $this->assertEqual($this->Dbo->introspectType($data), 'integer'); + + $data = array(2, 2.2); + $this->assertEqual($this->Dbo->introspectType($data), 'integer'); + + + // NULL + $result = $this->Dbo->value(null, 'boolean'); + $this->assertEqual($result, 'NULL'); + + // EMPTY STRING + $result = $this->Dbo->value('', 'boolean'); + $this->assertEqual($result, "'0'"); + + + // BOOLEAN + $result = $this->Dbo->value('true', 'boolean'); + $this->assertEqual($result, "'1'"); + + $result = $this->Dbo->value('false', 'boolean'); + $this->assertEqual($result, "'1'"); + + $result = $this->Dbo->value(true, 'boolean'); + $this->assertEqual($result, "'1'"); + + $result = $this->Dbo->value(false, 'boolean'); + $this->assertEqual($result, "'0'"); + + $result = $this->Dbo->value(1, 'boolean'); + $this->assertEqual($result, "'1'"); + + $result = $this->Dbo->value(0, 'boolean'); + $this->assertEqual($result, "'0'"); + + $result = $this->Dbo->value('abc', 'boolean'); + $this->assertEqual($result, "'1'"); + + $result = $this->Dbo->value(1.234, 'boolean'); + $this->assertEqual($result, "'1'"); + + $result = $this->Dbo->value('1.234e05', 'boolean'); + $this->assertEqual($result, "'1'"); + + // NUMBERS + $result = $this->Dbo->value(123, 'integer'); + $this->assertEqual($result, 123); + + $result = $this->Dbo->value('123', 'integer'); + $this->assertEqual($result, '123'); + + $result = $this->Dbo->value('0123', 'integer'); + $this->assertEqual($result, "'0123'"); + + $result = $this->Dbo->value('0x123ABC', 'integer'); + $this->assertEqual($result, "'0x123ABC'"); + + $result = $this->Dbo->value('0x123', 'integer'); + $this->assertEqual($result, "'0x123'"); + + $result = $this->Dbo->value(1.234, 'float'); + $this->assertEqual($result, 1.234); + + $result = $this->Dbo->value('1.234', 'float'); + $this->assertEqual($result, '1.234'); + + $result = $this->Dbo->value(' 1.234 ', 'float'); + $this->assertEqual($result, "' 1.234 '"); + + $result = $this->Dbo->value('1.234e05', 'float'); + $this->assertEqual($result, "'1.234e05'"); + + $result = $this->Dbo->value('1.234e+5', 'float'); + $this->assertEqual($result, "'1.234e+5'"); + + $result = $this->Dbo->value('1,234', 'float'); + $this->assertEqual($result, "'1,234'"); + + $result = $this->Dbo->value('FFF', 'integer'); + $this->assertEqual($result, "'FFF'"); + + $result = $this->Dbo->value('abc', 'integer'); + $this->assertEqual($result, "'abc'"); + + // STRINGS + $result = $this->Dbo->value('123', 'string'); + $this->assertEqual($result, "'123'"); + + $result = $this->Dbo->value(123, 'string'); + $this->assertEqual($result, "'123'"); + + $result = $this->Dbo->value(1.234, 'string'); + $this->assertEqual($result, "'1.234'"); + + $result = $this->Dbo->value('abc', 'string'); + $this->assertEqual($result, "'abc'"); + + $result = $this->Dbo->value(' abc ', 'string'); + $this->assertEqual($result, "' abc '"); + + $result = $this->Dbo->value('a bc', 'string'); + $this->assertEqual($result, "'a bc'"); + } + +/** + * testRealQueries method + * + * @access public + * @return void + */ + function testRealQueries() { + $this->loadFixtures('Apple', 'Article', 'User', 'Comment', 'Tag', 'Sample'); + + $Apple = ClassRegistry::init('Apple'); + $Article = ClassRegistry::init('Article'); + + $result = $this->Dbo->rawQuery('SELECT color, name FROM ' . $this->Dbo->fullTableName('apples')); + $this->assertTrue(!empty($result)); + + $result = $this->Dbo->fetchRow($result); + $expected = array($this->Dbo->fullTableName('apples', false) => array( + 'color' => 'Red 1', + 'name' => 'Red Apple 1' + )); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->fetchAll('SELECT name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id'); + $expected = array( + array($this->Dbo->fullTableName('apples', false) => array('name' => 'Red Apple 1')), + array($this->Dbo->fullTableName('apples', false) => array('name' => 'Bright Red Apple')), + array($this->Dbo->fullTableName('apples', false) => array('name' => 'green blue')), + array($this->Dbo->fullTableName('apples', false) => array('name' => 'Test Name')), + array($this->Dbo->fullTableName('apples', false) => array('name' => 'Blue Green')), + array($this->Dbo->fullTableName('apples', false) => array('name' => 'My new apple')), + array($this->Dbo->fullTableName('apples', false) => array('name' => 'Some odd color')) + ); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->field($this->Dbo->fullTableName('apples', false), 'SELECT color, name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id'); + $expected = array( + 'color' => 'Red 1', + 'name' => 'Red Apple 1' + ); + $this->assertEqual($result, $expected); + + $Apple->unbindModel(array(), false); + $result = $this->Dbo->read($Apple, array( + 'fields' => array($Apple->escapeField('name')), + 'conditions' => null, + 'recursive' => -1 + )); + $expected = array( + array('Apple' => array('name' => 'Red Apple 1')), + array('Apple' => array('name' => 'Bright Red Apple')), + array('Apple' => array('name' => 'green blue')), + array('Apple' => array('name' => 'Test Name')), + array('Apple' => array('name' => 'Blue Green')), + array('Apple' => array('name' => 'My new apple')), + array('Apple' => array('name' => 'Some odd color')) + ); + $this->assertEqual($result, $expected); + + $result = $this->Dbo->read($Article, array( + 'fields' => array('id', 'user_id', 'title'), + 'conditions' => null, + 'recursive' => 1 + )); + + $this->assertTrue(Set::matches('/Article[id=1]', $result)); + $this->assertTrue(Set::matches('/Comment[id=1]', $result)); + $this->assertTrue(Set::matches('/Comment[id=2]', $result)); + $this->assertFalse(Set::matches('/Comment[id=10]', $result)); + } } \ No newline at end of file diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 16d7e6cc5..0e13d38b6 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -502,166 +502,6 @@ class DboSourceTest extends CakeTestCase { $this->assertFalse($result); } -/** - * testIntrospectType method - * - * @access public - * @return void - */ - function testIntrospectType() { - $this->assertEqual($this->testDb->introspectType(0), 'integer'); - $this->assertEqual($this->testDb->introspectType(2), 'integer'); - $this->assertEqual($this->testDb->introspectType('2'), 'string'); - $this->assertEqual($this->testDb->introspectType('2.2'), 'string'); - $this->assertEqual($this->testDb->introspectType(2.2), 'float'); - $this->assertEqual($this->testDb->introspectType('stringme'), 'string'); - $this->assertEqual($this->testDb->introspectType('0stringme'), 'string'); - - $data = array(2.2); - $this->assertEqual($this->testDb->introspectType($data), 'float'); - - $data = array('2.2'); - $this->assertEqual($this->testDb->introspectType($data), 'float'); - - $data = array(2); - $this->assertEqual($this->testDb->introspectType($data), 'integer'); - - $data = array('2'); - $this->assertEqual($this->testDb->introspectType($data), 'integer'); - - $data = array('string'); - $this->assertEqual($this->testDb->introspectType($data), 'string'); - - $data = array(2.2, '2.2'); - $this->assertEqual($this->testDb->introspectType($data), 'float'); - - $data = array(2, '2'); - $this->assertEqual($this->testDb->introspectType($data), 'integer'); - - $data = array('string one', 'string two'); - $this->assertEqual($this->testDb->introspectType($data), 'string'); - - $data = array('2.2', 3); - $this->assertEqual($this->testDb->introspectType($data), 'integer'); - - $data = array('2.2', '0stringme'); - $this->assertEqual($this->testDb->introspectType($data), 'string'); - - $data = array(2.2, 3); - $this->assertEqual($this->testDb->introspectType($data), 'integer'); - - $data = array(2.2, '0stringme'); - $this->assertEqual($this->testDb->introspectType($data), 'string'); - - $data = array(2, 'stringme'); - $this->assertEqual($this->testDb->introspectType($data), 'string'); - - $data = array(2, '2.2', 'stringgme'); - $this->assertEqual($this->testDb->introspectType($data), 'string'); - - $data = array(2, '2.2'); - $this->assertEqual($this->testDb->introspectType($data), 'integer'); - - $data = array(2, 2.2); - $this->assertEqual($this->testDb->introspectType($data), 'integer'); - - - // NULL - $result = $this->testDb->value(null, 'boolean'); - $this->assertEqual($result, 'NULL'); - - // EMPTY STRING - $result = $this->testDb->value('', 'boolean'); - $this->assertEqual($result, "'0'"); - - - // BOOLEAN - $result = $this->testDb->value('true', 'boolean'); - $this->assertEqual($result, "'1'"); - - $result = $this->testDb->value('false', 'boolean'); - $this->assertEqual($result, "'1'"); - - $result = $this->testDb->value(true, 'boolean'); - $this->assertEqual($result, "'1'"); - - $result = $this->testDb->value(false, 'boolean'); - $this->assertEqual($result, "'0'"); - - $result = $this->testDb->value(1, 'boolean'); - $this->assertEqual($result, "'1'"); - - $result = $this->testDb->value(0, 'boolean'); - $this->assertEqual($result, "'0'"); - - $result = $this->testDb->value('abc', 'boolean'); - $this->assertEqual($result, "'1'"); - - $result = $this->testDb->value(1.234, 'boolean'); - $this->assertEqual($result, "'1'"); - - $result = $this->testDb->value('1.234e05', 'boolean'); - $this->assertEqual($result, "'1'"); - - // NUMBERS - $result = $this->testDb->value(123, 'integer'); - $this->assertEqual($result, 123); - - $result = $this->testDb->value('123', 'integer'); - $this->assertEqual($result, '123'); - - $result = $this->testDb->value('0123', 'integer'); - $this->assertEqual($result, "'0123'"); - - $result = $this->testDb->value('0x123ABC', 'integer'); - $this->assertEqual($result, "'0x123ABC'"); - - $result = $this->testDb->value('0x123', 'integer'); - $this->assertEqual($result, "'0x123'"); - - $result = $this->testDb->value(1.234, 'float'); - $this->assertEqual($result, 1.234); - - $result = $this->testDb->value('1.234', 'float'); - $this->assertEqual($result, '1.234'); - - $result = $this->testDb->value(' 1.234 ', 'float'); - $this->assertEqual($result, "' 1.234 '"); - - $result = $this->testDb->value('1.234e05', 'float'); - $this->assertEqual($result, "'1.234e05'"); - - $result = $this->testDb->value('1.234e+5', 'float'); - $this->assertEqual($result, "'1.234e+5'"); - - $result = $this->testDb->value('1,234', 'float'); - $this->assertEqual($result, "'1,234'"); - - $result = $this->testDb->value('FFF', 'integer'); - $this->assertEqual($result, "'FFF'"); - - $result = $this->testDb->value('abc', 'integer'); - $this->assertEqual($result, "'abc'"); - - // STRINGS - $result = $this->testDb->value('123', 'string'); - $this->assertEqual($result, "'123'"); - - $result = $this->testDb->value(123, 'string'); - $this->assertEqual($result, "'123'"); - - $result = $this->testDb->value(1.234, 'string'); - $this->assertEqual($result, "'1.234'"); - - $result = $this->testDb->value('abc', 'string'); - $this->assertEqual($result, "'abc'"); - - $result = $this->testDb->value(' abc ', 'string'); - $this->assertEqual($result, "' abc '"); - - $result = $this->testDb->value('a bc', 'string'); - $this->assertEqual($result, "'a bc'"); - } /** * testValue method @@ -690,76 +530,6 @@ class DboSourceTest extends CakeTestCase { $this->assertEqual($this->testDb->config['prefix'], 'foo'); } -/** - * testRealQueries method - * - * @access public - * @return void - */ - function testRealQueries() { - $this->loadFixtures('Apple', 'Article', 'User', 'Comment', 'Tag', 'Sample'); - - $Apple = ClassRegistry::init('Apple'); - $Article = ClassRegistry::init('Article'); - - $result = $this->db->rawQuery('SELECT color, name FROM ' . $this->db->fullTableName('apples')); - $this->assertTrue(!empty($result)); - - $result = $this->db->fetchRow($result); - $expected = array($this->db->fullTableName('apples', false) => array( - 'color' => 'Red 1', - 'name' => 'Red Apple 1' - )); - $this->assertEqual($result, $expected); - - $result = $this->db->fetchAll('SELECT name FROM ' . $this->testDb->fullTableName('apples') . ' ORDER BY id'); - $expected = array( - array($this->db->fullTableName('apples', false) => array('name' => 'Red Apple 1')), - array($this->db->fullTableName('apples', false) => array('name' => 'Bright Red Apple')), - array($this->db->fullTableName('apples', false) => array('name' => 'green blue')), - array($this->db->fullTableName('apples', false) => array('name' => 'Test Name')), - array($this->db->fullTableName('apples', false) => array('name' => 'Blue Green')), - array($this->db->fullTableName('apples', false) => array('name' => 'My new apple')), - array($this->db->fullTableName('apples', false) => array('name' => 'Some odd color')) - ); - $this->assertEqual($result, $expected); - - $result = $this->db->field($this->testDb->fullTableName('apples', false), 'SELECT color, name FROM ' . $this->testDb->fullTableName('apples') . ' ORDER BY id'); - $expected = array( - 'color' => 'Red 1', - 'name' => 'Red Apple 1' - ); - $this->assertEqual($result, $expected); - - $Apple->unbindModel(array(), false); - $result = $this->db->read($Apple, array( - 'fields' => array($Apple->escapeField('name')), - 'conditions' => null, - 'recursive' => -1 - )); - $expected = array( - array('Apple' => array('name' => 'Red Apple 1')), - array('Apple' => array('name' => 'Bright Red Apple')), - array('Apple' => array('name' => 'green blue')), - array('Apple' => array('name' => 'Test Name')), - array('Apple' => array('name' => 'Blue Green')), - array('Apple' => array('name' => 'My new apple')), - array('Apple' => array('name' => 'Some odd color')) - ); - $this->assertEqual($result, $expected); - - $result = $this->db->read($Article, array( - 'fields' => array('id', 'user_id', 'title'), - 'conditions' => null, - 'recursive' => 1 - )); - - $this->assertTrue(Set::matches('/Article[id=1]', $result)); - $this->assertTrue(Set::matches('/Comment[id=1]', $result)); - $this->assertTrue(Set::matches('/Comment[id=2]', $result)); - $this->assertFalse(Set::matches('/Comment[id=10]', $result)); - } - /** * testName method * @@ -925,26 +695,6 @@ class DboSourceTest extends CakeTestCase { $this->assertEqual($log['log'][2], $expected); } -/** - * test that execute runs queries. - * - * @return void - */ - function testExecute() { - $query = 'SELECT * FROM ' . $this->testDb->fullTableName('articles') . ' WHERE 1 = 1'; - $this->db->took = null; - $this->db->affected = null; - $result = $this->db->execute($query, array('log' => false)); - $this->assertNotNull($result, 'No query performed! %s'); - $this->assertNull($this->db->took, 'Stats were set %s'); - $this->assertNull($this->db->affected, 'Stats were set %s'); - - $result = $this->db->execute($query); - $this->assertNotNull($result, 'No query performed! %s'); - $this->assertNotNull($this->db->took, 'Stats were not set %s'); - $this->assertNotNull($this->db->affected, 'Stats were not set %s'); - } - /** * test that query() returns boolean values from operations like CREATE TABLE * @@ -999,62 +749,7 @@ class DboSourceTest extends CakeTestCase { $this->assertEqual($expected, $result); } -/** - * test a full example of using virtual fields - * - * @return void - */ - function testVirtualFieldsFetch() { - $this->loadFixtures('Article', 'Comment'); - $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( - 'comment_count' => 'SELECT COUNT(*) FROM ' . $this->db->fullTableName('comments') . - ' WHERE Article.id = ' . $this->db->fullTableName('comments') . '.article_id' - ); - - $conditions = array('comment_count >' => 2); - $query = 'SELECT ' . join(',',$this->db->fields($Article, null, array('id', 'comment_count'))) . - ' FROM ' . $this->db->fullTableName($Article) . ' Article ' . $this->db->conditions($conditions, true, true, $Article); - $result = $this->db->fetchAll($query); - $expected = array(array( - 'Article' => array('id' => 1, 'comment_count' => 4) - )); - $this->assertEqual($expected, $result); - } - -/** - * test reading complex virtualFields with subqueries. - * - * @return void - */ - function testVirtualFieldsComplexRead() { - $this->loadFixtures('DataTest', 'Article', 'Comment'); - - $Article = ClassRegistry::init('Article'); - $commentTable = $this->db->fullTableName('comments'); - $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( - 'comment_count' => 'SELECT COUNT(*) FROM ' . $commentTable . - ' AS Comment WHERE Article.id = Comment.article_id' - ); - $result = $Article->find('all'); - $this->assertTrue(count($result) > 0); - $this->assertTrue($result[0]['Article']['comment_count'] > 0); - - $DataTest = ClassRegistry::init('DataTest'); - $DataTest->virtualFields = array( - 'complicated' => 'ACOS(SIN(20 * PI() / 180) - * SIN(DataTest.float * PI() / 180) - + COS(20 * PI() / 180) - * COS(DataTest.count * PI() / 180) - * COS((50 - DataTest.float) * PI() / 180) - ) * 180 / PI() * 60 * 1.1515 * 1.609344' - ); - $result = $DataTest->find('all'); - $this->assertTrue(count($result) > 0); - $this->assertTrue($result[0]['DataTest']['complicated'] > 0); - } /** * test the permutations of fullTableName() @@ -1082,6 +777,7 @@ class DboSourceTest extends CakeTestCase { * @return void */ function testReadOnlyCallingQueryAssociationWhenDefined() { + $this->loadFixtures('Article', 'User', 'ArticlesTag', 'Tag'); ConnectionManager::create('test_no_queryAssociation', array( 'datasource' => 'data' )); From 00a3eda4d0b6bd781b823e05ed385a30e11f0401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 10 Nov 2010 23:48:58 -0430 Subject: [PATCH 100/378] Fixing broken test because of change done in previous commit --- cake/libs/model/datasources/dbo/dbo_postgres.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 313036ac5..1fcc40500 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -339,7 +339,7 @@ class DboPostgres extends DboSource { } $count = count($fields); - if ($count >= 1 && !preg_match('/^\s*COUNT\(/', $fields[0])) { + if ($count >= 1 && !preg_match('/^\s*COUNT\(\*/', $fields[0])) { $result = array(); for ($i = 0; $i < $count; $i++) { if (!preg_match('/^.+\\(.*\\)/', $fields[$i]) && !preg_match('/\s+AS\s+/', $fields[$i])) { From 91e2d889006f0028930f59c2e7e22534c50f9f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 11 Nov 2010 00:22:08 -0430 Subject: [PATCH 101/378] Moving method back to DboSourceTest, as it was very difficult to adapt it to use mock objects --- .../model/datasources/dbo/dbo_mysql.test.php | 47 ------------------- .../model/datasources/dbo_source.test.php | 40 ++++++++++++++++ 2 files changed, 40 insertions(+), 47 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index ea73c627d..20ca65999 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -2846,53 +2846,6 @@ class DboMysqlTest extends CakeTestCase { } - -/** - * testStatements method - * - * @access public - * @return void - */ - function testStatements() { - $this->skipIf(true, 'Fix me'); - $this->loadFixtures('Article', 'User', 'Comment', 'Tag', 'Attachment', 'ArticlesTag'); - $Article = new Article(); - //$this->Dbo = $this->getMock('DboMysql', array('connect', 'execute', '_execute')); - - $result = $this->Dbo->update($Article, array('field1'), array('value1')); - $this->assertFalse($result); - $result = $this->Dbo->getLastQuery(); - $this->assertPattern('/^\s*UPDATE\s+' . $this->Dbo->fullTableName('articles') . '\s+SET\s+`field1`\s*=\s*\'value1\'\s+WHERE\s+1 = 1\s*$/', $result); - - $result = $this->Dbo->update($Article, array('field1'), array('2'), '2=2'); - $this->assertFalse($result); - $result = $this->Dbo->getLastQuery(); - $this->assertPattern('/^\s*UPDATE\s+' . $this->Dbo->fullTableName('articles') . ' AS `Article`\s+LEFT JOIN\s+' . $this->Dbo->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+SET\s+`Article`\.`field1`\s*=\s*2\s+WHERE\s+2\s*=\s*2\s*$/', $result); - - $result = $this->Dbo->delete($Article); - $this->assertTrue($result); - $result = $this->Dbo->getLastQuery(); - $this->assertPattern('/^\s*DELETE\s+FROM\s+' . $this->Dbo->fullTableName('articles') . '\s+WHERE\s+1 = 1\s*$/', $result); - - $result = $this->Dbo->delete($Article, true); - $this->assertTrue($result); - $result = $this->Dbo->getLastQuery(); - $this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->Dbo->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->Dbo->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+1\s*=\s*1\s*$/', $result); - - $result = $this->Dbo->delete($Article, '2=2'); - $this->assertTrue($result); - $result = $this->Dbo->getLastQuery(); - $this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->Dbo->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->Dbo->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+2\s*=\s*2\s*$/', $result); - - $result = $this->Dbo->hasAny($Article, '1=2'); - $this->assertFalse($result); - - $result = $this->Dbo->insertMulti('articles', array('field'), array('(1)', '(2)')); - $this->assertNull($result); - $result = $this->Dbo->getLastQuery(); - $this->assertPattern('/^\s*INSERT INTO\s+' . $this->Dbo->fullTableName('articles') . '\s+\(`field`\)\s+VALUES\s+\(1\),\s*\(2\)\s*$/', $result); - } - /** * test fields generating usable virtual fields to use in query * diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 0e13d38b6..b7926570a 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -800,4 +800,44 @@ class DboSourceTest extends CakeTestCase { $this->testDb->fields($Article, null, array('title', 'body', 'published')); $this->assertTrue(empty($this->testDb->methodCache['fields']), 'Cache not empty'); } + +/** + * testStatements method + * + * @access public + * @return void + */ + function testStatements() { + $this->skipIf(!$this->testDb instanceof DboMysql); + $this->loadFixtures('Article', 'User', 'Comment', 'Tag', 'Attachment', 'ArticlesTag'); + $Article = new Article(); + + $result = $this->testDb->update($Article, array('field1'), array('value1')); + $this->assertFalse($result); + $result = $this->testDb->getLastQuery(); + $this->assertPattern('/^\s*UPDATE\s+' . $this->testDb->fullTableName('articles') . '\s+SET\s+`field1`\s*=\s*\'value1\'\s+WHERE\s+1 = 1\s*$/', $result); + + $result = $this->testDb->update($Article, array('field1'), array('2'), '2=2'); + $this->assertFalse($result); + $result = $this->testDb->getLastQuery(); + $this->assertPattern('/^\s*UPDATE\s+' . $this->testDb->fullTableName('articles') . ' AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+SET\s+`Article`\.`field1`\s*=\s*2\s+WHERE\s+2\s*=\s*2\s*$/', $result); + + $result = $this->testDb->delete($Article); + $this->assertTrue($result); + $result = $this->testDb->getLastQuery(); + $this->assertPattern('/^\s*DELETE\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+WHERE\s+1 = 1\s*$/', $result); + + $result = $this->testDb->delete($Article, true); + $this->assertTrue($result); + $result = $this->testDb->getLastQuery(); + $this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+1\s*=\s*1\s*$/', $result); + + $result = $this->testDb->delete($Article, '2=2'); + $this->assertTrue($result); + $result = $this->testDb->getLastQuery(); + $this->assertPattern('/^\s*DELETE\s+`Article`\s+FROM\s+' . $this->testDb->fullTableName('articles') . '\s+AS `Article`\s+LEFT JOIN\s+' . $this->testDb->fullTableName('users') . ' AS `User` ON \(`Article`.`user_id` = `User`.`id`\)\s+WHERE\s+2\s*=\s*2\s*$/', $result); + + $result = $this->testDb->hasAny($Article, '1=2'); + $this->assertFalse($result); + } } From 1dfd3ce0b17568ca351322a2b49532998532685e Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 13 Nov 2010 13:40:00 -0200 Subject: [PATCH 102/378] Changing the auth value only if auth not is setted. --- cake/libs/http_socket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 3def34cea..7a595364e 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -442,7 +442,7 @@ class HttpSocket extends CakeSocket { */ protected function _setAuth() { if (empty($this->request['auth']['method'])) { - if (isset($this->request['uri']['user'], $this->request['uri']['pass'])) { + if (isset($this->request['uri']['user'], $this->request['uri']['pass']) && !isset($this->request['auth']['user'])) { $this->request['auth'] = array( 'method' => 'Basic', 'user' => $this->request['uri']['user'], From 1d56625f3a243e90733eb864fd2f4572abf6c713 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 13 Nov 2010 17:21:52 -0200 Subject: [PATCH 103/378] If method is false, dont send the authentication. Fixed throw message. --- cake/libs/http_socket.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 7a595364e..a903aa445 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -441,6 +441,9 @@ class HttpSocket extends CakeSocket { * @throws Exception */ protected function _setAuth() { + if ($this->request['auth']['method'] === false) { + return; + } if (empty($this->request['auth']['method'])) { if (isset($this->request['uri']['user'], $this->request['uri']['pass']) && !isset($this->request['auth']['user'])) { $this->request['auth'] = array( @@ -454,7 +457,7 @@ class HttpSocket extends CakeSocket { } $authClass = Inflector::camelize($this->request['auth']['method']) . 'Method'; if (!App::import('Lib', 'http/' . $authClass)) { - throw new Exception(__('Authentication method unknown.')); + throw new Exception(__('Unknown authentication method.')); } $authClass::authentication($this); } From 44629bd673e90ab65f42b871ae73c961ebac4118 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 13 Nov 2010 20:51:09 -0200 Subject: [PATCH 104/378] Support to digest method in HttpSocket. Thanks to jmcneese and Adrien Gibrat. --- cake/libs/http/digest_method.php | 103 ++++++++++ .../cases/libs/http/digest_method.test.php | 182 ++++++++++++++++++ 2 files changed, 285 insertions(+) create mode 100644 cake/libs/http/digest_method.php create mode 100644 cake/tests/cases/libs/http/digest_method.test.php diff --git a/cake/libs/http/digest_method.php b/cake/libs/http/digest_method.php new file mode 100644 index 000000000..42d0c9482 --- /dev/null +++ b/cake/libs/http/digest_method.php @@ -0,0 +1,103 @@ +request['auth']['user'], $http->request['auth']['pass'])) { + if (!isset($http->config['request']['auth']['realm']) && !self::_getServerInformation($http)) { + return; + } + $http->request['header']['Authorization'] = self::_generateHeader($http); + } + } + +/** + * Retrive information about the authetication + * + * @param HttpSocket $http + * @return boolean + */ + protected static function _getServerInformation(&$http) { + $originalRequest = $http->request; + $http->request['auth'] = array('method' => false); + $http->request($http->request); + $http->request = $originalRequest; + + if (empty($http->response['header']['Www-Authenticate'])) { + return false; + } + preg_match_all('@(\w+)=(?:(?:")([^"]+)"|([^\s,$]+))@', $http->response['header']['Www-Authenticate'], $matches, PREG_SET_ORDER); + foreach ($matches as $match) { + $http->config['request']['auth'][$match[1]] = $match[2]; + } + if (!empty($http->config['request']['auth']['qop']) && empty($http->config['request']['auth']['nc'])) { + $http->config['request']['auth']['nc'] = 1; + } + return true; + } + +/** + * Generate the header Authorization + * + * @param HttpSocket $http + * @return string + */ + protected static function _generateHeader(&$http) { + $a1 = md5($http->request['auth']['user'] . ':' . $http->config['request']['auth']['realm'] . ':' . $http->request['auth']['pass']); + $a2 = md5($http->request['method'] . ':' . $http->request['uri']['path']); + + if (empty($http->config['request']['auth']['qop'])) { + $response = md5($a1 . ':' . $http->config['request']['auth']['nonce'] . ':' . $a2); + } else { + $http->config['request']['auth']['cnonce'] = uniqid(); + $nc = sprintf('%08x', $http->config['request']['auth']['nc']++); + $response = md5($a1 . ':' . $http->config['request']['auth']['nonce'] . ':' . $nc . ':' . $http->config['request']['auth']['cnonce'] . ':auth:' . $a2); + } + + $authHeader = 'Digest '; + $authHeader .= 'username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $http->request['auth']['user']) . '", '; + $authHeader .= 'realm="' . $http->config['request']['auth']['realm'] . '", '; + $authHeader .= 'nonce="' . $http->config['request']['auth']['nonce'] . '", '; + $authHeader .= 'uri="' . $http->request['uri']['path'] . '", '; + $authHeader .= 'response="' . $response . '"'; + if (!empty($http->config['request']['auth']['opaque'])) { + $authHeader .= ', opaque="' . $http->config['request']['auth']['opaque'] . '"'; + } + if (!empty($http->config['request']['auth']['qop'])) { + $authHeader .= ', qop="auth", nc=' . $nc . ', cnonce="' . $http->config['request']['auth']['cnonce'] . '"'; + } + return $authHeader; + } +} diff --git a/cake/tests/cases/libs/http/digest_method.test.php b/cake/tests/cases/libs/http/digest_method.test.php new file mode 100644 index 000000000..c5a67542b --- /dev/null +++ b/cake/tests/cases/libs/http/digest_method.test.php @@ -0,0 +1,182 @@ + + * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice + * + * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests + * @package cake + * @subpackage cake.tests.cases.libs.http + * @since CakePHP(tm) v 2.0.0 + * @license MIT License (http://www.opensource.org/licenses/mit-license.php) + */ + +App::import('Core', 'HttpSocket'); +App::import('Lib', 'http/DigestMethod'); + +class DigestHttpSocket extends HttpSocket { + +/** + * nextHeader attribute + * + * @var string + */ + public $nextHeader = ''; + +/** + * request method + * + * @param mixed $request + * @return void + */ + public function request($request) { + $this->response['header']['Www-Authenticate'] = $this->nextHeader; + } + +} + +/** + * DigestMethodTest class + * + * @package cake + * @subpackage cake.tests.cases.libs.http + */ +class DigestMethodTest extends CakeTestCase { + +/** + * Socket property + * + * @var mixed null + */ + public $HttpSocket = null; + +/** + * This function sets up a HttpSocket instance we are going to use for testing + * + * @return void + */ + public function setUp() { + $this->HttpSocket = new DigestHttpSocket(); + $this->HttpSocket->request['method'] = 'GET'; + $this->HttpSocket->request['uri']['path'] = '/'; + $this->HttpSocket->request['auth'] = array( + 'method' => 'Digest', + 'user' => 'admin', + 'pass' => '1234' + ); + } + +/** + * We use this function to clean up after the test case was executed + * + * @return void + */ + function tearDown() { + unset($this->HttpSocket); + } + +/** + * testBasic method + * + * @return void + */ + public function testBasic() { + $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; + $this->HttpSocket->config['request']['auth'] = array(); + $this->assertFalse(isset($this->HttpSocket->request['header']['Authorization'])); + DigestMethod::authentication($this->HttpSocket); + $this->assertTrue(isset($this->HttpSocket->request['header']['Authorization'])); + $this->assertEqual($this->HttpSocket->config['request']['auth']['realm'], 'The batcave'); + $this->assertEqual($this->HttpSocket->config['request']['auth']['nonce'], '4cded326c6c51'); + } + +/** + * testQop method + * + * @return void + */ + public function testQop() { + $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; + $this->HttpSocket->config['request']['auth'] = array(); + DigestMethod::authentication($this->HttpSocket); + $expected = 'Digest username="admin", realm="The batcave", nonce="4cded326c6c51", uri="/", response="da7e2a46b471d77f70a9bb3698c8902b"'; + $this->assertEqual($expected, $this->HttpSocket->request['header']['Authorization']); + $this->assertFalse(isset($this->HttpSocket->config['request']['auth']['qop'])); + $this->assertFalse(isset($this->HttpSocket->config['request']['auth']['nc'])); + + $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",qop="auth"'; + $this->HttpSocket->config['request']['auth'] = array(); + DigestMethod::authentication($this->HttpSocket); + $expected = '@Digest username="admin", realm="The batcave", nonce="4cded326c6c51", uri="/", response="[a-z0-9]{32}", qop="auth", nc=00000001, cnonce="[a-z0-9]+"@'; + $this->assertPattern($expected, $this->HttpSocket->request['header']['Authorization']); + $this->assertEqual($this->HttpSocket->config['request']['auth']['qop'], 'auth'); + $this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 2); + } + +/** + * testOpaque method + * + * @return void + */ + public function testOpaque() { + $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; + $this->HttpSocket->config['request']['auth'] = array(); + DigestMethod::authentication($this->HttpSocket); + $this->assertFalse(strpos($this->HttpSocket->request['header']['Authorization'], 'opaque="d8ea7aa61a1693024c4cc3a516f49b3c"')); + + $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",opaque="d8ea7aa61a1693024c4cc3a516f49b3c"'; + $this->HttpSocket->config['request']['auth'] = array(); + DigestMethod::authentication($this->HttpSocket); + $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'opaque="d8ea7aa61a1693024c4cc3a516f49b3c"') > 0); + } + +/** + * testMultipleRequest method + * + * @return void + */ + public function testMultipleRequest() { + $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",qop="auth"'; + $this->HttpSocket->config['request']['auth'] = array(); + DigestMethod::authentication($this->HttpSocket); + $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000001') > 0); + $this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 2); + + DigestMethod::authentication($this->HttpSocket); + $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000002') > 0); + $this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 3); + $responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response='); + $response = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32); + + $this->HttpSocket->nextHeader = ''; + DigestMethod::authentication($this->HttpSocket); + $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000003') > 0); + $this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 4); + $responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response='); + $response2 = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32); + $this->assertNotEqual($response, $response2); + } + +/** + * testPathChanged method + * + * @return void + */ + public function testPathChanged() { + $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; + $this->HttpSocket->request['uri']['path'] = '/admin'; + $this->HttpSocket->config['request']['auth'] = array(); + DigestMethod::authentication($this->HttpSocket); + $responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response='); + $response = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32); + $this->assertNotEqual($response, 'da7e2a46b471d77f70a9bb3698c8902b'); + } + +} \ No newline at end of file From 85607a9963ea375dc4d01bd098f8dbdcaa051f8b Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 13 Nov 2010 21:44:11 -0200 Subject: [PATCH 105/378] Removed interference in the name of the headers. --- cake/libs/http_socket.php | 28 ++++++++++------------ cake/tests/cases/libs/http_socket.test.php | 14 +++++------ 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index a903aa445..0df3a63e1 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -864,6 +864,7 @@ class HttpSocket extends CakeSocket { * Builds the header. * * @param array $header Header to build + * @param string $mode * @return string Header built from array */ protected function _buildHeader($header, $mode = 'standard') { @@ -873,6 +874,17 @@ class HttpSocket extends CakeSocket { return false; } + $fieldsInHeader = array(); + foreach ($header as $key => $value) { + $lowKey = strtolower($key); + if (array_key_exists($lowKey, $fieldsInHeader)) { + $header[$fieldsInHeader[$lowKey]] = $value; + unset($header[$key]); + } else { + $fieldsInHeader[$lowKey] = $key; + } + } + $returnHeader = ''; foreach ($header as $field => $contents) { if (is_array($contents) && $mode == 'standard') { @@ -896,16 +908,6 @@ class HttpSocket extends CakeSocket { */ protected function _parseHeader($header) { if (is_array($header)) { - foreach ($header as $field => $value) { - unset($header[$field]); - $field = strtolower($field); - preg_match_all('/(?:^|(?<=-))[a-z]/U', $field, $offsets, PREG_OFFSET_CAPTURE); - - foreach ($offsets[0] as $offset) { - $field = substr_replace($field, strtoupper($offset[0]), $offset[1], 1); - } - $header[$field] = $value; - } return $header; } elseif (!is_string($header)) { return false; @@ -922,12 +924,6 @@ class HttpSocket extends CakeSocket { $field = $this->_unescapeToken($field); - $field = strtolower($field); - preg_match_all('/(?:^|(?<=-))[a-z]/U', $field, $offsets, PREG_OFFSET_CAPTURE); - foreach ($offsets[0] as $offset) { - $field = substr_replace($field, strtoupper($offset[0]), $offset[1], 1); - } - if (!isset($header[$field])) { $header[$field] = $value; } else { diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index beb0fc0c5..fe6ec1c70 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -529,7 +529,7 @@ class HttpSocketTest extends CakeTestCase { $expectation['request']['raw'] = $expectation['request']['line'].$expectation['request']['header']."\r\n".$raw; $r = array('config' => $this->Socket->config, 'request' => $this->Socket->request); - $v = $this->assertEquals($r, $expectation, '%s in test #'.$i.' '); + $v = $this->assertEquals($r, $expectation, 'Failed test #'.$i.' '); $expectation['request']['raw'] = $raw; } @@ -948,13 +948,13 @@ class HttpSocketTest extends CakeTestCase { $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n0\r\nfoo-header: bar\r\ncake: PHP\r\n\r\n"; $r = $this->Socket->decodeChunkedBody($encoded); $this->assertEquals($r['body'], $decoded); - $this->assertEquals($r['header'], array('Foo-Header' => 'bar', 'Cake' => 'PHP')); + $this->assertEquals($r['header'], array('foo-header' => 'bar', 'cake' => 'PHP')); $this->Socket->quirksMode = true; $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\nfoo-header: bar\r\ncake: PHP\r\n\r\n"; $r = $this->Socket->decodeChunkedBody($encoded); $this->assertEquals($r['body'], $decoded); - $this->assertEquals($r['header'], array('Foo-Header' => 'bar', 'Cake' => 'PHP')); + $this->assertEquals($r['header'], array('foo-header' => 'bar', 'cake' => 'PHP')); $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n"; $r = $this->Socket->decodeChunkedBody($encoded); @@ -1393,7 +1393,7 @@ class HttpSocketTest extends CakeTestCase { $this->Socket->reset(); $r = $this->Socket->parseHeader(array('foo' => 'Bar', 'fOO-bAr' => 'quux')); - $this->assertEquals($r, array('Foo' => 'Bar', 'Foo-Bar' => 'quux')); + $this->assertEquals($r, array('foo' => 'Bar', 'fOO-bAr' => 'quux')); $r = $this->Socket->parseHeader(true); $this->assertEquals($r, false); @@ -1416,9 +1416,9 @@ class HttpSocketTest extends CakeTestCase { $header = "people: Jim,John\r\nfoo-LAND: Bar\r\ncAKe-PHP: rocks\r\n"; $r = $this->Socket->parseHeader($header); $expected = array( - 'People' => 'Jim,John' - , 'Foo-Land' => 'Bar' - , 'Cake-Php' => 'rocks' + 'people' => 'Jim,John' + , 'foo-LAND' => 'Bar' + , 'cAKe-PHP' => 'rocks' ); $this->assertEquals($r, $expected); From 974161cf3a75a791571b59dc506dc71035abd2ca Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 13 Nov 2010 21:47:25 -0200 Subject: [PATCH 106/378] Changed the name of header to use in Digest method. --- cake/libs/http/digest_method.php | 4 ++-- cake/tests/cases/libs/http/digest_method.test.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/http/digest_method.php b/cake/libs/http/digest_method.php index 42d0c9482..654dc60fb 100644 --- a/cake/libs/http/digest_method.php +++ b/cake/libs/http/digest_method.php @@ -55,10 +55,10 @@ class DigestMethod { $http->request($http->request); $http->request = $originalRequest; - if (empty($http->response['header']['Www-Authenticate'])) { + if (empty($http->response['header']['WWW-Authenticate'])) { return false; } - preg_match_all('@(\w+)=(?:(?:")([^"]+)"|([^\s,$]+))@', $http->response['header']['Www-Authenticate'], $matches, PREG_SET_ORDER); + preg_match_all('@(\w+)=(?:(?:")([^"]+)"|([^\s,$]+))@', $http->response['header']['WWW-Authenticate'], $matches, PREG_SET_ORDER); foreach ($matches as $match) { $http->config['request']['auth'][$match[1]] = $match[2]; } diff --git a/cake/tests/cases/libs/http/digest_method.test.php b/cake/tests/cases/libs/http/digest_method.test.php index c5a67542b..8b1715b7f 100644 --- a/cake/tests/cases/libs/http/digest_method.test.php +++ b/cake/tests/cases/libs/http/digest_method.test.php @@ -37,7 +37,7 @@ class DigestHttpSocket extends HttpSocket { * @return void */ public function request($request) { - $this->response['header']['Www-Authenticate'] = $this->nextHeader; + $this->response['header']['WWW-Authenticate'] = $this->nextHeader; } } From 7bea5d941070ec8f8767b7e9d6ef3fccb4dd89df Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 14 Nov 2010 23:56:12 -0200 Subject: [PATCH 107/378] Added the http directory to AllSocket tests. --- cake/tests/cases/libs/all_socket.test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/all_socket.test.php b/cake/tests/cases/libs/all_socket.test.php index 60802436e..896738957 100644 --- a/cake/tests/cases/libs/all_socket.test.php +++ b/cake/tests/cases/libs/all_socket.test.php @@ -34,10 +34,11 @@ class AllSocketTest extends PHPUnit_Framework_TestSuite { * @return void */ public static function suite() { - $suite = new PHPUnit_Framework_TestSuite('All Socket related class tests'); + $suite = new CakeTestSuite('All Socket related class tests'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_socket.test.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'http_socket.test.php'); + $suite->addTestDirectory(CORE_TEST_CASES . DS . 'libs' . DS . 'http'); return $suite; } } \ No newline at end of file From 7e0d34903eede19eaff8efac542274d359b60e5f Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 15 Nov 2010 00:09:52 -0200 Subject: [PATCH 108/378] Removed use of reference in params of http methods. --- cake/libs/http/basic_method.php | 2 +- cake/libs/http/digest_method.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/libs/http/basic_method.php b/cake/libs/http/basic_method.php index da7951c6c..a0d1590c7 100644 --- a/cake/libs/http/basic_method.php +++ b/cake/libs/http/basic_method.php @@ -33,7 +33,7 @@ class BasicMethod { * @return void * @throws Exception */ - public static function authentication(&$http) { + public static function authentication(HttpSocket $http) { if (isset($http->request['auth']['user'], $http->request['auth']['pass'])) { $http->request['header']['Authorization'] = 'Basic ' . base64_encode($http->request['auth']['user'] . ':' . $http->request['auth']['pass']); } diff --git a/cake/libs/http/digest_method.php b/cake/libs/http/digest_method.php index 654dc60fb..29c068bca 100644 --- a/cake/libs/http/digest_method.php +++ b/cake/libs/http/digest_method.php @@ -34,7 +34,7 @@ class DigestMethod { * @throws Exception * @link http://www.ietf.org/rfc/rfc2617.txt */ - public static function authentication(&$http) { + public static function authentication(HttpSocket $http) { if (isset($http->request['auth']['user'], $http->request['auth']['pass'])) { if (!isset($http->config['request']['auth']['realm']) && !self::_getServerInformation($http)) { return; @@ -49,7 +49,7 @@ class DigestMethod { * @param HttpSocket $http * @return boolean */ - protected static function _getServerInformation(&$http) { + protected static function _getServerInformation(HttpSocket $http) { $originalRequest = $http->request; $http->request['auth'] = array('method' => false); $http->request($http->request); @@ -74,7 +74,7 @@ class DigestMethod { * @param HttpSocket $http * @return string */ - protected static function _generateHeader(&$http) { + protected static function _generateHeader(HttpSocket $http) { $a1 = md5($http->request['auth']['user'] . ':' . $http->config['request']['auth']['realm'] . ':' . $http->request['auth']['pass']); $a2 = md5($http->request['method'] . ':' . $http->request['uri']['path']); From 5a881c461e28e07d36af70545535a0d8a5cf42cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 16 Nov 2010 01:22:29 -0430 Subject: [PATCH 109/378] Fixing acl testcase so it runs smoothly on postgres --- cake/tests/cases/console/shells/acl.test.php | 19 +++++++++++----- cake/tests/fixtures/aco_fixture.php | 24 ++++++++++---------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/cake/tests/cases/console/shells/acl.test.php b/cake/tests/cases/console/shells/acl.test.php index 305ee1ebc..f77642bf9 100644 --- a/cake/tests/cases/console/shells/acl.test.php +++ b/cake/tests/cases/console/shells/acl.test.php @@ -206,8 +206,9 @@ class AclShellTest extends CakeTestCase { $this->Task->expects($this->at(0))->method('out') ->with($this->matchesRegularExpression('/granted/'), true); $this->Task->grant(); + $node = $this->Task->Acl->Aro->node(array('model' => 'AuthUser', 'foreign_key' => 2)); + $node = $this->Task->Acl->Aro->read(null, $node[0]['Aro']['id']); - $node = $this->Task->Acl->Aro->read(null, 4); $this->assertFalse(empty($node['Aco'][0])); $this->assertEqual($node['Aco'][0]['Permission']['_create'], 1); } @@ -224,7 +225,8 @@ class AclShellTest extends CakeTestCase { $this->Task->deny(); - $node = $this->Task->Acl->Aro->read(null, 4); + $node = $this->Task->Acl->Aro->node(array('model' => 'AuthUser', 'foreign_key' => 2)); + $node = $this->Task->Acl->Aro->read(null, $node[0]['Aro']['id']); $this->assertFalse(empty($node['Aco'][0])); $this->assertEqual($node['Aco'][0]['Permission']['_create'], -1); } @@ -274,7 +276,8 @@ class AclShellTest extends CakeTestCase { $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'all'); $this->Task->inherit(); - $node = $this->Task->Acl->Aro->read(null, 4); + $node = $this->Task->Acl->Aro->node(array('model' => 'AuthUser', 'foreign_key' => 2)); + $node = $this->Task->Acl->Aro->read(null, $node[0]['Aro']['id']); $this->assertFalse(empty($node['Aco'][0])); $this->assertEqual($node['Aco'][0]['Permission']['_create'], 0); } @@ -286,9 +289,13 @@ class AclShellTest extends CakeTestCase { */ public function testGetPath() { $this->Task->args = array('aro', 'AuthUser.2'); - $this->Task->expects($this->at(2))->method('out')->with('[1] ROOT'); - $this->Task->expects($this->at(3))->method('out')->with(' [2] admins'); - $this->Task->expects($this->at(4))->method('out')->with(' [4] Elrond'); + $node = $this->Task->Acl->Aro->node(array('model' => 'AuthUser', 'foreign_key' => 2)); + $first = $node[0]['Aro']['id']; + $second = $node[1]['Aro']['id']; + $last = $node[2]['Aro']['id']; + $this->Task->expects($this->at(2))->method('out')->with('['.$last.'] ROOT'); + $this->Task->expects($this->at(3))->method('out')->with(' ['.$second.'] admins'); + $this->Task->expects($this->at(4))->method('out')->with(' ['.$first.'] Elrond'); $this->Task->getPath(); } diff --git a/cake/tests/fixtures/aco_fixture.php b/cake/tests/fixtures/aco_fixture.php index e6c649a15..be296aaf8 100644 --- a/cake/tests/fixtures/aco_fixture.php +++ b/cake/tests/fixtures/aco_fixture.php @@ -57,17 +57,17 @@ class AcoFixture extends CakeTestFixture { * @access public */ public $records = array( - array('parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT', 'lft' => 1, 'rght' => 24), - array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Controller1', 'lft' => 2, 'rght' => 9), - array('parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'action1', 'lft' => 3, 'rght' => 6), - array('parent_id' => 3, 'model' => null, 'foreign_key' => null, 'alias' => 'record1', 'lft' => 4, 'rght' => 5), - array('parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'action2', 'lft' => 7, 'rght' => 8), - array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Controller2','lft' => 10, 'rght' => 17), - array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'action1', 'lft' => 11, 'rght' => 14), - array('parent_id' => 7, 'model' => null, 'foreign_key' => null, 'alias' => 'record1', 'lft' => 12, 'rght' => 13), - array('parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'action2', 'lft' => 15, 'rght' => 16), - array('parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Users', 'lft' => 18, 'rght' => 23), - array('parent_id' => 9, 'model' => null, 'foreign_key' => null, 'alias' => 'Users', 'lft' => 19, 'rght' => 22), - array('parent_id' => 10, 'model' => null, 'foreign_key' => null, 'alias' => 'view', 'lft' => 20, 'rght' => 21), + array('id' => 1, 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT', 'lft' => 1, 'rght' => 24), + array('id' => 2, 'parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Controller1', 'lft' => 2, 'rght' => 9), + array('id' => 3, 'parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'action1', 'lft' => 3, 'rght' => 6), + array('id' => 4, 'parent_id' => 3, 'model' => null, 'foreign_key' => null, 'alias' => 'record1', 'lft' => 4, 'rght' => 5), + array('id' => 5, 'parent_id' => 2, 'model' => null, 'foreign_key' => null, 'alias' => 'action2', 'lft' => 7, 'rght' => 8), + array('id' => 6, 'parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Controller2','lft' => 10, 'rght' => 17), + array('id' => 7, 'parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'action1', 'lft' => 11, 'rght' => 14), + array('id' => 8, 'parent_id' => 7, 'model' => null, 'foreign_key' => null, 'alias' => 'record1', 'lft' => 12, 'rght' => 13), + array('id' => 9, 'parent_id' => 6, 'model' => null, 'foreign_key' => null, 'alias' => 'action2', 'lft' => 15, 'rght' => 16), + array('id' => 10, 'parent_id' => 1, 'model' => null, 'foreign_key' => null, 'alias' => 'Users', 'lft' => 18, 'rght' => 23), + array('id' => 11, 'parent_id' => 9, 'model' => null, 'foreign_key' => null, 'alias' => 'Users', 'lft' => 19, 'rght' => 22), + array('id' => 12, 'parent_id' => 10, 'model' => null, 'foreign_key' => null, 'alias' => 'view', 'lft' => 20, 'rght' => 21), ); } From a335891eba84e3576b4d6cf5c379bef38bcf4070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 16 Nov 2010 02:02:08 -0430 Subject: [PATCH 110/378] mapping lastNumRows to lastAffectedRows as it is not possible to do the first one using PDO --- cake/libs/model/datasources/dbo_source.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index e9f14e522..4eacfcfdc 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -299,8 +299,7 @@ class DboSource extends DataSource { if ($options['log']) { $this->took = round((microtime(true) - $t) * 1000, 0); - $this->affected = $this->lastAffected(); - //$this->numRows = $this->lastNumRows(); + $this->numRows = $this->affected = $this->lastAffected(); $this->logQuery($sql); } @@ -376,14 +375,7 @@ class DboSource extends DataSource { * @return integer Number of rows in resultset */ function lastNumRows($source = null) { - if ($this->hasResult()) { - $i = 0; - foreach ($this->_result as $row) { - $i++; - } - return $i; - } - return null; + return $this->lastAffected($source); } /** From 1326707c9d1c3edb0fb2e2b1006d7fbd483e83b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 16 Nov 2010 22:56:23 -0430 Subject: [PATCH 111/378] Implementing transaction nesting, this will allow to open multiple transactions that will only be commited if all transactions succesfully calls commit() --- cake/libs/model/datasources/dbo_source.php | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 4eacfcfdc..003c6acca 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1895,14 +1895,14 @@ class DboSource extends DataSource { /** * Begin a transaction * - * @param model $model * @return boolean True on success, false on fail * (i.e. if the database/model does not support transactions, * or a transaction has not started). */ - public function begin(&$model) { - if (parent::begin($model) && $this->execute($this->_commands['begin'])) { + public function begin() { + if ($this->_transactionStarted || $this->_connection->beginTransaction()) { $this->_transactionStarted = true; + $this->_transactionNesting++; return true; } return false; @@ -1911,14 +1911,18 @@ class DboSource extends DataSource { /** * Commit a transaction * - * @param model $model * @return boolean True on success, false on fail * (i.e. if the database/model does not support transactions, * or a transaction has not started). */ - public function commit(&$model) { - if (parent::commit($model) && $this->execute($this->_commands['commit'])) { - $this->_transactionStarted = false; + public function commit() { + if ($this->_transactionStarted) { + $this->_transactionNesting--; + if ($this->_transactionNesting <= 0) { + $this->_transactionStarted = false; + $this->_transactionNesting = 0; + return $this->_connection->commit(); + } return true; } return false; @@ -1927,14 +1931,14 @@ class DboSource extends DataSource { /** * Rollback a transaction * - * @param model $model * @return boolean True on success, false on fail * (i.e. if the database/model does not support transactions, * or a transaction has not started). */ - public function rollback(&$model) { - if (parent::rollback($model) && $this->execute($this->_commands['rollback'])) { + public function rollback() { + if ($this->_transactionStarted && $this->_connection->rollBack()) { $this->_transactionStarted = false; + $this->_transactionNesting = 0; return true; } return false; From c0f10437eae7ecee01bd81e3a6b8af99e2d11021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 16 Nov 2010 23:14:48 -0430 Subject: [PATCH 112/378] Adding a few transactions to speed up a little tests involving fixtures --- cake/libs/model/datasources/dbo_source.php | 3 ++- cake/tests/lib/cake_fixture_manager.php | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 003c6acca..df3c2dfa6 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -2687,11 +2687,12 @@ class DboSource extends DataSource { $count = count($values); $sql = "INSERT INTO {$table} ({$fields}) VALUES ({$holder})"; $statement = $this->_connection->prepare($sql); + $this->begin(); for ($x = 0; $x < $count; $x++) { $statement->execute($values[$x]); $statement->closeCursor(); } - return true; + return $this->commit(); } /** diff --git a/cake/tests/lib/cake_fixture_manager.php b/cake/tests/lib/cake_fixture_manager.php index 2643335f3..a7718e49e 100644 --- a/cake/tests/lib/cake_fixture_manager.php +++ b/cake/tests/lib/cake_fixture_manager.php @@ -206,6 +206,7 @@ class CakeFixtureManager { return; } + $test->db->begin(); foreach ($fixtures as $f) { if (!empty($this->_loaded[$f])) { $fixture = $this->_loaded[$f]; @@ -213,6 +214,7 @@ class CakeFixtureManager { $fixture->insert($test->db); } } + $test->db->commit(); } /** From 40418de21814d9bd66da1d7add11977457df8857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 16 Nov 2010 23:59:24 -0430 Subject: [PATCH 113/378] Freeing up some memory in dbos after the result set has been completly fetched. Adding dbo_mysql and dbo_postgres to the AllDAtabase testsuite --- cake/libs/model/datasources/dbo/dbo_mysql.php | 8 ++++++++ cake/libs/model/datasources/dbo/dbo_postgres.php | 5 +++++ cake/libs/model/datasources/dbo_source.php | 2 ++ cake/tests/cases/libs/all_database.test.php | 9 ++++++++- .../cases/libs/model/datasources/dbo/dbo_mysql.test.php | 1 + .../libs/model/datasources/dbo/dbo_postgres.test.php | 1 + 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 102e4890f..5936b0958 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -187,6 +187,7 @@ class DboMysql extends DboSource { $result = $this->_execute('SHOW TABLES FROM ' . $this->config['database']); if (!$result) { + $result->closeCursor(); return array(); } else { $tables = array(); @@ -194,6 +195,8 @@ class DboMysql extends DboSource { while ($line = $result->fetch()) { $tables[] = $line[0]; } + + $result->closeCursor(); parent::listSources($tables); return $tables; } @@ -245,6 +248,7 @@ class DboMysql extends DboSource { } return $resultRow; } else { + $this->_result->closeCursor(); return false; } } @@ -322,6 +326,7 @@ class DboMysql extends DboSource { } } $this->__cacheDescription($this->fullTableName($model, false), $fields); + $cols->closeCursor(); return $fields; } @@ -437,6 +442,7 @@ class DboMysql extends DboSource { $index[$idx->Key_name]['column'] = $col; } } + $indices->closeCursor(); } return $index; } @@ -596,6 +602,7 @@ class DboMysql extends DboSource { $result = $this->_execute('SHOW TABLE STATUS ' . $condition, $params); if (!$result) { + $result->closeCursor(); return array(); } else { $tables = array(); @@ -609,6 +616,7 @@ class DboMysql extends DboSource { } } } + $result->closeCursor(); if (is_string($name)) { return $tables[$name]; } diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 1fcc40500..bebbb5447 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -164,6 +164,7 @@ class DboPostgres extends DboSource { $result = $this->_execute($sql, array($schema)); if (!$result) { + $result->closeCursor(); return array(); } else { $tables = array(); @@ -172,6 +173,7 @@ class DboPostgres extends DboSource { $tables[] = $item->name; } + $result->closeCursor(); parent::listSources($tables); return $tables; } @@ -247,6 +249,8 @@ class DboPostgres extends DboSource { if (isset($model->sequence)) { $this->_sequenceMap[$table][$model->primaryKey] = $model->sequence; } + + $cols->closeCursor(); return $fields; } @@ -717,6 +721,7 @@ class DboPostgres extends DboSource { } return $resultRow; } else { + $this->_result->closeCursor(); return false; } } diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index df3c2dfa6..9d4bb8e72 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -333,9 +333,11 @@ class DboSource extends DataSource { if (!$query->execute($params)) { $this->_results = $query; $this->error = $this->lastError($query); + $query->closeCursor(); return false; } if (!$query->columnCount()) { + $query->closeCursor(); return true; } return $query; diff --git a/cake/tests/cases/libs/all_database.test.php b/cake/tests/cases/libs/all_database.test.php index 797541d05..39aa816ac 100644 --- a/cake/tests/cases/libs/all_database.test.php +++ b/cake/tests/cases/libs/all_database.test.php @@ -38,7 +38,14 @@ class AllDatabaseTest extends PHPUnit_Framework_TestSuite { $path = CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS; - $tasks = array('db_acl', 'cake_schema', 'connection_manager', 'datasources' . DS . 'dbo_source'); + $tasks = array( + 'db_acl', + 'cake_schema', + 'connection_manager', + 'datasources' . DS . 'dbo_source', + 'datasources' . DS . 'dbo' . DS . 'dbo_mysql', + 'datasources' . DS . 'dbo' . DS . 'dbo_postgres' + ); foreach ($tasks as $task) { $suite->addTestFile($path . $task . '.test.php'); } diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index e0e3e501e..d08c638c3 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -62,6 +62,7 @@ class DboMysqlTest extends CakeTestCase { */ public function setUp() { $this->Dbo = ConnectionManager::getDataSource('test'); + $this->skipIf(!($this->Dbo instanceof DboMysql)); if ($this->Dbo->config['driver'] !== 'mysql') { $this->markTestSkipped('The MySQL extension is not available.'); } diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index b44d50104..1338ed791 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -244,6 +244,7 @@ class DboPostgresTest extends CakeTestCase { public function setUp() { Configure::write('Cache.disable', true); $this->Dbo = ConnectionManager::getDataSource('test'); + $this->skipIf(!($this->Dbo instanceof DboPostgres)); $this->Dbo2 = new DboPostgresTestDb($this->Dbo->config, false); $this->skipUnless($this->Dbo->config['driver'] == 'postgres', 'PostgreSQL connection not available'); $this->model = new PostgresTestModel(); From 3056fbf680572fc63b2e53f7de5355fc60051c86 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 20 Nov 2010 17:47:35 -0200 Subject: [PATCH 114/378] Changing authentication classes to use suffix Authentication instead of Method. --- ...ic_method.php => basic_authentication.php} | 2 +- ...t_method.php => digest_authentication.php} | 2 +- cake/libs/http_socket.php | 2 +- ...test.php => basic_authentication.test.php} | 4 +-- ...est.php => digest_authentication.test.php} | 26 +++++++++---------- 5 files changed, 18 insertions(+), 18 deletions(-) rename cake/libs/http/{basic_method.php => basic_authentication.php} (97%) rename cake/libs/http/{digest_method.php => digest_authentication.php} (99%) rename cake/tests/cases/libs/http/{basic_method.test.php => basic_authentication.test.php} (92%) rename cake/tests/cases/libs/http/{digest_method.test.php => digest_authentication.test.php} (89%) diff --git a/cake/libs/http/basic_method.php b/cake/libs/http/basic_authentication.php similarity index 97% rename from cake/libs/http/basic_method.php rename to cake/libs/http/basic_authentication.php index a0d1590c7..7cd01b7cb 100644 --- a/cake/libs/http/basic_method.php +++ b/cake/libs/http/basic_authentication.php @@ -24,7 +24,7 @@ * @package cake * @subpackage cake.cake.libs.http */ -class BasicMethod { +class BasicAuthentication { /** * Authentication diff --git a/cake/libs/http/digest_method.php b/cake/libs/http/digest_authentication.php similarity index 99% rename from cake/libs/http/digest_method.php rename to cake/libs/http/digest_authentication.php index 29c068bca..b25c6c971 100644 --- a/cake/libs/http/digest_method.php +++ b/cake/libs/http/digest_authentication.php @@ -24,7 +24,7 @@ * @package cake * @subpackage cake.cake.libs.http */ -class DigestMethod { +class DigestAuthentication { /** * Authentication diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 0df3a63e1..da67a28ab 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -455,7 +455,7 @@ class HttpSocket extends CakeSocket { return; } } - $authClass = Inflector::camelize($this->request['auth']['method']) . 'Method'; + $authClass = Inflector::camelize($this->request['auth']['method']) . 'Authentication'; if (!App::import('Lib', 'http/' . $authClass)) { throw new Exception(__('Unknown authentication method.')); } diff --git a/cake/tests/cases/libs/http/basic_method.test.php b/cake/tests/cases/libs/http/basic_authentication.test.php similarity index 92% rename from cake/tests/cases/libs/http/basic_method.test.php rename to cake/tests/cases/libs/http/basic_authentication.test.php index c9d487f70..9843e4815 100644 --- a/cake/tests/cases/libs/http/basic_method.test.php +++ b/cake/tests/cases/libs/http/basic_authentication.test.php @@ -19,7 +19,7 @@ */ App::import('Core', 'HttpSocket'); -App::import('Lib', 'http/BasicMethod'); +App::import('Lib', 'http/BasicAuthentication'); /** * BasicMethodTest class @@ -42,7 +42,7 @@ class BasicMethodTest extends CakeTestCase { 'pass' => 'secret' ); - BasicMethod::authentication($http); + BasicAuthentication::authentication($http); $this->assertEqual($http->request['header']['Authorization'], 'Basic bWFyazpzZWNyZXQ='); } diff --git a/cake/tests/cases/libs/http/digest_method.test.php b/cake/tests/cases/libs/http/digest_authentication.test.php similarity index 89% rename from cake/tests/cases/libs/http/digest_method.test.php rename to cake/tests/cases/libs/http/digest_authentication.test.php index 8b1715b7f..7862f3147 100644 --- a/cake/tests/cases/libs/http/digest_method.test.php +++ b/cake/tests/cases/libs/http/digest_authentication.test.php @@ -1,6 +1,6 @@ HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; $this->HttpSocket->config['request']['auth'] = array(); $this->assertFalse(isset($this->HttpSocket->request['header']['Authorization'])); - DigestMethod::authentication($this->HttpSocket); + DigestAuthentication::authentication($this->HttpSocket); $this->assertTrue(isset($this->HttpSocket->request['header']['Authorization'])); $this->assertEqual($this->HttpSocket->config['request']['auth']['realm'], 'The batcave'); $this->assertEqual($this->HttpSocket->config['request']['auth']['nonce'], '4cded326c6c51'); @@ -105,7 +105,7 @@ class DigestMethodTest extends CakeTestCase { public function testQop() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; $this->HttpSocket->config['request']['auth'] = array(); - DigestMethod::authentication($this->HttpSocket); + DigestAuthentication::authentication($this->HttpSocket); $expected = 'Digest username="admin", realm="The batcave", nonce="4cded326c6c51", uri="/", response="da7e2a46b471d77f70a9bb3698c8902b"'; $this->assertEqual($expected, $this->HttpSocket->request['header']['Authorization']); $this->assertFalse(isset($this->HttpSocket->config['request']['auth']['qop'])); @@ -113,7 +113,7 @@ class DigestMethodTest extends CakeTestCase { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",qop="auth"'; $this->HttpSocket->config['request']['auth'] = array(); - DigestMethod::authentication($this->HttpSocket); + DigestAuthentication::authentication($this->HttpSocket); $expected = '@Digest username="admin", realm="The batcave", nonce="4cded326c6c51", uri="/", response="[a-z0-9]{32}", qop="auth", nc=00000001, cnonce="[a-z0-9]+"@'; $this->assertPattern($expected, $this->HttpSocket->request['header']['Authorization']); $this->assertEqual($this->HttpSocket->config['request']['auth']['qop'], 'auth'); @@ -128,12 +128,12 @@ class DigestMethodTest extends CakeTestCase { public function testOpaque() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; $this->HttpSocket->config['request']['auth'] = array(); - DigestMethod::authentication($this->HttpSocket); + DigestAuthentication::authentication($this->HttpSocket); $this->assertFalse(strpos($this->HttpSocket->request['header']['Authorization'], 'opaque="d8ea7aa61a1693024c4cc3a516f49b3c"')); $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",opaque="d8ea7aa61a1693024c4cc3a516f49b3c"'; $this->HttpSocket->config['request']['auth'] = array(); - DigestMethod::authentication($this->HttpSocket); + DigestAuthentication::authentication($this->HttpSocket); $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'opaque="d8ea7aa61a1693024c4cc3a516f49b3c"') > 0); } @@ -145,18 +145,18 @@ class DigestMethodTest extends CakeTestCase { public function testMultipleRequest() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",qop="auth"'; $this->HttpSocket->config['request']['auth'] = array(); - DigestMethod::authentication($this->HttpSocket); + DigestAuthentication::authentication($this->HttpSocket); $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000001') > 0); $this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 2); - DigestMethod::authentication($this->HttpSocket); + DigestAuthentication::authentication($this->HttpSocket); $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000002') > 0); $this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 3); $responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response='); $response = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32); $this->HttpSocket->nextHeader = ''; - DigestMethod::authentication($this->HttpSocket); + DigestAuthentication::authentication($this->HttpSocket); $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000003') > 0); $this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 4); $responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response='); @@ -173,7 +173,7 @@ class DigestMethodTest extends CakeTestCase { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; $this->HttpSocket->request['uri']['path'] = '/admin'; $this->HttpSocket->config['request']['auth'] = array(); - DigestMethod::authentication($this->HttpSocket); + DigestAuthentication::authentication($this->HttpSocket); $responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response='); $response = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32); $this->assertNotEqual($response, 'da7e2a46b471d77f70a9bb3698c8902b'); From ae7855692d131241f06ba78a837de536508f73f1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 20 Nov 2010 23:42:54 -0500 Subject: [PATCH 115/378] Removing unserialize() as its dangerous. Instead using | delimited fields for locked fields. This totally avoids issues with serialize(). Removing str_rot13, as its only child proof. Tests updated. --- cake/libs/controller/components/security.php | 6 +-- .../controller/components/security.test.php | 50 ++++++++----------- 2 files changed, 21 insertions(+), 35 deletions(-) diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index 7e5b3b28f..0de6c6ae4 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -618,15 +618,11 @@ class SecurityComponent extends Object { } unset($check['_Token']); - $locked = str_rot13($locked); - if (preg_match('/(\A|;|{|})O\:[0-9]+/', $locked)) { - return false; - } + $locked = explode('|', $locked); $lockedFields = array(); $fields = Set::flatten($check); $fieldList = array_keys($fields); - $locked = unserialize($locked); $multi = array(); foreach ($fieldList as $i => $key) { diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/cake/tests/cases/libs/controller/components/security.test.php index bbd514100..66cff58ba 100644 --- a/cake/tests/cases/libs/controller/components/security.test.php +++ b/cake/tests/cases/libs/controller/components/security.test.php @@ -573,8 +573,7 @@ DIGEST; function testValidatePost() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877%3An%3A1%3A%7Bv%3A0%3B'; - $fields .= 'f%3A11%3A%22Zbqry.inyvq%22%3B%7D'; + $fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877%3AModel.valid'; $this->Controller->data = array( 'Model' => array('username' => 'nate', 'password' => 'foo', 'valid' => '0'), @@ -591,8 +590,7 @@ DIGEST; function testValidatePostFormHacking() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877%3An%3A1%3A%7Bv%3A0%3B'; - $fields .= 'f%3A11%3A%22Zbqry.inyvq%22%3B%7D'; + $fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877%3AModel.valid'; $this->Controller->data = array( 'Model' => array('username' => 'nate', 'password' => 'foo', 'valid' => '0'), @@ -641,7 +639,7 @@ DIGEST; function testValidatePostArray() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = 'f7d573650a295b94e0938d32b323fde775e5f32b%3An%3A0%3A%7B%7D'; + $fields = 'f7d573650a295b94e0938d32b323fde775e5f32b%3A'; $this->Controller->data = array( 'Model' => array('multi_field' => array('1', '3')), @@ -659,7 +657,7 @@ DIGEST; function testValidatePostNoModel() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = '540ac9c60d323c22bafe997b72c0790f39a8bdef%3An%3A0%3A%7B%7D'; + $fields = '540ac9c60d323c22bafe997b72c0790f39a8bdef%3A'; $this->Controller->data = array( 'anything' => 'some_data', @@ -679,7 +677,7 @@ DIGEST; function testValidatePostSimple() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = '69f493434187b867ea14b901fdf58b55d27c935d%3An%3A0%3A%7B%7D'; + $fields = '69f493434187b867ea14b901fdf58b55d27c935d%3A'; $this->Controller->data = $data = array( 'Model' => array('username' => '', 'password' => ''), @@ -699,8 +697,7 @@ DIGEST; function testValidatePostComplex() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = 'c9118120e680a7201b543f562e5301006ccfcbe2%3An%3A2%3A%7Bv%3A0%3Bf%3A14%3A%'; - $fields .= '22Nqqerffrf.0.vq%22%3Bv%3A1%3Bf%3A14%3A%22Nqqerffrf.1.vq%22%3B%7D'; + $fields = 'c9118120e680a7201b543f562e5301006ccfcbe2%3AAddresses.0.id%7CAddresses.1.id'; $this->Controller->data = array( 'Addresses' => array( @@ -727,7 +724,7 @@ DIGEST; function testValidatePostMultipleSelect() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = '422cde416475abc171568be690a98cad20e66079%3An%3A0%3A%7B%7D'; + $fields = '422cde416475abc171568be690a98cad20e66079%3A'; $this->Controller->data = array( 'Tag' => array('Tag' => array(1, 2)), @@ -750,7 +747,7 @@ DIGEST; $result = $this->Controller->Security->validatePost($this->Controller); $this->assertTrue($result); - $fields = '19464422eafe977ee729c59222af07f983010c5f%3An%3A0%3A%7B%7D'; + $fields = '19464422eafe977ee729c59222af07f983010c5f%3A'; $this->Controller->data = array( 'User.password' => 'bar', 'User.name' => 'foo', 'User.is_valid' => '1', 'Tag' => array('Tag' => array(1)), '_Token' => compact('key', 'fields'), @@ -771,8 +768,7 @@ DIGEST; function testValidatePostCheckbox() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877%3An%3A1%3A%7Bv%3A0%'; - $fields .= '3Bf%3A11%3A%22Zbqry.inyvq%22%3B%7D'; + $fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877%3AModel.valid'; $this->Controller->data = array( 'Model' => array('username' => '', 'password' => '', 'valid' => '0'), @@ -782,7 +778,7 @@ DIGEST; $result = $this->Controller->Security->validatePost($this->Controller); $this->assertTrue($result); - $fields = '874439ca69f89b4c4a5f50fb9c36ff56a28f5d42%3An%3A0%3A%7B%7D'; + $fields = '874439ca69f89b4c4a5f50fb9c36ff56a28f5d42%3A'; $this->Controller->data = array( 'Model' => array('username' => '', 'password' => '', 'valid' => '0'), @@ -815,8 +811,8 @@ DIGEST; function testValidatePostHidden() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = '51ccd8cb0997c7b3d4523ecde5a109318405ef8c%3An%3A2%3A%7Bv%3A0%3Bf%3A12%3A'; - $fields .= '%22Zbqry.uvqqra%22%3Bv%3A1%3Bf%3A18%3A%22Zbqry.bgure_uvqqra%22%3B%7D'; + $fields = '51ccd8cb0997c7b3d4523ecde5a109318405ef8c%3AModel.hidden%7CModel.other_hidden'; + $fields .= ''; $this->Controller->data = array( 'Model' => array( @@ -839,8 +835,7 @@ DIGEST; $this->Controller->Security->disabledFields = array('Model.username', 'Model.password'); $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = 'ef1082968c449397bcd849f963636864383278b1%3An%3A1%3A%7Bv%'; - $fields .= '3A0%3Bf%3A12%3A%22Zbqry.uvqqra%22%3B%7D'; + $fields = 'ef1082968c449397bcd849f963636864383278b1%3AModel.hidden'; $this->Controller->data = array( 'Model' => array( @@ -862,9 +857,7 @@ DIGEST; function testValidateHiddenMultipleModel() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = 'a2d01072dc4660eea9d15007025f35a7a5b58e18%3An%3A3%3A%7Bv%3A0%3Bf%3A11'; - $fields .= '%3A%22Zbqry.inyvq%22%3Bv%3A1%3Bf%3A12%3A%22Zbqry2.inyvq%22%3Bv%3A2%'; - $fields .= '3Bf%3A12%3A%22Zbqry3.inyvq%22%3B%7D'; + $fields = 'a2d01072dc4660eea9d15007025f35a7a5b58e18%3AModel.valid%7CModel2.valid%7CModel3.valid'; $this->Controller->data = array( 'Model' => array('username' => '', 'password' => '', 'valid' => '0'), @@ -895,9 +888,8 @@ DIGEST; function testValidateHasManyModel() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = '51e3b55a6edd82020b3f29c9ae200e14bbeb7ee5%3An%3A4%3A%7Bv%3A0%3Bf%3A14%3A%2'; - $fields .= '2Zbqry.0.uvqqra%22%3Bv%3A1%3Bf%3A13%3A%22Zbqry.0.inyvq%22%3Bv%3A2%3Bf%3'; - $fields .= 'A14%3A%22Zbqry.1.uvqqra%22%3Bv%3A3%3Bf%3A13%3A%22Zbqry.1.inyvq%22%3B%7D'; + $fields = '51e3b55a6edd82020b3f29c9ae200e14bbeb7ee5%3AModel.0.hidden%7CModel.0.valid'; + $fields .= '%7CModel.1.hidden%7CModel.1.valid'; $this->Controller->data = array( 'Model' => array( @@ -926,9 +918,8 @@ DIGEST; function testValidateHasManyRecordsPass() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = '7a203edb3d345bbf38fe0dccae960da8842e11d7%3An%3A4%3A%7Bv%3A0%3Bf%3A12%3A%2'; - $fields .= '2Nqqerff.0.vq%22%3Bv%3A1%3Bf%3A17%3A%22Nqqerff.0.cevznel%22%3Bv%3A2%3Bf%'; - $fields .= '3A12%3A%22Nqqerff.1.vq%22%3Bv%3A3%3Bf%3A17%3A%22Nqqerff.1.cevznel%22%3B%7D'; + $fields = '7a203edb3d345bbf38fe0dccae960da8842e11d7%3AAddress.0.id%7CAddress.0.primary%7C'; + $fields .= 'Address.1.id%7CAddress.1.primary'; $this->Controller->data = array( 'Address' => array( @@ -971,9 +962,8 @@ DIGEST; function testValidateHasManyRecordsFail() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->params['_Token']['key']; - $fields = '7a203edb3d345bbf38fe0dccae960da8842e11d7%3An%3A4%3A%7Bv%3A0%3Bf%3A12%3A%2'; - $fields .= '2Nqqerff.0.vq%22%3Bv%3A1%3Bf%3A17%3A%22Nqqerff.0.cevznel%22%3Bv%3A2%3Bf%'; - $fields .= '3A12%3A%22Nqqerff.1.vq%22%3Bv%3A3%3Bf%3A17%3A%22Nqqerff.1.cevznel%22%3B%7D'; + $fields = '7a203edb3d345bbf38fe0dccae960da8842e11d7%3AAddress.0.id%7CAddress.0.primary%7C'; + $fields .= 'Address.1.id%7CAddress.1.primary'; $this->Controller->data = array( 'Address' => array( From 79aafda6986fba23b2308050fee9bb3c955741db Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 21 Nov 2010 00:09:45 -0500 Subject: [PATCH 116/378] Removing use of serialize() for locked fields. This removes any possible exploit related to serialize()/unserialize(). Instead values are passed as | delimited. --- cake/libs/view/helpers/form.php | 2 +- .../cases/libs/view/helpers/form.test.php | 21 +++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 538d844e5..5ee8a6c2c 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -406,7 +406,7 @@ class FormHelper extends AppHelper { $fields += $locked; $fields = Security::hash(serialize($fields) . Configure::read('Security.salt')); - $locked = str_rot13(serialize(array_keys($locked))); + $locked = implode(array_keys($locked), '|'); $out = $this->hidden('_Token.fields', array( 'value' => urlencode($fields . ':' . $locked), diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 0dc83aed7..3a9868c77 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -832,7 +832,7 @@ class FormHelperTest extends CakeTestCase { $result = $this->Form->secure($fields); $expected = Security::hash(serialize($fields) . Configure::read('Security.salt')); - $expected .= ':' . str_rot13(serialize(array('Model.valid'))); + $expected .= ':' . 'Model.valid'; $expected = array( 'div' => array('style' => 'display:none;'), @@ -894,9 +894,8 @@ class FormHelperTest extends CakeTestCase { $this->Form->params['_Token']['key'] = $key; $result = $this->Form->secure($fields); - $hash = '51e3b55a6edd82020b3f29c9ae200e14bbeb7ee5%3An%3A4%3A%7Bv%3A0%3Bf%3A14%3A%22Zbqry.'; - $hash .= '0.uvqqra%22%3Bv%3A1%3Bf%3A13%3A%22Zbqry.0.inyvq%22%3Bv%3A2%3Bf%3A14%3A%22Zbqry.1'; - $hash .= '.uvqqra%22%3Bv%3A3%3Bf%3A13%3A%22Zbqry.1.inyvq%22%3B%7D'; + $hash = '51e3b55a6edd82020b3f29c9ae200e14bbeb7ee5%3AModel.0.hidden%7CModel.0.valid'; + $hash .= '%7CModel.1.hidden%7CModel.1.valid'; $expected = array( 'div' => array('style' => 'display:none;'), @@ -985,8 +984,7 @@ class FormHelperTest extends CakeTestCase { $result = $this->Form->secure($this->Form->fields); - $hash = 'c9118120e680a7201b543f562e5301006ccfcbe2%3An%3A2%3A%7Bv%3A0%3Bf%3A14%'; - $hash .= '3A%22Nqqerffrf.0.vq%22%3Bv%3A1%3Bf%3A14%3A%22Nqqerffrf.1.vq%22%3B%7D'; + $hash = 'c9118120e680a7201b543f562e5301006ccfcbe2%3AAddresses.0.id%7CAddresses.1.id'; $expected = array( 'div' => array('style' => 'display:none;'), @@ -1029,8 +1027,7 @@ class FormHelperTest extends CakeTestCase { $this->Form->input('Addresses.1.phone'); $result = $this->Form->secure($this->Form->fields); - $hash = '774df31936dc850b7d8a5277dc0b890123788b09%3An%3A2%3A%7Bv%3A0%3Bf%3A14%3A%22Nqqerf'; - $hash .= 'frf.0.vq%22%3Bv%3A1%3Bf%3A14%3A%22Nqqerffrf.1.vq%22%3B%7D'; + $hash = '774df31936dc850b7d8a5277dc0b890123788b09%3AAddresses.0.id%7CAddresses.1.id'; $expected = array( 'div' => array('style' => 'display:none;'), @@ -1074,8 +1071,7 @@ class FormHelperTest extends CakeTestCase { $result = $this->Form->secure($expected); - $hash = '449b7e889128e8e52c5e81d19df68f5346571492%3An%3A1%3A%'; - $hash .= '7Bv%3A0%3Bf%3A12%3A%22Nqqerffrf.vq%22%3B%7D'; + $hash = '449b7e889128e8e52c5e81d19df68f5346571492%3AAddresses.id'; $expected = array( 'div' => array('style' => 'display:none;'), 'input' => array( @@ -1179,8 +1175,7 @@ class FormHelperTest extends CakeTestCase { ); $this->assertEqual($result, $expected); - $hash = 'bd7c4a654e5361f9a433a43f488ff9a1065d0aaf%3An%3A2%3A%7Bv%3A0%3Bf%3A15%3'; - $hash .= 'A%22HfreSbez.uvqqra%22%3Bv%3A1%3Bf%3A14%3A%22HfreSbez.fghss%22%3B%7D'; + $hash = 'bd7c4a654e5361f9a433a43f488ff9a1065d0aaf%3AUserForm.hidden%7CUserForm.stuff'; $result = $this->Form->secure($this->Form->fields); $expected = array( @@ -3569,7 +3564,7 @@ class FormHelperTest extends CakeTestCase { $this->assertEqual($this->Form->fields, array('Model.multi_field')); $result = $this->Form->secure($this->Form->fields); - $key = 'f7d573650a295b94e0938d32b323fde775e5f32b%3An%3A0%3A%7B%7D'; + $key = 'f7d573650a295b94e0938d32b323fde775e5f32b%3A'; $this->assertPattern('/"' . $key . '"/', $result); } From 244de1df8563dcd030245b251651d9f4a67b49eb Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 22 Nov 2010 12:58:51 -0500 Subject: [PATCH 117/378] Adding a comment about the messageId property and shells. Refs #1303 --- cake/libs/controller/components/email.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index 233945f53..52451fda1 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -261,6 +261,9 @@ class EmailComponent extends Object{ * it be handled by sendmail (or similar) or a string * to completely override the Message-ID. * + * If you are sending Email from a shell, be sure to set this value. As you + * could encounter delivery issues if you do not. + * * @var mixed * @access public */ From f48811a2ff471094462bd043dfc69792c30923f5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 22 Nov 2010 21:15:02 -0500 Subject: [PATCH 118/378] Moving include up so its not buried deep inside the class. --- cake/libs/cake_session.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php index bcb6459f9..0ad09de2c 100644 --- a/cake/libs/cake_session.php +++ b/cake/libs/cake_session.php @@ -22,6 +22,9 @@ * @since CakePHP(tm) v .0.10.0.1222 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +if (!class_exists('Security')) { + App::import('Core', 'Security'); +} /** * Session class for Cake. @@ -193,9 +196,6 @@ class CakeSession extends Object { } } if (isset($_SESSION) || $start === true) { - if (!class_exists('Security')) { - App::import('Core', 'Security'); - } $this->sessionTime = $this->time + (Security::inactiveMins() * Configure::read('Session.timeout')); $this->security = Configure::read('Security.level'); } From bf10723f897466a1b02149db4f45e9a279c37de8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 22 Nov 2010 21:21:55 -0500 Subject: [PATCH 119/378] Applying patch from 'michealc' to fix duplicated comments. Fixes #1306 --- cake/libs/model/datasources/datasource.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index 2c5a0ab12..94b5d5cef 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -396,7 +396,7 @@ class DataSource extends Object { } /** - * Returns the ID generated from the previous INSERT operation. + * Returns the number of rows returned by last operation. * * @param unknown_type $source * @return integer Number of rows returned by last operation @@ -407,7 +407,7 @@ class DataSource extends Object { } /** - * Returns the ID generated from the previous INSERT operation. + * Returns the number of rows affected by last query. * * @param unknown_type $source * @return integer Number of rows affected by last query. @@ -428,6 +428,7 @@ class DataSource extends Object { function enabled() { return true; } + /** * Returns true if the DataSource supports the given interface (method) * From d0d16a7edaa9a3b26f6a64c7bbaf9f50f0f7d1f2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 22 Nov 2010 21:29:11 -0500 Subject: [PATCH 120/378] Fixing i18n extraction errors in Scaffold. Fixes #1305 --- cake/libs/controller/scaffold.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index 0891616fd..ea5e9031f 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -303,7 +303,7 @@ class Scaffold extends Object { } if (!$this->ScaffoldModel->exists()) { - $message = __(sprintf("Invalid id for %s::edit()", Inflector::humanize($this->modelKey), true)); + $message = sprintf(__("Invalid id for %s::edit()", true), Inflector::humanize($this->modelKey)); if ($this->_validSession) { $this->controller->Session->setFlash($message); $this->controller->redirect($this->redirect); @@ -321,9 +321,10 @@ class Scaffold extends Object { if ($this->ScaffoldModel->save($this->controller->data)) { if ($this->controller->_afterScaffoldSave($action)) { - $message = __( - sprintf('The %1$s has been %2$s', Inflector::humanize($this->modelKey), $success), - true + $message = sprintf( + __('The %1$s has been %2$s', true), + Inflector::humanize($this->modelKey), + $success ); if ($this->_validSession) { $this->controller->Session->setFlash($message); @@ -376,8 +377,9 @@ class Scaffold extends Object { */ function __scaffoldDelete($params = array()) { if ($this->controller->_beforeScaffold('delete')) { - $message = __( - sprintf("No id set for %s::delete()", Inflector::humanize($this->modelKey)), true + $message = sprintf( + __("No id set for %s::delete()", true), + Inflector::humanize($this->modelKey) ); if (isset($params['pass'][0])) { $id = $params['pass'][0]; @@ -390,9 +392,9 @@ class Scaffold extends Object { } if ($this->ScaffoldModel->delete($id)) { - $message = __( - sprintf('The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id), - true + $message = sprintf( + __('The %1$s with id: %2$d has been deleted.', true), + Inflector::humanize($this->modelClass), $id ); if ($this->_validSession) { $this->controller->Session->setFlash($message); @@ -402,10 +404,10 @@ class Scaffold extends Object { return $this->_output(); } } else { - $message = __(sprintf( - 'There was an error deleting the %1$s with id: %2$d', + $message = sprintf( + __('There was an error deleting the %1$s with id: %2$d', true), Inflector::humanize($this->modelClass), $id - ), true); + ); if ($this->_validSession) { $this->controller->Session->setFlash($message); $this->controller->redirect($this->redirect); From d5fb0b25cb521d3b65e10d5265571ccd941b29ac Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 22 Nov 2010 22:08:46 -0500 Subject: [PATCH 121/378] Fixing issue where Date header would be missing from Emails sent by EmailComponent. Adding user configurable field for date. Test cases added. Fixes #1304 --- cake/libs/controller/components/email.php | 16 ++++++++++++ .../libs/controller/components/email.test.php | 25 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index 52451fda1..d27fd5c13 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -97,6 +97,15 @@ class EmailComponent extends Object{ */ var $bcc = array(); +/** + * The date to put in the Date: header. This should be a date + * conformant with the RFC2822 standard. Leave null, to have + * today's date generated. + * + * @var string + */ + var $date = null; + /** * The subject of the email * @@ -410,6 +419,7 @@ class EmailComponent extends Object{ $this->bcc = array(); $this->subject = null; $this->additionalParams = null; + $this->date = null; $this->smtpError = null; $this->attachments = array(); $this->htmlMessage = null; @@ -574,6 +584,12 @@ class EmailComponent extends Object{ } } + $date = $this->date; + if ($date == false) { + $date = date(DATE_RFC2822); + } + $headers['Date'] = $date; + $headers['X-Mailer'] = $this->xMailer; if (!empty($this->headers)) { diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index 8d7f588e6..8379e3e7b 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -493,6 +493,7 @@ TEMPDOC; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->messageId = false; + $date = date(DATE_RFC2822); $message = <<To: postmaster@localhost From: noreply@example.com @@ -501,6 +502,7 @@ Header: From: noreply@example.com Reply-To: noreply@example.com +Date: $date X-Mailer: CakePHP Email Component Content-Type: {CONTENTTYPE} Content-Transfer-Encoding: 7bitParameters: @@ -544,6 +546,7 @@ MSGBLOC; $this->Controller->EmailTest->delivery = 'debug'; $this->Controller->EmailTest->messageId = false; + $date = date(DATE_RFC2822); $header = <<assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: noreply@example.com\n/', $result); $this->assertPattern('/From: noreply@example.com\n/', $result); + $this->assertPattern('/Date: ' . date(DATE_RFC2822) . '\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\n/', $result); @@ -716,6 +721,7 @@ TEXTBLOC; $this->assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: noreply@example.com\n/', $result); $this->assertPattern('/From: noreply@example.com\n/', $result); + $this->assertPattern('/Date: ' . date(DATE_RFC2822) . '\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\n/', $result); @@ -849,7 +855,24 @@ HTMLBLOC; $this->assertPattern('/First line\n/', $result); $this->assertPattern('/Second line\n/', $result); $this->assertPattern('/Third line\n/', $result); + } +/** + * test setting a custom date. + * + * @return void + */ + function testDateProperty() { + $this->Controller->EmailTest->to = 'postmaster@localhost'; + $this->Controller->EmailTest->from = 'noreply@example.com'; + $this->Controller->EmailTest->subject = 'Cake Debug Test'; + $this->Controller->EmailTest->date = 'Today!'; + $this->Controller->EmailTest->template = null; + $this->Controller->EmailTest->delivery = 'debug'; + + $this->assertTrue($this->Controller->EmailTest->send('test message')); + $result = $this->Controller->Session->read('Message.email.message'); + $this->assertPattern('/Date: Today!\n/', $result); } /** @@ -1043,6 +1066,7 @@ HTMLBLOC; $this->Controller->EmailTest->return = 'test.return@example.com'; $this->Controller->EmailTest->cc = array('cc1@example.com', 'cc2@example.com'); $this->Controller->EmailTest->bcc = array('bcc1@example.com', 'bcc2@example.com'); + $this->Controller->EmailTest->date = 'Today!'; $this->Controller->EmailTest->subject = 'Test subject'; $this->Controller->EmailTest->additionalParams = 'X-additional-header'; $this->Controller->EmailTest->delivery = 'smtp'; @@ -1064,6 +1088,7 @@ HTMLBLOC; $this->assertNull($this->Controller->EmailTest->return); $this->assertIdentical($this->Controller->EmailTest->cc, array()); $this->assertIdentical($this->Controller->EmailTest->bcc, array()); + $this->assertNull($this->Controller->EmailTest->date); $this->assertNull($this->Controller->EmailTest->subject); $this->assertNull($this->Controller->EmailTest->additionalParams); $this->assertIdentical($this->Controller->EmailTest->getHeaders(), array()); From b567de977e6d1e570095f26ae1eb1eaccbb6cb78 Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 24 Nov 2010 01:43:10 +0530 Subject: [PATCH 122/378] Fixed bug where Dispatcher::getUrl() returned incorrect URL if $base appeared in a $uri besides at start of $uri. --- cake/dispatcher.php | 8 ++++---- cake/tests/cases/dispatcher.test.php | 21 ++++++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 1597c666f..e95771b2c 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -82,7 +82,7 @@ class Dispatcher extends Object { } /** - * Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the + * Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the * results (if autoRender is set). * * If no controller of given name can be found, invoke() shows error messages in @@ -483,8 +483,8 @@ class Dispatcher extends Object { if ($tmpUri === '/' || $tmpUri == $baseDir || $tmpUri == $base) { $url = $_GET['url'] = '/'; } else { - if ($base && strpos($uri, $base) !== false) { - $elements = explode($base, $uri); + if ($base && strpos($uri, $base) === 0) { + $elements = explode($base, $uri, 2); } elseif (preg_match('/^[\/\?\/|\/\?|\?\/]/', $uri)) { $elements = array(1 => preg_replace('/^[\/\?\/|\/\?|\?\/]/', '', $uri)); } else { @@ -560,7 +560,7 @@ class Dispatcher extends Object { } $filters = Configure::read('Asset.filter'); $isCss = ( - strpos($url, 'ccss/') === 0 || + strpos($url, 'ccss/') === 0 || preg_match('#^(theme/([^/]+)/ccss/)|(([^/]+)(?assertEqual($expected, $result); + $_GET['url'] = array(); + $Dispatcher =& new Dispatcher(); + $Dispatcher->base = '/shop'; + $uri = '/shop/fr/pages/shop'; + $result = $Dispatcher->getUrl($uri); + $expected = 'fr/pages/shop'; + $this->assertEqual($expected, $result); } /** @@ -1367,11 +1374,11 @@ class DispatcherTest extends CakeTestCase { $url = 'test_dispatch_pages/camelCased'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertEqual('TestDispatchPages', $controller->name); - + $url = 'test_dispatch_pages/camelCased/something. .'; $controller = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertEqual($controller->params['pass'][0], 'something. .', 'Period was chopped off. %s'); - + } /** @@ -1395,7 +1402,7 @@ class DispatcherTest extends CakeTestCase { $expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2'); $this->assertIdentical($expected, $controller->passedArgs); - + $this->assertEqual($Dispatcher->base . '/pages/display/home/param:value/param2:value2', $Dispatcher->here); } @@ -1441,7 +1448,7 @@ class DispatcherTest extends CakeTestCase { Router::reload(); $Dispatcher =& new TestDispatcher(); Router::connect( - '/my_plugin/:controller/*', + '/my_plugin/:controller/*', array('plugin' => 'my_plugin', 'controller' => 'pages', 'action' => 'display') ); @@ -1598,7 +1605,7 @@ class DispatcherTest extends CakeTestCase { 'action' => 'admin_index', 'prefix' => 'admin', 'admin' => true, - 'form' => array(), + 'form' => array(), 'url' => array('url' => 'admin/articles_test'), 'return' => 1 ); @@ -1980,7 +1987,7 @@ class DispatcherTest extends CakeTestCase { } /** - * test that asset filters work for theme and plugin assets + * test that asset filters work for theme and plugin assets * * @return void */ @@ -2008,7 +2015,7 @@ class DispatcherTest extends CakeTestCase { $Dispatcher->stopped = false; $Dispatcher->asset('css/ccss/debug_kit.css'); $this->assertFalse($Dispatcher->stopped); - + $Dispatcher->stopped = false; $Dispatcher->asset('js/cjs/debug_kit.js'); $this->assertFalse($Dispatcher->stopped); From af06b8f1791e658a0299095a6cea062afd0cc847 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 24 Nov 2010 21:14:52 -0200 Subject: [PATCH 123/378] Added test to a request that server dont response WWW-Authenticate. --- .../libs/http/digest_authentication.test.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cake/tests/cases/libs/http/digest_authentication.test.php b/cake/tests/cases/libs/http/digest_authentication.test.php index 7862f3147..75e98595e 100644 --- a/cake/tests/cases/libs/http/digest_authentication.test.php +++ b/cake/tests/cases/libs/http/digest_authentication.test.php @@ -37,6 +37,12 @@ class DigestHttpSocket extends HttpSocket { * @return void */ public function request($request) { + if ($request === false) { + if (isset($this->response['header']['WWW-Authenticate'])) { + unset($this->response['header']['WWW-Authenticate']); + } + return; + } $this->response['header']['WWW-Authenticate'] = $this->nextHeader; } @@ -179,4 +185,17 @@ class DigestAuthenticationTest extends CakeTestCase { $this->assertNotEqual($response, 'da7e2a46b471d77f70a9bb3698c8902b'); } +/** + * testNoDigestResponse method + * + * @return void + */ + public function testNoDigestResponse() { + $this->HttpSocket->nextHeader = false; + $this->HttpSocket->request['uri']['path'] = '/admin'; + $this->HttpSocket->config['request']['auth'] = array(); + DigestAuthentication::authentication($this->HttpSocket); + $this->assertFalse(isset($this->HttpSocket->request['header']['Authorization'])); + } + } \ No newline at end of file From 0e29567f8d8110948140b6445be4812750181ba8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 24 Nov 2010 22:09:08 -0500 Subject: [PATCH 124/378] Adding an array cast to fix issues where users could modify cookie values causing iteration errors. Fixes #1309 --- cake/libs/controller/components/cookie.php | 2 +- .../libs/controller/components/cookie.test.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/components/cookie.php b/cake/libs/controller/components/cookie.php index 67c3fe4db..38c5f00ae 100644 --- a/cake/libs/controller/components/cookie.php +++ b/cake/libs/controller/components/cookie.php @@ -411,7 +411,7 @@ class CookieComponent extends Object { $decrypted = array(); $type = $this->__type; - foreach ($values as $name => $value) { + foreach ((array)$values as $name => $value) { if (is_array($value)) { foreach ($value as $key => $val) { $pos = strpos($val, 'Q2FrZQ==.'); diff --git a/cake/tests/cases/libs/controller/components/cookie.test.php b/cake/tests/cases/libs/controller/components/cookie.test.php index 86e7789b5..5e3751f8b 100644 --- a/cake/tests/cases/libs/controller/components/cookie.test.php +++ b/cake/tests/cases/libs/controller/components/cookie.test.php @@ -437,6 +437,19 @@ class CookieComponentTest extends CakeTestCase { unset($_COOKIE['CakeTestCookie']); } + +/** + * test that no error is issued for non array data. + * + * @return void + */ + function testNoErrorOnNonArrayData() { + $this->Controller->Cookie->destroy(); + $_COOKIE['CakeTestCookie'] = 'kaboom'; + + $this->assertNull($this->Controller->Cookie->read('value')); + } + /** * encrypt method * From 4214242efd05645db042524aa85a953acda152f8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 24 Nov 2010 22:44:12 -0500 Subject: [PATCH 125/378] Adding test for correct merge order for $uses. Fixing incorrect merge ordering for $uses, so it matches historical behaviour. Fixes #1309 --- cake/libs/controller/controller.php | 8 ++------ cake/tests/cases/libs/controller/controller.test.php | 4 ++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 4a9827975..799d93f62 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -437,9 +437,7 @@ class Controller extends Object { $this->{$var} = Set::merge($app, $normal); } } else { - $this->{$var} = Set::merge( - array_diff($appVars[$var], $this->{$var}), $this->{$var} - ); + $this->{$var} = array_merge($this->{$var}, array_diff($appVars[$var], $this->{$var})); } } } @@ -463,9 +461,7 @@ class Controller extends Object { $this->{$var} = Set::merge($app, $normal); } } else { - $this->{$var} = Set::merge( - array_diff($appVars[$var], $this->{$var}), $this->{$var} - ); + $this->{$var} = array_merge($this->{$var}, array_diff($appVars[$var], $this->{$var})); } } } diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index d73672814..55a9e53cd 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -1153,6 +1153,10 @@ class ControllerTest extends CakeTestCase { $this->assertEqual(count(array_diff($TestController->uses, $uses)), 0); $this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0); + $expected = array('ControllerComment', 'ControllerAlias', 'ControllerPost'); + $this->assertEqual($expected, $TestController->uses, '$uses was merged incorrectly, AppController models should be last.'); + + $TestController =& new AnotherTestController(); $TestController->constructClasses(); From 7d158e8d1f8ea6a156e169c021b831740d8ca838 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 25 Nov 2010 06:39:08 -0500 Subject: [PATCH 126/378] Fixing Set::sort() for arrays with out of sequence, or missing keys. Tests added. Fixes #1312 --- cake/libs/set.php | 5 ++++- cake/tests/cases/libs/set.test.php | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/cake/libs/set.php b/cake/libs/set.php index 69706e8c9..3d4e89f02 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -1092,6 +1092,10 @@ class Set { * @static */ function sort($data, $path, $dir) { + $originalKeys = array_keys($data); + if (is_numeric(implode('', $originalKeys))) { + $data = array_values($data); + } $result = Set::__flatten(Set::extract($data, $path)); list($keys, $values) = array(Set::extract($result, '{n}.id'), Set::extract($result, '{n}.value')); @@ -1103,7 +1107,6 @@ class Set { } array_multisort($values, $dir, $keys, $dir); $sorted = array(); - $keys = array_unique($keys); foreach ($keys as $k) { diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index ee75ba1a9..3018c351a 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -354,6 +354,33 @@ class SetTest extends CakeTestCase { $this->assertEqual($result, $expected); } +/** + * test sorting with out of order keys. + * + * @return void + */ + function testSortWithOutOfOrderKeys() { + $data = array( + 9 => array('class' => 510, 'test2' => 2), + 1 => array('class' => 500, 'test2' => 1), + 2 => array('class' => 600, 'test2' => 2), + 5 => array('class' => 625, 'test2' => 4), + 0 => array('class' => 605, 'test2' => 3), + ); + $expected = array( + array('class' => 500, 'test2' => 1), + array('class' => 510, 'test2' => 2), + array('class' => 600, 'test2' => 2), + array('class' => 605, 'test2' => 3), + array('class' => 625, 'test2' => 4), + ); + $result = Set::sort($data, '{n}.class', 'asc'); + $this->assertEqual($expected, $result); + + $result = Set::sort($data, '{n}.test2', 'asc'); + $this->assertEqual($expected, $result); + } + /** * testExtract method * From 15ca2400bc546a42cdea462f6609cc65e0db6a8f Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 25 Nov 2010 06:52:23 -0500 Subject: [PATCH 127/378] Fixing issue in DboSource::name() where special characters in column names would not be correctly quoted. Tests added. Fixes #1264 --- cake/libs/model/datasources/dbo_source.php | 2 +- cake/tests/cases/libs/model/datasources/dbo_source.test.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 3f82a09d9..42d7db354 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -542,7 +542,7 @@ class DboSource extends DataSource { return $return; } $data = trim($data); - if (preg_match('/^[\w-]+(\.[\w-]+)*$/', $data)) { // string, string.string + if (preg_match('/^[\w-]+(?:\.[^ \*]*)*$/', $data)) { // string, string.string if (strpos($data, '.') === false) { // string return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . $data . $this->endQuote); } diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index bcb11045d..d60898dab 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -4077,6 +4077,10 @@ class DboSourceTest extends CakeTestCase { $result = $this->testDb->name(array('my-name', 'Foo-Model.*')); $expected = array('`my-name`', '`Foo-Model`.*'); $this->assertEqual($result, $expected); + + $result = $this->testDb->name(array('Team.P%', 'Team.G/G')); + $expected = array('`Team`.`P%`', '`Team`.`G/G`'); + $this->assertEqual($result, $expected); } /** From 70ae66edf7a0dccae40b1e004d190cf0a1a73170 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 27 Nov 2010 01:21:19 +0530 Subject: [PATCH 128/378] Fixing test cases for EmailComponent --- .../tests/cases/libs/controller/components/email.test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index 8379e3e7b..3a0472877 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -693,7 +693,7 @@ TEXTBLOC; $this->assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: noreply@example.com\n/', $result); $this->assertPattern('/From: noreply@example.com\n/', $result); - $this->assertPattern('/Date: ' . date(DATE_RFC2822) . '\n/', $result); + $this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\n/', $result); @@ -721,7 +721,7 @@ TEXTBLOC; $this->assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: noreply@example.com\n/', $result); $this->assertPattern('/From: noreply@example.com\n/', $result); - $this->assertPattern('/Date: ' . date(DATE_RFC2822) . '\n/', $result); + $this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\n/', $result); @@ -1217,10 +1217,10 @@ HTMLBLOC; $result = $this->Controller->EmailTest->formatAddress('email@example.com', true); $this->assertEqual($result, ''); - + $result = $this->Controller->EmailTest->formatAddress('', true); $this->assertEqual($result, ''); - + $result = $this->Controller->EmailTest->formatAddress('alias name ', true); $this->assertEqual($result, ''); } From 1186bc56f194defe827dd0802ea17cc243b5b836 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 27 Nov 2010 02:11:43 +0530 Subject: [PATCH 129/378] Adding EmailCompnent::lineFeed property toallow overriding the default line feed string when using mail() function to send mail. Closes #1320 --- cake/libs/controller/components/email.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index d27fd5c13..2aa96c3e0 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -98,7 +98,7 @@ class EmailComponent extends Object{ var $bcc = array(); /** - * The date to put in the Date: header. This should be a date + * The date to put in the Date: header. This should be a date * conformant with the RFC2822 standard. Leave null, to have * today's date generated. * @@ -157,6 +157,18 @@ class EmailComponent extends Object{ */ var $lineLength = 70; +/** + * Line feed character(s) to be used when sending using mail() function + * If null PHP_EOL is used. + * RFC2822 requires it to be CRLF but some Unix + * mail transfer agents replace LF by CRLF automatically + * (which leads to doubling CR if CRLF is used). + * + * @var string + * @access public + */ + var $lineFeed = null; + /** * @deprecated see lineLength */ @@ -804,8 +816,13 @@ class EmailComponent extends Object{ * @access private */ function _mail() { - $header = implode("\r\n", $this->__header); - $message = implode("\r\n", $this->__message); + if ($this->lineFeed === null) { + $lineFeed = PHP_EOL; + } else { + $lineFeed = $this->lineFeed; + } + $header = implode($lineFeed, $this->__header); + $message = implode($lineFeed, $this->__message); if (is_array($this->to)) { $to = implode(', ', array_map(array($this, '_formatAddress'), $this->to)); } else { From 547f48fb03ca6a0247028fcf8453e6431b4f25a2 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 26 Nov 2010 23:00:26 -0200 Subject: [PATCH 130/378] Changing to be compatible with PHP 5.2+ --- cake/libs/http_socket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index da67a28ab..8ae54948c 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -459,7 +459,7 @@ class HttpSocket extends CakeSocket { if (!App::import('Lib', 'http/' . $authClass)) { throw new Exception(__('Unknown authentication method.')); } - $authClass::authentication($this); + call_user_func("$authClass::authentication", $this); } /** From 41ee035d28dc11d95c26f072d2b1d5a00d5e6ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 26 Nov 2010 23:46:34 -0430 Subject: [PATCH 131/378] Starting to bring sqlite dbo up to date --- .../libs/model/datasources/dbo/dbo_sqlite.php | 344 ++++++++---------- cake/libs/model/datasources/dbo_source.php | 16 + .../cases/libs/model/model_read.test.php | 14 +- 3 files changed, 174 insertions(+), 200 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index 819f3f02c..63644a2b5 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -19,11 +19,11 @@ */ /** - * DBO implementation for the SQLite DBMS. + * DBO implementation for the SQLite3 DBMS. * - * Long description for class + * A DboSource adapter for SQLite 3 using PDO * - * @package cake + * @package datasources * @subpackage cake.cake.libs.model.datasources.dbo */ class DboSqlite extends DboSource { @@ -32,63 +32,48 @@ class DboSqlite extends DboSource { * Datasource Description * * @var string + * @access public */ - public $description = "SQLite DBO Driver"; + var $description = "SQLite DBO Driver"; /** - * Opening quote for quoted identifiers + * Quote Start * * @var string + * @access public */ - public $startQuote = '"'; + var $startQuote = '"'; /** - * Closing quote for quoted identifiers + * Quote End * * @var string + * @access public */ - public $endQuote = '"'; + var $endQuote = '"'; /** - * Keeps the transaction statistics of CREATE/UPDATE/DELETE queries + * Base configuration settings for SQLite3 driver * * @var array - * @access protected + * @access public */ - protected $_queryStats = array(); - -/** - * Base configuration settings for SQLite driver - * - * @var array - */ - protected $_baseConfig = array( - 'persistent' => true, + var $_baseConfig = array( + 'persistent' => false, 'database' => null ); /** - * Index of basic SQL commands + * SQLite3 column definition * * @var array - * @access protected + * @access public */ - protected $_commands = array( - 'begin' => 'BEGIN TRANSACTION', - 'commit' => 'COMMIT TRANSACTION', - 'rollback' => 'ROLLBACK TRANSACTION' - ); - -/** - * SQLite column definition - * - * @var array - */ - public $columns = array( - 'primary_key' => array('name' => 'integer primary key'), + var $columns = array( + 'primary_key' => array('name' => 'integer primary key autoincrement'), 'string' => array('name' => 'varchar', 'limit' => '255'), 'text' => array('name' => 'text'), - 'integer' => array('name' => 'integer', 'limit' => 11, 'formatter' => 'intval'), + 'integer' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'), 'float' => array('name' => 'float', 'formatter' => 'floatval'), 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), @@ -104,12 +89,12 @@ class DboSqlite extends DboSource { * @var array * @access public */ - public $fieldParameters = array( + var $fieldParameters = array( 'collate' => array( 'value' => 'COLLATE', 'quote' => false, - 'join' => ' ', - 'column' => 'Collate', + 'join' => ' ', + 'column' => 'Collate', 'position' => 'afterDefault', 'options' => array( 'BINARY', 'NOCASE', 'RTRIM' @@ -122,83 +107,49 @@ class DboSqlite extends DboSource { * * @param array $config Configuration array for connecting * @return mixed + * @access public */ function connect() { $config = $this->config; - if (!$config['persistent']) { - $this->connection = sqlite_open($config['database']); - } else { - $this->connection = sqlite_popen($config['database']); + $flags = array(PDO::ATTR_PERSISTENT => $config['persistent']); + try { + $this->_connection = new PDO('sqlite:'.$config['database'], null, null, $flags); + $this->_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $this->connected = true; } - $this->connected = is_resource($this->connection); - - if ($this->connected) { - $this->_execute('PRAGMA count_changes = 1;'); + catch(PDOException $e) { + $this->errors[] = $e->getMessage(); } return $this->connected; } /** - * Check that SQLite is enabled/installed + * Check whether the MySQL extension is installed/loaded * * @return boolean */ function enabled() { - return extension_loaded('sqlite'); - } -/** - * Disconnects from database. - * - * @return boolean True if the database could be disconnected, else false - */ - function disconnect() { - @sqlite_close($this->connection); - $this->connected = false; - return $this->connected; - } - -/** - * Executes given SQL statement. - * - * @param string $sql SQL statement - * @return resource Result resource identifier - */ - function _execute($sql) { - $result = sqlite_query($this->connection, $sql); - - if (preg_match('/^(INSERT|UPDATE|DELETE)/', $sql)) { - $this->resultSet($result); - list($this->_queryStats) = $this->fetchResult(); - } - return $result; - } - -/** - * Overrides DboSource::execute() to correctly handle query statistics - * - * @param string $sql - * @return unknown - */ - function execute($sql) { - $result = parent::execute($sql); - $this->_queryStats = array(); - return $result; + return in_array('sqlite', PDO::getAvailableDrivers()); } /** * Returns an array of tables in the database. If there are no tables, an error is raised and the application exits. * * @return array Array of tablenames in the database + * @access public */ function listSources() { - $cache = parent::listSources(); + $db = $this->config['database']; + $this->config['database'] = basename($this->config['database']); + $cache = parent::listSources(); if ($cache != null) { return $cache; } + $result = $this->fetchAll("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;", false); - if (empty($result)) { + if (!$result || empty($result)) { return array(); } else { $tables = array(); @@ -206,8 +157,11 @@ class DboSqlite extends DboSource { $tables[] = $table[0]['name']; } parent::listSources($tables); + + $this->config['database'] = $db; return $tables; } + $this->config['database'] = $db; return array(); } @@ -216,6 +170,7 @@ class DboSqlite extends DboSource { * * @param string $tableName Name of database table to inspect * @return array Fields in table. Keys are name and type + * @access public */ function describe(&$model) { $cache = parent::describe($model); @@ -223,23 +178,22 @@ class DboSqlite extends DboSource { return $cache; } $fields = array(); - $result = $this->fetchAll('PRAGMA table_info(' . $this->fullTableName($model) . ')'); + $result = $this->fetchAll('PRAGMA table_info(' . $model->tablePrefix . $model->table . ')'); foreach ($result as $column) { $fields[$column[0]['name']] = array( - 'type' => $this->column($column[0]['type']), - 'null' => !$column[0]['notnull'], - 'default' => $column[0]['dflt_value'], - 'length' => $this->length($column[0]['type']) + 'type' => $this->column($column[0]['type']), + 'null' => !$column[0]['notnull'], + 'default' => $column[0]['dflt_value'], + 'length' => $this->length($column[0]['type']) ); - if ($column[0]['pk'] == 1) { - $colLength = $this->length($column[0]['type']); + if($column[0]['pk'] == 1) { $fields[$column[0]['name']] = array( - 'type' => $fields[$column[0]['name']]['type'], - 'null' => false, - 'default' => $column[0]['dflt_value'], - 'key' => $this->index['PRI'], - 'length'=> ($colLength != null) ? $colLength : 11 + 'type' => $fields[$column[0]['name']]['type'], + 'null' => false, + 'default' => $column[0]['dflt_value'], + 'key' => $this->index['PRI'], + 'length' => 11 ); } } @@ -253,6 +207,7 @@ class DboSqlite extends DboSource { * * @param string $data String to be prepared for use in an SQL statement * @return string Quoted and escaped + * @access public */ function value($data, $column = null, $safe = false) { $parent = parent::value($data, $column, $safe); @@ -260,28 +215,41 @@ class DboSqlite extends DboSource { if ($parent != null) { return $parent; } - if ($data === null) { + if ($data === null || (is_array($data) && empty($data))) { return 'NULL'; } - if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') { + if ($data === '') { return "''"; } switch ($column) { case 'boolean': $data = $this->boolean((bool)$data); break; - case 'integer': - case 'float': - if ($data === '') { - return 'NULL'; - } default: - $data = sqlite_escape_string($data); + $data = $this->_connection->quote($data); + return $data; break; } return "'" . $data . "'"; } +/** + * Executes given SQL statement. + * + * @param string $sql SQL statement + * @param array $params list of params to be bound to query + * @return PDOStatement if query executes with no problem, true as the result of a succesfull + * query returning no rows, suchs as a CREATE statement, false otherwise + */ + protected function _execute($sql, $params = array()) { + $this->_result = parent::_execute($sql, $params); + //if (is_object($this->_result)) { + // $this->rows = $this->_result->fetchAll(PDO::FETCH_NUM); + // $this->row_count = count($this->rows); + //} + return $this->_result; + } + /** * Generates and executes an SQL UPDATE statement for given model, fields, and values. * @@ -290,6 +258,7 @@ class DboSqlite extends DboSource { * @param array $values * @param mixed $conditions * @return array + * @access public */ function update(&$model, $fields = array(), $values = null, $conditions = null) { if (empty($values) && !empty($fields)) { @@ -302,8 +271,7 @@ class DboSqlite extends DboSource { } } } - $result = parent::update($model, $fields, $values, $conditions); - return $result; + return parent::update($model, $fields, $values, $conditions); } /** @@ -312,60 +280,11 @@ class DboSqlite extends DboSource { * * @param mixed $table A string or model class representing the table to be truncated * @return boolean SQL TRUNCATE TABLE statement, false if not applicable. + * @access public */ - public function truncate($table) { - return $this->execute('DELETE From ' . $this->fullTableName($table)); - } - -/** - * Returns a formatted error message from previous database operation. - * - * @return string Error message - */ - function lastError() { - $error = sqlite_last_error($this->connection); - if ($error) { - return $error.': '.sqlite_error_string($error); - } - return null; - } - -/** - * Returns number of affected rows in previous database operation. If no previous operation exists, this returns false. - * - * @return integer Number of affected rows - */ - function lastAffected() { - if (!empty($this->_queryStats)) { - foreach (array('rows inserted', 'rows updated', 'rows deleted') as $key) { - if (array_key_exists($key, $this->_queryStats)) { - return $this->_queryStats[$key]; - } - } - } - return false; - } - -/** - * Returns number of rows in previous resultset. If no previous resultset exists, - * this returns false. - * - * @return integer Number of rows in resultset - */ - function lastNumRows() { - if ($this->hasResult()) { - sqlite_num_rows($this->_result); - } - return false; - } - -/** - * Returns the ID generated from the previous INSERT operation. - * - * @return int - */ - function lastInsertId() { - return sqlite_last_insert_rowid($this->connection); + function truncate($table) { + $this->_execute('DELETE FROM sqlite_sequence where name=' . $this->fullTableName($table)); + return $this->execute('DELETE FROM ' . $this->fullTableName($table)); } /** @@ -373,6 +292,7 @@ class DboSqlite extends DboSource { * * @param string $real Real database-layer column type (i.e. "varchar(255)") * @return string Abstract column type (i.e. "string") + * @access public */ function column($real) { if (is_array($real)) { @@ -385,9 +305,7 @@ class DboSqlite extends DboSource { $col = strtolower(str_replace(')', '', $real)); $limit = null; - if (strpos($col, '(') !== false) { - list($col, $limit) = explode('(', $col); - } + @list($col, $limit) = explode('(', $col); if (in_array($col, array('text', 'integer', 'float', 'boolean', 'timestamp', 'date', 'datetime', 'time'))) { return $col; @@ -398,29 +316,55 @@ class DboSqlite extends DboSource { if (in_array($col, array('blob', 'clob'))) { return 'binary'; } - if (strpos($col, 'numeric') !== false) { + if (strpos($col, 'numeric') !== false || strpos($col, 'decimal') !== false) { return 'float'; } return 'text'; } /** - * Enter description here... + * Generate ResultSet * - * @param unknown_type $results + * @param mixed $results + * @access public */ - function resultSet(&$results) { - $this->results =& $results; + function resultSet($results) { + $this->results = $results; $this->map = array(); - $fieldCount = sqlite_num_fields($results); - $index = $j = 0; + $num_fields = $results->columnCount(); + $index = 0; + $j = 0; - while ($j < $fieldCount) { - $columnName = str_replace('"', '', sqlite_field_name($results, $j)); + //PDO::getColumnMeta is experimental and does not work with sqlite3, + // so try to figure it out based on the querystring + $querystring = $results->queryString; + if (stripos($querystring, 'SELECT') === 0) { + $last = stripos($querystring, 'FROM'); + if ($last !== false) { + $selectpart = substr($querystring, 7, $last - 8); + $selects = explode(',', $selectpart); + } + } elseif (strpos($querystring, 'PRAGMA table_info') === 0) { + $selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk'); + } elseif(strpos($querystring, 'PRAGMA index_list') === 0) { + $selects = array('seq', 'name', 'unique'); + } elseif(strpos($querystring, 'PRAGMA index_info') === 0) { + $selects = array('seqno', 'cid', 'name'); + } + while ($j < $num_fields) { + if (preg_match('/\bAS\s+(.*)/i', $selects[$j], $matches)) { + $columnName = trim($matches[1],'"'); + } else { + $columnName = trim(str_replace('"', '', $selects[$j])); + } + + if (strpos($selects[$j], 'DISTINCT') === 0) { + $columnName = str_ireplace('DISTINCT', '', $columnName); + } if (strpos($columnName, '.')) { $parts = explode('.', $columnName); - $this->map[$index++] = array($parts[0], $parts[1]); + $this->map[$index++] = array(trim($parts[0]), trim($parts[1])); } else { $this->map[$index++] = array(0, $columnName); } @@ -431,34 +375,30 @@ class DboSqlite extends DboSource { /** * Fetches the next row from the current result set * - * @return unknown + * @return mixed array with results fetched and mapped to column names or false if there is no results left to fetch */ function fetchResult() { - if ($row = sqlite_fetch_array($this->results, SQLITE_ASSOC)) { + if ($row = $this->_result->fetch()) { $resultRow = array(); - $i = 0; - - foreach ($row as $index => $field) { - if (strpos($index, '.')) { - list($table, $column) = explode('.', str_replace('"', '', $index)); - $resultRow[$table][$column] = $row[$index]; - } else { - $resultRow[0][str_replace('"', '', $index)] = $row[$index]; - } - $i++; + foreach ($this->map as $col => $meta) { + list($table, $column) = $meta; + $resultRow[$table][$column] = $row[$col]; } return $resultRow; } else { + $this->_result->closeCursor(); return false; } } + /** * Returns a limit statement in the correct format for the particular database. * * @param integer $limit Limit of results returned * @param integer $offset Offset from which to start results * @return string SQL limit/offset statement + * @access public */ function limit($limit, $offset = null) { if ($limit) { @@ -479,8 +419,9 @@ class DboSqlite extends DboSource { * Generate a database-native column schema string * * @param array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]), - * where options can be 'default', 'length', or 'key'. + * where options can be 'default', 'length', or 'key'. * @return string + * @access public */ function buildColumn($column) { $name = $type = null; @@ -488,12 +429,12 @@ class DboSqlite extends DboSource { extract($column); if (empty($name) || empty($type)) { - trigger_error(__('Column name or type not defined in schema'), E_USER_WARNING); + trigger_error('Column name or type not defined in schema', E_USER_WARNING); return null; } if (!isset($this->columns[$type])) { - trigger_error(sprintf(__('Column type %s does not exist'), $type), E_USER_WARNING); + trigger_error("Column type {$type} does not exist", E_USER_WARNING); return null; } @@ -509,6 +450,7 @@ class DboSqlite extends DboSource { * Sets the database encoding * * @param string $enc Database encoding + * @access public */ function setEncoding($enc) { if (!in_array($enc, array("UTF-8", "UTF-16", "UTF-16le", "UTF-16be"))) { @@ -521,6 +463,7 @@ class DboSqlite extends DboSource { * Gets the database encoding * * @return string The database encoding + * @access public */ function getEncoding() { return $this->fetchRow('PRAGMA encoding'); @@ -532,6 +475,7 @@ class DboSqlite extends DboSource { * @param array $indexes * @param string $table * @return string + * @access public */ function buildIndex($indexes, $table = null) { $join = array(); @@ -547,7 +491,7 @@ class DboSqlite extends DboSource { $out .= 'UNIQUE '; } if (is_array($value['column'])) { - $value['column'] = implode(', ', array_map(array(&$this, 'name'), $value['column'])); + $value['column'] = join(', ', array_map(array(&$this, 'name'), $value['column'])); } else { $value['column'] = $this->name($value['column']); } @@ -563,6 +507,7 @@ class DboSqlite extends DboSource { * * @param string $model Name of model to inspect * @return array Fields in table. Keys are column and unique + * @access public */ function index(&$model) { $index = array(); @@ -600,6 +545,7 @@ class DboSqlite extends DboSource { * @param string $type * @param array $data * @return string + * @access public */ function renderStatement($type, $data) { switch (strtolower($type)) { @@ -608,7 +554,7 @@ class DboSqlite extends DboSource { foreach (array('columns', 'indexes') as $var) { if (is_array(${$var})) { - ${$var} = "\t" . implode(",\n\t", array_filter(${$var})); + ${$var} = "\t" . join(",\n\t", array_filter(${$var})); } } return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}"; @@ -618,4 +564,14 @@ class DboSqlite extends DboSource { break; } } -} + +/** + * PDO deals in objects, not resources, so overload accordingly. + * + * @return boolean + * @access public + */ + function hasResult() { + return is_object($this->_result); + } +} \ No newline at end of file diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 9d4bb8e72..f59fd0e72 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -88,6 +88,22 @@ class DboSource extends DataSource { */ private $__sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', 'regexp', 'similar to'); +/** + * Indicates that a transaction have been started + * + * @var boolean + * @access protected + */ + protected $_transactionStarted = false; + +/** + * Indicates the level of nested transactions + * + * @var integer + * @access protected + */ + protected $_transactionNesting = 0; + /** * Index of basic SQL commands * diff --git a/cake/tests/cases/libs/model/model_read.test.php b/cake/tests/cases/libs/model/model_read.test.php index 390e89fc3..93808578c 100755 --- a/cake/tests/cases/libs/model/model_read.test.php +++ b/cake/tests/cases/libs/model/model_read.test.php @@ -52,6 +52,7 @@ class ModelReadTest extends BaseModelTest { ) ); + $Something->JoinThing->create($joinThingData); $Something->JoinThing->save(); @@ -61,6 +62,7 @@ class ModelReadTest extends BaseModelTest { $this->assertEqual((bool)$result[1]['JoinThing']['doomed'], false); $result = $Something->find('first'); + $this->assertEqual(count($result['SomethingElse']), 2); $doomed = Set::extract('/JoinThing/doomed', $result['SomethingElse']); @@ -79,7 +81,7 @@ class ModelReadTest extends BaseModelTest { */ function testGroupBy() { $db = ConnectionManager::getDataSource('test'); - $isStrictGroupBy = in_array($db->config['driver'], array('postgres', 'oracle')); + $isStrictGroupBy = in_array($db->config['driver'], array('postgres', 'oracle', 'sqlite')); $message = '%s Postgres and Oracle have strict GROUP BY and are incompatible with this test.'; if ($this->skipIf($isStrictGroupBy, $message )) { @@ -7463,7 +7465,7 @@ class ModelReadTest extends BaseModelTest { $result = $Post->field('other_field'); $this->assertEqual($result, 4); - if ($this->skipIf($this->db->config['driver'] == 'postgres', 'The rest of virtualFieds test is not compatible with Postgres')) { + if ($this->skipIf($this->db->config['driver'] != 'mysql', 'The rest of virtualFieds test is not compatible with Postgres')) { return; } ClassRegistry::flush(); @@ -7471,20 +7473,20 @@ class ModelReadTest extends BaseModelTest { $Post->create(); $Post->virtualFields = array( - 'year' => 'YEAR(Post.created)', + 'low_title' => 'lower(Post.title)', 'unique_test_field' => 'COUNT(Post.id)' ); $expectation = array( 'Post' => array( - 'year' => 2007, - 'unique_test_field' => 3 + 'low_title' => 'first post', + 'unique_test_field' => 1 ) ); $result = $Post->find('first', array( 'fields' => array_keys($Post->virtualFields), - 'group' => array('year') + 'group' => array('low_title') )); $this->assertEqual($result, $expectation); From 0ff01330c47e6621ece2347d96f7b91f5ebe7ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sat, 27 Nov 2010 00:13:04 -0430 Subject: [PATCH 132/378] Making dates deconstruction in model more consistent for different datasources --- cake/libs/model/model.php | 11 ++++++----- .../tests/cases/libs/model/model_integration.test.php | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 551a9ea6c..896c172e6 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -902,9 +902,6 @@ class Model extends Object { $dateFields = array('Y' => 'year', 'm' => 'month', 'd' => 'day', 'H' => 'hour', 'i' => 'min', 's' => 'sec'); $timeFields = array('H' => 'hour', 'i' => 'min', 's' => 'sec'); - - $db = $this->getDataSource(); - $format = $db->columns[$type]['format']; $date = array(); if (isset($data['hour']) && isset($data['meridian']) && $data['hour'] != 12 && 'pm' == $data['meridian']) { @@ -947,9 +944,13 @@ class Model extends Object { } } } - $date = str_replace(array_keys($date), array_values($date), $format); + + $format = $this->getDataSource()->columns[$type]['format']; + $day = empty($date['Y']) ? null : $date['Y'] . '-' . $date['m'] . '-' . $date['d'] . ' '; + $hour = empty($date['H']) ? null : $date['H'] . ':' . $date['i'] . ':' . $date['s']; + $date = new DateTime($day . $hour); if ($useNewDate && !empty($date)) { - return $date; + return $date->format($format); } } return $data; diff --git a/cake/tests/cases/libs/model/model_integration.test.php b/cake/tests/cases/libs/model/model_integration.test.php index 1e6c73e21..a8b5a6796 100644 --- a/cake/tests/cases/libs/model/model_integration.test.php +++ b/cake/tests/cases/libs/model/model_integration.test.php @@ -1947,8 +1947,8 @@ class ModelIntegrationTest extends BaseModelTest { 'Featured' => array( 'article_featured_id' => 1, 'category_id' => 1, - 'published_date' => '2008-6-11 00:00:00', - 'end_date' => '2008-6-20 00:00:00' + 'published_date' => '2008-06-11 00:00:00', + 'end_date' => '2008-06-20 00:00:00' )); $this->assertEqual($FeaturedModel->create($data), $expected); @@ -1970,8 +1970,8 @@ class ModelIntegrationTest extends BaseModelTest { $expected = array( 'Featured' => array( - 'published_date' => '2008-6-11 00:00:00', - 'end_date' => '2008-6-20 00:00:00', + 'published_date' => '2008-06-11 00:00:00', + 'end_date' => '2008-06-20 00:00:00', 'article_featured_id' => 1, 'category_id' => 1 )); From 492bcea85f8f1fb9d1281f386c8a84da35c6be0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sat, 27 Nov 2010 00:37:13 -0430 Subject: [PATCH 133/378] mproving decribing process of tables in sqlite --- .../libs/model/datasources/dbo/dbo_sqlite.php | 62 +++++-------------- 1 file changed, 16 insertions(+), 46 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index 63644a2b5..c7e96e996 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -113,7 +113,7 @@ class DboSqlite extends DboSource { $config = $this->config; $flags = array(PDO::ATTR_PERSISTENT => $config['persistent']); try { - $this->_connection = new PDO('sqlite:'.$config['database'], null, null, $flags); + $this->_connection = new PDO('sqlite:' . $config['database'], null, null, $flags); $this->_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->connected = true; } @@ -178,61 +178,35 @@ class DboSqlite extends DboSource { return $cache; } $fields = array(); - $result = $this->fetchAll('PRAGMA table_info(' . $model->tablePrefix . $model->table . ')'); + $result = $this->_execute('PRAGMA table_info(' . $model->tablePrefix . $model->table . ')'); foreach ($result as $column) { - $fields[$column[0]['name']] = array( - 'type' => $this->column($column[0]['type']), - 'null' => !$column[0]['notnull'], - 'default' => $column[0]['dflt_value'], - 'length' => $this->length($column[0]['type']) + $column = (array) $column; + $default = ($column['dflt_value'] === 'NULL') ? null : trim($column['dflt_value'], "'"); + + $fields[$column['name']] = array( + 'type' => $this->column($column['type']), + 'null' => !$column['notnull'], + 'default' => $default, + 'length' => $this->length($column['type']) ); - if($column[0]['pk'] == 1) { - $fields[$column[0]['name']] = array( - 'type' => $fields[$column[0]['name']]['type'], + if($column['pk'] == 1) { + $fields[$column['name']] = array( + 'type' => $fields[$column['name']]['type'], 'null' => false, - 'default' => $column[0]['dflt_value'], + 'default' => $default, 'key' => $this->index['PRI'], 'length' => 11 ); } } + + $result->closeCursor(); $this->__cacheDescription($model->tablePrefix . $model->table, $fields); return $fields; } -/** - * Returns a quoted and escaped string of $data for use in an SQL statement. - * - * @param string $data String to be prepared for use in an SQL statement - * @return string Quoted and escaped - * @access public - */ - function value($data, $column = null, $safe = false) { - $parent = parent::value($data, $column, $safe); - - if ($parent != null) { - return $parent; - } - if ($data === null || (is_array($data) && empty($data))) { - return 'NULL'; - } - if ($data === '') { - return "''"; - } - switch ($column) { - case 'boolean': - $data = $this->boolean((bool)$data); - break; - default: - $data = $this->_connection->quote($data); - return $data; - break; - } - return "'" . $data . "'"; - } - /** * Executes given SQL statement. * @@ -243,10 +217,6 @@ class DboSqlite extends DboSource { */ protected function _execute($sql, $params = array()) { $this->_result = parent::_execute($sql, $params); - //if (is_object($this->_result)) { - // $this->rows = $this->_result->fetchAll(PDO::FETCH_NUM); - // $this->row_count = count($this->rows); - //} return $this->_result; } From 8492f2055bc6ed31fdc11547db72b74597a938f0 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sat, 27 Nov 2010 12:09:43 -0800 Subject: [PATCH 134/378] Added tests for object collection --- .../cases/libs/object_collection.test.php | 278 ++++++++++++++++++ 1 file changed, 278 insertions(+) create mode 100644 cake/tests/cases/libs/object_collection.test.php diff --git a/cake/tests/cases/libs/object_collection.test.php b/cake/tests/cases/libs/object_collection.test.php new file mode 100644 index 000000000..9d0861861 --- /dev/null +++ b/cake/tests/cases/libs/object_collection.test.php @@ -0,0 +1,278 @@ +_loaded[$name])) { + return $this->_loaded[$name]; + } + $objectClass = $name . 'GenericObject'; + $this->_loaded[$name] = new $objectClass($this, $settings); + if ($enable === true) { + $this->_enabled[] = $name; + } + return $this->_loaded[$name]; + } +} + +class ObjectCollectionTest extends CakeTestCase { +/** + * setup + * + * @return void + */ + function setup() { + $this->Objects = new GenericObjectCollection(); + } + +/** + * teardown + * + * @return void + */ + function teardown() { + unset($this->Objects); + } + +/** + * test triggering callbacks on loaded helpers + * + * @return void + */ + function testLoad() { + $result = $this->Objects->load('First'); + $this->assertType('FirstGenericObject', $result); + $this->assertType('FirstGenericObject', $this->Objects->First); + + $result = $this->Objects->attached(); + $this->assertEquals(array('First'), $result, 'attached() results are wrong.'); + + $this->assertTrue($this->Objects->enabled('First')); + + $result = $this->Objects->load('First'); + $this->assertSame($result, $this->Objects->First); + } + +/** + * test unload() + * + * @return void + */ + function testUnload() { + $this->Objects->load('First'); + $this->Objects->load('Second'); + + $result = $this->Objects->attached(); + $this->assertEquals(array('First', 'Second'), $result, 'loaded objects are wrong'); + + $this->Objects->unload('First'); + $this->assertFalse(isset($this->Objects->First)); + $this->assertTrue(isset($this->Objects->Second)); + + $result = $this->Objects->attached(); + $this->assertEquals(array('Second'), $result, 'loaded objects are wrong'); + + $result = $this->Objects->enabled(); + $this->assertEquals(array('Second'), $result, 'enabled objects are wrong'); + } + +/** + * creates mock classes for testing + * + * @return void + */ + protected function _makeMockClasses() { + if (!class_exists('TriggerMockFirstGenericObject')) { + $this->getMock('FirstGenericObject', array(), array(), 'TriggerMockFirstGenericObject', false); + } + if (!class_exists('TriggerMockSecondGenericObject')) { + $this->getMock('SecondGenericObject', array(), array(), 'TriggerMockSecondGenericObject', false); + } + } + +/** + * test triggering callbacks. + * + * @return void + */ + function testTrigger() { + $this->_makeMockClasses(); + $this->Objects->load('TriggerMockFirst'); + $this->Objects->load('TriggerMockSecond'); + + $this->Objects->TriggerMockFirst->expects($this->once()) + ->method('callback'); + $this->Objects->TriggerMockSecond->expects($this->once()) + ->method('callback'); + + $this->assertTrue($this->Objects->trigger('callback')); + } + +/** + * test that the initalize callback is triggered on all components even those that are disabled. + * + * @return void + */ + function testTriggerWithTriggerDisabledObjects() { + $this->_makeMockClasses(); + $this->Objects->load('TriggerMockFirst', array(), false); + $this->Objects->load('TriggerMockSecond'); + + $this->Objects->TriggerMockFirst->expects($this->once()) + ->method('callback'); + $this->Objects->TriggerMockSecond->expects($this->once()) + ->method('callback'); + + $result = $this->Objects->trigger('callback', array(), array('triggerDisabled' => true)); + $this->assertTrue($result); + } + +/** + * test trigger and disabled helpers. + * + * @return void + */ + function testTriggerWithDisabledComponents() { + $this->_makeMockClasses(); + $this->Objects->load('TriggerMockFirst'); + $this->Objects->load('TriggerMockSecond'); + + $this->Objects->TriggerMockFirst->expects($this->once()) + ->method('callback'); + $this->Objects->TriggerMockSecond->expects($this->never()) + ->method('callback'); + + $this->Objects->disable('TriggerMockSecond'); + + $this->assertTrue($this->Objects->trigger('callback', array())); + } + +/** + * test that the collectReturn option works. + * + * @return void + */ + function testTriggerWithCollectReturn() { + $this->_makeMockClasses(); + $this->Objects->load('TriggerMockFirst'); + $this->Objects->load('TriggerMockSecond'); + + $this->Objects->TriggerMockFirst->expects($this->once()) + ->method('callback') + ->will($this->returnValue(array('one', 'two'))); + $this->Objects->TriggerMockSecond->expects($this->once()) + ->method('callback') + ->will($this->returnValue(array('three', 'four'))); + + $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); + $expected = array( + array('one', 'two'), + array('three', 'four') + ); + $this->assertEquals($expected, $result); + } + +/** + * test that trigger with break & breakOn works. + * + * @return void + */ + function testTriggerWithBreak() { + $this->_makeMockClasses(); + $this->Objects->load('TriggerMockFirst'); + $this->Objects->load('TriggerMockSecond'); + + $this->Objects->TriggerMockFirst->expects($this->once()) + ->method('callback') + ->will($this->returnValue(false)); + $this->Objects->TriggerMockSecond->expects($this->never()) + ->method('callback'); + + $result = $this->Objects->trigger( + 'callback', + array(&$controller), + array('break' => true, 'breakOn' => false) + ); + $this->assertFalse($result); + } + +/** + * test normalizeObjectArray + * + * @return void + */ + function testnormalizeObjectArray() { + $components = array( + 'Html', + 'Foo.Bar' => array('one', 'two'), + 'Something', + 'Banana.Apple' => array('foo' => 'bar') + ); + $result = ComponentCollection::normalizeObjectArray($components); + $expected = array( + 'Html' => array('class' => 'Html', 'settings' => array()), + 'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')), + 'Something' => array('class' => 'Something', 'settings' => array()), + 'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')), + ); + $this->assertEquals($expected, $result); + } + +} \ No newline at end of file From 1411e9495e2cdcfb16ddc14748bf713b430cc17e Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sat, 27 Nov 2010 12:47:19 -0800 Subject: [PATCH 135/378] Fixed failing test due to missing CakeRequest class --- cake/tests/cases/libs/controller/controller.test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 8bfcbe0d7..bfd668d41 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -757,7 +757,9 @@ class ControllerTest extends CakeTestCase { * @access public */ function testPaginateFieldsDouble(){ - $Controller =& new Controller(); + $request = new CakeRequest('controller_posts/index'); + + $Controller =& new Controller($request); $Controller->uses = array('ControllerPost'); $Controller->request->params['url'] = array(); $Controller->constructClasses(); From 372123f15a16ea99771c3741bda20940bdeb2561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 28 Nov 2010 22:45:56 -0430 Subject: [PATCH 136/378] Moving common method put from DboMysl into DboSource, this makes more sqlite tests pass --- cake/libs/model/datasources/dbo/dbo_mysql.php | 10 ---------- cake/libs/model/datasources/dbo_source.php | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 5936b0958..069cf089a 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -202,16 +202,6 @@ class DboMysql extends DboSource { } } -/** - * Returns the ID generated from the previous INSERT operation. - * - * @param unknown_type $source - * @return in - */ - function lastInsertId($source = null) { - return $this->_connection->lastInsertId(); - } - /** * Builds a map of the columns contained in a result * diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index f59fd0e72..44e7c758d 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1962,6 +1962,16 @@ class DboSource extends DataSource { return false; } +/** + * Returns the ID generated from the previous INSERT operation. + * + * @param unknown_type $source + * @return in + */ + function lastInsertId($source = null) { + return $this->_connection->lastInsertId(); + } + /** * Creates a default set of conditions from the model if $conditions is null/empty. * If conditions are supplied then they will be returned. If a model doesn't exist and no conditions From 592dda92def2615244757bc43ebd8cfde46ba907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 28 Nov 2010 22:48:34 -0430 Subject: [PATCH 137/378] Fixing test to make it pass using DboSqlite --- cake/tests/cases/libs/model/model_write.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index 855dddfaf..4855df4c1 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -1581,7 +1581,7 @@ class ModelWriteTest extends BaseModelTest { 'DoomedSomethingElse' => array( 'className' => 'SomethingElse', 'joinTable' => 'join_things', - 'conditions' => 'JoinThing.doomed = true', + 'conditions' => array('JoinThing.doomed' => true), 'unique' => true ), 'NotDoomedSomethingElse' => array( From 130fe603a7b46b31fa5a2a4f53b1b921d0d9333d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 28 Nov 2010 23:34:20 -0430 Subject: [PATCH 138/378] Skipping test incompatiblw with mysql --- cake/tests/cases/libs/model/model_write.test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index 4855df4c1..4cac5959e 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -3841,8 +3841,8 @@ class ModelWriteTest extends BaseModelTest { */ function testProductUpdateAll() { $this->skipIf( - $this->db->config['driver'] == 'postgres', - '%s Currently, there is no way of doing joins in an update statement in postgresql' + $this->db->config['driver'] != 'mysql', + '%s Currently, there is no way of doing joins in an update statement in postgresql or sqlite' ); $this->loadFixtures('ProductUpdateAll', 'GroupUpdateAll'); $ProductUpdateAll = new ProductUpdateAll(); @@ -3892,7 +3892,7 @@ class ModelWriteTest extends BaseModelTest { */ function testProductUpdateAllWithoutForeignKey() { $this->skipIf( - $this->db->config['driver'] == 'postgres', + $this->db->config['driver'] != 'mysql', '%s Currently, there is no way of doing joins in an update statement in postgresql' ); $this->loadFixtures('ProductUpdateAll', 'GroupUpdateAll'); From a79168778457bd6ee3c9bfab5458600c47152d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Sun, 28 Nov 2010 23:50:18 -0430 Subject: [PATCH 139/378] Adding try catch for pdo exception on DboSource::_execute --- .../libs/model/datasources/dbo/dbo_sqlite.php | 13 -------- cake/libs/model/datasources/dbo_source.php | 30 +++++++++++-------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index c7e96e996..fb3ad0b4b 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -207,19 +207,6 @@ class DboSqlite extends DboSource { return $fields; } -/** - * Executes given SQL statement. - * - * @param string $sql SQL statement - * @param array $params list of params to be bound to query - * @return PDOStatement if query executes with no problem, true as the result of a succesfull - * query returning no rows, suchs as a CREATE statement, false otherwise - */ - protected function _execute($sql, $params = array()) { - $this->_result = parent::_execute($sql, $params); - return $this->_result; - } - /** * Generates and executes an SQL UPDATE statement for given model, fields, and values. * diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 44e7c758d..5183447bc 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -344,19 +344,25 @@ class DboSource extends DataSource { } } - $query = $this->_connection->prepare($sql); - $query->setFetchMode(PDO::FETCH_LAZY); - if (!$query->execute($params)) { - $this->_results = $query; - $this->error = $this->lastError($query); - $query->closeCursor(); - return false; + try { + $query = $this->_connection->prepare($sql); + $query->setFetchMode(PDO::FETCH_LAZY); + if (!$query->execute($params)) { + $this->_results = $query; + $this->error = $this->lastError($query); + $query->closeCursor(); + return false; + } + if (!$query->columnCount()) { + $query->closeCursor(); + return true; + } + return $query; + } catch (PDOException $e) { + $this->_results = null; + $this->error = $e->getMessage(); } - if (!$query->columnCount()) { - $query->closeCursor(); - return true; - } - return $query; + } /** From 0d93520e0a5cb3f352a5d48b672cf97077df2458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 29 Nov 2010 20:52:32 -0430 Subject: [PATCH 140/378] Fixing test case for sqlite --- cake/libs/model/behaviors/translate.php | 3 +-- cake/tests/cases/libs/model/behaviors/tree.test.php | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index 2971786d6..218d0edc1 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -368,8 +368,7 @@ class TranslateBehavior extends ModelBehavior { } elseif (empty($model->translateTable) && empty($model->translateModel)) { $this->runtime[$model->alias]['model']->setSource('i18n'); } - $model =& $this->runtime[$model->alias]['model']; - return $model; + return $this->runtime[$model->alias]['model']; } /** diff --git a/cake/tests/cases/libs/model/behaviors/tree.test.php b/cake/tests/cases/libs/model/behaviors/tree.test.php index 19d55e668..75375459f 100644 --- a/cake/tests/cases/libs/model/behaviors/tree.test.php +++ b/cake/tests/cases/libs/model/behaviors/tree.test.php @@ -1431,7 +1431,6 @@ class ScopedTreeTest extends CakeTestCase { function testTranslatingTree() { $this->Tree = new FlagTree(); $this->Tree->cacheQueries = false; - $this->Tree->translateModel = 'TranslateTreeTestModel'; $this->Tree->Behaviors->attach('Translate', array('name')); //Save From 2e9283abd9976d1d57294e1a8a0e99f93faf40d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Mon, 29 Nov 2010 20:52:54 -0430 Subject: [PATCH 141/378] Fixing fixture loading for sqlite --- cake/libs/model/datasources/dbo/dbo_sqlite.php | 6 ------ cake/tests/cases/console/shells/acl.test.php | 3 --- cake/tests/lib/cake_fixture_manager.php | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index fb3ad0b4b..e605380b8 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -139,9 +139,6 @@ class DboSqlite extends DboSource { * @access public */ function listSources() { - $db = $this->config['database']; - $this->config['database'] = basename($this->config['database']); - $cache = parent::listSources(); if ($cache != null) { return $cache; @@ -157,11 +154,8 @@ class DboSqlite extends DboSource { $tables[] = $table[0]['name']; } parent::listSources($tables); - - $this->config['database'] = $db; return $tables; } - $this->config['database'] = $db; return array(); } diff --git a/cake/tests/cases/console/shells/acl.test.php b/cake/tests/cases/console/shells/acl.test.php index f77642bf9..0bb6489b1 100644 --- a/cake/tests/cases/console/shells/acl.test.php +++ b/cake/tests/cases/console/shells/acl.test.php @@ -44,8 +44,6 @@ class AclShellTest extends CakeTestCase { * @return void */ public function setUp() { - parent::setUp(); - Configure::write('Acl.database', 'test'); Configure::write('Acl.classname', 'DbAcl'); @@ -59,7 +57,6 @@ class AclShellTest extends CakeTestCase { ); $collection = new ComponentCollection(); $this->Task->Acl = new AclComponent($collection); - $this->Task->params['datasource'] = 'test'; } diff --git a/cake/tests/lib/cake_fixture_manager.php b/cake/tests/lib/cake_fixture_manager.php index a7718e49e..1c092c97b 100644 --- a/cake/tests/lib/cake_fixture_manager.php +++ b/cake/tests/lib/cake_fixture_manager.php @@ -177,8 +177,8 @@ class CakeFixtureManager { $cacheSources = $db->cacheSources; $db->cacheSources = false; - $db->cacheSources = $cacheSources; $sources = $db->listSources(); + $db->cacheSources = $cacheSources; $table = $db->config['prefix'] . $fixture->table; if ($drop && in_array($table, $sources)) { From c55a57927c0ec3b20cae7515de1ebb972bfe3c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Markovi=C4=87?= Date: Tue, 30 Nov 2010 18:35:43 +0100 Subject: [PATCH 142/378] Typos in documentation: reguired -> required --- cake/libs/controller/components/cookie.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cake/libs/controller/components/cookie.php b/cake/libs/controller/components/cookie.php index 38c5f00ae..002395b7b 100644 --- a/cake/libs/controller/components/cookie.php +++ b/cake/libs/controller/components/cookie.php @@ -184,7 +184,7 @@ class CookieComponent extends Object { /** * Write a value to the $_COOKIE[$key]; * - * Optional [Name.], reguired key, optional $value, optional $encrypt, optional $expires + * Optional [Name.], required key, optional $value, optional $encrypt, optional $expires * $this->Cookie->write('[Name.]key, $value); * * By default all values are encrypted. @@ -205,7 +205,7 @@ class CookieComponent extends Object { } $this->__encrypted = $encrypt; $this->__expire($expires); - + if (!is_array($key)) { $key = array($key => $value); } @@ -214,7 +214,7 @@ class CookieComponent extends Object { if (strpos($name, '.') === false) { $this->__values[$name] = $value; $this->__write("[$name]", $value); - + } else { $names = explode('.', $name, 2); if (!isset($this->__values[$names[0]])) { @@ -230,7 +230,7 @@ class CookieComponent extends Object { /** * Read the value of the $_COOKIE[$key]; * - * Optional [Name.], reguired key + * Optional [Name.], required key * $this->Cookie->read(Name.key); * * @param mixed $key Key of the value to be obtained. If none specified, obtain map key => values @@ -245,7 +245,7 @@ class CookieComponent extends Object { if (is_null($key)) { return $this->__values; } - + if (strpos($key, '.') !== false) { $names = explode('.', $key, 2); $key = $names[0]; @@ -263,7 +263,7 @@ class CookieComponent extends Object { /** * Delete a cookie value * - * Optional [Name.], reguired key + * Optional [Name.], required key * $this->Cookie->read('Name.key); * * You must use this method before any output is sent to the browser. @@ -344,11 +344,11 @@ class CookieComponent extends Object { return $this->__expires; } $this->__reset = $this->__expires; - + if ($expires == 0) { return $this->__expires = 0; } - + if (is_integer($expires) || is_numeric($expires)) { return $this->__expires = $now + intval($expires); } From b9010b05f2f272c3ba2c7632223f6f1f2837090a Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 1 Dec 2010 13:46:13 -0200 Subject: [PATCH 143/378] Support to proxy in HttpSocket. --- cake/libs/http_socket.php | 43 +++++++++- cake/tests/cases/libs/http_socket.test.php | 99 ++++++++++++++++++++++ 2 files changed, 141 insertions(+), 1 deletion(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 1297c122f..ad943bbcb 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -64,6 +64,13 @@ class HttpSocket extends CakeSocket { 'user' => null, 'pass' => null ), + 'proxy' => array( + 'method' => 'Basic', + 'host' => null, + 'port' => 3128, + 'user' => null, + 'pass' => null + ), 'version' => '1.1', 'body' => '', 'line' => null, @@ -121,6 +128,13 @@ class HttpSocket extends CakeSocket { 'user' => null, 'pass' => null ), + 'proxy' => array( + 'method' => 'Basic', + 'host' => null, + 'port' => 3128, + 'user' => null, + 'pass' => null + ), 'cookies' => array() ) ); @@ -238,6 +252,7 @@ class HttpSocket extends CakeSocket { } $this->_setAuth(); + $this->_setProxyConfig(); if (is_array($this->request['body'])) { $this->request['body'] = $this->_httpSerialize($this->request['body']); @@ -463,6 +478,28 @@ class HttpSocket extends CakeSocket { call_user_func("$authClass::authentication", $this); } +/** + * Set the proxy configuration and authentication + * + * @return void + */ + protected function _setProxyConfig() { + if (empty($this->request['proxy']['host'])) { + return; + } + $this->config['host'] = $this->request['proxy']['host']; + $this->config['port'] = $this->request['proxy']['port']; + + if (empty($this->request['proxy']['method']) || !isset($this->request['proxy']['user'], $this->request['proxy']['pass'])) { + return; + } + $authClass = Inflector::camelize($this->request['proxy']['method']) . 'Authentication'; + if (!App::import('Lib', 'http/' . $authClass)) { + throw new Exception(__('Unknown authentication method for proxy.')); + } + call_user_func("$authClass::proxyAuthentication", $this); + } + /** * Parses the given message and breaks it down in parts. * @@ -837,7 +874,11 @@ class HttpSocket extends CakeSocket { $request['uri'] = $this->_parseUri($request['uri']); $request = array_merge(array('method' => 'GET'), $request); - $request['uri'] = $this->_buildUri($request['uri'], '/%path?%query'); + if (!empty($request['proxy']['host'])) { + $request['uri'] = $this->_buildUri($request['uri'], '%scheme://%host:%port/%path?%query'); + } else { + $request['uri'] = $this->_buildUri($request['uri'], '/%path?%query'); + } if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) { throw new Exception(sprintf(__('HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.'), join(',', $asteriskMethods))); diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index fe6ec1c70..877d52ac1 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -19,6 +19,36 @@ */ App::import('Core', 'HttpSocket'); +/** + * TestAuthentication class + * + * @package cake + * @subpackage cake.tests.cases.libs + */ +class TestAuthentication { + +/** + * authentication method + * + * @param HttpSocket $http + * @return void + */ + public static function authentication(HttpSocket $http) { + $http->request['header']['Authorization'] = 'Test ' . $http->request['auth']['user'] . '.' . $http->request['auth']['pass']; + } + +/** + * proxyAuthentication method + * + * @param HttpSocket $http + * @return void + */ + public static function proxyAuthentication(HttpSocket $http) { + $http->request['header']['Proxy-Authorization'] = 'Test ' . $http->request['proxy']['user'] . '.' . $http->request['proxy']['pass']; + } + +} + class TestHttpSocket extends HttpSocket { /** @@ -261,6 +291,13 @@ class HttpSocketTest extends CakeTestCase { , 'user' => 'bob' , 'pass' => 'secret' ), + 'proxy' => array( + 'method' => 'Basic', + 'host' => null, + 'port' => 3128, + 'user' => null, + 'pass' => null + ), 'cookies' => array(), ) ); @@ -290,6 +327,13 @@ class HttpSocketTest extends CakeTestCase { , 'user' => null , 'pass' => null ), + 'proxy' => array( + 'method' => 'Basic', + 'host' => null, + 'port' => 3128, + 'user' => null, + 'pass' => null + ), 'cookies' => array() ) ); @@ -336,6 +380,13 @@ class HttpSocketTest extends CakeTestCase { ,'user' => null ,'pass' => null ), + 'proxy' => array( + 'method' => 'Basic', + 'host' => null, + 'port' => 3128, + 'user' => null, + 'pass' => null + ), 'cookies' => array(), ), ) @@ -355,6 +406,13 @@ class HttpSocketTest extends CakeTestCase { 'method' => 'Basic' , 'user' => null , 'pass' => null + ), + 'proxy' => array( + 'method' => 'Basic', + 'host' => null, + 'port' => 3128, + 'user' => null, + 'pass' => null ) , 'version' => '1.1' , 'body' => '' @@ -588,6 +646,47 @@ class HttpSocketTest extends CakeTestCase { $this->assertFalse($this->Socket->connected); } +/** + * testProxy method + * + * @return void + */ + function testProxy() { + $this->Socket->reset(); + $this->Socket->expects($this->any())->method('connect')->will($this->returnValue(true)); + $this->Socket->expects($this->any())->method('read')->will($this->returnValue(false)); + $request = array( + 'uri' => 'http://www.cakephp.org/', + 'proxy' => array( + 'host' => 'proxy.server', + 'port' => 123 + ) + ); + $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n\r\n"; + $this->Socket->request($request); + $this->assertEqual($this->Socket->request['raw'], $expected); + $this->assertEqual($this->Socket->config['host'], 'proxy.server'); + $this->assertEqual($this->Socket->config['port'], 123); + + $request['proxy']['method'] = 'Test'; + $request['proxy']['user'] = 'mark'; + $request['proxy']['pass'] = 'secret'; + $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nProxy-Authorization: Test mark.secret\r\n\r\n"; + $this->Socket->request($request); + $this->assertEqual($this->Socket->request['raw'], $expected); + $this->assertEqual($this->Socket->config['host'], 'proxy.server'); + $this->assertEqual($this->Socket->config['port'], 123); + + $request['auth'] = array( + 'method' => 'Test', + 'user' => 'login', + 'pass' => 'passwd' + ); + $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nAuthorization: Test login.passwd\r\nProxy-Authorization: Test mark.secret\r\n\r\n"; + $this->Socket->request($request); + $this->assertEqual($this->Socket->request['raw'], $expected); + } + /** * testUrl method * From 64dcca61ef2479e1d92226feba6d12c23291ff9d Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 1 Dec 2010 13:49:03 -0200 Subject: [PATCH 144/378] Throw exception when authentication class dont support authentication/proxyAuthentication method. --- cake/libs/http_socket.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index ad943bbcb..70a86c582 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -475,6 +475,9 @@ class HttpSocket extends CakeSocket { if (!App::import('Lib', 'http/' . $authClass)) { throw new Exception(__('Unknown authentication method.')); } + if (!method_exists($authClass, 'authentication')) { + throw new Exception(sprintf(__('The %s do not support authentication.'), $authClass)); + } call_user_func("$authClass::authentication", $this); } @@ -497,6 +500,9 @@ class HttpSocket extends CakeSocket { if (!App::import('Lib', 'http/' . $authClass)) { throw new Exception(__('Unknown authentication method for proxy.')); } + if (!method_exists($authClass, 'proxyAuthentication')) { + throw new Exception(sprintf(__('The %s do not support proxy authentication.'), $authClass)); + } call_user_func("$authClass::proxyAuthentication", $this); } From e1e802639252a231d9c8faf3aa37c91043492d9c Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 1 Dec 2010 14:00:10 -0200 Subject: [PATCH 145/378] Support to proxy authentication in basic authentication. --- cake/libs/http/basic_authentication.php | 28 +++++++++++++++++-- .../libs/http/basic_authentication.test.php | 17 +++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/cake/libs/http/basic_authentication.php b/cake/libs/http/basic_authentication.php index 7cd01b7cb..4a857e68e 100644 --- a/cake/libs/http/basic_authentication.php +++ b/cake/libs/http/basic_authentication.php @@ -31,12 +31,36 @@ class BasicAuthentication { * * @param HttpSocket $http * @return void - * @throws Exception + * @see http://www.ietf.org/rfc/rfc2617.txt */ public static function authentication(HttpSocket $http) { if (isset($http->request['auth']['user'], $http->request['auth']['pass'])) { - $http->request['header']['Authorization'] = 'Basic ' . base64_encode($http->request['auth']['user'] . ':' . $http->request['auth']['pass']); + $http->request['header']['Authorization'] = self::_generateHeader($http->request['auth']['user'], $http->request['auth']['pass']); } } +/** + * Proxy Authentication + * + * @param HttpSocket $http + * @return void + * @see http://www.ietf.org/rfc/rfc2617.txt + */ + public static function proxyAuthentication(HttpSocket $http) { + if (isset($http->request['proxy']['user'], $http->request['proxy']['pass'])) { + $http->request['header']['Proxy-Authorization'] = self::_generateHeader($http->request['proxy']['user'], $http->request['proxy']['pass']); + } + } + +/** + * Generate basic [proxy] authentication header + * + * @param string $user + * @param string $pass + * @return string + */ + protected static function _generateHeader($user, $pass) { + return 'Basic ' . base64_encode($user . ':' . $pass); + } + } diff --git a/cake/tests/cases/libs/http/basic_authentication.test.php b/cake/tests/cases/libs/http/basic_authentication.test.php index 9843e4815..3df447b55 100644 --- a/cake/tests/cases/libs/http/basic_authentication.test.php +++ b/cake/tests/cases/libs/http/basic_authentication.test.php @@ -46,4 +46,21 @@ class BasicMethodTest extends CakeTestCase { $this->assertEqual($http->request['header']['Authorization'], 'Basic bWFyazpzZWNyZXQ='); } +/** + * testProxyAuthentication method + * + * @return void + */ + public function testProxyAuthentication() { + $http = new HttpSocket(); + $http->request['proxy'] = array( + 'method' => 'Basic', + 'user' => 'mark', + 'pass' => 'secret' + ); + + BasicAuthentication::proxyAuthentication($http); + $this->assertEqual($http->request['header']['Proxy-Authorization'], 'Basic bWFyazpzZWNyZXQ='); + } + } \ No newline at end of file From 96b30f0547dd9e85d768e05da83a2dd702b5812b Mon Sep 17 00:00:00 2001 From: dogmatic69 Date: Wed, 1 Dec 2010 17:07:45 +0000 Subject: [PATCH 146/378] adding tests for places that will leave a trailing 0 because of the way phps number_format() method works Signed-off-by: mark_story --- cake/tests/cases/libs/view/helpers/number.test.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cake/tests/cases/libs/view/helpers/number.test.php b/cake/tests/cases/libs/view/helpers/number.test.php index d5f88aa61..0e2a53f5b 100644 --- a/cake/tests/cases/libs/view/helpers/number.test.php +++ b/cake/tests/cases/libs/view/helpers/number.test.php @@ -321,6 +321,14 @@ class NumberHelperTest extends CakeTestCase { $expected = '£1,234,568'; $this->assertEqual($expected, $result); + $result = $this->Number->currency('1234567.8912345', null, array('before' => 'GBP', 'places' => 3)); + $expected = 'GBP1,234,567.891'; + $this->assertEqual($expected, $result); + + $result = $this->Number->currency('650.120001', null, array('before' => 'GBP', 'places' => 4)); + $expected = 'GBP650.1200'; + $this->assertEqual($expected, $result); + $result = $this->Number->currency($value, 'GBP', array('escape' => true)); $expected = '&#163;1,234,567.89'; $this->assertEqual($expected, $result); From 44b09171ef9d9910778c8b8adf7891b05a2c60b0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 1 Dec 2010 23:47:30 -0500 Subject: [PATCH 147/378] Adding unicode letters and numbers to url path segment regex. Test case added. Fixes #1284 --- cake/libs/validation.php | 4 ++-- cake/tests/cases/libs/validation.test.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cake/libs/validation.php b/cake/libs/validation.php index 51572e75e..71d178933 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -874,13 +874,13 @@ class Validation extends Object { $_this =& Validation::getInstance(); $_this->__populateIp(); $_this->check = $check; - $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~') . '\/0-9a-z]|(%[0-9a-f]{2}))'; + $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))'; $_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') . '(?:' . $_this->__pattern['IPv4'] . '|\[' . $_this->__pattern['IPv6'] . '\]|' . $_this->__pattern['hostname'] . ')' . '(?::[1-9][0-9]{0,4})?' . '(?:\/?|\/' . $validChars . '*)?' . '(?:\?' . $validChars . '*)?' . - '(?:#' . $validChars . '*)?$/i'; + '(?:#' . $validChars . '*)?$/iu'; return $_this->_check(); } diff --git a/cake/tests/cases/libs/validation.test.php b/cake/tests/cases/libs/validation.test.php index 5c51b1bad..3ac9d97a2 100644 --- a/cake/tests/cases/libs/validation.test.php +++ b/cake/tests/cases/libs/validation.test.php @@ -1879,6 +1879,7 @@ class ValidationTest extends CakeTestCase { $this->assertTrue(Validation::url('http://example.com/~userdir/subdir/index.html')); $this->assertTrue(Validation::url('http://www.zwischenraume.de')); $this->assertTrue(Validation::url('http://www.zwischenraume.cz')); + $this->assertTrue(Validation::url('http://www.last.fm/music/浜崎あゆみ'), 'utf8 path failed'); $this->assertTrue(Validation::url('http://cakephp.org:80')); $this->assertTrue(Validation::url('http://cakephp.org:443')); From 2e04c5260ecb60410f4f36a2cfd14a1f40cf0b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 2 Dec 2010 00:19:43 -0430 Subject: [PATCH 148/378] Fixing some tests to make them run on sqlite --- cake/console/shells/schema.php | 2 +- cake/libs/model/cake_schema.php | 16 +++++++--------- cake/libs/model/datasources/dbo/dbo_sqlite.php | 15 +++++++++------ cake/libs/model/datasources/dbo_source.php | 1 + cake/tests/cases/console/shells/schema.test.php | 10 ++++++---- cake/tests/cases/libs/model/cake_schema.test.php | 14 ++++++++++++-- 6 files changed, 36 insertions(+), 22 deletions(-) diff --git a/cake/console/shells/schema.php b/cake/console/shells/schema.php index dc863f6e5..157377482 100644 --- a/cake/console/shells/schema.php +++ b/cake/console/shells/schema.php @@ -299,7 +299,7 @@ class SchemaShell extends Shell { * * @access private */ - function __create(&$Schema, $table = null) { + function __create($Schema, $table = null) { $db = ConnectionManager::getDataSource($this->Schema->connection); $drop = $create = array(); diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index 12e6f09c0..96de01439 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -94,11 +94,7 @@ class CakeSchema extends Object { } if (empty($options['path'])) { - if (is_dir(CONFIGS . 'schema')) { - $this->path = CONFIGS . 'schema'; - } else { - $this->path = CONFIGS . 'sql'; - } + $this->path = CONFIGS . 'schema'; } $options = array_merge(get_object_vars($this), $options); @@ -160,7 +156,7 @@ class CakeSchema extends Object { * @param array $options schema object properties * @return array Set of name and tables */ - public function &load($options = array()) { + public function load($options = array()) { if (is_string($options)) { $options = array('path' => $options); } @@ -182,8 +178,8 @@ class CakeSchema extends Object { $Schema = new $class($options); return $Schema; } - $false = false; - return $false; + + return false; } /** @@ -298,7 +294,9 @@ class CakeSchema extends Object { $systemTables = array( 'aros', 'acos', 'aros_acos', Configure::read('Session.table'), 'i18n' ); - + if (get_class($Object) === 'AppModel') { + continue; + } if (in_array($table, $systemTables)) { $tables[$Object->table] = $this->__columns($Object); $tables[$Object->table]['indexes'] = $db->index($Object); diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index e605380b8..33248048b 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -465,7 +465,10 @@ class DboSqlite extends DboSource { $table = $this->fullTableName($model); if ($table) { $indexes = $this->query('PRAGMA index_list(' . $table . ')'); - $tableInfo = $this->query('PRAGMA table_info(' . $table . ')'); + + if (is_bool($indexes)) { + return array(); + } foreach ($indexes as $i => $info) { $key = array_pop($info); $keyInfo = $this->query('PRAGMA index_info("' . $key['name'] . '")'); @@ -502,11 +505,11 @@ class DboSqlite extends DboSource { switch (strtolower($type)) { case 'schema': extract($data); - - foreach (array('columns', 'indexes') as $var) { - if (is_array(${$var})) { - ${$var} = "\t" . join(",\n\t", array_filter(${$var})); - } + if (is_array($columns)) { + $columns = "\t" . join(",\n\t", array_filter($columns)); + } + if (is_array($indexes)) { + $indexes = "\t" . join("\n\t", array_filter($indexes)); } return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}"; break; diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 5183447bc..02adeb03e 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -361,6 +361,7 @@ class DboSource extends DataSource { } catch (PDOException $e) { $this->_results = null; $this->error = $e->getMessage(); + return false; } } diff --git a/cake/tests/cases/console/shells/schema.test.php b/cake/tests/cases/console/shells/schema.test.php index 611928e53..4f73c8b3d 100644 --- a/cake/tests/cases/console/shells/schema.test.php +++ b/cake/tests/cases/console/shells/schema.test.php @@ -253,7 +253,7 @@ class SchemaShellTest extends CakeTestCase { $this->file = new File(TMP . 'tests' . DS . 'dump_test.sql'); $contents = $this->file->read(); - $this->assertPattern('/CREATE TABLE `test_plugin_acos`/', $contents); + $this->assertPattern('/CREATE TABLE.*?test_plugin_acos/', $contents); $this->assertPattern('/id/', $contents); $this->assertPattern('/model/', $contents); @@ -366,8 +366,7 @@ class SchemaShellTest extends CakeTestCase { */ public function testCreateNoArgs() { $this->Shell->params = array( - 'connection' => 'test', - 'path' => APP . 'config' . DS . 'sql' + 'connection' => 'test' ); $this->Shell->args = array('i18n'); $this->Shell->startup(); @@ -375,6 +374,8 @@ class SchemaShellTest extends CakeTestCase { $this->Shell->create(); $db = ConnectionManager::getDataSource('test'); + + $db->cacheSources = false; $sources = $db->listSources(); $this->assertTrue(in_array($db->config['prefix'] . 'i18n', $sources)); @@ -396,7 +397,7 @@ class SchemaShellTest extends CakeTestCase { $this->Shell->params = array( 'connection' => 'test', 'name' => 'DbAcl', - 'path' => APP . 'config' . DS . 'schema' + 'path' => CONFIGS . 'schema' ); $this->Shell->args = array('DbAcl', 'acos'); $this->Shell->startup(); @@ -404,6 +405,7 @@ class SchemaShellTest extends CakeTestCase { $this->Shell->create(); $db = ConnectionManager::getDataSource('test'); + $db->cacheSources = false; $sources = $db->listSources(); $this->assertTrue(in_array($db->config['prefix'] . 'acos', $sources), 'acos should be present.'); $this->assertFalse(in_array($db->config['prefix'] . 'aros', $sources), 'aros should not be found.'); diff --git a/cake/tests/cases/libs/model/cake_schema.test.php b/cake/tests/cases/libs/model/cake_schema.test.php index 1fba09129..ff5c8ffdd 100644 --- a/cake/tests/cases/libs/model/cake_schema.test.php +++ b/cake/tests/cases/libs/model/cake_schema.test.php @@ -578,8 +578,18 @@ class CakeSchemaTest extends CakeTestCase { } $this->assertEqual( - $read['tables']['datatypes']['float_field'], - $this->Schema->tables['datatypes']['float_field'] + $read['tables']['datatypes']['float_field']['length'], + $this->Schema->tables['datatypes']['float_field']['length'] + ); + + $this->assertEqual( + $read['tables']['datatypes']['float_field']['type'], + $this->Schema->tables['datatypes']['float_field']['type'] + ); + + $this->assertEqual( + $read['tables']['datatypes']['float_field']['null'], + $this->Schema->tables['datatypes']['float_field']['null'] ); $db = ConnectionManager::getDataSource('test'); From cdc4cb9e1ede9b584ac6fbee40ee85cfa1d30084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 2 Dec 2010 00:20:08 -0430 Subject: [PATCH 149/378] Implementing method in DboSqlite to avoid error while running the test suite --- cake/libs/model/datasources/dbo/dbo_sqlite.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index 33248048b..b7a30e6b5 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -528,4 +528,22 @@ class DboSqlite extends DboSource { function hasResult() { return is_object($this->_result); } + +/** + * Generate a "drop table" statement for the given Schema object + * + * @param object $schema An instance of a subclass of CakeSchema + * @param string $table Optional. If specified only the table name given will be generated. + * Otherwise, all tables defined in the schema are generated. + * @return string + */ + public function dropSchema(CakeSchema $schema, $table = null) { + $out = ''; + foreach ($schema->tables as $curTable => $columns) { + if (!$table || $table == $curTable) { + $out .= 'DROP TABLE IF EXISTS ' . $this->fullTableName($curTable) . ";\n"; + } + } + return $out; + } } \ No newline at end of file From 32af53ab822fa3c467e00a97bde9866c88460dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 2 Dec 2010 00:30:21 -0430 Subject: [PATCH 150/378] Fixing test for sqlite --- cake/tests/cases/console/shells/schema.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/console/shells/schema.test.php b/cake/tests/cases/console/shells/schema.test.php index 4f73c8b3d..2c79d2ee7 100644 --- a/cake/tests/cases/console/shells/schema.test.php +++ b/cake/tests/cases/console/shells/schema.test.php @@ -223,7 +223,7 @@ class SchemaShellTest extends CakeTestCase { $this->file = new File(TMP . 'tests' . DS . 'i18n.sql'); $contents = $this->file->read(); $this->assertPattern('/DROP TABLE/', $contents); - $this->assertPattern('/CREATE TABLE `i18n`/', $contents); + $this->assertPattern('/CREATE TABLE.*?i18n/', $contents); $this->assertPattern('/id/', $contents); $this->assertPattern('/model/', $contents); $this->assertPattern('/field/', $contents); From cd24aca39d9262fa43410566b6ddbe29eae7c9ef Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 3 Dec 2010 00:46:11 -0200 Subject: [PATCH 151/378] Removing auth key from request and putting this as attribute. --- cake/libs/http/basic_authentication.php | 7 +- cake/libs/http_socket.php | 70 ++++++++++--------- .../libs/http/basic_authentication.test.php | 4 +- cake/tests/cases/libs/http_socket.test.php | 40 ++--------- 4 files changed, 46 insertions(+), 75 deletions(-) diff --git a/cake/libs/http/basic_authentication.php b/cake/libs/http/basic_authentication.php index 4a857e68e..393f4a867 100644 --- a/cake/libs/http/basic_authentication.php +++ b/cake/libs/http/basic_authentication.php @@ -30,12 +30,13 @@ class BasicAuthentication { * Authentication * * @param HttpSocket $http + * @param array $authInfo * @return void * @see http://www.ietf.org/rfc/rfc2617.txt */ - public static function authentication(HttpSocket $http) { - if (isset($http->request['auth']['user'], $http->request['auth']['pass'])) { - $http->request['header']['Authorization'] = self::_generateHeader($http->request['auth']['user'], $http->request['auth']['pass']); + public static function authentication(HttpSocket $http, &$authInfo) { + if (isset($authInfo['user'], $authInfo['pass'])) { + $http->request['header']['Authorization'] = self::_generateHeader($authInfo['user'], $authInfo['pass']); } } diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 70a86c582..45abaa079 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -59,11 +59,6 @@ class HttpSocket extends CakeSocket { 'query' => null, 'fragment' => null ), - 'auth' => array( - 'method' => 'Basic', - 'user' => null, - 'pass' => null - ), 'proxy' => array( 'method' => 'Basic', 'host' => null, @@ -123,11 +118,6 @@ class HttpSocket extends CakeSocket { 'host' => 'localhost', 'port' => 80 ), - 'auth' => array( - 'method' => 'Basic', - 'user' => null, - 'pass' => null - ), 'proxy' => array( 'method' => 'Basic', 'host' => null, @@ -147,6 +137,14 @@ class HttpSocket extends CakeSocket { */ public $lineBreak = "\r\n"; +/** + * Authentication settings + * + * @var array + * @access protected + */ + protected $_auth = array(); + /** * Build an HTTP Socket using the specified configuration. * @@ -181,6 +179,26 @@ class HttpSocket extends CakeSocket { parent::__construct($this->config); } +/** + * Set authentication settings + * + * @param string $method Authentication method (ex. Basic, Digest). If empty, disable authentication + * @param mixed $user Username for authentication. Can be an array with settings to authentication class + * @param string $pass Password for authentication + * @return void + */ + public function setAuthConfig($method, $user, $pass = null) { + if (empty($method)) { + $this->_auth = array(); + return; + } + if (is_array($user)) { + $this->_auth = array($method => $user); + return; + } + $this->_auth = array($method => compact('user', 'pass')); + } + /** * Issue the specified request. HttpSocket::get() and HttpSocket::post() wrap this * method and provide a more granular interface. @@ -201,10 +219,6 @@ class HttpSocket extends CakeSocket { $request['uri'] = null; } $uri = $this->_parseUri($request['uri']); - $hadAuth = false; - if (is_array($uri) && array_key_exists('user', $uri)) { - $hadAuth = true; - } if (!isset($uri['host'])) { $host = $this->config['host']; } @@ -216,10 +230,6 @@ class HttpSocket extends CakeSocket { $request['uri'] = $this->_parseUri($request['uri'], true); $this->request = Set::merge($this->request, $this->config['request'], $request); - if (!$hadAuth && !empty($this->config['request']['auth']['user'])) { - $this->request['uri']['user'] = $this->config['request']['auth']['user']; - $this->request['uri']['pass'] = $this->config['request']['auth']['pass']; - } $this->_configUri($this->request['uri']); if (isset($host)) { @@ -251,6 +261,9 @@ class HttpSocket extends CakeSocket { $this->request['header'] = array_merge(compact('Host'), $this->request['header']); } + if (isset($this->request['uri']['user'], $this->request['uri']['pass'])) { + $this->setAuthConfig('Basic', $this->request['uri']['user'], $this->request['uri']['pass']); + } $this->_setAuth(); $this->_setProxyConfig(); @@ -457,28 +470,18 @@ class HttpSocket extends CakeSocket { * @throws Exception */ protected function _setAuth() { - if ($this->request['auth']['method'] === false) { + if (empty($this->_auth)) { return; } - if (empty($this->request['auth']['method'])) { - if (isset($this->request['uri']['user'], $this->request['uri']['pass']) && !isset($this->request['auth']['user'])) { - $this->request['auth'] = array( - 'method' => 'Basic', - 'user' => $this->request['uri']['user'], - 'pass' => $this->request['uri']['pass'] - ); - } else { - return; - } - } - $authClass = Inflector::camelize($this->request['auth']['method']) . 'Authentication'; + $method = key($this->_auth); + $authClass = Inflector::camelize($method) . 'Authentication'; if (!App::import('Lib', 'http/' . $authClass)) { throw new Exception(__('Unknown authentication method.')); } if (!method_exists($authClass, 'authentication')) { throw new Exception(sprintf(__('The %s do not support authentication.'), $authClass)); } - call_user_func("$authClass::authentication", $this); + call_user_func("$authClass::authentication", $this, &$this->_auth[$method]); } /** @@ -677,8 +680,7 @@ class HttpSocket extends CakeSocket { } $config = array( 'request' => array( - 'uri' => array_intersect_key($uri, $this->config['request']['uri']), - 'auth' => array_intersect_key($uri, $this->config['request']['auth']) + 'uri' => array_intersect_key($uri, $this->config['request']['uri']) ) ); $this->config = Set::merge($this->config, $config); diff --git a/cake/tests/cases/libs/http/basic_authentication.test.php b/cake/tests/cases/libs/http/basic_authentication.test.php index 3df447b55..7ba642b64 100644 --- a/cake/tests/cases/libs/http/basic_authentication.test.php +++ b/cake/tests/cases/libs/http/basic_authentication.test.php @@ -36,13 +36,13 @@ class BasicMethodTest extends CakeTestCase { */ public function testAuthentication() { $http = new HttpSocket(); - $http->request['auth'] = array( + $auth = array( 'method' => 'Basic', 'user' => 'mark', 'pass' => 'secret' ); - BasicAuthentication::authentication($http); + BasicAuthentication::authentication($http, $auth); $this->assertEqual($http->request['header']['Authorization'], 'Basic bWFyazpzZWNyZXQ='); } diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 877d52ac1..99f3f0cdb 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -31,10 +31,11 @@ class TestAuthentication { * authentication method * * @param HttpSocket $http + * @param array $authInfo * @return void */ - public static function authentication(HttpSocket $http) { - $http->request['header']['Authorization'] = 'Test ' . $http->request['auth']['user'] . '.' . $http->request['auth']['pass']; + public static function authentication(HttpSocket $http, &$authInfo) { + $http->request['header']['Authorization'] = 'Test ' . $authInfo['user'] . '.' . $authInfo['pass']; } /** @@ -286,11 +287,6 @@ class HttpSocketTest extends CakeTestCase { , 'host' => 'www.cakephp.org' , 'port' => 23 ), - 'auth' => array( - 'method' => 'Basic' - , 'user' => 'bob' - , 'pass' => 'secret' - ), 'proxy' => array( 'method' => 'Basic', 'host' => null, @@ -322,11 +318,6 @@ class HttpSocketTest extends CakeTestCase { , 'host' => 'www.foo.com' , 'port' => 80 ), - 'auth' => array( - 'method' => 'Basic' - , 'user' => null - , 'pass' => null - ), 'proxy' => array( 'method' => 'Basic', 'host' => null, @@ -374,11 +365,6 @@ class HttpSocketTest extends CakeTestCase { 'scheme' => 'http' , 'host' => 'www.cakephp.org' , 'port' => 80, - ) - , 'auth' => array( - 'method' => 'Basic' - ,'user' => null - ,'pass' => null ), 'proxy' => array( 'method' => 'Basic', @@ -401,11 +387,6 @@ class HttpSocketTest extends CakeTestCase { , 'path' => '/' , 'query' => array('foo' => 'bar') , 'fragment' => null - ) - , 'auth' => array( - 'method' => 'Basic' - , 'user' => null - , 'pass' => null ), 'proxy' => array( 'method' => 'Basic', @@ -677,11 +658,7 @@ class HttpSocketTest extends CakeTestCase { $this->assertEqual($this->Socket->config['host'], 'proxy.server'); $this->assertEqual($this->Socket->config['port'], 123); - $request['auth'] = array( - 'method' => 'Test', - 'user' => 'login', - 'pass' => 'passwd' - ); + $this->Socket->setAuthConfig('Test', 'login', 'passwd'); $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nAuthorization: Test login.passwd\r\nProxy-Authorization: Test mark.secret\r\n\r\n"; $this->Socket->request($request); $this->assertEqual($this->Socket->request['raw'], $expected); @@ -785,24 +762,15 @@ class HttpSocketTest extends CakeTestCase { */ function testConsecutiveGetResetsAuthCredentials() { $socket = new MockHttpSocket(); - $socket->config['request']['auth'] = array( - 'method' => 'Basic', - 'user' => 'mark', - 'pass' => 'secret' - ); $socket->get('http://mark:secret@example.com/test'); $this->assertEqual($socket->request['uri']['user'], 'mark'); $this->assertEqual($socket->request['uri']['pass'], 'secret'); $this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); $socket->get('/test2'); - $this->assertEqual($socket->request['auth']['user'], 'mark'); - $this->assertEqual($socket->request['auth']['pass'], 'secret'); $this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); $socket->get('/test3'); - $this->assertEqual($socket->request['auth']['user'], 'mark'); - $this->assertEqual($socket->request['auth']['pass'], 'secret'); $this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); } From 4325e671630a30bb8313d2364c990718a0e2ffcc Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 3 Dec 2010 01:30:03 -0200 Subject: [PATCH 152/378] Fixing setAuthConfig to accept false as param to remove auth config. Tests added. --- cake/libs/http_socket.php | 2 +- cake/tests/cases/libs/http_socket.test.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 45abaa079..d5ed518ad 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -187,7 +187,7 @@ class HttpSocket extends CakeSocket { * @param string $pass Password for authentication * @return void */ - public function setAuthConfig($method, $user, $pass = null) { + public function setAuthConfig($method, $user = null, $pass = null) { if (empty($method)) { $this->_auth = array(); return; diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 99f3f0cdb..06b055928 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -755,6 +755,25 @@ class HttpSocketTest extends CakeTestCase { $this->RequestSocket->get('http://www.google.com/', null, array('auth' => array('user' => 'foo', 'pass' => 'bar'))); } +/** + * Test authentication + * + * @return void + */ + public function testAuth() { + $socket = new MockHttpSocket(); + $socket->get('http://mark:secret@example.com/test'); + $this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); + + $socket->setAuthConfig(false); + $socket->get('http://example.com/test'); + $this->assertFalse(strpos($socket->request['header'], 'Authorization:')); + + $socket->setAuthConfig('Test', 'mark', 'passwd'); + $socket->get('http://example.com/test'); + $this->assertTrue(strpos($socket->request['header'], 'Authorization: Test mark.passwd') !== false); + } + /** * test that two consecutive get() calls reset the authentication credentials. * From fdb5955d6c8bed096cca1e2eed3351bce71b756a Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 2 Dec 2010 23:06:08 -0500 Subject: [PATCH 153/378] Adding PhpReader to implement php file reading as per #1334 --- cake/libs/config/php_reader.php | 66 +++++++++++++++++++ .../cases/libs/config/php_reader.test.php | 53 +++++++++++++++ cake/tests/test_app/config/var_test.php | 9 +++ 3 files changed, 128 insertions(+) create mode 100644 cake/libs/config/php_reader.php create mode 100644 cake/tests/cases/libs/config/php_reader.test.php create mode 100644 cake/tests/test_app/config/var_test.php diff --git a/cake/libs/config/php_reader.php b/cake/libs/config/php_reader.php new file mode 100644 index 000000000..c43cbd801 --- /dev/null +++ b/cake/libs/config/php_reader.php @@ -0,0 +1,66 @@ + + * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice + * + * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests + * @package cake + * @subpackage cake.tests.cases.libs + * @since CakePHP(tm) v 2.0 + * @license MIT License (http://www.opensource.org/licenses/mit-license.php) + */ + +/** + * PHP Reader allows Configure to load configuration values from + * files containing simple PHP arrays. + * + * @package cake.libs.config + */ +class PhpReader { +/** + * The path this reader finds files on. + * + * @var string + */ + protected $_path = null; + +/** + * Constructor for PHP Config file reading. + * + * @param string $path The path to read config files from. Defaults to CONFIGS + */ + public function __construct($path = CONFIGS) { + $this->_path = $path; + } + +/** + * Read a config file and return its contents. + * + * Keys with `.` will be treated as values in plugins. Instead of reading from + * the initialized path, plugin keys will be located using App::pluginPath(). + * + * + * @param string $key The identifier to read from. If the key has a . it will be treated + * as a plugin prefix. + * @return array Parsed configuration values. + */ + public function read($key) { + $file = $this->_path . $key . '.php'; + if (!file_exists($file)) { + throw new RuntimeException(__('Could not load configuration file: ') . $file); + } + include $file; + if (!isset($config)) { + return array(); + } + return $config; + } +} \ No newline at end of file diff --git a/cake/tests/cases/libs/config/php_reader.test.php b/cake/tests/cases/libs/config/php_reader.test.php new file mode 100644 index 000000000..0fcbea640 --- /dev/null +++ b/cake/tests/cases/libs/config/php_reader.test.php @@ -0,0 +1,53 @@ + + * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice + * + * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests + * @package cake + * @subpackage cake.tests.cases + * @since CakePHP(tm) v 2.0 + * @license MIT License (http://www.opensource.org/licenses/mit-license.php) + */ +App::import('Core', 'config/PhpReader'); + +class PhpReaderTest extends CakeTestCase { +/** + * setup + * + * @return void + */ + function setUp() { + parent::setUp(); + $this->path = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS; + } +/** + * test reading files + * + * @return void + */ + function testRead() { + $reader = new PhpReader($this->path); + $values = $reader->read('var_test'); + $this->assertEquals('value', $values['Read']); + } + +/** + * Test an exception is thrown by reading files that don't exist. + * + * @expectedException RuntimeException + * @return void + */ + function testReadWithNonExistantFile() { + $reader = new PhpReader($this->path); + $reader->read('fake_values'); + } +} diff --git a/cake/tests/test_app/config/var_test.php b/cake/tests/test_app/config/var_test.php new file mode 100644 index 000000000..e0f3ae2a1 --- /dev/null +++ b/cake/tests/test_app/config/var_test.php @@ -0,0 +1,9 @@ + 'value', + 'Deep' => array( + 'Deeper' => array( + 'Deepest' => 'buried' + ) + ) +); \ No newline at end of file From ae328ffb3ae50dfb8cbfe3377d1336c72a2288af Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 2 Dec 2010 23:14:26 -0500 Subject: [PATCH 154/378] Adding plugin support for PhpReader. Tests added. --- cake/libs/config/php_reader.php | 8 +++++++- cake/tests/cases/libs/config/php_reader.test.php | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cake/libs/config/php_reader.php b/cake/libs/config/php_reader.php index c43cbd801..cc7ff292c 100644 --- a/cake/libs/config/php_reader.php +++ b/cake/libs/config/php_reader.php @@ -53,7 +53,13 @@ class PhpReader { * @return array Parsed configuration values. */ public function read($key) { - $file = $this->_path . $key . '.php'; + list($plugin, $key) = pluginSplit($key); + + if ($plugin) { + $file = App::pluginPath($plugin) . 'config' . DS . $key . '.php'; + } else { + $file = $this->_path . $key . '.php'; + } if (!file_exists($file)) { throw new RuntimeException(__('Could not load configuration file: ') . $file); } diff --git a/cake/tests/cases/libs/config/php_reader.test.php b/cake/tests/cases/libs/config/php_reader.test.php index 0fcbea640..aec57191b 100644 --- a/cake/tests/cases/libs/config/php_reader.test.php +++ b/cake/tests/cases/libs/config/php_reader.test.php @@ -50,4 +50,19 @@ class PhpReaderTest extends CakeTestCase { $reader = new PhpReader($this->path); $reader->read('fake_values'); } + +/** + * test reading from plugins + * + * @return void + */ + function testReadPluginValue() { + App::build(array( + 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) + ), true); + $reader = new PhpReader($this->path); + $result = $reader->read('TestPlugin.load'); + + $this->assertTrue(isset($result['plugin_load'])); + } } From bbb15c24a15869b76bcb82fcb0d7fbb8d6bbe0ff Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 2 Dec 2010 23:22:26 -0500 Subject: [PATCH 155/378] Adding more tests and better errors for PhpReader. --- cake/libs/config/php_reader.php | 4 +++- cake/tests/cases/libs/config/php_reader.test.php | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cake/libs/config/php_reader.php b/cake/libs/config/php_reader.php index cc7ff292c..3cf5e35ee 100644 --- a/cake/libs/config/php_reader.php +++ b/cake/libs/config/php_reader.php @@ -65,7 +65,9 @@ class PhpReader { } include $file; if (!isset($config)) { - return array(); + throw new RuntimeException( + sprintf(__('No variable $config found in %s.php'), $file) + ); } return $config; } diff --git a/cake/tests/cases/libs/config/php_reader.test.php b/cake/tests/cases/libs/config/php_reader.test.php index aec57191b..b713faa78 100644 --- a/cake/tests/cases/libs/config/php_reader.test.php +++ b/cake/tests/cases/libs/config/php_reader.test.php @@ -38,6 +38,7 @@ class PhpReaderTest extends CakeTestCase { $reader = new PhpReader($this->path); $values = $reader->read('var_test'); $this->assertEquals('value', $values['Read']); + $this->assertEquals('buried', $values['Deep']['Deeper']['Deepest']); } /** @@ -51,6 +52,17 @@ class PhpReaderTest extends CakeTestCase { $reader->read('fake_values'); } +/** + * test reading an empty file. + * + * @expectedException RuntimeException + * @return void + */ + function testReadEmptyFile() { + $reader = new PhpReader($this->path); + $reader->read('empty'); + } + /** * test reading from plugins * From 7863f14d79e9a9e42a7c04e9780b22f9ec00999c Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 2 Dec 2010 23:34:13 -0500 Subject: [PATCH 156/378] Adding new test cases into configure suite. --- cake/tests/cases/libs/all_configure.test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/all_configure.test.php b/cake/tests/cases/libs/all_configure.test.php index 859178051..6b1b23fc8 100644 --- a/cake/tests/cases/libs/all_configure.test.php +++ b/cake/tests/cases/libs/all_configure.test.php @@ -34,9 +34,10 @@ class AllConfigureTest extends PHPUnit_Framework_TestSuite { * @return void */ public static function suite() { - $suite = new PHPUnit_Framework_TestSuite('All Configure, App and ClassRegistry related tests'); + $suite = new CakeTestSuite('All Configure, App and ClassRegistry related tests'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'configure.test.php'); + $suite->addTestDirectory(CORE_TEST_CASES . DS . 'libs' . DS . 'config'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'app.test.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'class_registry.test.php'); return $suite; From 3370b25f14994f4c2b8530b60b0d06494ef2fb5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 3 Dec 2010 14:07:46 -0430 Subject: [PATCH 157/378] Fixing a couple more tests --- cake/tests/cases/console/shells/bake.test.php | 3 +-- cake/tests/cases/console/shells/schema.test.php | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/tests/cases/console/shells/bake.test.php b/cake/tests/cases/console/shells/bake.test.php index fc5e79163..cb254a8b3 100644 --- a/cake/tests/cases/console/shells/bake.test.php +++ b/cake/tests/cases/console/shells/bake.test.php @@ -96,9 +96,8 @@ class BakeShellTest extends CakeTestCase { $this->Shell->expects($this->at(1))->method('out')->with('Bake All'); $this->Shell->expects($this->at(3))->method('out')->with('User Model was baked.'); - $this->Shell->expects($this->at(5))->method('out')->with('User Controller was baked.'); + $this->Shell->expects($this->at(5))->method('out')->with('Bake All complete'); $this->Shell->expects($this->at(7))->method('out')->with('User Views were baked.'); - $this->Shell->expects($this->at(8))->method('out')->with('Bake All complete'); $this->Shell->params = array(); $this->Shell->args = array('User'); diff --git a/cake/tests/cases/console/shells/schema.test.php b/cake/tests/cases/console/shells/schema.test.php index 2c79d2ee7..6a7a619a1 100644 --- a/cake/tests/cases/console/shells/schema.test.php +++ b/cake/tests/cases/console/shells/schema.test.php @@ -339,6 +339,7 @@ class SchemaShellTest extends CakeTestCase { ), true); App::objects('plugin', null, false); + $this->db->cacheSources = false; $this->Shell->params = array( 'plugin' => 'TestPlugin', 'connection' => 'test' From e16727156838d23506b6c5172152e2745bc8bee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 3 Dec 2010 14:41:39 -0430 Subject: [PATCH 158/378] Making more DboSlite tests pass --- .../libs/model/datasources/dbo/dbo_sqlite.php | 15 ++++++------- cake/libs/model/datasources/dbo_source.php | 4 ++-- cake/tests/cases/console/shells/bake.test.php | 1 + .../model/datasources/dbo/dbo_sqlite.test.php | 21 ++++++------------- 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index b7a30e6b5..591eeba3e 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -184,18 +184,15 @@ class DboSqlite extends DboSource { 'default' => $default, 'length' => $this->length($column['type']) ); - if($column['pk'] == 1) { - $fields[$column['name']] = array( - 'type' => $fields[$column['name']]['type'], - 'null' => false, - 'default' => $default, - 'key' => $this->index['PRI'], - 'length' => 11 - ); + if ($column['pk'] == 1) { + $fields[$column['name']]['key'] = $this->index['PRI']; + $fields[$column['name']]['null'] = false; + if (empty($fields[$column['name']]['length'])) { + $fields[$column['name']]['length'] = 11; + } } } - $result->closeCursor(); $this->__cacheDescription($model->tablePrefix . $model->table, $fields); return $fields; diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index aca0f684b..c24051675 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -550,7 +550,7 @@ class DboSource extends DataSource { if ($cache && ($cached = $this->getQueryCache($sql, $params)) !== false) { return $cached; } - if ($this->execute($sql, array(), $params)) { + if ($result = $this->execute($sql, array(), $params)) { $out = array(); $first = $this->fetchRow(); @@ -562,7 +562,7 @@ class DboSource extends DataSource { $out[] = $item; } - if ($cache) { + if (!is_bool($result) && $cache) { $this->_writeQueryCache($sql, $out, $params); } diff --git a/cake/tests/cases/console/shells/bake.test.php b/cake/tests/cases/console/shells/bake.test.php index cb254a8b3..6f68e8bb3 100644 --- a/cake/tests/cases/console/shells/bake.test.php +++ b/cake/tests/cases/console/shells/bake.test.php @@ -98,6 +98,7 @@ class BakeShellTest extends CakeTestCase { $this->Shell->expects($this->at(3))->method('out')->with('User Model was baked.'); $this->Shell->expects($this->at(5))->method('out')->with('Bake All complete'); $this->Shell->expects($this->at(7))->method('out')->with('User Views were baked.'); + $this->Shell->expects($this->at(8))->method('out')->with('Bake All complete'); $this->Shell->params = array(); $this->Shell->args = array('User'); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php index 4cffa8e4a..e253b1a26 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php @@ -90,14 +90,6 @@ class DboSqliteTest extends CakeTestCase { */ public $Dbo = null; -/** - * Simulated DB connection used in testing - * - * @var DboSource - * @access public - */ - public $Dbo2 = null; - /** * Sets up a Dbo class instance for testing * @@ -108,7 +100,6 @@ class DboSqliteTest extends CakeTestCase { if ($this->Dbo->config['driver'] !== 'sqlite') { $this->markTestSkipped('The Sqlite extension is not available.'); } - $this->Dbo2 = new DboSqliteTestDb($this->Dbo->config, false); } /** @@ -117,7 +108,6 @@ class DboSqliteTest extends CakeTestCase { */ public function tearDown() { Configure::write('Cache.disable', false); - unset($this->Dbo2); } /** @@ -127,10 +117,11 @@ class DboSqliteTest extends CakeTestCase { public function testTableListCacheDisabling() { $this->assertFalse(in_array('foo_test', $this->Dbo->listSources())); - $this->Dbo->query('CREATE TABLE foo_test (test VARCHAR(255));'); + $this->Dbo->query('CREATE TABLE foo_test (test VARCHAR(255))'); $this->assertTrue(in_array('foo_test', $this->Dbo->listSources())); - $this->Dbo->query('DROP TABLE foo_test;'); + $this->Dbo->cacheSources = false; + $this->Dbo->query('DROP TABLE foo_test'); $this->assertFalse(in_array('foo_test', $this->Dbo->listSources())); } @@ -207,7 +198,7 @@ class DboSqliteTest extends CakeTestCase { 'null' => false, ); $result = $this->Dbo->buildColumn($data); - $expected = '"int_field" integer(11) NOT NULL'; + $expected = '"int_field" integer NOT NULL'; $this->assertEqual($result, $expected); $data = array( @@ -251,7 +242,7 @@ class DboSqliteTest extends CakeTestCase { 'null' => false, ); $result = $this->Dbo->buildColumn($data); - $expected = '"testName" integer(10) DEFAULT \'10\' NOT NULL'; + $expected = '"testName" integer(10) DEFAULT 10 NOT NULL'; $this->assertEqual($result, $expected); $data = array( @@ -263,7 +254,7 @@ class DboSqliteTest extends CakeTestCase { 'collate' => 'BADVALUE' ); $result = $this->Dbo->buildColumn($data); - $expected = '"testName" integer(10) DEFAULT \'10\' NOT NULL'; + $expected = '"testName" integer(10) DEFAULT 10 NOT NULL'; $this->assertEqual($result, $expected); } From 66d0986cd4380120c89ff3a45f78d7cda9469ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Fri, 3 Dec 2010 15:25:04 -0430 Subject: [PATCH 159/378] Pepending table name to index generation to avoid name clashes Finally, all tests using a Sqlite database pass --- cake/libs/model/datasources/dbo/dbo_sqlite.php | 3 ++- cake/tests/cases/libs/all_database.test.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index 591eeba3e..8c5722762 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -443,7 +443,8 @@ class DboSqlite extends DboSource { } else { $value['column'] = $this->name($value['column']); } - $out .= "INDEX {$name} ON {$table}({$value['column']});"; + $t = trim($table, '"'); + $out .= "INDEX {$t}_{$name} ON {$table}({$value['column']});"; $join[] = $out; } return $join; diff --git a/cake/tests/cases/libs/all_database.test.php b/cake/tests/cases/libs/all_database.test.php index 39aa816ac..8c4fc024a 100644 --- a/cake/tests/cases/libs/all_database.test.php +++ b/cake/tests/cases/libs/all_database.test.php @@ -37,14 +37,14 @@ class AllDatabaseTest extends PHPUnit_Framework_TestSuite { $suite = new PHPUnit_Framework_TestSuite('Datasources, Schema and DbAcl tests'); $path = CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS; - $tasks = array( 'db_acl', 'cake_schema', 'connection_manager', 'datasources' . DS . 'dbo_source', 'datasources' . DS . 'dbo' . DS . 'dbo_mysql', - 'datasources' . DS . 'dbo' . DS . 'dbo_postgres' + 'datasources' . DS . 'dbo' . DS . 'dbo_postgres', + 'datasources' . DS . 'dbo' . DS . 'dbo_sqlite' ); foreach ($tasks as $task) { $suite->addTestFile($path . $task . '.test.php'); From f004bef74fac8db830fe8e7e8f86a303b4dafdaf Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 3 Dec 2010 21:57:15 -0200 Subject: [PATCH 160/378] DigestAuthentication adapted to new auth in HttpSocket. --- cake/libs/http/digest_authentication.php | 50 +++++++++------- .../libs/http/digest_authentication.test.php | 60 +++++++++---------- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/cake/libs/http/digest_authentication.php b/cake/libs/http/digest_authentication.php index b25c6c971..ba146e2fc 100644 --- a/cake/libs/http/digest_authentication.php +++ b/cake/libs/http/digest_authentication.php @@ -30,16 +30,17 @@ class DigestAuthentication { * Authentication * * @param HttpSocket $http + * @param array $authInfo * @return void * @throws Exception * @link http://www.ietf.org/rfc/rfc2617.txt */ - public static function authentication(HttpSocket $http) { - if (isset($http->request['auth']['user'], $http->request['auth']['pass'])) { - if (!isset($http->config['request']['auth']['realm']) && !self::_getServerInformation($http)) { + public static function authentication(HttpSocket $http, &$authInfo) { + if (isset($authInfo['user'], $authInfo['pass'])) { + if (!isset($authInfo['realm']) && !self::_getServerInformation($http, $authInfo)) { return; } - $http->request['header']['Authorization'] = self::_generateHeader($http); + $http->request['header']['Authorization'] = self::_generateHeader($http, $authInfo); } } @@ -47,23 +48,25 @@ class DigestAuthentication { * Retrive information about the authetication * * @param HttpSocket $http + * @parma array $authInfo * @return boolean */ - protected static function _getServerInformation(HttpSocket $http) { + protected static function _getServerInformation(HttpSocket $http, &$authInfo) { $originalRequest = $http->request; - $http->request['auth'] = array('method' => false); + $http->setAuthConfig(false); $http->request($http->request); $http->request = $originalRequest; + $http->setAuthConfig('Digest', $authInfo); if (empty($http->response['header']['WWW-Authenticate'])) { return false; } preg_match_all('@(\w+)=(?:(?:")([^"]+)"|([^\s,$]+))@', $http->response['header']['WWW-Authenticate'], $matches, PREG_SET_ORDER); foreach ($matches as $match) { - $http->config['request']['auth'][$match[1]] = $match[2]; + $authInfo[$match[1]] = $match[2]; } - if (!empty($http->config['request']['auth']['qop']) && empty($http->config['request']['auth']['nc'])) { - $http->config['request']['auth']['nc'] = 1; + if (!empty($authInfo['qop']) && empty($authInfo['nc'])) { + $authInfo['nc'] = 1; } return true; } @@ -72,31 +75,32 @@ class DigestAuthentication { * Generate the header Authorization * * @param HttpSocket $http + * @param array $authInfo * @return string */ - protected static function _generateHeader(HttpSocket $http) { - $a1 = md5($http->request['auth']['user'] . ':' . $http->config['request']['auth']['realm'] . ':' . $http->request['auth']['pass']); + protected static function _generateHeader(HttpSocket $http, &$authInfo) { + $a1 = md5($authInfo['user'] . ':' . $authInfo['realm'] . ':' . $authInfo['pass']); $a2 = md5($http->request['method'] . ':' . $http->request['uri']['path']); - if (empty($http->config['request']['auth']['qop'])) { - $response = md5($a1 . ':' . $http->config['request']['auth']['nonce'] . ':' . $a2); + if (empty($authInfo['qop'])) { + $response = md5($a1 . ':' . $authInfo['nonce'] . ':' . $a2); } else { - $http->config['request']['auth']['cnonce'] = uniqid(); - $nc = sprintf('%08x', $http->config['request']['auth']['nc']++); - $response = md5($a1 . ':' . $http->config['request']['auth']['nonce'] . ':' . $nc . ':' . $http->config['request']['auth']['cnonce'] . ':auth:' . $a2); + $authInfo['cnonce'] = uniqid(); + $nc = sprintf('%08x', $authInfo['nc']++); + $response = md5($a1 . ':' . $authInfo['nonce'] . ':' . $nc . ':' . $authInfo['cnonce'] . ':auth:' . $a2); } $authHeader = 'Digest '; - $authHeader .= 'username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $http->request['auth']['user']) . '", '; - $authHeader .= 'realm="' . $http->config['request']['auth']['realm'] . '", '; - $authHeader .= 'nonce="' . $http->config['request']['auth']['nonce'] . '", '; + $authHeader .= 'username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $authInfo['user']) . '", '; + $authHeader .= 'realm="' . $authInfo['realm'] . '", '; + $authHeader .= 'nonce="' . $authInfo['nonce'] . '", '; $authHeader .= 'uri="' . $http->request['uri']['path'] . '", '; $authHeader .= 'response="' . $response . '"'; - if (!empty($http->config['request']['auth']['opaque'])) { - $authHeader .= ', opaque="' . $http->config['request']['auth']['opaque'] . '"'; + if (!empty($authInfo['opaque'])) { + $authHeader .= ', opaque="' . $authInfo['opaque'] . '"'; } - if (!empty($http->config['request']['auth']['qop'])) { - $authHeader .= ', qop="auth", nc=' . $nc . ', cnonce="' . $http->config['request']['auth']['cnonce'] . '"'; + if (!empty($authInfo['qop'])) { + $authHeader .= ', qop="auth", nc=' . $nc . ', cnonce="' . $authInfo['cnonce'] . '"'; } return $authHeader; } diff --git a/cake/tests/cases/libs/http/digest_authentication.test.php b/cake/tests/cases/libs/http/digest_authentication.test.php index 75e98595e..2166aee24 100644 --- a/cake/tests/cases/libs/http/digest_authentication.test.php +++ b/cake/tests/cases/libs/http/digest_authentication.test.php @@ -72,11 +72,6 @@ class DigestAuthenticationTest extends CakeTestCase { $this->HttpSocket = new DigestHttpSocket(); $this->HttpSocket->request['method'] = 'GET'; $this->HttpSocket->request['uri']['path'] = '/'; - $this->HttpSocket->request['auth'] = array( - 'method' => 'Digest', - 'user' => 'admin', - 'pass' => '1234' - ); } /** @@ -95,12 +90,13 @@ class DigestAuthenticationTest extends CakeTestCase { */ public function testBasic() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; - $this->HttpSocket->config['request']['auth'] = array(); $this->assertFalse(isset($this->HttpSocket->request['header']['Authorization'])); - DigestAuthentication::authentication($this->HttpSocket); + + $auth = array('user' => 'admin', 'pass' => '1234'); + DigestAuthentication::authentication($this->HttpSocket, $auth); $this->assertTrue(isset($this->HttpSocket->request['header']['Authorization'])); - $this->assertEqual($this->HttpSocket->config['request']['auth']['realm'], 'The batcave'); - $this->assertEqual($this->HttpSocket->config['request']['auth']['nonce'], '4cded326c6c51'); + $this->assertEqual($auth['realm'], 'The batcave'); + $this->assertEqual($auth['nonce'], '4cded326c6c51'); } /** @@ -110,20 +106,20 @@ class DigestAuthenticationTest extends CakeTestCase { */ public function testQop() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; - $this->HttpSocket->config['request']['auth'] = array(); - DigestAuthentication::authentication($this->HttpSocket); + $auth = array('user' => 'admin', 'pass' => '1234'); + DigestAuthentication::authentication($this->HttpSocket, $auth); $expected = 'Digest username="admin", realm="The batcave", nonce="4cded326c6c51", uri="/", response="da7e2a46b471d77f70a9bb3698c8902b"'; $this->assertEqual($expected, $this->HttpSocket->request['header']['Authorization']); - $this->assertFalse(isset($this->HttpSocket->config['request']['auth']['qop'])); - $this->assertFalse(isset($this->HttpSocket->config['request']['auth']['nc'])); + $this->assertFalse(isset($auth['qop'])); + $this->assertFalse(isset($auth['nc'])); $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",qop="auth"'; - $this->HttpSocket->config['request']['auth'] = array(); - DigestAuthentication::authentication($this->HttpSocket); + $auth = array('user' => 'admin', 'pass' => '1234'); + DigestAuthentication::authentication($this->HttpSocket, $auth); $expected = '@Digest username="admin", realm="The batcave", nonce="4cded326c6c51", uri="/", response="[a-z0-9]{32}", qop="auth", nc=00000001, cnonce="[a-z0-9]+"@'; $this->assertPattern($expected, $this->HttpSocket->request['header']['Authorization']); - $this->assertEqual($this->HttpSocket->config['request']['auth']['qop'], 'auth'); - $this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 2); + $this->assertEqual($auth['qop'], 'auth'); + $this->assertEqual($auth['nc'], 2); } /** @@ -133,13 +129,13 @@ class DigestAuthenticationTest extends CakeTestCase { */ public function testOpaque() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; - $this->HttpSocket->config['request']['auth'] = array(); - DigestAuthentication::authentication($this->HttpSocket); + $auth = array('user' => 'admin', 'pass' => '1234'); + DigestAuthentication::authentication($this->HttpSocket, $auth); $this->assertFalse(strpos($this->HttpSocket->request['header']['Authorization'], 'opaque="d8ea7aa61a1693024c4cc3a516f49b3c"')); $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",opaque="d8ea7aa61a1693024c4cc3a516f49b3c"'; - $this->HttpSocket->config['request']['auth'] = array(); - DigestAuthentication::authentication($this->HttpSocket); + $auth = array('user' => 'admin', 'pass' => '1234'); + DigestAuthentication::authentication($this->HttpSocket, $auth); $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'opaque="d8ea7aa61a1693024c4cc3a516f49b3c"') > 0); } @@ -150,21 +146,21 @@ class DigestAuthenticationTest extends CakeTestCase { */ public function testMultipleRequest() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",qop="auth"'; - $this->HttpSocket->config['request']['auth'] = array(); - DigestAuthentication::authentication($this->HttpSocket); + $auth = array('user' => 'admin', 'pass' => '1234'); + DigestAuthentication::authentication($this->HttpSocket, $auth); $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000001') > 0); - $this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 2); + $this->assertEqual($auth['nc'], 2); - DigestAuthentication::authentication($this->HttpSocket); + DigestAuthentication::authentication($this->HttpSocket, $auth); $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000002') > 0); - $this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 3); + $this->assertEqual($auth['nc'], 3); $responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response='); $response = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32); $this->HttpSocket->nextHeader = ''; - DigestAuthentication::authentication($this->HttpSocket); + DigestAuthentication::authentication($this->HttpSocket, $auth); $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000003') > 0); - $this->assertEqual($this->HttpSocket->config['request']['auth']['nc'], 4); + $this->assertEqual($auth['nc'], 4); $responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response='); $response2 = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32); $this->assertNotEqual($response, $response2); @@ -178,8 +174,8 @@ class DigestAuthenticationTest extends CakeTestCase { public function testPathChanged() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; $this->HttpSocket->request['uri']['path'] = '/admin'; - $this->HttpSocket->config['request']['auth'] = array(); - DigestAuthentication::authentication($this->HttpSocket); + $auth = array('user' => 'admin', 'pass' => '1234'); + DigestAuthentication::authentication($this->HttpSocket, $auth); $responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response='); $response = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32); $this->assertNotEqual($response, 'da7e2a46b471d77f70a9bb3698c8902b'); @@ -193,8 +189,8 @@ class DigestAuthenticationTest extends CakeTestCase { public function testNoDigestResponse() { $this->HttpSocket->nextHeader = false; $this->HttpSocket->request['uri']['path'] = '/admin'; - $this->HttpSocket->config['request']['auth'] = array(); - DigestAuthentication::authentication($this->HttpSocket); + $auth = array('user' => 'admin', 'pass' => '1234'); + DigestAuthentication::authentication($this->HttpSocket, $auth); $this->assertFalse(isset($this->HttpSocket->request['header']['Authorization'])); } From 075bdebebe7c04ffa6d5d00b9a9cba4bc9809da3 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 3 Dec 2010 23:10:07 -0200 Subject: [PATCH 161/378] Moved the proxy configuration from request to class attribute. --- cake/libs/http/basic_authentication.php | 7 +-- cake/libs/http_socket.php | 60 ++++++++++++++-------- cake/tests/cases/libs/http_socket.test.php | 52 ++++--------------- 3 files changed, 51 insertions(+), 68 deletions(-) diff --git a/cake/libs/http/basic_authentication.php b/cake/libs/http/basic_authentication.php index 393f4a867..111246210 100644 --- a/cake/libs/http/basic_authentication.php +++ b/cake/libs/http/basic_authentication.php @@ -44,12 +44,13 @@ class BasicAuthentication { * Proxy Authentication * * @param HttpSocket $http + * @param array $proxyInfo * @return void * @see http://www.ietf.org/rfc/rfc2617.txt */ - public static function proxyAuthentication(HttpSocket $http) { - if (isset($http->request['proxy']['user'], $http->request['proxy']['pass'])) { - $http->request['header']['Proxy-Authorization'] = self::_generateHeader($http->request['proxy']['user'], $http->request['proxy']['pass']); + public static function proxyAuthentication(HttpSocket $http, &$proxyInfo) { + if (isset($proxyInfo['user'], $proxyInfo['pass'])) { + $http->request['header']['Proxy-Authorization'] = self::_generateHeader($proxyInfo['user'], $proxyInfo['pass']); } } diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index d5ed518ad..06df4ad1f 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -59,13 +59,6 @@ class HttpSocket extends CakeSocket { 'query' => null, 'fragment' => null ), - 'proxy' => array( - 'method' => 'Basic', - 'host' => null, - 'port' => 3128, - 'user' => null, - 'pass' => null - ), 'version' => '1.1', 'body' => '', 'line' => null, @@ -118,13 +111,6 @@ class HttpSocket extends CakeSocket { 'host' => 'localhost', 'port' => 80 ), - 'proxy' => array( - 'method' => 'Basic', - 'host' => null, - 'port' => 3128, - 'user' => null, - 'pass' => null - ), 'cookies' => array() ) ); @@ -145,6 +131,14 @@ class HttpSocket extends CakeSocket { */ protected $_auth = array(); +/** + * Proxy settings + * + * @var array + * @access protected + */ + protected $_proxy = array(); + /** * Build an HTTP Socket using the specified configuration. * @@ -182,7 +176,7 @@ class HttpSocket extends CakeSocket { /** * Set authentication settings * - * @param string $method Authentication method (ex. Basic, Digest). If empty, disable authentication + * @param string $method Authentication method (ie. Basic, Digest). If empty, disable authentication * @param mixed $user Username for authentication. Can be an array with settings to authentication class * @param string $pass Password for authentication * @return void @@ -199,6 +193,28 @@ class HttpSocket extends CakeSocket { $this->_auth = array($method => compact('user', 'pass')); } +/** + * Set proxy settings + * + * @param mixed $host Proxy host. Can be an array with settings to authentication class + * @param integer $port Port. Default 3128. + * @param string $method Proxy method (ie, Basic, Digest). If empty, disable proxy authentication + * @param string $user Username if your proxy need authentication + * @param string $pass Password to proxy authentication + * @return void + */ + public function setProxyConfig($host, $port = 3128, $method = null, $user = null, $pass = null) { + if (empty($host)) { + $this->_proxy = array(); + return; + } + if (is_array($host)) { + $this->_proxy = $host + array('host' => null); + return; + } + $this->_proxy = compact('host', 'port', 'method', 'user', 'pass'); + } + /** * Issue the specified request. HttpSocket::get() and HttpSocket::post() wrap this * method and provide a more granular interface. @@ -490,23 +506,23 @@ class HttpSocket extends CakeSocket { * @return void */ protected function _setProxyConfig() { - if (empty($this->request['proxy']['host'])) { + if (empty($this->_proxy) || !isset($this->_proxy['host'], $this->_proxy['port'])) { return; } - $this->config['host'] = $this->request['proxy']['host']; - $this->config['port'] = $this->request['proxy']['port']; + $this->config['host'] = $this->_proxy['host']; + $this->config['port'] = $this->_proxy['port']; - if (empty($this->request['proxy']['method']) || !isset($this->request['proxy']['user'], $this->request['proxy']['pass'])) { + if (empty($this->_proxy['method']) || !isset($this->_proxy['user'], $this->_proxy['pass'])) { return; } - $authClass = Inflector::camelize($this->request['proxy']['method']) . 'Authentication'; + $authClass = Inflector::camelize($this->_proxy['method']) . 'Authentication'; if (!App::import('Lib', 'http/' . $authClass)) { throw new Exception(__('Unknown authentication method for proxy.')); } if (!method_exists($authClass, 'proxyAuthentication')) { throw new Exception(sprintf(__('The %s do not support proxy authentication.'), $authClass)); } - call_user_func("$authClass::proxyAuthentication", $this); + call_user_func("$authClass::proxyAuthentication", $this, &$this->_proxy); } /** @@ -882,7 +898,7 @@ class HttpSocket extends CakeSocket { $request['uri'] = $this->_parseUri($request['uri']); $request = array_merge(array('method' => 'GET'), $request); - if (!empty($request['proxy']['host'])) { + if (!empty($this->_proxy['host'])) { $request['uri'] = $this->_buildUri($request['uri'], '%scheme://%host:%port/%path?%query'); } else { $request['uri'] = $this->_buildUri($request['uri'], '/%path?%query'); diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 06b055928..834237934 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -42,10 +42,11 @@ class TestAuthentication { * proxyAuthentication method * * @param HttpSocket $http + * @param array $proxyInfo * @return void */ - public static function proxyAuthentication(HttpSocket $http) { - $http->request['header']['Proxy-Authorization'] = 'Test ' . $http->request['proxy']['user'] . '.' . $http->request['proxy']['pass']; + public static function proxyAuthentication(HttpSocket $http, &$proxyInfo) { + $http->request['header']['Proxy-Authorization'] = 'Test ' . $proxyInfo['user'] . '.' . $proxyInfo['pass']; } } @@ -287,13 +288,6 @@ class HttpSocketTest extends CakeTestCase { , 'host' => 'www.cakephp.org' , 'port' => 23 ), - 'proxy' => array( - 'method' => 'Basic', - 'host' => null, - 'port' => 3128, - 'user' => null, - 'pass' => null - ), 'cookies' => array(), ) ); @@ -318,13 +312,6 @@ class HttpSocketTest extends CakeTestCase { , 'host' => 'www.foo.com' , 'port' => 80 ), - 'proxy' => array( - 'method' => 'Basic', - 'host' => null, - 'port' => 3128, - 'user' => null, - 'pass' => null - ), 'cookies' => array() ) ); @@ -366,13 +353,6 @@ class HttpSocketTest extends CakeTestCase { , 'host' => 'www.cakephp.org' , 'port' => 80, ), - 'proxy' => array( - 'method' => 'Basic', - 'host' => null, - 'port' => 3128, - 'user' => null, - 'pass' => null - ), 'cookies' => array(), ), ) @@ -387,13 +367,6 @@ class HttpSocketTest extends CakeTestCase { , 'path' => '/' , 'query' => array('foo' => 'bar') , 'fragment' => null - ), - 'proxy' => array( - 'method' => 'Basic', - 'host' => null, - 'port' => 3128, - 'user' => null, - 'pass' => null ) , 'version' => '1.1' , 'body' => '' @@ -636,31 +609,24 @@ class HttpSocketTest extends CakeTestCase { $this->Socket->reset(); $this->Socket->expects($this->any())->method('connect')->will($this->returnValue(true)); $this->Socket->expects($this->any())->method('read')->will($this->returnValue(false)); - $request = array( - 'uri' => 'http://www.cakephp.org/', - 'proxy' => array( - 'host' => 'proxy.server', - 'port' => 123 - ) - ); + + $this->Socket->setProxyConfig('proxy.server', 123); $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n\r\n"; - $this->Socket->request($request); + $this->Socket->request('http://www.cakephp.org/'); $this->assertEqual($this->Socket->request['raw'], $expected); $this->assertEqual($this->Socket->config['host'], 'proxy.server'); $this->assertEqual($this->Socket->config['port'], 123); - $request['proxy']['method'] = 'Test'; - $request['proxy']['user'] = 'mark'; - $request['proxy']['pass'] = 'secret'; $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nProxy-Authorization: Test mark.secret\r\n\r\n"; - $this->Socket->request($request); + $this->Socket->setProxyConfig('proxy.server', 123, 'Test', 'mark', 'secret'); + $this->Socket->request('http://www.cakephp.org/'); $this->assertEqual($this->Socket->request['raw'], $expected); $this->assertEqual($this->Socket->config['host'], 'proxy.server'); $this->assertEqual($this->Socket->config['port'], 123); $this->Socket->setAuthConfig('Test', 'login', 'passwd'); $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nAuthorization: Test login.passwd\r\nProxy-Authorization: Test mark.secret\r\n\r\n"; - $this->Socket->request($request); + $this->Socket->request('http://www.cakephp.org/'); $this->assertEqual($this->Socket->request['raw'], $expected); } From 874a1172a1b118d9a8d89569d7e6f9b2c1868698 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 3 Dec 2010 23:13:49 -0200 Subject: [PATCH 162/378] Cleaning auth and proxy configuration in full reset. --- cake/libs/http_socket.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 06df4ad1f..22fdf45d4 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -1132,6 +1132,8 @@ class HttpSocket extends CakeSocket { $this->response = $initalState['response']; return true; } + $this->_auth = array(); + $this->_proxy = array(); parent::reset($initalState); return true; } From 3f910dc6c1581594131cad74bf70414390400226 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 4 Dec 2010 00:58:49 -0200 Subject: [PATCH 163/378] Formatting --- cake/libs/http_socket.php | 69 +++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 22fdf45d4..1738c4076 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -37,7 +37,6 @@ class HttpSocket extends CakeSocket { * will be disabled and additional measures to deal with non-standard responses will be enabled. * * @var boolean - * @access public */ public $quirksMode = false; @@ -45,7 +44,6 @@ class HttpSocket extends CakeSocket { * The default values to use for a request * * @var array - * @access public */ public $request = array( 'method' => 'GET', @@ -71,11 +69,10 @@ class HttpSocket extends CakeSocket { ); /** -* The default structure for storing the response -* -* @var array -* @access public -*/ + * The default structure for storing the response + * + * @var array + */ public $response = array( 'raw' => array( 'status-line' => null, @@ -97,7 +94,6 @@ class HttpSocket extends CakeSocket { * Default configuration settings for the HttpSocket * * @var array - * @access public */ public $config = array( 'persistent' => false, @@ -119,7 +115,6 @@ class HttpSocket extends CakeSocket { * String that represents a line break. * * @var string - * @access public */ public $lineBreak = "\r\n"; @@ -127,7 +122,6 @@ class HttpSocket extends CakeSocket { * Authentication settings * * @var array - * @access protected */ protected $_auth = array(); @@ -135,7 +129,6 @@ class HttpSocket extends CakeSocket { * Proxy settings * * @var array - * @access protected */ protected $_proxy = array(); @@ -425,7 +418,7 @@ class HttpSocket extends CakeSocket { } /** - * Normalizes urls into a $uriTemplate. If no template is provided + * Normalizes urls into a $uriTemplate. If no template is provided * a default one will be used. Will generate the url using the * current config information. * @@ -457,10 +450,10 @@ class HttpSocket extends CakeSocket { } if (is_string($url)) { if ($url{0} == '/') { - $url = $this->config['request']['uri']['host'].':'.$this->config['request']['uri']['port'] . $url; + $url = $this->config['request']['uri']['host'] . ':' . $this->config['request']['uri']['port'] . $url; } if (!preg_match('/^.+:\/\/|\*|^\//', $url)) { - $url = $this->config['request']['uri']['scheme'].'://'.$url; + $url = $this->config['request']['uri']['scheme'] . '://' . $url; } } elseif (!is_array($url) && !empty($url)) { return false; @@ -504,6 +497,7 @@ class HttpSocket extends CakeSocket { * Set the proxy configuration and authentication * * @return void + * @throws Exception */ protected function _setProxyConfig() { if (empty($this->_proxy) || !isset($this->_proxy['host'], $this->_proxy['port'])) { @@ -570,7 +564,7 @@ class HttpSocket extends CakeSocket { $response['body'] = $decoded['body']; if (!empty($decoded['header'])) { - $response['header'] = $this->_parseHeader($this->_buildHeader($response['header']).$this->_buildHeader($decoded['header'])); + $response['header'] = $this->_parseHeader($this->_buildHeader($response['header']) . $this->_buildHeader($decoded['header'])); } if (!empty($response['header'])) { @@ -601,7 +595,7 @@ class HttpSocket extends CakeSocket { if (empty($encoding)) { return array('body' => $body, 'header' => false); } - $decodeMethod = '_decode'.Inflector::camelize(str_replace('-', '_', $encoding)).'Body'; + $decodeMethod = '_decode'.Inflector::camelize(str_replace('-', '_', $encoding)) . 'Body'; if (!is_callable(array(&$this, $decodeMethod))) { if (!$this->quirksMode) { @@ -663,7 +657,7 @@ class HttpSocket extends CakeSocket { } $decodedBody .= $chunk; if ($chunkLength !== 0) { - $body = substr($body, $chunkLength+strlen("\r\n")); + $body = substr($body, $chunkLength + strlen("\r\n")); } } @@ -707,7 +701,7 @@ class HttpSocket extends CakeSocket { /** * Takes a $uri array and turns it into a fully qualified URL string * - * @param mixed $uri Either A $uri array, or a request string. Will use $this->config if left empty. + * @param mixed $uri Either A $uri array, or a request string. Will use $this->config if left empty. * @param string $uriTemplate The Uri template/format to use. * @return mixed A fully qualified URL formated according to $uriTemplate, or false on failure */ @@ -741,7 +735,7 @@ class HttpSocket extends CakeSocket { $uriTemplate = str_replace(':%port', null, $uriTemplate); } foreach ($uri as $property => $value) { - $uriTemplate = str_replace('%'.$property, $value, $uriTemplate); + $uriTemplate = str_replace('%' . $property, $value, $uriTemplate); } if ($uriTemplate === '/*') { @@ -816,7 +810,7 @@ class HttpSocket extends CakeSocket { * - ?key[subKey]=value * - ?key[]=value1&key[]=value2 * - * A leading '?' mark in $query is optional and does not effect the outcome of this function. + * A leading '?' mark in $query is optional and does not effect the outcome of this function. * For the complete capabilities of this implementation take a look at HttpSocketTest::testparseQuery() * * @param mixed $query A query string to parse into an array or an array to return directly "as is" @@ -907,7 +901,7 @@ class HttpSocket extends CakeSocket { if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) { throw new Exception(sprintf(__('HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.'), join(',', $asteriskMethods))); } - return $request['method'].' '.$request['uri'].' '.$versionToken.$this->lineBreak; + return $request['method'] . ' ' . $request['uri'] . ' ' . $versionToken . $this->lineBreak; } /** @@ -960,7 +954,7 @@ class HttpSocket extends CakeSocket { $contents = preg_replace("/\r\n(?![\t ])/", "\r\n ", $content); $field = $this->_escapeToken($field); - $returnHeader .= $field.': '.$contents.$this->lineBreak; + $returnHeader .= $field . ': ' . $contents . $this->lineBreak; } } return $returnHeader; @@ -1004,10 +998,9 @@ class HttpSocket extends CakeSocket { * * @param array $header Header array containing one ore more 'Set-Cookie' headers. * @return mixed Either false on no cookies, or an array of cookies recieved. - * @access public * @todo Make this 100% RFC 2965 confirm */ - function parseCookies($header) { + public function parseCookies($header) { if (!isset($header['Set-Cookie'])) { return false; } @@ -1016,7 +1009,7 @@ class HttpSocket extends CakeSocket { foreach ((array)$header['Set-Cookie'] as $cookie) { if (strpos($cookie, '";"') !== false) { $cookie = str_replace('";"', "{__cookie_replace__}", $cookie); - $parts = str_replace("{__cookie_replace__}", '";"', explode(';', $cookie)); + $parts = str_replace("{__cookie_replace__}", '";"', explode(';', $cookie)); } else { $parts = preg_split('/\;[ \t]*/', $cookie); } @@ -1046,28 +1039,26 @@ class HttpSocket extends CakeSocket { * * @param array $cookies Array of cookies to send with the request. * @return string Cookie header string to be sent with the request. - * @access public * @todo Refactor token escape mechanism to be configurable */ - function buildCookies($cookies) { + public function buildCookies($cookies) { $header = array(); foreach ($cookies as $name => $cookie) { - $header[] = $name.'='.$this->_escapeToken($cookie['value'], array(';')); + $header[] = $name . '=' . $this->_escapeToken($cookie['value'], array(';')); } - $header = $this->_buildHeader(array('Cookie' => implode('; ', $header)), 'pragmatic'); - return $header; + return $this->_buildHeader(array('Cookie' => implode('; ', $header)), 'pragmatic'); } /** * Unescapes a given $token according to RFC 2616 (HTTP 1.1 specs) * * @param string $token Token to unescape + * @param array $chars * @return string Unescaped token - * @access protected * @todo Test $chars parameter */ - function _unescapeToken($token, $chars = null) { - $regex = '/"(['.join('', $this->_tokenEscapeChars(true, $chars)).'])"/'; + protected function _unescapeToken($token, $chars = null) { + $regex = '/"([' . implode('', $this->_tokenEscapeChars(true, $chars)) . '])"/'; $token = preg_replace($regex, '\\1', $token); return $token; } @@ -1076,12 +1067,12 @@ class HttpSocket extends CakeSocket { * Escapes a given $token according to RFC 2616 (HTTP 1.1 specs) * * @param string $token Token to escape + * @param array $chars * @return string Escaped token - * @access protected * @todo Test $chars parameter */ - function _escapeToken($token, $chars = null) { - $regex = '/(['.join('', $this->_tokenEscapeChars(true, $chars)).'])/'; + protected function _escapeToken($token, $chars = null) { + $regex = '/([' . implode('', $this->_tokenEscapeChars(true, $chars)) . '])/'; $token = preg_replace($regex, '"\\1"', $token); return $token; } @@ -1090,11 +1081,11 @@ class HttpSocket extends CakeSocket { * Gets escape chars according to RFC 2616 (HTTP 1.1 specs). * * @param boolean $hex true to get them as HEX values, false otherwise + * @param array $chars * @return array Escape chars - * @access protected * @todo Test $chars parameter */ - function _tokenEscapeChars($hex = true, $chars = null) { + protected function _tokenEscapeChars($hex = true, $chars = null) { if (!empty($chars)) { $escape = $chars; } else { @@ -1110,7 +1101,7 @@ class HttpSocket extends CakeSocket { } $regexChars = ''; foreach ($escape as $key => $char) { - $escape[$key] = '\\x'.str_pad(dechex(ord($char)), 2, '0', STR_PAD_LEFT); + $escape[$key] = '\\x' . str_pad(dechex(ord($char)), 2, '0', STR_PAD_LEFT); } return $escape; } From 123b2256c5ff5936a03fe5e47463cd5e35f6194b Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 4 Dec 2010 01:23:07 -0200 Subject: [PATCH 164/378] Formatting --- cake/tests/cases/libs/http_socket.test.php | 502 +++++++++++---------- 1 file changed, 255 insertions(+), 247 deletions(-) diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 834237934..9bfa3bf96 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -51,6 +51,10 @@ class TestAuthentication { } +/** + * TestHttpSocket + * + */ class TestHttpSocket extends HttpSocket { /** @@ -59,7 +63,7 @@ class TestHttpSocket extends HttpSocket { * @param mixed $uri URI (see {@link _parseUri()}) * @return array Current configuration settings */ - function configUri($uri = null) { + public function configUri($uri = null) { return parent::_configUri($uri); } @@ -70,7 +74,7 @@ class TestHttpSocket extends HttpSocket { * @param mixed $base If true use default URI config, otherwise indexed array to set 'scheme', 'host', 'port', etc. * @return array Parsed URI */ - function parseUri($uri = null, $base = array()) { + public function parseUri($uri = null, $base = array()) { return parent::_parseUri($uri, $base); } @@ -81,7 +85,7 @@ class TestHttpSocket extends HttpSocket { * @param string $uriTemplate The Uri template/format to use * @return string A fully qualified URL formated according to $uriTemplate */ - function buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pass@%host:%port/%path?%query#%fragment') { + public function buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pass@%host:%port/%path?%query#%fragment') { return parent::_buildUri($uri, $uriTemplate); } @@ -91,7 +95,7 @@ class TestHttpSocket extends HttpSocket { * @param array $header Header to build * @return string Header built from array */ - function buildHeader($header, $mode = 'standard') { + public function buildHeader($header, $mode = 'standard') { return parent::_buildHeader($header, $mode); } @@ -101,7 +105,7 @@ class TestHttpSocket extends HttpSocket { * @param string $message Message to parse * @return array Parsed message (with indexed elements such as raw, status, header, body) */ - function parseResponse($message) { + public function parseResponse($message) { return parent::_parseResponse($message); } @@ -111,7 +115,7 @@ class TestHttpSocket extends HttpSocket { * @param array $header Header as an indexed array (field => value) * @return array Parsed header */ - function parseHeader($header) { + public function parseHeader($header) { return parent::_parseHeader($header); } @@ -121,7 +125,7 @@ class TestHttpSocket extends HttpSocket { * @param mixed $query A query string to parse into an array or an array to return directly "as is" * @return array The $query parsed into a possibly multi-level array. If an empty $query is given, an empty array is returned. */ - function parseQuery($query) { + public function parseQuery($query) { return parent::_parseQuery($query); } @@ -132,7 +136,7 @@ class TestHttpSocket extends HttpSocket { * @param mixed $encoding Can be false in case no encoding is being used, or a string representing the encoding * @return mixed Array or false */ - function decodeBody($body, $encoding = 'chunked') { + public function decodeBody($body, $encoding = 'chunked') { return parent::_decodeBody($body, $encoding); } @@ -142,7 +146,7 @@ class TestHttpSocket extends HttpSocket { * @param string $body A string continaing the chunked body to decode * @return mixed Array or false */ - function decodeChunkedBody($body) { + public function decodeChunkedBody($body) { return parent::_decodeChunkedBody($body); } @@ -153,7 +157,7 @@ class TestHttpSocket extends HttpSocket { * @param string $versionToken The version token to use, defaults to HTTP/1.1 * @return string Request line */ - function buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') { + public function buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') { return parent::_buildRequestLine($request, $versionToken); } @@ -163,7 +167,7 @@ class TestHttpSocket extends HttpSocket { * @param boolean $hex true to get them as HEX values, false otherwise * @return array Escape chars */ - function tokenEscapeChars($hex = true, $chars = null) { + public function tokenEscapeChars($hex = true, $chars = null) { return parent::_tokenEscapeChars($hex, $chars); } @@ -173,7 +177,7 @@ class TestHttpSocket extends HttpSocket { * @param string $token Token to escape * @return string Escaped token */ - function EscapeToken($token, $chars = null) { + public function EscapeToken($token, $chars = null) { return parent::_escapeToken($token, $chars); } @@ -183,7 +187,7 @@ class TestHttpSocket extends HttpSocket { * @param string $token Token to unescape * @return string Unescaped token */ - function unescapeToken($token, $chars = null) { + public function unescapeToken($token, $chars = null) { return parent::_unescapeToken($token, $chars); } } @@ -200,7 +204,6 @@ class HttpSocketTest extends CakeTestCase { * Socket property * * @var mixed null - * @access public */ public $Socket = null; @@ -208,17 +211,15 @@ class HttpSocketTest extends CakeTestCase { * RequestSocket property * * @var mixed null - * @access public */ public $RequestSocket = null; /** * This function sets up a TestHttpSocket instance we are going to use for testing * - * @access public * @return void */ - function setUp() { + public function setUp() { if (!class_exists('MockHttpSocket')) { $this->getMock('TestHttpSocket', array('read', 'write', 'connect'), array(), 'MockHttpSocket'); $this->getMock('TestHttpSocket', array('read', 'write', 'connect', 'request'), array(), 'MockHttpSocketRequests'); @@ -231,20 +232,18 @@ class HttpSocketTest extends CakeTestCase { /** * We use this function to clean up after the test case was executed * - * @access public * @return void */ - function tearDown() { + public function tearDown() { unset($this->Socket, $this->RequestSocket); } /** * Test that HttpSocket::__construct does what one would expect it to do * - * @access public * @return void */ - function testConstruct() { + public function testConstruct() { $this->Socket->reset(); $baseConfig = $this->Socket->config; $this->Socket->expects($this->never())->method('connect'); @@ -270,25 +269,24 @@ class HttpSocketTest extends CakeTestCase { /** * Test that HttpSocket::configUri works properly with different types of arguments * - * @access public * @return void */ - function testConfigUri() { + public function testConfigUri() { $this->Socket->reset(); $r = $this->Socket->configUri('https://bob:secret@www.cakephp.org:23/?query=foo'); $expected = array( 'persistent' => false, - 'host' => 'www.cakephp.org', - 'protocol' => 'tcp', - 'port' => 23, - 'timeout' => 30, + 'host' => 'www.cakephp.org', + 'protocol' => 'tcp', + 'port' => 23, + 'timeout' => 30, 'request' => array( 'uri' => array( - 'scheme' => 'https' - , 'host' => 'www.cakephp.org' - , 'port' => 23 + 'scheme' => 'https', + 'host' => 'www.cakephp.org', + 'port' => 23 ), - 'cookies' => array(), + 'cookies' => array() ) ); $this->assertEquals($this->Socket->config, $expected); @@ -302,15 +300,15 @@ class HttpSocketTest extends CakeTestCase { $r = $this->Socket->configUri('http://www.foo.com'); $expected = array( 'persistent' => false, - 'host' => 'www.foo.com', - 'protocol' => 'tcp', - 'port' => 80, - 'timeout' => 30, + 'host' => 'www.foo.com', + 'protocol' => 'tcp', + 'port' => 80, + 'timeout' => 30, 'request' => array( 'uri' => array( - 'scheme' => 'http' - , 'host' => 'www.foo.com' - , 'port' => 80 + 'scheme' => 'http', + 'host' => 'www.foo.com', + 'port' => 80 ), 'cookies' => array() ) @@ -328,191 +326,216 @@ class HttpSocketTest extends CakeTestCase { /** * Tests that HttpSocket::request (the heart of the HttpSocket) is working properly. * - * @access public * @return void */ - function testRequest() { + public function testRequest() { $this->Socket->reset(); $response = $this->Socket->request(true); $this->assertFalse($response); $tests = array( - 0 => array( - 'request' => 'http://www.cakephp.org/?foo=bar' - , 'expectation' => array( + array( + 'request' => 'http://www.cakephp.org/?foo=bar', + 'expectation' => array( 'config' => array( - 'persistent' => false - , 'host' => 'www.cakephp.org' - , 'protocol' => 'tcp' - , 'port' => 80 - , 'timeout' => 30 - , 'request' => array( + 'persistent' => false, + 'host' => 'www.cakephp.org', + 'protocol' => 'tcp', + 'port' => 80, + 'timeout' => 30, + 'request' => array( 'uri' => array ( - 'scheme' => 'http' - , 'host' => 'www.cakephp.org' - , 'port' => 80, + 'scheme' => 'http', + 'host' => 'www.cakephp.org', + 'port' => 80 ), - 'cookies' => array(), - ), - ) - , 'request' => array( - 'method' => 'GET' - , 'uri' => array( - 'scheme' => 'http' - , 'host' => 'www.cakephp.org' - , 'port' => 80 - , 'user' => null - , 'pass' => null - , 'path' => '/' - , 'query' => array('foo' => 'bar') - , 'fragment' => null + 'cookies' => array() ) - , 'version' => '1.1' - , 'body' => '' - , 'line' => "GET /?foo=bar HTTP/1.1\r\n" - , 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n" - , 'raw' => "" - , 'cookies' => array(), + ), + 'request' => array( + 'method' => 'GET', + 'uri' => array( + 'scheme' => 'http', + 'host' => 'www.cakephp.org', + 'port' => 80, + 'user' => null, + 'pass' => null, + 'path' => '/', + 'query' => array('foo' => 'bar'), + 'fragment' => null + ), + 'version' => '1.1', + 'body' => '', + 'line' => "GET /?foo=bar HTTP/1.1\r\n", + 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n", + 'raw' => "", + 'cookies' => array() ) ) - ) - , 1 => array( + ), + array( 'request' => array( 'uri' => array( - 'host' => 'www.cakephp.org' - , 'query' => '?foo=bar' + 'host' => 'www.cakephp.org', + 'query' => '?foo=bar' ) ) - ) - , 2 => array( + ), + array( 'request' => 'www.cakephp.org/?foo=bar' - ) - , 3 => array( - 'request' => array('host' => '192.168.0.1', 'uri' => 'http://www.cakephp.org/?foo=bar') - , 'expectation' => array( + ), + array( + 'request' => array( + 'host' => '192.168.0.1', + 'uri' => 'http://www.cakephp.org/?foo=bar' + ), + 'expectation' => array( 'request' => array( 'uri' => array('host' => 'www.cakephp.org') - ) - , 'config' => array( + ), + 'config' => array( 'request' => array( 'uri' => array('host' => 'www.cakephp.org') - ) - , 'host' => '192.168.0.1' + ), + 'host' => '192.168.0.1' ) ) - ) - , 'reset4' => array( + ), + 'reset4' => array( 'request.uri.query' => array() - ) - , 4 => array( - 'request' => array('header' => array('Foo@woo' => 'bar-value')) - , 'expectation' => array( + ), + array( + 'request' => array( + 'header' => array('Foo@woo' => 'bar-value') + ), + 'expectation' => array( 'request' => array( - 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nFoo\"@\"woo: bar-value\r\n" - , 'line' => "GET / HTTP/1.1\r\n" + 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nFoo\"@\"woo: bar-value\r\n", + 'line' => "GET / HTTP/1.1\r\n" ) ) - ) - , 5 => array( - 'request' => array('header' => array('Foo@woo' => 'bar-value', 'host' => 'foo.com'), 'uri' => 'http://www.cakephp.org/') - , 'expectation' => array( + ), + array( + 'request' => array('header' => array('Foo@woo' => 'bar-value', 'host' => 'foo.com'), 'uri' => 'http://www.cakephp.org/'), + 'expectation' => array( 'request' => array( 'header' => "Host: foo.com\r\nConnection: close\r\nUser-Agent: CakePHP\r\nFoo\"@\"woo: bar-value\r\n" - ) - , 'config' => array( + ), + 'config' => array( 'host' => 'www.cakephp.org' ) ) - ) - , 6 => array( - 'request' => array('header' => "Foo: bar\r\n") - , 'expectation' => array( + ), + array( + 'request' => array('header' => "Foo: bar\r\n"), + 'expectation' => array( 'request' => array( 'header' => "Foo: bar\r\n" ) ) - ) - , 7 => array( - 'request' => array('header' => "Foo: bar\r\n", 'uri' => 'http://www.cakephp.org/search?q=http_socket#ignore-me') - , 'expectation' => array( + ), + array( + 'request' => array('header' => "Foo: bar\r\n", 'uri' => 'http://www.cakephp.org/search?q=http_socket#ignore-me'), + 'expectation' => array( 'request' => array( 'uri' => array( - 'path' => '/search' - , 'query' => array('q' => 'http_socket') - , 'fragment' => 'ignore-me' - ) - , 'line' => "GET /search?q=http_socket HTTP/1.1\r\n" + 'path' => '/search', + 'query' => array('q' => 'http_socket'), + 'fragment' => 'ignore-me' + ), + 'line' => "GET /search?q=http_socket HTTP/1.1\r\n" ) ) - ) - , 'reset8' => array( + ), + 'reset8' => array( 'request.uri.query' => array() - ) - , 8 => array( - 'request' => array('method' => 'POST', 'uri' => 'http://www.cakephp.org/posts/add', 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today')) - , 'expectation' => array( + ), + array( + 'request' => array( + 'method' => 'POST', + 'uri' => 'http://www.cakephp.org/posts/add', + 'body' => array( + 'name' => 'HttpSocket-is-released', + 'date' => 'today' + ) + ), + 'expectation' => array( 'request' => array( - 'method' => 'POST' - , 'uri' => array( - 'path' => '/posts/add' - , 'fragment' => null - ) - , 'body' => "name=HttpSocket-is-released&date=today" - , 'line' => "POST /posts/add HTTP/1.1\r\n" - , 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n" - , 'raw' => "name=HttpSocket-is-released&date=today" + 'method' => 'POST', + 'uri' => array( + 'path' => '/posts/add', + 'fragment' => null + ), + 'body' => "name=HttpSocket-is-released&date=today", + 'line' => "POST /posts/add HTTP/1.1\r\n", + 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n", + 'raw' => "name=HttpSocket-is-released&date=today" ) ) - ) - , 9 => array( - 'request' => array('method' => 'POST', 'uri' => 'http://www.cakephp.org:8080/posts/add', 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today')) - , 'expectation' => array( + ), + array( + 'request' => array( + 'method' => 'POST', + 'uri' => 'http://www.cakephp.org:8080/posts/add', + 'body' => array( + 'name' => 'HttpSocket-is-released', + 'date' => 'today' + ) + ), + 'expectation' => array( 'config' => array( - 'port' => 8080 - , 'request' => array( + 'port' => 8080, + 'request' => array( 'uri' => array( 'port' => 8080 ) ) - ) - , 'request' => array( + ), + 'request' => array( 'uri' => array( 'port' => 8080 - ) - , 'header' => "Host: www.cakephp.org:8080\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n" + ), + 'header' => "Host: www.cakephp.org:8080\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n" ) ) - ) - , 10 => array( - 'request' => array('method' => 'POST', 'uri' => 'https://www.cakephp.org/posts/add', 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today')) - , 'expectation' => array( + ), + array( + 'request' => array( + 'method' => 'POST', + 'uri' => 'https://www.cakephp.org/posts/add', + 'body' => array( + 'name' => 'HttpSocket-is-released', + 'date' => 'today' + ) + ), + 'expectation' => array( 'config' => array( - 'port' => 443 - , 'request' => array( + 'port' => 443, + 'request' => array( 'uri' => array( - 'scheme' => 'https' - , 'port' => 443 + 'scheme' => 'https', + 'port' => 443 ) ) - ) - , 'request' => array( + ), + 'request' => array( 'uri' => array( - 'scheme' => 'https' - , 'port' => 443 - ) - , 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n" + 'scheme' => 'https', + 'port' => 443 + ), + 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n" ) ) - ) - , 11 => array( + ), + array( 'request' => array( - 'method' => 'POST', - 'uri' => 'https://www.cakephp.org/posts/add', - 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today'), - 'cookies' => array('foo' => array('value' => 'bar')) - ) - , 'expectation' => array( + 'method' => 'POST', + 'uri' => 'https://www.cakephp.org/posts/add', + 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today'), + 'cookies' => array('foo' => array('value' => 'bar')) + ), + 'expectation' => array( 'request' => array( 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\nCookie: foo=bar\r\n", 'cookies' => array( @@ -538,10 +561,10 @@ class HttpSocketTest extends CakeTestCase { $this->Socket->request($test['request']); $raw = $expectation['request']['raw']; - $expectation['request']['raw'] = $expectation['request']['line'].$expectation['request']['header']."\r\n".$raw; + $expectation['request']['raw'] = $expectation['request']['line'] . $expectation['request']['header'] . "\r\n" . $raw; $r = array('config' => $this->Socket->config, 'request' => $this->Socket->request); - $v = $this->assertEquals($r, $expectation, 'Failed test #'.$i.' '); + $v = $this->assertEquals($r, $expectation, 'Failed test #' . $i . ' '); $expectation['request']['raw'] = $raw; } @@ -560,10 +583,9 @@ class HttpSocketTest extends CakeTestCase { /** * testRequest2 method * - * @access public * @return void */ - function testRequest2() { + public function testRequest2() { $this->Socket->reset(); $request = array('uri' => 'htpp://www.cakephp.org/'); $number = mt_rand(0, 9999999); @@ -580,10 +602,9 @@ class HttpSocketTest extends CakeTestCase { /** * testRequest3 method * - * @access public * @return void */ - function testRequest3() { + public function testRequest3() { $request = array('uri' => 'htpp://www.cakephp.org/'); $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a cookie test!

"; $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); @@ -605,7 +626,7 @@ class HttpSocketTest extends CakeTestCase { * * @return void */ - function testProxy() { + public function testProxy() { $this->Socket->reset(); $this->Socket->expects($this->any())->method('connect')->will($this->returnValue(true)); $this->Socket->expects($this->any())->method('read')->will($this->returnValue(false)); @@ -633,10 +654,9 @@ class HttpSocketTest extends CakeTestCase { /** * testUrl method * - * @access public * @return void */ - function testUrl() { + public function testUrl() { $this->Socket->reset(true); $this->assertEquals($this->Socket->url(true), false); @@ -688,10 +708,9 @@ class HttpSocketTest extends CakeTestCase { /** * testGet method * - * @access public * @return void */ - function testGet() { + public function testGet() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) @@ -701,7 +720,7 @@ class HttpSocketTest extends CakeTestCase { $this->RequestSocket->expects($this->at(1)) ->method('request') ->with(array('method' => 'GET', 'uri' => 'http://www.google.com/?foo=bar')); - + $this->RequestSocket->expects($this->at(2)) ->method('request') ->with(array('method' => 'GET', 'uri' => 'http://www.google.com/?foo=bar')); @@ -745,7 +764,7 @@ class HttpSocketTest extends CakeTestCase { * * @return void */ - function testConsecutiveGetResetsAuthCredentials() { + public function testConsecutiveGetResetsAuthCredentials() { $socket = new MockHttpSocket(); $socket->get('http://mark:secret@example.com/test'); $this->assertEqual($socket->request['uri']['user'], 'mark'); @@ -762,10 +781,9 @@ class HttpSocketTest extends CakeTestCase { /** * testPostPutDelete method * - * @access public * @return void */ - function testPost() { + public function testPost() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) ->method('request') @@ -784,7 +802,12 @@ class HttpSocketTest extends CakeTestCase { $this->RequestSocket->post('http://www.google.com/', null, array('line' => 'Hey Server')); } - function testPut() { +/** + * testPut + * + * @return void + */ + public function testPut() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) ->method('request') @@ -803,7 +826,12 @@ class HttpSocketTest extends CakeTestCase { $this->RequestSocket->put('http://www.google.com/', null, array('line' => 'Hey Server')); } - function testDelete() { +/** + * testDelete + * + * @return void + */ + public function testDelete() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) ->method('request') @@ -825,10 +853,9 @@ class HttpSocketTest extends CakeTestCase { /** * testParseResponse method * - * @access public * @return void */ - function testParseResponse() { + public function testParseResponse() { $this->Socket->reset(); $r = $this->Socket->parseResponse(array('foo' => 'bar')); @@ -846,8 +873,8 @@ class HttpSocketTest extends CakeTestCase { 'status-line' => "HTTP/1.x 200 OK\r\n", 'header' => "Date: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\n", 'body' => "

Hello World

\r\n

It's good to be html

" - ) - , 'expectations' => array( + ), + 'expectations' => array( 'status.http-version' => 'HTTP/1.x', 'status.code' => 200, 'status.reason-phrase' => 'OK', @@ -858,9 +885,9 @@ class HttpSocketTest extends CakeTestCase { 'no-header' => array( 'response' => array( 'status-line' => "HTTP/1.x 404 OK\r\n", - 'header' => null, - ) - , 'expectations' => array( + 'header' => null + ), + 'expectations' => array( 'status.code' => 404, 'header' => array() ) @@ -897,19 +924,18 @@ class HttpSocketTest extends CakeTestCase { $expectations = array(); foreach ($tests as $name => $test) { - $testResponse = array_merge($testResponse, $test['response']); - $testResponse['response'] = $testResponse['status-line'].$testResponse['header']."\r\n".$testResponse['body']; + $testResponse['response'] = $testResponse['status-line'] . $testResponse['header'] . "\r\n" . $testResponse['body']; $r = $this->Socket->parseResponse($testResponse['response']); $expectations = array_merge($expectations, $test['expectations']); foreach ($expectations as $property => $expectedVal) { $val = Set::extract($r, $property); - $this->assertEquals($val, $expectedVal, 'Test "'.$name.'": response.'.$property.' - %s'); + $this->assertEquals($val, $expectedVal, 'Test "' . $name . '": response.' . $property . ' - %s'); } foreach (array('status-line', 'header', 'body', 'response') as $field) { - $this->assertEquals($r['raw'][$field], $testResponse[$field], 'Test response.raw.'.$field.': %s'); + $this->assertEquals($r['raw'][$field], $testResponse[$field], 'Test response.raw.' . $field . ': %s'); } } } @@ -917,10 +943,9 @@ class HttpSocketTest extends CakeTestCase { /** * testDecodeBody method * - * @access public * @return void */ - function testDecodeBody() { + public function testDecodeBody() { $this->Socket->reset(); $r = $this->Socket->decodeBody(true); @@ -939,7 +964,12 @@ class HttpSocketTest extends CakeTestCase { $this->assertEquals($r, $sample['decoded']); } - function testDecodeFooCoded() { +/** + * testDecodeFooCoded + * + * @return void + */ + public function testDecodeFooCoded() { $this->Socket->reset(); $r = $this->Socket->decodeBody(true); @@ -967,10 +997,9 @@ class HttpSocketTest extends CakeTestCase { /** * testDecodeChunkedBody method * - * @access public * @return void */ - function testDecodeChunkedBody() { + public function testDecodeChunkedBody() { $this->Socket->reset(); $r = $this->Socket->decodeChunkedBody(true); @@ -1023,10 +1052,9 @@ class HttpSocketTest extends CakeTestCase { /** * testBuildRequestLine method * - * @access public * @return void */ - function testBuildRequestLine() { + public function testBuildRequestLine() { $this->Socket->reset(); $this->Socket->quirksMode = true; @@ -1067,7 +1095,7 @@ class HttpSocketTest extends CakeTestCase { $request['method'] = 'GET'; $this->Socket->quirksMode = true; $r = $this->Socket->buildRequestLine($request); - $this->assertEquals($r, "GET * HTTP/1.1\r\n"); + $this->assertEquals($r, "GET * HTTP/1.1\r\n"); $r = $this->Socket->buildRequestLine("GET * HTTP/1.1\r\n"); $this->assertEquals($r, "GET * HTTP/1.1\r\n"); @@ -1076,10 +1104,9 @@ class HttpSocketTest extends CakeTestCase { /** * testBadBuildRequestLine method * - * @access public * @return void */ - function testBadBuildRequestLine() { + public function testBadBuildRequestLine() { $this->expectError(); $r = $this->Socket->buildRequestLine('Foo'); } @@ -1087,10 +1114,9 @@ class HttpSocketTest extends CakeTestCase { /** * testBadBuildRequestLine2 method * - * @access public * @return void */ - function testBadBuildRequestLine2() { + public function testBadBuildRequestLine2() { $this->expectError(); $r = $this->Socket->buildRequestLine("GET * HTTP/1.1\r\n"); } @@ -1098,10 +1124,9 @@ class HttpSocketTest extends CakeTestCase { /** * Asserts that HttpSocket::parseUri is working properly * - * @access public * @return void */ - function testParseUri() { + public function testParseUri() { $this->Socket->reset(); $uri = $this->Socket->parseUri(array('invalid' => 'uri-string')); @@ -1132,7 +1157,7 @@ class HttpSocketTest extends CakeTestCase { $this->assertEquals($uri, array( 'scheme' => 'http', 'host' => 'www.cakephp.org', - 'path' => '/', + 'path' => '/' )); $uri = $this->Socket->parseUri('http://www.cakephp.org', true); @@ -1197,7 +1222,7 @@ class HttpSocketTest extends CakeTestCase { $this->assertEquals($uri, array( 'scheme' => 'http', 'host' => 'www.google.com', - 'port' => 8080, + 'port' => 8080 )); $uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1¶m2=value2%3Dvalue3'); @@ -1226,10 +1251,9 @@ class HttpSocketTest extends CakeTestCase { /** * Tests that HttpSocket::buildUri can turn all kinds of uri arrays (and strings) into fully or partially qualified URI's * - * @access public * @return void */ - function testBuildUri() { + public function testBuildUri() { $this->Socket->reset(); $r = $this->Socket->buildUri(true); @@ -1293,10 +1317,9 @@ class HttpSocketTest extends CakeTestCase { /** * Asserts that HttpSocket::parseQuery is working properly * - * @access public * @return void */ - function testParseQuery() { + public function testParseQuery() { $this->Socket->reset(); $query = $this->Socket->parseQuery(array('framework' => 'cakephp')); @@ -1345,16 +1368,10 @@ class HttpSocketTest extends CakeTestCase { $query = $this->Socket->parseQuery('a[][]=foo&a[bar]=php&a[][]=bar&a[][]=cake'); $expectedQuery = array( 'a' => array( - 0 => array( - 0 => 'foo' - ), + array('foo'), 'bar' => 'php', - 1 => array( - 0 => 'bar' - ), - array( - 0 => 'cake' - ) + array('bar'), + array('cake') ) ); $this->assertEquals($query, $expectedQuery); @@ -1400,10 +1417,9 @@ class HttpSocketTest extends CakeTestCase { * Tests that HttpSocket::buildHeader can turn a given $header array into a proper header string according to * HTTP 1.1 specs. * - * @access public * @return void */ - function testBuildHeader() { + public function testBuildHeader() { $this->Socket->reset(); $r = $this->Socket->buildHeader(true); @@ -1438,10 +1454,9 @@ class HttpSocketTest extends CakeTestCase { /** * Test that HttpSocket::parseHeader can take apart a given (and valid) $header string and turn it into an array. * - * @access public * @return void */ - function testParseHeader() { + public function testParseHeader() { $this->Socket->reset(); $r = $this->Socket->parseHeader(array('foo' => 'Bar', 'fOO-bAr' => 'quux')); @@ -1460,32 +1475,32 @@ class HttpSocketTest extends CakeTestCase { $header = "Date:Sat, 07 Apr 2007 10:10:25 GMT\r\nX-Powered-By: PHP/5.1.2\r\n"; $r = $this->Socket->parseHeader($header); $expected = array( - 'Date' => 'Sat, 07 Apr 2007 10:10:25 GMT' - , 'X-Powered-By' => 'PHP/5.1.2' + 'Date' => 'Sat, 07 Apr 2007 10:10:25 GMT', + 'X-Powered-By' => 'PHP/5.1.2' ); $this->assertEquals($r, $expected); $header = "people: Jim,John\r\nfoo-LAND: Bar\r\ncAKe-PHP: rocks\r\n"; $r = $this->Socket->parseHeader($header); $expected = array( - 'people' => 'Jim,John' - , 'foo-LAND' => 'Bar' - , 'cAKe-PHP' => 'rocks' + 'people' => 'Jim,John', + 'foo-LAND' => 'Bar', + 'cAKe-PHP' => 'rocks' ); $this->assertEquals($r, $expected); $header = "People: Jim,John,Tim\r\nPeople: Lisa,Tina,Chelsea\r\n"; $r = $this->Socket->parseHeader($header); $expected = array( - 'People' => array('Jim,John,Tim', 'Lisa,Tina,Chelsea') + 'People' => array('Jim,John,Tim', 'Lisa,Tina,Chelsea') ); $this->assertEquals($r, $expected); $header = "Multi-Line: I am a \r\nmulti line\t\r\nfield value.\r\nSingle-Line: I am not\r\n"; $r = $this->Socket->parseHeader($header); $expected = array( - 'Multi-Line' => "I am a\r\nmulti line\r\nfield value." - , 'Single-Line' => 'I am not' + 'Multi-Line' => "I am a\r\nmulti line\r\nfield value.", + 'Single-Line' => 'I am not' ); $this->assertEquals($r, $expected); @@ -1500,10 +1515,9 @@ class HttpSocketTest extends CakeTestCase { /** * testParseCookies method * - * @access public * @return void */ - function testParseCookies() { + public function testParseCookies() { $header = array( 'Set-Cookie' => array( 'foo=bar', @@ -1543,10 +1557,9 @@ class HttpSocketTest extends CakeTestCase { * testBuildCookies method * * @return void - * @access public * @todo Test more scenarios */ - function testBuildCookies() { + public function testBuildCookies() { $cookies = array( 'foo' => array( 'value' => 'bar' @@ -1564,10 +1577,9 @@ class HttpSocketTest extends CakeTestCase { /** * Tests that HttpSocket::_tokenEscapeChars() returns the right characters. * - * @access public * @return void */ - function testTokenEscapeChars() { + public function testTokenEscapeChars() { $this->Socket->reset(); $expected = array( @@ -1590,19 +1602,18 @@ class HttpSocketTest extends CakeTestCase { /** * Test that HttpSocket::escapeToken is escaping all characters as descriped in RFC 2616 (HTTP 1.1 specs) * - * @access public * @return void */ - function testEscapeToken() { + public function testEscapeToken() { $this->Socket->reset(); $this->assertEquals($this->Socket->escapeToken('Foo'), 'Foo'); $escape = $this->Socket->tokenEscapeChars(false); foreach ($escape as $char) { - $token = 'My-special-'.$char.'-Token'; + $token = 'My-special-' . $char . '-Token'; $escapedToken = $this->Socket->escapeToken($token); - $expectedToken = 'My-special-"'.$char.'"-Token'; + $expectedToken = 'My-special-"' . $char . '"-Token'; $this->assertEquals($escapedToken, $expectedToken, 'Test token escaping for ASCII '.ord($char)); } @@ -1616,19 +1627,18 @@ class HttpSocketTest extends CakeTestCase { /** * Test that escaped token strings are properly unescaped by HttpSocket::unescapeToken * - * @access public * @return void */ - function testUnescapeToken() { + public function testUnescapeToken() { $this->Socket->reset(); $this->assertEquals($this->Socket->unescapeToken('Foo'), 'Foo'); $escape = $this->Socket->tokenEscapeChars(false); foreach ($escape as $char) { - $token = 'My-special-"'.$char.'"-Token'; + $token = 'My-special-"' . $char . '"-Token'; $unescapedToken = $this->Socket->unescapeToken($token); - $expectedToken = 'My-special-'.$char.'-Token'; + $expectedToken = 'My-special-' . $char . '-Token'; $this->assertEquals($unescapedToken, $expectedToken, 'Test token unescaping for ASCII '.ord($char)); } @@ -1643,10 +1653,9 @@ class HttpSocketTest extends CakeTestCase { * This tests asserts HttpSocket::reset() resets a HttpSocket instance to it's initial state (before Object::__construct * got executed) * - * @access public * @return void */ - function testReset() { + public function testReset() { $this->Socket->reset(); $initialState = get_class_vars('HttpSocket'); @@ -1667,10 +1676,9 @@ class HttpSocketTest extends CakeTestCase { * This tests asserts HttpSocket::reset(false) resets certain HttpSocket properties to their initial state (before * Object::__construct got executed). * - * @access public * @return void */ - function testPartialReset() { + public function testPartialReset() { $this->Socket->reset(); $partialResetProperties = array('request', 'response'); From c4743a24388ccca519e223fea5fc810dc1f03ca1 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 4 Dec 2010 01:41:45 -0200 Subject: [PATCH 165/378] Changing the test with get to use version instead auth. --- cake/tests/cases/libs/http_socket.test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 9bfa3bf96..858a5df10 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -731,13 +731,13 @@ class HttpSocketTest extends CakeTestCase { $this->RequestSocket->expects($this->at(4)) ->method('request') - ->with(array('method' => 'GET', 'uri' => 'http://www.google.com/', 'auth' => array('user' => 'foo', 'pass' => 'bar'))); + ->with(array('method' => 'GET', 'uri' => 'http://www.google.com/', 'version' => '1.0')); $this->RequestSocket->get('http://www.google.com/'); $this->RequestSocket->get('http://www.google.com/', array('foo' => 'bar')); $this->RequestSocket->get('http://www.google.com/', 'foo=bar'); $this->RequestSocket->get('http://www.google.com/?foo=bar', array('foobar' => '42', 'foo' => '23')); - $this->RequestSocket->get('http://www.google.com/', null, array('auth' => array('user' => 'foo', 'pass' => 'bar'))); + $this->RequestSocket->get('http://www.google.com/', null, array('version' => '1.0')); } /** From 9b8456ce6f9349db54b06153247ecd64e7659101 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 00:09:11 -0500 Subject: [PATCH 166/378] Adding an interface to define the necessary public methods. Adding insertion of configure readers. Adding tests. --- cake/libs/config/php_reader.php | 2 +- cake/libs/configure.php | 52 ++++++++++++++++++++++++ cake/tests/cases/libs/configure.test.php | 25 ++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) diff --git a/cake/libs/config/php_reader.php b/cake/libs/config/php_reader.php index 3cf5e35ee..dafea6da0 100644 --- a/cake/libs/config/php_reader.php +++ b/cake/libs/config/php_reader.php @@ -24,7 +24,7 @@ * * @package cake.libs.config */ -class PhpReader { +class PhpReader implements ConfigReaderInterface { /** * The path this reader finds files on. * diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 34b6bbc52..941c0b3c6 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -40,6 +40,14 @@ class Configure { 'debug' => 0 ); +/** + * Configured reader classes, used to load config files from resources + * + * @var array + * @see Configure::load() + */ + protected static $_readers = array(); + /** * Initializes configure and runs the bootstrap process. * Bootstrapping includes the following steps: @@ -249,6 +257,33 @@ class Configure { self::$_values[$names[0]] = Set::remove(self::$_values[$names[0]], $names[1]); } +/** + * Add a new reader to Configure. Readers allow you to read configuration + * files in various formats/storage locations. CakePHP comes with two built-in readers + * PhpReader and IniReader. You can also implement your own reader classes in your application. + * + * To add a new reader to Configure: + * + * `Configure::reader('ini', new IniReader());` + * + * @param string $alias The name of the reader being configured. This alias is used later to + * read values from a specific reader. + * @param ConfigReaderInterface $reader The reader to append. + * @return void + */ + public static function reader($alias, ConfigReaderInterface $reader) { + self::$_readers[$alias] = $reader; + } + +/** + * Gets the names of the configured reader objects. + * + * @return array Array of the configured reader objects. + */ + public static function configured() { + return array_keys(self::$_readers); + } + /** * Loads a file from app/config/configure_file.php. * @@ -380,4 +415,21 @@ class Configure { } } +} + +/** + * An interface for creating objects compatible with Configure::load() + * + * @package cake.libs + */ +interface ConfigReaderInterface { +/** + * Read method is used for reading configuration information from sources. + * These sources can either be static resources like files, or dynamic ones like + * a database, or other datasource. + * + * @param string $key + * @return array An array of data to merge into the runtime configuration + */ + function read($key); } \ No newline at end of file diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index a99790291..20e8100f3 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -19,6 +19,7 @@ * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::import('Core', 'config/PhpReader'); /** * ConfigureTest @@ -256,5 +257,29 @@ class ConfigureTest extends CakeTestCase { $result = Configure::version(); $this->assertTrue(version_compare($result, '1.2', '>=')); } + +/** + * test adding new readers. + * + * @return void + */ + function testReaderSetup() { + $reader = new PhpReader(); + Configure::reader('test', $reader); + $configured = Configure::configured(); + + $this->assertTrue(in_array('test', $configured)); + } + +/** + * test reader() throwing exceptions on missing interface. + * + * @expectedException Exception + * @return void + */ + function testReaderExceptionOnIncorrectClass() { + $reader = new StdClass(); + Configure::reader('test', $reader); + } } From da632fe19139406fd076b962ff632c1e90bb2d42 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 00:10:42 -0500 Subject: [PATCH 167/378] Renaming method to match other core classes with similar features. --- cake/libs/configure.php | 4 ++-- cake/tests/cases/libs/configure.test.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 941c0b3c6..0c6bf4f08 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -264,14 +264,14 @@ class Configure { * * To add a new reader to Configure: * - * `Configure::reader('ini', new IniReader());` + * `Configure::config('ini', new IniReader());` * * @param string $alias The name of the reader being configured. This alias is used later to * read values from a specific reader. * @param ConfigReaderInterface $reader The reader to append. * @return void */ - public static function reader($alias, ConfigReaderInterface $reader) { + public static function config($alias, ConfigReaderInterface $reader) { self::$_readers[$alias] = $reader; } diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index 20e8100f3..f9120d0ec 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -265,7 +265,7 @@ class ConfigureTest extends CakeTestCase { */ function testReaderSetup() { $reader = new PhpReader(); - Configure::reader('test', $reader); + Configure::config('test', $reader); $configured = Configure::configured(); $this->assertTrue(in_array('test', $configured)); @@ -279,7 +279,7 @@ class ConfigureTest extends CakeTestCase { */ function testReaderExceptionOnIncorrectClass() { $reader = new StdClass(); - Configure::reader('test', $reader); + Configure::config('test', $reader); } } From aef53cd23a4181b91b53bbe837e4c4b40327322c Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 00:14:55 -0500 Subject: [PATCH 168/378] Adding some more basic methods. --- cake/libs/configure.php | 21 ++++++++++++++++++--- cake/tests/cases/libs/configure.test.php | 2 ++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 0c6bf4f08..8340ca1f6 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -266,13 +266,13 @@ class Configure { * * `Configure::config('ini', new IniReader());` * - * @param string $alias The name of the reader being configured. This alias is used later to + * @param string $name The name of the reader being configured. This alias is used later to * read values from a specific reader. * @param ConfigReaderInterface $reader The reader to append. * @return void */ - public static function config($alias, ConfigReaderInterface $reader) { - self::$_readers[$alias] = $reader; + public static function config($name, ConfigReaderInterface $reader) { + self::$_readers[$name] = $reader; } /** @@ -284,6 +284,21 @@ class Configure { return array_keys(self::$_readers); } +/** + * Remove a configured reader. This will unset the reader + * and make any future attempts to use it cause an Exception. + * + * @param string $name Name of the reader to drop. + * @return boolean Success + */ + public static function drop($name) { + if (!isset(self::$_readers[$name])) { + return false; + } + unset(self::$_readers[$name]); + return true; + } + /** * Loads a file from app/config/configure_file.php. * diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index f9120d0ec..84e0787a5 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -269,6 +269,8 @@ class ConfigureTest extends CakeTestCase { $configured = Configure::configured(); $this->assertTrue(in_array('test', $configured)); + $this->assertTrue(Configure::drop('test')); + $this->assertFalse(Configure::drop('test'), 'dropping things that do not exist should return false.'); } /** From 9b55487d4ee3690c3840005e43b66c840a5bb779 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 00:24:09 -0500 Subject: [PATCH 169/378] Removing a dead isset() and collapsing an if. --- cake/libs/configure.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 8340ca1f6..2540910f2 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -175,13 +175,11 @@ class Configure { } } - if (isset($config['debug']) || isset($config['log'])) { - if (function_exists('ini_set')) { - if (self::$_values['debug']) { - ini_set('display_errors', 1); - } else { - ini_set('display_errors', 0); - } + if (isset($config['debug']) && function_exists('ini_set')) { + if (self::$_values['debug']) { + ini_set('display_errors', 1); + } else { + ini_set('display_errors', 0); } } return true; From 6618178e1b1192f977649b5a004e4982ba6f8023 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 00:58:02 -0500 Subject: [PATCH 170/378] Adding more checks into PhpReader that currently exist in Configure. --- cake/libs/config/php_reader.php | 5 +++++ cake/tests/cases/libs/config/php_reader.test.php | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/cake/libs/config/php_reader.php b/cake/libs/config/php_reader.php index dafea6da0..169b44df6 100644 --- a/cake/libs/config/php_reader.php +++ b/cake/libs/config/php_reader.php @@ -51,8 +51,13 @@ class PhpReader implements ConfigReaderInterface { * @param string $key The identifier to read from. If the key has a . it will be treated * as a plugin prefix. * @return array Parsed configuration values. + * @throws RuntimeException when files don't exist or they don't contain `$config`. + * InvalidArgumentException when files contain '..' as this could lead to abusive reads. */ public function read($key) { + if (strpos($key, '..') !== false) { + throw new InvalidArgumentException(__('Cannot load configuration files with ../ in them.')); + } list($plugin, $key) = pluginSplit($key); if ($plugin) { diff --git a/cake/tests/cases/libs/config/php_reader.test.php b/cake/tests/cases/libs/config/php_reader.test.php index b713faa78..53898f97f 100644 --- a/cake/tests/cases/libs/config/php_reader.test.php +++ b/cake/tests/cases/libs/config/php_reader.test.php @@ -63,6 +63,17 @@ class PhpReaderTest extends CakeTestCase { $reader->read('empty'); } +/** + * test reading keys with ../ doesn't work + * + * @expectedException InvalidArgumentException + * @return void + */ + function testReadWithDots() { + $reader = new PhpReader($this->path); + $reader->read('../empty'); + } + /** * test reading from plugins * From 7eab3b285093e32192d4660431a79f9a4cd065bd Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 01:05:12 -0500 Subject: [PATCH 171/378] Moving load() logic out of Configure, and putting it into PhpReader. Updating test cases. store() still needs to be properly implemented. --- cake/libs/configure.php | 44 ++++-------------------- cake/tests/cases/libs/configure.test.php | 30 +++++++++++----- 2 files changed, 27 insertions(+), 47 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 2540910f2..d0646c289 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -309,48 +309,16 @@ class Configure { * - To load config files from a plugin `Configure::load('plugin.configure_file');`. * * @link http://book.cakephp.org/view/929/load - * @param string $fileName name of file to load, extension must be .php and only the name - * should be used, not the extenstion + * @param string $key name of configuration resource to load. + * @param string $config Name of the configured reader to use to read the resource identfied by $key. * @return mixed false if file not found, void if load successful */ - public static function load($fileName) { - $found = $plugin = $pluginPath = false; - list($plugin, $fileName) = pluginSplit($fileName); - if ($plugin) { - $pluginPath = App::pluginPath($plugin); - } - $pos = strpos($fileName, '..'); - - if ($pos === false) { - if ($pluginPath && file_exists($pluginPath . 'config' . DS . $fileName . '.php')) { - include($pluginPath . 'config' . DS . $fileName . '.php'); - $found = true; - } elseif (file_exists(CONFIGS . $fileName . '.php')) { - include(CONFIGS . $fileName . '.php'); - $found = true; - } elseif (file_exists(CACHE . 'persistent' . DS . $fileName . '.php')) { - include(CACHE . 'persistent' . DS . $fileName . '.php'); - $found = true; - } else { - foreach (App::core('cake') as $key => $path) { - if (file_exists($path . DS . 'config' . DS . $fileName . '.php')) { - include($path . DS . 'config' . DS . $fileName . '.php'); - $found = true; - break; - } - } - } - } - - if (!$found) { + public static function load($key, $config = 'default') { + if (!isset(self::$_readers[$config])) { return false; } - - if (!isset($config)) { - trigger_error(sprintf(__('Configure::load() - no variable $config found in %s.php'), $fileName), E_USER_WARNING); - return false; - } - return self::write($config); + $values = self::$_readers[$config]->read($key); + return self::write($values); } /** diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index 84e0787a5..bbe43047b 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -71,6 +71,7 @@ class ConfigureTest extends CakeTestCase { } Configure::write('debug', $this->_debug); Configure::write('Cache.disable', $this->_cacheDisable); + Configure::drop('test'); } /** @@ -185,18 +186,26 @@ class ConfigureTest extends CakeTestCase { /** * testLoad method * - * @access public + * @expectedException RuntimeException + * @return void + */ + function testLoadExceptionOnNonExistantFile() { + Configure::config('test', new PhpReader()); + $result = Configure::load('non_existing_configuration_file', 'test'); + } + +/** + * test load + * * @return void */ function testLoad() { - $result = Configure::load('non_existing_configuration_file'); - $this->assertFalse($result); + Configure::config('test', new PhpReader(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS)); - $result = Configure::load('config'); + $result = Configure::load('var_test', 'test'); $this->assertTrue($result); - - $result = Configure::load('../../index'); - $this->assertFalse($result); + + $this->assertEquals('value', Configure::read('Read')); } /** @@ -207,13 +216,15 @@ class ConfigureTest extends CakeTestCase { */ function testLoadPlugin() { App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true); - $result = Configure::load('test_plugin.load'); + Configure::config('test', new PhpReader()); + + $result = Configure::load('test_plugin.load', 'test'); $this->assertTrue($result); $expected = '/test_app/plugins/test_plugin/config/load.php'; $config = Configure::read('plugin_load'); $this->assertEqual($config, $expected); - $result = Configure::load('test_plugin.more.load'); + $result = Configure::load('test_plugin.more.load', 'test'); $this->assertTrue($result); $expected = '/test_app/plugins/test_plugin/config/more.load.php'; $config = Configure::read('plugin_more_load'); @@ -227,6 +238,7 @@ class ConfigureTest extends CakeTestCase { * @return void */ function testStoreAndLoad() { + $this->markTestSkipped('Configure::store() is not working right now.'); Configure::write('Cache.disable', false); $expected = array('data' => 'value with backslash \, \'singlequote\' and "doublequotes"'); From 1dbed85979a46a5508b3386d595b8ffd827e0a9a Mon Sep 17 00:00:00 2001 From: Graham Weldon Date: Sat, 4 Dec 2010 22:14:33 +1100 Subject: [PATCH 172/378] Append Controller to error class name for isAuthorized() not implemented. --- cake/libs/controller/controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 799d93f62..0bfe924f0 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -800,7 +800,7 @@ class Controller extends Object { */ function isAuthorized() { trigger_error(sprintf( - __('%s::isAuthorized() is not defined.', true), $this->name + __('%sController::isAuthorized() is not defined.', true), $this->name ), E_USER_WARNING); return false; } From 9e32c13cac878a185454ccad06fa35b8942cd7f1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 10:41:23 -0500 Subject: [PATCH 173/378] Updating doc blocks. --- cake/libs/configure.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index d0646c289..dd4fded79 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -298,15 +298,19 @@ class Configure { } /** - * Loads a file from app/config/configure_file.php. + * Loads stored configuration information from a resource. You can add + * config file resource readers with `Configure::config()`. * - * Config file variables should be formated like: - * `$config['name'] = 'value';` - * These will be used to create dynamic Configure vars. load() is also used to - * load stored config files created with Configure::store() + * Loaded configuration infomration will be merged with the current + * runtime configuration. You can load configuration files from plugins + * by preceeding the filename with the plugin name. * - * - To load config files from app/config use `Configure::load('configure_file');`. - * - To load config files from a plugin `Configure::load('plugin.configure_file');`. + * `Configure::load('Users.user', 'default')` + * + * Would load the 'user' config file using the default config reader. You can load + * app config files by giving the name of the resource you want loaded. + * + * `Configure::load('setup', 'default');` * * @link http://book.cakephp.org/view/929/load * @param string $key name of configuration resource to load. From 1e569f509aba65f240f981f84d3556d25b647dd8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 12:15:47 -0500 Subject: [PATCH 174/378] Changing IniFile to be a ConfigReader for use with Configure. Test case updated. --- cake/libs/config/ini_file.php | 101 ------------------ cake/libs/config/ini_reader.php | 73 +++++++++++++ cake/libs/configure.php | 5 +- ...{ini_file.test.php => ini_reader.test.php} | 36 ++----- 4 files changed, 84 insertions(+), 131 deletions(-) delete mode 100644 cake/libs/config/ini_file.php create mode 100644 cake/libs/config/ini_reader.php rename cake/tests/cases/libs/config/{ini_file.test.php => ini_reader.test.php} (61%) diff --git a/cake/libs/config/ini_file.php b/cake/libs/config/ini_file.php deleted file mode 100644 index 722dbcb08..000000000 --- a/cake/libs/config/ini_file.php +++ /dev/null @@ -1,101 +0,0 @@ -_values = $contents[$section]; - } else { - $this->_values = $contents; - } - } - -/** - * Get the contents of the ini file as a plain array. - * - * @return array - */ - public function asArray() { - return $this->_values; - } - -/** - * Part of ArrayAccess implementation. - * - * @param string $name - */ - public function offsetExists($name) { - return isset($this->_values[$name]); - } - -/** - * Part of ArrayAccess implementation. - * - * @param string $name - */ - public function offsetGet($name) { - if (!isset($this->_values[$name])) { - return null; - } - return $this->_values[$name]; - } - -/** - * Part of ArrayAccess implementation. - * - * @param string $name - */ - public function offsetSet($name, $value) { - throw new LogicException('You cannot modify an IniFile parse result.'); - } - -/** - * Part of ArrayAccess implementation. - * - * @param string $name - */ - public function offsetUnset($name) { - unset($this->_values[$name]); - } -} \ No newline at end of file diff --git a/cake/libs/config/ini_reader.php b/cake/libs/config/ini_reader.php new file mode 100644 index 000000000..7163a47b5 --- /dev/null +++ b/cake/libs/config/ini_reader.php @@ -0,0 +1,73 @@ +_path = $path; + $this->_section = $section; + } + +/** + * Read an ini file and return the results as an array. + * + * @param string $file Name of the file to read. + * @return array + */ + public function read($file) { + $filename = $this->_path . $file; + $contents = parse_ini_file($filename, true); + if (!empty($this->_section) && isset($contents[$this->_section])) { + $values = $contents[$this->_section]; + } else { + $values = $contents; + } + return $values; + } +} \ No newline at end of file diff --git a/cake/libs/configure.php b/cake/libs/configure.php index dd4fded79..f4623a7b3 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -313,9 +313,10 @@ class Configure { * `Configure::load('setup', 'default');` * * @link http://book.cakephp.org/view/929/load - * @param string $key name of configuration resource to load. + * @param string $key name of configuration resource to load. * @param string $config Name of the configured reader to use to read the resource identfied by $key. - * @return mixed false if file not found, void if load successful + * @return mixed false if file not found, void if load successful. + * @throws Exception Will throw any exceptions the reader raises. */ public static function load($key, $config = 'default') { if (!isset(self::$_readers[$config])) { diff --git a/cake/tests/cases/libs/config/ini_file.test.php b/cake/tests/cases/libs/config/ini_reader.test.php similarity index 61% rename from cake/tests/cases/libs/config/ini_file.test.php rename to cake/tests/cases/libs/config/ini_reader.test.php index 566c1113b..c3da7edf0 100644 --- a/cake/tests/cases/libs/config/ini_file.test.php +++ b/cake/tests/cases/libs/config/ini_reader.test.php @@ -1,6 +1,6 @@ file = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS . 'acl.ini.php'; + $this->path = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS; } /** @@ -44,7 +44,8 @@ class IniFileTest extends CakeTestCase { * @return void */ function testConstruct() { - $config = new IniFile($this->file); + $reader = new IniReader($this->path); + $config = $reader->read('acl.ini.php'); $this->assertTrue(isset($config['admin'])); $this->assertTrue(isset($config['paul']['groups'])); @@ -57,32 +58,11 @@ class IniFileTest extends CakeTestCase { * @return void */ function testReadingOnlyOneSection() { - $config = new IniFile($this->file, 'admin'); + $reader = new IniReader($this->path, 'admin'); + $config = $reader->read('acl.ini.php'); $this->assertTrue(isset($config['groups'])); $this->assertEquals('administrators', $config['groups']); } -/** - * test getting all the values as an array - * - * @return void - */ - function testAsArray() { - $config = new IniFile($this->file); - $content = $config->asArray(); - - $this->assertTrue(isset($content['admin']['groups'])); - $this->assertTrue(isset($content['paul']['groups'])); - } - -/** - * test that values cannot be modified - * - * @expectedException LogicException - */ - function testNoModification() { - $config = new IniFile($this->file); - $config['admin'] = 'something'; - } } \ No newline at end of file From 26980c23ba7d2a023a060a6bd3e631c44bd81fde Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 12:56:13 -0500 Subject: [PATCH 175/378] Adding file that was omitted from previous commits. --- cake/tests/test_app/config/empty.php | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 cake/tests/test_app/config/empty.php diff --git a/cake/tests/test_app/config/empty.php b/cake/tests/test_app/config/empty.php new file mode 100644 index 000000000..01d4f0a16 --- /dev/null +++ b/cake/tests/test_app/config/empty.php @@ -0,0 +1,2 @@ + Date: Sat, 4 Dec 2010 12:56:37 -0500 Subject: [PATCH 176/378] Adding nested value support to IniReader. Adding boolean conversions. Adding test cases. --- cake/libs/config/ini_reader.php | 42 +++++++++++++++++-- .../cases/libs/config/ini_reader.test.php | 28 +++++++++++++ 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/cake/libs/config/ini_reader.php b/cake/libs/config/ini_reader.php index 7163a47b5..e901d4e18 100644 --- a/cake/libs/config/ini_reader.php +++ b/cake/libs/config/ini_reader.php @@ -13,7 +13,7 @@ * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package cake - * @subpackage cake.cake.libs.controller.components + * @subpackage cake.libs.config * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,6 +23,16 @@ * you should be aware that this class shares the same behavior, especially with * regards to boolean and null values. * + * In addition to the native parse_ini_file features, IniReader also allows you + * to create nested array structures through usage of . delimited names. This allows + * you to create nested arrays structures in an ini config file. For example: + * + * `db.password = secret` would turn into `array('db' => array('password' => 'secret'))` + * + * You can nest properties as deeply as needed using .'s. IniReader also manipulates + * how the special ini values of 'yes', 'no', 'on', 'off', 'null' are handled. + * These values will be converted to their boolean equivalents. + * * @package cake.config * @see http://php.net/parse_ini_file */ @@ -64,9 +74,35 @@ class IniReader implements ConfigReaderInterface { $filename = $this->_path . $file; $contents = parse_ini_file($filename, true); if (!empty($this->_section) && isset($contents[$this->_section])) { - $values = $contents[$this->_section]; + $values = $this->_parseNestedValues($contents[$this->_section]); } else { - $values = $contents; + $values = array(); + foreach ($contents as $section => $attribs) { + $values[$section] = $this->_parseNestedValues($attribs); + } + } + return $values; + } + +/** + * parses nested values out of keys. + * + * @param array $values Values to be exploded. + * @return array Array of values exploded + */ + protected function _parseNestedValues($values) { + foreach ($values as $key => $value) { + if ($value === '1') { + $value = true; + } + if ($value === '') { + $value = false; + } + if (strpos($key, '.') !== false) { + $values = Set::insert($values, $key, $value); + } else { + $values[$key] = $value; + } } return $values; } diff --git a/cake/tests/cases/libs/config/ini_reader.test.php b/cake/tests/cases/libs/config/ini_reader.test.php index c3da7edf0..ef397dece 100644 --- a/cake/tests/cases/libs/config/ini_reader.test.php +++ b/cake/tests/cases/libs/config/ini_reader.test.php @@ -65,4 +65,32 @@ class IniReaderTest extends CakeTestCase { $this->assertEquals('administrators', $config['groups']); } +/** + * test that names with .'s get exploded into arrays. + * + * @return void + */ + function testReadingValuesWithDots() { + $reader = new IniReader($this->path); + $config = $reader->read('nested.ini'); + + $this->assertTrue(isset($config['database']['db']['username'])); + $this->assertEquals('mark', $config['database']['db']['username']); + $this->assertEquals(3, $config['nesting']['one']['two']['three']); + } + +/** + * test boolean reading + * + * @return void + */ + function testBooleanReading() { + $reader = new IniReader($this->path); + $config = $reader->read('nested.ini'); + + $this->assertTrue($config['bools']['test_on']); + $this->assertTrue($config['bools']['test_yes']); + $this->assertFalse($config['bools']['test_no']); + $this->assertFalse($config['bools']['test_off']); + } } \ No newline at end of file From 159f25ff0f02ad3f1e54ac38d2460e9d98ac6035 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 12:58:02 -0500 Subject: [PATCH 177/378] Adding ini file and more tests for types. --- .../tests/cases/libs/config/ini_reader.test.php | 10 ++++++++-- cake/tests/test_app/config/nested.ini | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 cake/tests/test_app/config/nested.ini diff --git a/cake/tests/cases/libs/config/ini_reader.test.php b/cake/tests/cases/libs/config/ini_reader.test.php index ef397dece..b0bd31ee0 100644 --- a/cake/tests/cases/libs/config/ini_reader.test.php +++ b/cake/tests/cases/libs/config/ini_reader.test.php @@ -87,10 +87,16 @@ class IniReaderTest extends CakeTestCase { function testBooleanReading() { $reader = new IniReader($this->path); $config = $reader->read('nested.ini'); - + $this->assertTrue($config['bools']['test_on']); + $this->assertFalse($config['bools']['test_off']); + $this->assertTrue($config['bools']['test_yes']); $this->assertFalse($config['bools']['test_no']); - $this->assertFalse($config['bools']['test_off']); + + $this->assertTrue($config['bools']['test_true']); + $this->assertFalse($config['bools']['test_false']); + + $this->assertFalse($config['bools']['test_null']); } } \ No newline at end of file diff --git a/cake/tests/test_app/config/nested.ini b/cake/tests/test_app/config/nested.ini new file mode 100644 index 000000000..f9832a26c --- /dev/null +++ b/cake/tests/test_app/config/nested.ini @@ -0,0 +1,17 @@ +; Test file for testing ini files with . syntax +[database] +db.username = mark +db.password = secret + +[nesting] +one.two.three = 3 +a.b.c.d = On + +[bools] +test_on = on +test_off = off +test_yes = yes +test_no = no +test_true = true +test_false = false +test_null = null From 466137485d48d668720f08141dcaaa4aa4656d22 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 13:28:43 -0500 Subject: [PATCH 178/378] Removing a duplicated property. Changing is_a() to instanceof as it marginally faster. Adding a comment to getConnection as it was missing it. Minor optimization to a regular expression. --- cake/libs/model/datasources/dbo_source.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index c24051675..a47ee4d74 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -88,14 +88,6 @@ class DboSource extends DataSource { */ private $__sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', 'regexp', 'similar to'); -/** - * Indicates that a transaction have been started - * - * @var boolean - * @access protected - */ - protected $_transactionStarted = false; - /** * Indicates the level of nested transactions * @@ -181,7 +173,7 @@ class DboSource extends DataSource { * @return boolean True if the database could be disconnected, else false */ function disconnect() { - if (is_a($this->_result, 'PDOStatement')) { + if ($this->_result instanceof PDOStatement) { $this->_result->closeCursor(); } unset($this->_connection); @@ -189,6 +181,11 @@ class DboSource extends DataSource { return !$this->connected; } +/** + * Get the underlying connection object. + * + * @return PDOConnection + */ public function getConnection() { return $this->_connection; } @@ -336,7 +333,7 @@ class DboSource extends DataSource { */ protected function _execute($sql, $params = array()) { $sql = trim($sql); - if (preg_match('/^CREATE|^ALTER|^DROP/i', $sql)) { + if (preg_match('/^(?:CREATE|ALTER|DROP)/i', $sql)) { $statements = array_filter(explode(';', $sql)); if (count($statements) > 1) { $result = array_map(array($this, '_execute'), $statements); From d13759522bd34d7ed2babdbb7ba5e6706db17e8c Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 13:45:42 -0500 Subject: [PATCH 179/378] Removing strtolower() calls. You must now call model magic findBy and findAllBy using camelcase forms. --- cake/libs/model/datasources/dbo_source.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index a47ee4d74..010a66630 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -416,14 +416,14 @@ class DboSource extends DataSource { if (count($args) == 1) { return $this->fetchAll($args[0]); - } elseif (count($args) > 1 && (strpos(strtolower($args[0]), 'findby') === 0 || strpos(strtolower($args[0]), 'findallby') === 0)) { + } elseif (count($args) > 1 && (strpos($args[0], 'findBy') === 0 || strpos($args[0], 'findAllBy') === 0)) { $params = $args[1]; - if (strpos(strtolower($args[0]), 'findby') === 0) { - $all = false; + if (strpos($args[0], 'findBy') === 0) { + $all = false; $field = Inflector::underscore(preg_replace('/^findBy/i', '', $args[0])); } else { - $all = true; + $all = true; $field = Inflector::underscore(preg_replace('/^findAllBy/i', '', $args[0])); } From 64d1f799f829a2d38104d9f597b33787be5df4cc Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 13:52:38 -0500 Subject: [PATCH 180/378] Adding fixtures that fixed MissingTableExceptions I was getting. --- .../tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 9df7be0fa..02c0f4a37 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -3111,7 +3111,7 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testVirtualFieldsComplexRead() { - $this->loadFixtures('DataTest', 'Article', 'Comment', 'User', 'Tag'); + $this->loadFixtures('DataTest', 'Article', 'Comment', 'User', 'Tag', 'ArticlesTag'); $Article = ClassRegistry::init('Article'); $commentTable = $this->Dbo->fullTableName('comments'); @@ -3306,7 +3306,7 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testRealQueries() { - $this->loadFixtures('Apple', 'Article', 'User', 'Comment', 'Tag', 'Sample'); + $this->loadFixtures('Apple', 'Article', 'User', 'Comment', 'Tag', 'Sample', 'ArticlesTag'); $Apple = ClassRegistry::init('Apple'); $Article = ClassRegistry::init('Article'); From 18fb12c95c41c130af2362c2a22e726c7b7a3185 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 14:15:32 -0500 Subject: [PATCH 181/378] Removing & pass by ref operators as they aren't needed any more. Fixing a bunch of E_STRICT errors. --- cake/libs/model/datasources/datasource.php | 14 ++++----- cake/libs/model/datasources/dbo/dbo_mssql.php | 10 +++---- cake/libs/model/datasources/dbo/dbo_mysql.php | 4 +-- .../libs/model/datasources/dbo/dbo_oracle.php | 4 +-- .../model/datasources/dbo/dbo_postgres.php | 4 +-- .../libs/model/datasources/dbo/dbo_sqlite.php | 6 ++-- cake/libs/model/datasources/dbo_source.php | 30 +++++++++---------- .../model/datasources/dbo/dbo_mysql.test.php | 1 + 8 files changed, 37 insertions(+), 36 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index 391e1bf65..119f87773 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -286,7 +286,7 @@ class DataSource extends Object { * * @return boolean Returns true if a transaction is not in progress */ - public function begin(&$model) { + public function begin() { return !$this->_transactionStarted; } @@ -295,7 +295,7 @@ class DataSource extends Object { * * @return boolean Returns true if a transaction is in progress */ - public function commit(&$model) { + public function commit() { return $this->_transactionStarted; } @@ -304,7 +304,7 @@ class DataSource extends Object { * * @return boolean Returns true if a transaction is in progress */ - public function rollback(&$model) { + public function rollback() { return $this->_transactionStarted; } @@ -328,7 +328,7 @@ class DataSource extends Object { * @param array $values An Array of values to save. * @return boolean success */ - public function create(&$model, $fields = null, $values = null) { + public function create($model, $fields = null, $values = null) { return false; } @@ -341,7 +341,7 @@ class DataSource extends Object { * @param array $queryData An array of query data used to find the data you want * @return mixed */ - public function read(&$model, $queryData = array()) { + public function read($model, $queryData = array()) { return false; } @@ -355,7 +355,7 @@ class DataSource extends Object { * @param array $values Array of values to be update $fields to. * @return boolean Success */ - public function update(&$model, $fields = null, $values = null) { + public function update($model, $fields = null, $values = null) { return false; } @@ -367,7 +367,7 @@ class DataSource extends Object { * @param Model $model The model class having record(s) deleted * @param mixed $id Primary key of the model */ - public function delete(&$model, $id = null) { + public function delete($model, $id = null) { if ($id == null) { $id = $model->id; } diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php index a07829eb3..4fa73bf8e 100644 --- a/cake/libs/model/datasources/dbo/dbo_mssql.php +++ b/cake/libs/model/datasources/dbo/dbo_mssql.php @@ -227,7 +227,7 @@ class DboMssql extends DboSource { * @param Model $model Model object to describe * @return array Fields in table. Keys are name and type */ - function describe(&$model) { + function describe($model) { $cache = parent::describe($model); if ($cache != null) { @@ -317,7 +317,7 @@ class DboMssql extends DboSource { * @param mixed $fields * @return array */ - function fields(&$model, $alias = null, $fields = array(), $quote = true) { + function fields($model, $alias = null, $fields = array(), $quote = true) { if (empty($alias)) { $alias = $model->alias; } @@ -383,7 +383,7 @@ class DboMssql extends DboSource { * @param mixed $conditions * @return array */ - function create(&$model, $fields = null, $values = null) { + function create($model, $fields = null, $values = null) { if (!empty($values)) { $fields = array_combine($fields, $values); } @@ -413,7 +413,7 @@ class DboMssql extends DboSource { * @param mixed $conditions * @return array */ - function update(&$model, $fields = array(), $values = null, $conditions = null) { + function update($model, $fields = array(), $values = null, $conditions = null) { if (!empty($values)) { $fields = array_combine($fields, $values); } @@ -667,7 +667,7 @@ class DboMssql extends DboSource { * @param boolean $cache Enables returning/storing cached query results * @return array Array of resultset rows, or false if no rows matched */ - function read(&$model, $queryData = array(), $recursive = null) { + function read($model, $queryData = array(), $recursive = null) { $results = parent::read($model, $queryData, $recursive); $this->__fieldMappings = array(); return $results; diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 069cf089a..ab1e0f3b6 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -329,7 +329,7 @@ class DboMysql extends DboSource { * @param mixed $conditions * @return array */ - function update(&$model, $fields = array(), $values = null, $conditions = null) { + function update($model, $fields = array(), $values = null, $conditions = null) { if (!$this->_useAlias) { return parent::update($model, $fields, $values, $conditions); } @@ -371,7 +371,7 @@ class DboMysql extends DboSource { * @param mixed $conditions * @return boolean Success */ - function delete(&$model, $conditions = null) { + function delete($model, $conditions = null) { if (!$this->_useAlias) { return parent::delete($model, $conditions); } diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php index c559a28a4..6d1286794 100644 --- a/cake/libs/model/datasources/dbo/dbo_oracle.php +++ b/cake/libs/model/datasources/dbo/dbo_oracle.php @@ -478,7 +478,7 @@ class DboOracle extends DboSource { * @param object instance of a model to inspect * @return array Fields in table. Keys are name and type */ - public function describe(&$model) { + public function describe($model) { $table = $this->fullTableName($model, false); if (!empty($model->sequence)) { @@ -974,7 +974,7 @@ class DboOracle extends DboSource { * @param integer $recursive Number of levels of association * @param array $stack */ - function queryAssociation(&$model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) { + function queryAssociation($model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) { if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) { if (!isset($resultSet) || !is_array($resultSet)) { if (Configure::read('debug') > 0) { diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index bebbb5447..e2f2e8234 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -185,7 +185,7 @@ class DboPostgres extends DboSource { * @param string $tableName Name of database table to inspect * @return array Fields in table. Keys are name and type */ - function &describe(&$model) { + function describe($model) { $fields = parent::describe($model); $table = $this->fullTableName($model, false); $this->_sequenceMap[$table] = array(); @@ -332,7 +332,7 @@ class DboPostgres extends DboSource { * @param mixed $fields * @return array */ - function fields(&$model, $alias = null, $fields = array(), $quote = true) { + function fields($model, $alias = null, $fields = array(), $quote = true) { if (empty($alias)) { $alias = $model->alias; } diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index 8c5722762..1b4887613 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -166,7 +166,7 @@ class DboSqlite extends DboSource { * @return array Fields in table. Keys are name and type * @access public */ - function describe(&$model) { + function describe($model) { $cache = parent::describe($model); if ($cache != null) { return $cache; @@ -208,7 +208,7 @@ class DboSqlite extends DboSource { * @return array * @access public */ - function update(&$model, $fields = array(), $values = null, $conditions = null) { + function update($model, $fields = array(), $values = null, $conditions = null) { if (empty($values) && !empty($fields)) { foreach ($fields as $field => $value) { if (strpos($field, $model->alias . '.') !== false) { @@ -458,7 +458,7 @@ class DboSqlite extends DboSource { * @return array Fields in table. Keys are column and unique * @access public */ - function index(&$model) { + function index($model) { $index = array(); $table = $this->fullTableName($model); if ($table) { diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 010a66630..b12bed759 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -854,7 +854,7 @@ class DboSource extends DataSource { * be used to generate values. * @return boolean Success */ - public function create(&$model, $fields = null, $values = null) { + public function create($model, $fields = null, $values = null) { $id = null; if ($fields == null) { @@ -902,7 +902,7 @@ class DboSource extends DataSource { * @param integer $recursive Number of levels of association * @return mixed boolean false on error/failure. An array of results on success. */ - public function read(&$model, $queryData = array(), $recursive = null) { + public function read($model, $queryData = array(), $recursive = null) { $queryData = $this->__scrubQueryData($queryData); $null = null; @@ -1046,7 +1046,7 @@ class DboSource extends DataSource { * @param integer $recursive Number of levels of association * @param array $stack */ - public function queryAssociation(&$model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) { + public function queryAssociation($model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) { if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) { if (!isset($resultSet) || !is_array($resultSet)) { if (Configure::read('debug') > 0) { @@ -1342,7 +1342,7 @@ class DboSource extends DataSource { * @param array $resultSet * @return mixed */ - public function generateAssociationQuery(&$model, &$linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) { + public function generateAssociationQuery($model, &$linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) { $queryData = $this->__scrubQueryData($queryData); $assocData = $this->__scrubQueryData($assocData); @@ -1575,7 +1575,7 @@ class DboSource extends DataSource { * @access public * @see DboSource::renderStatement() */ - public function buildStatement($query, &$model) { + public function buildStatement($query, $model) { $query = array_merge(array('offset' => null, 'joins' => array()), $query); if (!empty($query['joins'])) { $count = count($query['joins']); @@ -1694,7 +1694,7 @@ class DboSource extends DataSource { * @param mixed $conditions * @return boolean Success */ - public function update(&$model, $fields = array(), $values = null, $conditions = null) { + public function update($model, $fields = array(), $values = null, $conditions = null) { if ($values == null) { $combined = $fields; } else { @@ -1728,7 +1728,7 @@ class DboSource extends DataSource { * @param boolean $alias Include the model alias in the field name * @return array Fields and values, quoted and preparted */ - protected function _prepareUpdateFields(&$model, $fields, $quoteValues = true, $alias = false) { + protected function _prepareUpdateFields($model, $fields, $quoteValues = true, $alias = false) { $quotedAlias = $this->startQuote . $model->alias . $this->endQuote; $updates = array(); @@ -1771,7 +1771,7 @@ class DboSource extends DataSource { * @param mixed $conditions * @return boolean Success */ - public function delete(&$model, $conditions = null) { + public function delete($model, $conditions = null) { $alias = $joins = null; $table = $this->fullTableName($model); $conditions = $this->_matchRecords($model, $conditions); @@ -1795,7 +1795,7 @@ class DboSource extends DataSource { * @param mixed $conditions * @return array List of record IDs */ - protected function _matchRecords(&$model, $conditions = null) { + protected function _matchRecords($model, $conditions = null) { if ($conditions === true) { $conditions = $this->conditions(true); } elseif ($conditions === null) { @@ -1871,7 +1871,7 @@ class DboSource extends DataSource { * @param array $params Function parameters (any values must be quoted manually) * @return string An SQL calculation function */ - public function calculate(&$model, $func, $params = array()) { + public function calculate($model, $func, $params = array()) { $params = (array)$params; switch (strtolower($func)) { @@ -1990,7 +1990,7 @@ class DboSource extends DataSource { * @see DboSource::update() * @see DboSource::conditions() */ - public function defaultConditions(&$model, $conditions, $useAlias = true) { + public function defaultConditions($model, $conditions, $useAlias = true) { if (!empty($conditions)) { return $conditions; } @@ -2049,7 +2049,7 @@ class DboSource extends DataSource { * @param mixed $fields virtual fields to be used on query * @return array */ - protected function _constructVirtualFields(&$model, $alias, $fields) { + protected function _constructVirtualFields($model, $alias, $fields) { $virtual = array(); foreach ($fields as $field) { $virtualField = $this->name($alias . $this->virtualFieldSeparator . $field); @@ -2068,7 +2068,7 @@ class DboSource extends DataSource { * @param boolean $quote If false, returns fields array unquoted * @return array */ - public function fields(&$model, $alias = null, $fields = array(), $quote = true) { + public function fields($model, $alias = null, $fields = array(), $quote = true) { if (empty($alias)) { $alias = $model->alias; } @@ -2361,7 +2361,7 @@ class DboSource extends DataSource { * @return string * @access private */ - function __parseKey(&$model, $key, $value) { + function __parseKey($model, $key, $value) { $operatorMatch = '/^((' . implode(')|(', $this->__sqlOps); $operatorMatch .= '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is'; $bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false)); @@ -2612,7 +2612,7 @@ class DboSource extends DataSource { * @param string $sql SQL WHERE clause (condition only, not the "WHERE" part) * @return boolean True if the table has a matching record, else false */ - public function hasAny(&$Model, $sql) { + public function hasAny($Model, $sql) { $sql = $this->conditions($sql); $table = $this->fullTableName($Model); $alias = $this->alias . $this->name($Model->alias); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 02c0f4a37..bd29b5d39 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -2601,6 +2601,7 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testCalculations() { + $this->Model = new TestModel(); $result = $this->Dbo->calculate($this->Model, 'count'); $this->assertEqual($result, 'COUNT(*) AS `count`'); From 7e3c98024e2e8c12e102b89a686e6829c5602e27 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 14:19:36 -0500 Subject: [PATCH 182/378] Removing reference operators in ModelBehavior. --- cake/libs/model/model_behavior.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cake/libs/model/model_behavior.php b/cake/libs/model/model_behavior.php index ae38705cd..192b21b72 100644 --- a/cake/libs/model/model_behavior.php +++ b/cake/libs/model/model_behavior.php @@ -59,7 +59,7 @@ class ModelBehavior extends Object { * @param object $model Model using this behavior * @param array $config Configuration settings for $model */ - public function setup(&$model, $config = array()) { } + public function setup($model, $config = array()) { } /** * Clean up any initialization this behavior has done on a model. Called when a behavior is dynamically @@ -69,7 +69,7 @@ class ModelBehavior extends Object { * @access public * @see BehaviorCollection::detach() */ - function cleanup(&$model) { + function cleanup($model) { if (isset($this->settings[$model->alias])) { unset($this->settings[$model->alias]); } @@ -83,7 +83,7 @@ class ModelBehavior extends Object { * @return mixed False if the operation should abort. An array will replace the value of $query. * @access public */ - public function beforeFind(&$model, $query) { } + public function beforeFind($model, $query) { } /** * After find callback. Can be used to modify any results returned by find and findAll. @@ -94,7 +94,7 @@ class ModelBehavior extends Object { * @return mixed An array value will replace the value of $results - any other value will be ignored. * @access public */ - public function afterFind(&$model, $results, $primary) { } + public function afterFind($model, $results, $primary) { } /** * Before validate callback @@ -103,7 +103,7 @@ class ModelBehavior extends Object { * @return mixed False if the operation should abort. Any other result will continue. * @access public */ - public function beforeValidate(&$model) { } + public function beforeValidate($model) { } /** * Before save callback @@ -112,7 +112,7 @@ class ModelBehavior extends Object { * @return mixed False if the operation should abort. Any other result will continue. * @access public */ - public function beforeSave(&$model) { } + public function beforeSave($model) { } /** * After save callback @@ -120,7 +120,7 @@ class ModelBehavior extends Object { * @param object $model Model using this behavior * @param boolean $created True if this save created a new record */ - public function afterSave(&$model, $created) { } + public function afterSave($model, $created) { } /** * Before delete callback @@ -130,14 +130,14 @@ class ModelBehavior extends Object { * @return mixed False if the operation should abort. Any other result will continue. * @access public */ - public function beforeDelete(&$model, $cascade = true) { } + public function beforeDelete($model, $cascade = true) { } /** * After delete callback * * @param object $model Model using this behavior */ - public function afterDelete(&$model) { } + public function afterDelete($model) { } /** * DataSource error callback @@ -145,7 +145,7 @@ class ModelBehavior extends Object { * @param object $model Model using this behavior * @param string $error Error generated in DataSource */ - public function onError(&$model, $error) { } + public function onError($model, $error) { } /** * If $model's whitelist property is non-empty, $field will be added to it. @@ -158,7 +158,7 @@ class ModelBehavior extends Object { * @access protected * @return void */ - function _addToWhitelist(&$model, $field) { + function _addToWhitelist($model, $field) { if (is_array($field)) { foreach ($field as $f) { $this->_addToWhitelist($model, $f); From 7e29859676b4087687d8e6fee843a742fbf7bb7e Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 14:19:53 -0500 Subject: [PATCH 183/378] Fixing E_STRICT errors in test models. --- cake/tests/cases/libs/model/models.php | 54 +++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/cake/tests/cases/libs/model/models.php b/cake/tests/cases/libs/model/models.php index 8e20eb6be..45e3fc80c 100644 --- a/cake/tests/cases/libs/model/models.php +++ b/cake/tests/cases/libs/model/models.php @@ -262,7 +262,7 @@ class Article extends CakeTestModel { * @access public * @return void */ - function beforeSave() { + function beforeSave($options = array()) { return $this->beforeSaveReturn; } @@ -560,7 +560,7 @@ class ModifiedComment extends CakeTestModel { * * @return void */ - function afterFind($results) { + function afterFind($results, $primary = false) { if (isset($results[0])) { $results[0]['Comment']['callback'] = 'Fire'; } @@ -605,7 +605,7 @@ class AgainModifiedComment extends CakeTestModel { * * @return void */ - function afterFind($results) { + function afterFind($results, $primary = false) { if (isset($results[0])) { $results[0]['Comment']['querytype'] = $this->findQueryType; } @@ -921,7 +921,7 @@ class Post extends CakeTestModel { return true; } - function afterFind($results) { + function afterFind($results, $primary = false) { $this->useDbConfig = 'test'; return $results; } @@ -958,7 +958,7 @@ class Author extends CakeTestModel { * @access public * @return void */ - function afterFind($results) { + function afterFind($results, $primary = false) { $results[0]['Author']['test'] = 'working'; return $results; } @@ -987,7 +987,7 @@ class ModifiedAuthor extends Author { * @access public * @return void */ - function afterFind($results) { + function afterFind($results, $primary = false) { foreach($results as $index => $result) { $results[$index]['Author']['user'] .= ' (CakePHP)'; } @@ -1166,7 +1166,7 @@ class NodeAfterFind extends CakeTestModel { * @access public * @return void */ - function afterFind($results) { + function afterFind($results, $primary = false) { return $results; } } @@ -2075,7 +2075,7 @@ class CallbackPostTestModel extends CakeTestModel { * * @return void */ - function beforeSave($options) { + function beforeSave($options = array()) { return $this->beforeSaveReturn; } /** @@ -2083,7 +2083,7 @@ class CallbackPostTestModel extends CakeTestModel { * * @return void */ - function beforeValidate($options) { + function beforeValidate($options = array()) { return $this->beforeValidateReturn; } /** @@ -2304,7 +2304,7 @@ class ValidationTest2 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { return array(); } } @@ -3801,7 +3801,7 @@ class TestModel4 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), @@ -3852,7 +3852,7 @@ class TestModel4TestModel7 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'test_model4_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), @@ -3923,7 +3923,7 @@ class TestModel5 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), @@ -3986,7 +3986,7 @@ class TestModel6 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), @@ -4038,7 +4038,7 @@ class TestModel7 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), @@ -4103,7 +4103,7 @@ class TestModel8 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), @@ -4167,7 +4167,7 @@ class TestModel9 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), @@ -4234,7 +4234,7 @@ class Level extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), @@ -4299,7 +4299,7 @@ class Group extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), @@ -4377,7 +4377,7 @@ class User2 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), @@ -4463,7 +4463,7 @@ class Category2 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), @@ -4528,7 +4528,7 @@ class Article2 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), @@ -4594,7 +4594,7 @@ class CategoryFeatured2 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), @@ -4658,7 +4658,7 @@ class Featured2 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), @@ -4717,7 +4717,7 @@ class Comment2 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), @@ -4799,7 +4799,7 @@ class ArticleFeatured2 extends CakeTestModel { * @access public * @return void */ - function schema() { + public function schema($field = false) { if (!isset($this->_schema)) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), @@ -4875,7 +4875,7 @@ class MysqlTestModel extends Model { * @access public * @return void */ - function schema() { + public function schema($field = false) { return array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'), From 843f5c6190c9dd01defe57b8644bc4539a3703fb Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 14:20:50 -0500 Subject: [PATCH 184/378] Fixing E_STRICT error in ConsoleErrorHandler. --- cake/console/libs/console_error_handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/console/libs/console_error_handler.php b/cake/console/libs/console_error_handler.php index 4a7b6ceed..b941a6c93 100644 --- a/cake/console/libs/console_error_handler.php +++ b/cake/console/libs/console_error_handler.php @@ -55,7 +55,7 @@ class ConsoleErrorHandler extends ErrorHandler { * * @return void */ - public static function handleException($exception) { + public static function handleException(Exception $exception) { $stderr = self::getStderr(); $stderr->write(sprintf( __("Error: %s\n%s"), From a6c5065e9c7d9057db5cd18787b44492ad7e68c8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 14:31:11 -0500 Subject: [PATCH 185/378] Fixing a few more E_STRICT errors in postgres test/class. --- cake/libs/model/datasources/dbo/dbo_postgres.php | 2 +- .../cases/libs/model/datasources/dbo/dbo_postgres.test.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index e2f2e8234..7e001344d 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -152,7 +152,7 @@ class DboPostgres extends DboSource { * * @return array Array of tablenames in the database */ - function listSources() { + function listSources($data = null) { $cache = parent::listSources(); if ($cache != null) { diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 1338ed791..c71836f5d 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -44,7 +44,7 @@ class DboPostgresTestDb extends DboPostgres { * @access protected * @return void */ - function _execute($sql) { + function _execute($sql, $params = array()) { $this->simulated[] = $sql; return null; } @@ -130,7 +130,7 @@ class PostgresTestModel extends Model { * @access public * @return void */ - function schema() { + function schema($field = false) { return array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'), @@ -184,7 +184,7 @@ class PostgresClientTestModel extends Model { * @access public * @return void */ - function schema() { + function schema($field = false) { return array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'), 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), From 8031d33d33188cb32bb3a72b978acca844c0a5e4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 14:37:02 -0500 Subject: [PATCH 186/378] Fixing more E_STRICT notices and adding a type check to DboSource::dropSchema(). --- cake/libs/model/datasources/dbo/dbo_mysql.php | 8 ++------ cake/libs/model/datasources/dbo/dbo_oracle.php | 8 ++------ cake/libs/model/datasources/dbo/dbo_sqlite.php | 2 +- cake/libs/model/datasources/dbo_source.php | 8 ++------ .../cases/libs/model/datasources/dbo/dbo_sqlite.test.php | 2 +- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index ab1e0f3b6..f39b50420 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -500,16 +500,12 @@ class DboMysql extends DboSource { /** * Generate a MySQL "drop table" statement for the given Schema object * - * @param object $schema An instance of a subclass of CakeSchema + * @param CakeSchema $schema An instance of a subclass of CakeSchema * @param string $table Optional. If specified only the table name given will be generated. * Otherwise, all tables defined in the schema are generated. * @return string */ - function dropSchema($schema, $table = null) { - if (!is_a($schema, 'CakeSchema')) { - trigger_error(__('Invalid schema object'), E_USER_WARNING); - return null; - } + function dropSchema(CakeSchema $schema, $table = null) { $out = ''; foreach ($schema->tables as $curTable => $columns) { if (!$table || $table == $curTable) { diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php index 6d1286794..9d94fbf2d 100644 --- a/cake/libs/model/datasources/dbo/dbo_oracle.php +++ b/cake/libs/model/datasources/dbo/dbo_oracle.php @@ -1121,16 +1121,12 @@ class DboOracle extends DboSource { /** * Generate a "drop table" statement for the given Schema object * - * @param object $schema An instance of a subclass of CakeSchema + * @param CakeSchema $schema An instance of a subclass of CakeSchema * @param string $table Optional. If specified only the table name given will be generated. * Otherwise, all tables defined in the schema are generated. * @return string */ - function dropSchema($schema, $table = null) { - if (!is_a($schema, 'CakeSchema')) { - trigger_error(__('Invalid schema object'), E_USER_WARNING); - return null; - } + function dropSchema(CakeSchema $schema, $table = null) { $out = ''; foreach ($schema->tables as $curTable => $columns) { diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index 1b4887613..245c64aa7 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -138,7 +138,7 @@ class DboSqlite extends DboSource { * @return array Array of tablenames in the database * @access public */ - function listSources() { + function listSources($data = null) { $cache = parent::listSources(); if ($cache != null) { return $cache; diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index b12bed759..35edeb799 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -2801,16 +2801,12 @@ class DboSource extends DataSource { /** * Generate a "drop table" statement for the given Schema object * - * @param object $schema An instance of a subclass of CakeSchema + * @param CakeSchema $schema An instance of a subclass of CakeSchema * @param string $table Optional. If specified only the table name given will be generated. * Otherwise, all tables defined in the schema are generated. * @return string */ - public function dropSchema($schema, $table = null) { - if (!is_a($schema, 'CakeSchema')) { - trigger_error(__('Invalid schema object'), E_USER_WARNING); - return null; - } + public function dropSchema(CakeSchema $schema, $table = null) { $out = ''; foreach ($schema->tables as $curTable => $columns) { diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php index e253b1a26..b42b6209a 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php @@ -42,7 +42,7 @@ class DboSqliteTestDb extends DboSqlite { * @access protected * @return void */ - function _execute($sql) { + function _execute($sql, $params = array()) { $this->simulated[] = $sql; return null; } From ae814db2dd37f6bccbc2013f91f04afcab6240ac Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 14:47:47 -0500 Subject: [PATCH 187/378] Changing IniAcl to use IniReader. --- cake/libs/controller/components/acl.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/controller/components/acl.php b/cake/libs/controller/components/acl.php index 77f2cccc2..659f6869b 100644 --- a/cake/libs/controller/components/acl.php +++ b/cake/libs/controller/components/acl.php @@ -662,9 +662,9 @@ class IniAcl extends Object implements AclInterface { * @return array INI section structure */ public function readConfigFile($filename) { - App::import('Core', 'config/IniFile'); - $iniFile = new IniFile($filename); - return $iniFile->asArray(); + App::import('Core', 'config/IniReader'); + $iniFile = new IniReader(dirname($filename) . DS); + return $iniFile->read(basename($filename)); } /** From 94258e14d711d5f0bec386f017b543d1414d415e Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 16:29:34 -0500 Subject: [PATCH 188/378] Doing some reformatting and removing calls to read() since we are already in Configure. --- cake/libs/configure.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index f4623a7b3..003330516 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -63,13 +63,19 @@ class Configure { */ public static function bootstrap($boot = true) { if ($boot) { - self::write('App', array('base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR, 'www_root' => WWW_ROOT)); + self::write('App', array( + 'base' => false, + 'baseUrl' => false, + 'dir' => APP_DIR, + 'webroot' => WEBROOT_DIR, + 'www_root' => WWW_ROOT + )); if (!include(CONFIGS . 'core.php')) { trigger_error(sprintf(__("Can't find application core file. Please create %score.php, and make sure it is readable by PHP."), CONFIGS), E_USER_ERROR); } - if (Configure::read('Cache.disable') !== true) { + if (empty(self::$_values['Cache']['disable'])) { $cache = Cache::config('default'); if (empty($cache['settings'])) { @@ -84,7 +90,7 @@ class Configure { $prefix = $cache['settings']['prefix']; } - if (Configure::read('debug') >= 1) { + if (self::$_values['debug'] >= 1) { $duration = '+10 seconds'; } else { $duration = '+999 days'; From 539f2cd785df423f61fbf76b7e4dd0a07a4a7245 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 16:34:20 -0500 Subject: [PATCH 189/378] Removing a cakeError that slipped through the cracks. --- cake/libs/view/pages/home.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/view/pages/home.ctp b/cake/libs/view/pages/home.ctp index c8939c85e..a781a9a4f 100644 --- a/cake/libs/view/pages/home.ctp +++ b/cake/libs/view/pages/home.ctp @@ -17,7 +17,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ if (Configure::read() == 0): - $this->cakeError('error404'); + throw new NotFoundException(); endif; ?>

From b49c4402e52eab97daafb413e6804a17c1aca73c Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 17:26:59 -0500 Subject: [PATCH 190/378] Implementing store and restore for Configure. Test cases added. --- cake/libs/configure.php | 69 ++++++++---------------- cake/tests/cases/libs/configure.test.php | 43 +++++++++------ 2 files changed, 49 insertions(+), 63 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 003330516..7fde78601 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -349,64 +349,37 @@ class Configure { } /** - * Used to write a config file to disk. + * Used to write runtime configuration into Cache. Stored runtime configuration can be + * restored using `Configure::restore()`. These methods can be used to enable configuration managers + * frontends, or other GUI type interfaces for configuration. * - * {{{ - * Configure::store('Model', 'class_paths', array('Users' => array( - * 'path' => 'users', 'plugin' => true - * ))); - * }}} - * - * @param string $type Type of config file to write, ex: Models, Controllers, Helpers, Components - * @param string $name file name. - * @param array $data array of values to store. - * @return void + * @param string $name The storage name for the saved configuration. + * @param string $cacheConfig The cache configuration to save into. Defaults to 'default' + * @param array $data Either an array of data to store, or leave empty to store all values. + * @return boolean Success */ - public static function store($type, $name, $data = array()) { - $write = true; - $content = ''; - - foreach ($data as $key => $value) { - $content .= "\$config['$type']['$key'] = " . var_export($value, true) . ";\n"; + public static function store($name, $cacheConfig = 'default', $data = null) { + if ($data === null) { + $data = self::$_values; } - if (is_null($type)) { - $write = false; - } - self::__writeConfig($content, $name, $write); + return Cache::write($name, $data, $cacheConfig); } /** - * Creates a cached version of a configuration file. - * Appends values passed from Configure::store() to the cached file + * Restores configuration data stored in the Cache into configure. Restored + * values will overwrite existing ones. * - * @param string $content Content to write on file - * @param string $name Name to use for cache file - * @param boolean $write true if content should be written, false otherwise - * @return void - * @access private + * @param string $name Name of the stored config file to load. + * @param string $cacheConfig Name of the Cache configuration to read from. + * @return boolean Success. */ - private static function __writeConfig($content, $name, $write = true) { - $file = CACHE . 'persistent' . DS . $name . '.php'; - - if (self::read('debug') > 0) { - $expires = "+10 seconds"; - } else { - $expires = "+999 days"; - } - $cache = cache('persistent' . DS . $name . '.php', null, $expires); - - if ($cache === null) { - cache('persistent' . DS . $name . '.php', "isWritable()) { - $fileClass->fwrite($content); - } + public static function restore($name, $cacheConfig = 'default') { + $values = Cache::read($name, $cacheConfig); + if ($values) { + return self::write($values); } + return false; } - } /** diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index bbe43047b..0e3a3b52c 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -237,26 +237,39 @@ class ConfigureTest extends CakeTestCase { * @access public * @return void */ - function testStoreAndLoad() { - $this->markTestSkipped('Configure::store() is not working right now.'); + function testStoreAndRestore() { Configure::write('Cache.disable', false); - $expected = array('data' => 'value with backslash \, \'singlequote\' and "doublequotes"'); - Configure::store('SomeExample', 'test', $expected); + Configure::write('Testing', 'yummy'); + $this->assertTrue(Configure::store('store_test', 'default')); - Configure::load('test'); - $config = Configure::read('SomeExample'); - $this->assertEqual($config, $expected); + Configure::delete('Testing'); + $this->assertNull(Configure::read('Testing')); - $expected = array( - 'data' => array('first' => 'value with backslash \, \'singlequote\' and "doublequotes"', 'second' => 'value2'), - 'data2' => 'value' - ); - Configure::store('AnotherExample', 'test_config', $expected); + Configure::restore('store_test', 'default'); + $this->assertEquals('yummy', Configure::read('Testing')); - Configure::load('test_config'); - $config = Configure::read('AnotherExample'); - $this->assertEqual($config, $expected); + Cache::delete('store_test', 'default'); + } + +/** + * test that store and restore only store/restore the provided data. + * + * @return void + */ + function testStoreAndRestoreWithData() { + Configure::write('Cache.disable', false); + + Configure::write('testing', 'value'); + Configure::store('store_test', 'default', array('store_test' => 'one')); + Configure::delete('testing'); + $this->assertNull(Configure::read('store_test'), 'Calling store with data shouldnt modify runtime.'); + + Configure::restore('store_test', 'default'); + $this->assertEquals('one', Configure::read('store_test')); + $this->assertNull(Configure::read('testing'), 'Values that were not stored are not restored.'); + + Cache::delete('store_test', 'default'); } /** From ba63a2948c055db76b7a0b67e29d907f488437ff Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 17:49:09 -0500 Subject: [PATCH 191/378] Fixing failing test caused by additional trailing space. --- cake/tests/cases/console/libs/console_error_handler.test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cake/tests/cases/console/libs/console_error_handler.test.php b/cake/tests/cases/console/libs/console_error_handler.test.php index 0b0719a14..f00232bfb 100644 --- a/cake/tests/cases/console/libs/console_error_handler.test.php +++ b/cake/tests/cases/console/libs/console_error_handler.test.php @@ -43,7 +43,6 @@ class ConsoleErrorHandlerTest extends CakeTestCase { */ function tearDown() { parent::tearDown(); - ConsoleErrorHandler::$stderr = null; } /** @@ -52,7 +51,7 @@ class ConsoleErrorHandlerTest extends CakeTestCase { * @return void */ function testHandleError() { - $content = 'Notice Error: This is a notice error in [/some/file, line 275]'; + $content = "Notice Error: This is a notice error in [/some/file, line 275]\n"; ConsoleErrorHandler::$stderr->expects($this->once())->method('write') ->with($content); From 0b18fc25a697914c34d55b3372f02bd1e8ea4ab0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 17:53:57 -0500 Subject: [PATCH 192/378] Changing some requires so things run smoother. --- cake/tests/cases/libs/app.test.php | 4 ++-- cake/tests/cases/libs/cache/memcache.test.php | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cake/tests/cases/libs/app.test.php b/cake/tests/cases/libs/app.test.php index 5a03cb623..2d7627cc6 100644 --- a/cake/tests/cases/libs/app.test.php +++ b/cake/tests/cases/libs/app.test.php @@ -211,9 +211,9 @@ class AppImportTest extends CakeTestCase { $this->assertTrue($file); $this->assertTrue(class_exists('Shell')); - $file = App::import('Lib', 'cache/Apc'); + $file = App::import('Lib', 'config/PhpReader'); $this->assertTrue($file); - $this->assertTrue(class_exists('ApcEngine')); + $this->assertTrue(class_exists('PhpReader')); $file = App::import('Model', 'SomeRandomModelThatDoesNotExist', false); $this->assertFalse($file); diff --git a/cake/tests/cases/libs/cache/memcache.test.php b/cake/tests/cases/libs/cache/memcache.test.php index 0eb11e71a..e69e243a2 100644 --- a/cake/tests/cases/libs/cache/memcache.test.php +++ b/cake/tests/cases/libs/cache/memcache.test.php @@ -20,8 +20,7 @@ if (!class_exists('Cache')) { require LIBS . 'cache.php'; } -App::import('Core', 'cache/Memcache'); - +require_once LIBS . 'cache' . DS . 'memcache.php'; class TestMemcacheEngine extends MemcacheEngine { /** From 5ad8d8af41b7ca1b4b7b6198a1914e949518d0ff Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 22:57:33 -0500 Subject: [PATCH 193/378] Adding a parameter to configured() to allow you to check if a particular config has been configured. --- cake/libs/configure.php | 5 ++++- cake/tests/cases/libs/configure.test.php | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 7fde78601..433231742 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -284,7 +284,10 @@ class Configure { * * @return array Array of the configured reader objects. */ - public static function configured() { + public static function configured($name = null) { + if ($name) { + return isset(self::$_readers[$name]); + } return array_keys(self::$_readers); } diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index 0e3a3b52c..eb9cb63b5 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -294,6 +294,10 @@ class ConfigureTest extends CakeTestCase { $configured = Configure::configured(); $this->assertTrue(in_array('test', $configured)); + + $this->assertTrue(Configure::configured('test')); + $this->assertFalse(Configure::configured('fake_garbage')); + $this->assertTrue(Configure::drop('test')); $this->assertFalse(Configure::drop('test'), 'dropping things that do not exist should return false.'); } From 9dd78c7dc1adbebe7ef69e10bfbb1625ebacc83f Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 22:59:07 -0500 Subject: [PATCH 194/378] Updating Multibyte class to use new Configure api. --- cake/libs/multibyte.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cake/libs/multibyte.php b/cake/libs/multibyte.php index a988fa109..69c23188f 100644 --- a/cake/libs/multibyte.php +++ b/cake/libs/multibyte.php @@ -1077,7 +1077,11 @@ class Multibyte { if ($range === false) { return null; } - Configure::load('unicode' . DS . 'casefolding' . DS . $range); + if (!Configure::configured('_cake_core_')) { + App::import('Core', 'config/PhpReader'); + Configure::config('_cake_core_', new PhpReader(CAKE . 'config' . DS)); + } + Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_'); self::$__caseFold[$range] = Configure::read($range); Configure::delete($range); } From d202ea643d213d519c9388b1ea47fed803098cff Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 23:49:00 -0500 Subject: [PATCH 195/378] Fixing issue loading plugin models when uses == false. --- cake/libs/controller/controller.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index d4341655b..b51770eb7 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -476,9 +476,10 @@ class Controller extends Object { } else { $id = $this->passedArgs['0']; } + $plugin = $this->plugin ? $this->plugin . '.' : null; if ($this->uses === false) { - $this->loadModel($this->modelClass, $id); + $this->loadModel($plugin . $this->modelClass, $id); } elseif ($this->uses) { $uses = is_array($this->uses) ? $this->uses : array($this->uses); list($plugin, $modelClassName) = pluginSplit($uses[0]); From 7024d14c748a312af19ca2f8546db3248b844ec2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 5 Dec 2010 18:41:26 -0500 Subject: [PATCH 196/378] Removing private annotations for File::__construct() and File::__destruct() as its just not true. This also prevents them from being included in the API docs. --- cake/libs/file.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/cake/libs/file.php b/cake/libs/file.php index cc69c2122..86755a513 100644 --- a/cake/libs/file.php +++ b/cake/libs/file.php @@ -93,7 +93,6 @@ class File extends Object { * @param string $path Path to file * @param boolean $create Create file if it does not exist (if true) * @param integer $mode Mode to apply to the folder holding the file - * @access private */ function __construct($path, $create = false, $mode = 0755) { parent::__construct(); @@ -108,7 +107,6 @@ class File extends Object { /** * Closes the current file if it is opened * - * @access private */ function __destruct() { $this->close(); From 5eab027b84ef970ef48a91a2e40ef0bff5a1d16f Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 5 Dec 2010 17:28:15 -0800 Subject: [PATCH 197/378] Removed unnecessary pass by references --- cake/tests/cases/libs/controller/controller.test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index bfd668d41..e1ba796d9 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -759,7 +759,7 @@ class ControllerTest extends CakeTestCase { function testPaginateFieldsDouble(){ $request = new CakeRequest('controller_posts/index'); - $Controller =& new Controller($request); + $Controller = new Controller($request); $Controller->uses = array('ControllerPost'); $Controller->request->params['url'] = array(); $Controller->constructClasses(); @@ -1044,7 +1044,7 @@ class ControllerTest extends CakeTestCase { $core[0] ) ), true); - $Controller =& new Controller($this->getMock('CakeRequest')); + $Controller = new Controller($this->getMock('CakeRequest')); $Controller->uses = array(); $Controller->components = array('Test'); $Controller->constructClasses(); @@ -1408,7 +1408,7 @@ class ControllerTest extends CakeTestCase { * @return void */ function testValidateErrorsOnArbitraryModels() { - $TestController =& new TestController(); + $TestController = new TestController(); $Post = new ControllerPost(); $Post->validate = array('title' => 'notEmpty'); From 97fe32f87c16a6a3e909389e58bac44de5a4960d Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 5 Dec 2010 23:36:28 -0200 Subject: [PATCH 198/378] Request return a pointer to body. It will reduce the memory usage in big responses. --- cake/libs/http_socket.php | 15 ++++++++------- cake/tests/cases/libs/http_socket.test.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 1738c4076..c467393c9 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -213,15 +213,16 @@ class HttpSocket extends CakeSocket { * method and provide a more granular interface. * * @param mixed $request Either an URI string, or an array defining host/uri - * @return mixed false on error, request body on success + * @return mixed null on error, reference to request body on success */ - public function request($request = array()) { + public function &request($request = array()) { $this->reset(false); if (is_string($request)) { $request = array('uri' => $request); } elseif (!is_array($request)) { - return false; + $return = false; + return $return; } if (!isset($request['uri'])) { @@ -354,7 +355,7 @@ class HttpSocket extends CakeSocket { * @param array $request An indexed array with indexes such as 'method' or uri * @return mixed Result of request, either false on failure or the response to the request. */ - public function get($uri = null, $query = array(), $request = array()) { + public function &get($uri = null, $query = array(), $request = array()) { if (!empty($query)) { $uri = $this->_parseUri($uri); if (isset($uri['query'])) { @@ -386,7 +387,7 @@ class HttpSocket extends CakeSocket { * @param array $request An indexed array with indexes such as 'method' or uri * @return mixed Result of request, either false on failure or the response to the request. */ - public function post($uri = null, $data = array(), $request = array()) { + public function &post($uri = null, $data = array(), $request = array()) { $request = Set::merge(array('method' => 'POST', 'uri' => $uri, 'body' => $data), $request); return $this->request($request); } @@ -399,7 +400,7 @@ class HttpSocket extends CakeSocket { * @param array $request An indexed array with indexes such as 'method' or uri * @return mixed Result of request */ - public function put($uri = null, $data = array(), $request = array()) { + public function &put($uri = null, $data = array(), $request = array()) { $request = Set::merge(array('method' => 'PUT', 'uri' => $uri, 'body' => $data), $request); return $this->request($request); } @@ -412,7 +413,7 @@ class HttpSocket extends CakeSocket { * @param array $request An indexed array with indexes such as 'method' or uri * @return mixed Result of request */ - public function delete($uri = null, $data = array(), $request = array()) { + public function &delete($uri = null, $data = array(), $request = array()) { $request = Set::merge(array('method' => 'DELETE', 'uri' => $uri, 'body' => $data), $request); return $this->request($request); } diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 858a5df10..df4914ec3 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -621,6 +621,22 @@ class HttpSocketTest extends CakeTestCase { $this->assertFalse($this->Socket->connected); } +/** + * testRequestResultAsPointer method + * + * @return void + */ + public function testRequestResultAsPointer() { + $request = array('uri' => 'htpp://www.cakephp.org/'); + $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a cookie test!

"; + $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); + $this->Socket->connected = true; + $data =& $this->Socket->request($request); + $this->assertEqual($data, $this->Socket->response['body']); + $data = 'new data'; + $this->assertEqual($data, $this->Socket->response['body']); + } + /** * testProxy method * From 0ec1e6501331d47199a75dec492d05a9b7606619 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 5 Dec 2010 22:53:29 -0500 Subject: [PATCH 199/378] Removing collisions that prevent TestTask from being loaded. --- cake/tests/cases/console/shells/shell.test.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cake/tests/cases/console/shells/shell.test.php b/cake/tests/cases/console/shells/shell.test.php index ff341468b..91c623cda 100644 --- a/cake/tests/cases/console/shells/shell.test.php +++ b/cake/tests/cases/console/shells/shell.test.php @@ -25,12 +25,12 @@ App::import('Shell', 'Shell', false); require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; /** - * TestShell class + * ShellTestShell class * * @package cake * @subpackage cake.tests.cases.console.libs */ -class TestShell extends Shell { +class ShellTestShell extends Shell { /** * name property @@ -38,7 +38,7 @@ class TestShell extends Shell { * @var name * @access public */ - public $name = 'TestShell'; + public $name = 'ShellTestShell'; /** * stopped property @@ -133,7 +133,7 @@ class ShellTest extends CakeTestCase { $output = $this->getMock('ConsoleOutput', array(), array(), '', false); $error = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Shell = new TestShell($output, $error, $in); + $this->Shell = new ShellTestShell($output, $error, $in); } /** @@ -142,7 +142,7 @@ class ShellTest extends CakeTestCase { * @return void */ public function testConstruct() { - $this->assertEqual($this->Shell->name, 'TestShell'); + $this->assertEqual($this->Shell->name, 'ShellTestShell'); $this->assertType('ConsoleInput', $this->Shell->stdin); $this->assertType('ConsoleOutput', $this->Shell->stdout); $this->assertType('ConsoleOutput', $this->Shell->stderr); From c096eea664d0e4172fd5eb8828d3d8d14e5073ba Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 5 Dec 2010 23:32:34 -0500 Subject: [PATCH 200/378] Fixing failing tests caused by constants changing. --- cake/console/shells/tasks/fixture.php | 1 - cake/libs/model/cake_schema.php | 3 --- cake/tests/cases/console/shells/api.test.php | 2 +- cake/tests/cases/console/shells/tasks/project.test.php | 6 +++--- cake/tests/cases/console/shells/tasks/template.test.php | 2 +- cake/tests/cases/libs/controller/scaffold.test.php | 2 +- 6 files changed, 6 insertions(+), 10 deletions(-) diff --git a/cake/console/shells/tasks/fixture.php b/cake/console/shells/tasks/fixture.php index 88eb5241a..3bf60f3ae 100644 --- a/cake/console/shells/tasks/fixture.php +++ b/cake/console/shells/tasks/fixture.php @@ -211,7 +211,6 @@ class FixtureTask extends BakeTask { $this->_Schema = new CakeSchema(); $data = $this->_Schema->read(array('models' => false, 'connection' => $this->connection)); - if (!isset($data['tables'][$useTable])) { $this->err('Could not find your selected table ' . $useTable); return false; diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index 84f132083..fc4e32d28 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -295,9 +295,6 @@ class CakeSchema extends Object { $systemTables = array( 'aros', 'acos', 'aros_acos', Configure::read('Session.table'), 'i18n' ); - if (get_class($Object) === 'AppModel') { - continue; - } if (in_array($table, $systemTables)) { $tables[$Object->table] = $this->__columns($Object); $tables[$Object->table]['indexes'] = $db->index($Object); diff --git a/cake/tests/cases/console/shells/api.test.php b/cake/tests/cases/console/shells/api.test.php index 109cf57f7..82f134552 100644 --- a/cake/tests/cases/console/shells/api.test.php +++ b/cake/tests/cases/console/shells/api.test.php @@ -84,7 +84,7 @@ class ApiShellTest extends CakeTestCase { $this->Shell->expects($this->at(2))->method('out')->with($expected); $this->Shell->args = array('controller'); - $this->Shell->paths['controller'] = CAKE_CORE_INCLUDE_PATH . DS . LIBS . 'controller' . DS; + $this->Shell->paths['controller'] = LIBS . 'controller' . DS; $this->Shell->main(); } } diff --git a/cake/tests/cases/console/shells/tasks/project.test.php b/cake/tests/cases/console/shells/tasks/project.test.php index e9044d992..8e92b7949 100644 --- a/cake/tests/cases/console/shells/tasks/project.test.php +++ b/cake/tests/cases/console/shells/tasks/project.test.php @@ -70,7 +70,7 @@ class ProjectTaskTest extends CakeTestCase { * @return void */ protected function _setupTestProject() { - $skel = CAKE_CORE_INCLUDE_PATH . DS . CAKE . 'console' . DS . 'templates' . DS . 'skel'; + $skel = CAKE . 'console' . DS . 'templates' . DS . 'skel'; $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y')); $this->Task->bake($this->Task->path . 'bake_test_app', $skel); } @@ -256,7 +256,7 @@ class ProjectTaskTest extends CakeTestCase { * @return void */ public function testExecute() { - $this->Task->params['skel'] = CAKE_CORE_INCLUDE_PATH . DS . CAKE . DS . 'console' . DS. 'templates' . DS . 'skel'; + $this->Task->params['skel'] = CAKE . DS . 'console' . DS. 'templates' . DS . 'skel'; $this->Task->params['working'] = TMP . 'tests' . DS; $path = $this->Task->path . 'bake_test_app'; @@ -264,7 +264,7 @@ class ProjectTaskTest extends CakeTestCase { $this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y')); $this->Task->execute(); - $this->assertTrue(is_dir($path), 'No project dir %s'); + $this->assertTrue(is_dir($path), 'No project dir'); $this->assertTrue(is_dir($path . DS . 'controllers'), 'No controllers dir '); $this->assertTrue(is_dir($path . DS . 'controllers' . DS .'components'), 'No components dir '); $this->assertTrue(is_dir($path . DS . 'models'), 'No models dir'); diff --git a/cake/tests/cases/console/shells/tasks/template.test.php b/cake/tests/cases/console/shells/tasks/template.test.php index 9d970a092..bbd81404d 100644 --- a/cake/tests/cases/console/shells/tasks/template.test.php +++ b/cake/tests/cases/console/shells/tasks/template.test.php @@ -88,7 +88,7 @@ class TemplateTaskTest extends CakeTestCase { * @return void */ public function testFindingInstalledThemesForBake() { - $consoleLibs = CAKE_CORE_INCLUDE_PATH . DS . CAKE . 'console' . DS; + $consoleLibs = CAKE . 'console' . DS; $this->Task->initialize(); $this->assertEqual($this->Task->templatePaths, array('default' => $consoleLibs . 'templates' . DS . 'default' . DS)); } diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php index 415ac6ce2..2ebd3f5e3 100644 --- a/cake/tests/cases/libs/controller/scaffold.test.php +++ b/cake/tests/cases/libs/controller/scaffold.test.php @@ -347,7 +347,7 @@ class ScaffoldViewTest extends CakeTestCase { $this->assertEqual($result, $expected); $result = $ScaffoldView->testGetFilename('error'); - $expected = 'cake' . DS . 'libs' . DS . 'view' . DS . 'errors' . DS . 'scaffold_error.ctp'; + $expected = CAKE . 'libs' . DS . 'view' . DS . 'errors' . DS . 'scaffold_error.ctp'; $this->assertEqual($result, $expected); $Controller = new ScaffoldMockController($this->request); From 151ea2804f64531207e2452a07c80fd03758edb6 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 6 Dec 2010 03:23:09 -0200 Subject: [PATCH 201/378] Default value to raw key, avoiding warnings if line is false. --- cake/libs/http_socket.php | 1 + 1 file changed, 1 insertion(+) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index c467393c9..99bd71014 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -303,6 +303,7 @@ class HttpSocket extends CakeSocket { return $this->response = false; } + $this->request['raw'] = ''; if ($this->request['line'] !== false) { $this->request['raw'] = $this->request['line']; } From 33bb253dfa5c8d10a0774110ed72b8964b2e80b8 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 6 Dec 2010 03:56:16 -0200 Subject: [PATCH 202/378] Minor optimization in HttpSocket::reset(). --- cake/libs/http_socket.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 99bd71014..f88a16e67 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -1120,13 +1120,11 @@ class HttpSocket extends CakeSocket { if (empty($initalState)) { $initalState = get_class_vars(__CLASS__); } - if ($full == false) { + if (!$full) { $this->request = $initalState['request']; $this->response = $initalState['response']; return true; } - $this->_auth = array(); - $this->_proxy = array(); parent::reset($initalState); return true; } From 30a70b700bb0967c1f726bab809a6a2cf4834546 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 6 Dec 2010 04:02:23 -0200 Subject: [PATCH 203/378] HttpSocket::_configUri() always change config attribute and it is public. This function dont need return it. --- cake/libs/http_socket.php | 4 ++-- cake/tests/cases/libs/http_socket.test.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index f88a16e67..263dcb585 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -674,7 +674,7 @@ class HttpSocket extends CakeSocket { * Parses and sets the specified URI into current request configuration. * * @param mixed $uri URI, See HttpSocket::_parseUri() - * @return array Current configuration settings + * @return boolean If uri has merged in config */ protected function _configUri($uri = null) { if (empty($uri)) { @@ -697,7 +697,7 @@ class HttpSocket extends CakeSocket { ); $this->config = Set::merge($this->config, $config); $this->config = Set::merge($this->config, array_intersect_key($this->config['request']['uri'], $this->config)); - return $this->config; + return true; } /** diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index df4914ec3..d589f11a3 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -290,12 +290,12 @@ class HttpSocketTest extends CakeTestCase { ) ); $this->assertEquals($this->Socket->config, $expected); - $this->assertEquals($r, $expected); + $this->assertTrue($r); $r = $this->Socket->configUri(array('host' => 'www.foo-bar.org')); $expected['host'] = 'www.foo-bar.org'; $expected['request']['uri']['host'] = 'www.foo-bar.org'; $this->assertEquals($this->Socket->config, $expected); - $this->assertEquals($r, $expected); + $this->assertTrue($r); $r = $this->Socket->configUri('http://www.foo.com'); $expected = array( @@ -314,13 +314,13 @@ class HttpSocketTest extends CakeTestCase { ) ); $this->assertEquals($this->Socket->config, $expected); - $this->assertEquals($r, $expected); + $this->assertTrue($r); $r = $this->Socket->configUri('/this-is-broken'); $this->assertEquals($this->Socket->config, $expected); - $this->assertEquals($r, false); + $this->assertFalse($r); $r = $this->Socket->configUri(false); $this->assertEquals($this->Socket->config, $expected); - $this->assertEquals($r, false); + $this->assertFalse($r); } /** From d656bdae3b3c622f03a8eabab9dd8c09e194a71d Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 6 Dec 2010 11:28:40 -0200 Subject: [PATCH 204/378] Renamed proxy method and calling togheter from host config. --- cake/libs/http_socket.php | 4 ++-- cake/tests/cases/libs/http_socket.test.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 263dcb585..84742fddd 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -245,6 +245,7 @@ class HttpSocket extends CakeSocket { if (isset($host)) { $this->config['host'] = $host; } + $this->_setProxy(); $cookies = null; if (is_array($this->request['header'])) { @@ -275,7 +276,6 @@ class HttpSocket extends CakeSocket { $this->setAuthConfig('Basic', $this->request['uri']['user'], $this->request['uri']['pass']); } $this->_setAuth(); - $this->_setProxyConfig(); if (is_array($this->request['body'])) { $this->request['body'] = $this->_httpSerialize($this->request['body']); @@ -501,7 +501,7 @@ class HttpSocket extends CakeSocket { * @return void * @throws Exception */ - protected function _setProxyConfig() { + protected function _setProxy() { if (empty($this->_proxy) || !isset($this->_proxy['host'], $this->_proxy['port'])) { return; } diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index d589f11a3..156dc9816 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -662,7 +662,7 @@ class HttpSocketTest extends CakeTestCase { $this->assertEqual($this->Socket->config['port'], 123); $this->Socket->setAuthConfig('Test', 'login', 'passwd'); - $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nAuthorization: Test login.passwd\r\nProxy-Authorization: Test mark.secret\r\n\r\n"; + $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nProxy-Authorization: Test mark.secret\r\nAuthorization: Test login.passwd\r\n\r\n"; $this->Socket->request('http://www.cakephp.org/'); $this->assertEqual($this->Socket->request['raw'], $expected); } From 7c23d289e0945f0af53ef2e219ca5c4aa95c6aea Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 6 Dec 2010 12:03:22 -0200 Subject: [PATCH 205/378] Minor optimizations. --- cake/libs/http_socket.php | 2 +- cake/tests/cases/libs/http_socket.test.php | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 84742fddd..545762b75 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -321,7 +321,7 @@ class HttpSocket extends CakeSocket { $response .= $data; } - if ($connectionType == 'close') { + if ($connectionType === 'close') { $this->disconnect(); } diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 156dc9816..a7410231f 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -251,13 +251,12 @@ class HttpSocketTest extends CakeTestCase { $baseConfig['host'] = 'foo-bar'; $baseConfig['protocol'] = getprotobyname($baseConfig['protocol']); $this->assertEquals($this->Socket->config, $baseConfig); + $this->Socket->reset(); $baseConfig = $this->Socket->config; $this->Socket->__construct('http://www.cakephp.org:23/'); - $baseConfig['host'] = 'www.cakephp.org'; - $baseConfig['request']['uri']['host'] = 'www.cakephp.org'; - $baseConfig['port'] = 23; - $baseConfig['request']['uri']['port'] = 23; + $baseConfig['host'] = $baseConfig['request']['uri']['host'] = 'www.cakephp.org'; + $baseConfig['port'] = $baseConfig['request']['uri']['port'] = 23; $baseConfig['protocol'] = getprotobyname($baseConfig['protocol']); $this->assertEquals($this->Socket->config, $baseConfig); From bcacace061106e8c04b02c670992b1bf8c678d9a Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 6 Dec 2010 12:04:00 -0200 Subject: [PATCH 206/378] Updating docs. --- cake/libs/http_socket.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 545762b75..a128e96ad 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -41,7 +41,7 @@ class HttpSocket extends CakeSocket { public $quirksMode = false; /** - * The default values to use for a request + * Contain information about the last request (read only) * * @var array */ @@ -69,7 +69,7 @@ class HttpSocket extends CakeSocket { ); /** - * The default structure for storing the response + * Contain information about the last response (read only) * * @var array */ @@ -91,7 +91,7 @@ class HttpSocket extends CakeSocket { ); /** - * Default configuration settings for the HttpSocket + * Configuration settings for the HttpSocket and the requests * * @var array */ From 8681399fc29443281107a0788e65056f44e72598 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 6 Dec 2010 21:29:11 -0500 Subject: [PATCH 207/378] Forcing the plugin list to use a fresh directory listing in the web runner. Fixes #1338 --- cake/tests/lib/reporter/cake_html_reporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 7074b844a..b1ef7ac9f 100755 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -74,7 +74,7 @@ class CakeHtmlReporter extends CakeBaseReporter { function paintTestMenu() { $groups = $this->baseUrl() . '?show=groups'; $cases = $this->baseUrl() . '?show=cases'; - $plugins = App::objects('plugin'); + $plugins = App::objects('plugin', null, false); sort($plugins); include CAKE_TESTS_LIB . 'templates' . DS . 'menu.php'; } From 48f32a11e03b7af923aea601e17fb93f77df5cee Mon Sep 17 00:00:00 2001 From: jblotus Date: Wed, 8 Dec 2010 09:41:28 -0800 Subject: [PATCH 208/378] Fixed incorrect docblock. Fixes #1350 Signed-off-by: mark_story --- cake/libs/view/helpers/html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index 3dedaccbc..dee7cc309 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -806,7 +806,7 @@ class HtmlHelper extends AppHelper { /** * Internal function to build a nested list (UL/OL) out of an associative array. * - * @param array $list Set of elements to list + * @param array $items Set of elements to list * @param array $options Additional HTML attributes of the list (ol/ul) tag * @param array $itemOptions Additional HTML attributes of the list item (LI) tag * @param string $tag Type of list tag to use (ol/ul) From 33d2f9a6ed7adfee0aedd0fd20d9f31368ef1836 Mon Sep 17 00:00:00 2001 From: Graham Weldon Date: Fri, 10 Dec 2010 12:22:12 +1100 Subject: [PATCH 209/378] Refs #621. Provides default maxLimit for pagination to prevent url manipulation causing long queries. --- cake/libs/controller/controller.php | 8 ++-- .../cases/libs/controller/controller.test.php | 40 +++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 8a0585f4d..22b5fe881 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -112,7 +112,7 @@ class Controller extends Object { * @var array * @link http://book.cakephp.org/view/1231/Pagination */ - public $paginate = array('limit' => 20, 'page' => 1); + public $paginate = array('limit' => 20, 'page' => 1, 'maxLimit' => 100); /** * The name of the views subfolder containing views for this controller. @@ -1074,8 +1074,8 @@ class Controller extends Object { unset($defaults[0]); } - $options = array_merge(array('page' => 1, 'limit' => 20), $defaults, $options); - $options['limit'] = (int) $options['limit']; + $options = array_merge(array('page' => 1, 'limit' => 20, 'maxLimit' => 100), $defaults, $options); + $options['limit'] = min((int)$options['limit'], $options['maxLimit']); if (empty($options['limit']) || $options['limit'] < 1) { $options['limit'] = 1; } @@ -1114,7 +1114,7 @@ class Controller extends Object { } elseif (intval($page) < 1) { $options['page'] = $page = 1; } - $page = $options['page'] = (integer)$page; + $page = $options['page'] = (int)$page; if (method_exists($object, 'paginate')) { $results = $object->paginate( diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index e55ed54b6..ddc708aa2 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -750,6 +750,45 @@ class ControllerTest extends CakeTestCase { $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); } +/** + * testPaginateMaxLimit + * + * @return void + * @access public + */ + function testPaginateMaxLimit() { + $request = new CakeRequest('controller_posts/index'); + $request->params['pass'] = $request->params['named'] = array(); + + $Controller = new Controller($request); + + $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->passedArgs[] = '1'; + $Controller->params['url'] = array(); + $Controller->constructClasses(); + + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000'); + $result = $Controller->paginate('ControllerPost'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 100); + + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000', 'maxLimit' => 1000); + $result = $Controller->paginate('ControllerPost'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 100); + + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '10'); + $result = $Controller->paginate('ControllerPost'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 10); + + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000'); + $Controller->paginate = array('maxLimit' => 2000); + $result = $Controller->paginate('ControllerPost'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 1000); + + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '5000'); + $result = $Controller->paginate('ControllerPost'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 2000); + } + /** * testPaginateFieldsDouble method * @@ -820,6 +859,7 @@ class ControllerTest extends CakeTestCase { 'fields' => array(), 'order' => '', 'limit' => 5, + 'maxLimit' => 100, 'page' => 1, 'recursive' => -1, 'conditions' => array() From e9907cb9da9ff17b6a13dbdebd162b51153f230d Mon Sep 17 00:00:00 2001 From: Graham Weldon Date: Fri, 10 Dec 2010 12:53:45 +1100 Subject: [PATCH 210/378] Made debug() output html-safe strings by default. --- cake/basics.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cake/basics.php b/cake/basics.php index cba8c4eae..b80b1b645 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -85,12 +85,12 @@ * Only runs if debug level is greater than zero. * * @param boolean $var Variable to show debug information for. - * @param boolean $showHtml If set to true, the method prints the debug data in a screen-friendly way. + * @param boolean $showHtml If set to true, the method prints the debug data in a browser-friendly way. * @param boolean $showFrom If set to true, the method prints from where the function was called. * @link http://book.cakephp.org/view/1190/Basic-Debugging * @link http://book.cakephp.org/view/1128/debug */ - function debug($var = false, $showHtml = false, $showFrom = true) { + function debug($var = false, $showHtml = null, $showFrom = true) { if (Configure::read('debug') > 0) { $file = ''; $line = ''; @@ -116,10 +116,14 @@ TEXT; $template = $html; if (php_sapi_name() == 'cli') { $template = $text; + } else { + if ($showHtml === null) { + $showHtml = true; + } } $var = print_r($var, true); if ($showHtml) { - $var = str_replace('<', '<', str_replace('>', '>', $var)); + $var = str_replace(array('<', '>'), array('<', '>'), $var); } printf($template, $file, $line, $var); } From a8306320717feb75f870b0c68eeeb5e708dae64f Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 9 Dec 2010 22:06:23 -0500 Subject: [PATCH 211/378] Changing View::element() to not overwrite viewVars with helpers that have the same name. Test added. Fixes #1354 --- cake/libs/view/view.php | 9 +++++++-- cake/tests/cases/libs/view/view.test.php | 18 ++++++++++++++++++ .../test_app/views/elements/type_check.ctp | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 cake/tests/test_app/views/elements/type_check.ctp diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index ad7600b1f..fd1999e9a 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -381,8 +381,13 @@ class View extends Object { } if (is_file($file)) { - $params = array_merge_recursive($params, $this->loaded); - $element = $this->_render($file, array_merge($this->viewVars, $params), $loadHelpers); + $vars = array_merge($this->viewVars, $params); + foreach ($this->loaded as $name => $helper) { + if (!isset($vars[$name])) { + $vars[$name] =& $this->loaded[$name]; + } + } + $element = $this->_render($file, $vars, $loadHelpers); if (isset($params['cache']) && isset($cacheFile) && isset($expires)) { cache('views' . DS . $cacheFile, $element, $expires); } diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index 4905cad20..8ffb0837a 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -487,6 +487,24 @@ class ViewTest extends CakeTestCase { $this->assertPattern('/non_existant_element/', $result); } +/** + * test that additional element viewVars don't get overwritten with helpers. + * + * @return void + */ + function testElementParamsDontOverwriteHelpers() { + $Controller = new ViewPostsController(); + $Controller->helpers = array('Form'); + + $View = new View($Controller); + $result = $View->element('type_check', array('form' => 'string'), true); + $this->assertEqual('string', $result); + + $View->set('form', 'string'); + $result = $View->element('type_check', array(), true); + $this->assertEqual('string', $result); + } + /** * testElementCacheHelperNoCache method * diff --git a/cake/tests/test_app/views/elements/type_check.ctp b/cake/tests/test_app/views/elements/type_check.ctp new file mode 100644 index 000000000..a863c2b48 --- /dev/null +++ b/cake/tests/test_app/views/elements/type_check.ctp @@ -0,0 +1 @@ + \ No newline at end of file From d7e62b88bc889921040dc256987e51a2241fd373 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 9 Dec 2010 22:34:20 -0500 Subject: [PATCH 212/378] Adding test cases for using helpers in nested elements from email templates. Closes #1355 --- .../libs/controller/components/email.test.php | 34 ++++++++++++------- .../elements/email/html/nested_element.ctp | 3 ++ .../test_app/views/elements/html_call.ctp | 3 ++ 3 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 cake/tests/test_app/views/elements/email/html/nested_element.ctp create mode 100644 cake/tests/test_app/views/elements/html_call.ctp diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index 3a0472877..ed80c1b2b 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -629,22 +629,30 @@ HTMLBLOC; $expect = '
' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . '
'; $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'default', 'thin')); $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); + } - return; +/** + * test that elements used in email templates get helpers. + * + * @return void + */ + function testTemplateNestedElements() { + $this->Controller->EmailTest->to = 'postmaster@localhost'; + $this->Controller->EmailTest->from = 'noreply@example.com'; + $this->Controller->EmailTest->subject = 'Cake SMTP test'; + $this->Controller->EmailTest->replyTo = 'noreply@example.com'; - $text = <<Controller->EmailTest->delivery = 'debug'; + $this->Controller->EmailTest->messageId = false; + $this->Controller->EmailTest->layout = 'default'; + $this->Controller->EmailTest->template = 'nested_element'; + $this->Controller->EmailTest->sendAs = 'html'; + $this->Controller->helpers = array('Html'); -This element has some text that is just too wide to comply with email -standards. -This is the body of the message - -This email was sent using the CakePHP Framework, http://cakephp.org. -TEXTBLOC; - - $this->Controller->EmailTest->sendAs = 'text'; - $expect = '
' . str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $header) . $text . "\n" . '
'; - $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'wide', 'default')); - $this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect)); + $this->Controller->EmailTest->send(); + $result = $this->Controller->Session->read('Message.email.message'); + $this->assertPattern('/Test/', $result); + $this->assertPattern('/http\:\/\/example\.com/', $result); } /** diff --git a/cake/tests/test_app/views/elements/email/html/nested_element.ctp b/cake/tests/test_app/views/elements/email/html/nested_element.ctp new file mode 100644 index 000000000..49858200e --- /dev/null +++ b/cake/tests/test_app/views/elements/email/html/nested_element.ctp @@ -0,0 +1,3 @@ +Before the element. +element('html_call'); ?> +After the element. \ No newline at end of file diff --git a/cake/tests/test_app/views/elements/html_call.ctp b/cake/tests/test_app/views/elements/html_call.ctp new file mode 100644 index 000000000..8c2c08978 --- /dev/null +++ b/cake/tests/test_app/views/elements/html_call.ctp @@ -0,0 +1,3 @@ +Html->link('Test', 'http://example.com'); +?> \ No newline at end of file From 1548b7badbc27cc80fea2982092665655319b19f Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 6 Dec 2010 00:09:23 -0500 Subject: [PATCH 213/378] Expanding and correcting the doc block for ObjectCollection. --- cake/libs/object_collection.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cake/libs/object_collection.php b/cake/libs/object_collection.php index b2a6eb443..e9dd53abe 100644 --- a/cake/libs/object_collection.php +++ b/cake/libs/object_collection.php @@ -1,10 +1,5 @@ _loaded`. Enabled objects are stored in `$this->_enabled`. In addition + * the all support an `enabled` option that controls the enabled/disabled state of the object + * when loaded. + * + * @package cake.libs + * @since CakePHP(tm) v 2.0 + */ abstract class ObjectCollection { /** From 0deaa6eee0e263e606a399c2e80ad0f9da27a84e Mon Sep 17 00:00:00 2001 From: Graham Weldon Date: Fri, 10 Dec 2010 15:39:50 +1100 Subject: [PATCH 214/378] Update basics test for debug() changes. --- cake/tests/cases/basics.test.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php index f6051717b..323429f8d 100644 --- a/cake/tests/cases/basics.test.php +++ b/cake/tests/cases/basics.test.php @@ -686,12 +686,20 @@ class BasicsTest extends CakeTestCase { $this->assertPattern($pattern, $result); ob_start(); - debug('
this-is-a-test
', true); + debug('
this-is-a-test
'); $result = ob_get_clean(); $pattern = '/(.+?tests(\/|\\\)cases(\/|\\\)basics\.test\.php|'; $pattern .= preg_quote(substr(__FILE__, 1), '/') . ')'; $pattern .= '.*line.*' . (__LINE__ - 4) . '.*<div>this-is-a-test<\/div>.*/s'; $this->assertPattern($pattern, $result); + + ob_start(); + debug('
this-is-a-test
', false); + $result = ob_get_clean(); + $pattern = '/(.+?tests(\/|\\\)cases(\/|\\\)basics\.test\.php|'; + $pattern .= preg_quote(substr(__FILE__, 1), '/') . ')'; + $pattern .= '.*line.*' . (__LINE__ - 4) . '.*\this-is-a-test\<\/div\>.*/s'; + $this->assertPattern($pattern, $result); } /** From d97103d7391502a65b8050b6163aee823aaadda1 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 10 Dec 2010 02:42:38 -0200 Subject: [PATCH 215/378] Making the format attribute customizable in helpers. --- cake/libs/view/helper.php | 40 +++++++++++++++++----- cake/tests/cases/libs/view/helper.test.php | 39 ++++++++++++++++++++- 2 files changed, 69 insertions(+), 10 deletions(-) diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index 59470ea9f..6397cf722 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -107,6 +107,30 @@ class Helper extends Object { */ protected $_View; +/** + * Minimized attributes + * + * @var array + */ + protected $_minimizedAttributes = array( + 'compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', + 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize' + ); + +/** + * Format to attribute + * + * @var string + */ + protected $_attributeFormat = '%s="%s"'; + +/** + * Format to attribute + * + * @var string + */ + protected $_minimizedAttributeFormat = '%s="%s"'; + /** * Default Constructor * @@ -361,7 +385,7 @@ class Helper extends Object { foreach ($filtered as $key => $value) { if ($value !== false && $value !== null) { - $attributes[] = $this->__formatAttribute($key, $value, $escape); + $attributes[] = $this->_formatAttribute($key, $value, $escape); } } $out = implode(' ', $attributes); @@ -378,23 +402,21 @@ class Helper extends Object { * @param string $key The name of the attribute to create * @param string $value The value of the attribute to create. * @return string The composed attribute. - * @access private */ - function __formatAttribute($key, $value, $escape = true) { + protected function _formatAttribute($key, $value, $escape = true) { $attribute = ''; - $attributeFormat = '%s="%s"'; - $minimizedAttributes = array('compact', 'checked', 'declare', 'readonly', 'disabled', - 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize'); if (is_array($value)) { $value = ''; } - if (in_array($key, $minimizedAttributes)) { + if (is_numeric($key)) { + $attribute = sprintf($this->_minimizedAttributeFormat, $value, $value); + } elseif (in_array($key, $this->_minimizedAttributes)) { if ($value === 1 || $value === true || $value === 'true' || $value === '1' || $value == $key) { - $attribute = sprintf($attributeFormat, $key, $key); + $attribute = sprintf($this->_minimizedAttributeFormat, $key, $key); } } else { - $attribute = sprintf($attributeFormat, $key, ($escape ? h($value) : $value)); + $attribute = sprintf($this->_attributeFormat, $key, ($escape ? h($value) : $value)); } return $attribute; } diff --git a/cake/tests/cases/libs/view/helper.test.php b/cake/tests/cases/libs/view/helper.test.php index b30c2a767..ba401fe6e 100644 --- a/cake/tests/cases/libs/view/helper.test.php +++ b/cake/tests/cases/libs/view/helper.test.php @@ -184,11 +184,41 @@ class TestHelper extends Helper { } } +/** + * Html5TestHelper class + * + * @package cake + * @subpackage cake.tests.cases.libs.view + */ +class Html5TestHelper extends TestHelper { + +/** + * Minimized + * + * @var array + */ + protected $_minimizedAttributes = array('require', 'checked'); + +/** + * Allow compact use in HTML + * + * @var string + */ + protected $_minimizedAttributeFormat = '%s'; + +/** + * Test to attribute format + * + * @var string + */ + protected $_attributeFormat = 'data-%s="%s"'; +} + /** * HelperTest class * * @package cake - * @subpackage cake.tests.cases.libs + * @subpackage cake.tests.cases.libs.view */ class HelperTest extends CakeTestCase { @@ -809,6 +839,13 @@ class HelperTest extends CakeTestCase { $this->assertEqual($helper->parseAttributes($attrs), $expected, '%s Failed on ' . $value); } } + $this->assertEqual($helper->parseAttributes(array('compact')), ' compact="compact"'); + + $helper = new Html5TestHelper($this->View); + $expected = ' require'; + $this->assertEqual($helper->parseAttributes(array('require')), $expected); + $this->assertEqual($helper->parseAttributes(array('require' => true)), $expected); + $this->assertEqual($helper->parseAttributes(array('require' => false)), ''); } /** From 453c5364c28dc86841582912a72a50608f68f12c Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 10 Dec 2010 10:38:49 -0200 Subject: [PATCH 216/378] Putting the auth and proxy data in request attribute after request. --- cake/libs/http_socket.php | 3 ++ cake/tests/cases/libs/http_socket.test.php | 55 ++++++++++++++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index a128e96ad..53e010874 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -246,6 +246,8 @@ class HttpSocket extends CakeSocket { $this->config['host'] = $host; } $this->_setProxy(); + $this->request['proxy'] = $this->_proxy; + $cookies = null; if (is_array($this->request['header'])) { @@ -276,6 +278,7 @@ class HttpSocket extends CakeSocket { $this->setAuthConfig('Basic', $this->request['uri']['user'], $this->request['uri']['pass']); } $this->_setAuth(); + $this->request['auth'] = $this->_auth; if (is_array($this->request['body'])) { $this->request['body'] = $this->_httpSerialize($this->request['body']); diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index a7410231f..aac957c0d 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -349,7 +349,7 @@ class HttpSocketTest extends CakeTestCase { 'host' => 'www.cakephp.org', 'port' => 80 ), - 'cookies' => array() + 'cookies' => array(), ) ), 'request' => array( @@ -369,7 +369,9 @@ class HttpSocketTest extends CakeTestCase { 'line' => "GET /?foo=bar HTTP/1.1\r\n", 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n", 'raw' => "", - 'cookies' => array() + 'cookies' => array(), + 'proxy' => array(), + 'auth' => array() ) ) ), @@ -621,11 +623,11 @@ class HttpSocketTest extends CakeTestCase { } /** - * testRequestResultAsPointer method + * testRequestResultAsReference method * * @return void */ - public function testRequestResultAsPointer() { + public function testRequestResultAsReference() { $request = array('uri' => 'htpp://www.cakephp.org/'); $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a cookie test!

"; $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); @@ -652,6 +654,28 @@ class HttpSocketTest extends CakeTestCase { $this->assertEqual($this->Socket->request['raw'], $expected); $this->assertEqual($this->Socket->config['host'], 'proxy.server'); $this->assertEqual($this->Socket->config['port'], 123); + $expected = array( + 'host' => 'proxy.server', + 'port' => 123, + 'method' => null, + 'user' => null, + 'pass' => null + ); + $this->assertEqual($this->Socket->request['proxy'], $expected); + + $expected = "GET http://www.cakephp.org/bakery HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n\r\n"; + $this->Socket->request('/bakery'); + $this->assertEqual($this->Socket->request['raw'], $expected); + $this->assertEqual($this->Socket->config['host'], 'proxy.server'); + $this->assertEqual($this->Socket->config['port'], 123); + $expected = array( + 'host' => 'proxy.server', + 'port' => 123, + 'method' => null, + 'user' => null, + 'pass' => null + ); + $this->assertEqual($this->Socket->request['proxy'], $expected); $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nProxy-Authorization: Test mark.secret\r\n\r\n"; $this->Socket->setProxyConfig('proxy.server', 123, 'Test', 'mark', 'secret'); @@ -659,11 +683,34 @@ class HttpSocketTest extends CakeTestCase { $this->assertEqual($this->Socket->request['raw'], $expected); $this->assertEqual($this->Socket->config['host'], 'proxy.server'); $this->assertEqual($this->Socket->config['port'], 123); + $expected = array( + 'host' => 'proxy.server', + 'port' => 123, + 'method' => 'Test', + 'user' => 'mark', + 'pass' => 'secret' + ); + $this->assertEqual($this->Socket->request['proxy'], $expected); $this->Socket->setAuthConfig('Test', 'login', 'passwd'); $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nProxy-Authorization: Test mark.secret\r\nAuthorization: Test login.passwd\r\n\r\n"; $this->Socket->request('http://www.cakephp.org/'); $this->assertEqual($this->Socket->request['raw'], $expected); + $expected = array( + 'host' => 'proxy.server', + 'port' => 123, + 'method' => 'Test', + 'user' => 'mark', + 'pass' => 'secret' + ); + $this->assertEqual($this->Socket->request['proxy'], $expected); + $expected = array( + 'Test' => array( + 'user' => 'login', + 'pass' => 'passwd' + ) + ); + $this->assertEqual($this->Socket->request['auth'], $expected); } /** From 1e108748e923b6daa5698fe98836c7483552e96b Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 10 Dec 2010 22:51:42 -0500 Subject: [PATCH 217/378] Fixing validation methods + features lost in [f51ce734] due to a bad merge. Fixing additional tests to reflect changes in 2.0 --- cake/libs/cake_session.php | 2 +- cake/libs/controller/scaffold.php | 4 ++-- cake/libs/validation.php | 16 ++++++++++++++-- .../libs/controller/components/cookie.test.php | 4 ++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php index 34c293fe7..f90b27b3d 100644 --- a/cake/libs/cake_session.php +++ b/cake/libs/cake_session.php @@ -455,7 +455,7 @@ class CakeSession { } foreach ($write as $key => $val) { if (in_array($key, self::$watchKeys)) { - trigger_error(__('Writing session key {%s}: %s', $key, Debugger::exportVar($val)), E_USER_NOTICE); + trigger_error(__('Writing session key {%s}: %s', $key, var_export($val, true)), E_USER_NOTICE); } self::__overwrite($_SESSION, Set::insert($_SESSION, $key, $val)); if (Set::classicExtract($_SESSION, $key) !== $val) { diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index 492ddeba9..34eb22c6d 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -260,7 +260,7 @@ class Scaffold { if ($this->ScaffoldModel->save($request->data)) { if ($this->controller->_afterScaffoldSave($action)) { $message = sprintf( - __('The %1$s has been %2$s', true), + __('The %1$s has been %2$s'), Inflector::humanize($this->modelKey), $success ); @@ -328,7 +328,7 @@ class Scaffold { $message = sprintf( __('There was an error deleting the %1$s with id: %2$d', true), Inflector::humanize($this->modelClass), $id - )); + ); return $this->_sendMessage($message); } } elseif ($this->controller->_scaffoldError('delete') === false) { diff --git a/cake/libs/validation.php b/cake/libs/validation.php index 15f4af042..5af6db748 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -670,10 +670,10 @@ class Validation { self::__populateIp(); $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))'; $regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') . - '(?:' . self::$__pattern['IPv4'] . '|' . self::$__pattern['hostname'] . ')(?::[1-9][0-9]{0,3})?' . + '(?:' . self::$__pattern['IPv4'] . '|\[' . self::$__pattern['IPv6'] . '\]|' . self::$__pattern['hostname'] . ')(?::[1-9][0-9]{0,4})?' . '(?:\/?|\/' . $validChars . '*)?' . '(?:\?' . $validChars . '*)?' . - '(?:#' . $validChars . '*)?$/i'; + '(?:#' . $validChars . '*)?$/iu'; return self::_check($check, $regex); } @@ -701,6 +701,18 @@ class Validation { return call_user_func_array(array($object, $method), array($check, $args)); } +/** + * Checks that a value is a valid uuid - http://tools.ietf.org/html/rfc4122 + * + * @param string $check Value to check + * @return boolean Success + * @access public + */ + public static function uuid($check) { + $regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i'; + return self::_check($check, $regex); + } + /** * Attempts to pass unhandled Validation locales to a class starting with $classPrefix * and ending with Validation. For example $classPrefix = 'nl', the class would be diff --git a/cake/tests/cases/libs/controller/components/cookie.test.php b/cake/tests/cases/libs/controller/components/cookie.test.php index c223034ff..84a852c6d 100644 --- a/cake/tests/cases/libs/controller/components/cookie.test.php +++ b/cake/tests/cases/libs/controller/components/cookie.test.php @@ -465,10 +465,10 @@ class CookieComponentTest extends CakeTestCase { * @return void */ function testNoErrorOnNonArrayData() { - $this->Controller->Cookie->destroy(); + $this->Cookie->destroy(); $_COOKIE['CakeTestCookie'] = 'kaboom'; - $this->assertNull($this->Controller->Cookie->read('value')); + $this->assertNull($this->Cookie->read('value')); } /** From ceca1791846a4925a503ee6b6093560b936c5633 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 10 Dec 2010 23:17:42 -0500 Subject: [PATCH 218/378] Fixing more tests that were failing post merge. --- cake/libs/controller/controller.php | 17 ++++++++++++----- .../cases/libs/controller/controller.test.php | 7 ++++--- .../cases/libs/view/helpers/number.test.php | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 22b5fe881..7bc58f024 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -440,17 +440,24 @@ class Controller extends Object { $this->uses = array_flip($this->uses); array_unshift($this->uses, $plugin . $this->modelClass); } - } elseif ($this->uses !== null || $this->uses !== false) { - $this->_mergeVars(array('uses'), 'AppController', false); + } elseif ( + ($this->uses !== null || $this->uses !== false) && + is_array($this->uses) && !empty($appVars['uses']) + ) { + $this->uses = array_merge($this->uses, array_diff($appVars['uses'], $this->uses)); + var_dump($this->uses); } $this->_mergeVars($merge, 'AppController', true); } if ($pluginController && $pluginName != null) { $merge = array('components', 'helpers'); - - if ($this->uses !== null || $this->uses !== false) { - $this->_mergeVars(array('uses'), $pluginController, false); + $appVars = get_class_vars($pluginController); + if ( + ($this->uses !== null || $this->uses !== false) && + is_array($this->uses) && !empty($appVars['uses']) + ) { + $this->uses = array_merge($this->uses, array_diff($appVars['uses'], $this->uses)); } $this->_mergeVars($merge, $pluginController); } diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index a1d06b779..089955373 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -1283,13 +1283,14 @@ class ControllerTest extends CakeTestCase { ? array_merge($appVars['uses'], $testVars['uses']) : $testVars['uses']; - $this->assertEqual(count(array_diff($TestController->helpers, $helpers)), 0); + $this->assertEqual(count(array_diff_key($TestController->helpers, array_flip($helpers))), 0); $this->assertEqual(count(array_diff($TestController->uses, $uses)), 0); $this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0); - $TestController = new AnotherTestController($request); $expected = array('ControllerComment', 'ControllerAlias', 'ControllerPost'); - $this->assertEqual($expected, $TestController->uses, '$uses was merged incorrectly, AppController models should be last.'); + $this->assertEquals($expected, $TestController->uses, '$uses was merged incorrectly, AppController models should be last.'); + + $TestController = new AnotherTestController($request); $TestController->constructClasses(); $appVars = get_class_vars('AppController'); diff --git a/cake/tests/cases/libs/view/helpers/number.test.php b/cake/tests/cases/libs/view/helpers/number.test.php index d34eb65c0..30022d2cd 100644 --- a/cake/tests/cases/libs/view/helpers/number.test.php +++ b/cake/tests/cases/libs/view/helpers/number.test.php @@ -18,6 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Helper', 'Number'); +App::import('View', 'View'); /** * NumberHelperTest class From 9bfd170443c249a10b31b8a6cac972d6ef9b1b9a Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 10 Dec 2010 23:35:22 -0500 Subject: [PATCH 219/378] Making behaviour of debug() consistent between cli and web. --- cake/basics.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cake/basics.php b/cake/basics.php index b80b1b645..b88e14a9e 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -116,10 +116,9 @@ TEXT; $template = $html; if (php_sapi_name() == 'cli') { $template = $text; - } else { - if ($showHtml === null) { - $showHtml = true; - } + } + if ($showHtml === null) { + $showHtml = true; } $var = print_r($var, true); if ($showHtml) { From eeafb55d314f3a03508d7067b8d3c46bd3a7ea40 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 10 Dec 2010 12:08:49 -0200 Subject: [PATCH 220/378] Support to download requests. --- cake/libs/http_socket.php | 46 +++++++++++++++++++++- cake/tests/cases/libs/http_socket.test.php | 28 +++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 53e010874..0ecc1a60b 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -132,6 +132,13 @@ class HttpSocket extends CakeSocket { */ protected $_proxy = array(); +/** + * Resource to receive the content of request + * + * @var mixed + */ + protected $_contentResource = null; + /** * Build an HTTP Socket using the specified configuration. * @@ -208,6 +215,24 @@ class HttpSocket extends CakeSocket { $this->_proxy = compact('host', 'port', 'method', 'user', 'pass'); } +/** + * Set the resource to receive the request content. This resource must support fwrite. + * + * @param mixed $resource Resource or false to disable the resource use + * @return void + * @throw Exception + */ + public function setContentResource($resource) { + if ($resource === false) { + $this->_contentResource = null; + return; + } + if (!is_resource($resource)) { + throw new Exception(__('Invalid resource.')); + } + $this->_contentResource = $resource; + } + /** * Issue the specified request. HttpSocket::get() and HttpSocket::post() wrap this * method and provide a more granular interface. @@ -320,8 +345,27 @@ class HttpSocket extends CakeSocket { $this->write($this->request['raw']); $response = null; + $inHeader = true; while ($data = $this->read()) { - $response .= $data; + if ($this->_contentResource) { + if ($inHeader) { + $response .= $data; + $pos = strpos($response, "\r\n\r\n"); + if ($pos !== false) { + $pos += 4; + $data = substr($response, $pos); + fwrite($this->_contentResource, $data); + + $response = substr($response, 0, $pos); + $inHeader = false; + } + } else { + fwrite($this->_contentResource, $data); + fflush($this->_contentResource); + } + } else { + $response .= $data; + } } if ($connectionType === 'close') { diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index aac957c0d..32be35f7b 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -638,6 +638,34 @@ class HttpSocketTest extends CakeTestCase { $this->assertEqual($data, $this->Socket->response['body']); } +/** + * testRequestWithResource + * + * @return void + */ + public function testRequestWithResource() { + $serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a test!

"; + $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); + $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); + $this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse)); + $this->Socket->connected = true; + + $f = fopen(TMP . 'download.txt', 'w'); + $this->skipUnless($f, 'Can not write in TMP directory.'); + + $this->Socket->setContentResource($f); + $result = $this->Socket->request('http://www.cakephp.org/'); + $this->assertEqual($result, ''); + $this->assertEqual($this->Socket->response['header']['Server'], 'CakeHttp Server'); + fclose($f); + $this->assertEqual(file_get_contents(TMP . 'download.txt'), '

This is a test!

'); + unlink(TMP . 'download.txt'); + + $this->Socket->setContentResource(false); + $result = $this->Socket->request('http://www.cakephp.org/'); + $this->assertEqual($result, '

This is a test!

'); + } + /** * testProxy method * From 504b4d495f72cd34f581813029775c2488350ddf Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 11 Dec 2010 12:47:16 -0500 Subject: [PATCH 221/378] Adding stack traces to logged exceptions, as I forgot them last time around. --- cake/libs/error/error_handler.php | 7 ++++++- cake/tests/cases/libs/error/error_handler.test.php | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cake/libs/error/error_handler.php b/cake/libs/error/error_handler.php index 85cea7ec4..b25582fac 100644 --- a/cake/libs/error/error_handler.php +++ b/cake/libs/error/error_handler.php @@ -110,7 +110,12 @@ class ErrorHandler { if (!class_exists('CakeLog')) { require LIBS . 'cake_log.php'; } - CakeLog::write(LOG_ERR, '[' . get_class($exception) . '] ' . $exception->getMessage()); + $message = sprintf("[%s] %s\n%s", + get_class($exception), + $exception->getMessage(), + $exception->getTraceAsString() + ); + CakeLog::write(LOG_ERR, $message); } if ($config['renderer'] !== 'ExceptionRenderer') { App::import('Lib', $config['renderer']); diff --git a/cake/tests/cases/libs/error/error_handler.test.php b/cake/tests/cases/libs/error/error_handler.test.php index 736524251..c6f33d600 100644 --- a/cake/tests/cases/libs/error/error_handler.test.php +++ b/cake/tests/cases/libs/error/error_handler.test.php @@ -220,6 +220,7 @@ class ErrorHandlerTest extends CakeTestCase { $log = file(LOGS . 'error.log'); $this->assertPattern('/\[NotFoundException\] Kaboom!/', $log[0], 'message missing.'); + $this->assertPattern('/\#0.*ErrorHandlerTest->testHandleExceptionLog/', $log[1], 'Stack trace missing.'); } } From 60ada4432a1a52839f2f6a4cafdb0d6594a410e0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 11 Dec 2010 13:30:29 -0500 Subject: [PATCH 222/378] Making unknown errors with codes higher than 500 render as error500. Test added. --- cake/libs/error/exception_renderer.php | 2 +- .../libs/error/exception_renderer.test.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cake/libs/error/exception_renderer.php b/cake/libs/error/exception_renderer.php index 0d6c71b83..6666f4414 100644 --- a/cake/libs/error/exception_renderer.php +++ b/cake/libs/error/exception_renderer.php @@ -107,7 +107,7 @@ class ExceptionRenderer { } } elseif (!$methodExists) { $method = 'error500'; - if ($code >= 400) { + if ($code >= 400 && $code < 500) { $method = 'error400'; } } diff --git a/cake/tests/cases/libs/error/exception_renderer.test.php b/cake/tests/cases/libs/error/exception_renderer.test.php index c99c6b118..91efdf608 100644 --- a/cake/tests/cases/libs/error/exception_renderer.test.php +++ b/cake/tests/cases/libs/error/exception_renderer.test.php @@ -322,6 +322,24 @@ class ExceptionRendererTest extends CakeTestCase { $this->assertEquals('error500', $ExceptionRenderer->method, 'incorrect method coercion.'); } +/** + * test that unknown exception types with valid status codes are treated correctly. + * + * @return void + */ + function testUnknownExceptionTypeWithCodeHigherThan500() { + $exception = new OutOfBoundsException('foul ball.', 501); + $ExceptionRenderer = new ExceptionRenderer($exception); + $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); + $ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(501); + + ob_start(); + $ExceptionRenderer->render(); + $results = ob_get_clean(); + + $this->assertEquals('error500', $ExceptionRenderer->method, 'incorrect method coercion.'); + } + /** * testerror400 method * From 6c0efb62e729ea5e8658c1561f630a1b5fff37f4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 11 Dec 2010 13:38:09 -0500 Subject: [PATCH 223/378] Adding a base HttpException for all the various HttpExceptions that cake provides, this should make it easier to write concise catch blocks. --- cake/libs/error/exceptions.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/cake/libs/error/exceptions.php b/cake/libs/error/exceptions.php index 473b2dbee..961b39c7d 100644 --- a/cake/libs/error/exceptions.php +++ b/cake/libs/error/exceptions.php @@ -19,12 +19,21 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +/** + * Parent class for all of the HTTP related exceptions in CakePHP. + * All HTTP status/error related exceptions should extend this class so + * catch blocks can be specifically typed. + * + * @package cake.libs + */ +class HttpException extends RuntimeException { } + /** * Represents an HTTP 400 error. * * @package cake.libs */ -class BadRequestException extends RuntimeException { +class BadRequestException extends HttpException { /** * Constructor * @@ -44,7 +53,7 @@ class BadRequestException extends RuntimeException { * * @package cake.libs */ -class UnauthorizedException extends RuntimeException { +class UnauthorizedException extends HttpException { /** * Constructor * @@ -64,7 +73,7 @@ class UnauthorizedException extends RuntimeException { * * @package cake.libs */ -class ForbiddenException extends RuntimeException { +class ForbiddenException extends HttpException { /** * Constructor * @@ -84,7 +93,7 @@ class ForbiddenException extends RuntimeException { * * @package cake.libs */ -class NotFoundException extends RuntimeException { +class NotFoundException extends HttpException { /** * Constructor * @@ -104,7 +113,7 @@ class NotFoundException extends RuntimeException { * * @package cake.libs */ -class MethodNotAllowedException extends RuntimeException { +class MethodNotAllowedException extends HttpException { /** * Constructor * @@ -124,7 +133,7 @@ class MethodNotAllowedException extends RuntimeException { * * @package cake.libs */ -class InternalErrorException extends CakeException { +class InternalErrorException extends HttpException { /** * Constructor * From d332f0624fbe91afe5524b55d4fa0826b239d710 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 11 Dec 2010 16:49:19 -0200 Subject: [PATCH 224/378] Making the cookies independent for each host. --- cake/libs/http_socket.php | 19 ++++++++-- cake/tests/cases/libs/http_socket.test.php | 41 +++++++++++++++++++++- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 0ecc1a60b..0af827f44 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -263,10 +263,21 @@ class HttpSocket extends CakeSocket { } $request['uri'] = $this->url($request['uri']); $request['uri'] = $this->_parseUri($request['uri'], true); - $this->request = Set::merge($this->request, $this->config['request'], $request); + $this->request = Set::merge($this->request, array_diff_key($this->config['request'], array('cookies' => true)), $request); $this->_configUri($this->request['uri']); + $Host = $this->request['uri']['host']; + if (!empty($this->config['request']['cookies'][$Host])) { + if (!isset($this->request['cookies'])) { + $this->request['cookies'] = array(); + } + if (!isset($request['cookies'])) { + $request['cookies'] = array(); + } + $this->request['cookies'] = array_merge($this->request['cookies'], $this->config['request']['cookies'][$Host], $request['cookies']); + } + if (isset($host)) { $this->config['host'] = $host; } @@ -280,7 +291,6 @@ class HttpSocket extends CakeSocket { if (!empty($this->request['cookies'])) { $cookies = $this->buildCookies($this->request['cookies']); } - $Host = $this->request['uri']['host']; $schema = ''; $port = 0; if (isset($this->request['uri']['schema'])) { @@ -374,7 +384,10 @@ class HttpSocket extends CakeSocket { $this->response = $this->_parseResponse($response); if (!empty($this->response['cookies'])) { - $this->config['request']['cookies'] = array_merge($this->config['request']['cookies'], $this->response['cookies']); + if (!isset($this->config['request']['cookies'][$Host])) { + $this->config['request']['cookies'][$Host] = array(); + } + $this->config['request']['cookies'][$Host] = array_merge($this->config['request']['cookies'][$Host], $this->response['cookies']); } return $this->response['body']; diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 32be35f7b..895b62e08 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -618,7 +618,7 @@ class HttpSocketTest extends CakeTestCase { ) ); $this->assertEqual($result, $expect); - $this->assertEqual($this->Socket->config['request']['cookies'], $expect); + $this->assertEqual($this->Socket->config['request']['cookies']['www.cakephp.org'], $expect); $this->assertFalse($this->Socket->connected); } @@ -666,6 +666,45 @@ class HttpSocketTest extends CakeTestCase { $this->assertEqual($result, '

This is a test!

'); } +/** + * testRequestWithCrossCookie + * + * @return void + */ + public function testRequestWithCrossCookie() { + $this->Socket->connected = true; + $this->Socket->config['request']['cookies'] = array(); + + $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a test!

"; + $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); + $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); + $expected = array('www.cakephp.org' => array('foo' => array('value' => 'bar'))); + $this->Socket->request('http://www.cakephp.org/'); + $this->assertEqual($this->Socket->config['request']['cookies'], $expected); + + $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: bar=foo\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a test!

"; + $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); + $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); + $this->Socket->request('http://www.cakephp.org/other'); + $this->assertEqual($this->Socket->request['cookies'], array('foo' => array('value' => 'bar'))); + $expected['www.cakephp.org'] += array('bar' => array('value' => 'foo')); + $this->assertEqual($this->Socket->config['request']['cookies'], $expected); + + $serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a test!

"; + $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); + $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); + $this->Socket->request('/other2'); + $this->assertEqual($this->Socket->config['request']['cookies'], $expected); + + $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foobar=ok\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a test!

"; + $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); + $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); + $this->Socket->request('http://www.cake.com'); + $this->assertTrue(empty($this->Socket->request['cookies'])); + $expected['www.cake.com'] = array('foobar' => array('value' => 'ok')); + $this->assertEqual($this->Socket->config['request']['cookies'], $expected); + } + /** * testProxy method * From b3f55bfd29de80d2cee560db0bdc7466e7a4734d Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sat, 11 Dec 2010 13:23:23 -0800 Subject: [PATCH 225/378] Added shorter timeout to fsockopen checks --- .../libs/controller/components/email.test.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index f8fd2e4a5..1dafc9b42 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -268,7 +268,7 @@ class EmailComponentTest extends CakeTestCase { * @return void */ function testSmtpConfig() { - if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { + if ($this->skipIf(!@fsockopen('localhost', 25, $err, $errstr, .01), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->delivery = 'smtp'; @@ -295,7 +295,7 @@ class EmailComponentTest extends CakeTestCase { * @return void */ function testBadSmtpSend() { - if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { + if ($this->skipIf(!@fsockopen('localhost', 25, $err, $errstr, .01), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->smtpOptions['host'] = 'blah'; @@ -310,7 +310,7 @@ class EmailComponentTest extends CakeTestCase { * @return void */ function testSmtpSend() { - if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { + if ($this->skipIf(!@fsockopen('localhost', 25, $err, $errstr, .01), '%s No SMTP server running on localhost')) { return; } @@ -359,7 +359,7 @@ TEMPDOC; * @return void */ function testSmtpEhlo() { - if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { + if ($this->skipIf(!@fsockopen('localhost', 25, $err, $errstr, .01), '%s No SMTP server running on localhost')) { return; } @@ -416,7 +416,7 @@ TEMPDOC; * @return void */ function testSmtpSendMultipleTo() { - if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { + if ($this->skipIf(!@fsockopen('localhost', 25, $err, $errstr, .01), '%s No SMTP server running on localhost')) { return; } $this->Controller->EmailTest->reset(); @@ -465,7 +465,7 @@ TEMPDOC; * @return void */ function testAuthenticatedSmtpSend() { - if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { + if ($this->skipIf(!@fsockopen('localhost', 25, $err, $errstr, .01), '%s No SMTP server running on localhost')) { return; } @@ -658,7 +658,7 @@ TEXTBLOC; * @return void */ function testSmtpSendSocket() { - if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { + if ($this->skipIf(!@fsockopen('localhost', 25, $err, $errstr, .01), '%s No SMTP server running on localhost')) { return; } From 7ed19eae88043e72c737144b077d3a8e1dcc50fc Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sat, 11 Dec 2010 15:11:54 -0800 Subject: [PATCH 226/378] Allowed comma-delimited list in smtp $to var to be consistent with standard mail delivery. Fixes #1353 --- cake/libs/controller/components/email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index a4cb6dd02..76fbee04e 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -861,7 +861,7 @@ class EmailComponent extends Component { } if (!is_array($this->to)) { - $tos = array($this->to); + $tos = array_map('trim', explode(',', $this->to)); } else { $tos = $this->to; } From 44c080d5ad0ef977d187b7887ccc748a836b7af5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 11 Dec 2010 19:01:07 -0500 Subject: [PATCH 227/378] Making all core classes throw CakeException subclasses, this allows developers to catch framework exceptions with one catch. Adding package specific exceptions. Replacing generic exceptions in the codebase with CakeException + package exceptions. --- cake/console/libs/console_input_argument.php | 2 +- cake/console/libs/console_input_option.php | 2 +- cake/console/libs/console_option_parser.php | 6 +- cake/console/shell_dispatcher.php | 4 +- cake/libs/cache.php | 8 +-- cake/libs/cache/file.php | 8 +-- cake/libs/cache/memcache.php | 8 +-- cake/libs/cake_log.php | 8 +-- cake/libs/cake_request.php | 2 +- cake/libs/cake_response.php | 3 +- cake/libs/cake_session.php | 13 ++-- cake/libs/config/php_reader.php | 10 ++-- cake/libs/configure.php | 2 +- cake/libs/controller/components/acl.php | 8 +-- cake/libs/error/exceptions.php | 60 ++++++++++++++++++- cake/libs/router.php | 11 ++-- cake/libs/view/helpers/form.php | 5 +- cake/libs/view/helpers/paginator.php | 4 +- cake/libs/view/view.php | 6 +- cake/libs/xml.php | 18 +++--- .../libs/console_option_parser.test.php | 10 ++-- cake/tests/cases/libs/cake_log.test.php | 6 +- cake/tests/cases/libs/cake_request.test.php | 6 +- cake/tests/cases/libs/cake_response.test.php | 2 +- cake/tests/cases/libs/cake_session.test.php | 10 ++-- .../cases/libs/config/php_reader.test.php | 4 +- .../libs/controller/components/acl.test.php | 4 +- .../cases/libs/view/helpers/form.test.php | 2 +- 28 files changed, 146 insertions(+), 86 deletions(-) diff --git a/cake/console/libs/console_input_argument.php b/cake/console/libs/console_input_argument.php index c0ed84fc0..200582353 100644 --- a/cake/console/libs/console_input_argument.php +++ b/cake/console/libs/console_input_argument.php @@ -116,7 +116,7 @@ class ConsoleInputArgument { return true; } if (!in_array($value, $this->_choices)) { - throw new InvalidArgumentException(sprintf( + throw new ConsoleException(sprintf( __('"%s" is not a valid value for %s. Please use one of "%s"'), $value, $this->_name, implode(', ', $this->_choices) )); diff --git a/cake/console/libs/console_input_option.php b/cake/console/libs/console_input_option.php index d4d831aa1..56b01d448 100644 --- a/cake/console/libs/console_input_option.php +++ b/cake/console/libs/console_input_option.php @@ -142,7 +142,7 @@ class ConsoleInputOption { return true; } if (!in_array($value, $this->_choices)) { - throw new InvalidArgumentException(sprintf( + throw new ConsoleException(sprintf( __('"%s" is not a valid value for --%s. Please use one of "%s"'), $value, $this->_name, implode(', ', $this->_choices) )); diff --git a/cake/console/libs/console_option_parser.php b/cake/console/libs/console_option_parser.php index 8a9f8af65..5af733e2d 100644 --- a/cake/console/libs/console_option_parser.php +++ b/cake/console/libs/console_option_parser.php @@ -457,7 +457,7 @@ class ConsoleOptionParser { } foreach ($this->_args as $i => $arg) { if ($arg->isRequired() && !isset($args[$i]) && empty($params['help'])) { - throw new RuntimeException( + throw new ConsoleException( __('Missing required arguments. %s is required.', $arg->name()) ); } @@ -552,7 +552,7 @@ class ConsoleOptionParser { */ protected function _parseOption($name, $params) { if (!isset($this->_options[$name])) { - throw new InvalidArgumentException(__('Unknown option `%s`', $name)); + throw new ConsoleException(__('Unknown option `%s`', $name)); } $option = $this->_options[$name]; $isBoolean = $option->isBoolean(); @@ -586,7 +586,7 @@ class ConsoleOptionParser { } $next = count($args); if (!isset($this->_args[$next])) { - throw new InvalidArgumentException(__('Too many arguments.')); + throw new ConsoleException(__('Too many arguments.')); } if ($this->_args[$next]->validChoice($argument)) { diff --git a/cake/console/shell_dispatcher.php b/cake/console/shell_dispatcher.php index a80407613..029a91442 100644 --- a/cake/console/shell_dispatcher.php +++ b/cake/console/shell_dispatcher.php @@ -102,7 +102,7 @@ class ShellDispatcher { protected function _initEnvironment() { if (!$this->__bootstrap()) { $message = "Unable to load CakePHP core.\nMake sure " . DS . 'cake' . DS . 'libs exists in ' . CAKE_CORE_INCLUDE_PATH; - throw new RuntimeException($message); + throw new CakeException($message); } if (!isset($this->args[0]) || !isset($this->params['working'])) { @@ -110,7 +110,7 @@ class ShellDispatcher { "Please make sure that " . DIRECTORY_SEPARATOR . "cake" . DIRECTORY_SEPARATOR . "console is in your system path,\n" . "and check the cookbook for the correct usage of this command.\n" . "(http://book.cakephp.org/)"; - throw new RuntimeException($message); + throw new CakeException($message); } $this->shiftArgs(); diff --git a/cake/libs/cache.php b/cake/libs/cache.php index e211d20f9..17ba3f8d7 100644 --- a/cake/libs/cache.php +++ b/cake/libs/cache.php @@ -67,7 +67,7 @@ class Cache { * @param string $name Name of the configuration * @param array $settings Optional associative array of settings passed to the engine * @return array(engine, settings) on success, false on failure - * @throws Exception + * @throws CacheException */ public static function config($name = null, $settings = array()) { if (is_array($name)) { @@ -113,10 +113,10 @@ class Cache { return false; } $cacheClass = $class . 'Engine'; - self::$_engines[$name] = new $cacheClass(); - if (!self::$_engines[$name] instanceof CacheEngine) { - throw new Exception(__('Cache engines must use CacheEngine as a base class.')); + if (!is_subclass_of($cacheClass, 'CacheEngine')) { + throw new CacheException(__('Cache engines must use CacheEngine as a base class.')); } + self::$_engines[$name] = new $cacheClass(); if (self::$_engines[$name]->init($config)) { if (time() % self::$_engines[$name]->settings['probability'] === 0) { self::$_engines[$name]->gc(); diff --git a/cake/libs/cache/file.php b/cake/libs/cache/file.php index 687a74f72..7560d8113 100644 --- a/cake/libs/cache/file.php +++ b/cake/libs/cache/file.php @@ -249,20 +249,20 @@ class FileEngine extends CacheEngine { * Not implemented * * @return void - * @throws BadMethodCallException + * @throws CacheException */ public function decrement($key, $offset = 1) { - throw new BadMethodCallException(__('Files cannot be atomically decremented.')); + throw new CacheException(__('Files cannot be atomically decremented.')); } /** * Not implemented * * @return void - * @throws BadMethodCallException + * @throws CacheException */ public function increment($key, $offset = 1) { - throw new BadMethodCallException(__('Files cannot be atomically incremented.')); + throw new CacheException(__('Files cannot be atomically incremented.')); } /** diff --git a/cake/libs/cache/memcache.php b/cake/libs/cache/memcache.php index 9b121e89f..d4a1dbfa8 100644 --- a/cake/libs/cache/memcache.php +++ b/cake/libs/cache/memcache.php @@ -148,11 +148,11 @@ class MemcacheEngine extends CacheEngine { * @param integer $offset How much to increment * @param integer $duration How long to cache the data, in seconds * @return New incremented value, false otherwise - * @throws RuntimeException when you try to increment with compress = true + * @throws CacheException when you try to increment with compress = true */ public function increment($key, $offset = 1) { if ($this->settings['compress']) { - throw new RuntimeException( + throw new CacheException( __('Method increment() not implemented for compressed cache in %s', __CLASS__) ); } @@ -166,11 +166,11 @@ class MemcacheEngine extends CacheEngine { * @param integer $offset How much to substract * @param integer $duration How long to cache the data, in seconds * @return New decremented value, false otherwise - * @throws RuntimeException when you try to decrement with compress = true + * @throws CacheException when you try to decrement with compress = true */ public function decrement($key, $offset = 1) { if ($this->settings['compress']) { - throw new RuntimeException( + throw new CacheException( __('Method decrement() not implemented for compressed cache in %s', __CLASS__) ); } diff --git a/cake/libs/cake_log.php b/cake/libs/cake_log.php index 5e8887c65..afc8df033 100644 --- a/cake/libs/cake_log.php +++ b/cake/libs/cake_log.php @@ -97,18 +97,18 @@ class CakeLog { * @param string $key The keyname for this logger, used to remove the logger later. * @param array $config Array of configuration information for the logger * @return boolean success of configuration. - * @throws Exception + * @throws CakeLogException */ public static function config($key, $config) { if (empty($config['engine'])) { - throw new Exception(__('Missing logger classname')); + throw new CakeLogException(__('Missing logger classname')); } $loggerName = $config['engine']; unset($config['engine']); $className = self::_getLogger($loggerName); $logger = new $className($config); if (!$logger instanceof CakeLogInterface) { - throw new Exception(sprintf( + throw new CakeLogException(sprintf( __('logger class %s does not implement a write method.'), $loggerName )); } @@ -134,7 +134,7 @@ class CakeLog { } } if (!class_exists($loggerName)) { - throw new Exception(__('Could not load class %s', $loggerName)); + throw new CakeLogException(__('Could not load class %s', $loggerName)); } return $loggerName; } diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index ec05c55d2..580f51296 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -426,7 +426,7 @@ class CakeRequest implements ArrayAccess { $type = strtolower(substr($name, 2)); return $this->is($type); } - throw new BadMethodCallException(sprintf('Method %s does not exist', $name)); + throw new CakeException(__('Method %s does not exist', $name)); } /** diff --git a/cake/libs/cake_response.php b/cake/libs/cake_response.php index d2217efbd..6c3d751c2 100644 --- a/cake/libs/cake_response.php +++ b/cake/libs/cake_response.php @@ -448,13 +448,14 @@ class CakeResponse { * * @param integer $code * @return integer current status code + * @throws CakeException When an unknown status code is reached. */ public function statusCode($code = null) { if (is_null($code)) { return $this->_status; } if (!isset($this->_statusCodes[$code])) { - throw new OutOfRangeException(__('Unknown status code')); + throw new CakeException(__('Unknown status code')); } return $this->_status = $code; } diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php index f90b27b3d..c590f2881 100644 --- a/cake/libs/cake_session.php +++ b/cake/libs/cake_session.php @@ -265,7 +265,7 @@ class CakeSession { public static function delete($name) { if (self::check($name)) { if (in_array($name, self::$watchKeys)) { - trigger_error(__('Deleting session key {%s}', $name), E_USER_NOTICE); + throw new CakeSessionException(__('Deleting session key {%s}', $name)); } self::__overwrite($_SESSION, Set::remove($_SESSION, $name)); return (self::check($name) == false); @@ -426,7 +426,6 @@ class CakeSession { */ public static function ignore($var) { if (!in_array($var, self::$watchKeys)) { - debug("NOT"); return; } foreach (self::$watchKeys as $i => $key) { @@ -455,7 +454,7 @@ class CakeSession { } foreach ($write as $key => $val) { if (in_array($key, self::$watchKeys)) { - trigger_error(__('Writing session key {%s}: %s', $key, var_export($val, true)), E_USER_NOTICE); + throw new CakeSessionException(__('Writing session key {%s}: %s', $key, var_export($val, true))); } self::__overwrite($_SESSION, Set::insert($_SESSION, $key, $val)); if (Set::classicExtract($_SESSION, $key) !== $val) { @@ -495,7 +494,7 @@ class CakeSession { * Sessions can be configured with a few shortcut names as well as have any number of ini settings declared. * * @return void - * @throws Exception Throws exceptions when ini_set() fails. + * @throws CakeSessionException Throws exceptions when ini_set() fails. */ protected static function _configureSession() { $sessionConfig = Configure::read('Session'); @@ -527,7 +526,7 @@ class CakeSession { if (!empty($sessionConfig['ini']) && is_array($sessionConfig['ini'])) { foreach ($sessionConfig['ini'] as $setting => $value) { if (ini_set($setting, $value) === false) { - throw new Exception(sprintf( + throw new CakeSessionException(sprintf( __('Unable to configure the session, setting %s failed.'), $setting )); @@ -565,13 +564,13 @@ class CakeSession { App::import('Core', 'session/' . $class); } if (!class_exists($class)) { - throw new Exception(__('Could not load %s to handle the session.', $class)); + throw new CakeSessionException(__('Could not load %s to handle the session.', $class)); } $handler = new $class(); if ($handler instanceof CakeSessionHandlerInterface) { return $handler; } - throw new Exception(__('Chosen SessionHandler does not implement CakeSessionHandlerInterface it cannot be used with an engine key.')); + throw new CakeSessionException(__('Chosen SessionHandler does not implement CakeSessionHandlerInterface it cannot be used with an engine key.')); } /** diff --git a/cake/libs/config/php_reader.php b/cake/libs/config/php_reader.php index 169b44df6..1e2734d12 100644 --- a/cake/libs/config/php_reader.php +++ b/cake/libs/config/php_reader.php @@ -51,12 +51,12 @@ class PhpReader implements ConfigReaderInterface { * @param string $key The identifier to read from. If the key has a . it will be treated * as a plugin prefix. * @return array Parsed configuration values. - * @throws RuntimeException when files don't exist or they don't contain `$config`. - * InvalidArgumentException when files contain '..' as this could lead to abusive reads. + * @throws ConfigureException when files don't exist or they don't contain `$config`. + * Or when files contain '..' as this could lead to abusive reads. */ public function read($key) { if (strpos($key, '..') !== false) { - throw new InvalidArgumentException(__('Cannot load configuration files with ../ in them.')); + throw new ConfigureException(__('Cannot load configuration files with ../ in them.')); } list($plugin, $key) = pluginSplit($key); @@ -66,11 +66,11 @@ class PhpReader implements ConfigReaderInterface { $file = $this->_path . $key . '.php'; } if (!file_exists($file)) { - throw new RuntimeException(__('Could not load configuration file: ') . $file); + throw new ConfigureException(__('Could not load configuration file: ') . $file); } include $file; if (!isset($config)) { - throw new RuntimeException( + throw new ConfigureException( sprintf(__('No variable $config found in %s.php'), $file) ); } diff --git a/cake/libs/configure.php b/cake/libs/configure.php index fca858832..ce05b018e 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -325,7 +325,7 @@ class Configure { * @param string $key name of configuration resource to load. * @param string $config Name of the configured reader to use to read the resource identfied by $key. * @return mixed false if file not found, void if load successful. - * @throws Exception Will throw any exceptions the reader raises. + * @throws ConfigureException Will throw any exceptions the reader raises. */ public static function load($key, $config = 'default') { if (!isset(self::$_readers[$config])) { diff --git a/cake/libs/controller/components/acl.php b/cake/libs/controller/components/acl.php index 3a09c590b..1b7b31486 100644 --- a/cake/libs/controller/components/acl.php +++ b/cake/libs/controller/components/acl.php @@ -58,7 +58,7 @@ class AclComponent extends Component { /** * Constructor. Will return an instance of the correct ACL class as defined in `Configure::read('Acl.classname')` * - * @throws Exception when Acl.classname could not be loaded. + * @throws CakeException when Acl.classname could not be loaded. */ public function __construct(ComponentCollection $collection, $settings = array()) { parent::__construct($collection, $settings); @@ -68,7 +68,7 @@ class AclComponent extends Component { list($plugin, $name) = pluginSplit($name); $name .= 'Component'; } else { - throw new Exception(__('Could not find %s.', $name)); + throw new CakeException(__('Could not find %s.', $name)); } } $this->adapter($name); @@ -84,7 +84,7 @@ class AclComponent extends Component { * * @param mixed $adapter Instance of AclBase or a string name of the class to use. (optional) * @return mixed either null, or instance of AclBase - * @throws Exception when the given class is not an AclBase + * @throws CakeException when the given class is not an AclBase */ public function adapter($adapter = null) { if ($adapter) { @@ -92,7 +92,7 @@ class AclComponent extends Component { $adapter = new $adapter(); } if (!$adapter instanceof AclInterface) { - throw new Exception(__('AclComponent adapters must implement AclInterface')); + throw new CakeException(__('AclComponent adapters must implement AclInterface')); } $this->_Instance = $adapter; $this->_Instance->initialize($this); diff --git a/cake/libs/error/exceptions.php b/cake/libs/error/exceptions.php index 961b39c7d..b6d49061d 100644 --- a/cake/libs/error/exceptions.php +++ b/cake/libs/error/exceptions.php @@ -387,4 +387,62 @@ class MissingTableException extends CakeException { */ class MissingModelException extends CakeException { protected $_messageTemplate = 'Model %s could not be found.'; -} \ No newline at end of file +} + + +/** + * Exception class for Cache. This exception will be thrown from Cache when it + * encounters an error. + * + * @package cake.libs + */ +class CacheException extends CakeException { } + +/** + * Exception class for Router. This exception will be thrown from Router when it + * encounters an error. + * + * @package cake.libs + */ +class RouterException extends CakeException { } + +/** + * Exception class for CakeLog. This exception will be thrown from CakeLog when it + * encounters an error. + * + * @package cake.libs + */ +class CakeLogException extends CakeException { } + +/** + * Exception class for CakeSession. This exception will be thrown from CakeSession when it + * encounters an error. + * + * @package cake.libs + */ +class CakeSessionException extends CakeException { } + +/** + * Exception class for Configure. This exception will be thrown from Configure when it + * encounters an error. + * + * @package cake.libs + */ +class ConfigureException extends CakeException { } + +/** + * Exception class for Xml. This exception will be thrown from Xml when it + * encounters an error. + * + * @package cake.libs + */ +class XmlException extends CakeException { } + +/** + * Exception class for Console libraries. This exception will be thrown from Console library + * classes when they encounter an error. + * + * @package cake.libs + */ +class ConsoleException extends CakeException { } + diff --git a/cake/libs/router.php b/cake/libs/router.php index b51f02134..010511cb2 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -226,7 +226,7 @@ class Router { * shifted into the passed arguments. As well as supplying patterns for routing parameters. * @see routes * @return array Array of routes - * @throws Exception + * @throws RouterException */ public static function connect($route, $defaults = array(), $options = array()) { foreach (self::$_prefixes as $prefix) { @@ -246,13 +246,12 @@ class Router { $routeClass = 'CakeRoute'; if (isset($options['routeClass'])) { $routeClass = $options['routeClass']; + if (!is_subclass_of($routeClass, 'CakeRoute')) { + throw new RouterException(__('Route classes must extend CakeRoute')); + } unset($options['routeClass']); } - $Route = new $routeClass($route, $defaults, $options); - if (!$Route instanceof CakeRoute) { - throw new Exception(__('Route classes must extend CakeRoute')); - } - self::$routes[] =& $Route; + self::$routes[] = new $routeClass($route, $defaults, $options); return self::$routes; } diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index e57e12a68..a92b3fd41 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -1133,14 +1133,15 @@ class FormHelper extends AppHelper { * The first argument to an input type should always be the fieldname, in `Model.field` format. * The second argument should always be an array of attributes for the input. * - * @param string $method Method name / input type to make. + * @param string $method Method name / input type to make. * @param array $params Parameters for the method call * @return string Formatted input method. + * @throws CakeException When there are no params for the method call. */ public function __call($method, $params) { $options = array(); if (empty($params)) { - throw new Exception(__('Missing field name for FormHelper::%s', $method)); + throw new CakeException(__('Missing field name for FormHelper::%s', $method)); } if (isset($params[1])) { $options = $params[1]; diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 5816c6b6a..11b897226 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -87,7 +87,7 @@ class PaginatorHelper extends AppHelper { * * @param View $View the view object the helper is attached to. * @param array $settings Array of settings. - * @return void + * @throws CakeException When the AjaxProvider helper does not implement a link method. */ function __construct(View $View, $settings = array()) { parent::__construct($View, $settings); @@ -99,7 +99,7 @@ class PaginatorHelper extends AppHelper { } $classname = $ajaxProvider . 'Helper'; if (!method_exists($classname, 'link')) { - throw new Exception(sprintf( + throw new CakeException(sprintf( __('%s does not implement a link() method, it is incompatible with PaginatorHelper'), $classname )); } diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index a3221c761..af035292f 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -385,6 +385,7 @@ class View extends Object { * @param string $layout Layout to use * @param string $file Custom filename for view * @return string Rendered Element + * @throws CakeException if there is an error in the view. */ public function render($action = null, $layout = null, $file = null) { if ($this->hasRendered) { @@ -409,7 +410,7 @@ class View extends Object { $layout = $this->layout; } if ($this->output === false) { - throw new RuntimeException(__("Error in view %s, got no content.", $viewFileName)); + throw new CakeException(__("Error in view %s, got no content.", $viewFileName)); } if ($layout && $this->autoLayout) { $this->output = $this->renderLayout($this->output, $layout); @@ -428,6 +429,7 @@ class View extends Object { * * @param string $content_for_layout Content to render in a view, wrapped by the surrounding layout. * @return mixed Rendered output, or false on error + * @throws CakeException if there is an error in the view. */ public function renderLayout($content_for_layout, $layout = null) { $layoutFileName = $this->_getLayoutFileName($layout); @@ -451,7 +453,7 @@ class View extends Object { $this->output = $this->_render($layoutFileName); if ($this->output === false) { - throw new RuntimeException(__("Error in layout %s, got no content.", $layoutFileName)); + throw new CakeException(__("Error in layout %s, got no content.", $layoutFileName)); } $this->Helpers->trigger('afterLayout', array($layoutFileName)); diff --git a/cake/libs/xml.php b/cake/libs/xml.php index 42097597a..160572b95 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -73,7 +73,7 @@ class Xml { * @param mixed $input XML string, a path to a file, an URL or an array * @param array $options The options to use * @return object SimpleXMLElement or DOMDocument - * @throws Exception + * @throws XmlException */ public static function build($input, $options = array()) { if (!is_array($options)) { @@ -101,9 +101,9 @@ class Xml { $dom->load($input); return $dom; } elseif (!is_string($input)) { - throw new Exception(__('Invalid input.')); + throw new XmlException(__('Invalid input.')); } - throw new Exception(__('XML cannot be read.')); + throw new XmlException(__('XML cannot be read.')); } /** @@ -141,14 +141,15 @@ class Xml { * @param array $input Array with data * @param array $options The options to use * @return object SimpleXMLElement or DOMDocument + * @throws XmlException */ public static function fromArray($input, $options = array()) { if (!is_array($input) || count($input) !== 1) { - throw new Exception(__('Invalid input.')); + throw new XmlException(__('Invalid input.')); } $key = key($input); if (is_integer($key)) { - throw new Exception(__('The key of input must be alphanumeric')); + throw new XmlException(__('The key of input must be alphanumeric')); } if (!is_array($options)) { @@ -212,7 +213,7 @@ class Xml { } } else { if ($key[0] === '@') { - throw new Exception(__('Invalid array')); + throw new XmlException(__('Invalid array')); } if (array_keys($value) === range(0, count($value) - 1)) { // List foreach ($value as $item) { @@ -225,7 +226,7 @@ class Xml { } } } else { - throw new Exception(__('Invalid array')); + throw new XmlException(__('Invalid array')); } } } @@ -270,13 +271,14 @@ class Xml { * * @param object $obj SimpleXMLElement, DOMDocument or DOMNode instance * @return array Array representation of the XML structure. + * @throws XmlException */ public static function toArray($obj) { if ($obj instanceof DOMNode) { $obj = simplexml_import_dom($obj); } if (!($obj instanceof SimpleXMLElement)) { - throw new Exception(__('The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.')); + throw new XmlException(__('The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.')); } $result = array(); $namespaces = array_merge(array('' => ''), $obj->getNamespaces(true)); diff --git a/cake/tests/cases/console/libs/console_option_parser.test.php b/cake/tests/cases/console/libs/console_option_parser.test.php index 656f3317a..e010bbaf4 100644 --- a/cake/tests/cases/console/libs/console_option_parser.test.php +++ b/cake/tests/cases/console/libs/console_option_parser.test.php @@ -230,7 +230,7 @@ class ConsoleOptionParserTest extends CakeTestCase { /** * test parsing options that do not exist. * - * @expectedException InvalidArgumentException + * @expectedException ConsoleException */ function testOptionThatDoesNotExist() { $parser = new ConsoleOptionParser('test', false); @@ -242,7 +242,7 @@ class ConsoleOptionParserTest extends CakeTestCase { /** * test that options with choices enforce them. * - * @expectedException InvalidArgumentException + * @expectedException ConsoleException * @return void */ function testOptionWithChoices() { @@ -297,7 +297,7 @@ class ConsoleOptionParserTest extends CakeTestCase { /** * test parsing arguments. * - * @expectedException InvalidArgumentException + * @expectedException ConsoleException * @return void */ function testParseArgumentTooMany() { @@ -315,7 +315,7 @@ class ConsoleOptionParserTest extends CakeTestCase { /** * test that when there are not enough arguments an exception is raised * - * @expectedException RuntimeException + * @expectedException ConsoleException * @return void */ function testPositionalArgNotEnough() { @@ -329,7 +329,7 @@ class ConsoleOptionParserTest extends CakeTestCase { /** * test that arguments with choices enforce them. * - * @expectedException InvalidArgumentException + * @expectedException ConsoleException * @return void */ function testPositionalArgWithChoices() { diff --git a/cake/tests/cases/libs/cake_log.test.php b/cake/tests/cases/libs/cake_log.test.php index 52c5c5abc..72fe1e8e8 100644 --- a/cake/tests/cases/libs/cake_log.test.php +++ b/cake/tests/cases/libs/cake_log.test.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Log'); +App::import('Core', 'CakeLog'); App::import('Core', 'log/FileLog'); /** @@ -70,7 +70,7 @@ class CakeLogTest extends CakeTestCase { /** * test all the errors from failed logger imports * - * @expectedException Exception + * @expectedException CakeLogException * @return void */ function testImportingLoggerFailure() { @@ -80,7 +80,7 @@ class CakeLogTest extends CakeTestCase { /** * test that loggers have to implement the correct interface. * - * @expectedException Exception + * @expectedException CakeLogException * @return void */ function testNotImplementingInterface() { diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index af4ad93cb..f423ac19d 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -17,9 +17,7 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!class_exists('dispatcher')) { - require CAKE . 'dispatcher.php'; -} +App::import('Core', 'Dispatcher'); App::import('Core', 'CakeRequest'); class CakeRequestTestCase extends CakeTestCase { @@ -614,7 +612,7 @@ class CakeRequestTestCase extends CakeTestCase { /** * test __call expcetions * - * @expectedException Exception + * @expectedException CakeException * @return void */ function test__callExceptionOnUnknownMethod() { diff --git a/cake/tests/cases/libs/cake_response.test.php b/cake/tests/cases/libs/cake_response.test.php index eee0cfc69..d0d2a9e58 100644 --- a/cake/tests/cases/libs/cake_response.test.php +++ b/cake/tests/cases/libs/cake_response.test.php @@ -55,7 +55,7 @@ class CakeResponseTestCase extends CakeTestCase { /** * Tests the statusCode method * -* @expectedException OutOfRangeException +* @expectedException CakeException */ public function testStatusCode() { $response = new CakeResponse(); diff --git a/cake/tests/cases/libs/cake_session.test.php b/cake/tests/cases/libs/cake_session.test.php index 51d37dc14..02fda57e7 100644 --- a/cake/tests/cases/libs/cake_session.test.php +++ b/cake/tests/cases/libs/cake_session.test.php @@ -367,7 +367,7 @@ class CakeSessionTest extends CakeTestCase { /** * testWatchVar method * - * @expectedException Exception + * @expectedException CakeSessionException * @access public * @return void */ @@ -380,16 +380,16 @@ class CakeSessionTest extends CakeTestCase { } /** - * undocumented function + * Test that deleting watched vars causes exceptions * - * @expectedException Exception + * @expectedException CakeSessionException * @return void */ function testWatchVarDelete() { + TestCakeSession::write('Watching', 'I am watching you.'); + TestCakeSession::watch('Watching'); TestCakeSession::delete('Watching'); - - $this->assertFalse(TestCakeSession::watch('Invalid.key')); } /** diff --git a/cake/tests/cases/libs/config/php_reader.test.php b/cake/tests/cases/libs/config/php_reader.test.php index 53898f97f..539f56666 100644 --- a/cake/tests/cases/libs/config/php_reader.test.php +++ b/cake/tests/cases/libs/config/php_reader.test.php @@ -44,7 +44,7 @@ class PhpReaderTest extends CakeTestCase { /** * Test an exception is thrown by reading files that don't exist. * - * @expectedException RuntimeException + * @expectedException ConfigureException * @return void */ function testReadWithNonExistantFile() { @@ -66,7 +66,7 @@ class PhpReaderTest extends CakeTestCase { /** * test reading keys with ../ doesn't work * - * @expectedException InvalidArgumentException + * @expectedException ConfigureException * @return void */ function testReadWithDots() { diff --git a/cake/tests/cases/libs/controller/components/acl.test.php b/cake/tests/cases/libs/controller/components/acl.test.php index 600b69069..544ff44b1 100644 --- a/cake/tests/cases/libs/controller/components/acl.test.php +++ b/cake/tests/cases/libs/controller/components/acl.test.php @@ -218,7 +218,7 @@ class AclComponentTest extends CakeTestCase { * test that construtor throws an exception when Acl.classname is a * non-existant class * - * @expectedException Exception + * @expectedException CakeException * @return void */ function testConstrutorException() { @@ -243,7 +243,7 @@ class AclComponentTest extends CakeTestCase { /** * test that adapter() whines when the class is not an AclBase * - * @expectedException Exception + * @expectedException CakeException * @return void */ function testAdapterException() { diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index a5a37bb7e..143570711 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -6700,7 +6700,7 @@ class FormHelperTest extends CakeTestCase { /** * - * @expectedException Exception + * @expectedException CakeException * @return void */ function testHtml5InputException() { From daffe3adb27260c2e8b80d09ecc184c219d2fe99 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 12:37:02 -0500 Subject: [PATCH 228/378] Making baked code throw 404 errors when you try to edit, delete, or view records that do not exist. Updated tests. --- .../default/actions/controller_actions.ctp | 35 ++++++------------- .../console/shells/tasks/controller.test.php | 8 ++--- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/cake/console/templates/default/actions/controller_actions.ctp b/cake/console/templates/default/actions/controller_actions.ctp index 370879e66..b02ad7647 100644 --- a/cake/console/templates/default/actions/controller_actions.ctp +++ b/cake/console/templates/default/actions/controller_actions.ctp @@ -25,13 +25,9 @@ } public function view($id = null) { - if (!$id) { - - $this->Session->setFlash(__('Invalid ')); - $this->redirect(array('action' => 'index')); - - $this->flash(__('Invalid '), array('action' => 'index')); - + $this->->id = $id; + if (!$this->->exists()) { + throw new NotFoundException(__('Invalid ')); } $this->set('', $this->->read(null, $id)); } @@ -72,13 +68,9 @@ public function edit($id = null) { - if (!$id && empty($this->request->data)) { - - $this->Session->setFlash(__('Invalid ')); - $this->redirect(array('action' => 'index')); - - $this->flash(__('Invalid '), array('action' => 'index')); - + $this->->id = $id; + if (!$this->->exists()) { + throw new NotFoundException(__('Invalid ')); } if ($this->request->is('post')) { if ($this->->save($this->request->data)) { @@ -93,8 +85,7 @@ $this->Session->setFlash(__('The could not be saved. Please, try again.')); } - } - if (!$this->request->is('post')) { + } else { $this->data = $this->->read(null, $id); } request->is('post')) { throw new MethodNotAllowedException(); } - if (!$id) { - - $this->Session->setFlash(__('Invalid id for ')); - $this->redirect(array('action'=>'index')); - - $this->flash(__('Invalid '), array('action' => 'index')); - + $this->->id = $id; + if (!$this->->exists()) { + throw new NotFoundException(__('Invalid ')); } - if ($this->->delete($id)) { + if ($this->->delete()) { $this->Session->setFlash(__(' deleted')); $this->redirect(array('action'=>'index')); diff --git a/cake/tests/cases/console/shells/tasks/controller.test.php b/cake/tests/cases/console/shells/tasks/controller.test.php index f3601376e..86ff8fb77 100644 --- a/cake/tests/cases/console/shells/tasks/controller.test.php +++ b/cake/tests/cases/console/shells/tasks/controller.test.php @@ -340,7 +340,7 @@ class ControllerTaskTest extends CakeTestCase { $this->assertContains("\$this->set('bakeArticles', \$this->paginate());", $result); $this->assertContains('function view($id = null)', $result); - $this->assertContains("\$this->Session->setFlash(__('Invalid bake article'));", $result); + $this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result); $this->assertContains("\$this->set('bakeArticle', \$this->BakeArticle->read(null, \$id)", $result); $this->assertContains('function add()', $result); @@ -352,7 +352,7 @@ class ControllerTaskTest extends CakeTestCase { $this->assertContains("\$this->Session->setFlash(__('The bake article could not be saved. Please, try again.'));", $result); $this->assertContains('function delete($id = null)', $result); - $this->assertContains('if ($this->BakeArticle->delete($id))', $result); + $this->assertContains('if ($this->BakeArticle->delete())', $result); $this->assertContains("\$this->Session->setFlash(__('Bake article deleted'));", $result); $result = $this->Task->bakeActions('BakeArticles', 'admin_', true); @@ -382,7 +382,7 @@ class ControllerTaskTest extends CakeTestCase { $this->assertContains("\$this->set('bakeArticles', \$this->paginate());", $result); $this->assertContains('function view($id = null)', $result); - $this->assertContains("\$this->flash(__('Invalid bake article'), array('action' => 'index'))", $result); + $this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result); $this->assertContains("\$this->set('bakeArticle', \$this->BakeArticle->read(null, \$id)", $result); $this->assertContains('function add()', $result); @@ -396,7 +396,7 @@ class ControllerTaskTest extends CakeTestCase { $this->assertContains("\$this->set(compact('bakeTags'))", $result); $this->assertContains('function delete($id = null)', $result); - $this->assertContains('if ($this->BakeArticle->delete($id))', $result); + $this->assertContains('if ($this->BakeArticle->delete())', $result); $this->assertContains("\$this->flash(__('Bake article deleted'), array('action' => 'index'))", $result); } From 661195db6ca6944f1013c2c7682b7977437e0482 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 12:44:48 -0500 Subject: [PATCH 229/378] Updating __() use in scaffold to take advantage of sprintf() being built into __() now. --- cake/libs/controller/scaffold.php | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index 34eb22c6d..68883be52 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -173,7 +173,7 @@ class Scaffold { protected function _scaffoldView(CakeRequest $request) { if ($this->controller->_beforeScaffold('view')) { - $message = __(sprintf("No id set for %s::view()", Inflector::humanize($this->modelKey))); + $message = __("No id set for %s::view()", Inflector::humanize($this->modelKey)); if (isset($request->params['pass'][0])) { $this->ScaffoldModel->id = $request->params['pass'][0]; } else { @@ -247,7 +247,7 @@ class Scaffold { } if (!$this->ScaffoldModel->exists()) { - $message = sprintf(__("Invalid id for %s::edit()", true), Inflector::humanize($this->modelKey)); + $message = __("Invalid id for %s::edit()", Inflector::humanize($this->modelKey)); return $this->_sendMessage($message); } } @@ -259,8 +259,8 @@ class Scaffold { if ($this->ScaffoldModel->save($request->data)) { if ($this->controller->_afterScaffoldSave($action)) { - $message = sprintf( - __('The %1$s has been %2$s'), + $message = __( + 'The %1$s has been %2$s', Inflector::humanize($this->modelKey), $success ); @@ -308,10 +308,7 @@ class Scaffold { */ protected function _scaffoldDelete(CakeRequest $request) { if ($this->controller->_beforeScaffold('delete')) { - $message = sprintf( - __("No id set for %s::delete()", true), - Inflector::humanize($this->modelKey) - ); + $message = __("No id set for %s::delete()", Inflector::humanize($this->modelKey)); if (isset($request->params['pass'][0])) { $id = $request->params['pass'][0]; } else { @@ -319,15 +316,13 @@ class Scaffold { } if ($this->ScaffoldModel->delete($id)) { - $message = sprintf( - __('The %1$s with id: %2$d has been deleted.', true), - Inflector::humanize($this->modelClass), $id - ); + $message = __('The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id); return $this->_sendMessage($message); } else { - $message = sprintf( - __('There was an error deleting the %1$s with id: %2$d', true), - Inflector::humanize($this->modelClass), $id + $message = __( + 'There was an error deleting the %1$s with id: %2$d', + Inflector::humanize($this->modelClass), + $id ); return $this->_sendMessage($message); } From 495061537fd1e776fe3436f89ba28a87004130e4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 12:59:25 -0500 Subject: [PATCH 230/378] Changing Scaffold to use exceptions to indicate error states. Starting to convert record deletion to POST only. --- cake/libs/controller/scaffold.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index 68883be52..c58fba7d1 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -172,15 +172,14 @@ class Scaffold { */ protected function _scaffoldView(CakeRequest $request) { if ($this->controller->_beforeScaffold('view')) { - - $message = __("No id set for %s::view()", Inflector::humanize($this->modelKey)); if (isset($request->params['pass'][0])) { $this->ScaffoldModel->id = $request->params['pass'][0]; - } else { - return $this->_sendMessage($message); + } + if (!$this->ScaffoldModel->exists()) { + throw new NotFoundException(__('Invalid %s', Inflector::humanize($this->modelKey))); } $this->ScaffoldModel->recursive = 1; - $this->controller->request->data = $this->controller->data = $this->ScaffoldModel->read(); + $this->controller->request->data = $this->ScaffoldModel->read(); $this->controller->set( Inflector::variable($this->controller->modelClass), $this->request->data ); @@ -245,10 +244,8 @@ class Scaffold { if (isset($request->params['pass'][0])) { $this->ScaffoldModel->id = $request['pass'][0]; } - if (!$this->ScaffoldModel->exists()) { - $message = __("Invalid id for %s::edit()", Inflector::humanize($this->modelKey)); - return $this->_sendMessage($message); + throw new NotFoundException(__('Invalid %s', Inflector::humanize($this->modelKey))); } } @@ -308,14 +305,18 @@ class Scaffold { */ protected function _scaffoldDelete(CakeRequest $request) { if ($this->controller->_beforeScaffold('delete')) { - $message = __("No id set for %s::delete()", Inflector::humanize($this->modelKey)); + if (!$request->is('post')) { + throw new MethodNotAllowedException(); + } + $id = false; if (isset($request->params['pass'][0])) { $id = $request->params['pass'][0]; - } else { - return $this->_sendMessage($message); } - - if ($this->ScaffoldModel->delete($id)) { + $this->ScaffoldModel->id = $id; + if (!$this->ScaffoldModel->exists()) { + throw new NotFoundException(__('Invalid %s', Inflector::humanize($this->modelClass))); + } + if ($this->ScaffoldModel->delete()) { $message = __('The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id); return $this->_sendMessage($message); } else { From 11df32148f9d0cd7f620b9ee829eea8373e37558 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 13:13:00 -0500 Subject: [PATCH 231/378] Updating scaffold templates to use post forms for delete buttons. Updating test case. --- cake/libs/view/scaffolds/edit.ctp | 11 ++++-- cake/libs/view/scaffolds/index.ctp | 36 ++++++++++--------- .../cases/libs/controller/scaffold.test.php | 2 +- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/cake/libs/view/scaffolds/edit.ctp b/cake/libs/view/scaffolds/edit.ctp index 3e59682b5..7fb2c4c8b 100644 --- a/cake/libs/view/scaffolds/edit.ctp +++ b/cake/libs/view/scaffolds/edit.ctp @@ -27,10 +27,15 @@

    -action != 'add'):?> -
  • Html->link(__('Delete'), array('action' => 'delete', $this->Form->value($modelClass.'.'.$primaryKey)), null, __('Are you sure you want to delete').' #' . $this->Form->value($modelClass.'.'.$primaryKey)); ?>
  • +request->action != 'add'): ?> +
  • Form->postLink( + __('Delete'), + array('action' => 'delete', $this->Form->value($modelClass . '.' . $primaryKey)), + null, + __('Are you sure you want to delete # %s?', $this->Form->value($modelClass . '.' . $primaryKey))); + ?>
  • -
  • Html->link(__('List').' '.$pluralHumanName, array('action' => 'index'));?>
  • +
  • Html->link(__('List') . ' ' . $pluralHumanName, array('action' => 'index'));?>
  • $_data) { diff --git a/cake/libs/view/scaffolds/index.ctp b/cake/libs/view/scaffolds/index.ctp index 7a4f49aef..d92b88320 100644 --- a/cake/libs/view/scaffolds/index.ctp +++ b/cake/libs/view/scaffolds/index.ctp @@ -33,33 +33,37 @@ foreach (${$pluralVar} as ${$singularVar}): if ($i++ % 2 == 0) { $class = ' class="altrow"'; } -echo "\n"; - echo "\t\n"; + echo ""; foreach ($scaffoldFields as $_field) { $isKey = false; if (!empty($associations['belongsTo'])) { foreach ($associations['belongsTo'] as $_alias => $_details) { if ($_field === $_details['foreignKey']) { $isKey = true; - echo "\t\t\n\t\t\t" . $this->Html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t\n"; + echo "" . $this->Html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . ""; break; } } } if ($isKey !== true) { - echo "\t\t" . h(${$singularVar}[$modelClass][$_field]) . "\n"; + echo "" . h(${$singularVar}[$modelClass][$_field]) . ""; } } - echo "\t\t\n"; - echo "\t\t\t" . $this->Html->link(__('View'), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])) . "\n"; - echo "\t\t\t" . $this->Html->link(__('Edit'), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])) . "\n"; - echo "\t\t\t" . $this->Html->link(__('Delete'), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey]) . "\n"; - echo "\t\t\n"; - echo "\t\n"; + echo ''; + echo $this->Html->link(__('View'), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])); + echo $this->Html->link(__('Edit'), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])); + echo $this->Form->postLink( + __('Delete'), + array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), + null, + __('Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] + ); + echo ''; + echo ''; endforeach; -echo "\n"; + ?>

    - Paginator->prev('<< ' . __('previous'), array(), null, array('class' => 'disabled')) . "\n";?> - | Paginator->numbers() . "\n"?> - Paginator->next(__('next') .' >>', array(), null, array('class' => 'disabled')) . "\n";?> + Paginator->prev('<< ' . __('previous'), array(), null, array('class' => 'disabled')); ?> + | Paginator->numbers(); ?> + Paginator->next(__('next') .' >>', array(), null, array('class' => 'disabled')); ?>
@@ -82,8 +86,8 @@ echo "\n"; foreach ($associations as $_type => $_data) { foreach ($_data as $_alias => $_details) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { - echo "\t\t
  • " . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "
  • \n"; - echo "\t\t
  • " . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "
  • \n"; + echo "
  • " . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "
  • "; + echo "
  • " . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "
  • "; $done[] = $_details['controller']; } } diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php index 2ebd3f5e3..17e755047 100644 --- a/cake/tests/cases/libs/controller/scaffold.test.php +++ b/cake/tests/cases/libs/controller/scaffold.test.php @@ -524,7 +524,7 @@ class ScaffoldViewTest extends CakeTestCase { $this->assertContains('input name="data[ScaffoldMock][title]" maxlength="255" type="text" value="First Article" id="ScaffoldMockTitle"', $result); $this->assertContains('input name="data[ScaffoldMock][published]" maxlength="1" type="text" value="Y" id="ScaffoldMockPublished"', $result); $this->assertContains('textarea name="data[ScaffoldMock][body]" cols="30" rows="6" id="ScaffoldMockBody"', $result); - $this->assertPattern('/
  • ]*>Delete<\/a>\s*<\/li>/', $result); + $this->assertPattern('/useDbConfig); if (!$db->connected) { trigger_error( @@ -73,7 +73,7 @@ class TranslateBehavior extends ModelBehavior { * @param Model $model Model being detached. * @return void */ - public function cleanup(&$model) { + public function cleanup($model) { $this->unbindTranslation($model); unset($this->settings[$model->alias]); unset($this->runtime[$model->alias]); @@ -86,7 +86,7 @@ class TranslateBehavior extends ModelBehavior { * @param array $query Array of Query parameters. * @return array Modified query */ - public function beforeFind(&$model, $query) { + public function beforeFind($model, $query) { $this->runtime[$model->alias]['virtualFields'] = $model->virtualFields; $locale = $this->_getLocale($model); if (empty($locale)) { @@ -196,7 +196,7 @@ class TranslateBehavior extends ModelBehavior { * @param boolean $primary Did the find originate on $model. * @return array Modified results */ - public function afterFind(&$model, $results, $primary) { + public function afterFind($model, $results, $primary) { $model->virtualFields = $this->runtime[$model->alias]['virtualFields']; $this->runtime[$model->alias]['virtualFields'] = $this->runtime[$model->alias]['fields'] = array(); $locale = $this->_getLocale($model); @@ -242,7 +242,7 @@ class TranslateBehavior extends ModelBehavior { * @param Model $model Model invalidFields was called on. * @return boolean */ - public function beforeValidate(&$model) { + public function beforeValidate($model) { $locale = $this->_getLocale($model); if (empty($locale)) { return true; @@ -276,7 +276,7 @@ class TranslateBehavior extends ModelBehavior { * @param boolean $created Whether or not the save created a record. * @return void */ - public function afterSave(&$model, $created) { + public function afterSave($model, $created) { if (!isset($this->runtime[$model->alias]['beforeSave'])) { return true; } @@ -284,7 +284,7 @@ class TranslateBehavior extends ModelBehavior { $tempData = $this->runtime[$model->alias]['beforeSave']; unset($this->runtime[$model->alias]['beforeSave']); $conditions = array('model' => $model->alias, 'foreign_key' => $model->id); - $RuntimeModel =& $this->translateModel($model); + $RuntimeModel = $this->translateModel($model); foreach ($tempData as $field => $value) { unset($conditions['content']); @@ -319,8 +319,8 @@ class TranslateBehavior extends ModelBehavior { * @param Model $model Model the callback was run on. * @return void */ - public function afterDelete(&$model) { - $RuntimeModel =& $this->translateModel($model); + public function afterDelete($model) { + $RuntimeModel = $this->translateModel($model); $conditions = array('model' => $model->alias, 'foreign_key' => $model->id); $RuntimeModel->deleteAll($conditions); } @@ -331,12 +331,12 @@ class TranslateBehavior extends ModelBehavior { * @param Model $model Model the locale needs to be set/get on. * @return mixed string or false */ - protected function _getLocale(&$model) { + protected function _getLocale($model) { if (!isset($model->locale) || is_null($model->locale)) { if (!class_exists('I18n')) { App::import('Core', 'i18n'); } - $I18n =& I18n::getInstance(); + $I18n = I18n::getInstance(); $I18n->l10n->get(Configure::read('Config.language')); $model->locale = $I18n->l10n->locale; } @@ -353,7 +353,7 @@ class TranslateBehavior extends ModelBehavior { * @param Model $model Model to get a translatemodel for. * @return object */ - public function &translateModel(&$model) { + public function translateModel($model) { if (!isset($this->runtime[$model->alias]['model'])) { if (!isset($model->translateModel) || empty($model->translateModel)) { $className = 'I18nModel'; @@ -380,12 +380,12 @@ class TranslateBehavior extends ModelBehavior { * @param boolean $reset * @return bool */ - function bindTranslation(&$model, $fields, $reset = true) { + function bindTranslation($model, $fields, $reset = true) { if (is_string($fields)) { $fields = array($fields); } $associations = array(); - $RuntimeModel =& $this->translateModel($model); + $RuntimeModel = $this->translateModel($model); $default = array('className' => $RuntimeModel->alias, 'foreignKey' => 'foreign_key'); foreach ($fields as $key => $value) { @@ -453,7 +453,7 @@ class TranslateBehavior extends ModelBehavior { * unbind all original translations * @return bool */ - function unbindTranslation(&$model, $fields = null) { + function unbindTranslation($model, $fields = null) { if (empty($fields) && empty($this->settings[$model->alias])) { return false; } @@ -464,7 +464,7 @@ class TranslateBehavior extends ModelBehavior { if (is_string($fields)) { $fields = array($fields); } - $RuntimeModel =& $this->translateModel($model); + $RuntimeModel = $this->translateModel($model); $associations = array(); foreach ($fields as $key => $value) { @@ -499,15 +499,13 @@ class TranslateBehavior extends ModelBehavior { return true; } } -if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) { /** * @package cake * @subpackage cake.cake.libs.model.behaviors */ - class I18nModel extends AppModel { - public $name = 'I18nModel'; - public $useTable = 'i18n'; - public $displayField = 'field'; - } +class I18nModel extends AppModel { + public $name = 'I18nModel'; + public $useTable = 'i18n'; + public $displayField = 'field'; } diff --git a/cake/tests/cases/libs/model/models.php b/cake/tests/cases/libs/model/models.php index 33a566edf..b116962b0 100644 --- a/cake/tests/cases/libs/model/models.php +++ b/cake/tests/cases/libs/model/models.php @@ -2591,38 +2591,6 @@ class MyCategoriesMyProduct extends CakeTestModel { public $name = 'MyCategoriesMyProduct'; } -/** - * I18nModel class - * - * @package cake - * @subpackage cake.tests.cases.libs.model - */ -class I18nModel extends CakeTestModel { - -/** - * name property - * - * @var string 'I18nModel' - * @access public - */ - public $name = 'I18nModel'; - -/** - * useTable property - * - * @var string 'i18n' - * @access public - */ - public $useTable = 'i18n'; - -/** - * displayField property - * - * @var string 'field' - * @access public - */ - public $displayField = 'field'; -} /** * NumberTree class @@ -2662,7 +2630,7 @@ class NumberTree extends CakeTestModel { */ function initialize($levelLimit = 3, $childLimit = 3, $currentLevel = null, $parent_id = null, $prefix = '1', $hierachial = true) { if (!$parent_id) { - $db =& ConnectionManager::getDataSource($this->useDbConfig); + $db = ConnectionManager::getDataSource($this->useDbConfig); $db->truncate($this->table); $this->save(array($this->name => array('name' => '1. Root'))); $this->initialize($levelLimit, $childLimit, 1, $this->id, '1', $hierachial); From 3c69d9b13841610bc10be707224c10244a02d1f8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 17:40:13 -0500 Subject: [PATCH 242/378] Making ModelBehavior beforeX callbacks default to returning true. Returning null or false from a Behavior::before method will abort the operation. It felt illogical to have null continue, but false stop. --- cake/libs/model/model.php | 10 +++++----- cake/libs/model/model_behavior.php | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 7f757a79c..7c8b5f2e6 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1322,7 +1322,7 @@ class Model extends Object { if ($options['callbacks'] === true || $options['callbacks'] === 'before') { $result = $this->Behaviors->trigger('beforeSave', array(&$this, $options), array( - 'break' => true, 'breakOn' => false + 'break' => true, 'breakOn' => array(false, null) )); if (!$result || !$this->beforeSave($options)) { $this->whitelist = $_whitelist; @@ -1854,7 +1854,7 @@ class Model extends Object { $filters = $this->Behaviors->trigger( 'beforeDelete', array(&$this, $cascade), - array('break' => true, 'breakOn' => false) + array('break' => true, 'breakOn' => array(false, null)) ); if (!$filters || !$this->exists()) { return false; @@ -1876,7 +1876,7 @@ class Model extends Object { if (!empty($this->belongsTo)) { $this->updateCounterCache($keys[$this->alias]); } - $this->Behaviors->trigger($this, 'afterDelete'); + $this->Behaviors->trigger('afterDelete', array(&$this)); $this->afterDelete(); $this->_clearCache(); $this->id = false; @@ -2142,8 +2142,8 @@ class Model extends Object { if ($query['callbacks'] === true || $query['callbacks'] === 'before') { $return = $this->Behaviors->trigger( 'beforeFind', - array(&$this, $query), - array('break' => true, 'breakOn' => false, 'modParams' => 1) + array(&$this, $query), + array('break' => true, 'breakOn' => array(false, null), 'modParams' => 1) ); $query = (is_array($return)) ? $return : $query; diff --git a/cake/libs/model/model_behavior.php b/cake/libs/model/model_behavior.php index 192b21b72..46ad69165 100644 --- a/cake/libs/model/model_behavior.php +++ b/cake/libs/model/model_behavior.php @@ -80,7 +80,7 @@ class ModelBehavior extends Object { * * @param object $model Model using this behavior * @param array $queryData Data used to execute this query, i.e. conditions, order, etc. - * @return mixed False if the operation should abort. An array will replace the value of $query. + * @return mixed False or null will abort the operation. You should array will replace the value of $query. * @access public */ public function beforeFind($model, $query) { } @@ -100,10 +100,12 @@ class ModelBehavior extends Object { * Before validate callback * * @param object $model Model using this behavior - * @return mixed False if the operation should abort. Any other result will continue. + * @return mixed False or null will abort the operation. Any other result will continue. * @access public */ - public function beforeValidate($model) { } + public function beforeValidate($model) { + return true; + } /** * Before save callback @@ -112,7 +114,9 @@ class ModelBehavior extends Object { * @return mixed False if the operation should abort. Any other result will continue. * @access public */ - public function beforeSave($model) { } + public function beforeSave($model) { + return true; + } /** * After save callback @@ -120,7 +124,9 @@ class ModelBehavior extends Object { * @param object $model Model using this behavior * @param boolean $created True if this save created a new record */ - public function afterSave($model, $created) { } + public function afterSave($model, $created) { + return true; + } /** * Before delete callback @@ -130,7 +136,9 @@ class ModelBehavior extends Object { * @return mixed False if the operation should abort. Any other result will continue. * @access public */ - public function beforeDelete($model, $cascade = true) { } + public function beforeDelete($model, $cascade = true) { + return true; + } /** * After delete callback From ce2e6053e4eda2b95ba95bc126ac5a0bae7181a0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 17:40:41 -0500 Subject: [PATCH 243/378] Adding containable to the AllBehaviors test as it now runs. --- cake/tests/cases/libs/all_behaviors.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/all_behaviors.test.php b/cake/tests/cases/libs/all_behaviors.test.php index 625e4065a..b27a1cfe4 100644 --- a/cake/tests/cases/libs/all_behaviors.test.php +++ b/cake/tests/cases/libs/all_behaviors.test.php @@ -39,7 +39,7 @@ class AllBehaviorsTest extends PHPUnit_Framework_TestSuite { $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'behavior_collection.test.php'); $suite->addTestFile($path . 'acl.test.php'); - // $suite->addTestFile($path . 'containable.test.php'); + $suite->addTestFile($path . 'containable.test.php'); $suite->addTestFile($path . 'translate.test.php'); $suite->addTestFile($path . 'tree.test.php'); return $suite; From bf22af6b7f9a463043dd1b51534e3641f0a492ab Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 17:41:57 -0500 Subject: [PATCH 244/378] Fixing more strict errors and usage errors in BehaviorCollection test. Making modParams only work if the result is an array. This is for compatibility with previous behaviour. --- cake/libs/object_collection.php | 7 +-- .../libs/model/behavior_collection.test.php | 59 ++++++++----------- .../cases/libs/object_collection.test.php | 2 +- 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/cake/libs/object_collection.php b/cake/libs/object_collection.php index 831dd555b..d91f62cc9 100644 --- a/cake/libs/object_collection.php +++ b/cake/libs/object_collection.php @@ -107,18 +107,17 @@ abstract class ObjectCollection { if ($options['modParams'] !== false && !isset($params[$options['modParams']])) { throw new CakeException(__('Cannot use modParams with indexes that do not exist.')); } - foreach ($list as $name) { $result = call_user_func_array(array($this->_loaded[$name], $callback), $params); if ($options['collectReturn'] === true) { $collected[] = $result; } if ( - $options['break'] && ($result === $options['breakOn'] || + $options['break'] && ($result === $options['breakOn'] || (is_array($options['breakOn']) && in_array($result, $options['breakOn'], true))) ) { - break; - } elseif ($options['modParams'] !== false && $result !== null) { + return $result; + } elseif ($options['modParams'] !== false && is_array($result)) { $params[$options['modParams']] = $result; } } diff --git a/cake/tests/cases/libs/model/behavior_collection.test.php b/cake/tests/cases/libs/model/behavior_collection.test.php index 12ce1dd4f..27c71e2f9 100644 --- a/cake/tests/cases/libs/model/behavior_collection.test.php +++ b/cake/tests/cases/libs/model/behavior_collection.test.php @@ -46,7 +46,7 @@ class TestBehavior extends ModelBehavior { * @access public * @return void */ - function setup(&$model, $config = array()) { + function setup($model, $config = array()) { parent::setup($model, $config); if (isset($config['mangle'])) { $config['mangle'] .= ' mangled'; @@ -62,7 +62,7 @@ class TestBehavior extends ModelBehavior { * @access public * @return void */ - function beforeFind(&$model, $query) { + function beforeFind($model, $query) { $settings = $this->settings[$model->alias]; if (!isset($settings['beforeFind']) || $settings['beforeFind'] == 'off') { return parent::beforeFind($model, $query); @@ -91,7 +91,7 @@ class TestBehavior extends ModelBehavior { * @access public * @return void */ - function afterFind(&$model, $results, $primary) { + function afterFind($model, $results, $primary) { $settings = $this->settings[$model->alias]; if (!isset($settings['afterFind']) || $settings['afterFind'] == 'off') { return parent::afterFind($model, $results, $primary); @@ -119,7 +119,7 @@ class TestBehavior extends ModelBehavior { * @access public * @return void */ - function beforeSave(&$model) { + function beforeSave($model) { $settings = $this->settings[$model->alias]; if (!isset($settings['beforeSave']) || $settings['beforeSave'] == 'off') { return parent::beforeSave($model); @@ -129,7 +129,7 @@ class TestBehavior extends ModelBehavior { return false; break; case 'test': - return null; + return true; break; case 'modify': $model->data[$model->alias]['name'] .= ' modified before'; @@ -146,7 +146,7 @@ class TestBehavior extends ModelBehavior { * @access public * @return void */ - function afterSave(&$model, $created) { + function afterSave($model, $created) { $settings = $this->settings[$model->alias]; if (!isset($settings['afterSave']) || $settings['afterSave'] == 'off') { return parent::afterSave($model, $created); @@ -178,7 +178,7 @@ class TestBehavior extends ModelBehavior { * @access public * @return void */ - function beforeValidate(&$model) { + function beforeValidate($model) { $settings = $this->settings[$model->alias]; if (!isset($settings['validate']) || $settings['validate'] == 'off') { return parent::beforeValidate($model); @@ -210,7 +210,7 @@ class TestBehavior extends ModelBehavior { * @access public * @return void */ - function beforeDelete(&$model, $cascade = true) { + function beforeDelete($model, $cascade = true) { $settings = $this->settings[$model->alias]; if (!isset($settings['beforeDelete']) || $settings['beforeDelete'] == 'off') { return parent::beforeDelete($model, $cascade); @@ -227,6 +227,7 @@ class TestBehavior extends ModelBehavior { if ($cascade) { echo ' (cascading) '; } + return true; break; } } @@ -238,7 +239,7 @@ class TestBehavior extends ModelBehavior { * @access public * @return void */ - function afterDelete(&$model) { + function afterDelete($model) { $settings = $this->settings[$model->alias]; if (!isset($settings['afterDelete']) || $settings['afterDelete'] == 'off') { return parent::afterDelete($model); @@ -257,10 +258,10 @@ class TestBehavior extends ModelBehavior { * @access public * @return void */ - function onError(&$model) { + function onError($model, $error) { $settings = $this->settings[$model->alias]; if (!isset($settings['onError']) || $settings['onError'] == 'off') { - return parent::onError($model, $cascade); + return parent::onError($model, $error); } echo "onError trigger success"; } @@ -271,7 +272,7 @@ class TestBehavior extends ModelBehavior { * @access public * @return void */ - function beforeTest(&$model) { + function beforeTest($model) { if (!isset($model->beforeTestResult)) { $model->beforeTestResult = array(); } @@ -361,7 +362,7 @@ class Test3Behavior extends TestBehavior{ * @subpackage cake.tests.cases.libs.model */ class Test4Behavior extends ModelBehavior{ - function setup(&$model, $config = null) { + function setup($model, $config = null) { $model->bindModel( array('hasMany' => array('Comment')) ); @@ -375,7 +376,7 @@ class Test4Behavior extends ModelBehavior{ * @subpackage cake.tests.cases.libs.model */ class Test5Behavior extends ModelBehavior{ - function setup(&$model, $config = null) { + function setup($model, $config = null) { $model->bindModel( array('belongsTo' => array('User')) ); @@ -389,7 +390,7 @@ class Test5Behavior extends ModelBehavior{ * @subpackage cake.tests.cases.libs.model */ class Test6Behavior extends ModelBehavior{ - function setup(&$model, $config = null) { + function setup($model, $config = null) { $model->bindModel( array('hasAndBelongsToMany' => array('Tag')) ); @@ -403,7 +404,7 @@ class Test6Behavior extends ModelBehavior{ * @subpackage cake.tests.cases.libs.model */ class Test7Behavior extends ModelBehavior{ - function setup(&$model, $config = null) { + function setup($model, $config = null) { $model->bindModel( array('hasOne' => array('Attachment')) ); @@ -429,16 +430,6 @@ class BehaviorCollectionTest extends CakeTestCase { 'core.attachment', 'core.tag', 'core.articles_tag' ); -/** - * tearDown method - * - * @access public - * @return void - */ - function endTest() { - ClassRegistry::flush(); - } - /** * testBehaviorBinding method * @@ -937,7 +928,8 @@ class BehaviorCollectionTest extends CakeTestCase { $this->assertIdentical(trim(ob_get_clean()), 'afterDelete success'); $this->assertIdentical($results, true); } - /** + +/** * testBehaviorOnErrorCallback method * * @access public @@ -948,10 +940,11 @@ class BehaviorCollectionTest extends CakeTestCase { $Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'onError' => 'on')); ob_start(); - $Apple->Behaviors->Test->onError($Apple); + $Apple->Behaviors->Test->onError($Apple, ''); $this->assertIdentical(trim(ob_get_clean()), 'onError trigger success'); } - /** + +/** * testBehaviorValidateCallback method * * @access public @@ -1055,17 +1048,17 @@ class BehaviorCollectionTest extends CakeTestCase { $Apple->Behaviors->attach('Test3'); $Apple->beforeTestResult = array(); - $Apple->Behaviors->trigger($Apple, 'beforeTest'); + $Apple->Behaviors->trigger('beforeTest', array(&$Apple)); $expected = array('testbehavior', 'test2behavior', 'test3behavior'); $this->assertIdentical($Apple->beforeTestResult, $expected); $Apple->beforeTestResult = array(); - $Apple->Behaviors->trigger($Apple, 'beforeTest', array(), array('break' => true, 'breakOn' => 'test2behavior')); + $Apple->Behaviors->trigger('beforeTest', array(&$Apple), array('break' => true, 'breakOn' => 'test2behavior')); $expected = array('testbehavior', 'test2behavior'); $this->assertIdentical($Apple->beforeTestResult, $expected); $Apple->beforeTestResult = array(); - $Apple->Behaviors->trigger($Apple, 'beforeTest', array(), array('break' => true, 'breakOn' => array('test2behavior', 'test3behavior'))); + $Apple->Behaviors->trigger('beforeTest', array($Apple), array('break' => true, 'breakOn' => array('test2behavior', 'test3behavior'))); $expected = array('testbehavior', 'test2behavior'); $this->assertIdentical($Apple->beforeTestResult, $expected); } @@ -1130,6 +1123,6 @@ class BehaviorCollectionTest extends CakeTestCase { $Sample->Behaviors->attach('Test2'); $Sample->Behaviors->detach('Test3'); - $Sample->Behaviors->trigger($Sample, 'beforeTest'); + $Sample->Behaviors->trigger('beforeTest', array(&$Sample)); } } diff --git a/cake/tests/cases/libs/object_collection.test.php b/cake/tests/cases/libs/object_collection.test.php index 91f7080e1..fd51cbecd 100644 --- a/cake/tests/cases/libs/object_collection.test.php +++ b/cake/tests/cases/libs/object_collection.test.php @@ -334,7 +334,7 @@ class ObjectCollectionTest extends CakeTestCase { $this->Objects->TriggerMockSecond->expects($this->once()) ->method('callback') ->with(array('value')) - ->will($this->returnValue('new value')); + ->will($this->returnValue(array('new value'))); $result = $this->Objects->trigger( 'callback', From dc7ff8911dfbcb6442e1905cb90406abd9b0ac67 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 18:02:45 -0500 Subject: [PATCH 245/378] Fixing tests in ComponentCollection and HelperCollection as return of trigger now depends on the triggered objects. Removing annoying test that broke anytime something changed in Model. --- .../libs/controller/component_collection.test.php | 6 +++--- cake/tests/cases/libs/set.test.php | 14 -------------- .../cases/libs/view/helper_collection.test.php | 4 ++-- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/cake/tests/cases/libs/controller/component_collection.test.php b/cake/tests/cases/libs/controller/component_collection.test.php index d41f74095..ff96199b1 100644 --- a/cake/tests/cases/libs/controller/component_collection.test.php +++ b/cake/tests/cases/libs/controller/component_collection.test.php @@ -150,7 +150,7 @@ class ComponentCollectionTest extends CakeTestCase { $this->mockObjects[] = $this->Components->TriggerMockCookie; $this->mockObjects[] = $this->Components->TriggerMockSecurity; - $this->assertTrue($this->Components->trigger('startup', array(&$controller))); + $this->assertNull($this->Components->trigger('startup', array(&$controller))); } /** @@ -174,7 +174,7 @@ class ComponentCollectionTest extends CakeTestCase { $this->mockObjects[] = $this->Components->TriggerMockSecurity; $result = $this->Components->trigger('initialize', array(&$controller), array('triggerDisabled' => true)); - $this->assertTrue($result); + $this->assertNull($result); } /** @@ -197,7 +197,7 @@ class ComponentCollectionTest extends CakeTestCase { $this->Components->disable('TriggerMockSecurity'); - $this->assertTrue($this->Components->trigger('startup', array(&$controller))); + $this->assertNull($this->Components->trigger('startup', array(&$controller))); } /** diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index 01fb97663..1075b6cf7 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -2115,20 +2115,6 @@ class SetTest extends CakeTestCase { $result = Set::reverse($class); $this->assertEquals($result, $expected); - $model = new Model(array('id' => false, 'name' => 'Model', 'table' => false)); - $expected = array( - 'Behaviors' => array('modelName' => 'Model'), - 'useDbConfig' => 'default', 'useTable' => false, 'displayField' => null, 'id' => false, 'data' => array(), 'table' => 'models', 'primaryKey' => 'id', 'validate' => array(), - 'validationErrors' => array(), 'tablePrefix' => null, 'name' => 'Model', 'alias' => 'Model', 'tableToModel' => array(), 'logTransactions' => false, 'cacheQueries' => false, - 'belongsTo' => array(), 'hasOne' => array(), 'hasMany' => array(), 'hasAndBelongsToMany' => array(), 'actsAs' => null, 'whitelist' => array(), 'cacheSources' => true, - 'findQueryType' => null, 'recursive' => 1, 'order' => null, 'virtualFields' => array(), -); - $result = Set::reverse($model); - - ksort($result); - ksort($expected); - $this->assertEquals($result, $expected); - $class = new stdClass; $class->User = new stdClass; $class->User->id = 100; diff --git a/cake/tests/cases/libs/view/helper_collection.test.php b/cake/tests/cases/libs/view/helper_collection.test.php index 8d60f0109..403bbc8e7 100644 --- a/cake/tests/cases/libs/view/helper_collection.test.php +++ b/cake/tests/cases/libs/view/helper_collection.test.php @@ -137,7 +137,7 @@ class HelperCollectionTest extends CakeTestCase { $this->mockObjects[] = $this->Helpers->TriggerMockForm; - $this->assertTrue($this->Helpers->trigger('beforeRender', array('one', 'two'))); + $this->assertNull($this->Helpers->trigger('beforeRender', array('one', 'two'))); } /** @@ -163,7 +163,7 @@ class HelperCollectionTest extends CakeTestCase { $this->Helpers->disable('TriggerMockForm'); - $this->assertTrue($this->Helpers->trigger('beforeRender', array('one', 'two'))); + $this->assertNull($this->Helpers->trigger('beforeRender', array('one', 'two'))); } /** From f3445cd94152c478fc30700307a8c824815574ca Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 18:04:47 -0500 Subject: [PATCH 246/378] Making ModelBehavior::beforeFind() return true by default. Since returning null causes the find to abort, behaviors should return true if they are not going to return a query array. --- cake/libs/model/model_behavior.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/model_behavior.php b/cake/libs/model/model_behavior.php index 46ad69165..d0093e95e 100644 --- a/cake/libs/model/model_behavior.php +++ b/cake/libs/model/model_behavior.php @@ -80,10 +80,13 @@ class ModelBehavior extends Object { * * @param object $model Model using this behavior * @param array $queryData Data used to execute this query, i.e. conditions, order, etc. - * @return mixed False or null will abort the operation. You should array will replace the value of $query. + * @return mixed False or null will abort the operation. You can return an array to replace the + * $query that will be eventually run. * @access public */ - public function beforeFind($model, $query) { } + public function beforeFind($model, $query) { + return true; + } /** * After find callback. Can be used to modify any results returned by find and findAll. From 017385d61c6059f3e546a2da6cb6957a2b34461d Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 20:21:14 -0500 Subject: [PATCH 247/378] Fixing most of the strict errors in the helper test suite. --- cake/libs/view/helpers/form.php | 3 ++- cake/libs/view/helpers/js.php | 15 --------------- cake/tests/cases/libs/view/helper.test.php | 8 ++++---- cake/tests/cases/libs/view/helpers/form.test.php | 10 +++++----- cake/tests/cases/libs/view/helpers/rss.test.php | 4 ++-- 5 files changed, 13 insertions(+), 27 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index a92b3fd41..06a465e84 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -540,7 +540,8 @@ class FormHelper extends AppHelper { if ($text === null) { if (strpos($fieldName, '.') !== false) { - $text = array_pop(explode('.', $fieldName)); + $fieldElements = explode('.', $fieldName); + $text = array_pop($fieldElements); } else { $text = $fieldName; } diff --git a/cake/libs/view/helpers/js.php b/cake/libs/view/helpers/js.php index 9fcecaab9..41f0ffbd5 100644 --- a/cake/libs/view/helpers/js.php +++ b/cake/libs/view/helpers/js.php @@ -155,20 +155,6 @@ class JsHelper extends AppHelper { trigger_error(__('JsHelper:: Missing Method %s is undefined', $method), E_USER_WARNING); } -/** - * Workaround for Object::Object() existing. Since Object::object exists, it does not - * fall into call__ and is not passed onto the engine helper. See JsBaseEngineHelper::object() for - * more information on this method. - * - * @param mixed $data Data to convert into JSON - * @param array $options Options to use for encoding JSON. See JsBaseEngineHelper::object() for more details. - * @return string encoded JSON - * @deprecated Remove when support for PHP4 and Object::object are removed. - */ - public function object($data = array(), $options = array()) { - return $this->{$this->__engineName}->object($data, $options); - } - /** * Overwrite inherited Helper::value() * See JsBaseEngineHelper::value() for more information on this method. @@ -203,7 +189,6 @@ class JsHelper extends AppHelper { */ public function writeBuffer($options = array()) { $domReady = $this->request->is('ajax'); - // $domReady = isset($this->params['isAjax']) ? !$this->params['isAjax'] : true; $defaults = array( 'onDomReady' => $domReady, 'inline' => true, 'cache' => false, 'clear' => true, 'safe' => true diff --git a/cake/tests/cases/libs/view/helper.test.php b/cake/tests/cases/libs/view/helper.test.php index ba401fe6e..4ef761091 100644 --- a/cake/tests/cases/libs/view/helper.test.php +++ b/cake/tests/cases/libs/view/helper.test.php @@ -41,7 +41,7 @@ class HelperTestPost extends Model { * @access public * @return void */ - function schema() { + function schema($field = false) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), 'title' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), @@ -85,7 +85,7 @@ class HelperTestComment extends Model { * @access public * @return void */ - function schema() { + function schema($field = false) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), 'author_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), @@ -120,7 +120,7 @@ class HelperTestTag extends Model { * @access public * @return void */ - function schema() { + function schema($field = false) { $this->_schema = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), 'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), @@ -153,7 +153,7 @@ class HelperTestPostsTag extends Model { * @access public * @return void */ - function schema() { + function schema($field = false) { $this->_schema = array( 'helper_test_post_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), 'helper_test_tag_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 143570711..8c01f95eb 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -221,7 +221,7 @@ class ContactNonStandardPk extends Contact { * @access public * @return void */ - function schema() { + function schema($field = false) { $this->_schema = parent::schema(); $this->_schema['pk'] = $this->_schema['id']; unset($this->_schema['id']); @@ -389,7 +389,7 @@ class OpenidUrl extends CakeTestModel { * @access public * @return void */ - function beforeValidate() { + function beforeValidate($options = array()) { $this->invalidate('openid_not_registered'); return true; } @@ -458,7 +458,7 @@ class ValidateUser extends CakeTestModel { * @access public * @return void */ - function beforeValidate() { + function beforeValidate($options = array()) { $this->invalidate('email'); return false; } @@ -537,7 +537,7 @@ class ValidateProfile extends CakeTestModel { * @access public * @return void */ - function beforeValidate() { + function beforeValidate($options = array()) { $this->invalidate('full_name'); $this->invalidate('city'); return false; @@ -607,7 +607,7 @@ class ValidateItem extends CakeTestModel { * @access public * @return void */ - function beforeValidate() { + function beforeValidate($options = array()) { $this->invalidate('description'); return false; } diff --git a/cake/tests/cases/libs/view/helpers/rss.test.php b/cake/tests/cases/libs/view/helpers/rss.test.php index afc3e54e9..f836d890f 100644 --- a/cake/tests/cases/libs/view/helpers/rss.test.php +++ b/cake/tests/cases/libs/view/helpers/rss.test.php @@ -108,7 +108,7 @@ class RssHelperTest extends CakeTestCase { 'title', '/title', 'Rss->url('/', true), '/link', ' array('url' => RssHelper::url('/test.flv', true)), + 'enclosure' => array('url' => $this->Rss->url('/test.flv', true)), ' Date: Sun, 12 Dec 2010 23:48:04 -0200 Subject: [PATCH 248/378] Renamed setAuthConfig to configAuth, and setProxyConfig to configProxy. --- cake/libs/http_socket.php | 6 +++--- cake/tests/cases/libs/http_socket.test.php | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 0af827f44..5c58745c6 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -181,7 +181,7 @@ class HttpSocket extends CakeSocket { * @param string $pass Password for authentication * @return void */ - public function setAuthConfig($method, $user = null, $pass = null) { + public function configAuth($method, $user = null, $pass = null) { if (empty($method)) { $this->_auth = array(); return; @@ -203,7 +203,7 @@ class HttpSocket extends CakeSocket { * @param string $pass Password to proxy authentication * @return void */ - public function setProxyConfig($host, $port = 3128, $method = null, $user = null, $pass = null) { + public function configProxy($host, $port = 3128, $method = null, $user = null, $pass = null) { if (empty($host)) { $this->_proxy = array(); return; @@ -310,7 +310,7 @@ class HttpSocket extends CakeSocket { } if (isset($this->request['uri']['user'], $this->request['uri']['pass'])) { - $this->setAuthConfig('Basic', $this->request['uri']['user'], $this->request['uri']['pass']); + $this->configAuth('Basic', $this->request['uri']['user'], $this->request['uri']['pass']); } $this->_setAuth(); $this->request['auth'] = $this->_auth; diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 895b62e08..73c44fe62 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -715,7 +715,7 @@ class HttpSocketTest extends CakeTestCase { $this->Socket->expects($this->any())->method('connect')->will($this->returnValue(true)); $this->Socket->expects($this->any())->method('read')->will($this->returnValue(false)); - $this->Socket->setProxyConfig('proxy.server', 123); + $this->Socket->configProxy('proxy.server', 123); $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n\r\n"; $this->Socket->request('http://www.cakephp.org/'); $this->assertEqual($this->Socket->request['raw'], $expected); @@ -745,7 +745,7 @@ class HttpSocketTest extends CakeTestCase { $this->assertEqual($this->Socket->request['proxy'], $expected); $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nProxy-Authorization: Test mark.secret\r\n\r\n"; - $this->Socket->setProxyConfig('proxy.server', 123, 'Test', 'mark', 'secret'); + $this->Socket->configProxy('proxy.server', 123, 'Test', 'mark', 'secret'); $this->Socket->request('http://www.cakephp.org/'); $this->assertEqual($this->Socket->request['raw'], $expected); $this->assertEqual($this->Socket->config['host'], 'proxy.server'); @@ -759,7 +759,7 @@ class HttpSocketTest extends CakeTestCase { ); $this->assertEqual($this->Socket->request['proxy'], $expected); - $this->Socket->setAuthConfig('Test', 'login', 'passwd'); + $this->Socket->configAuth('Test', 'login', 'passwd'); $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nProxy-Authorization: Test mark.secret\r\nAuthorization: Test login.passwd\r\n\r\n"; $this->Socket->request('http://www.cakephp.org/'); $this->assertEqual($this->Socket->request['raw'], $expected); @@ -879,11 +879,11 @@ class HttpSocketTest extends CakeTestCase { $socket->get('http://mark:secret@example.com/test'); $this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); - $socket->setAuthConfig(false); + $socket->configAuth(false); $socket->get('http://example.com/test'); $this->assertFalse(strpos($socket->request['header'], 'Authorization:')); - $socket->setAuthConfig('Test', 'mark', 'passwd'); + $socket->configAuth('Test', 'mark', 'passwd'); $socket->get('http://example.com/test'); $this->assertTrue(strpos($socket->request['header'], 'Authorization: Test mark.passwd') !== false); } From f84871ae47a4298f419a31d108ca7366519306c6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 20:55:33 -0500 Subject: [PATCH 249/378] Fixing strict errors that were causing shell tests to fail. Fixing test case for bake test that has been getting skipped. --- cake/console/shells/bake.php | 2 +- cake/console/shells/tasks/model.php | 2 +- cake/libs/folder.php | 28 +++++-------------- cake/tests/cases/console/shells/bake.test.php | 13 ++++----- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/cake/console/shells/bake.php b/cake/console/shells/bake.php index 77dd36201..7e4dbb016 100644 --- a/cake/console/shells/bake.php +++ b/cake/console/shells/bake.php @@ -186,7 +186,7 @@ class BakeShell extends Shell { } else { $this->error(__('Bake All could not continue without a valid model')); } - $this->_stop(); + return $this->_stop(); } /** diff --git a/cake/console/shells/tasks/model.php b/cake/console/shells/tasks/model.php index 7616ef14c..ffa06640a 100644 --- a/cake/console/shells/tasks/model.php +++ b/cake/console/shells/tasks/model.php @@ -701,7 +701,7 @@ class ModelTask extends BakeTask { protected function _generatePossibleKeys() { $possible = array(); foreach ($this->_tables as $otherTable) { - $tempOtherModel = & new Model(array('table' => $otherTable, 'ds' => $this->connection)); + $tempOtherModel = new Model(array('table' => $otherTable, 'ds' => $this->connection)); $modelFieldsTemp = $tempOtherModel->schema(true); foreach ($modelFieldsTemp as $fieldName => $field) { if ($field['type'] == 'integer' || $field['type'] == 'string') { diff --git a/cake/libs/folder.php b/cake/libs/folder.php index 551e05876..733315a1a 100644 --- a/cake/libs/folder.php +++ b/cake/libs/folder.php @@ -240,10 +240,8 @@ class Folder { * * @param string $path Path to check * @return boolean true if windows path, false otherwise - * @access public - * @static */ - function isWindowsPath($path) { + public static function isWindowsPath($path) { return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\'); } @@ -252,10 +250,8 @@ class Folder { * * @param string $path Path to check * @return bool true if path is absolute. - * @access public - * @static */ - function isAbsolute($path) { + public static function isAbsolute($path) { return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\'); } @@ -264,10 +260,8 @@ class Folder { * * @param string $path Path to check * @return string Set of slashes ("\\" or "/") - * @access public - * @static */ - function normalizePath($path) { + public static function normalizePath($path) { return Folder::correctSlashFor($path); } @@ -276,10 +270,8 @@ class Folder { * * @param string $path Path to check * @return string Set of slashes ("\\" or "/") - * @access public - * @static */ - function correctSlashFor($path) { + public static function correctSlashFor($path) { return (Folder::isWindowsPath($path)) ? '\\' : '/'; } @@ -288,10 +280,8 @@ class Folder { * * @param string $path Path to check * @return string Path with ending slash - * @access public - * @static */ - function slashTerm($path) { + public static function slashTerm($path) { if (Folder::isSlashTerm($path)) { return $path; } @@ -304,10 +294,8 @@ class Folder { * @param string $path Path * @param string $element Element to and at end of path * @return string Combined path - * @access public - * @static */ - function addPathElement($path, $element) { + public static function addPathElement($path, $element) { return rtrim($path, DS) . DS . $element; } @@ -755,10 +743,8 @@ class Folder { * * @param string $path Path to check * @return boolean true if path ends with slash, false otherwise - * @access public - * @static */ - function isSlashTerm($path) { + public static function isSlashTerm($path) { $lastChar = $path[strlen($path) - 1]; return $lastChar === '/' || $lastChar === '\\'; } diff --git a/cake/tests/cases/console/shells/bake.test.php b/cake/tests/cases/console/shells/bake.test.php index 6f68e8bb3..89383b1ff 100644 --- a/cake/tests/cases/console/shells/bake.test.php +++ b/cake/tests/cases/console/shells/bake.test.php @@ -20,9 +20,9 @@ */ App::import('Shell', 'Shell', false); App::import('Shell', 'Bake', false); -App::import('Shell', 'tasks/model', false); -App::import('Shell', 'tasks/controller', false); -App::import('Shell', 'tasks/db_config', false); +App::import('Shell', 'tasks/model'); +App::import('Shell', 'tasks/controller'); +App::import('Shell', 'tasks/db_config'); App::import('Core', 'Controller'); require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; @@ -94,12 +94,11 @@ class BakeShellTest extends CakeTestCase { $this->Shell->Controller->expects($this->once())->method('bake')->will($this->returnValue(true)); $this->Shell->View->expects($this->once())->method('execute'); - $this->Shell->expects($this->at(1))->method('out')->with('Bake All'); - $this->Shell->expects($this->at(3))->method('out')->with('User Model was baked.'); + $this->Shell->expects($this->once())->method('_stop'); + $this->Shell->expects($this->at(0))->method('out')->with('Bake All'); $this->Shell->expects($this->at(5))->method('out')->with('Bake All complete'); - $this->Shell->expects($this->at(7))->method('out')->with('User Views were baked.'); - $this->Shell->expects($this->at(8))->method('out')->with('Bake All complete'); + $this->Shell->connection = ''; $this->Shell->params = array(); $this->Shell->args = array('User'); $this->Shell->all(); From 0ac8d042417899c51316ec499c70b9c74bb4eb5b Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 21:02:42 -0500 Subject: [PATCH 250/378] Fixing more strict warnings. --- cake/libs/dispatcher.php | 3 ++- cake/libs/file.php | 2 +- cake/tests/cases/libs/dispatcher.test.php | 9 ++++----- cake/tests/cases/libs/folder.test.php | 4 ++-- cake/tests/cases/libs/router.test.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cake/libs/dispatcher.php b/cake/libs/dispatcher.php index cb14d18ba..4f35138c8 100644 --- a/cake/libs/dispatcher.php +++ b/cake/libs/dispatcher.php @@ -315,7 +315,8 @@ class Dispatcher { $this->_stop(); } $controller = null; - $ext = array_pop(explode('.', $url)); + $pathSegments = explode('.', $url); + $ext = array_pop($pathSegments); $parts = explode('/', $url); $assetFile = null; diff --git a/cake/libs/file.php b/cake/libs/file.php index 0151181f5..47f922d9d 100644 --- a/cake/libs/file.php +++ b/cake/libs/file.php @@ -212,7 +212,7 @@ class File { * @param string $data Data to prepare for writing. * @return string The with converted line endings. */ - public function prepare($data, $forceWindows = false) { + public static function prepare($data, $forceWindows = false) { $lineBreak = "\n"; if (DIRECTORY_SEPARATOR == '\\' || $forceWindows === true) { $lineBreak = "\r\n"; diff --git a/cake/tests/cases/libs/dispatcher.test.php b/cake/tests/cases/libs/dispatcher.test.php index 35f161e7a..0192e6740 100644 --- a/cake/tests/cases/libs/dispatcher.test.php +++ b/cake/tests/cases/libs/dispatcher.test.php @@ -49,12 +49,11 @@ class TestDispatcher extends Dispatcher { * invoke method * * @param mixed $controller - * @param mixed $params - * @param mixed $missingAction + * @param mixed $request * @return void */ - protected function _invoke(&$controller, $params) { - if ($result = parent::_invoke($controller, $params)) { + protected function _invoke(Controller $controller, CakeRequest $request) { + if ($result = parent::_invoke($controller, $request)) { if ($result[0] === 'missingAction') { return $result; } @@ -192,7 +191,7 @@ class SomePagesController extends AppController { * * @return void */ - public function redirect() { + public function redirect($url, $status = null, $exit = true) { echo 'this should not be accessible'; } } diff --git a/cake/tests/cases/libs/folder.test.php b/cake/tests/cases/libs/folder.test.php index 428520610..472385243 100644 --- a/cake/tests/cases/libs/folder.test.php +++ b/cake/tests/cases/libs/folder.test.php @@ -195,8 +195,8 @@ class FolderTest extends CakeTestCase { $this->assertFalse($result); $expected = $new . ' is a file'; - $result = array_pop($Folder->errors()); - $this->assertEqual($result, $expected); + $result = $Folder->errors(); + $this->assertEqual($result[0], $expected); $new = TMP . 'test_folder_new'; $result = $Folder->create($new); diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 92c3f0971..ffe168ac8 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -2273,7 +2273,7 @@ class RouterTest extends CakeTestCase { * @return void */ function testPatternOnAction() { - $route =& new CakeRoute( + $route = new CakeRoute( '/blog/:action/*', array('controller' => 'blog_posts'), array('action' => 'other|actions') From 2fe60142f53381d91b2000261447a5dd3f4673d5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 21:09:56 -0500 Subject: [PATCH 251/378] Fixing more strict warnings. --- cake/libs/cake_session.php | 3 +-- cake/libs/controller/cake_error_controller.php | 2 +- cake/libs/debugger.php | 2 +- cake/libs/validation.php | 5 +++-- cake/libs/xml.php | 4 ++-- cake/tests/cases/libs/set.test.php | 3 +-- cake/tests/cases/libs/validation.test.php | 8 ++++---- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php index c590f2881..91ed52f02 100644 --- a/cake/libs/cake_session.php +++ b/cake/libs/cake_session.php @@ -393,9 +393,8 @@ class CakeSession { * Returns all session variables. * * @return mixed Full $_SESSION array, or false on error. - * @access private */ - function __returnSessionVars() { + private static function __returnSessionVars() { if (!empty($_SESSION)) { return $_SESSION; } diff --git a/cake/libs/controller/cake_error_controller.php b/cake/libs/controller/cake_error_controller.php index 765e79f30..443024840 100644 --- a/cake/libs/controller/cake_error_controller.php +++ b/cake/libs/controller/cake_error_controller.php @@ -26,7 +26,7 @@ class CakeErrorController extends AppController { function __construct() { parent::__construct(); $this->_set(Router::getPaths()); - $this->request = $this->params = Router::getRequest(false); + $this->request = Router::getRequest(false); $this->constructClasses(); $this->Components->trigger('initialize', array(&$this)); $this->_set(array('cacheAction' => false, 'viewPath' => 'errors')); diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php index f07ab78c6..33f665a2c 100644 --- a/cake/libs/debugger.php +++ b/cake/libs/debugger.php @@ -236,7 +236,7 @@ class Debugger { * @param array $context Context * @return boolean true if error was handled */ - public function showError($code, $description, $file = null, $line = null, $context = null) { + public static function showError($code, $description, $file = null, $line = null, $context = null) { $_this = Debugger::getInstance(); if (empty($file)) { diff --git a/cake/libs/validation.php b/cake/libs/validation.php index 5af6db748..adda137c0 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -415,7 +415,8 @@ class Validation { if (is_array($check)) { return self::extension(array_shift($check), $extensions); } - $extension = strtolower(array_pop(explode('.', $check))); + $pathSegments = explode('.', $check); + $extension = strtolower(array_pop($pathSegments)); foreach ($extensions as $value) { if ($extension == strtolower($value)) { return true; @@ -431,7 +432,7 @@ class Validation { * @param string $ipVersion The IP Protocol version to validate against * @return boolean Success */ - public function ip($check, $type = 'both') { + public static function ip($check, $type = 'both') { $type = strtolower($type); $flags = array(); if ($type === 'ipv4' || $type === 'both') { diff --git a/cake/libs/xml.php b/cake/libs/xml.php index 160572b95..0027d1631 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -182,7 +182,7 @@ class Xml { * @param string $format Either 'attribute' or 'tags'. This determines where nested keys go. * @return void */ - protected function _fromArray(&$dom, &$node, &$data, $format) { + protected static function _fromArray(&$dom, &$node, &$data, $format) { if (empty($data) || !is_array($data)) { return; } @@ -237,7 +237,7 @@ class Xml { * @param array $data Array with informations to create childs * @return void */ - private function __createChild($data) { + private static function __createChild($data) { extract($data); $childNS = $childValue = null; if (is_array($value)) { diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index 1075b6cf7..a4d6a5427 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -2706,10 +2706,9 @@ class SetTest extends CakeTestCase { /** * Helper method to test Set::apply() * - * @access protected * @return void */ - function _method($val1, $val2) { + static function _method($val1, $val2) { $val1 += $val2; return $val1; } diff --git a/cake/tests/cases/libs/validation.test.php b/cake/tests/cases/libs/validation.test.php index a794453d8..002902a9d 100644 --- a/cake/tests/cases/libs/validation.test.php +++ b/cake/tests/cases/libs/validation.test.php @@ -34,7 +34,7 @@ class CustomValidator { * @return boolean * @access public */ - function customValidate($check) { + static function customValidate($check) { return (bool)preg_match('/^[0-9]{3}$/', $check); } } @@ -53,7 +53,7 @@ class TestNlValidation { * @param string $check * @return void */ - function postal($check) { + static function postal($check) { return true; } /** @@ -61,7 +61,7 @@ class TestNlValidation { * * @return void */ - function ssn($check) { + static function ssn($check) { return true; } } @@ -80,7 +80,7 @@ class TestDeValidation { * @param string $check * @return void */ - function phone($check) { + static function phone($check) { return true; } } From dfb76d67da6e14b4c3b01ebfe371518ca9a62ed1 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 14 Dec 2010 00:16:45 -0200 Subject: [PATCH 252/378] Created the HttpResponse to get HttpSocket responses. --- cake/libs/http_response.php | 180 +++++++++++++++++++ cake/tests/cases/libs/all_socket.test.php | 1 + cake/tests/cases/libs/http_response.test.php | 157 ++++++++++++++++ 3 files changed, 338 insertions(+) create mode 100644 cake/libs/http_response.php create mode 100644 cake/tests/cases/libs/http_response.test.php diff --git a/cake/libs/http_response.php b/cake/libs/http_response.php new file mode 100644 index 000000000..ef54423ab --- /dev/null +++ b/cake/libs/http_response.php @@ -0,0 +1,180 @@ +body; + } + +/** + * Get header in case insensitive + * + * @param string $name Header name + * @return mixed String if header exists or null + */ + public function getHeader($name) { + if (isset($this->headers[$name])) { + return $this->headers[$name]; + } + foreach ($this->headers as $key => $value) { + if (strcasecmp($key, $name) == 0) { + return $value; + } + } + return null; + } + +/** + * If return is 200 (OK) + * + * @return boolean + */ + public function isOk() { + return $this->code == 200; + } + +/** + * ArrayAccess - Offset Exists + * + * @param mixed $offset + * @return boolean + */ + public function offsetExists($offset) { + return in_array($offset, array('raw', 'status', 'header', 'body', 'cookies')); + } + +/** + * ArrayAccess - Offset Get + * + * @param mixed $offset + * @return mixed + */ + public function offsetGet($offset) { + switch ($offset) { + case 'raw': + $firstLineLength = strpos($this->raw, "\r\n") + 2; + return array( + 'status-line' => $this->httpVersion . ' ' . $this->code . ' ' . $this->reasonPhrase, + 'header' => substr($this->raw, $firstLineLength, strpos($this->raw, "\r\n\r\n") - $firstLineLength), + 'body' => $this->body, + 'response' => $this->raw + ); + case 'status': + return array( + 'http-version' => $this->httpVersion, + 'code' => $this->code, + 'reason-phrase' => $this->reasonPhrase + ); + case 'header': + return $this->headers; + case 'body': + return $this->body; + case 'cookies': + return $this->cookies; + } + return null; + } + +/** + * ArrayAccess - 0ffset Set + * + * @param mixed $offset + * @param mixed $value + * @return void + */ + public function offsetSet($offset, $value) { + return; + } + +/** + * ArrayAccess - Offset Unset + * + * @param mixed @offset + * @return void + */ + public function offsetUnset($offset) { + return; + } + +/** + * Instance as string + * + * @return string + */ + public function __toString() { + return $this->body(); + } + +} diff --git a/cake/tests/cases/libs/all_socket.test.php b/cake/tests/cases/libs/all_socket.test.php index 896738957..ec276f580 100644 --- a/cake/tests/cases/libs/all_socket.test.php +++ b/cake/tests/cases/libs/all_socket.test.php @@ -38,6 +38,7 @@ class AllSocketTest extends PHPUnit_Framework_TestSuite { $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_socket.test.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'http_socket.test.php'); + $suite->addTestFile(CAKE_TEST_CASES . DS . 'libs' . DS . 'http_response.test.php'); $suite->addTestDirectory(CORE_TEST_CASES . DS . 'libs' . DS . 'http'); return $suite; } diff --git a/cake/tests/cases/libs/http_response.test.php b/cake/tests/cases/libs/http_response.test.php new file mode 100644 index 000000000..debac0735 --- /dev/null +++ b/cake/tests/cases/libs/http_response.test.php @@ -0,0 +1,157 @@ + + * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice + * + * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests + * @package cake + * @subpackage cake.tests.cases.libs + * @since CakePHP(tm) v 1.2.0.4206 + * @license MIT License (http://www.opensource.org/licenses/mit-license.php) + */ +App::import('Core', 'HttpResponse'); + +/** + * HttpResponseTest class + * + * @package cake + * @subpackage cake.tests.cases.libs + */ +class HttpResponseTest extends CakeTestCase { +/** + * This function sets up a HttpResponse + * + * @return void + */ + public function setUp() { + $this->HttpResponse = new HttpResponse(); + } + +/** + * testBody + * + * @return void + */ + public function testBody() { + $this->HttpResponse->body = 'testing'; + $this->assertEqual($this->HttpResponse->body(), 'testing'); + + $this->HttpResponse->body = null; + $this->assertIdentical($this->HttpResponse->body(), ''); + } + +/** + * testToString + * + * @return void + */ + public function testToString() { + $this->HttpResponse->body = 'other test'; + $this->assertEqual($this->HttpResponse->body(), 'other test'); + $this->assertEqual((string)$this->HttpResponse, 'other test'); + $this->assertTrue(strpos($this->HttpResponse, 'test') > 0); + + $this->HttpResponse->body = null; + $this->assertEqual((string)$this->HttpResponse, ''); + } + +/** + * testGetHeadr + * + * @return void + */ + public function testGetHeader() { + $this->HttpResponse->headers = array( + 'foo' => 'Bar', + 'Some' => 'ok', + 'HeAdEr' => 'value', + 'content-Type' => 'text/plain' + ); + + $this->assertEqual($this->HttpResponse->getHeader('foo'), 'Bar'); + $this->assertEqual($this->HttpResponse->getHeader('Foo'), 'Bar'); + $this->assertEqual($this->HttpResponse->getHeader('FOO'), 'Bar'); + $this->assertEqual($this->HttpResponse->getHeader('header'), 'value'); + $this->assertEqual($this->HttpResponse->getHeader('Content-Type'), 'text/plain'); + $this->assertIdentical($this->HttpResponse->getHeader(0), null); + } + +/** + * testIsOk + * + * @return void + */ + public function testIsOk() { + $this->HttpResponse->code = 0; + $this->assertFalse($this->HttpResponse->isOk()); + $this->HttpResponse->code = -1; + $this->assertFalse($this->HttpResponse->isOk()); + $this->HttpResponse->code = 201; + $this->assertFalse($this->HttpResponse->isOk()); + $this->HttpResponse->code = 'what?'; + $this->assertFalse($this->HttpResponse->isOk()); + $this->HttpResponse->code = 200; + $this->assertTrue($this->HttpResponse->isOk()); + } + +/** + * testArrayAccess + * + * @return void + */ + public function testArrayAccess() { + $this->HttpResponse->httpVersion = 'HTTP/1.1'; + $this->HttpResponse->code = 200; + $this->HttpResponse->reasonPhrase = 'OK'; + $this->HttpResponse->headers = array( + 'Server' => 'CakePHP', + 'ContEnt-Type' => 'text/plain' + ); + $this->HttpResponse->cookies = array( + 'foo' => array('value' => 'bar'), + 'bar' => array('value' => 'foo') + ); + $this->HttpResponse->body = 'This is a test!'; + $this->HttpResponse->raw = "HTTP/1.1 200 OK\r\nServer: CakePHP\r\nContEnt-Type: text/plain\r\n\r\nThis is a test!"; + + $expected1 = 'HTTP/1.1 200 OK'; + $this->assertEqual($this->HttpResponse['raw']['status-line'], $expected1); + $expected2 = "Server: CakePHP\r\nContEnt-Type: text/plain"; + $this->assertEqual($this->HttpResponse['raw']['header'], $expected2); + $expected3 = 'This is a test!'; + $this->assertEqual($this->HttpResponse['raw']['body'], $expected3); + $expected = $expected1 . "\r\n" . $expected2 . "\r\n\r\n" . $expected3; + $this->assertEqual($this->HttpResponse['raw']['response'], $expected); + + $expected = 'HTTP/1.1'; + $this->assertEqual($this->HttpResponse['status']['http-version'], $expected); + $expected = 200; + $this->assertEqual($this->HttpResponse['status']['code'], $expected); + $expected = 'OK'; + $this->assertEqual($this->HttpResponse['status']['reason-phrase'], $expected); + + $expected = array( + 'Server' => 'CakePHP', + 'ContEnt-Type' => 'text/plain' + ); + $this->assertEqual($this->HttpResponse['header'], $expected); + + $expected = 'This is a test!'; + $this->assertEqual($this->HttpResponse['body'], $expected); + + $expected = array( + 'foo' => array('value' => 'bar'), + 'bar' => array('value' => 'foo') + ); + $this->assertEqual($this->HttpResponse['cookies'], $expected); + } + +} \ No newline at end of file From f45027ecd87041be3a8f257664b661650a315bd7 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 14 Dec 2010 01:06:57 -0200 Subject: [PATCH 253/378] Adjusting HttpResponse responses in array to be more compatible. --- cake/libs/http_response.php | 9 +++++++-- cake/tests/cases/libs/http_response.test.php | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cake/libs/http_response.php b/cake/libs/http_response.php index ef54423ab..f0cc637c8 100644 --- a/cake/libs/http_response.php +++ b/cake/libs/http_response.php @@ -125,9 +125,14 @@ class HttpResponse implements ArrayAccess { switch ($offset) { case 'raw': $firstLineLength = strpos($this->raw, "\r\n") + 2; + if ($this->raw[$firstLineLength] === "\r") { + $header = null; + } else { + $header = substr($this->raw, $firstLineLength, strpos($this->raw, "\r\n\r\n") - $firstLineLength) . "\r\n"; + } return array( - 'status-line' => $this->httpVersion . ' ' . $this->code . ' ' . $this->reasonPhrase, - 'header' => substr($this->raw, $firstLineLength, strpos($this->raw, "\r\n\r\n") - $firstLineLength), + 'status-line' => $this->httpVersion . ' ' . $this->code . ' ' . $this->reasonPhrase . "\r\n", + 'header' => $header, 'body' => $this->body, 'response' => $this->raw ); diff --git a/cake/tests/cases/libs/http_response.test.php b/cake/tests/cases/libs/http_response.test.php index debac0735..6c3967a89 100644 --- a/cake/tests/cases/libs/http_response.test.php +++ b/cake/tests/cases/libs/http_response.test.php @@ -122,13 +122,13 @@ class HttpResponseTest extends CakeTestCase { $this->HttpResponse->body = 'This is a test!'; $this->HttpResponse->raw = "HTTP/1.1 200 OK\r\nServer: CakePHP\r\nContEnt-Type: text/plain\r\n\r\nThis is a test!"; - $expected1 = 'HTTP/1.1 200 OK'; + $expected1 = "HTTP/1.1 200 OK\r\n"; $this->assertEqual($this->HttpResponse['raw']['status-line'], $expected1); - $expected2 = "Server: CakePHP\r\nContEnt-Type: text/plain"; + $expected2 = "Server: CakePHP\r\nContEnt-Type: text/plain\r\n"; $this->assertEqual($this->HttpResponse['raw']['header'], $expected2); $expected3 = 'This is a test!'; $this->assertEqual($this->HttpResponse['raw']['body'], $expected3); - $expected = $expected1 . "\r\n" . $expected2 . "\r\n\r\n" . $expected3; + $expected = $expected1 . $expected2 . "\r\n" . $expected3; $this->assertEqual($this->HttpResponse['raw']['response'], $expected); $expected = 'HTTP/1.1'; @@ -152,6 +152,9 @@ class HttpResponseTest extends CakeTestCase { 'bar' => array('value' => 'foo') ); $this->assertEqual($this->HttpResponse['cookies'], $expected); + + $this->HttpResponse->raw = "HTTP/1.1 200 OK\r\n\r\nThis is a test!"; + $this->assertIdentical($this->HttpResponse['raw']['header'], null); } } \ No newline at end of file From 60a9d34027d9ab1d822fb75bcefe2c87bac7e4cf Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 14 Dec 2010 01:07:25 -0200 Subject: [PATCH 254/378] Updated the HttpSocket to use the new HttpResponse. --- cake/libs/http_socket.php | 99 +++++++------------ cake/tests/cases/libs/http_socket.test.php | 110 +++++++++------------ 2 files changed, 81 insertions(+), 128 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 5c58745c6..aa4769319 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -19,6 +19,7 @@ */ App::import('Core', 'CakeSocket'); App::import('Core', 'Router'); +App::import('Lib', 'HttpResponse'); /** * Cake network socket connection class. @@ -73,22 +74,7 @@ class HttpSocket extends CakeSocket { * * @var array */ - public $response = array( - 'raw' => array( - 'status-line' => null, - 'header' => null, - 'body' => null, - 'response' => null - ), - 'status' => array( - 'http-version' => null, - 'code' => null, - 'reason-phrase' => null - ), - 'header' => array(), - 'body' => '', - 'cookies' => array() - ); + public $response = null; /** * Configuration settings for the HttpSocket and the requests @@ -238,16 +224,15 @@ class HttpSocket extends CakeSocket { * method and provide a more granular interface. * * @param mixed $request Either an URI string, or an array defining host/uri - * @return mixed null on error, reference to request body on success + * @return mixed false on error, HttpResponse on success */ - public function &request($request = array()) { + public function request($request = array()) { $this->reset(false); if (is_string($request)) { $request = array('uri' => $request); } elseif (!is_array($request)) { - $return = false; - return $return; + return false; } if (!isset($request['uri'])) { @@ -338,7 +323,7 @@ class HttpSocket extends CakeSocket { } if ($this->quirksMode === false && $this->request['line'] === false) { - return $this->response = false; + return false; } $this->request['raw'] = ''; @@ -383,14 +368,14 @@ class HttpSocket extends CakeSocket { } $this->response = $this->_parseResponse($response); - if (!empty($this->response['cookies'])) { + if (!empty($this->response->cookies)) { if (!isset($this->config['request']['cookies'][$Host])) { $this->config['request']['cookies'][$Host] = array(); } - $this->config['request']['cookies'][$Host] = array_merge($this->config['request']['cookies'][$Host], $this->response['cookies']); + $this->config['request']['cookies'][$Host] = array_merge($this->config['request']['cookies'][$Host], $this->response->cookies); } - return $this->response['body']; + return $this->response; } /** @@ -416,7 +401,7 @@ class HttpSocket extends CakeSocket { * @param array $request An indexed array with indexes such as 'method' or uri * @return mixed Result of request, either false on failure or the response to the request. */ - public function &get($uri = null, $query = array(), $request = array()) { + public function get($uri = null, $query = array(), $request = array()) { if (!empty($query)) { $uri = $this->_parseUri($uri); if (isset($uri['query'])) { @@ -448,7 +433,7 @@ class HttpSocket extends CakeSocket { * @param array $request An indexed array with indexes such as 'method' or uri * @return mixed Result of request, either false on failure or the response to the request. */ - public function &post($uri = null, $data = array(), $request = array()) { + public function post($uri = null, $data = array(), $request = array()) { $request = Set::merge(array('method' => 'POST', 'uri' => $uri, 'body' => $data), $request); return $this->request($request); } @@ -461,7 +446,7 @@ class HttpSocket extends CakeSocket { * @param array $request An indexed array with indexes such as 'method' or uri * @return mixed Result of request */ - public function &put($uri = null, $data = array(), $request = array()) { + public function put($uri = null, $data = array(), $request = array()) { $request = Set::merge(array('method' => 'PUT', 'uri' => $uri, 'body' => $data), $request); return $this->request($request); } @@ -474,7 +459,7 @@ class HttpSocket extends CakeSocket { * @param array $request An indexed array with indexes such as 'method' or uri * @return mixed Result of request */ - public function &delete($uri = null, $data = array(), $request = array()) { + public function delete($uri = null, $data = array(), $request = array()) { $request = Set::merge(array('method' => 'DELETE', 'uri' => $uri, 'body' => $data), $request); return $this->request($request); } @@ -585,58 +570,40 @@ class HttpSocket extends CakeSocket { * Parses the given message and breaks it down in parts. * * @param string $message Message to parse - * @return array Parsed message (with indexed elements such as raw, status, header, body) + * @return object Parsed message as HttpResponse */ protected function _parseResponse($message) { - if (is_array($message)) { - return $message; - } elseif (!is_string($message)) { - return false; + if (!is_string($message)) { + throw new Exception(__('Invalid response.')); } - static $responseTemplate; - - if (empty($responseTemplate)) { - $classVars = get_class_vars(__CLASS__); - $responseTemplate = $classVars['response']; - } - - $response = $responseTemplate; - if (!preg_match("/^(.+\r\n)(.*)(?<=\r\n)\r\n/Us", $message, $match)) { - return false; + throw new Exception(__('Invalid HTTP response.')); } - list($null, $response['raw']['status-line'], $response['raw']['header']) = $match; - $response['raw']['response'] = $message; - $response['raw']['body'] = substr($message, strlen($match[0])); + $response = new HttpResponse(); - if (preg_match("/(.+) ([0-9]{3}) (.+)\r\n/DU", $response['raw']['status-line'], $match)) { - $response['status']['http-version'] = $match[1]; - $response['status']['code'] = (int)$match[2]; - $response['status']['reason-phrase'] = $match[3]; + list(, $statusLine, $header) = $match; + $response->raw = $message; + $response->body = (string)substr($message, strlen($match[0])); + + if (preg_match("/(.+) ([0-9]{3}) (.+)\r\n/DU", $statusLine, $match)) { + $response->httpVersion = $match[1]; + $response->code = $match[2]; + $response->reasonPhrase = $match[3]; } - $response['header'] = $this->_parseHeader($response['raw']['header']); - $transferEncoding = null; - if (isset($response['header']['Transfer-Encoding'])) { - $transferEncoding = $response['header']['Transfer-Encoding']; - } - $decoded = $this->_decodeBody($response['raw']['body'], $transferEncoding); - $response['body'] = $decoded['body']; + $response->headers = $this->_parseHeader($header); + $transferEncoding = $response->getHeader('Transfer-Encoding'); + $decoded = $this->_decodeBody($response->body, $transferEncoding); + $response->body = $decoded['body']; if (!empty($decoded['header'])) { - $response['header'] = $this->_parseHeader($this->_buildHeader($response['header']) . $this->_buildHeader($decoded['header'])); + $response->headers = $this->_parseHeader($this->_buildHeader($response->headers) . $this->_buildHeader($decoded['header'])); } - if (!empty($response['header'])) { - $response['cookies'] = $this->parseCookies($response['header']); - } - - foreach ($response['raw'] as $field => $val) { - if ($val === '') { - $response['raw'][$field] = null; - } + if (!empty($response->headers)) { + $response->cookies = $this->parseCookies($response->headers); } return $response; diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 73c44fe62..9dff42b8f 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -190,6 +190,19 @@ class TestHttpSocket extends HttpSocket { public function unescapeToken($token, $chars = null) { return parent::_unescapeToken($token, $chars); } + +/** + * Convenience method for testing protected method + * + * @param string $message + * @return object HttpResponse + */ + protected function _parseResponse($message) { + if (!is_string($message)) { + return false; + } + return parent::_parseResponse($message); + } } /** @@ -596,7 +609,7 @@ class HttpSocketTest extends CakeTestCase { $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); $this->Socket->expects($this->once())->method('write') ->with("GET / HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n\r\n"); - $response = $this->Socket->request($request); + $response = (string)$this->Socket->request($request); $this->assertEquals($response, "

    Hello, your lucky number is " . $number . "

    "); } @@ -622,22 +635,6 @@ class HttpSocketTest extends CakeTestCase { $this->assertFalse($this->Socket->connected); } -/** - * testRequestResultAsReference method - * - * @return void - */ - public function testRequestResultAsReference() { - $request = array('uri' => 'htpp://www.cakephp.org/'); - $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

    This is a cookie test!

    "; - $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); - $this->Socket->connected = true; - $data =& $this->Socket->request($request); - $this->assertEqual($data, $this->Socket->response['body']); - $data = 'new data'; - $this->assertEqual($data, $this->Socket->response['body']); - } - /** * testRequestWithResource * @@ -654,7 +651,7 @@ class HttpSocketTest extends CakeTestCase { $this->skipUnless($f, 'Can not write in TMP directory.'); $this->Socket->setContentResource($f); - $result = $this->Socket->request('http://www.cakephp.org/'); + $result = (string)$this->Socket->request('http://www.cakephp.org/'); $this->assertEqual($result, ''); $this->assertEqual($this->Socket->response['header']['Server'], 'CakeHttp Server'); fclose($f); @@ -662,7 +659,7 @@ class HttpSocketTest extends CakeTestCase { unlink(TMP . 'download.txt'); $this->Socket->setContentResource(false); - $result = $this->Socket->request('http://www.cakephp.org/'); + $result = (string)$this->Socket->request('http://www.cakephp.org/'); $this->assertEqual($result, '

    This is a test!

    '); } @@ -987,15 +984,6 @@ class HttpSocketTest extends CakeTestCase { public function testParseResponse() { $this->Socket->reset(); - $r = $this->Socket->parseResponse(array('foo' => 'bar')); - $this->assertEquals($r, array('foo' => 'bar')); - - $r = $this->Socket->parseResponse(true); - $this->assertEquals($r, false); - - $r = $this->Socket->parseResponse("HTTP Foo\r\nBar: La"); - $this->assertEquals($r, false); - $tests = array( 'simple-request' => array( 'response' => array( @@ -1004,10 +992,10 @@ class HttpSocketTest extends CakeTestCase { 'body' => "

    Hello World

    \r\n

    It's good to be html

    " ), 'expectations' => array( - 'status.http-version' => 'HTTP/1.x', - 'status.code' => 200, - 'status.reason-phrase' => 'OK', - 'header' => $this->Socket->parseHeader("Date: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\n"), + 'httpVersion' => 'HTTP/1.x', + 'code' => 200, + 'reasonPhrase' => 'OK', + 'headers' => array('Date' => 'Mon, 16 Apr 2007 04:14:16 GMT', 'Server' => 'CakeHttp Server'), 'body' => "

    Hello World

    \r\n

    It's good to be html

    " ) ), @@ -1017,34 +1005,8 @@ class HttpSocketTest extends CakeTestCase { 'header' => null ), 'expectations' => array( - 'status.code' => 404, - 'header' => array() - ) - ), - 'chunked' => array( - 'response' => array( - 'header' => "Transfer-Encoding: chunked\r\n", - 'body' => "19\r\nThis is a chunked message\r\n0\r\n" - ), - 'expectations' => array( - 'body' => "This is a chunked message", - 'header' => $this->Socket->parseHeader("Transfer-Encoding: chunked\r\n") - ) - ), - 'enitity-header' => array( - 'response' => array( - 'body' => "19\r\nThis is a chunked message\r\n0\r\nFoo: Bar\r\n" - ), - 'expectations' => array( - 'header' => $this->Socket->parseHeader("Transfer-Encoding: chunked\r\nFoo: Bar\r\n") - ) - ), - 'enitity-header-combine' => array( - 'response' => array( - 'header' => "Transfer-Encoding: chunked\r\nFoo: Foobar\r\n" - ), - 'expectations' => array( - 'header' => $this->Socket->parseHeader("Transfer-Encoding: chunked\r\nFoo: Foobar\r\nFoo: Bar\r\n") + 'code' => 404, + 'headers' => array() ) ) ); @@ -1059,8 +1021,7 @@ class HttpSocketTest extends CakeTestCase { $expectations = array_merge($expectations, $test['expectations']); foreach ($expectations as $property => $expectedVal) { - $val = Set::extract($r, $property); - $this->assertEquals($val, $expectedVal, 'Test "' . $name . '": response.' . $property . ' - %s'); + $this->assertEquals($r->{$property}, $expectedVal, 'Test "' . $name . '": response.' . $property . ' - %s'); } foreach (array('status-line', 'header', 'body', 'response') as $field) { @@ -1069,6 +1030,31 @@ class HttpSocketTest extends CakeTestCase { } } +/** + * data provider function for testInvalidParseResponseData + * + * @return array + */ + public static function invalidParseResponseDataProvider() { + return array( + array(array('foo' => 'bar')), + array(true), + array("HTTP Foo\r\nBar: La"), + array('HTTP/1.1 TEST ERROR') + ); + } + +/** + * testInvalidParseResponseData + * + * @dataProvider invalidParseResponseDataProvider + * @expectedException Exception + * return void + */ + public function testInvalidParseResponseData($value) { + $this->Socket->parseResponse($value); + } + /** * testDecodeBody method * From 176da154172c9d7670086ad4dc25733e03912bec Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 14 Dec 2010 02:22:30 -0200 Subject: [PATCH 255/378] Moved the response methods from HttpSocket to HttpResponse. --- cake/libs/http_response.php | 249 +++++++++++++++++ cake/libs/http_socket.php | 176 +----------- cake/tests/cases/libs/http_response.test.php | 236 +++++++++++++++- cake/tests/cases/libs/http_socket.test.php | 272 ------------------- 4 files changed, 486 insertions(+), 447 deletions(-) diff --git a/cake/libs/http_response.php b/cake/libs/http_response.php index f0cc637c8..aea0133ae 100644 --- a/cake/libs/http_response.php +++ b/cake/libs/http_response.php @@ -69,6 +69,16 @@ class HttpResponse implements ArrayAccess { */ public $raw = ''; +/** + * Contructor + * + */ + public function __construct($message = null) { + if ($message !== null) { + $this->parseResponse($message); + } + } + /** * Body content * @@ -105,6 +115,245 @@ class HttpResponse implements ArrayAccess { return $this->code == 200; } +/** + * Parses the given message and breaks it down in parts. + * + * @param string $message Message to parse + * @return void + * @throw Exception + */ + public function parseResponse($message) { + if (!is_string($message)) { + throw new Exception(__('Invalid response.')); + } + + if (!preg_match("/^(.+\r\n)(.*)(?<=\r\n)\r\n/Us", $message, $match)) { + throw new Exception(__('Invalid HTTP response.')); + } + + list(, $statusLine, $header) = $match; + $this->raw = $message; + $this->body = (string)substr($message, strlen($match[0])); + + if (preg_match("/(.+) ([0-9]{3}) (.+)\r\n/DU", $statusLine, $match)) { + $this->httpVersion = $match[1]; + $this->code = $match[2]; + $this->reasonPhrase = $match[3]; + } + + $this->headers = $this->_parseHeader($header); + $transferEncoding = $this->getHeader('Transfer-Encoding'); + $decoded = $this->_decodeBody($this->body, $transferEncoding); + $this->body = $decoded['body']; + + if (!empty($decoded['header'])) { + $this->headers = $this->_parseHeader($this->_buildHeader($this->headers) . $this->_buildHeader($decoded['header'])); + } + + if (!empty($this->headers)) { + $this->cookies = $this->parseCookies($this->headers); + } + } + +/** + * Generic function to decode a $body with a given $encoding. Returns either an array with the keys + * 'body' and 'header' or false on failure. + * + * @param string $body A string continaing the body to decode. + * @param mixed $encoding Can be false in case no encoding is being used, or a string representing the encoding. + * @return mixed Array of response headers and body or false. + */ + protected function _decodeBody($body, $encoding = 'chunked') { + if (!is_string($body)) { + return false; + } + if (empty($encoding)) { + return array('body' => $body, 'header' => false); + } + $decodeMethod = '_decode' . Inflector::camelize(str_replace('-', '_', $encoding)) . 'Body'; + + if (!is_callable(array(&$this, $decodeMethod))) { + return array('body' => $body, 'header' => false); + } + return $this->{$decodeMethod}($body); + } + +/** + * Decodes a chunked message $body and returns either an array with the keys 'body' and 'header' or false as + * a result. + * + * @param string $body A string continaing the chunked body to decode. + * @return mixed Array of response headers and body or false. + * @throws Exception + */ + protected function _decodeChunkedBody($body) { + if (!is_string($body)) { + return false; + } + + $decodedBody = null; + $chunkLength = null; + + while ($chunkLength !== 0) { + if (!preg_match("/^([0-9a-f]+) *(?:;(.+)=(.+))?\r\n/iU", $body, $match)) { + throw new Exception(__('HttpSocket::_decodeChunkedBody - Could not parse malformed chunk.')); + } + + $chunkSize = 0; + $hexLength = 0; + $chunkExtensionName = ''; + $chunkExtensionValue = ''; + if (isset($match[0])) { + $chunkSize = $match[0]; + } + if (isset($match[1])) { + $hexLength = $match[1]; + } + if (isset($match[2])) { + $chunkExtensionName = $match[2]; + } + if (isset($match[3])) { + $chunkExtensionValue = $match[3]; + } + + $body = substr($body, strlen($chunkSize)); + $chunkLength = hexdec($hexLength); + $chunk = substr($body, 0, $chunkLength); + if (!empty($chunkExtensionName)) { + /** + * @todo See if there are popular chunk extensions we should implement + */ + } + $decodedBody .= $chunk; + if ($chunkLength !== 0) { + $body = substr($body, $chunkLength + strlen("\r\n")); + } + } + + $entityHeader = false; + if (!empty($body)) { + $entityHeader = $this->_parseHeader($body); + } + return array('body' => $decodedBody, 'header' => $entityHeader); + } + +/** + * Parses an array based header. + * + * @param array $header Header as an indexed array (field => value) + * @return array Parsed header + */ + protected function _parseHeader($header) { + if (is_array($header)) { + return $header; + } elseif (!is_string($header)) { + return false; + } + + preg_match_all("/(.+):(.+)(?:(?_unescapeToken($field); + + if (!isset($header[$field])) { + $header[$field] = $value; + } else { + $header[$field] = array_merge((array)$header[$field], (array)$value); + } + } + return $header; + } + +/** + * Parses cookies in response headers. + * + * @param array $header Header array containing one ore more 'Set-Cookie' headers. + * @return mixed Either false on no cookies, or an array of cookies recieved. + * @todo Make this 100% RFC 2965 confirm + */ + public function parseCookies($header) { + if (!isset($header['Set-Cookie'])) { + return false; + } + + $cookies = array(); + foreach ((array)$header['Set-Cookie'] as $cookie) { + if (strpos($cookie, '";"') !== false) { + $cookie = str_replace('";"', "{__cookie_replace__}", $cookie); + $parts = str_replace("{__cookie_replace__}", '";"', explode(';', $cookie)); + } else { + $parts = preg_split('/\;[ \t]*/', $cookie); + } + + list($name, $value) = explode('=', array_shift($parts), 2); + $cookies[$name] = compact('value'); + + foreach ($parts as $part) { + if (strpos($part, '=') !== false) { + list($key, $value) = explode('=', $part); + } else { + $key = $part; + $value = true; + } + + $key = strtolower($key); + if (!isset($cookies[$name][$key])) { + $cookies[$name][$key] = $value; + } + } + } + return $cookies; + } + +/** + * Unescapes a given $token according to RFC 2616 (HTTP 1.1 specs) + * + * @param string $token Token to unescape + * @param array $chars + * @return string Unescaped token + * @todo Test $chars parameter + */ + protected function _unescapeToken($token, $chars = null) { + $regex = '/"([' . implode('', $this->_tokenEscapeChars(true, $chars)) . '])"/'; + $token = preg_replace($regex, '\\1', $token); + return $token; + } + +/** + * Gets escape chars according to RFC 2616 (HTTP 1.1 specs). + * + * @param boolean $hex true to get them as HEX values, false otherwise + * @param array $chars + * @return array Escape chars + * @todo Test $chars parameter + */ + protected function _tokenEscapeChars($hex = true, $chars = null) { + if (!empty($chars)) { + $escape = $chars; + } else { + $escape = array('"', "(", ")", "<", ">", "@", ",", ";", ":", "\\", "/", "[", "]", "?", "=", "{", "}", " "); + for ($i = 0; $i <= 31; $i++) { + $escape[] = chr($i); + } + $escape[] = chr(127); + } + + if ($hex == false) { + return $escape; + } + $regexChars = ''; + foreach ($escape as $key => $char) { + $escape[$key] = '\\x' . str_pad(dechex(ord($char)), 2, '0', STR_PAD_LEFT); + } + return $escape; + } + /** * ArrayAccess - Offset Exists * diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index aa4769319..c226b574f 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -367,7 +367,7 @@ class HttpSocket extends CakeSocket { $this->disconnect(); } - $this->response = $this->_parseResponse($response); + $this->response = new HttpResponse($response); if (!empty($this->response->cookies)) { if (!isset($this->config['request']['cookies'][$Host])) { $this->config['request']['cookies'][$Host] = array(); @@ -566,137 +566,6 @@ class HttpSocket extends CakeSocket { call_user_func("$authClass::proxyAuthentication", $this, &$this->_proxy); } -/** - * Parses the given message and breaks it down in parts. - * - * @param string $message Message to parse - * @return object Parsed message as HttpResponse - */ - protected function _parseResponse($message) { - if (!is_string($message)) { - throw new Exception(__('Invalid response.')); - } - - if (!preg_match("/^(.+\r\n)(.*)(?<=\r\n)\r\n/Us", $message, $match)) { - throw new Exception(__('Invalid HTTP response.')); - } - - $response = new HttpResponse(); - - list(, $statusLine, $header) = $match; - $response->raw = $message; - $response->body = (string)substr($message, strlen($match[0])); - - if (preg_match("/(.+) ([0-9]{3}) (.+)\r\n/DU", $statusLine, $match)) { - $response->httpVersion = $match[1]; - $response->code = $match[2]; - $response->reasonPhrase = $match[3]; - } - - $response->headers = $this->_parseHeader($header); - $transferEncoding = $response->getHeader('Transfer-Encoding'); - $decoded = $this->_decodeBody($response->body, $transferEncoding); - $response->body = $decoded['body']; - - if (!empty($decoded['header'])) { - $response->headers = $this->_parseHeader($this->_buildHeader($response->headers) . $this->_buildHeader($decoded['header'])); - } - - if (!empty($response->headers)) { - $response->cookies = $this->parseCookies($response->headers); - } - - return $response; - } - -/** - * Generic function to decode a $body with a given $encoding. Returns either an array with the keys - * 'body' and 'header' or false on failure. - * - * @param string $body A string continaing the body to decode. - * @param mixed $encoding Can be false in case no encoding is being used, or a string representing the encoding. - * @return mixed Array of response headers and body or false. - */ - protected function _decodeBody($body, $encoding = 'chunked') { - if (!is_string($body)) { - return false; - } - if (empty($encoding)) { - return array('body' => $body, 'header' => false); - } - $decodeMethod = '_decode'.Inflector::camelize(str_replace('-', '_', $encoding)) . 'Body'; - - if (!is_callable(array(&$this, $decodeMethod))) { - if (!$this->quirksMode) { - trigger_error(sprintf(__('HttpSocket::_decodeBody - Unknown encoding: %s. Activate quirks mode to surpress error.'), h($encoding)), E_USER_WARNING); - } - return array('body' => $body, 'header' => false); - } - return $this->{$decodeMethod}($body); - } - -/** - * Decodes a chunked message $body and returns either an array with the keys 'body' and 'header' or false as - * a result. - * - * @param string $body A string continaing the chunked body to decode. - * @return mixed Array of response headers and body or false. - * @throws Exception - */ - protected function _decodeChunkedBody($body) { - if (!is_string($body)) { - return false; - } - - $decodedBody = null; - $chunkLength = null; - - while ($chunkLength !== 0) { - if (!preg_match("/^([0-9a-f]+) *(?:;(.+)=(.+))?\r\n/iU", $body, $match)) { - if (!$this->quirksMode) { - throw new Exception(__('HttpSocket::_decodeChunkedBody - Could not parse malformed chunk. Activate quirks mode to do this.')); - } - break; - } - - $chunkSize = 0; - $hexLength = 0; - $chunkExtensionName = ''; - $chunkExtensionValue = ''; - if (isset($match[0])) { - $chunkSize = $match[0]; - } - if (isset($match[1])) { - $hexLength = $match[1]; - } - if (isset($match[2])) { - $chunkExtensionName = $match[2]; - } - if (isset($match[3])) { - $chunkExtensionValue = $match[3]; - } - - $body = substr($body, strlen($chunkSize)); - $chunkLength = hexdec($hexLength); - $chunk = substr($body, 0, $chunkLength); - if (!empty($chunkExtensionName)) { - /** - * @todo See if there are popular chunk extensions we should implement - */ - } - $decodedBody .= $chunk; - if ($chunkLength !== 0) { - $body = substr($body, $chunkLength + strlen("\r\n")); - } - } - - $entityHeader = false; - if (!empty($body)) { - $entityHeader = $this->_parseHeader($body); - } - return array('body' => $decodedBody, 'header' => $entityHeader); - } - /** * Parses and sets the specified URI into current request configuration. * @@ -1002,7 +871,7 @@ class HttpSocket extends CakeSocket { return false; } - preg_match_all("/(.+):(.+)(?:(?lineBreak . "|\$)/Uis", $header, $matches, PREG_SET_ORDER); + preg_match_all("/(.+):(.+)(?:(?HttpResponse = new HttpResponse(); + $this->HttpResponse = new TestHttpResponse(); } /** @@ -102,6 +133,209 @@ class HttpResponseTest extends CakeTestCase { $this->assertTrue($this->HttpResponse->isOk()); } +/** + * testParseResponse method + * + * @return void + */ + public function testParseResponse() { + $tests = array( + 'simple-request' => array( + 'response' => array( + 'status-line' => "HTTP/1.x 200 OK\r\n", + 'header' => "Date: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\n", + 'body' => "

    Hello World

    \r\n

    It's good to be html

    " + ), + 'expectations' => array( + 'httpVersion' => 'HTTP/1.x', + 'code' => 200, + 'reasonPhrase' => 'OK', + 'headers' => array('Date' => 'Mon, 16 Apr 2007 04:14:16 GMT', 'Server' => 'CakeHttp Server'), + 'body' => "

    Hello World

    \r\n

    It's good to be html

    " + ) + ), + 'no-header' => array( + 'response' => array( + 'status-line' => "HTTP/1.x 404 OK\r\n", + 'header' => null + ), + 'expectations' => array( + 'code' => 404, + 'headers' => array() + ) + ) + ); + + $testResponse = array(); + $expectations = array(); + + foreach ($tests as $name => $test) { + $testResponse = array_merge($testResponse, $test['response']); + $testResponse['response'] = $testResponse['status-line'] . $testResponse['header'] . "\r\n" . $testResponse['body']; + $this->HttpResponse->parseResponse($testResponse['response']); + $expectations = array_merge($expectations, $test['expectations']); + + foreach ($expectations as $property => $expectedVal) { + $this->assertEquals($this->HttpResponse->{$property}, $expectedVal, 'Test "' . $name . '": response.' . $property . ' - %s'); + } + + foreach (array('status-line', 'header', 'body', 'response') as $field) { + $this->assertEquals($this->HttpResponse['raw'][$field], $testResponse[$field], 'Test response.raw.' . $field . ': %s'); + } + } + } + +/** + * data provider function for testInvalidParseResponseData + * + * @return array + */ + public static function invalidParseResponseDataProvider() { + return array( + array(array('foo' => 'bar')), + array(true), + array("HTTP Foo\r\nBar: La"), + array('HTTP/1.1 TEST ERROR') + ); + } + +/** + * testInvalidParseResponseData + * + * @dataProvider invalidParseResponseDataProvider + * @expectedException Exception + * return void + */ + public function testInvalidParseResponseData($value) { + $this->HttpResponse->parseResponse($value); + } + +/** + * testDecodeBody method + * + * @return void + */ + public function testDecodeBody() { + $r = $this->HttpResponse->decodeBody(true); + $this->assertEquals($r, false); + + $r = $this->HttpResponse->decodeBody('Foobar', false); + $this->assertEquals($r, array('body' => 'Foobar', 'header' => false)); + + $encoding = 'chunked'; + $sample = array( + 'encoded' => "19\r\nThis is a chunked message\r\n0\r\n", + 'decoded' => array('body' => "This is a chunked message", 'header' => false) + ); + + $r = $this->HttpResponse->decodeBody($sample['encoded'], $encoding); + $this->assertEquals($r, $sample['decoded']); + } + +/** + * testDecodeFooCoded + * + * @return void + */ + public function testDecodeFooCoded() { + $r = $this->HttpResponse->decodeBody(true); + $this->assertEquals($r, false); + + $r = $this->HttpResponse->decodeBody('Foobar', false); + $this->assertEquals($r, array('body' => 'Foobar', 'header' => false)); + + $encoding = 'foo-bar'; + $sample = array( + 'encoded' => '!Foobar!', + 'decoded' => array('body' => '!Foobar!', 'header' => false), + ); + + $r = $this->HttpResponse->decodeBody($sample['encoded'], $encoding); + $this->assertEquals($r, $sample['decoded']); + } + +/** + * testDecodeChunkedBody method + * + * @return void + */ + public function testDecodeChunkedBody() { + $r = $this->HttpResponse->decodeChunkedBody(true); + $this->assertEquals($r, false); + + $encoded = "19\r\nThis is a chunked message\r\n0\r\n"; + $decoded = "This is a chunked message"; + $r = $this->HttpResponse->decodeChunkedBody($encoded); + $this->assertEquals($r['body'], $decoded); + $this->assertEquals($r['header'], false); + + $encoded = "19 \r\nThis is a chunked message\r\n0\r\n"; + $r = $this->HttpResponse->decodeChunkedBody($encoded); + $this->assertEquals($r['body'], $decoded); + + $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n0\r\n"; + $decoded = "This is a chunked message\nThat is cool\n"; + $r = $this->HttpResponse->decodeChunkedBody($encoded); + $this->assertEquals($r['body'], $decoded); + $this->assertEquals($r['header'], false); + + $encoded = "19\r\nThis is a chunked message\r\nE;foo-chunk=5\r\n\nThat is cool\n\r\n0\r\n"; + $r = $this->HttpResponse->decodeChunkedBody($encoded); + $this->assertEquals($r['body'], $decoded); + $this->assertEquals($r['header'], false); + + $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n0\r\nfoo-header: bar\r\ncake: PHP\r\n\r\n"; + $r = $this->HttpResponse->decodeChunkedBody($encoded); + $this->assertEquals($r['body'], $decoded); + $this->assertEquals($r['header'], array('foo-header' => 'bar', 'cake' => 'PHP')); + + $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n"; + $this->expectError(); + $r = $this->HttpResponse->decodeChunkedBody($encoded); + $this->assertEquals($r, false); + } + +/** + * testParseCookies method + * + * @return void + */ + public function testParseCookies() { + $header = array( + 'Set-Cookie' => array( + 'foo=bar', + 'people=jim,jack,johnny";";Path=/accounts', + 'google=not=nice' + ), + 'Transfer-Encoding' => 'chunked', + 'Date' => 'Sun, 18 Nov 2007 18:57:42 GMT', + ); + $cookies = $this->HttpResponse->parseCookies($header); + $expected = array( + 'foo' => array( + 'value' => 'bar' + ), + 'people' => array( + 'value' => 'jim,jack,johnny";"', + 'path' => '/accounts', + ), + 'google' => array( + 'value' => 'not=nice', + ) + ); + $this->assertEqual($cookies, $expected); + + $header['Set-Cookie'][] = 'cakephp=great; Secure'; + $expected['cakephp'] = array('value' => 'great', 'secure' => true); + $cookies = $this->HttpResponse->parseCookies($header); + $this->assertEqual($cookies, $expected); + + $header['Set-Cookie'] = 'foo=bar'; + unset($expected['people'], $expected['cakephp'], $expected['google']); + $cookies = $this->HttpResponse->parseCookies($header); + $this->assertEqual($cookies, $expected); + } + /** * testArrayAccess * diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 9dff42b8f..b6a540759 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -99,16 +99,6 @@ class TestHttpSocket extends HttpSocket { return parent::_buildHeader($header, $mode); } -/** - * Convenience method for testing protected method - * - * @param string $message Message to parse - * @return array Parsed message (with indexed elements such as raw, status, header, body) - */ - public function parseResponse($message) { - return parent::_parseResponse($message); - } - /** * Convenience method for testing protected method * @@ -129,27 +119,6 @@ class TestHttpSocket extends HttpSocket { return parent::_parseQuery($query); } -/** - * Convenience method for testing protected method - * - * @param string $body A string continaing the body to decode - * @param mixed $encoding Can be false in case no encoding is being used, or a string representing the encoding - * @return mixed Array or false - */ - public function decodeBody($body, $encoding = 'chunked') { - return parent::_decodeBody($body, $encoding); - } - -/** - * Convenience method for testing protected method - * - * @param string $body A string continaing the chunked body to decode - * @return mixed Array or false - */ - public function decodeChunkedBody($body) { - return parent::_decodeChunkedBody($body); - } - /** * Convenience method for testing protected method * @@ -191,18 +160,6 @@ class TestHttpSocket extends HttpSocket { return parent::_unescapeToken($token, $chars); } -/** - * Convenience method for testing protected method - * - * @param string $message - * @return object HttpResponse - */ - protected function _parseResponse($message) { - if (!is_string($message)) { - return false; - } - return parent::_parseResponse($message); - } } /** @@ -976,194 +933,6 @@ class HttpSocketTest extends CakeTestCase { $this->RequestSocket->delete('http://www.google.com/', null, array('line' => 'Hey Server')); } -/** - * testParseResponse method - * - * @return void - */ - public function testParseResponse() { - $this->Socket->reset(); - - $tests = array( - 'simple-request' => array( - 'response' => array( - 'status-line' => "HTTP/1.x 200 OK\r\n", - 'header' => "Date: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\n", - 'body' => "

    Hello World

    \r\n

    It's good to be html

    " - ), - 'expectations' => array( - 'httpVersion' => 'HTTP/1.x', - 'code' => 200, - 'reasonPhrase' => 'OK', - 'headers' => array('Date' => 'Mon, 16 Apr 2007 04:14:16 GMT', 'Server' => 'CakeHttp Server'), - 'body' => "

    Hello World

    \r\n

    It's good to be html

    " - ) - ), - 'no-header' => array( - 'response' => array( - 'status-line' => "HTTP/1.x 404 OK\r\n", - 'header' => null - ), - 'expectations' => array( - 'code' => 404, - 'headers' => array() - ) - ) - ); - - $testResponse = array(); - $expectations = array(); - - foreach ($tests as $name => $test) { - $testResponse = array_merge($testResponse, $test['response']); - $testResponse['response'] = $testResponse['status-line'] . $testResponse['header'] . "\r\n" . $testResponse['body']; - $r = $this->Socket->parseResponse($testResponse['response']); - $expectations = array_merge($expectations, $test['expectations']); - - foreach ($expectations as $property => $expectedVal) { - $this->assertEquals($r->{$property}, $expectedVal, 'Test "' . $name . '": response.' . $property . ' - %s'); - } - - foreach (array('status-line', 'header', 'body', 'response') as $field) { - $this->assertEquals($r['raw'][$field], $testResponse[$field], 'Test response.raw.' . $field . ': %s'); - } - } - } - -/** - * data provider function for testInvalidParseResponseData - * - * @return array - */ - public static function invalidParseResponseDataProvider() { - return array( - array(array('foo' => 'bar')), - array(true), - array("HTTP Foo\r\nBar: La"), - array('HTTP/1.1 TEST ERROR') - ); - } - -/** - * testInvalidParseResponseData - * - * @dataProvider invalidParseResponseDataProvider - * @expectedException Exception - * return void - */ - public function testInvalidParseResponseData($value) { - $this->Socket->parseResponse($value); - } - -/** - * testDecodeBody method - * - * @return void - */ - public function testDecodeBody() { - $this->Socket->reset(); - - $r = $this->Socket->decodeBody(true); - $this->assertEquals($r, false); - - $r = $this->Socket->decodeBody('Foobar', false); - $this->assertEquals($r, array('body' => 'Foobar', 'header' => false)); - - $encoding = 'chunked'; - $sample = array( - 'encoded' => "19\r\nThis is a chunked message\r\n0\r\n", - 'decoded' => array('body' => "This is a chunked message", 'header' => false) - ); - - $r = $this->Socket->decodeBody($sample['encoded'], $encoding); - $this->assertEquals($r, $sample['decoded']); - } - -/** - * testDecodeFooCoded - * - * @return void - */ - public function testDecodeFooCoded() { - $this->Socket->reset(); - - $r = $this->Socket->decodeBody(true); - $this->assertEquals($r, false); - - $r = $this->Socket->decodeBody('Foobar', false); - $this->assertEquals($r, array('body' => 'Foobar', 'header' => false)); - - $encoding = 'foo-bar'; - $sample = array( - 'encoded' => '!Foobar!', - 'decoded' => array('body' => '!Foobar!', 'header' => false), - ); - - $this->Socket->quirksMode = true; - $r = $this->Socket->decodeBody($sample['encoded'], $encoding); - $this->assertEquals($r, $sample['decoded']); - $this->Socket->quirksMode = false; - - $this->expectError(); - $r = $this->Socket->decodeBody($sample['encoded'], $encoding); - $this->assertEquals($r, $sample['decoded']); - } - -/** - * testDecodeChunkedBody method - * - * @return void - */ - public function testDecodeChunkedBody() { - $this->Socket->reset(); - - $r = $this->Socket->decodeChunkedBody(true); - $this->assertEquals($r, false); - - $encoded = "19\r\nThis is a chunked message\r\n0\r\n"; - $decoded = "This is a chunked message"; - $r = $this->Socket->decodeChunkedBody($encoded); - $this->assertEquals($r['body'], $decoded); - $this->assertEquals($r['header'], false); - - $encoded = "19 \r\nThis is a chunked message\r\n0\r\n"; - $r = $this->Socket->decodeChunkedBody($encoded); - $this->assertEquals($r['body'], $decoded); - - $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n0\r\n"; - $decoded = "This is a chunked message\nThat is cool\n"; - $r = $this->Socket->decodeChunkedBody($encoded); - $this->assertEquals($r['body'], $decoded); - $this->assertEquals($r['header'], false); - - $encoded = "19\r\nThis is a chunked message\r\nE;foo-chunk=5\r\n\nThat is cool\n\r\n0\r\n"; - $r = $this->Socket->decodeChunkedBody($encoded); - $this->assertEquals($r['body'], $decoded); - $this->assertEquals($r['header'], false); - - $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n0\r\nfoo-header: bar\r\ncake: PHP\r\n\r\n"; - $r = $this->Socket->decodeChunkedBody($encoded); - $this->assertEquals($r['body'], $decoded); - $this->assertEquals($r['header'], array('foo-header' => 'bar', 'cake' => 'PHP')); - - $this->Socket->quirksMode = true; - $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\nfoo-header: bar\r\ncake: PHP\r\n\r\n"; - $r = $this->Socket->decodeChunkedBody($encoded); - $this->assertEquals($r['body'], $decoded); - $this->assertEquals($r['header'], array('foo-header' => 'bar', 'cake' => 'PHP')); - - $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n"; - $r = $this->Socket->decodeChunkedBody($encoded); - $this->assertEquals($r['body'], $decoded); - $this->assertEquals($r['header'], false); - - $this->Socket->quirksMode = false; - $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n"; - $this->expectError(); - $r = $this->Socket->decodeChunkedBody($encoded); - $this->assertEquals($r, false); - } - /** * testBuildRequestLine method * @@ -1627,47 +1396,6 @@ class HttpSocketTest extends CakeTestCase { $this->assertEquals($r, $expected); } -/** - * testParseCookies method - * - * @return void - */ - public function testParseCookies() { - $header = array( - 'Set-Cookie' => array( - 'foo=bar', - 'people=jim,jack,johnny";";Path=/accounts', - 'google=not=nice' - ), - 'Transfer-Encoding' => 'chunked', - 'Date' => 'Sun, 18 Nov 2007 18:57:42 GMT', - ); - $cookies = $this->Socket->parseCookies($header); - $expected = array( - 'foo' => array( - 'value' => 'bar' - ), - 'people' => array( - 'value' => 'jim,jack,johnny";"', - 'path' => '/accounts', - ), - 'google' => array( - 'value' => 'not=nice', - ) - ); - $this->assertEqual($cookies, $expected); - - $header['Set-Cookie'][] = 'cakephp=great; Secure'; - $expected['cakephp'] = array('value' => 'great', 'secure' => true); - $cookies = $this->Socket->parseCookies($header); - $this->assertEqual($cookies, $expected); - - $header['Set-Cookie'] = 'foo=bar'; - unset($expected['people'], $expected['cakephp'], $expected['google']); - $cookies = $this->Socket->parseCookies($header); - $this->assertEqual($cookies, $expected); - } - /** * testBuildCookies method * From 2f64afe44e888a897ad7ea12f6b54f780af7b776 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 14 Dec 2010 02:46:31 -0200 Subject: [PATCH 256/378] Allowing the user change the response class. --- cake/libs/http_socket.php | 13 ++++++- cake/tests/cases/libs/http_socket.test.php | 40 ++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index c226b574f..a4fea03f3 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -76,6 +76,13 @@ class HttpSocket extends CakeSocket { */ public $response = null; +/** + * Response classname + * + * @var string + */ + public $responseClass = 'HttpResponse'; + /** * Configuration settings for the HttpSocket and the requests * @@ -367,7 +374,11 @@ class HttpSocket extends CakeSocket { $this->disconnect(); } - $this->response = new HttpResponse($response); + if (!App::import('Lib', $this->responseClass)) { + throw new Exception(__('Class %s not found.', $this->responseClass)); + } + $responseClass = $this->responseClass; + $this->response = new $responseClass($response); if (!empty($this->response->cookies)) { if (!isset($this->config['request']['cookies'][$Host])) { $this->config['request']['cookies'][$Host] = array(); diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index b6a540759..45f0350c6 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -51,6 +51,29 @@ class TestAuthentication { } +/** + * CustomResponse + * + */ +class CustomResponse { + +/** + * First 10 chars + * + * @var string + */ + public $first10; + +/** + * Constructor + * + */ + public function __construct($message) { + $this->first10 = substr($message, 0, 10); + } + +} + /** * TestHttpSocket * @@ -659,6 +682,23 @@ class HttpSocketTest extends CakeTestCase { $this->assertEqual($this->Socket->config['request']['cookies'], $expected); } +/** + * testRequestCustomResponse + * + * @return void + */ + public function testRequestCustomResponse() { + $this->Socket->connected = true; + $serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

    This is a test!

    "; + $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); + $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); + + $this->Socket->responseClass = 'CustomResponse'; + $response = $this->Socket->request('http://www.cakephp.org/'); + $this->assertIsA($response, 'CustomResponse'); + $this->assertEqual($response->first10, 'HTTP/1.x 2'); + } + /** * testProxy method * From 37303d9c37abe86fe2d8eeea75b3e9d2fcf5316d Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 14 Dec 2010 02:52:40 -0200 Subject: [PATCH 257/378] HttpResponse::getHeader() is more flexible to accept a custom header list. --- cake/libs/http_response.php | 16 ++++++++++------ cake/tests/cases/libs/http_response.test.php | 3 +++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cake/libs/http_response.php b/cake/libs/http_response.php index aea0133ae..77b7feb02 100644 --- a/cake/libs/http_response.php +++ b/cake/libs/http_response.php @@ -94,11 +94,14 @@ class HttpResponse implements ArrayAccess { * @param string $name Header name * @return mixed String if header exists or null */ - public function getHeader($name) { - if (isset($this->headers[$name])) { - return $this->headers[$name]; + public function getHeader($name, $headers = null) { + if (!is_array($headers)) { + $headers =& $this->headers; } - foreach ($this->headers as $key => $value) { + if (isset($headers[$name])) { + return $headers[$name]; + } + foreach ($headers as $key => $value) { if (strcasecmp($key, $name) == 0) { return $value; } @@ -278,12 +281,13 @@ class HttpResponse implements ArrayAccess { * @todo Make this 100% RFC 2965 confirm */ public function parseCookies($header) { - if (!isset($header['Set-Cookie'])) { + $cookieHeader = $this->getHeader('Set-Cookie', $header); + if (!$cookieHeader) { return false; } $cookies = array(); - foreach ((array)$header['Set-Cookie'] as $cookie) { + foreach ((array)$cookieHeader as $cookie) { if (strpos($cookie, '";"') !== false) { $cookie = str_replace('";"', "{__cookie_replace__}", $cookie); $parts = str_replace("{__cookie_replace__}", '";"', explode(';', $cookie)); diff --git a/cake/tests/cases/libs/http_response.test.php b/cake/tests/cases/libs/http_response.test.php index 54a92e1a4..4f54dc3f7 100644 --- a/cake/tests/cases/libs/http_response.test.php +++ b/cake/tests/cases/libs/http_response.test.php @@ -113,6 +113,9 @@ class HttpResponseTest extends CakeTestCase { $this->assertEqual($this->HttpResponse->getHeader('header'), 'value'); $this->assertEqual($this->HttpResponse->getHeader('Content-Type'), 'text/plain'); $this->assertIdentical($this->HttpResponse->getHeader(0), null); + + $this->assertEqual($this->HttpResponse->getHeader('foo', false), 'Bar'); + $this->assertEqual($this->HttpResponse->getHeader('foo', array('foo' => 'not from class')), 'not from class'); } /** From 9e1c85e627392bae6574962df5502f847d452548 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 9 Dec 2010 23:41:07 -0500 Subject: [PATCH 258/378] Removing auto-start from CakeSession. Lazy starting will be more performant in most cases. --- cake/libs/cake_session.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php index 91ed52f02..e38f3f243 100644 --- a/cake/libs/cake_session.php +++ b/cake/libs/cake_session.php @@ -151,14 +151,8 @@ class CakeSession { if (($checkAgent === true || $checkAgent === null) && env('HTTP_USER_AGENT') != null) { self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt')); } - - if ($start === true) { - self::_setPath($base); - self::_setHost(env('HTTP_HOST')); - } - if (isset($_SESSION) || $start === true) { - self::start(); - } + self::_setPath($base); + self::_setHost(env('HTTP_HOST')); } /** @@ -374,12 +368,12 @@ class CakeSession { * @return mixed The value of the session variable */ public static function read($name = null) { - if (is_null($name)) { - return self::__returnSessionVars(); - } if (empty($name)) { return false; } + if (is_null($name)) { + return self::__returnSessionVars(); + } $result = Set::classicExtract($_SESSION, $name); if (!is_null($result)) { From 8eebdffcbb41faba84aa20019b61ea34fcbb4217 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 9 Dec 2010 23:55:38 -0500 Subject: [PATCH 259/378] Updating session to lazy start after the first time an operation has been performed. This should make controllers that only use sessions on some actions perform better. --- cake/libs/cake_session.php | 21 ++++++++++++++++++++- cake/tests/cases/libs/cake_session.test.php | 5 ++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php index e38f3f243..a0b44b9cb 100644 --- a/cake/libs/cake_session.php +++ b/cake/libs/cake_session.php @@ -226,6 +226,9 @@ class CakeSession { * @return boolean True if variable is there */ public static function check($name = null) { + if (!self::started() && !self::start()) { + return false; + } if (empty($name)) { return false; } @@ -368,12 +371,15 @@ class CakeSession { * @return mixed The value of the session variable */ public static function read($name = null) { - if (empty($name)) { + if (!self::started() && !self::start()) { return false; } if (is_null($name)) { return self::__returnSessionVars(); } + if (empty($name)) { + return false; + } $result = Set::classicExtract($_SESSION, $name); if (!is_null($result)) { @@ -403,6 +409,9 @@ class CakeSession { * @return void */ public static function watch($var) { + if (!self::started() && !self::start()) { + return false; + } if (empty($var)) { return false; } @@ -418,6 +427,9 @@ class CakeSession { * @return void */ public static function ignore($var) { + if (!self::started() && !self::start()) { + return false; + } if (!in_array($var, self::$watchKeys)) { return; } @@ -438,6 +450,9 @@ class CakeSession { * @return boolean True if the write was successful, false if the write failed */ public static function write($name, $value = null) { + if (!self::started() && !self::start()) { + return false; + } if (empty($name)) { return false; } @@ -666,6 +681,10 @@ class CakeSession { * @return void */ protected static function _checkValid() { + if (!self::started() && !self::start()) { + self::$valid = false; + return false; + } if (self::read('Config')) { $sessionConfig = Configure::read('Session'); diff --git a/cake/tests/cases/libs/cake_session.test.php b/cake/tests/cases/libs/cake_session.test.php index 02fda57e7..889053817 100644 --- a/cake/tests/cases/libs/cake_session.test.php +++ b/cake/tests/cases/libs/cake_session.test.php @@ -305,8 +305,8 @@ class CakeSessionTest extends CakeTestCase { * @return void */ function testId() { - $expected = session_id(); $result = TestCakeSession::id(); + $expected = session_id(); $this->assertEqual($result, $expected); TestCakeSession::id('MySessionId'); @@ -321,10 +321,9 @@ class CakeSessionTest extends CakeTestCase { * @return void */ function testStarted() { - $this->assertTrue(TestCakeSession::started()); - unset($_SESSION); $_SESSION = null; + $this->assertFalse(TestCakeSession::started()); $this->assertTrue(TestCakeSession::start()); $this->assertTrue(TestCakeSession::started()); From 106c1185b4618b5d6fe39226c549d1cc052b3d93 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 10 Dec 2010 22:00:44 -0500 Subject: [PATCH 260/378] Making the id() test pass. --- cake/tests/cases/libs/cake_session.test.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cake/tests/cases/libs/cake_session.test.php b/cake/tests/cases/libs/cake_session.test.php index 889053817..231b74ec9 100644 --- a/cake/tests/cases/libs/cake_session.test.php +++ b/cake/tests/cases/libs/cake_session.test.php @@ -305,13 +305,15 @@ class CakeSessionTest extends CakeTestCase { * @return void */ function testId() { + TestCakeSession::destroy(); + $result = TestCakeSession::id(); $expected = session_id(); - $this->assertEqual($result, $expected); + $this->assertEquals($expected, $result); TestCakeSession::id('MySessionId'); $result = TestCakeSession::id(); - $this->assertEqual($result, 'MySessionId'); + $this->assertEquals('MySessionId', $result); } /** From daf6084cccba6cc4129407c2c5e596191444b4e9 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 10 Dec 2010 22:03:53 -0500 Subject: [PATCH 261/378] Converting assertions to not use compatibility wrappers. --- cake/tests/cases/libs/cake_session.test.php | 84 ++++++++++----------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/cake/tests/cases/libs/cake_session.test.php b/cake/tests/cases/libs/cake_session.test.php index 231b74ec9..2c84254dd 100644 --- a/cake/tests/cases/libs/cake_session.test.php +++ b/cake/tests/cases/libs/cake_session.test.php @@ -136,10 +136,10 @@ class CakeSessionTest extends CakeTestCase { */ function testSessionPath() { TestCakeSession::init('/index.php'); - $this->assertEqual('/', TestCakeSession::$path); + $this->assertEquals(TestCakeSession::$path, '/'); TestCakeSession::init('/sub_dir/index.php'); - $this->assertEqual('/sub_dir/', TestCakeSession::$path); + $this->assertEquals(TestCakeSession::$path, '/sub_dir/'); } /** @@ -150,7 +150,7 @@ class CakeSessionTest extends CakeTestCase { */ function testCakeSessionPathEmpty() { TestCakeSession::init(''); - $this->assertEqual('/', TestCakeSession::$path, 'Session path is empty, with "" as $base needs to be / %s'); + $this->assertEquals(TestCakeSession::$path, '/', 'Session path is empty, with "" as $base needs to be /'); } /** @@ -161,7 +161,7 @@ class CakeSessionTest extends CakeTestCase { */ function testCakeSessionPathContainsQuestion() { TestCakeSession::init('/index.php?'); - $this->assertEqual('/', TestCakeSession::$path); + $this->assertEquals(TestCakeSession::$path, '/'); } /** @@ -173,7 +173,7 @@ class CakeSessionTest extends CakeTestCase { function testSetHost() { TestCakeSession::init(); TestCakeSession::setHost('cakephp.org'); - $this->assertEqual('cakephp.org', TestCakeSession::$host); + $this->assertEquals(TestCakeSession::$host, 'cakephp.org'); } /** @@ -185,7 +185,7 @@ class CakeSessionTest extends CakeTestCase { function testSetHostWithPort() { TestCakeSession::init(); TestCakeSession::setHost('cakephp.org:443'); - $this->assertEqual('cakephp.org', TestCakeSession::$host); + $this->assertEquals(TestCakeSession::$host, 'cakephp.org'); } /** @@ -238,14 +238,14 @@ class CakeSessionTest extends CakeTestCase { function testSimpleRead() { TestCakeSession::write('testing', '1,2,3'); $result = TestCakeSession::read('testing'); - $this->assertEqual($result, '1,2,3'); + $this->assertEquals('1,2,3', $result); TestCakeSession::write('testing', array('1' => 'one', '2' => 'two','3' => 'three')); $result = TestCakeSession::read('testing.1'); - $this->assertEqual($result, 'one'); + $this->assertEquals('one', $result); $result = TestCakeSession::read('testing'); - $this->assertEqual($result, array('1' => 'one', '2' => 'two', '3' => 'three')); + $this->assertEquals(array('1' => 'one', '2' => 'two', '3' => 'three'), $result); $result = TestCakeSession::read(); $this->assertTrue(isset($result['testing'])); @@ -254,7 +254,7 @@ class CakeSessionTest extends CakeTestCase { TestCakeSession::write('This.is.a.deep.array.my.friend', 'value'); $result = TestCakeSession::read('This.is.a.deep.array.my.friend'); - $this->assertEqual('value', $result); + $this->assertEquals($result, 'value'); } /** @@ -340,11 +340,11 @@ class CakeSessionTest extends CakeTestCase { function testError() { TestCakeSession::read('Does.not.exist'); $result = TestCakeSession::error(); - $this->assertEqual($result, "Does.not.exist doesn't exist"); + $this->assertEquals("Does.not.exist doesn't exist", $result); TestCakeSession::delete('Failing.delete'); $result = TestCakeSession::error(); - $this->assertEqual($result, "Failing.delete doesn't exist"); + $this->assertEquals("Failing.delete doesn't exist", $result); } /** @@ -449,7 +449,7 @@ class CakeSessionTest extends CakeTestCase { */ function testCheckKeyWithSpaces() { $this->assertTrue(TestCakeSession::write('Session Test', "test")); - $this->assertEqual(TestCakeSession::check('Session Test'), 'test'); + $this->assertEquals('test', TestCakeSession::check('Session Test')); TestCakeSession::delete('Session Test'); $this->assertTrue(TestCakeSession::write('Session Test.Test Case', "test")); @@ -477,7 +477,7 @@ class CakeSessionTest extends CakeTestCase { $this->assertTrue($result); $result = TestCakeSession::read($key); - $this->assertEqual($result, 'haxored'); + $this->assertEquals('haxored', $result); } /** @@ -488,17 +488,17 @@ class CakeSessionTest extends CakeTestCase { */ function testReadingSavedEmpty() { TestCakeSession::write('SessionTestCase', 0); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), 0); + $this->assertEquals(0, TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', '0'); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), '0'); + $this->assertEquals('0', TestCakeSession::read('SessionTestCase')); $this->assertFalse(TestCakeSession::read('SessionTestCase') === 0); TestCakeSession::write('SessionTestCase', false); $this->assertFalse(TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', null); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), null); + $this->assertEquals(null, TestCakeSession::read('SessionTestCase')); } /** @@ -542,24 +542,24 @@ class CakeSessionTest extends CakeTestCase { TestCakeSession::start(); TestCakeSession::write('SessionTestCase', 0); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), 0); + $this->assertEquals(0, TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', '0'); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), '0'); + $this->assertEquals('0', TestCakeSession::read('SessionTestCase')); $this->assertFalse(TestCakeSession::read('SessionTestCase') === 0); TestCakeSession::write('SessionTestCase', false); $this->assertFalse(TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', null); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), null); + $this->assertEquals(null, TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', 'This is a Test'); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), 'This is a Test'); + $this->assertEquals('This is a Test', TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', 'This is a Test'); TestCakeSession::write('SessionTestCase', 'This was updated'); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), 'This was updated'); + $this->assertEquals('This was updated', TestCakeSession::read('SessionTestCase')); TestCakeSession::destroy(); $this->assertNull(TestCakeSession::read('SessionTestCase')); @@ -624,24 +624,24 @@ class CakeSessionTest extends CakeTestCase { TestCakeSession::destroy(); TestCakeSession::write('SessionTestCase', 0); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), 0); + $this->assertEquals(0, TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', '0'); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), '0'); + $this->assertEquals('0', TestCakeSession::read('SessionTestCase')); $this->assertFalse(TestCakeSession::read('SessionTestCase') === 0); TestCakeSession::write('SessionTestCase', false); $this->assertFalse(TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', null); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), null); + $this->assertEquals(null, TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', 'This is a Test'); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), 'This is a Test'); + $this->assertEquals('This is a Test', TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', 'This is a Test'); TestCakeSession::write('SessionTestCase', 'This was updated'); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), 'This was updated'); + $this->assertEquals('This was updated', TestCakeSession::read('SessionTestCase')); TestCakeSession::destroy(); $this->assertNull(TestCakeSession::read('SessionTestCase')); @@ -687,23 +687,23 @@ class CakeSessionTest extends CakeTestCase { TestCakeSession::start(); TestCakeSession::write('SessionTestCase', 0); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), 0); + $this->assertEquals(0, TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', '0'); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), '0'); + $this->assertEquals('0', TestCakeSession::read('SessionTestCase')); $this->assertFalse(TestCakeSession::read('SessionTestCase') === 0); TestCakeSession::write('SessionTestCase', false); $this->assertFalse(TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', null); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), null); + $this->assertEquals(null, TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', 'This is a Test'); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), 'This is a Test'); + $this->assertEquals('This is a Test', TestCakeSession::read('SessionTestCase')); TestCakeSession::write('SessionTestCase', 'Some additional data'); - $this->assertEqual(TestCakeSession::read('SessionTestCase'), 'Some additional data'); + $this->assertEquals('Some additional data', TestCakeSession::read('SessionTestCase')); TestCakeSession::destroy(); $this->assertNull(TestCakeSession::read('SessionTestCase')); @@ -729,21 +729,21 @@ class CakeSessionTest extends CakeTestCase { TestCakeSession::destroy(); TestCakeSession::write('Test', 'some value'); - $this->assertEqual(CakeSession::$sessionTime, time() + $timeoutSeconds); - $this->assertEqual($_SESSION['Config']['countdown'], 10); - $this->assertEqual($_SESSION['Config']['time'], CakeSession::$sessionTime); - $this->assertEqual(CakeSession::$time, time()); - $this->assertEqual($_SESSION['Config']['time'], time() + $timeoutSeconds); + $this->assertEquals(time() + $timeoutSeconds, CakeSession::$sessionTime); + $this->assertEquals(10, $_SESSION['Config']['countdown']); + $this->assertEquals(CakeSession::$sessionTime, $_SESSION['Config']['time']); + $this->assertEquals(time(), CakeSession::$time); + $this->assertEquals(time() + $timeoutSeconds, $_SESSION['Config']['time']); Configure::write('Session.harden', true); TestCakeSession::destroy(); TestCakeSession::write('Test', 'some value'); - $this->assertEqual(CakeSession::$sessionTime, time() + $timeoutSeconds); - $this->assertEqual($_SESSION['Config']['countdown'], 10); - $this->assertEqual($_SESSION['Config']['time'], CakeSession::$sessionTime); - $this->assertEqual(CakeSession::$time, time()); - $this->assertEqual($_SESSION['Config']['time'], CakeSession::$time + $timeoutSeconds); + $this->assertEquals(time() + $timeoutSeconds, CakeSession::$sessionTime); + $this->assertEquals(10, $_SESSION['Config']['countdown']); + $this->assertEquals(CakeSession::$sessionTime, $_SESSION['Config']['time']); + $this->assertEquals(time(), CakeSession::$time); + $this->assertEquals(CakeSession::$time + $timeoutSeconds, $_SESSION['Config']['time']); } } From bd951791f4429c91502fcfe184039534257f3c9b Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 13 Dec 2010 23:58:42 -0500 Subject: [PATCH 262/378] Removing forced start of sessions now that they are lazily started. --- cake/libs/controller/components/session.php | 11 ----------- cake/libs/view/helpers/session.php | 13 ------------- 2 files changed, 24 deletions(-) diff --git a/cake/libs/controller/components/session.php b/cake/libs/controller/components/session.php index 77ab43a4d..af4474c6c 100644 --- a/cake/libs/controller/components/session.php +++ b/cake/libs/controller/components/session.php @@ -33,17 +33,6 @@ if (!class_exists('cakesession')) { */ class SessionComponent extends Component { -/** - * Constructor automatically starts the session. - * - * @param ComponentCollection $collection A ComponentCollection this component can use to lazy load its components - * @param array $settings Array of configuration settings. - */ - public function __construct(ComponentCollection $collection, $settings = array()) { - parent::__construct($collection, $settings); - CakeSession::start(); - } - /** * Get / Set the userAgent * diff --git a/cake/libs/view/helpers/session.php b/cake/libs/view/helpers/session.php index 0f6aa002d..b12fa3190 100644 --- a/cake/libs/view/helpers/session.php +++ b/cake/libs/view/helpers/session.php @@ -31,19 +31,6 @@ if (!class_exists('CakeSession')) { */ class SessionHelper extends AppHelper { -/** - * Constructor. Starts the session if it has not already been started - * - * @param View $view View instance for this helper - * @param array $settings Settings for the helper. - * @return void - */ - public function __construct(View $view, $settings = array()) { - parent::__construct($view, $settings); - if (!CakeSession::started()) { - CakeSession::start(); - } - } /** * Used to read a session values set in a controller for a key or return values for all keys. * From cf7aae791132a3ca418edad5894f52f14cb86826 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 14 Dec 2010 11:05:37 -0200 Subject: [PATCH 263/378] Removed parseHeader from HttpSocket (it was not used). Moved the tests of parseHeader to HttpResponse. --- cake/libs/http_socket.php | 48 -------- cake/tests/cases/libs/http_response.test.php | 112 +++++++++++++++++++ cake/tests/cases/libs/http_socket.test.php | 106 ------------------ 3 files changed, 112 insertions(+), 154 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index a4fea03f3..cc28ae5fd 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -279,7 +279,6 @@ class HttpSocket extends CakeSocket { $cookies = null; if (is_array($this->request['header'])) { - $this->request['header'] = $this->_parseHeader($this->request['header']); if (!empty($this->request['cookies'])) { $cookies = $this->buildCookies($this->request['cookies']); } @@ -869,39 +868,6 @@ class HttpSocket extends CakeSocket { return $returnHeader; } -/** - * Parses an array based header. - * - * @param array $header Header as an indexed array (field => value) - * @return array Parsed header - */ - protected function _parseHeader($header) { - if (is_array($header)) { - return $header; - } elseif (!is_string($header)) { - return false; - } - - preg_match_all("/(.+):(.+)(?:(?_unescapeToken($field); - - if (!isset($header[$field])) { - $header[$field] = $value; - } else { - $header[$field] = array_merge((array)$header[$field], (array)$value); - } - } - return $header; - } - /** * Builds cookie headers for a request. * @@ -917,20 +883,6 @@ class HttpSocket extends CakeSocket { return $this->_buildHeader(array('Cookie' => implode('; ', $header)), 'pragmatic'); } -/** - * Unescapes a given $token according to RFC 2616 (HTTP 1.1 specs) - * - * @param string $token Token to unescape - * @param array $chars - * @return string Unescaped token - * @todo Test $chars parameter - */ - protected function _unescapeToken($token, $chars = null) { - $regex = '/"([' . implode('', $this->_tokenEscapeChars(true, $chars)) . '])"/'; - $token = preg_replace($regex, '\\1', $token); - return $token; - } - /** * Escapes a given $token according to RFC 2616 (HTTP 1.1 specs) * diff --git a/cake/tests/cases/libs/http_response.test.php b/cake/tests/cases/libs/http_response.test.php index 4f54dc3f7..63892535c 100644 --- a/cake/tests/cases/libs/http_response.test.php +++ b/cake/tests/cases/libs/http_response.test.php @@ -27,6 +27,16 @@ App::import('Core', 'HttpResponse'); */ class TestHttpResponse extends HttpResponse { +/** + * Convenience method for testing protected method + * + * @param array $header Header as an indexed array (field => value) + * @return array Parsed header + */ + public function parseHeader($header) { + return parent::_parseHeader($header); + } + /** * Convenience method for testing protected method * @@ -48,6 +58,26 @@ class TestHttpResponse extends HttpResponse { return parent::_decodeChunkedBody($body); } +/** + * Convenience method for testing protected method + * + * @param string $token Token to unescape + * @return string Unescaped token + */ + public function unescapeToken($token, $chars = null) { + return parent::_unescapeToken($token, $chars); + } + +/** + * Convenience method for testing protected method + * + * @param boolean $hex true to get them as HEX values, false otherwise + * @return array Escape chars + */ + public function tokenEscapeChars($hex = true, $chars = null) { + return parent::_tokenEscapeChars($hex, $chars); + } + } /** @@ -136,6 +166,65 @@ class HttpResponseTest extends CakeTestCase { $this->assertTrue($this->HttpResponse->isOk()); } +/** + * Test that HttpSocket::parseHeader can take apart a given (and valid) $header string and turn it into an array. + * + * @return void + */ + public function testParseHeader() { + $r = $this->HttpResponse->parseHeader(array('foo' => 'Bar', 'fOO-bAr' => 'quux')); + $this->assertEquals($r, array('foo' => 'Bar', 'fOO-bAr' => 'quux')); + + $r = $this->HttpResponse->parseHeader(true); + $this->assertEquals($r, false); + + $header = "Host: cakephp.org\t\r\n"; + $r = $this->HttpResponse->parseHeader($header); + $expected = array( + 'Host' => 'cakephp.org' + ); + $this->assertEquals($r, $expected); + + $header = "Date:Sat, 07 Apr 2007 10:10:25 GMT\r\nX-Powered-By: PHP/5.1.2\r\n"; + $r = $this->HttpResponse->parseHeader($header); + $expected = array( + 'Date' => 'Sat, 07 Apr 2007 10:10:25 GMT', + 'X-Powered-By' => 'PHP/5.1.2' + ); + $this->assertEquals($r, $expected); + + $header = "people: Jim,John\r\nfoo-LAND: Bar\r\ncAKe-PHP: rocks\r\n"; + $r = $this->HttpResponse->parseHeader($header); + $expected = array( + 'people' => 'Jim,John', + 'foo-LAND' => 'Bar', + 'cAKe-PHP' => 'rocks' + ); + $this->assertEquals($r, $expected); + + $header = "People: Jim,John,Tim\r\nPeople: Lisa,Tina,Chelsea\r\n"; + $r = $this->HttpResponse->parseHeader($header); + $expected = array( + 'People' => array('Jim,John,Tim', 'Lisa,Tina,Chelsea') + ); + $this->assertEquals($r, $expected); + + $header = "Multi-Line: I am a \r\nmulti line\t\r\nfield value.\r\nSingle-Line: I am not\r\n"; + $r = $this->HttpResponse->parseHeader($header); + $expected = array( + 'Multi-Line' => "I am a\r\nmulti line\r\nfield value.", + 'Single-Line' => 'I am not' + ); + $this->assertEquals($r, $expected); + + $header = "Esc\"@\"ped: value\r\n"; + $r = $this->HttpResponse->parseHeader($header); + $expected = array( + 'Esc@ped' => 'value' + ); + $this->assertEquals($r, $expected); + } + /** * testParseResponse method * @@ -339,6 +428,29 @@ class HttpResponseTest extends CakeTestCase { $this->assertEqual($cookies, $expected); } +/** + * Test that escaped token strings are properly unescaped by HttpSocket::unescapeToken + * + * @return void + */ + public function testUnescapeToken() { + $this->assertEquals($this->HttpResponse->unescapeToken('Foo'), 'Foo'); + + $escape = $this->HttpResponse->tokenEscapeChars(false); + foreach ($escape as $char) { + $token = 'My-special-"' . $char . '"-Token'; + $unescapedToken = $this->HttpResponse->unescapeToken($token); + $expectedToken = 'My-special-' . $char . '-Token'; + + $this->assertEquals($unescapedToken, $expectedToken, 'Test token unescaping for ASCII '.ord($char)); + } + + $token = 'Extreme-":"Token-" "-""""@"-test'; + $escapedToken = $this->HttpResponse->unescapeToken($token); + $expectedToken = 'Extreme-:Token- -"@-test'; + $this->assertEquals($expectedToken, $escapedToken); + } + /** * testArrayAccess * diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index 45f0350c6..cefd649e2 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -122,16 +122,6 @@ class TestHttpSocket extends HttpSocket { return parent::_buildHeader($header, $mode); } -/** - * Convenience method for testing protected method - * - * @param array $header Header as an indexed array (field => value) - * @return array Parsed header - */ - public function parseHeader($header) { - return parent::_parseHeader($header); - } - /** * Convenience method for testing protected method * @@ -173,16 +163,6 @@ class TestHttpSocket extends HttpSocket { return parent::_escapeToken($token, $chars); } -/** - * Convenience method for testing protected method - * - * @param string $token Token to unescape - * @return string Unescaped token - */ - public function unescapeToken($token, $chars = null) { - return parent::_unescapeToken($token, $chars); - } - } /** @@ -1375,67 +1355,6 @@ class HttpSocketTest extends CakeTestCase { } -/** - * Test that HttpSocket::parseHeader can take apart a given (and valid) $header string and turn it into an array. - * - * @return void - */ - public function testParseHeader() { - $this->Socket->reset(); - - $r = $this->Socket->parseHeader(array('foo' => 'Bar', 'fOO-bAr' => 'quux')); - $this->assertEquals($r, array('foo' => 'Bar', 'fOO-bAr' => 'quux')); - - $r = $this->Socket->parseHeader(true); - $this->assertEquals($r, false); - - $header = "Host: cakephp.org\t\r\n"; - $r = $this->Socket->parseHeader($header); - $expected = array( - 'Host' => 'cakephp.org' - ); - $this->assertEquals($r, $expected); - - $header = "Date:Sat, 07 Apr 2007 10:10:25 GMT\r\nX-Powered-By: PHP/5.1.2\r\n"; - $r = $this->Socket->parseHeader($header); - $expected = array( - 'Date' => 'Sat, 07 Apr 2007 10:10:25 GMT', - 'X-Powered-By' => 'PHP/5.1.2' - ); - $this->assertEquals($r, $expected); - - $header = "people: Jim,John\r\nfoo-LAND: Bar\r\ncAKe-PHP: rocks\r\n"; - $r = $this->Socket->parseHeader($header); - $expected = array( - 'people' => 'Jim,John', - 'foo-LAND' => 'Bar', - 'cAKe-PHP' => 'rocks' - ); - $this->assertEquals($r, $expected); - - $header = "People: Jim,John,Tim\r\nPeople: Lisa,Tina,Chelsea\r\n"; - $r = $this->Socket->parseHeader($header); - $expected = array( - 'People' => array('Jim,John,Tim', 'Lisa,Tina,Chelsea') - ); - $this->assertEquals($r, $expected); - - $header = "Multi-Line: I am a \r\nmulti line\t\r\nfield value.\r\nSingle-Line: I am not\r\n"; - $r = $this->Socket->parseHeader($header); - $expected = array( - 'Multi-Line' => "I am a\r\nmulti line\r\nfield value.", - 'Single-Line' => 'I am not' - ); - $this->assertEquals($r, $expected); - - $header = "Esc\"@\"ped: value\r\n"; - $r = $this->Socket->parseHeader($header); - $expected = array( - 'Esc@ped' => 'value' - ); - $this->assertEquals($r, $expected); - } - /** * testBuildCookies method * @@ -1507,31 +1426,6 @@ class HttpSocketTest extends CakeTestCase { $this->assertEquals($expectedToken, $escapedToken); } -/** - * Test that escaped token strings are properly unescaped by HttpSocket::unescapeToken - * - * @return void - */ - public function testUnescapeToken() { - $this->Socket->reset(); - - $this->assertEquals($this->Socket->unescapeToken('Foo'), 'Foo'); - - $escape = $this->Socket->tokenEscapeChars(false); - foreach ($escape as $char) { - $token = 'My-special-"' . $char . '"-Token'; - $unescapedToken = $this->Socket->unescapeToken($token); - $expectedToken = 'My-special-' . $char . '-Token'; - - $this->assertEquals($unescapedToken, $expectedToken, 'Test token unescaping for ASCII '.ord($char)); - } - - $token = 'Extreme-":"Token-" "-""""@"-test'; - $escapedToken = $this->Socket->unescapeToken($token); - $expectedToken = 'Extreme-:Token- -"@-test'; - $this->assertEquals($expectedToken, $escapedToken); - } - /** * This tests asserts HttpSocket::reset() resets a HttpSocket instance to it's initial state (before Object::__construct * got executed) From 2cbece678495273aa5504b1362b5f252309dc7e9 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 14 Dec 2010 11:11:36 -0200 Subject: [PATCH 264/378] Removed the lineBreak attribute, this is fixed in RFC. --- cake/libs/http_socket.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index cc28ae5fd..a521ea9c5 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -104,13 +104,6 @@ class HttpSocket extends CakeSocket { ) ); -/** - * String that represents a line break. - * - * @var string - */ - public $lineBreak = "\r\n"; - /** * Authentication settings * @@ -809,7 +802,7 @@ class HttpSocket extends CakeSocket { if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) { throw new Exception(sprintf(__('HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.'), join(',', $asteriskMethods))); } - return $request['method'] . ' ' . $request['uri'] . ' ' . $versionToken . $this->lineBreak; + return $request['method'] . ' ' . $request['uri'] . ' ' . $versionToken . "\r\n"; } /** @@ -862,7 +855,7 @@ class HttpSocket extends CakeSocket { $contents = preg_replace("/\r\n(?![\t ])/", "\r\n ", $content); $field = $this->_escapeToken($field); - $returnHeader .= $field . ': ' . $contents . $this->lineBreak; + $returnHeader .= $field . ': ' . $contents . "\r\n"; } } return $returnHeader; From 296aef2c112ff8c6d6783d282e22895ef86e125d Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 14 Dec 2010 11:13:44 -0200 Subject: [PATCH 265/378] Removed the import. It is called in request. --- cake/libs/http_socket.php | 1 - 1 file changed, 1 deletion(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index a521ea9c5..a5e66964a 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -19,7 +19,6 @@ */ App::import('Core', 'CakeSocket'); App::import('Core', 'Router'); -App::import('Lib', 'HttpResponse'); /** * Cake network socket connection class. From 9fa1bec0cb4605ffdc00002b4d9e7fe4b039ae67 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 14 Dec 2010 18:21:39 -0800 Subject: [PATCH 266/378] Move Controller::paginate() into PaginatorComponent --- cake/libs/controller/components/paginator.php | 251 +++++++++ cake/libs/controller/controller.php | 219 +------- cake/libs/route/cake_route.php | 8 +- cake/libs/router.php | 28 +- .../controller/components/paginator.test.php | 485 ++++++++++++++++++ .../cases/libs/controller/controller.test.php | 373 ++------------ cake/tests/cases/libs/router.test.php | 107 ++++ 7 files changed, 910 insertions(+), 561 deletions(-) create mode 100644 cake/libs/controller/components/paginator.php create mode 100644 cake/tests/cases/libs/controller/components/paginator.test.php diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php new file mode 100644 index 000000000..cb1bf7f0e --- /dev/null +++ b/cake/libs/controller/components/paginator.php @@ -0,0 +1,251 @@ + 1, 'limit' => 20), (array)$settings); + $this->Controller = $collection->getController(); + parent::__construct($collection, $settings); + } + +/** + * Handles automatic pagination of model records. + * + * @param mixed $object Model to paginate (e.g: model instance, or 'Model', or 'Model.InnerModel') + * @param mixed $scope Conditions to use while paginating + * @param array $whitelist List of allowed options for paging + * @return array Model query results + */ + public function paginate($object = null, $scope = array(), $whitelist = array()) { + if (is_array($object)) { + $whitelist = $scope; + $scope = $object; + $object = null; + } + $assoc = null; + + if (is_string($object)) { + $assoc = null; + if (strpos($object, '.') !== false) { + list($object, $assoc) = pluginSplit($object); + } + + if ($assoc && isset($this->Controller->{$object}->{$assoc})) { + $object = $this->Controller->{$object}->{$assoc}; + } elseif ( + $assoc && isset($this->Controller->{$this->Controller->modelClass}) && + isset($this->Controller->{$this->Controller->modelClass}->{$assoc} + )) { + $object = $this->Controller->{$this->Controller->modelClass}->{$assoc}; + } elseif (isset($this->Controller->{$object})) { + $object = $this->Controller->{$object}; + } elseif ( + isset($this->Controller->{$this->Controller->modelClass}) && isset($this->Controller->{$this->Controller->modelClass}->{$object} + )) { + $object = $this->Controller->{$this->Controller->modelClass}->{$object}; + } + } elseif (empty($object) || $object === null) { + if (isset($this->Controller->{$this->Controller->modelClass})) { + $object = $this->Controller->{$this->Controller->modelClass}; + } else { + $className = null; + $name = $this->Controller->uses[0]; + if (strpos($this->Controller->uses[0], '.') !== false) { + list($name, $className) = explode('.', $this->Controller->uses[0]); + } + if ($className) { + $object = $this->Controller->{$className}; + } else { + $object = $this->Controller->{$name}; + } + } + } + + if (!is_object($object)) { + throw new MissingModelException($object); + } + $options = array_merge($this->Controller->request->params, $this->Controller->params['url'], $this->Controller->passedArgs); + + if (isset($this->settings[$object->alias])) { + $defaults = $this->settings[$object->alias]; + } else { + $defaults = $this->settings; + } + + if (isset($options['show'])) { + $options['limit'] = $options['show']; + } + + if (isset($options['sort'])) { + $direction = null; + if (isset($options['direction'])) { + $direction = strtolower($options['direction']); + } + if ($direction != 'asc' && $direction != 'desc') { + $direction = 'asc'; + } + $options['order'] = array($options['sort'] => $direction); + } + + if (!empty($options['order']) && is_array($options['order'])) { + $alias = $object->alias ; + $key = $field = key($options['order']); + + if (strpos($key, '.') !== false) { + list($alias, $field) = explode('.', $key); + } + $value = $options['order'][$key]; + unset($options['order'][$key]); + + if ($object->hasField($field)) { + $options['order'][$alias . '.' . $field] = $value; + } elseif ($object->hasField($field, true)) { + $options['order'][$field] = $value; + } elseif (isset($object->{$alias}) && $object->{$alias}->hasField($field)) { + $options['order'][$alias . '.' . $field] = $value; + } + } + $vars = array('fields', 'order', 'limit', 'page', 'recursive'); + $keys = array_keys($options); + $count = count($keys); + + for ($i = 0; $i < $count; $i++) { + if (!in_array($keys[$i], $vars, true)) { + unset($options[$keys[$i]]); + } + if (empty($whitelist) && ($keys[$i] === 'fields' || $keys[$i] === 'recursive')) { + unset($options[$keys[$i]]); + } elseif (!empty($whitelist) && !in_array($keys[$i], $whitelist)) { + unset($options[$keys[$i]]); + } + } + $conditions = $fields = $order = $limit = $page = $recursive = null; + + if (!isset($defaults['conditions'])) { + $defaults['conditions'] = array(); + } + + $type = 'all'; + + if (isset($defaults[0])) { + $type = $defaults[0]; + unset($defaults[0]); + } + + $options = array_merge(array('page' => 1, 'limit' => 20), $defaults, $options); + $options['limit'] = (int) $options['limit']; + if (empty($options['limit']) || $options['limit'] < 1) { + $options['limit'] = 1; + } + + extract($options); + + if (is_array($scope) && !empty($scope)) { + $conditions = array_merge($conditions, $scope); + } elseif (is_string($scope)) { + $conditions = array($conditions, $scope); + } + if ($recursive === null) { + $recursive = $object->recursive; + } + + $extra = array_diff_key($defaults, compact( + 'conditions', 'fields', 'order', 'limit', 'page', 'recursive' + )); + if ($type !== 'all') { + $extra['type'] = $type; + } + + if (method_exists($object, 'paginateCount')) { + $count = $object->paginateCount($conditions, $recursive, $extra); + } else { + $parameters = compact('conditions'); + if ($recursive != $object->recursive) { + $parameters['recursive'] = $recursive; + } + $count = $object->find('count', array_merge($parameters, $extra)); + } + $pageCount = intval(ceil($count / $limit)); + + if ($page === 'last' || $page >= $pageCount) { + $options['page'] = $page = $pageCount; + } elseif (intval($page) < 1) { + $options['page'] = $page = 1; + } + $page = $options['page'] = (integer)$page; + + if (method_exists($object, 'paginate')) { + $results = $object->paginate( + $conditions, $fields, $order, $limit, $page, $recursive, $extra + ); + } else { + $parameters = compact('conditions', 'fields', 'order', 'limit', 'page'); + if ($recursive != $object->recursive) { + $parameters['recursive'] = $recursive; + } + $results = $object->find($type, array_merge($parameters, $extra)); + } + $paging = array( + 'page' => $page, + 'current' => count($results), + 'count' => $count, + 'prevPage' => ($page > 1), + 'nextPage' => ($count > ($page * $limit)), + 'pageCount' => $pageCount, + 'defaults' => array_merge(array('limit' => 20, 'step' => 1), $defaults), + 'options' => $options + ); + if (!isset($this->Controller->request['paging'])) { + $this->Controller->request['paging'] = array(); + } + $this->Controller->request['paging'] = array_merge( + (array)$this->Controller->request['paging'], + array($object->alias => $paging) + ); + + if (!in_array('Paginator', $this->Controller->helpers) && !array_key_exists('Paginator', $this->Controller->helpers)) { + $this->Controller->helpers[] = 'Paginator'; + } + return $results; + } +} \ No newline at end of file diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 7bc58f024..9afc3e315 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -94,26 +94,6 @@ class Controller extends Object { */ protected $_responseClass = 'CakeResponse'; -/** - * Holds pagination defaults for controller actions. The keys that can be included - * in this array are: 'conditions', 'fields', 'order', 'limit', 'page', and 'recursive', - * similar to the keys in the second parameter of Model::find(). - * - * Pagination defaults can also be supplied in a model-by-model basis by using - * the name of the model as a key for a pagination array: - * - * {{{ - * public $paginate = array( - * 'Post' => array(...), - * 'Comment' => array(...) - * ); - * }}} - * - * @var array - * @link http://book.cakephp.org/view/1231/Pagination - */ - public $paginate = array('limit' => 20, 'page' => 1, 'maxLimit' => 100); - /** * The name of the views subfolder containing views for this controller. * @@ -362,6 +342,8 @@ class Controller extends Object { return isset($this->request->params['action']) ? $this->request->params['action'] : ''; case 'params': return $this->request; + case 'paginate': + return $this->Components->load('Paginator')->settings; } return null; } @@ -382,6 +364,8 @@ class Controller extends Object { return $this->request->params['action'] = $value; case 'params': return $this->request->params = $value; + case 'paginate': + return $this->Components->load('Paginator')->settings = $value; } return $this->{$name} = $value; } @@ -961,201 +945,10 @@ class Controller extends Object { * @param array $whitelist List of allowed options for paging * @return array Model query results * @link http://book.cakephp.org/view/1232/Controller-Setup + * @deprecated Use PaginatorComponent instead */ public function paginate($object = null, $scope = array(), $whitelist = array()) { - if (is_array($object)) { - $whitelist = $scope; - $scope = $object; - $object = null; - } - $assoc = null; - - if (is_string($object)) { - $assoc = null; - if (strpos($object, '.') !== false) { - list($object, $assoc) = pluginSplit($object); - } - - if ($assoc && isset($this->{$object}->{$assoc})) { - $object = $this->{$object}->{$assoc}; - } elseif ( - $assoc && isset($this->{$this->modelClass}) && - isset($this->{$this->modelClass}->{$assoc} - )) { - $object = $this->{$this->modelClass}->{$assoc}; - } elseif (isset($this->{$object})) { - $object = $this->{$object}; - } elseif ( - isset($this->{$this->modelClass}) && isset($this->{$this->modelClass}->{$object} - )) { - $object = $this->{$this->modelClass}->{$object}; - } - } elseif (empty($object) || $object === null) { - if (isset($this->{$this->modelClass})) { - $object = $this->{$this->modelClass}; - } else { - $className = null; - $name = $this->uses[0]; - if (strpos($this->uses[0], '.') !== false) { - list($name, $className) = explode('.', $this->uses[0]); - } - if ($className) { - $object = $this->{$className}; - } else { - $object = $this->{$name}; - } - } - } - - if (!is_object($object)) { - trigger_error(sprintf( - __('Controller::paginate() - can\'t find model %1$s in controller %2$sController'), $object, $this->name - ), E_USER_WARNING); - return array(); - } - $options = array_merge($this->request->params, $this->request->query, $this->passedArgs); - - if (isset($this->paginate[$object->alias])) { - $defaults = $this->paginate[$object->alias]; - } else { - $defaults = $this->paginate; - } - - if (isset($options['show'])) { - $options['limit'] = $options['show']; - } - - if (isset($options['sort'])) { - $direction = null; - if (isset($options['direction'])) { - $direction = strtolower($options['direction']); - } - if ($direction != 'asc' && $direction != 'desc') { - $direction = 'asc'; - } - $options['order'] = array($options['sort'] => $direction); - } - - if (!empty($options['order']) && is_array($options['order'])) { - $alias = $object->alias ; - $key = $field = key($options['order']); - - if (strpos($key, '.') !== false) { - list($alias, $field) = explode('.', $key); - } - $value = $options['order'][$key]; - unset($options['order'][$key]); - - if ($object->hasField($field)) { - $options['order'][$alias . '.' . $field] = $value; - } elseif ($object->hasField($field, true)) { - $options['order'][$field] = $value; - } elseif (isset($object->{$alias}) && $object->{$alias}->hasField($field)) { - $options['order'][$alias . '.' . $field] = $value; - } - } - $vars = array('fields', 'order', 'limit', 'page', 'recursive'); - $keys = array_keys($options); - $count = count($keys); - - for ($i = 0; $i < $count; $i++) { - if (!in_array($keys[$i], $vars, true)) { - unset($options[$keys[$i]]); - } - if (empty($whitelist) && ($keys[$i] === 'fields' || $keys[$i] === 'recursive')) { - unset($options[$keys[$i]]); - } elseif (!empty($whitelist) && !in_array($keys[$i], $whitelist)) { - unset($options[$keys[$i]]); - } - } - $conditions = $fields = $order = $limit = $page = $recursive = null; - - if (!isset($defaults['conditions'])) { - $defaults['conditions'] = array(); - } - - $type = 'all'; - - if (isset($defaults[0])) { - $type = $defaults[0]; - unset($defaults[0]); - } - - $options = array_merge(array('page' => 1, 'limit' => 20, 'maxLimit' => 100), $defaults, $options); - $options['limit'] = min((int)$options['limit'], $options['maxLimit']); - if (empty($options['limit']) || $options['limit'] < 1) { - $options['limit'] = 1; - } - - extract($options); - - if (is_array($scope) && !empty($scope)) { - $conditions = array_merge($conditions, $scope); - } elseif (is_string($scope)) { - $conditions = array($conditions, $scope); - } - if ($recursive === null) { - $recursive = $object->recursive; - } - - $extra = array_diff_key($defaults, compact( - 'conditions', 'fields', 'order', 'limit', 'page', 'recursive' - )); - if ($type !== 'all') { - $extra['type'] = $type; - } - - if (method_exists($object, 'paginateCount')) { - $count = $object->paginateCount($conditions, $recursive, $extra); - } else { - $parameters = compact('conditions'); - if ($recursive != $object->recursive) { - $parameters['recursive'] = $recursive; - } - $count = $object->find('count', array_merge($parameters, $extra)); - } - $pageCount = intval(ceil($count / $limit)); - - if ($page === 'last' || $page >= $pageCount) { - $options['page'] = $page = $pageCount; - } elseif (intval($page) < 1) { - $options['page'] = $page = 1; - } - $page = $options['page'] = (int)$page; - - if (method_exists($object, 'paginate')) { - $results = $object->paginate( - $conditions, $fields, $order, $limit, $page, $recursive, $extra - ); - } else { - $parameters = compact('conditions', 'fields', 'order', 'limit', 'page'); - if ($recursive != $object->recursive) { - $parameters['recursive'] = $recursive; - } - $results = $object->find($type, array_merge($parameters, $extra)); - } - $paging = array( - 'page' => $page, - 'current' => count($results), - 'count' => $count, - 'prevPage' => ($page > 1), - 'nextPage' => ($count > ($page * $limit)), - 'pageCount' => $pageCount, - 'defaults' => array_merge(array('limit' => 20, 'step' => 1), $defaults), - 'options' => $options - ); - if (!isset($this->request->params['paging'])) { - $this->request->params['paging'] = array(); - } - $this->request->params['paging'] = array_merge( - (array)$this->request->params['paging'], - array($object->alias => $paging) - ); - - if (!in_array('Paginator', $this->helpers) && !array_key_exists('Paginator', $this->helpers)) { - $this->helpers[] = 'Paginator'; - } - return $results; + return $this->Components->load('Paginator', $this->paginate)->paginate($object, $scope, $whitelist); } /** diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 706323f3a..979f90dcf 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -343,7 +343,13 @@ class CakeRoute { if (!empty($params['named']) && is_array($params['named'])) { $named = array(); foreach ($params['named'] as $key => $value) { - $named[] = $key . $separator . $value; + if (is_array($value)) { + foreach ($value as $namedKey => $namedValue) { + $named[] = $key . "[$namedKey]" . $separator . $namedValue; + } + } else { + $named[] = $key . $separator . $value; + } } $params['pass'] = $params['pass'] . '/' . implode('/', $named); } diff --git a/cake/libs/router.php b/cake/libs/router.php index 010511cb2..91261c6ce 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -937,8 +937,15 @@ class Router { } if (!empty($named)) { - foreach ($named as $name => $value) { - $output .= '/' . $name . self::$named['separator'] . $value; + foreach ($named as $name => $value) { + if (is_array($value)) { + $flattend = Set::flatten($value, ']['); + foreach ($flattend as $namedKey => $namedValue) { + $output .= '/' . $name . "[$namedKey]" . self::$named['separator'] . $namedValue; + } + } else { + $output .= '/' . $name . self::$named['separator'] . $value; + } } } return $output; @@ -1202,7 +1209,22 @@ class Router { if ($passIt) { $pass[] = $param; } else { - $named[$key] = $val; + if (preg_match_all('/\[([A-Za-z0-9_-]+)?\]/', $key, $matches, PREG_SET_ORDER)) { + $matches = array_reverse($matches); + $key = array_shift(explode('[', $key)); + $arr = $val; + foreach ($matches as $match) { + if (empty($match[1])) { + $arr = array($arr); + } else { + $arr = array( + $match[1] => $arr + ); + } + } + $val = $arr; + } + $named = array_merge_recursive($named, array($key => $val)); } } else { $pass[] = $param; diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php new file mode 100644 index 000000000..eebdd3304 --- /dev/null +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -0,0 +1,485 @@ + + * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice + * + * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests + * @package cake + * @subpackage cake.cake.tests.cases.libs.controller.components + * @since CakePHP(tm) v 2.0 + * @license MIT License (http://www.opensource.org/licenses/mit-license.php) + */ +App::import('Controller', 'Controller', false); +App::import('Core', array('CakeRequest', 'CakeResponse')); + +/** + * PaginatorTestController class + * + * @package cake + * @subpackage cake.tests.cases.libs.controller.components + */ +class PaginatorTestController extends Controller { +/** + * name property + * + * @var string 'PaginatorTest' + * @access public + */ + public $name = 'PaginatorTest'; + +/** + * uses property + * + * @var array + * @access public + */ + //public $uses = null; + +/** + * components property + * + * @var array + * @access public + */ + public $components = array('Paginator'); +} + +/** + * ControllerPost class + * + * @package cake + * @subpackage cake.tests.cases.libs.controller.components + */ +class ControllerPost extends CakeTestModel { + +/** + * name property + * + * @var string 'ControllerPost' + * @access public + */ + public $name = 'ControllerPost'; + +/** + * useTable property + * + * @var string 'posts' + * @access public + */ + public $useTable = 'posts'; + +/** + * invalidFields property + * + * @var array + * @access public + */ + public $invalidFields = array('name' => 'error_msg'); + +/** + * lastQuery property + * + * @var mixed null + * @access public + */ + public $lastQuery = null; + +/** + * beforeFind method + * + * @param mixed $query + * @access public + * @return void + */ + function beforeFind($query) { + $this->lastQuery = $query; + } + +/** + * find method + * + * @param mixed $type + * @param array $options + * @access public + * @return void + */ + function find($type, $options = array()) { + if ($type == 'popular') { + $conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1'); + $options = Set::merge($options, compact('conditions')); + return parent::find('all', $options); + } + return parent::find($type, $options); + } +} + +/** + * ControllerPaginateModel class + * + * @package cake + * @subpackage cake.tests.cases.libs.controller.components + */ +class ControllerPaginateModel extends CakeTestModel { + +/** + * name property + * + * @var string 'ControllerPaginateModel' + * @access public + */ + public $name = 'ControllerPaginateModel'; + +/** + * useTable property + * + * @var string 'comments' + * @access public + */ + public $useTable = 'comments'; + +/** + * paginate method + * + * @return void + */ + public function paginate($conditions, $fields, $order, $limit, $page, $recursive, $extra) { + $this->extra = $extra; + } + +/** + * paginateCount + * + * @access public + * @return void + */ + function paginateCount($conditions, $recursive, $extra) { + $this->extraCount = $extra; + } +} + +/** + * ControllerComment class + * + * @package cake + * @subpackage cake.tests.cases.libs.controller.components + */ +class ControllerComment extends CakeTestModel { + +/** + * name property + * + * @var string 'Comment' + * @access public + */ + public $name = 'Comment'; + +/** + * useTable property + * + * @var string 'comments' + * @access public + */ + public $useTable = 'comments'; + +/** + * alias property + * + * @var string 'ControllerComment' + * @access public + */ + public $alias = 'ControllerComment'; +} + +class PaginatorTest extends CakeTestCase { + +/** + * fixtures property + * + * @var array + * @access public + */ + public $fixtures = array('core.post', 'core.comment'); + +/** + * testPaginate method + * + * @access public + * @return void + */ + function testPaginate() { + $request = new CakeRequest('controller_posts/index'); + $request->params['pass'] = $request->params['named'] = array(); + + $Controller = new PaginatorTestController($request); + $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->passedArgs[] = '1'; + $Controller->params['url'] = array(); + $Controller->constructClasses(); + + $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); + $this->assertEqual($results, array(1, 2, 3)); + + $results = Set::extract($Controller->Paginator->paginate('ControllerComment'), '{n}.ControllerComment.id'); + $this->assertEqual($results, array(1, 2, 3, 4, 5, 6)); + + $Controller->modelClass = null; + + $Controller->uses[0] = 'Plugin.ControllerPost'; + $results = Set::extract($Controller->Paginator->paginate(), '{n}.ControllerPost.id'); + $this->assertEqual($results, array(1, 2, 3)); + + $Controller->passedArgs = array('page' => '-1'); + $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); + $this->assertEqual($results, array(1, 2, 3)); + + $Controller->passedArgs = array('sort' => 'ControllerPost.id', 'direction' => 'asc'); + $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); + $this->assertEqual($results, array(1, 2, 3)); + + $Controller->passedArgs = array('sort' => 'ControllerPost.id', 'direction' => 'desc'); + $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); + $this->assertEqual($results, array(3, 2, 1)); + + $Controller->passedArgs = array('sort' => 'id', 'direction' => 'desc'); + $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); + $this->assertEqual($results, array(3, 2, 1)); + + $Controller->passedArgs = array('sort' => 'NotExisting.field', 'direction' => 'desc'); + $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1, 'Invalid field in query %s'); + $this->assertEqual($results, array(1, 2, 3)); + + $Controller->passedArgs = array('sort' => 'ControllerPost.author_id', 'direction' => 'allYourBase'); + $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); + $this->assertEqual($Controller->ControllerPost->lastQuery['order'][0], array('ControllerPost.author_id' => 'asc')); + $this->assertEqual($results, array(1, 3, 2)); + + $Controller->passedArgs = array('page' => '1 " onclick="alert(\'xss\');">'); + $Controller->Paginator->settings = array('limit' => 1); + $Controller->Paginator->paginate('ControllerPost'); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1, 'XSS exploit opened %s'); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['options']['page'], 1, 'XSS exploit opened %s'); + + $Controller->passedArgs = array(); + $Controller->Paginator->settings = array('limit' => 0); + $Controller->Paginator->paginate('ControllerPost'); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['pageCount'], 3); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['prevPage'], false); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['nextPage'], true); + + $Controller->passedArgs = array(); + $Controller->Paginator->settings = array('limit' => 'garbage!'); + $Controller->Paginator->paginate('ControllerPost'); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['pageCount'], 3); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['prevPage'], false); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['nextPage'], true); + + $Controller->passedArgs = array(); + $Controller->Paginator->settings = array('limit' => '-1'); + $Controller->Paginator->paginate('ControllerPost'); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['pageCount'], 3); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['prevPage'], false); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['nextPage'], true); + } + +/** + * testPaginateExtraParams method + * + * @access public + * @return void + */ + function testPaginateExtraParams() { + $request = new CakeRequest('controller_posts/index'); + $request->params['pass'] = $request->params['named'] = array(); + + $Controller = new PaginatorTestController($request); + + $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->passedArgs[] = '1'; + $Controller->params['url'] = array(); + $Controller->constructClasses(); + + $Controller->passedArgs = array('page' => '-1', 'contain' => array('ControllerComment')); + $result = $Controller->Paginator->paginate('ControllerPost'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); + $this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(1, 2, 3)); + $this->assertTrue(!isset($Controller->ControllerPost->lastQuery['contain'])); + + $Controller->passedArgs = array('page' => '-1'); + $Controller->Paginator->settings = array('ControllerPost' => array('contain' => array('ControllerComment'))); + $result = $Controller->Paginator->paginate('ControllerPost'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); + $this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(1, 2, 3)); + $this->assertTrue(isset($Controller->ControllerPost->lastQuery['contain'])); + + $Controller->Paginator->settings = array('ControllerPost' => array('popular', 'fields' => array('id', 'title'))); + $result = $Controller->Paginator->paginate('ControllerPost'); + $this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(2, 3)); + $this->assertEqual($Controller->ControllerPost->lastQuery['conditions'], array('ControllerPost.id > ' => '1')); + + $Controller->passedArgs = array('limit' => 12); + $Controller->Paginator->settings = array('limit' => 30); + $result = $Controller->Paginator->paginate('ControllerPost'); + $paging = $Controller->params['paging']['ControllerPost']; + + $this->assertEqual($Controller->ControllerPost->lastQuery['limit'], 12); + $this->assertEqual($paging['options']['limit'], 12); + + $Controller = new PaginatorTestController($request); + $Controller->uses = array('ControllerPaginateModel'); + $Controller->params['url'] = array(); + $Controller->constructClasses(); + $Controller->Paginator->settings = array( + 'ControllerPaginateModel' => array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id') + ); + $result = $Controller->Paginator->paginate('ControllerPaginateModel'); + $expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id'); + $this->assertEqual($Controller->ControllerPaginateModel->extra, $expected); + $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); + + $Controller->Paginator->settings = array( + 'ControllerPaginateModel' => array('foo', 'contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id') + ); + $Controller->Paginator->paginate('ControllerPaginateModel'); + $expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id', 'type' => 'foo'); + $this->assertEqual($Controller->ControllerPaginateModel->extra, $expected); + $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); + } + +/** + * testPaginatePassedArgs method + * + * @return void + */ + public function testPaginatePassedArgs() { + $request = new CakeRequest('controller_posts/index'); + $request->params['pass'] = $request->params['named'] = array(); + + $Controller = new PaginatorTestController($request); + $Controller->uses = array('ControllerPost'); + $Controller->passedArgs[] = array('1', '2', '3'); + $Controller->params['url'] = array(); + $Controller->constructClasses(); + + $Controller->Paginator->settings = array( + 'fields' => array(), + 'order' => '', + 'limit' => 5, + 'page' => 1, + 'recursive' => -1 + ); + $conditions = array(); + $Controller->Paginator->paginate('ControllerPost',$conditions); + + $expected = array( + 'fields' => array(), + 'order' => '', + 'limit' => 5, + 'page' => 1, + 'recursive' => -1, + 'conditions' => array() + ); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options'],$expected); + } + +/** + * Test that special paginate types are called and that the type param doesn't leak out into defaults or options. + * + * @return void + */ + function testPaginateSpecialType() { + $request = new CakeRequest('controller_posts/index'); + $request->params['pass'] = $request->params['named'] = array(); + + $Controller = new PaginatorTestController($request); + $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->passedArgs[] = '1'; + $Controller->params['url'] = array(); + $Controller->constructClasses(); + + $Controller->Paginator->settings = array('ControllerPost' => array('popular', 'fields' => array('id', 'title'))); + $result = $Controller->Paginator->paginate('ControllerPost'); + + $this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(2, 3)); + $this->assertEqual($Controller->ControllerPost->lastQuery['conditions'], array('ControllerPost.id > ' => '1')); + $this->assertFalse(isset($Controller->params['paging']['ControllerPost']['defaults'][0])); + $this->assertFalse(isset($Controller->params['paging']['ControllerPost']['options'][0])); + } + +/** + * testDefaultPaginateParams method + * + * @access public + * @return void + */ + function testDefaultPaginateParams() { + $request = new CakeRequest('controller_posts/index'); + $request->params['pass'] = $request->params['named'] = array(); + + $Controller = new PaginatorTestController($request); + $Controller->modelClass = 'ControllerPost'; + $Controller->params['url'] = array(); + $Controller->constructClasses(); + $Controller->Paginator->settings = array('order' => 'ControllerPost.id DESC'); + $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['defaults']['order'], 'ControllerPost.id DESC'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['order'], 'ControllerPost.id DESC'); + $this->assertEqual($results, array(3, 2, 1)); + } + +/** + * test paginate() and virtualField interactions + * + * @return void + */ + function testPaginateOrderVirtualField() { + $request = new CakeRequest('controller_posts/index'); + $request->params['pass'] = $request->params['named'] = array(); + + $Controller = new PaginatorTestController($request); + $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->params['url'] = array(); + $Controller->constructClasses(); + $Controller->ControllerPost->virtualFields = array( + 'offset_test' => 'ControllerPost.id + 1' + ); + + $Controller->Paginator->settings = array( + 'fields' => array('id', 'title', 'offset_test'), + 'order' => array('offset_test' => 'DESC') + ); + $result = $Controller->Paginator->paginate('ControllerPost'); + $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(4, 3, 2)); + + $Controller->passedArgs = array('sort' => 'offset_test', 'direction' => 'asc'); + $result = $Controller->Paginator->paginate('ControllerPost'); + $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(2, 3, 4)); + } + + function testPaginateMissingModel() { + $request = new CakeRequest('controller_posts/index'); + $request->params['pass'] = $request->params['named'] = array(); + + $Controller = new PaginatorTestController($request); + $Controller->constructClasses(); + $this->expectException('MissingModelException'); + $Controller->Paginator->paginate('MissingModel'); + } +} \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 089955373..0521283b2 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -597,350 +597,6 @@ class ControllerTest extends CakeTestCase { Configure::write('Cache.disable', true); } -/** - * testPaginate method - * - * @access public - * @return void - */ - function testPaginate() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new Controller($request); - $Controller->uses = array('ControllerPost', 'ControllerComment'); - $Controller->passedArgs[] = '1'; - $Controller->params['url'] = array(); - $Controller->constructClasses(); - - $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($results, array(1, 2, 3)); - - $results = Set::extract($Controller->paginate('ControllerComment'), '{n}.ControllerComment.id'); - $this->assertEqual($results, array(1, 2, 3, 4, 5, 6)); - - $Controller->modelClass = null; - - $Controller->uses[0] = 'Plugin.ControllerPost'; - $results = Set::extract($Controller->paginate(), '{n}.ControllerPost.id'); - $this->assertEqual($results, array(1, 2, 3)); - - $Controller->passedArgs = array('page' => '-1'); - $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertEqual($results, array(1, 2, 3)); - - $Controller->passedArgs = array('sort' => 'ControllerPost.id', 'direction' => 'asc'); - $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertEqual($results, array(1, 2, 3)); - - $Controller->passedArgs = array('sort' => 'ControllerPost.id', 'direction' => 'desc'); - $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertEqual($results, array(3, 2, 1)); - - $Controller->passedArgs = array('sort' => 'id', 'direction' => 'desc'); - $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertEqual($results, array(3, 2, 1)); - - $Controller->passedArgs = array('sort' => 'NotExisting.field', 'direction' => 'desc'); - $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1, 'Invalid field in query %s'); - $this->assertEqual($results, array(1, 2, 3)); - - $Controller->passedArgs = array('sort' => 'ControllerPost.author_id', 'direction' => 'allYourBase'); - $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->ControllerPost->lastQuery['order'][0], array('ControllerPost.author_id' => 'asc')); - $this->assertEqual($results, array(1, 3, 2)); - - $Controller->passedArgs = array('page' => '1 " onclick="alert(\'xss\');">'); - $Controller->paginate = array('limit' => 1); - $Controller->paginate('ControllerPost'); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1, 'XSS exploit opened %s'); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['options']['page'], 1, 'XSS exploit opened %s'); - - $Controller->passedArgs = array(); - $Controller->paginate = array('limit' => 0); - $Controller->paginate('ControllerPost'); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['pageCount'], 3); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['prevPage'], false); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['nextPage'], true); - - $Controller->passedArgs = array(); - $Controller->paginate = array('limit' => 'garbage!'); - $Controller->paginate('ControllerPost'); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['pageCount'], 3); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['prevPage'], false); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['nextPage'], true); - - $Controller->passedArgs = array(); - $Controller->paginate = array('limit' => '-1'); - $Controller->paginate('ControllerPost'); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['pageCount'], 3); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['prevPage'], false); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['nextPage'], true); - } - -/** - * testPaginateExtraParams method - * - * @access public - * @return void - */ - function testPaginateExtraParams() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new Controller($request); - - $Controller->uses = array('ControllerPost', 'ControllerComment'); - $Controller->passedArgs[] = '1'; - $Controller->params['url'] = array(); - $Controller->constructClasses(); - - $Controller->passedArgs = array('page' => '-1', 'contain' => array('ControllerComment')); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(1, 2, 3)); - $this->assertTrue(!isset($Controller->ControllerPost->lastQuery['contain'])); - - $Controller->passedArgs = array('page' => '-1'); - $Controller->paginate = array('ControllerPost' => array('contain' => array('ControllerComment'))); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(1, 2, 3)); - $this->assertTrue(isset($Controller->ControllerPost->lastQuery['contain'])); - - $Controller->paginate = array('ControllerPost' => array('popular', 'fields' => array('id', 'title'))); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(2, 3)); - $this->assertEqual($Controller->ControllerPost->lastQuery['conditions'], array('ControllerPost.id > ' => '1')); - - $Controller->passedArgs = array('limit' => 12); - $Controller->paginate = array('limit' => 30); - $result = $Controller->paginate('ControllerPost'); - $paging = $Controller->params['paging']['ControllerPost']; - - $this->assertEqual($Controller->ControllerPost->lastQuery['limit'], 12); - $this->assertEqual($paging['options']['limit'], 12); - - $Controller = new Controller($request); - $Controller->uses = array('ControllerPaginateModel'); - $Controller->params['url'] = array(); - $Controller->constructClasses(); - $Controller->paginate = array( - 'ControllerPaginateModel' => array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id') - ); - $result = $Controller->paginate('ControllerPaginateModel'); - $expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id'); - $this->assertEqual($Controller->ControllerPaginateModel->extra, $expected); - $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); - - $Controller->paginate = array( - 'ControllerPaginateModel' => array('foo', 'contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id') - ); - $Controller->paginate('ControllerPaginateModel'); - $expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id', 'type' => 'foo'); - $this->assertEqual($Controller->ControllerPaginateModel->extra, $expected); - $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); - } - -/** - * testPaginateMaxLimit - * - * @return void - * @access public - */ - function testPaginateMaxLimit() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new Controller($request); - - $Controller->uses = array('ControllerPost', 'ControllerComment'); - $Controller->passedArgs[] = '1'; - $Controller->params['url'] = array(); - $Controller->constructClasses(); - - $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000'); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 100); - - $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000', 'maxLimit' => 1000); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 100); - - $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '10'); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 10); - - $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000'); - $Controller->paginate = array('maxLimit' => 2000); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 1000); - - $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '5000'); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 2000); - } - -/** - * testPaginateFieldsDouble method - * - * @return void - * @access public - */ - function testPaginateFieldsDouble(){ - $request = new CakeRequest('controller_posts/index'); - - $Controller = new Controller($request); - $Controller->uses = array('ControllerPost'); - $Controller->request = $this->getMock('CakeRequest'); - $Controller->request->params['url'] = array(); - $Controller->constructClasses(); - - $Controller->paginate = array( - 'fields' => array( - 'ControllerPost.id', - 'radians(180.0) as floatvalue' - ), - 'order' => array('ControllerPost.created'=>'DESC'), - 'limit' => 1, - 'page' => 1, - 'recursive' => -1 - ); - $conditions = array(); - $result = $Controller->paginate('ControllerPost',$conditions); - $expected = array( - array( - 'ControllerPost' => array( - 'id' => 3, - ), - 0 => array( - 'floatvalue' => '3.14159265358979', - ), - ), - ); - $this->assertEqual($result, $expected); - } - - -/** - * testPaginatePassedArgs method - * - * @return void - */ - public function testPaginatePassedArgs() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new Controller($request); - $Controller->uses = array('ControllerPost'); - $Controller->passedArgs[] = array('1', '2', '3'); - $Controller->params['url'] = array(); - $Controller->constructClasses(); - - $Controller->paginate = array( - 'fields' => array(), - 'order' => '', - 'limit' => 5, - 'page' => 1, - 'recursive' => -1 - ); - $conditions = array(); - $Controller->paginate('ControllerPost',$conditions); - - $expected = array( - 'fields' => array(), - 'order' => '', - 'limit' => 5, - 'maxLimit' => 100, - 'page' => 1, - 'recursive' => -1, - 'conditions' => array() - ); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options'],$expected); - } - -/** - * Test that special paginate types are called and that the type param doesn't leak out into defaults or options. - * - * @return void - */ - function testPaginateSpecialType() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new Controller($request); - $Controller->uses = array('ControllerPost', 'ControllerComment'); - $Controller->passedArgs[] = '1'; - $Controller->params['url'] = array(); - $Controller->constructClasses(); - - $Controller->paginate = array('ControllerPost' => array('popular', 'fields' => array('id', 'title'))); - $result = $Controller->paginate('ControllerPost'); - - $this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(2, 3)); - $this->assertEqual($Controller->ControllerPost->lastQuery['conditions'], array('ControllerPost.id > ' => '1')); - $this->assertFalse(isset($Controller->params['paging']['ControllerPost']['defaults'][0])); - $this->assertFalse(isset($Controller->params['paging']['ControllerPost']['options'][0])); - } - -/** - * testDefaultPaginateParams method - * - * @access public - * @return void - */ - function testDefaultPaginateParams() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new Controller($request); - $Controller->modelClass = 'ControllerPost'; - $Controller->params['url'] = array(); - $Controller->paginate = array('order' => 'ControllerPost.id DESC'); - $Controller->constructClasses(); - $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['defaults']['order'], 'ControllerPost.id DESC'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['order'], 'ControllerPost.id DESC'); - $this->assertEqual($results, array(3, 2, 1)); - } - -/** - * test paginate() and virtualField interactions - * - * @return void - */ - function testPaginateOrderVirtualField() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new Controller($request); - $Controller->uses = array('ControllerPost', 'ControllerComment'); - $Controller->params['url'] = array(); - $Controller->constructClasses(); - $Controller->ControllerPost->virtualFields = array( - 'offset_test' => 'ControllerPost.id + 1' - ); - - $Controller->paginate = array( - 'fields' => array('id', 'title', 'offset_test'), - 'order' => array('offset_test' => 'DESC') - ); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(4, 3, 2)); - - $Controller->passedArgs = array('sort' => 'offset_test', 'direction' => 'asc'); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(2, 3, 4)); - } - /** * testFlash method * @@ -1648,4 +1304,33 @@ class ControllerTest extends CakeTestCase { $this->assertType('SecurityComponent', $Controller->Security); $this->assertType('ControllerComment', $Controller->ControllerComment); } + +/** + * test that using Controller::paginate() falls back to PaginatorComponent + * + * @return void + */ + function testPaginateBackwardsCompatibility() { + $request = new CakeRequest('controller_posts/index'); + $request->params['pass'] = $request->params['named'] = array(); + + $Controller = new Controller($request); + $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->passedArgs[] = '1'; + $Controller->params['url'] = array(); + $Controller->constructClasses(); + $this->assertEqual($Controller->paginate, array('page' => 1, 'limit' => 20)); + + $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); + $this->assertEqual($results, array(1, 2, 3)); + + $Controller->passedArgs = array(); + $Controller->paginate = array('limit' => '-1'); + $this->assertEqual($Controller->paginate, array('limit' => '-1')); + $Controller->paginate('ControllerPost'); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['pageCount'], 3); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['prevPage'], false); + $this->assertIdentical($Controller->params['paging']['ControllerPost']['nextPage'], true); + } } diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index ffe168ac8..e0def56f9 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -383,6 +383,113 @@ class RouterTest extends CakeTestCase { $this->assertEqual($result, $expected); } +/** + * Tests using arrays in named parameters + * + * @return void + */ + function testArrayNamedParameters() { + $result = Router::url(array('controller' => 'tests', 'pages' => array( + 1, 2, 3 + ))); + $expected = '/tests/index/pages[0]:1/pages[1]:2/pages[2]:3'; + $this->assertEqual($result, $expected); + + $result = Router::url(array('controller' => 'tests', + 'pages' => array( + 'param1' => array( + 'one', + 'two' + ), + 'three' + ) + )); + $expected = '/tests/index/pages[param1][0]:one/pages[param1][1]:two/pages[0]:three'; + $this->assertEqual($result, $expected); + + $result = Router::url(array('controller' => 'tests', + 'pages' => array( + 'param1' => array( + 'one' => 1, + 'two' => 2 + ), + 'three' + ) + )); + $expected = '/tests/index/pages[param1][one]:1/pages[param1][two]:2/pages[0]:three'; + $this->assertEqual($result, $expected); + + $result = Router::url(array('controller' => 'tests', + 'super' => array( + 'nested' => array( + 'array' => 'awesome', + 'something' => 'else' + ), + 'cool' + ) + )); + $expected = '/tests/index/super[nested][array]:awesome/super[nested][something]:else/super[0]:cool'; + $this->assertEqual($result, $expected); + + $result = Router::url(array('controller' => 'tests', 'namedParam' => array( + 'keyed' => 'is an array', + 'test' + ))); + $expected = '/tests/index/namedParam[keyed]:is an array/namedParam[0]:test'; + $this->assertEqual($result, $expected); + + $result = Router::parse('/tests/action/var[]:val1/var[]:val2'); + $expected = array( + 'controller' => 'tests', + 'action' => 'action', + 'named' => array( + 'var' => array( + 'val1', + 'val2' + ) + ), + 'pass' => array(), + 'plugin' => null + ); + $this->assertEqual($result, $expected); + + $result = Router::parse('/tests/action/theanswer[is]:42/var[]:val2/var[]:val3'); + $expected = array( + 'controller' => 'tests', + 'action' => 'action', + 'named' => array( + 'theanswer' => array( + 'is' => 42 + ), + 'var' => array( + 'val2', + 'val3' + ) + ), + 'pass' => array(), + 'plugin' => null + ); + $this->assertEqual($result, $expected); + + $result = Router::parse('/tests/action/theanswer[is][not]:42/theanswer[]:5/theanswer[is]:6'); + $expected = array( + 'controller' => 'tests', + 'action' => 'action', + 'named' => array( + 'theanswer' => array( + 5, + 'is' => array( + 6, + 'not' => 42 + ) + ), + ), + 'pass' => array(), + 'plugin' => null + ); + $this->assertEqual($result, $expected); + } + /** * Test generation of routes with query string parameters. * From 19f9caed28f1100d87e7ce51e9e2cbaef1972469 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 14 Dec 2010 21:59:53 -0500 Subject: [PATCH 267/378] Fixing tests so they initialize the session, before trying to test things. --- cake/tests/cases/libs/controller/components/session.test.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cake/tests/cases/libs/controller/components/session.test.php b/cake/tests/cases/libs/controller/components/session.test.php index bf605f1df..a2fa96410 100644 --- a/cake/tests/cases/libs/controller/components/session.test.php +++ b/cake/tests/cases/libs/controller/components/session.test.php @@ -143,6 +143,7 @@ class SessionComponentTest extends CakeTestCase { */ function testSessionIdConsistentAcrossRequestAction() { $Session = new SessionComponent($this->ComponentCollection); + $Session->check('Test'); $this->assertTrue(isset($_SESSION)); $Object = new Object(); @@ -287,6 +288,7 @@ class SessionComponentTest extends CakeTestCase { function testSessionId() { unset($_SESSION); $Session = new SessionComponent($this->ComponentCollection); + $Session->check('test'); $this->assertEquals(session_id(), $Session->id()); } From 10bf41a4df1cd16404d80e240a6af0ca910365a8 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 14 Dec 2010 19:00:26 -0800 Subject: [PATCH 268/378] Merge commit '42a5ebf47b73bbdf200f0238e30e6d4893695f80' into 2.0 --- .../cases/libs/controller/components/paginator.test.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index eebdd3304..93ee5b6b5 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -473,13 +473,17 @@ class PaginatorTest extends CakeTestCase { $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(2, 3, 4)); } +/** + * Tests for missing models + * + * @expectedException MissingModelException + */ function testPaginateMissingModel() { $request = new CakeRequest('controller_posts/index'); $request->params['pass'] = $request->params['named'] = array(); $Controller = new PaginatorTestController($request); $Controller->constructClasses(); - $this->expectException('MissingModelException'); $Controller->Paginator->paginate('MissingModel'); } } \ No newline at end of file From 75af48b774120394b8870a50b01474eabc27e70f Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 14 Dec 2010 22:09:29 -0500 Subject: [PATCH 269/378] Updating bake templates to let PUT methods through as well. --- cake/console/templates/default/actions/controller_actions.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/console/templates/default/actions/controller_actions.ctp b/cake/console/templates/default/actions/controller_actions.ctp index b02ad7647..0a4c9d311 100644 --- a/cake/console/templates/default/actions/controller_actions.ctp +++ b/cake/console/templates/default/actions/controller_actions.ctp @@ -72,7 +72,7 @@ if (!$this->->exists()) { throw new NotFoundException(__('Invalid ')); } - if ($this->request->is('post')) { + if ($this->request->is('post') || $this->request->is('put')) { if ($this->->save($this->request->data)) { $this->Session->setFlash(__('The has been saved')); From 84414eeb075ab598e4b9018e0c90bd36cd1d4117 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 14 Dec 2010 22:35:43 -0500 Subject: [PATCH 270/378] Removing CakeSession::watch() and CakeSession::ignore(). You should use logging, or an interactive debugger instead. --- cake/libs/cake_session.php | 53 --------------------- cake/tests/cases/libs/cake_session.test.php | 42 ---------------- 2 files changed, 95 deletions(-) diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php index a0b44b9cb..2d201f81d 100644 --- a/cake/libs/cake_session.php +++ b/cake/libs/cake_session.php @@ -100,13 +100,6 @@ class CakeSession { */ public static $sessionTime = false; -/** - * Keeps track of keys to watch for writes on - * - * @var array - */ - public static $watchKeys = array(); - /** * Current Session id * @@ -261,9 +254,6 @@ class CakeSession { */ public static function delete($name) { if (self::check($name)) { - if (in_array($name, self::$watchKeys)) { - throw new CakeSessionException(__('Deleting session key {%s}', $name)); - } self::__overwrite($_SESSION, Set::remove($_SESSION, $name)); return (self::check($name) == false); } @@ -402,46 +392,6 @@ class CakeSession { return false; } -/** - * Tells Session to write a notification when a certain session path or subpath is written to - * - * @param mixed $var The variable path to watch - * @return void - */ - public static function watch($var) { - if (!self::started() && !self::start()) { - return false; - } - if (empty($var)) { - return false; - } - if (!in_array($var, self::$watchKeys, true)) { - self::$watchKeys[] = $var; - } - } - -/** - * Tells Session to stop watching a given key path - * - * @param mixed $var The variable path to watch - * @return void - */ - public static function ignore($var) { - if (!self::started() && !self::start()) { - return false; - } - if (!in_array($var, self::$watchKeys)) { - return; - } - foreach (self::$watchKeys as $i => $key) { - if ($key == $var) { - unset(self::$watchKeys[$i]); - self::$watchKeys = array_values(self::$watchKeys); - return; - } - } - } - /** * Writes value to given session variable name. * @@ -461,9 +411,6 @@ class CakeSession { $write = array($name => $value); } foreach ($write as $key => $val) { - if (in_array($key, self::$watchKeys)) { - throw new CakeSessionException(__('Writing session key {%s}: %s', $key, var_export($val, true))); - } self::__overwrite($_SESSION, Set::insert($_SESSION, $key, $val)); if (Set::classicExtract($_SESSION, $key) !== $val) { return false; diff --git a/cake/tests/cases/libs/cake_session.test.php b/cake/tests/cases/libs/cake_session.test.php index 2c84254dd..e25c9416d 100644 --- a/cake/tests/cases/libs/cake_session.test.php +++ b/cake/tests/cases/libs/cake_session.test.php @@ -88,7 +88,6 @@ class CakeSessionTest extends CakeTestCase { 'ini' => array(), )); TestCakeSession::init(); - TestCakeSession::$watchKeys = array(); } /** @@ -365,47 +364,6 @@ class CakeSessionTest extends CakeTestCase { $this->assertFalse(TestCakeSession::check('Clearing')); } -/** - * testWatchVar method - * - * @expectedException CakeSessionException - * @access public - * @return void - */ - function testWatchVarWrite() { - $this->assertFalse(TestCakeSession::watch(null)); - - TestCakeSession::write('Watching', "I'm watching you"); - TestCakeSession::watch('Watching'); - TestCakeSession::write('Watching', 'They found us!'); - } - -/** - * Test that deleting watched vars causes exceptions - * - * @expectedException CakeSessionException - * @return void - */ - function testWatchVarDelete() { - TestCakeSession::write('Watching', 'I am watching you.'); - - TestCakeSession::watch('Watching'); - TestCakeSession::delete('Watching'); - } - -/** - * testIgnore method - * - * @access public - * @return void - */ - function testIgnore() { - TestCakeSession::write('Watching', "I'm watching you"); - TestCakeSession::watch('Watching'); - TestCakeSession::ignore('Watching'); - $this->assertTrue(TestCakeSession::write('Watching', 'They found us!')); - } - /** * testDestroy method * From 99407282e5c6bfda96b7ff311138b6007acc7852 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 15 Dec 2010 01:51:00 -0200 Subject: [PATCH 271/378] Updated the config of auth in digest method. --- cake/libs/http/digest_authentication.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/http/digest_authentication.php b/cake/libs/http/digest_authentication.php index ba146e2fc..adcc9dd9d 100644 --- a/cake/libs/http/digest_authentication.php +++ b/cake/libs/http/digest_authentication.php @@ -53,10 +53,10 @@ class DigestAuthentication { */ protected static function _getServerInformation(HttpSocket $http, &$authInfo) { $originalRequest = $http->request; - $http->setAuthConfig(false); + $http->configAuth(false); $http->request($http->request); $http->request = $originalRequest; - $http->setAuthConfig('Digest', $authInfo); + $http->configAuth('Digest', $authInfo); if (empty($http->response['header']['WWW-Authenticate'])) { return false; From 478d158133c3408b0259231b01b144934c58c3df Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 14 Dec 2010 22:52:31 -0500 Subject: [PATCH 272/378] Removing a var_dump because I'm a muppet. --- cake/libs/controller/controller.php | 1 - 1 file changed, 1 deletion(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 7bc58f024..1093c4ac1 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -445,7 +445,6 @@ class Controller extends Object { is_array($this->uses) && !empty($appVars['uses']) ) { $this->uses = array_merge($this->uses, array_diff($appVars['uses'], $this->uses)); - var_dump($this->uses); } $this->_mergeVars($merge, 'AppController', true); } From 575da672b0c81305eb22fe2ba46bd0d1a164a760 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 15 Dec 2010 01:54:37 -0200 Subject: [PATCH 273/378] Fixed basic proxy test. --- cake/tests/cases/libs/http/basic_authentication.test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/tests/cases/libs/http/basic_authentication.test.php b/cake/tests/cases/libs/http/basic_authentication.test.php index 7ba642b64..f886a6686 100644 --- a/cake/tests/cases/libs/http/basic_authentication.test.php +++ b/cake/tests/cases/libs/http/basic_authentication.test.php @@ -53,13 +53,13 @@ class BasicMethodTest extends CakeTestCase { */ public function testProxyAuthentication() { $http = new HttpSocket(); - $http->request['proxy'] = array( + $proxy = array( 'method' => 'Basic', 'user' => 'mark', 'pass' => 'secret' ); - BasicAuthentication::proxyAuthentication($http); + BasicAuthentication::proxyAuthentication($http, $proxy); $this->assertEqual($http->request['header']['Proxy-Authorization'], 'Basic bWFyazpzZWNyZXQ='); } From ad5e7248c56b4e40f53ebe7fb2aa217e52b60d10 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 15 Dec 2010 01:54:48 -0200 Subject: [PATCH 274/378] Fixed documentation. --- cake/libs/http/digest_authentication.php | 1 - 1 file changed, 1 deletion(-) diff --git a/cake/libs/http/digest_authentication.php b/cake/libs/http/digest_authentication.php index adcc9dd9d..21f7ea8e6 100644 --- a/cake/libs/http/digest_authentication.php +++ b/cake/libs/http/digest_authentication.php @@ -32,7 +32,6 @@ class DigestAuthentication { * @param HttpSocket $http * @param array $authInfo * @return void - * @throws Exception * @link http://www.ietf.org/rfc/rfc2617.txt */ public static function authentication(HttpSocket $http, &$authInfo) { From b9143dc7d451d6307aebbf1a74dbaf60248204dd Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 14 Dec 2010 19:58:27 -0800 Subject: [PATCH 275/378] Added ControllerTestCase class for testing controllers. Fixes #1244 --- cake/libs/controller/controller.php | 4 +- cake/libs/dispatcher.php | 16 +- cake/libs/object_collection.php | 14 + cake/libs/router.php | 8 +- cake/tests/cases/libs/all_test_suite.test.php | 1 + .../cases/libs/controller_test_case.test.php | 407 ++++++++++++++++++ .../cases/libs/object_collection.test.php | 20 + cake/tests/lib/controller_test_case.php | 312 ++++++++++++++ cake/tests/lib/test_manager.php | 1 + cake/tests/test_app/config/routes.php | 26 ++ .../controllers/tests_apps_controller.php | 4 + .../test_app/views/layouts/json/default.ctp | 1 + .../test_app/views/tests_apps/json/index.ctp | 1 + 13 files changed, 809 insertions(+), 6 deletions(-) create mode 100644 cake/tests/cases/libs/controller_test_case.test.php create mode 100644 cake/tests/lib/controller_test_case.php create mode 100644 cake/tests/test_app/config/routes.php create mode 100644 cake/tests/test_app/views/layouts/json/default.ctp create mode 100644 cake/tests/test_app/views/tests_apps/json/index.ctp diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 9afc3e315..724fa93aa 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -301,7 +301,7 @@ class Controller extends Object { $this->methods = array_diff($childMethods, $parentMethods); if ($request instanceof CakeRequest) { - $this->_setRequest($request); + $this->setRequest($request); } $this->getResponse(); parent::__construct(); @@ -377,7 +377,7 @@ class Controller extends Object { * @param CakeRequest $request * @return void */ - protected function _setRequest(CakeRequest $request) { + public function setRequest(CakeRequest $request) { $this->request = $request; $this->plugin = isset($request->params['plugin']) ? $request->params['plugin'] : null; diff --git a/cake/libs/dispatcher.php b/cake/libs/dispatcher.php index 4f35138c8..0b498b5b2 100644 --- a/cake/libs/dispatcher.php +++ b/cake/libs/dispatcher.php @@ -99,8 +99,8 @@ class Dispatcher { return; } - $request = $this->parseParams($request, $additionalParams); - $controller = $this->_getController($request); + $this->request = $this->parseParams($request, $additionalParams); + $controller = $this->_getController($this->request); if (!is_object($controller)) { Router::setRequestInfo($request); @@ -198,7 +198,7 @@ class Dispatcher { if (count(Router::$routes) > 0) { $namedExpressions = Router::getNamedExpressions(); extract($namedExpressions); - include CONFIGS . 'routes.php'; + $this->__loadRoutes(); } $params = Router::parse($request->url); @@ -250,6 +250,16 @@ class Dispatcher { return false; } +/** + * Loads route configuration + * + * @return void + * @access protected + */ + protected function __loadRoutes() { + include CONFIGS . 'routes.php'; + } + /** * Outputs cached dispatch view cache * diff --git a/cake/libs/object_collection.php b/cake/libs/object_collection.php index d91f62cc9..a9750f3e8 100644 --- a/cake/libs/object_collection.php +++ b/cake/libs/object_collection.php @@ -221,6 +221,20 @@ abstract class ObjectCollection { $this->_enabled = array_values(array_diff($this->_enabled, (array)$name)); } +/** + * Adds or overwrites an instatiated object to the collection + * + * @param string $name Name of the object + * @param Object $object The object to use + */ + public function set($name = null, $object = null) { + if (!empty($name) && !empty($object)) { + list($plugin, $name) = pluginSplit($name); + $this->_loaded[$name] = $object; + } + return $this->_loaded; + } + /** * Normalizes an object array, creates an array that makes lazy loading * easier diff --git a/cake/libs/router.php b/cake/libs/router.php index 91261c6ce..a4408b92f 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -250,6 +250,9 @@ class Router { throw new RouterException(__('Route classes must extend CakeRoute')); } unset($options['routeClass']); + if ($routeClass == 'RedirectRoute' && isset($defaults['redirect'])) { + $defaults = $defaults['redirect']; + } } self::$routes[] = new $routeClass($route, $defaults, $options); return self::$routes; @@ -284,9 +287,12 @@ class Router { * @see routes * @return array Array of routes */ - public static function redirect($route, $url, $options) { + public static function redirect($route, $url, $options = array()) { App::import('Core', 'route/RedirectRoute'); $options['routeClass'] = 'RedirectRoute'; + if (is_string($url)) { + $url = array('redirect' => $url); + } return self::connect($route, $url, $options); } diff --git a/cake/tests/cases/libs/all_test_suite.test.php b/cake/tests/cases/libs/all_test_suite.test.php index 9c6a46e6a..f1d52c2dc 100644 --- a/cake/tests/cases/libs/all_test_suite.test.php +++ b/cake/tests/cases/libs/all_test_suite.test.php @@ -40,6 +40,7 @@ class AllTestSuiteTest extends PHPUnit_Framework_TestSuite { $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_test_case.test.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_test_fixture.test.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'html_coverage_report.test.php'); + $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'controller_test_case.test.php'); return $suite; } } \ No newline at end of file diff --git a/cake/tests/cases/libs/controller_test_case.test.php b/cake/tests/cases/libs/controller_test_case.test.php new file mode 100644 index 000000000..db66d0a9d --- /dev/null +++ b/cake/tests/cases/libs/controller_test_case.test.php @@ -0,0 +1,407 @@ + array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), + 'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS), + 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS), + 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS) + )); + $this->Case = new ControllerTestCase(); + Router::reload(); + } + +/** + * teardown + * + * @return void + */ + function tearDown() { + $this->Case->controller = null; + App::build(); + } + +/** + * Test that ControllerTestCase::generate() creates mock objects correctly + */ + function testGenerate() { + $Posts = $this->Case->generate('Posts'); + $this->Case->assertEquals($Posts->name, 'Posts'); + $this->Case->assertEquals($Posts->modelClass, 'Post'); + $this->Case->assertNull($Posts->response->send()); + + $Posts = $this->Case->generate('Posts', array( + 'methods' => array( + 'render' + ) + )); + $this->Case->assertNull($Posts->render('index')); + + $Posts = $this->Case->generate('Posts', array( + 'models' => array('Post'), + 'components' => array('RequestHandler') + )); + $this->Case->assertNull($Posts->Post->save(array())); + $this->Case->assertNull($Posts->Post->find('all')); + $this->Case->assertEquals($Posts->Post->useTable, 'posts'); + $this->Case->assertNull($Posts->RequestHandler->isAjax()); + + $Posts = $this->Case->generate('Posts', array( + 'models' => array( + 'Post' => true + ) + )); + $this->Case->assertNull($Posts->Post->save(array())); + $this->Case->assertNull($Posts->Post->find('all')); + + $Posts = $this->Case->generate('Posts', array( + 'models' => array( + 'Post' => array('save'), + ) + )); + $this->Case->assertNull($Posts->Post->save(array())); + $this->Case->assertIsA($Posts->Post->find('all'), 'array'); + + $Posts = $this->Case->generate('Posts', array( + 'models' => array('Post'), + 'components' => array( + 'RequestHandler' => array('isPut'), + 'Email' => array('send'), + 'Session' + ) + )); + $Posts->RequestHandler->expects($this->once()) + ->method('isPut') + ->will($this->returnValue(true)); + $this->assertTrue($Posts->RequestHandler->isPut()); + + $Posts->Auth->Session->expects($this->any()) + ->method('write') + ->will($this->returnValue('written!')); + $this->assertEquals($Posts->Auth->Session->write('something'), 'written!'); + } + +/** + * Tests testAction + */ + function testTestAction() { + $Controller = $this->Case->generate('TestsApps'); + $this->Case->testAction('/tests_apps/index'); + $this->Case->assertIsA($this->Case->controller->viewVars, 'array'); + + $this->Case->testAction('/tests_apps/set_action'); + $results = $this->Case->controller->viewVars; + $expected = array( + 'var' => 'string' + ); + $this->Case->assertEquals($expected, $results); + + $result = $this->Case->controller->response->body(); + $this->Case->assertPattern('/This is the TestsAppsController index view/', $result); + + $this->Case->testAction('/tests_apps/redirect_to'); + $results = $this->Case->headers; + $expected = array( + 'Location' => 'http://cakephp.org' + ); + $this->Case->assertEquals($expected, $results); + } + +/** + * Tests using loaded routes during tests + */ + function testUseRoutes() { + include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php'; + $controller = $this->Case->generate('TestsApps'); + $controller->Components->load('RequestHandler'); + $result = $this->Case->testAction('/tests_apps/index.json', array('return' => 'view')); + $result = json_decode($result, true); + $expected = array('cakephp' => 'cool'); + $this->Case->assertEquals($result, $expected); + + include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php'; + $result = $this->Case->testAction('/some_alias'); + $this->Case->assertEquals($result, 5); + + include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php'; + $this->Case->testAction('/redirect_me_now'); + $result = $this->Case->headers['Location']; + $this->Case->assertEquals($result, 'http://cakephp.org'); + + include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php'; + $this->Case->testAction('/redirect_me'); + $result = $this->Case->headers['Location']; + $this->Case->assertEquals($result, Router::url(array('controller' => 'tests_apps', 'action' => 'some_method'), true)); + } + +/** + * Tests not using loaded routes during tests + */ + function testSkipRoutes() { + include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php'; + + $this->Case->loadRoutes = false; + + $this->expectException('MissingActionException'); + $result = $this->Case->testAction('/tests_apps/index.json', array('return' => 'view')); + } + +/** + * Tests backwards compatibility with setting the return type + */ + function testBCSetReturn() { + $this->Case->autoMock = true; + + $result = $this->Case->testAction('/tests_apps/some_method'); + $this->Case->assertEquals($result, 5); + + $data = array('var' => 'set'); + $result = $this->Case->testAction('/tests_apps_posts/post_var', array( + 'data' => $data, + 'return' => 'vars' + )); + $this->Case->assertEquals($result['data'], $data); + + $result = $this->Case->testAction('/tests_apps/set_action', array( + 'return' => 'view' + )); + $this->Case->assertEquals($result, 'This is the TestsAppsController index view'); + + $result = $this->Case->testAction('/tests_apps/set_action', array( + 'return' => 'contents' + )); + $this->Case->assertPattern('/Case->assertPattern('/This is the TestsAppsController index view/', $result); + $this->Case->assertPattern('/<\/html>/', $result); + } + +/** + * Tests sending POST data to testAction + */ + function testTestActionPostData() { + $this->Case->autoMock = true; + + $data = array( + 'Post' => array( + 'name' => 'Some Post' + ) + ); + $this->Case->testAction('/tests_apps_posts/post_var', array( + 'data' => $data + )); + $this->Case->assertEquals($this->Case->controller->viewVars['data'], $data); + $this->Case->assertEquals($this->Case->controller->data, $data); + + $this->Case->testAction('/tests_apps_posts/post_var/named:param', array( + 'data' => $data + )); + $expected = array( + 'named' => 'param' + ); + $this->Case->assertEqual($this->Case->controller->request->named, $expected); + $this->Case->assertEquals($this->Case->controller->data, $data); + + $result = $this->Case->testAction('/tests_apps_posts/post_var', array( + 'return' => 'vars', + 'method' => 'post', + 'data' => array( + 'name' => 'is jonas', + 'pork' => 'and beans', + ) + )); + $this->assertEqual(array_keys($result['data']), array('name', 'pork')); + + $result = $this->Case->testAction('/tests_apps_posts/add', array('return' => 'vars')); + $this->assertTrue(array_key_exists('posts', $result)); + $this->assertEqual(count($result['posts']), 4); + } + +/** + * Tests sending GET data to testAction + */ + function testTestActionGetData() { + $this->Case->autoMock = true; + + $result = $this->Case->testAction('/tests_apps_posts/url_var', array( + 'method' => 'get', + 'data' => array( + 'some' => 'var', + 'lackof' => 'creativity' + ) + )); + $this->Case->assertEquals($this->Case->controller->request->query['some'], 'var'); + $this->Case->assertEquals($this->Case->controller->request->query['lackof'], 'creativity'); + + $result = $this->Case->testAction('/tests_apps_posts/url_var/var1:value1/var2:val2', array( + 'return' => 'vars', + 'method' => 'get', + )); + $this->assertTrue(isset($result['params']['url']['url'])); + $this->assertEqual(array_keys($result['params']['named']), array('var1', 'var2')); + + $result = $this->Case->testAction('/tests_apps_posts/url_var/gogo/val2', array( + 'return' => 'vars', + 'method' => 'get', + )); + $this->assertEqual($result['params']['pass'], array('gogo', 'val2')); + + $result = $this->Case->testAction('/tests_apps_posts/url_var', array( + 'return' => 'vars', + 'method' => 'get', + 'data' => array( + 'red' => 'health', + 'blue' => 'mana' + ) + )); + $this->assertTrue(isset($result['params']['url']['red'])); + $this->assertTrue(isset($result['params']['url']['blue'])); + $this->assertTrue(isset($result['params']['url']['url'])); + } + +/** + * Tests autoMock ability + */ + function testAutoMock() { + $this->Case->autoMock = true; + $this->Case->testAction('/tests_apps/set_action'); + $results = $this->Case->controller->viewVars; + $expected = array( + 'var' => 'string' + ); + $this->Case->assertEquals($expected, $results); + } + +/** + * Test using testAction and not mocking + */ + function testNoMocking() { + $result = $this->Case->testAction('/tests_apps/some_method'); + $this->Case->assertEquals($result, 5); + + $data = array('var' => 'set'); + $result = $this->Case->testAction('/tests_apps_posts/post_var', array( + 'data' => $data, + 'return' => 'vars' + )); + $this->Case->assertEquals($result['data'], $data); + + $result = $this->Case->testAction('/tests_apps/set_action', array( + 'return' => 'view' + )); + $this->Case->assertEquals($result, 'This is the TestsAppsController index view'); + + $result = $this->Case->testAction('/tests_apps/set_action', array( + 'return' => 'contents' + )); + $this->Case->assertPattern('/Case->assertPattern('/This is the TestsAppsController index view/', $result); + $this->Case->assertPattern('/<\/html>/', $result); + } + +} \ No newline at end of file diff --git a/cake/tests/cases/libs/object_collection.test.php b/cake/tests/cases/libs/object_collection.test.php index fd51cbecd..ac5fb5a4c 100644 --- a/cake/tests/cases/libs/object_collection.test.php +++ b/cake/tests/cases/libs/object_collection.test.php @@ -133,6 +133,26 @@ class ObjectCollectionTest extends CakeTestCase { $this->assertEquals(array('Second'), $result, 'enabled objects are wrong'); } +/** + * Tests set() + * + * @return void + */ + function testSet() { + $this->Objects->load('First'); + + $result = $this->Objects->attached(); + $this->assertEquals(array('First'), $result, 'loaded objects are wrong'); + + $result = $this->Objects->set('First', new SecondGenericObject()); + $this->assertIsA($result['First'], 'SecondGenericObject', 'set failed'); + + $result = $this->Objects->set('Second', new SecondGenericObject()); + $this->assertIsA($result['Second'], 'SecondGenericObject', 'set failed'); + + $this->assertEquals(count($result), 2); + } + /** * creates mock classes for testing * diff --git a/cake/tests/lib/controller_test_case.php b/cake/tests/lib/controller_test_case.php new file mode 100644 index 000000000..d65650601 --- /dev/null +++ b/cake/tests/lib/controller_test_case.php @@ -0,0 +1,312 @@ + + * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice + * + * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests + * @package cake + * @subpackage cake.cake.tests.libs + * @since CakePHP(tm) v 2.0 + * @license MIT License (http://www.opensource.org/licenses/mit-license.php) + */ + +PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); + +require_once CAKE . 'libs' . DS . 'dispatcher.php'; +require_once CAKE_TESTS_LIB . 'cake_test_case.php'; +App::import('Core', array('Router', 'CakeRequest', 'CakeResponse', 'Helper')); + +/** + * ControllerTestDispatcher class + * + * @package cake + * @subpackage cake.cake.tests.lib + */ +class ControllerTestDispatcher extends Dispatcher { + +/** + * The controller to use in the dispatch process + * + * @var Controller + */ + public $testController = null; + +/** + * Use custom routes during tests + * + * @var boolean + */ + public $loadRoutes = true; + +/** + * Returns the test controller + * + * @return Controller + */ + function _getController($request) { + if ($this->testController === null) { + $this->testController = parent::_getController($request); + } + $this->testController->helpers = array_merge(array('InterceptContent'), $this->testController->helpers); + $this->testController->setRequest($request); + $this->testController->response = $this->response; + return $this->testController; + } + +/** + * Loads routes and resets if the test case dictates it should + * + * @return void + * @access private + */ + protected function __loadRoutes() { + parent::__loadRoutes(); + if (!$this->loadRoutes) { + Router::reload(); + } + } +} + +/** + * InterceptContentHelper class + * + * @package cake + * @subpackage cake.cake.tests.lib + */ +class InterceptContentHelper extends Helper { + +/** + * Intercepts and stores the contents of the view before the layout is rendered + * + * @param string $viewFile The view file + */ + function afterRender($viewFile) { + $this->_View->_viewNoLayout = $this->_View->output; + $this->_View->Helpers->unload('InterceptContent'); + } +} + +/** + * ControllerTestCase class + * + * @package cake + * @subpackage cake.cake.tests.lib + */ +class ControllerTestCase extends CakeTestCase { + +/** + * The controller to test in testAction + * + * @var Controller + */ + public $controller = null; + +/** + * Automatically mock controllers that aren't mocked + * + * @var boolean + */ + public $autoMock = false; + +/** + * Use custom routes during tests + * + * @var boolean + */ + public $loadRoutes = true; + +/** + * The resulting view vars of the last testAction call + * + * @var array + */ + public $vars = null; + +/** + * The resulting rendered view of the last testAction call + * + * @var string + */ + public $view = null; + +/** + * The resulting rendered layout+view of the last testAction call + * + * @var string + */ + public $contents = null; + +/** + * The returned result of the dispatch (requestAction), if any + * + * @var string + */ + public $result = null; + +/** + * The headers that would have been sent by the action + * + * @var string + */ + public $headers = null; + +/** + * Used to enable calling ControllerTestCase::testAction() without the testing + * framework thinking that it's a test case + * + * @param string $name The name of the function + * @param array $arguments Array of arguments + * @return Function + */ + public function __call($name, $arguments) { + if ($name == 'testAction') { + return call_user_func_array(array($this, '_testAction'), $arguments); + } + } + +/** + * Tests a controller action. + * + * ### Options: + * - `data` POST or GET data to pass + * - `method` POST or GET + * + * @param string $url The url to test + * @param array $options See options + */ + private function _testAction($url = '', $options = array()) { + $this->vars = $this->result = $this->view = $this->contents = $this->headers = null; + + $options = array_merge(array( + 'data' => array(), + 'method' => 'POST', + 'return' => 'result' + ), $options); + + if (strtoupper($options['method']) == 'GET') { + $_GET = $options['data']; + $_POST = array(); + } else { + $_POST = array('data' => $options['data']); + $_GET = array(); + } + $request = new CakeRequest($url); + $Dispatch = new ControllerTestDispatcher(); + foreach (Router::$routes as $route) { + if (is_a($route, 'RedirectRoute')) { + $route->response = $this->getMock('CakeResponse', array('send')); + } + } + $Dispatch->loadRoutes = $this->loadRoutes; + $request = $Dispatch->parseParams($request); + if (!isset($request->params['controller'])) { + $this->headers = Router::currentRoute()->response->header(); + return; + } + if ($this->controller !== null && Inflector::camelize($request->params['controller']) !== $this->controller->name) { + $this->controller = null; + } + if ($this->controller === null && $this->autoMock) { + $this->generate(Inflector::camelize($request->params['controller'])); + } + $params = array(); + if ($options['return'] == 'result') { + $params['return'] = 1; + $params['bare'] = 1; + $params['requested'] = 1; + } + $Dispatch->testController = $this->controller; + $Dispatch->response = $this->getMock('CakeResponse', array('send')); + $this->result = $Dispatch->dispatch($request, $params); + $this->controller = $Dispatch->testController; + if ($options['return'] != 'result') { + $this->vars = $this->controller->View->viewVars; + $this->view = $this->controller->View->_viewNoLayout; + $this->contents = $this->controller->response->body(); + } + $this->headers = $Dispatch->response->header(); + return $this->{$options['return']}; + } + +/** + * Generates a mocked controller and mocks any classes passed to `$mocks`. By + * default, `_stop()` is stubbed as is sending the response headers, so to not + * interfere with testing. + * + * ### Mocks: + * - `methods` Methods to mock on the controller. `_stop()` is mocked by default + * - `models` Models to mock. Models are added to the ClassRegistry so they any + * time they are instatiated the mock will be created. Pass as key value pairs + * with the value being specific methods on the model to mock. If `true` or + * no value is passed, the entire model will be mocked. + * - `components` Components to mock. Components are only mocked on this controller + * and not within each other (i.e., components on components) + * + * @param string $controller Controller name + * @param array $mocks List of classes and methods to mock + * @return Controller Mocked controller + */ + public function generate($controller, $mocks = array()) { + if (!class_exists($controller.'Controller') && App::import('Controller', $controller) === false) { + throw new MissingControllerException(array('controller' => $controller.'Controller')); + } + ClassRegistry::flush(); + + $mocks = array_merge_recursive(array( + 'methods' => array('_stop'), + 'models' => array(), + 'components' => array() + ), (array)$mocks); + + $_controller = $this->getMock($controller.'Controller', $mocks['methods'], array(), '', false); + $_controller->name = $controller; + $_controller->__construct(); + + foreach ($mocks['models'] as $model => $methods) { + if (is_string($methods)) { + $model = $methods; + $methods = true; + } + if ($methods === true) { + $methods = array(); + } + ClassRegistry::init($model); + $_model = $this->getMock($model, $methods, array(), '', false); + $_model->name = $model; + $_model->__construct(); + ClassRegistry::removeObject($model); + ClassRegistry::addObject($model, $_model); + } + + foreach ($mocks['components'] as $component => $methods) { + if (is_string($methods)) { + $component = $methods; + $methods = true; + } + if ($methods === true) { + $methods = array(); + } + if (!App::import('Component', $component)) { + throw new MissingComponentFileException(array( + 'file' => Inflector::underscore($component) . '.php', + 'class' => $componentClass + )); + } + $_component = $this->getMock($component.'Component', $methods, array(), '', false); + $_controller->Components->set($component, $_component); + } + + $_controller->constructClasses(); + + $this->controller = $_controller; + return $this->controller; + } +} \ No newline at end of file diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index f4f5b4571..9322db04e 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -89,6 +89,7 @@ class TestManager { */ public function __construct($params = array()) { require_once(CAKE_TESTS_LIB . 'cake_test_case.php'); + require_once(CAKE_TESTS_LIB . 'controller_test_case.php'); $this->params = $params; if (isset($params['app'])) { diff --git a/cake/tests/test_app/config/routes.php b/cake/tests/test_app/config/routes.php new file mode 100644 index 000000000..17fdccf25 --- /dev/null +++ b/cake/tests/test_app/config/routes.php @@ -0,0 +1,26 @@ + 'tests_apps', 'action' => 'some_method')); +Router::redirect('/redirect_me_now', 'http://cakephp.org'); +Router::redirect('/redirect_me', array('controller' => 'tests_apps', 'action' => 'some_method')); \ No newline at end of file diff --git a/cake/tests/test_app/controllers/tests_apps_controller.php b/cake/tests/test_app/controllers/tests_apps_controller.php index 28ed43f53..f7f2faf9f 100644 --- a/cake/tests/test_app/controllers/tests_apps_controller.php +++ b/cake/tests/test_app/controllers/tests_apps_controller.php @@ -32,4 +32,8 @@ class TestsAppsController extends AppController { $this->set('var', 'string'); $this->render('index'); } + + function redirect_to() { + $this->redirect('http://cakephp.org'); + } } diff --git a/cake/tests/test_app/views/layouts/json/default.ctp b/cake/tests/test_app/views/layouts/json/default.ctp new file mode 100644 index 000000000..3f290130e --- /dev/null +++ b/cake/tests/test_app/views/layouts/json/default.ctp @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/cake/tests/test_app/views/tests_apps/json/index.ctp b/cake/tests/test_app/views/tests_apps/json/index.ctp new file mode 100644 index 000000000..49236e795 --- /dev/null +++ b/cake/tests/test_app/views/tests_apps/json/index.ctp @@ -0,0 +1 @@ +{"cakephp":"cool"} \ No newline at end of file From 754c9b2c3dd1198c6fb91c479520fc7c0ef6a396 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 15 Dec 2010 02:01:00 -0200 Subject: [PATCH 276/378] Updated to HttpSocket, HttpResponse and CakeSocket use SocketException. --- cake/libs/cake_socket.php | 4 ++-- cake/libs/error/exceptions.php | 8 +++++++ cake/libs/http_response.php | 10 ++++---- cake/libs/http_socket.php | 24 ++++++++++---------- cake/tests/cases/libs/cake_socket.test.php | 2 +- cake/tests/cases/libs/http_response.test.php | 2 +- 6 files changed, 29 insertions(+), 21 deletions(-) diff --git a/cake/libs/cake_socket.php b/cake/libs/cake_socket.php index 531c3b43a..e6f51ee54 100644 --- a/cake/libs/cake_socket.php +++ b/cake/libs/cake_socket.php @@ -100,7 +100,7 @@ class CakeSocket { * Connect the socket to the given host and port. * * @return boolean Success - * @throws Exception + * @throws SocketException */ public function connect() { if ($this->connection != null) { @@ -120,7 +120,7 @@ class CakeSocket { if (!empty($errNum) || !empty($errStr)) { $this->setLastError($errStr, $errNum); - throw new Exception($errStr, $errNum); + throw new SocketException($errStr, $errNum); } $this->connected = is_resource($this->connection); diff --git a/cake/libs/error/exceptions.php b/cake/libs/error/exceptions.php index b6d49061d..dc8538334 100644 --- a/cake/libs/error/exceptions.php +++ b/cake/libs/error/exceptions.php @@ -430,6 +430,14 @@ class CakeSessionException extends CakeException { } */ class ConfigureException extends CakeException { } +/** + * Exception class for Socket. This exception will be thrown from CakeSocket, HttpSocket and HttpResponse when it + * encounters an error. + * + * @package cake.libs + */ +class SocketException extends CakeException { } + /** * Exception class for Xml. This exception will be thrown from Xml when it * encounters an error. diff --git a/cake/libs/http_response.php b/cake/libs/http_response.php index 77b7feb02..ade1b14f4 100644 --- a/cake/libs/http_response.php +++ b/cake/libs/http_response.php @@ -123,15 +123,15 @@ class HttpResponse implements ArrayAccess { * * @param string $message Message to parse * @return void - * @throw Exception + * @throw SocketException */ public function parseResponse($message) { if (!is_string($message)) { - throw new Exception(__('Invalid response.')); + throw new SocketException(__('Invalid response.')); } if (!preg_match("/^(.+\r\n)(.*)(?<=\r\n)\r\n/Us", $message, $match)) { - throw new Exception(__('Invalid HTTP response.')); + throw new SocketException(__('Invalid HTTP response.')); } list(, $statusLine, $header) = $match; @@ -187,7 +187,7 @@ class HttpResponse implements ArrayAccess { * * @param string $body A string continaing the chunked body to decode. * @return mixed Array of response headers and body or false. - * @throws Exception + * @throws SocketException */ protected function _decodeChunkedBody($body) { if (!is_string($body)) { @@ -199,7 +199,7 @@ class HttpResponse implements ArrayAccess { while ($chunkLength !== 0) { if (!preg_match("/^([0-9a-f]+) *(?:;(.+)=(.+))?\r\n/iU", $body, $match)) { - throw new Exception(__('HttpSocket::_decodeChunkedBody - Could not parse malformed chunk.')); + throw new SocketException(__('HttpSocket::_decodeChunkedBody - Could not parse malformed chunk.')); } $chunkSize = 0; diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index cdbb7d77c..b1df3f25d 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -205,7 +205,7 @@ class HttpSocket extends CakeSocket { * * @param mixed $resource Resource or false to disable the resource use * @return void - * @throw Exception + * @throw SocketException */ public function setContentResource($resource) { if ($resource === false) { @@ -213,7 +213,7 @@ class HttpSocket extends CakeSocket { return; } if (!is_resource($resource)) { - throw new Exception(__('Invalid resource.')); + throw new SocketException(__('Invalid resource.')); } $this->_contentResource = $resource; } @@ -366,7 +366,7 @@ class HttpSocket extends CakeSocket { } if (!App::import('Lib', $this->responseClass)) { - throw new Exception(__('Class %s not found.', $this->responseClass)); + throw new SocketException(__('Class %s not found.', $this->responseClass)); } $responseClass = $this->responseClass; $this->response = new $responseClass($response); @@ -525,7 +525,7 @@ class HttpSocket extends CakeSocket { * Set authentication in request * * @return void - * @throws Exception + * @throws SocketException */ protected function _setAuth() { if (empty($this->_auth)) { @@ -534,10 +534,10 @@ class HttpSocket extends CakeSocket { $method = key($this->_auth); $authClass = Inflector::camelize($method) . 'Authentication'; if (!App::import('Lib', 'http/' . $authClass)) { - throw new Exception(__('Unknown authentication method.')); + throw new SocketException(__('Unknown authentication method.')); } if (!method_exists($authClass, 'authentication')) { - throw new Exception(sprintf(__('The %s do not support authentication.'), $authClass)); + throw new SocketException(sprintf(__('The %s do not support authentication.'), $authClass)); } call_user_func("$authClass::authentication", $this, &$this->_auth[$method]); } @@ -546,7 +546,7 @@ class HttpSocket extends CakeSocket { * Set the proxy configuration and authentication * * @return void - * @throws Exception + * @throws SocketException */ protected function _setProxy() { if (empty($this->_proxy) || !isset($this->_proxy['host'], $this->_proxy['port'])) { @@ -560,10 +560,10 @@ class HttpSocket extends CakeSocket { } $authClass = Inflector::camelize($this->_proxy['method']) . 'Authentication'; if (!App::import('Lib', 'http/' . $authClass)) { - throw new Exception(__('Unknown authentication method for proxy.')); + throw new SocketException(__('Unknown authentication method for proxy.')); } if (!method_exists($authClass, 'proxyAuthentication')) { - throw new Exception(sprintf(__('The %s do not support proxy authentication.'), $authClass)); + throw new SocketException(sprintf(__('The %s do not support proxy authentication.'), $authClass)); } call_user_func("$authClass::proxyAuthentication", $this, &$this->_proxy); } @@ -773,7 +773,7 @@ class HttpSocket extends CakeSocket { * @param array $request Needs to contain a 'uri' key. Should also contain a 'method' key, otherwise defaults to GET. * @param string $versionToken The version token to use, defaults to HTTP/1.1 * @return string Request line - * @throws Exception + * @throws SocketException */ protected function _buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') { $asteriskMethods = array('OPTIONS'); @@ -781,7 +781,7 @@ class HttpSocket extends CakeSocket { if (is_string($request)) { $isValid = preg_match("/(.+) (.+) (.+)\r\n/U", $request, $match); if (!$this->quirksMode && (!$isValid || ($match[2] == '*' && !in_array($match[3], $asteriskMethods)))) { - throw new Exception(__('HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.')); + throw new SocketException(__('HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.')); } return $request; } elseif (!is_array($request)) { @@ -799,7 +799,7 @@ class HttpSocket extends CakeSocket { } if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) { - throw new Exception(__('HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', implode(',', $asteriskMethods))); + throw new SocketException(__('HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', implode(',', $asteriskMethods))); } return $request['method'] . ' ' . $request['uri'] . ' ' . $versionToken . "\r\n"; } diff --git a/cake/tests/cases/libs/cake_socket.test.php b/cake/tests/cases/libs/cake_socket.test.php index c14afbff6..8359db3bb 100644 --- a/cake/tests/cases/libs/cake_socket.test.php +++ b/cake/tests/cases/libs/cake_socket.test.php @@ -117,7 +117,7 @@ class CakeSocketTest extends CakeTestCase { * testInvalidConnection method * * @dataProvider invalidConnections - * @expectedException Exception + * @expectedException SocketException * return void */ public function testInvalidConnection($data) { diff --git a/cake/tests/cases/libs/http_response.test.php b/cake/tests/cases/libs/http_response.test.php index 63892535c..5d1647ebf 100644 --- a/cake/tests/cases/libs/http_response.test.php +++ b/cake/tests/cases/libs/http_response.test.php @@ -295,7 +295,7 @@ class HttpResponseTest extends CakeTestCase { * testInvalidParseResponseData * * @dataProvider invalidParseResponseDataProvider - * @expectedException Exception + * @expectedException SocketException * return void */ public function testInvalidParseResponseData($value) { From 29441ca880bd4a06325d1b6e9616aa466bd05bd1 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 14 Dec 2010 20:01:31 -0800 Subject: [PATCH 277/378] Added ObjectCollection test to libs group --- cake/tests/cases/libs/all_libs.test.php | 1 + 1 file changed, 1 insertion(+) diff --git a/cake/tests/cases/libs/all_libs.test.php b/cake/tests/cases/libs/all_libs.test.php index 0bab4f0e9..b0a070b49 100644 --- a/cake/tests/cases/libs/all_libs.test.php +++ b/cake/tests/cases/libs/all_libs.test.php @@ -49,6 +49,7 @@ class AllLibsTest extends PHPUnit_Framework_TestSuite { $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'set.test.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'string.test.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'validation.test.php'); + $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'object_collection.test.php'); return $suite; } } \ No newline at end of file From a6014cfd8de859cf0ccc34e7037fae78d12552be Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 15 Dec 2010 02:02:51 -0200 Subject: [PATCH 278/378] Fixed the define name to run all socket tests. --- cake/tests/cases/libs/all_socket.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/all_socket.test.php b/cake/tests/cases/libs/all_socket.test.php index ec276f580..01af39255 100644 --- a/cake/tests/cases/libs/all_socket.test.php +++ b/cake/tests/cases/libs/all_socket.test.php @@ -38,7 +38,7 @@ class AllSocketTest extends PHPUnit_Framework_TestSuite { $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_socket.test.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'http_socket.test.php'); - $suite->addTestFile(CAKE_TEST_CASES . DS . 'libs' . DS . 'http_response.test.php'); + $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'http_response.test.php'); $suite->addTestDirectory(CORE_TEST_CASES . DS . 'libs' . DS . 'http'); return $suite; } From 7b4ffa2ee9405ab782254e5fb68a0247772965ec Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 14 Dec 2010 23:22:03 -0500 Subject: [PATCH 279/378] Fixing incorrect exception type. --- cake/libs/controller/component_collection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/controller/component_collection.php b/cake/libs/controller/component_collection.php index 90ec17f17..b644902a9 100644 --- a/cake/libs/controller/component_collection.php +++ b/cake/libs/controller/component_collection.php @@ -78,7 +78,7 @@ class ComponentCollection extends ObjectCollection { )); } if (!class_exists($componentClass)) { - throw new MissingComponentFileException(array( + throw new MissingComponentClassException(array( 'file' => Inflector::underscore($component) . '.php', 'class' => $componentClass )); From 1531a7226e8cb1317e8a17d7a7c2b06f261e4e5d Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 14 Dec 2010 23:26:24 -0500 Subject: [PATCH 280/378] Removing duplicated tests, and tests for methods that are not implemented in the subclasses. --- .../console/libs/task_collection.test.php | 21 --- .../controller/component_collection.test.php | 156 ------------------ .../cases/libs/object_collection.test.php | 4 +- .../libs/view/helper_collection.test.php | 71 -------- 4 files changed, 2 insertions(+), 250 deletions(-) diff --git a/cake/tests/cases/console/libs/task_collection.test.php b/cake/tests/cases/console/libs/task_collection.test.php index da7d6eaef..b89de158c 100644 --- a/cake/tests/cases/console/libs/task_collection.test.php +++ b/cake/tests/cases/console/libs/task_collection.test.php @@ -118,25 +118,4 @@ class TaskCollectionTest extends CakeTestCase { $this->assertEquals(array('Extract'), $result, 'loaded tasks is wrong'); } -/** - * test normalizeObjectArray - * - * @return void - */ - function testnormalizeObjectArray() { - $tasks = array( - 'Html', - 'Foo.Bar' => array('one', 'two'), - 'Something', - 'Banana.Apple' => array('foo' => 'bar') - ); - $result = TaskCollection::normalizeObjectArray($tasks); - $expected = array( - 'Html' => array('class' => 'Html', 'settings' => array()), - 'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')), - 'Something' => array('class' => 'Something', 'settings' => array()), - 'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')), - ); - $this->assertEquals($expected, $result); - } } \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/component_collection.test.php b/cake/tests/cases/libs/controller/component_collection.test.php index ff96199b1..ecdac7775 100644 --- a/cake/tests/cases/libs/controller/component_collection.test.php +++ b/cake/tests/cases/libs/controller/component_collection.test.php @@ -119,162 +119,6 @@ class ComponentCollectionTest extends CakeTestCase { $this->assertEquals(array('Security'), $result, 'enabled components is wrong'); } -/** - * creates mock classes for testing - * - * @return void - */ - protected function _makeMockClasses() { - if (!class_exists('TriggerMockCookieComponent')) { - $this->getMock('CookieComponent', array(), array(), 'TriggerMockCookieComponent', false); - $this->getMock('SecurityComponent', array(), array(), 'TriggerMockSecurityComponent', false); - } - } - -/** - * test triggering callbacks. - * - * @return void - */ - function testTrigger() { - $controller = null; - $this->_makeMockClasses(); - $this->Components->load('TriggerMockCookie'); - $this->Components->load('TriggerMockSecurity'); - - $this->Components->TriggerMockCookie->expects($this->once())->method('startup') - ->with(null); - $this->Components->TriggerMockSecurity->expects($this->once())->method('startup') - ->with(null); - - $this->mockObjects[] = $this->Components->TriggerMockCookie; - $this->mockObjects[] = $this->Components->TriggerMockSecurity; - - $this->assertNull($this->Components->trigger('startup', array(&$controller))); - } - -/** - * test that the initalize callback is triggered on all components even those that are disabled. - * - * @return void - */ - function testTriggerWithTriggerDisabledObjects() { - $controller = 'Not a controller'; - - $this->_makeMockClasses(); - $this->Components->load('TriggerMockCookie', array(), false); - $this->Components->load('TriggerMockSecurity'); - - $this->Components->TriggerMockCookie->expects($this->once())->method('initialize') - ->with($controller); - $this->Components->TriggerMockSecurity->expects($this->once())->method('initialize') - ->with($controller); - - $this->mockObjects[] = $this->Components->TriggerMockCookie; - $this->mockObjects[] = $this->Components->TriggerMockSecurity; - - $result = $this->Components->trigger('initialize', array(&$controller), array('triggerDisabled' => true)); - $this->assertNull($result); - } - -/** - * test trigger and disabled helpers. - * - * @return void - */ - function testTriggerWithDisabledComponents() { - $controller = null; - $this->_makeMockClasses(); - $this->Components->load('TriggerMockCookie'); - $this->Components->load('TriggerMockSecurity'); - - $this->Components->TriggerMockCookie->expects($this->once())->method('startup') - ->with($controller); - $this->Components->TriggerMockSecurity->expects($this->never())->method('startup'); - - $this->mockObjects[] = $this->Components->TriggerMockCookie; - $this->mockObjects[] = $this->Components->TriggerMockSecurity; - - $this->Components->disable('TriggerMockSecurity'); - - $this->assertNull($this->Components->trigger('startup', array(&$controller))); - } - -/** - * test that the collectReturn option works. - * - * @return void - */ - function testTriggerWithCollectReturn() { - $controller = null; - $this->_makeMockClasses(); - $this->Components->load('TriggerMockCookie'); - $this->Components->load('TriggerMockSecurity'); - - $this->Components->TriggerMockCookie->expects($this->once())->method('startup') - ->will($this->returnValue(array('one', 'two'))); - $this->Components->TriggerMockSecurity->expects($this->once())->method('startup') - ->will($this->returnValue(array('three', 'four'))); - - $this->mockObjects[] = $this->Components->TriggerMockCookie; - $this->mockObjects[] = $this->Components->TriggerMockSecurity; - - $result = $this->Components->trigger('startup', array(&$controller), array('collectReturn' => true)); - $expected = array( - array('one', 'two'), - array('three', 'four') - ); - $this->assertEquals($expected, $result); - } - -/** - * test that trigger with break & breakOn works. - * - * @return void - */ - function testTriggerWithBreak() { - $controller = null; - $this->_makeMockClasses(); - $this->Components->load('TriggerMockCookie'); - $this->Components->load('TriggerMockSecurity'); - - $this->Components->TriggerMockCookie->expects($this->once())->method('startup') - ->will($this->returnValue(false)); - $this->Components->TriggerMockSecurity->expects($this->never())->method('startup'); - - $this->mockObjects[] = $this->Components->TriggerMockCookie; - $this->mockObjects[] = $this->Components->TriggerMockSecurity; - - $result = $this->Components->trigger( - 'startup', - array(&$controller), - array('break' => true, 'breakOn' => false) - ); - $this->assertFalse($result); - } - -/** - * test normalizeObjectArray - * - * @return void - */ - function testnormalizeObjectArray() { - $components = array( - 'Html', - 'Foo.Bar' => array('one', 'two'), - 'Something', - 'Banana.Apple' => array('foo' => 'bar') - ); - $result = ComponentCollection::normalizeObjectArray($components); - $expected = array( - 'Html' => array('class' => 'Html', 'settings' => array()), - 'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')), - 'Something' => array('class' => 'Something', 'settings' => array()), - 'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')), - ); - $this->assertEquals($expected, $result); - } - /** * test getting the controller out of the collection * diff --git a/cake/tests/cases/libs/object_collection.test.php b/cake/tests/cases/libs/object_collection.test.php index fd51cbecd..73e0fec4f 100644 --- a/cake/tests/cases/libs/object_collection.test.php +++ b/cake/tests/cases/libs/object_collection.test.php @@ -189,11 +189,11 @@ class ObjectCollectionTest extends CakeTestCase { } /** - * test trigger and disabled helpers. + * test trigger and disabled objects * * @return void */ - function testTriggerWithDisabledComponents() { + function testTriggerWithDisabledObjects() { $this->_makeMockClasses(); $this->Objects->load('TriggerMockFirst'); $this->Objects->load('TriggerMockSecond'); diff --git a/cake/tests/cases/libs/view/helper_collection.test.php b/cake/tests/cases/libs/view/helper_collection.test.php index 403bbc8e7..d5f1480dd 100644 --- a/cake/tests/cases/libs/view/helper_collection.test.php +++ b/cake/tests/cases/libs/view/helper_collection.test.php @@ -116,75 +116,4 @@ class HelperCollectionTest extends CakeTestCase { $this->assertEquals(array('Form'), $result, 'loaded helpers is wrong'); } -/** - * test triggering callbacks. - * - * @return void - */ - function testTrigger() { - if (!class_exists('TriggerMockHtmlHelper')) { - $this->getMock('HtmlHelper', array(), array($this->View), 'TriggerMockHtmlHelper'); - $this->getMock('FormHelper', array(), array($this->View), 'TriggerMockFormHelper'); - } - - $this->Helpers->load('TriggerMockHtml'); - $this->Helpers->load('TriggerMockForm'); - - $this->Helpers->TriggerMockHtml->expects($this->once())->method('beforeRender') - ->with('one', 'two'); - $this->Helpers->TriggerMockForm->expects($this->once())->method('beforeRender') - ->with('one', 'two'); - - $this->mockObjects[] = $this->Helpers->TriggerMockForm; - - $this->assertNull($this->Helpers->trigger('beforeRender', array('one', 'two'))); - } - -/** - * test trigger and disabled helpers. - * - * @return void - */ - function testTriggerWithDisabledHelpers() { - if (!class_exists('TriggerMockHtmlHelper')) { - $this->getMock('HtmlHelper', array(), array(), 'TriggerMockHtmlHelper', false); - $this->getMock('FormHelper', array(), array(), 'TriggerMockFormHelper', false); - } - - $this->Helpers->load('TriggerMockHtml'); - $this->Helpers->load('TriggerMockForm'); - - $this->Helpers->TriggerMockHtml->expects($this->once())->method('beforeRender') - ->with('one', 'two'); - $this->Helpers->TriggerMockForm->expects($this->never())->method('beforeRender'); - - $this->mockObjects[] = $this->Helpers->TriggerMockForm; - $this->mockObjects[] = $this->Helpers->TriggerMockHtml; - - $this->Helpers->disable('TriggerMockForm'); - - $this->assertNull($this->Helpers->trigger('beforeRender', array('one', 'two'))); - } - -/** - * test normalizeObjectArray - * - * @return void - */ - function testnormalizeObjectArray() { - $helpers = array( - 'Html', - 'Foo.Bar' => array('one', 'two'), - 'Something', - 'Banana.Apple' => array('foo' => 'bar') - ); - $result = ObjectCollection::normalizeObjectArray($helpers); - $expected = array( - 'Html' => array('class' => 'Html', 'settings' => array()), - 'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')), - 'Something' => array('class' => 'Something', 'settings' => array()), - 'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')), - ); - $this->assertEquals($expected, $result); - } } \ No newline at end of file From 97c82e28a1c19397a4990f83016449bf99f24427 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 14 Dec 2010 20:27:12 -0800 Subject: [PATCH 281/378] Fixed problems where running all tests will fail due to duplicate classes --- .../controller/components/paginator.test.php | 172 +++++++++--------- .../cases/libs/controller/controller.test.php | 44 ----- .../cases/libs/controller_test_case.test.php | 28 +-- 3 files changed, 102 insertions(+), 142 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index 93ee5b6b5..cb6beb153 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -55,20 +55,20 @@ class PaginatorTestController extends Controller { } /** - * ControllerPost class + * PaginatorControllerPost class * * @package cake * @subpackage cake.tests.cases.libs.controller.components */ -class ControllerPost extends CakeTestModel { +class PaginatorControllerPost extends CakeTestModel { /** * name property * - * @var string 'ControllerPost' + * @var string 'PaginatorControllerPost' * @access public */ - public $name = 'ControllerPost'; + public $name = 'PaginatorControllerPost'; /** * useTable property @@ -168,12 +168,12 @@ class ControllerPaginateModel extends CakeTestModel { } /** - * ControllerComment class + * PaginatorControllerCommentclass * * @package cake * @subpackage cake.tests.cases.libs.controller.components */ -class ControllerComment extends CakeTestModel { +class PaginatorControllerComment extends CakeTestModel { /** * name property @@ -194,10 +194,10 @@ class ControllerComment extends CakeTestModel { /** * alias property * - * @var string 'ControllerComment' + * @var string 'PaginatorControllerComment' * @access public */ - public $alias = 'ControllerComment'; + public $alias = 'PaginatorControllerComment'; } class PaginatorTest extends CakeTestCase { @@ -221,82 +221,82 @@ class PaginatorTest extends CakeTestCase { $request->params['pass'] = $request->params['named'] = array(); $Controller = new PaginatorTestController($request); - $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); $Controller->passedArgs[] = '1'; $Controller->params['url'] = array(); $Controller->constructClasses(); - $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); + $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEqual($results, array(1, 2, 3)); - $results = Set::extract($Controller->Paginator->paginate('ControllerComment'), '{n}.ControllerComment.id'); + $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerComment'), '{n}.PaginatorControllerComment.id'); $this->assertEqual($results, array(1, 2, 3, 4, 5, 6)); $Controller->modelClass = null; - $Controller->uses[0] = 'Plugin.ControllerPost'; - $results = Set::extract($Controller->Paginator->paginate(), '{n}.ControllerPost.id'); + $Controller->uses[0] = 'Plugin.PaginatorControllerPost'; + $results = Set::extract($Controller->Paginator->paginate(), '{n}.PaginatorControllerPost.id'); $this->assertEqual($results, array(1, 2, 3)); $Controller->passedArgs = array('page' => '-1'); - $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); + $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertEqual($results, array(1, 2, 3)); - $Controller->passedArgs = array('sort' => 'ControllerPost.id', 'direction' => 'asc'); - $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); + $Controller->passedArgs = array('sort' => 'PaginatorControllerPost.id', 'direction' => 'asc'); + $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertEqual($results, array(1, 2, 3)); - $Controller->passedArgs = array('sort' => 'ControllerPost.id', 'direction' => 'desc'); - $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); + $Controller->passedArgs = array('sort' => 'PaginatorControllerPost.id', 'direction' => 'desc'); + $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertEqual($results, array(3, 2, 1)); $Controller->passedArgs = array('sort' => 'id', 'direction' => 'desc'); - $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); + $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertEqual($results, array(3, 2, 1)); $Controller->passedArgs = array('sort' => 'NotExisting.field', 'direction' => 'desc'); - $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1, 'Invalid field in query %s'); + $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1, 'Invalid field in query %s'); $this->assertEqual($results, array(1, 2, 3)); - $Controller->passedArgs = array('sort' => 'ControllerPost.author_id', 'direction' => 'allYourBase'); - $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->ControllerPost->lastQuery['order'][0], array('ControllerPost.author_id' => 'asc')); + $Controller->passedArgs = array('sort' => 'PaginatorControllerPost.author_id', 'direction' => 'allYourBase'); + $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); + $this->assertEqual($Controller->PaginatorControllerPost->lastQuery['order'][0], array('PaginatorControllerPost.author_id' => 'asc')); $this->assertEqual($results, array(1, 3, 2)); $Controller->passedArgs = array('page' => '1 " onclick="alert(\'xss\');">'); $Controller->Paginator->settings = array('limit' => 1); - $Controller->Paginator->paginate('ControllerPost'); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1, 'XSS exploit opened %s'); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['options']['page'], 1, 'XSS exploit opened %s'); + $Controller->Paginator->paginate('PaginatorControllerPost'); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1, 'XSS exploit opened %s'); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['options']['page'], 1, 'XSS exploit opened %s'); $Controller->passedArgs = array(); $Controller->Paginator->settings = array('limit' => 0); - $Controller->Paginator->paginate('ControllerPost'); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['pageCount'], 3); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['prevPage'], false); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['nextPage'], true); + $Controller->Paginator->paginate('PaginatorControllerPost'); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['prevPage'], false); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true); $Controller->passedArgs = array(); $Controller->Paginator->settings = array('limit' => 'garbage!'); - $Controller->Paginator->paginate('ControllerPost'); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['pageCount'], 3); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['prevPage'], false); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['nextPage'], true); + $Controller->Paginator->paginate('PaginatorControllerPost'); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['prevPage'], false); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true); $Controller->passedArgs = array(); $Controller->Paginator->settings = array('limit' => '-1'); - $Controller->Paginator->paginate('ControllerPost'); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['pageCount'], 3); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['prevPage'], false); - $this->assertIdentical($Controller->params['paging']['ControllerPost']['nextPage'], true); + $Controller->Paginator->paginate('PaginatorControllerPost'); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['prevPage'], false); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true); } /** @@ -311,35 +311,35 @@ class PaginatorTest extends CakeTestCase { $Controller = new PaginatorTestController($request); - $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); $Controller->passedArgs[] = '1'; $Controller->params['url'] = array(); $Controller->constructClasses(); - $Controller->passedArgs = array('page' => '-1', 'contain' => array('ControllerComment')); - $result = $Controller->Paginator->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(1, 2, 3)); - $this->assertTrue(!isset($Controller->ControllerPost->lastQuery['contain'])); + $Controller->passedArgs = array('page' => '-1', 'contain' => array('PaginatorControllerComment')); + $result = $Controller->Paginator->paginate('PaginatorControllerPost'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); + $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.id'), array(1, 2, 3)); + $this->assertTrue(!isset($Controller->PaginatorControllerPost->lastQuery['contain'])); $Controller->passedArgs = array('page' => '-1'); - $Controller->Paginator->settings = array('ControllerPost' => array('contain' => array('ControllerComment'))); - $result = $Controller->Paginator->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['page'], 1); - $this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(1, 2, 3)); - $this->assertTrue(isset($Controller->ControllerPost->lastQuery['contain'])); + $Controller->Paginator->settings = array('PaginatorControllerPost' => array('contain' => array('PaginatorControllerComment'))); + $result = $Controller->Paginator->paginate('PaginatorControllerPost'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); + $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.id'), array(1, 2, 3)); + $this->assertTrue(isset($Controller->PaginatorControllerPost->lastQuery['contain'])); - $Controller->Paginator->settings = array('ControllerPost' => array('popular', 'fields' => array('id', 'title'))); - $result = $Controller->Paginator->paginate('ControllerPost'); - $this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(2, 3)); - $this->assertEqual($Controller->ControllerPost->lastQuery['conditions'], array('ControllerPost.id > ' => '1')); + $Controller->Paginator->settings = array('PaginatorControllerPost' => array('popular', 'fields' => array('id', 'title'))); + $result = $Controller->Paginator->paginate('PaginatorControllerPost'); + $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.id'), array(2, 3)); + $this->assertEqual($Controller->PaginatorControllerPost->lastQuery['conditions'], array('PaginatorControllerPost.id > ' => '1')); $Controller->passedArgs = array('limit' => 12); $Controller->Paginator->settings = array('limit' => 30); - $result = $Controller->Paginator->paginate('ControllerPost'); - $paging = $Controller->params['paging']['ControllerPost']; + $result = $Controller->Paginator->paginate('PaginatorControllerPost'); + $paging = $Controller->params['paging']['PaginatorControllerPost']; - $this->assertEqual($Controller->ControllerPost->lastQuery['limit'], 12); + $this->assertEqual($Controller->PaginatorControllerPost->lastQuery['limit'], 12); $this->assertEqual($paging['options']['limit'], 12); $Controller = new PaginatorTestController($request); @@ -373,7 +373,7 @@ class PaginatorTest extends CakeTestCase { $request->params['pass'] = $request->params['named'] = array(); $Controller = new PaginatorTestController($request); - $Controller->uses = array('ControllerPost'); + $Controller->uses = array('PaginatorControllerPost'); $Controller->passedArgs[] = array('1', '2', '3'); $Controller->params['url'] = array(); $Controller->constructClasses(); @@ -386,7 +386,7 @@ class PaginatorTest extends CakeTestCase { 'recursive' => -1 ); $conditions = array(); - $Controller->Paginator->paginate('ControllerPost',$conditions); + $Controller->Paginator->paginate('PaginatorControllerPost',$conditions); $expected = array( 'fields' => array(), @@ -396,7 +396,7 @@ class PaginatorTest extends CakeTestCase { 'recursive' => -1, 'conditions' => array() ); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options'],$expected); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options'],$expected); } /** @@ -409,18 +409,18 @@ class PaginatorTest extends CakeTestCase { $request->params['pass'] = $request->params['named'] = array(); $Controller = new PaginatorTestController($request); - $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); $Controller->passedArgs[] = '1'; $Controller->params['url'] = array(); $Controller->constructClasses(); - $Controller->Paginator->settings = array('ControllerPost' => array('popular', 'fields' => array('id', 'title'))); - $result = $Controller->Paginator->paginate('ControllerPost'); + $Controller->Paginator->settings = array('PaginatorControllerPost' => array('popular', 'fields' => array('id', 'title'))); + $result = $Controller->Paginator->paginate('PaginatorControllerPost'); - $this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(2, 3)); - $this->assertEqual($Controller->ControllerPost->lastQuery['conditions'], array('ControllerPost.id > ' => '1')); - $this->assertFalse(isset($Controller->params['paging']['ControllerPost']['defaults'][0])); - $this->assertFalse(isset($Controller->params['paging']['ControllerPost']['options'][0])); + $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.id'), array(2, 3)); + $this->assertEqual($Controller->PaginatorControllerPost->lastQuery['conditions'], array('PaginatorControllerPost.id > ' => '1')); + $this->assertFalse(isset($Controller->params['paging']['PaginatorControllerPost']['defaults'][0])); + $this->assertFalse(isset($Controller->params['paging']['PaginatorControllerPost']['options'][0])); } /** @@ -434,13 +434,13 @@ class PaginatorTest extends CakeTestCase { $request->params['pass'] = $request->params['named'] = array(); $Controller = new PaginatorTestController($request); - $Controller->modelClass = 'ControllerPost'; + $Controller->modelClass = 'PaginatorControllerPost'; $Controller->params['url'] = array(); $Controller->constructClasses(); - $Controller->Paginator->settings = array('order' => 'ControllerPost.id DESC'); - $results = Set::extract($Controller->Paginator->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['defaults']['order'], 'ControllerPost.id DESC'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['order'], 'ControllerPost.id DESC'); + $Controller->Paginator->settings = array('order' => 'PaginatorControllerPost.id DESC'); + $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['defaults']['order'], 'PaginatorControllerPost.id DESC'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['order'], 'PaginatorControllerPost.id DESC'); $this->assertEqual($results, array(3, 2, 1)); } @@ -454,23 +454,23 @@ class PaginatorTest extends CakeTestCase { $request->params['pass'] = $request->params['named'] = array(); $Controller = new PaginatorTestController($request); - $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); $Controller->params['url'] = array(); $Controller->constructClasses(); - $Controller->ControllerPost->virtualFields = array( - 'offset_test' => 'ControllerPost.id + 1' + $Controller->PaginatorControllerPost->virtualFields = array( + 'offset_test' => 'PaginatorControllerPost.id + 1' ); $Controller->Paginator->settings = array( 'fields' => array('id', 'title', 'offset_test'), 'order' => array('offset_test' => 'DESC') ); - $result = $Controller->Paginator->paginate('ControllerPost'); - $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(4, 3, 2)); + $result = $Controller->Paginator->paginate('PaginatorControllerPost'); + $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.offset_test'), array(4, 3, 2)); $Controller->passedArgs = array('sort' => 'offset_test', 'direction' => 'asc'); - $result = $Controller->Paginator->paginate('ControllerPost'); - $this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(2, 3, 4)); + $result = $Controller->Paginator->paginate('PaginatorControllerPost'); + $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.offset_test'), array(2, 3, 4)); } /** diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 0521283b2..6f217b3e9 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -222,50 +222,6 @@ class ControllerAlias extends CakeTestModel { public $useTable = 'posts'; } -/** - * ControllerPaginateModel class - * - * @package cake - * @subpackage cake.tests.cases.libs.controller - */ -class ControllerPaginateModel extends CakeTestModel { - -/** - * name property - * - * @var string - * @access public - */ - public $name = 'ControllerPaginateModel'; - -/** - * useTable property - * - * @var string' - * @access public - */ - public $useTable = 'comments'; - -/** - * paginate method - * - * @return void - */ - public function paginate($conditions, $fields, $order, $limit, $page, $recursive, $extra) { - $this->extra = $extra; - } - -/** - * paginateCount - * - * @access public - * @return void - */ - function paginateCount($conditions, $recursive, $extra) { - $this->extraCount = $extra; - } -} - /** * NameTest class * diff --git a/cake/tests/cases/libs/controller_test_case.test.php b/cake/tests/cases/libs/controller_test_case.test.php index db66d0a9d..5b5294e75 100644 --- a/cake/tests/cases/libs/controller_test_case.test.php +++ b/cake/tests/cases/libs/controller_test_case.test.php @@ -65,24 +65,28 @@ if (!class_exists('AppController')) { /** * PostsController class */ -class PostsController extends AppController { +if (!class_exists('PostsController')) { + class PostsController extends AppController { -/** - * Components array - * - * @var array - */ - public $components = array( - 'RequestHandler', - 'Email', - 'Auth' - ); + /** + * Components array + * + * @var array + */ + public $components = array( + 'RequestHandler', + 'Email', + 'Auth' + ); + } } /** * Post model */ -class Post extends CakeTestModel { +if (!class_exists('Post')) { + class Post extends CakeTestModel { + } } /** From a054695dca6d955fa3290117b23ce1cbaab74c9f Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 15 Dec 2010 22:08:24 -0500 Subject: [PATCH 282/378] Fixing failing tests. --- cake/libs/controller/components/paginator.php | 6 +++++- cake/tests/cases/console/shells/api.test.php | 9 +++++---- cake/tests/cases/libs/cake_socket.test.php | 10 ++++++---- .../cases/libs/controller/components/email.test.php | 9 +++++++-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index cb1bf7f0e..9bf89f991 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -104,7 +104,11 @@ class PaginatorComponent extends Component { if (!is_object($object)) { throw new MissingModelException($object); } - $options = array_merge($this->Controller->request->params, $this->Controller->params['url'], $this->Controller->passedArgs); + $options = array_merge( + $this->Controller->request->params, + $this->Controller->request->query, + $this->Controller->passedArgs + ); if (isset($this->settings[$object->alias])) { $defaults = $this->settings[$object->alias]; diff --git a/cake/tests/cases/console/shells/api.test.php b/cake/tests/cases/console/shells/api.test.php index 82f134552..7ed9b85a3 100644 --- a/cake/tests/cases/console/shells/api.test.php +++ b/cake/tests/cases/console/shells/api.test.php @@ -76,10 +76,11 @@ class ApiShellTest extends CakeTestCase { '16. render($action = NULL, $layout = NULL, $file = NULL)', '17. set($one, $two = NULL)', '18. setAction($action)', - '19. shutdownProcess()', - '20. startupProcess()', - '21. validate()', - '22. validateErrors()' + '19. setRequest($request)', + '20. shutdownProcess()', + '21. startupProcess()', + '22. validate()', + '23. validateErrors()' ); $this->Shell->expects($this->at(2))->method('out')->with($expected); diff --git a/cake/tests/cases/libs/cake_socket.test.php b/cake/tests/cases/libs/cake_socket.test.php index 8359db3bb..ce84dedfb 100644 --- a/cake/tests/cases/libs/cake_socket.test.php +++ b/cake/tests/cases/libs/cake_socket.test.php @@ -34,7 +34,8 @@ class CakeSocketTest extends CakeTestCase { * @return void */ function setUp() { - $this->Socket = new CakeSocket(); + parent::setUp(); + $this->Socket = new CakeSocket(array('timeout' => 1)); } /** @@ -44,6 +45,7 @@ class CakeSocketTest extends CakeTestCase { * @return void */ function tearDown() { + parent::tearDown(); unset($this->Socket); } @@ -54,7 +56,7 @@ class CakeSocketTest extends CakeTestCase { * @return void */ function testConstruct() { - $this->Socket->__construct(); + $this->Socket = new CakeSocket(); $config = $this->Socket->config; $this->assertIdentical($config, array( 'persistent' => false, @@ -108,8 +110,8 @@ class CakeSocketTest extends CakeTestCase { */ public static function invalidConnections() { return array( - array(array('host' => 'invalid.host')), - array(array('host' => '127.0.0.1', 'port' => '70000')) + array(array('host' => 'invalid.host', 'timeout' => 1)), + array(array('host' => '127.0.0.1', 'port' => '70000', 'timeout' => 1)) ); } diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index e853d4a7e..ea2d86b29 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -1087,13 +1087,18 @@ HTMLBLOC; $this->Controller->EmailTest->additionalParams = 'X-additional-header'; $this->Controller->EmailTest->delivery = 'smtp'; $this->Controller->EmailTest->smtpOptions['host'] = 'blah'; - $this->Controller->EmailTest->smtpOptions['timeout'] = 0.5; + $this->Controller->EmailTest->smtpOptions['timeout'] = 0.2; $this->Controller->EmailTest->attachments = array('attachment1', 'attachment2'); $this->Controller->EmailTest->textMessage = 'This is the body of the message'; $this->Controller->EmailTest->htmlMessage = 'This is the body of the message'; $this->Controller->EmailTest->messageId = false; - $this->assertFalse($this->Controller->EmailTest->send('Should not work')); + try { + $this->Controller->EmailTest->send('Should not work'); + $this->fail('No exception'); + } catch (SocketException $e) { + $this->assertTrue(true, 'SocketException raised'); + } $this->Controller->EmailTest->reset(); From 5ff376e0a0a7b9354a61653df270d7808e67aa4b Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 15 Dec 2010 22:12:48 -0500 Subject: [PATCH 283/378] Adding parent calls. --- cake/tests/cases/libs/controller_test_case.test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/controller_test_case.test.php b/cake/tests/cases/libs/controller_test_case.test.php index 5b5294e75..d7f9b8f15 100644 --- a/cake/tests/cases/libs/controller_test_case.test.php +++ b/cake/tests/cases/libs/controller_test_case.test.php @@ -111,6 +111,7 @@ class ControllerTestCaseTest extends CakeTestCase { * @return void */ function setUp() { + parent::setUp(); App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), 'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS), @@ -127,8 +128,8 @@ class ControllerTestCaseTest extends CakeTestCase { * @return void */ function tearDown() { + parent::tearDown(); $this->Case->controller = null; - App::build(); } /** From 9dcea304c1475aba76ae7e2a22a6483e7dc771d8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 15 Dec 2010 22:19:44 -0500 Subject: [PATCH 284/378] making assertions run against the test case, not the subject test case. --- .../cases/libs/controller_test_case.test.php | 80 ++++++++++--------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/cake/tests/cases/libs/controller_test_case.test.php b/cake/tests/cases/libs/controller_test_case.test.php index d7f9b8f15..9ca9913ff 100644 --- a/cake/tests/cases/libs/controller_test_case.test.php +++ b/cake/tests/cases/libs/controller_test_case.test.php @@ -137,41 +137,42 @@ class ControllerTestCaseTest extends CakeTestCase { */ function testGenerate() { $Posts = $this->Case->generate('Posts'); - $this->Case->assertEquals($Posts->name, 'Posts'); - $this->Case->assertEquals($Posts->modelClass, 'Post'); - $this->Case->assertNull($Posts->response->send()); + $this->assertEquals($Posts->name, 'Posts'); + $this->assertEquals($Posts->modelClass, 'Post'); + $this->assertNull($Posts->response->send()); $Posts = $this->Case->generate('Posts', array( 'methods' => array( 'render' ) )); - $this->Case->assertNull($Posts->render('index')); + $this->assertNull($Posts->render('index')); $Posts = $this->Case->generate('Posts', array( 'models' => array('Post'), 'components' => array('RequestHandler') )); - $this->Case->assertNull($Posts->Post->save(array())); - $this->Case->assertNull($Posts->Post->find('all')); - $this->Case->assertEquals($Posts->Post->useTable, 'posts'); - $this->Case->assertNull($Posts->RequestHandler->isAjax()); + + $this->assertNull($Posts->Post->save(array())); + $this->assertNull($Posts->Post->find('all')); + $this->assertEquals($Posts->Post->useTable, 'posts'); + $this->assertNull($Posts->RequestHandler->isAjax()); $Posts = $this->Case->generate('Posts', array( 'models' => array( 'Post' => true ) )); - $this->Case->assertNull($Posts->Post->save(array())); - $this->Case->assertNull($Posts->Post->find('all')); + $this->assertNull($Posts->Post->save(array())); + $this->assertNull($Posts->Post->find('all')); $Posts = $this->Case->generate('Posts', array( 'models' => array( 'Post' => array('save'), ) )); - $this->Case->assertNull($Posts->Post->save(array())); - $this->Case->assertIsA($Posts->Post->find('all'), 'array'); + $this->assertNull($Posts->Post->save(array())); + $this->assertIsA($Posts->Post->find('all'), 'array'); $Posts = $this->Case->generate('Posts', array( 'models' => array('Post'), @@ -198,24 +199,24 @@ class ControllerTestCaseTest extends CakeTestCase { function testTestAction() { $Controller = $this->Case->generate('TestsApps'); $this->Case->testAction('/tests_apps/index'); - $this->Case->assertIsA($this->Case->controller->viewVars, 'array'); + $this->assertIsA($this->Case->controller->viewVars, 'array'); $this->Case->testAction('/tests_apps/set_action'); $results = $this->Case->controller->viewVars; $expected = array( 'var' => 'string' ); - $this->Case->assertEquals($expected, $results); + $this->assertEquals($expected, $results); $result = $this->Case->controller->response->body(); - $this->Case->assertPattern('/This is the TestsAppsController index view/', $result); + $this->assertPattern('/This is the TestsAppsController index view/', $result); $this->Case->testAction('/tests_apps/redirect_to'); $results = $this->Case->headers; $expected = array( 'Location' => 'http://cakephp.org' ); - $this->Case->assertEquals($expected, $results); + $this->assertEquals($expected, $results); } /** @@ -228,32 +229,33 @@ class ControllerTestCaseTest extends CakeTestCase { $result = $this->Case->testAction('/tests_apps/index.json', array('return' => 'view')); $result = json_decode($result, true); $expected = array('cakephp' => 'cool'); - $this->Case->assertEquals($result, $expected); + $this->assertEquals($result, $expected); include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php'; $result = $this->Case->testAction('/some_alias'); - $this->Case->assertEquals($result, 5); + $this->assertEquals($result, 5); include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php'; $this->Case->testAction('/redirect_me_now'); $result = $this->Case->headers['Location']; - $this->Case->assertEquals($result, 'http://cakephp.org'); + $this->assertEquals($result, 'http://cakephp.org'); include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php'; $this->Case->testAction('/redirect_me'); $result = $this->Case->headers['Location']; - $this->Case->assertEquals($result, Router::url(array('controller' => 'tests_apps', 'action' => 'some_method'), true)); + $this->assertEquals($result, Router::url(array('controller' => 'tests_apps', 'action' => 'some_method'), true)); } /** * Tests not using loaded routes during tests + * + * @expectedException MissingActionException */ function testSkipRoutes() { include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php'; $this->Case->loadRoutes = false; - $this->expectException('MissingActionException'); $result = $this->Case->testAction('/tests_apps/index.json', array('return' => 'view')); } @@ -264,26 +266,26 @@ class ControllerTestCaseTest extends CakeTestCase { $this->Case->autoMock = true; $result = $this->Case->testAction('/tests_apps/some_method'); - $this->Case->assertEquals($result, 5); + $this->assertEquals($result, 5); $data = array('var' => 'set'); $result = $this->Case->testAction('/tests_apps_posts/post_var', array( 'data' => $data, 'return' => 'vars' )); - $this->Case->assertEquals($result['data'], $data); + $this->assertEquals($result['data'], $data); $result = $this->Case->testAction('/tests_apps/set_action', array( 'return' => 'view' )); - $this->Case->assertEquals($result, 'This is the TestsAppsController index view'); + $this->assertEquals($result, 'This is the TestsAppsController index view'); $result = $this->Case->testAction('/tests_apps/set_action', array( 'return' => 'contents' )); - $this->Case->assertPattern('/Case->assertPattern('/This is the TestsAppsController index view/', $result); - $this->Case->assertPattern('/<\/html>/', $result); + $this->assertPattern('/assertPattern('/This is the TestsAppsController index view/', $result); + $this->assertPattern('/<\/html>/', $result); } /** @@ -300,8 +302,8 @@ class ControllerTestCaseTest extends CakeTestCase { $this->Case->testAction('/tests_apps_posts/post_var', array( 'data' => $data )); - $this->Case->assertEquals($this->Case->controller->viewVars['data'], $data); - $this->Case->assertEquals($this->Case->controller->data, $data); + $this->assertEquals($this->Case->controller->viewVars['data'], $data); + $this->assertEquals($this->Case->controller->data, $data); $this->Case->testAction('/tests_apps_posts/post_var/named:param', array( 'data' => $data @@ -309,8 +311,8 @@ class ControllerTestCaseTest extends CakeTestCase { $expected = array( 'named' => 'param' ); - $this->Case->assertEqual($this->Case->controller->request->named, $expected); - $this->Case->assertEquals($this->Case->controller->data, $data); + $this->assertEqual($this->Case->controller->request->named, $expected); + $this->assertEquals($this->Case->controller->data, $data); $result = $this->Case->testAction('/tests_apps_posts/post_var', array( 'return' => 'vars', @@ -340,8 +342,8 @@ class ControllerTestCaseTest extends CakeTestCase { 'lackof' => 'creativity' ) )); - $this->Case->assertEquals($this->Case->controller->request->query['some'], 'var'); - $this->Case->assertEquals($this->Case->controller->request->query['lackof'], 'creativity'); + $this->assertEquals($this->Case->controller->request->query['some'], 'var'); + $this->assertEquals($this->Case->controller->request->query['lackof'], 'creativity'); $result = $this->Case->testAction('/tests_apps_posts/url_var/var1:value1/var2:val2', array( 'return' => 'vars', @@ -379,7 +381,7 @@ class ControllerTestCaseTest extends CakeTestCase { $expected = array( 'var' => 'string' ); - $this->Case->assertEquals($expected, $results); + $this->assertEquals($expected, $results); } /** @@ -394,19 +396,19 @@ class ControllerTestCaseTest extends CakeTestCase { 'data' => $data, 'return' => 'vars' )); - $this->Case->assertEquals($result['data'], $data); + $this->assertEquals($result['data'], $data); $result = $this->Case->testAction('/tests_apps/set_action', array( 'return' => 'view' )); - $this->Case->assertEquals($result, 'This is the TestsAppsController index view'); + $this->assertEquals($result, 'This is the TestsAppsController index view'); $result = $this->Case->testAction('/tests_apps/set_action', array( 'return' => 'contents' )); - $this->Case->assertPattern('/Case->assertPattern('/This is the TestsAppsController index view/', $result); - $this->Case->assertPattern('/<\/html>/', $result); + $this->assertPattern('/assertPattern('/This is the TestsAppsController index view/', $result); + $this->assertPattern('/<\/html>/', $result); } } \ No newline at end of file From 862a2bc25e36ff3a89f734a046588242b2780040 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 15 Dec 2010 23:33:00 -0500 Subject: [PATCH 285/378] Removing duplicate class definition that could cause test suite inconsistencies. Adding skip for when AppController is defined. Changing how mock models are constructed to better use Model::__construct parameters. --- .../cases/libs/controller_test_case.test.php | 15 +++++++-------- cake/tests/lib/controller_test_case.php | 8 ++++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cake/tests/cases/libs/controller_test_case.test.php b/cake/tests/cases/libs/controller_test_case.test.php index 9ca9913ff..c457da428 100644 --- a/cake/tests/cases/libs/controller_test_case.test.php +++ b/cake/tests/cases/libs/controller_test_case.test.php @@ -20,7 +20,9 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Controller', 'Controller', false); +App::import('Core', array('AppModel', 'Model')); require_once TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'lib' . DS . 'reporter' . DS . 'cake_html_reporter.php'; +require_once dirname(__FILE__) . DS . 'model' . DS . 'models.php'; /** * AppController class @@ -81,13 +83,6 @@ if (!class_exists('PostsController')) { } } -/** - * Post model - */ -if (!class_exists('Post')) { - class Post extends CakeTestModel { - } -} /** * ControllerTestCaseTest @@ -103,7 +98,7 @@ class ControllerTestCaseTest extends CakeTestCase { * @var array * @access public */ - public $fixtures = array('core.post'); + public $fixtures = array('core.post', 'core.author'); /** * reset environment. @@ -136,6 +131,9 @@ class ControllerTestCaseTest extends CakeTestCase { * Test that ControllerTestCase::generate() creates mock objects correctly */ function testGenerate() { + if (defined('APP_CONTROLLER_EXISTS')) { + $this->markTestSkipped('AppController exists, cannot run.'); + } $Posts = $this->Case->generate('Posts'); $this->assertEquals($Posts->name, 'Posts'); $this->assertEquals($Posts->modelClass, 'Post'); @@ -153,6 +151,7 @@ class ControllerTestCaseTest extends CakeTestCase { 'components' => array('RequestHandler') )); + $this->assertInstanceOf('Post', $Posts->Post); $this->assertNull($Posts->Post->save(array())); $this->assertNull($Posts->Post->find('all')); $this->assertEquals($Posts->Post->useTable, 'posts'); diff --git a/cake/tests/lib/controller_test_case.php b/cake/tests/lib/controller_test_case.php index d65650601..63188b059 100644 --- a/cake/tests/lib/controller_test_case.php +++ b/cake/tests/lib/controller_test_case.php @@ -242,6 +242,7 @@ class ControllerTestCase extends CakeTestCase { * interfere with testing. * * ### Mocks: + * * - `methods` Methods to mock on the controller. `_stop()` is mocked by default * - `models` Models to mock. Models are added to the ClassRegistry so they any * time they are instatiated the mock will be created. Pass as key value pairs @@ -270,6 +271,7 @@ class ControllerTestCase extends CakeTestCase { $_controller->name = $controller; $_controller->__construct(); + $config = ClassRegistry::config('Model'); foreach ($mocks['models'] as $model => $methods) { if (is_string($methods)) { $model = $methods; @@ -278,10 +280,8 @@ class ControllerTestCase extends CakeTestCase { if ($methods === true) { $methods = array(); } - ClassRegistry::init($model); - $_model = $this->getMock($model, $methods, array(), '', false); - $_model->name = $model; - $_model->__construct(); + $config = array_merge((array)$config, array('name' => $model)); + $_model = $this->getMock($model, $methods, array($config)); ClassRegistry::removeObject($model); ClassRegistry::addObject($model, $_model); } From 6206fefceefd3620bab1e98c1fbf6fd5802cd78c Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 15 Dec 2010 23:44:43 -0500 Subject: [PATCH 286/378] Starting to switch to a _mergeParent. This will allow un skipping of many tests, and make mergeVars more flexible. --- cake/libs/controller/controller.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index e9d0754d4..de0553b01 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -272,6 +272,15 @@ class Controller extends Object { */ public $validationErrors = null; +/** + * The class name of the parent class you wish to merge with. + * Typically this is AppController, but you may wish to merge vars with a different + * parent class. + * + * @var string + */ + protected $_mergeParent = 'AppController'; + /** * Constructor. * @@ -394,7 +403,7 @@ class Controller extends Object { } /** - * Merge components, helpers, and uses vars from AppController and PluginAppController. + * Merge components, helpers, and uses vars from Controller::$_mergeParent and PluginAppController. * * @return void */ @@ -410,8 +419,8 @@ class Controller extends Object { $plugin = $pluginName . '.'; } - if (is_subclass_of($this, 'AppController') || !empty($pluginController)) { - $appVars = get_class_vars('AppController'); + if (is_subclass_of($this, $this->_mergeParent) || !empty($pluginController)) { + $appVars = get_class_vars($this->_mergeParent); $uses = $appVars['uses']; $merge = array('components', 'helpers'); @@ -430,7 +439,7 @@ class Controller extends Object { ) { $this->uses = array_merge($this->uses, array_diff($appVars['uses'], $this->uses)); } - $this->_mergeVars($merge, 'AppController', true); + $this->_mergeVars($merge, $this->_mergeParent, true); } if ($pluginController && $pluginName != null) { From 339cb41ea27bb99cad8f2bc9ea7c889338c9d0a1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 15 Dec 2010 23:49:54 -0500 Subject: [PATCH 287/378] Using $_mergeParent to unskip tests in test suites. --- .../controller/controller_merge_vars.test.php | 54 ++++++++----------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/cake/tests/cases/libs/controller/controller_merge_vars.test.php b/cake/tests/cases/libs/controller/controller_merge_vars.test.php index a3199b3a2..b90a6b6e9 100644 --- a/cake/tests/cases/libs/controller/controller_merge_vars.test.php +++ b/cake/tests/cases/libs/controller/controller_merge_vars.test.php @@ -21,33 +21,29 @@ */ App::import('Core', 'Controller'); -if (!class_exists('AppController')) { - /** * Test case AppController * * @package cake * @subpackage cake.tests.cases.libs.controller */ - class AppController extends Controller { +class MergeVarsAppController extends Controller { /** * components * * @var array */ - public $components = array('MergeVar' => array('flag', 'otherFlag', 'redirect' => false)); + public $components = array('MergeVar' => array('flag', 'otherFlag', 'redirect' => false)); /** * helpers * * @var array */ - public $helpers = array('MergeVar' => array('format' => 'html', 'terse')); - } -} elseif (!defined('APP_CONTROLLER_EXISTS')) { - define('APP_CONTROLLER_EXISTS', true); + public $helpers = array('MergeVar' => array('format' => 'html', 'terse')); } + /** * MergeVar Component * @@ -62,7 +58,7 @@ class MergeVarComponent extends Object { * * @package cake.tests.cases.libs.controller */ -class MergeVariablesController extends AppController { +class MergeVariablesController extends MergeVarsAppController { /** * name @@ -77,6 +73,13 @@ class MergeVariablesController extends AppController { * @var arrays */ public $uses = array(); + +/** + * parent for mergeVars + * + * @var string + */ + protected $_mergeParent = 'MergeVarsAppController'; } /** @@ -84,7 +87,7 @@ class MergeVariablesController extends AppController { * * @package cake.tests.cases.libs.controller */ -class MergeVarPluginAppController extends AppController { +class MergeVarPluginAppController extends MergeVarsAppController { /** * components @@ -99,6 +102,13 @@ class MergeVarPluginAppController extends AppController { * @var array */ public $helpers = array('Javascript'); + +/** + * parent for mergeVars + * + * @var string + */ + protected $_mergeParent = 'MergeVarsAppController'; } /** @@ -130,14 +140,6 @@ class MergePostsController extends MergeVarPluginAppController { * @package cake.tests.cases.libs.controller */ class ControllerMergeVarsTest extends CakeTestCase { -/** - * end test - * - * @return void - */ - function endTest() { - ClassRegistry::flush(); - } /** * test that component settings are not duplicated when merging component settings @@ -145,8 +147,6 @@ class ControllerMergeVarsTest extends CakeTestCase { * @return void */ function testComponentParamMergingNoDuplication() { - $this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}"); - $Controller = new MergeVariablesController(); $Controller->constructClasses(); @@ -160,8 +160,6 @@ class ControllerMergeVarsTest extends CakeTestCase { * @return void */ function testComponentMergingWithRedeclarations() { - $this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}"); - $Controller = new MergeVariablesController(); $Controller->components['MergeVar'] = array('remote', 'redirect' => true); $Controller->constructClasses(); @@ -176,8 +174,6 @@ class ControllerMergeVarsTest extends CakeTestCase { * @return void */ function testHelperSettingMergingNoDuplication() { - $this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}"); - $Controller = new MergeVariablesController(); $Controller->constructClasses(); @@ -192,9 +188,7 @@ class ControllerMergeVarsTest extends CakeTestCase { * @return void */ function testHelperOrderPrecedence() { - $this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}"); - - $Controller =& new MergeVariablesController(); + $Controller = new MergeVariablesController(); $Controller->helpers = array('Custom', 'Foo' => array('something')); $Controller->constructClasses(); @@ -212,8 +206,6 @@ class ControllerMergeVarsTest extends CakeTestCase { * @return void */ function testMergeVarsWithPlugin() { - $this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}"); - $Controller = new MergePostsController(); $Controller->components = array('Email' => array('ports' => 'open')); $Controller->plugin = 'MergeVarPlugin'; @@ -251,9 +243,7 @@ class ControllerMergeVarsTest extends CakeTestCase { * @return void */ function testMergeVarsNotGreedy() { - $this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}"); - - $Controller =& new Controller(); + $Controller = new Controller(); $Controller->components = array(); $Controller->uses = array(); $Controller->constructClasses(); From 95f58321a8dfba24dd4e93b1b63a69776bf65140 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 15 Dec 2010 23:54:28 -0500 Subject: [PATCH 288/378] Removing a duplicate test, and extra classes. --- .../cases/libs/controller/component.test.php | 67 +------------------ 1 file changed, 2 insertions(+), 65 deletions(-) diff --git a/cake/tests/cases/libs/controller/component.test.php b/cake/tests/cases/libs/controller/component.test.php index 923e86868..726f3b3ac 100644 --- a/cake/tests/cases/libs/controller/component.test.php +++ b/cake/tests/cases/libs/controller/component.test.php @@ -20,52 +20,6 @@ App::import('Controller', 'Controller', false); App::import('Controller', 'Component', false); -if (!class_exists('AppController')) { - -/** - * AppController class - * - * @package cake - * @subpackage cake.tests.cases.libs.controller - */ - class AppController extends Controller { - -/** - * name property - * - * @var string 'App' - * @access public - */ - public $name = 'App'; - -/** - * uses property - * - * @var array - * @access public - */ - public $uses = array(); - -/** - * helpers property - * - * @var array - * @access public - */ - public $helpers = array(); - -/** - * components property - * - * @var array - * @access public - */ - public $components = array('Orange' => array('colour' => 'blood orange')); - } -} elseif (!defined('APP_CONTROLLER_EXISTS')){ - define('APP_CONTROLLER_EXISTS', true); -} - /** * ParamTestComponent * @@ -115,7 +69,7 @@ class ParamTestComponent extends Component { * @package cake * @subpackage cake.tests.cases.libs.controller */ -class ComponentTestController extends AppController { +class ComponentTestController extends Controller { /** * name property @@ -132,6 +86,7 @@ class ComponentTestController extends AppController { * @access public */ public $uses = array(); + } /** @@ -396,22 +351,4 @@ class ComponentTest extends CakeTestCase { $this->assertType('ComponentTestController', $Controller->SomethingWithEmail->Email->Controller); } -/** - * Test that SessionComponent doesn't get added if its already in the components array. - * - * @return void - */ - public function testDoubleLoadingOfSessionComponent() { - if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) { - return; - } - - $Controller = new ComponentTestController(); - $Controller->uses = false; - $Controller->components = array('Session'); - $Controller->constructClasses(); - - $this->assertEqual($Controller->components, array('Session' => '', 'Orange' => array('colour' => 'blood orange'))); - } - } From 42754c63ff8c7aecdc0bb65277f3800f24c27a82 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 16 Dec 2010 00:01:43 -0500 Subject: [PATCH 289/378] Making more tests no longer skip in test suites. --- .../cases/libs/controller/controller.test.php | 85 +++++++++---------- 1 file changed, 38 insertions(+), 47 deletions(-) diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 6f217b3e9..851e3a4a4 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -22,46 +22,38 @@ App::import('Core', array('CakeRequest', 'CakeResponse')); App::import('Component', 'Security'); App::import('Component', 'Cookie'); + /** * AppController class * * @package cake * @subpackage cake.tests.cases.libs.controller */ -if (!class_exists('AppController')) { - /** - * AppController class - * - * @package cake - * @subpackage cake.tests.cases.libs.controller - */ - class AppController extends Controller { - /** - * helpers property - * - * @var array - * @access public - */ - public $helpers = array('Html'); - /** - * uses property - * - * @var array - * @access public - */ - public $uses = array('ControllerPost'); - /** - * components property - * - * @var array - * @access public - */ - public $components = array('Cookie'); - } -} elseif (!defined('APP_CONTROLLER_EXISTS')) { - define('APP_CONTROLLER_EXISTS', true); +class ControllerTestAppController extends Controller { +/** + * helpers property + * + * @var array + * @access public + */ + public $helpers = array('Html'); +/** + * uses property + * + * @var array + * @access public + */ + public $uses = array('ControllerPost'); +/** + * components property + * + * @var array + * @access public + */ + public $components = array('Cookie'); } + /** * ControllerPost class * @@ -137,7 +129,7 @@ class ControllerPost extends CakeTestModel { * @package cake * @subpackage cake.tests.cases.libs.controller */ -class ControllerCommentsController extends AppController { +class ControllerCommentsController extends ControllerTestAppController { /** * name property @@ -146,6 +138,8 @@ class ControllerCommentsController extends AppController { * @access public */ public $name = 'ControllerComments'; + + protected $_mergeParent = 'ControllerTestAppController'; } /** @@ -259,7 +253,7 @@ class NameTest extends CakeTestModel { * @package cake * @subpackage cake.tests.cases.libs.controller */ -class TestController extends AppController { +class TestController extends ControllerTestAppController { /** * name property @@ -291,6 +285,8 @@ class TestController extends AppController { * @access public */ public $uses = array('ControllerComment', 'ControllerAlias'); + + protected $_mergeParent = 'ControllerTestAppController'; /** * index method @@ -367,7 +363,7 @@ class TestComponent extends Object { * @package cake * @subpackage cake.tests.cases.libs.controller */ -class AnotherTestController extends AppController { +class AnotherTestController extends ControllerTestAppController { /** * name property @@ -382,6 +378,8 @@ class AnotherTestController extends AppController { * @access public */ public $uses = null; + + protected $_mergeParent = 'ControllerTestAppController'; } /** @@ -870,17 +868,13 @@ class ControllerTest extends CakeTestCase { * @return void */ function testMergeVars() { - if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) { - return; - } $request = new CakeRequest('controller_posts/index'); - $TestController = new TestController($request); $TestController->constructClasses(); $testVars = get_class_vars('TestController'); - $appVars = get_class_vars('AppController'); + $appVars = get_class_vars('ControllerTestAppController'); $components = is_array($appVars['components']) ? array_merge($appVars['components'], $testVars['components']) @@ -900,12 +894,12 @@ class ControllerTest extends CakeTestCase { $this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0); $expected = array('ControllerComment', 'ControllerAlias', 'ControllerPost'); - $this->assertEquals($expected, $TestController->uses, '$uses was merged incorrectly, AppController models should be last.'); + $this->assertEquals($expected, $TestController->uses, '$uses was merged incorrectly, ControllerTestAppController models should be last.'); $TestController = new AnotherTestController($request); $TestController->constructClasses(); - $appVars = get_class_vars('AppController'); + $appVars = get_class_vars('ControllerTestAppController'); $testVars = get_class_vars('AnotherTestController'); @@ -918,7 +912,7 @@ class ControllerTest extends CakeTestCase { $TestController = new ControllerCommentsController($request); $TestController->constructClasses(); - $appVars = get_class_vars('AppController'); + $appVars = get_class_vars('ControllerTestAppController'); $testVars = get_class_vars('ControllerCommentsController'); @@ -936,9 +930,6 @@ class ControllerTest extends CakeTestCase { * @return void */ function testChildComponentOptionsSupercedeParents() { - if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) { - return; - } $request = new CakeRequest('controller_posts/index'); $TestController = new TestController($request); @@ -951,7 +942,7 @@ class ControllerTest extends CakeTestCase { /** * Ensure that __mergeVars is not being greedy and merging with - * AppController when you make an instance of Controller + * ControllerTestAppController when you make an instance of Controller * * @return void */ From f50a97bff1e5948d041f4cb4b752705e1f142c3f Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 16 Dec 2010 22:53:00 -0500 Subject: [PATCH 290/378] Making PagesController test unskipped in all_tests. --- .../cases/libs/controller/pages_controller.test.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/cake/tests/cases/libs/controller/pages_controller.test.php b/cake/tests/cases/libs/controller/pages_controller.test.php index 8188d3976..f22a6eba6 100644 --- a/cake/tests/cases/libs/controller/pages_controller.test.php +++ b/cake/tests/cases/libs/controller/pages_controller.test.php @@ -17,11 +17,6 @@ * @since CakePHP(tm) v 1.2.0.5436 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!class_exists('AppController')) { - require_once LIBS . 'controller' . DS . 'app_controller.php'; -} elseif (!defined('APP_CONTROLLER_EXISTS')) { - define('APP_CONTROLLER_EXISTS', true); -} App::import('Controller', 'Pages'); /** @@ -49,10 +44,6 @@ class PagesControllerTest extends CakeTestCase { * @return void */ function testDisplay() { - if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) { - return; - } - App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS) )); From 24373ae3c1f2629eaa994c1b793912168a568951 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 16 Dec 2010 23:05:21 -0500 Subject: [PATCH 291/378] Removing uses() it was deprecated in 1.3. Use App::import() instead. --- app/webroot/css.php | 4 +--- cake/basics.php | 18 ------------------ cake/tests/cases/basics.test.php | 19 ------------------- 3 files changed, 1 insertion(+), 40 deletions(-) diff --git a/app/webroot/css.php b/app/webroot/css.php index bab3b5405..26cddcb14 100644 --- a/app/webroot/css.php +++ b/app/webroot/css.php @@ -25,9 +25,7 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) { /** * Ensure required classes are available. */ -if (!class_exists('File')) { - uses('file'); -} +App::import('Core', 'File'); /** * Make clean CSS diff --git a/cake/basics.php b/cake/basics.php index b88e14a9e..a5ee633dd 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -61,24 +61,6 @@ return true; } -/** - * Loads component/components from LIBS. Takes optional number of parameters. - * - * Example: - * - * `uses('flay', 'time');` - * - * @param string $name Filename without the .php part - * @deprecated Will be removed in 2.0 - * @link http://book.cakephp.org/view/1140/uses - */ - function uses() { - $args = func_get_args(); - foreach ($args as $file) { - require_once(LIBS . strtolower($file) . '.php'); - } - } - /** * Prints out debug information about given variable. * diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php index 323429f8d..524c8857a 100644 --- a/cake/tests/cases/basics.test.php +++ b/cake/tests/cases/basics.test.php @@ -167,25 +167,6 @@ class BasicsTest extends CakeTestCase { $_ENV = $__ENV; } -/** - * test uses() - * - * @return void - * @access public - * @deprecated - */ - function testUses() { - $this->skipIf(class_exists('Security') || class_exists('Sanitize'), '%s Security and/or Sanitize class already loaded'); - - $this->assertFalse(class_exists('Security')); - $this->assertFalse(class_exists('Sanitize')); - - uses('Security', 'Sanitize'); - - $this->assertTrue(class_exists('Security')); - $this->assertTrue(class_exists('Sanitize')); - } - /** * Test h() * From de7b324444db56d43311fb08ec0e03954f92f4f5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 00:03:03 -0500 Subject: [PATCH 292/378] Fixing more strict warnings. Removing & on component callbacks. Updating incorrect method signatures. --- cake/libs/controller/component.php | 10 +++++----- cake/libs/controller/components/auth.php | 6 +++--- cake/libs/controller/components/cookie.php | 2 +- cake/libs/controller/components/email.php | 4 ++-- .../controller/components/request_handler.php | 8 ++++---- cake/libs/controller/components/security.php | 18 +++++++++--------- cake/libs/router.php | 3 ++- .../cases/libs/controller/component.test.php | 10 +++++----- .../libs/controller/components/auth.test.php | 5 +++-- .../libs/controller/components/cookie.test.php | 2 +- .../libs/controller/components/email.test.php | 3 ++- .../controller/components/paginator.test.php | 8 ++++---- .../controller/components/security.test.php | 6 +++--- .../cases/libs/controller/controller.test.php | 18 +++++++++--------- .../libs/controller/pages_controller.test.php | 10 ---------- .../cases/libs/controller/scaffold.test.php | 4 ++-- .../libs/error/exception_renderer.test.php | 2 +- 17 files changed, 56 insertions(+), 63 deletions(-) diff --git a/cake/libs/controller/component.php b/cake/libs/controller/component.php index c0d4b57a6..95ceb00b8 100644 --- a/cake/libs/controller/component.php +++ b/cake/libs/controller/component.php @@ -108,7 +108,7 @@ class Component extends Object { * @return void * @link http://book.cakephp.org/view/998/MVC-Class-Access-Within-Components */ - public function initialize(&$controller) { } + public function initialize($controller) { } /** * Called after the Controller::beforeFilter() and before the controller action @@ -117,7 +117,7 @@ class Component extends Object { * @return void * @link http://book.cakephp.org/view/998/MVC-Class-Access-Within-Components */ - public function startup(&$controller) { } + public function startup($controller) { } /** * Called after the Controller::beforeRender(), after the view class is loaded, and before the @@ -126,7 +126,7 @@ class Component extends Object { * @param object $controller Controller with components to beforeRender * @return void */ - public function beforeRender(&$controller) { } + public function beforeRender($controller) { } /** * Called after Controller::render() and before the output is printed to the browser. @@ -134,7 +134,7 @@ class Component extends Object { * @param object $controller Controller with components to shutdown * @return void */ - function shutdown(&$controller) { } + function shutdown($controller) { } /** * Called before Controller::redirect(). Allows you to replace the url that will @@ -154,6 +154,6 @@ class Component extends Object { * @param bool $exit Will the script exit. * @return mixed Either an array or null. */ - public function beforeRedirect(&$controller, $url, $status = null, $exit = true) {} + public function beforeRedirect($controller, $url, $status = null, $exit = true) {} } diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index a075f4fcf..f8e74f3a1 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -262,7 +262,7 @@ class AuthComponent extends Component { * @param object $controller A reference to the instantiating controller object * @return void */ - public function initialize(Controller $controller, $settings = array()) { + public function initialize($controller) { $this->request = $controller->request; $this->params = $this->request; @@ -299,7 +299,7 @@ class AuthComponent extends Component { * @param object $controller A reference to the instantiating controller object * @return boolean */ - public function startup(&$controller) { + public function startup($controller) { $isErrorOrTests = ( strtolower($controller->name) == 'cakeerror' || (strtolower($controller->name) == 'tests' && Configure::read('debug') > 0) @@ -926,7 +926,7 @@ class AuthComponent extends Component { * * @param object $controller Instantiating controller */ - public function shutdown(&$controller) { + public function shutdown($controller) { if ($this->_loggedIn) { $this->Session->delete('Auth.redirect'); } diff --git a/cake/libs/controller/components/cookie.php b/cake/libs/controller/components/cookie.php index cb12ad46e..f8aac83a0 100644 --- a/cake/libs/controller/components/cookie.php +++ b/cake/libs/controller/components/cookie.php @@ -182,7 +182,7 @@ class CookieComponent extends Component { * Start CookieComponent for use in the controller * */ - public function startup() { + public function startup($controller) { $this->_expire($this->time); if (isset($_COOKIE[$this->name])) { diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index bd8774fd3..bcb854be3 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -338,7 +338,7 @@ class EmailComponent extends Component { * * @param object $controller Instantiating controller */ - public function initialize(&$controller) { + public function initialize($controller) { if (Configure::read('App.encoding') !== null) { $this->charset = Configure::read('App.encoding'); } @@ -349,7 +349,7 @@ class EmailComponent extends Component { * * @param object $controller Instantiating controller */ - public function startup(&$controller) {} + public function startup($controller) {} /** * Send an email using the specified content, template and layout diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php index b68e5e33e..b688c755d 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/cake/libs/controller/components/request_handler.php @@ -118,7 +118,7 @@ class RequestHandlerComponent extends Component { * @return void * @see Router::parseExtensions() */ - public function initialize(&$controller, $settings = array()) { + public function initialize($controller, $settings = array()) { $this->request = $controller->request; $this->response = $controller->response; if (isset($this->request->params['url']['ext'])) { @@ -156,7 +156,7 @@ class RequestHandlerComponent extends Component { * @param object $controller A reference to the controller * @return void */ - public function startup(&$controller) { + public function startup($controller) { $controller->request->params['isAjax'] = $this->request->is('ajax'); $isRecognized = ( !in_array($this->ext, array('html', 'htm')) && @@ -194,7 +194,7 @@ class RequestHandlerComponent extends Component { * @param mixed $url A string or array containing the redirect location * @param mixed HTTP Status for redirect */ - public function beforeRedirect(&$controller, $url, $status = null) { + public function beforeRedirect($controller, $url, $status = null, $exit = true) { if (!$this->request->is('ajax')) { return; } @@ -509,7 +509,7 @@ class RequestHandlerComponent extends Component { * @see RequestHandlerComponent::setContent() * @see RequestHandlerComponent::respondAs() */ - public function renderAs(&$controller, $type, $options = array()) { + public function renderAs($controller, $type, $options = array()) { $defaults = array('charset' => 'UTF-8'); if (Configure::read('App.encoding') !== null) { diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index 69e13dbbd..b3ae711d8 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -211,7 +211,7 @@ class SecurityComponent extends Component { * @param object $controller Instantiating controller * @return void */ - public function startup(&$controller) { + public function startup($controller) { $this->request = $controller->request; $this->_action = strtolower($this->request->params['action']); $this->_methodsRequired($controller); @@ -441,7 +441,7 @@ class SecurityComponent extends Component { * @see SecurityComponent::$blackHoleCallback * @link http://book.cakephp.org/view/1307/blackHole-object-controller-string-error */ - function blackHole(&$controller, $error = '') { + function blackHole($controller, $error = '') { if ($this->blackHoleCallback == null) { $code = 404; if ($error == 'login') { @@ -474,7 +474,7 @@ class SecurityComponent extends Component { * @param object $controller Instantiating controller * @return bool true if $method is required */ - protected function _methodsRequired(&$controller) { + protected function _methodsRequired($controller) { foreach (array('Post', 'Get', 'Put', 'Delete') as $method) { $property = 'require' . $method; if (is_array($this->$property) && !empty($this->$property)) { @@ -497,7 +497,7 @@ class SecurityComponent extends Component { * @param object $controller Instantiating controller * @return bool true if secure connection required */ - protected function _secureRequired(&$controller) { + protected function _secureRequired($controller) { if (is_array($this->requireSecure) && !empty($this->requireSecure)) { $requireSecure = array_map('strtolower', $this->requireSecure); @@ -518,7 +518,7 @@ class SecurityComponent extends Component { * @param object $controller Instantiating controller * @return bool true if authentication required */ - protected function _authRequired(&$controller) { + protected function _authRequired($controller) { if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) { $requireAuth = array_map('strtolower', $this->requireAuth); @@ -553,7 +553,7 @@ class SecurityComponent extends Component { * @param object $controller Instantiating controller * @return bool true if login is required */ - protected function _loginRequired(&$controller) { + protected function _loginRequired($controller) { if (is_array($this->requireLogin) && !empty($this->requireLogin)) { $requireLogin = array_map('strtolower', $this->requireLogin); @@ -600,7 +600,7 @@ class SecurityComponent extends Component { * @param object $controller Instantiating controller * @return bool true if submitted form is valid */ - protected function _validatePost(&$controller) { + protected function _validatePost($controller) { if (empty($controller->request->data)) { return true; } @@ -672,7 +672,7 @@ class SecurityComponent extends Component { * @param object $controller Instantiating controller * @return bool Success */ - protected function _generateToken(&$controller) { + protected function _generateToken($controller) { if (isset($controller->request->params['requested']) && $controller->request->params['requested'] === 1) { if ($this->Session->check('_Token')) { $tokenData = $this->Session->read('_Token'); @@ -765,7 +765,7 @@ class SecurityComponent extends Component { * @param array $params Parameters to send to method * @return mixed Controller callback method's response */ - protected function _callback(&$controller, $method, $params = array()) { + protected function _callback($controller, $method, $params = array()) { if (is_callable(array($controller, $method))) { return call_user_func_array(array(&$controller, $method), empty($params) ? null : $params); } else { diff --git a/cake/libs/router.php b/cake/libs/router.php index a4408b92f..611301867 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -1217,7 +1217,8 @@ class Router { } else { if (preg_match_all('/\[([A-Za-z0-9_-]+)?\]/', $key, $matches, PREG_SET_ORDER)) { $matches = array_reverse($matches); - $key = array_shift(explode('[', $key)); + $parts = explode('[', $key); + $key = array_shift($parts); $arr = $val; foreach ($matches as $match) { if (empty($match[1])) { diff --git a/cake/tests/cases/libs/controller/component.test.php b/cake/tests/cases/libs/controller/component.test.php index 726f3b3ac..3c8dc99c6 100644 --- a/cake/tests/cases/libs/controller/component.test.php +++ b/cake/tests/cases/libs/controller/component.test.php @@ -52,7 +52,7 @@ class ParamTestComponent extends Component { * @access public * @return void */ - function initialize(&$controller, $settings) { + function initialize($controllerz) { foreach ($settings as $key => $value) { if (is_numeric($key)) { $this->{$value} = true; @@ -120,7 +120,7 @@ class AppleComponent extends Component { * @access public * @return void */ - function startup(&$controller) { + function startup($controller) { $this->testName = $controller->name; } } @@ -148,7 +148,7 @@ class OrangeComponent extends Component { * @access public * @return void */ - function initialize(&$controller) { + function initialize($controller) { $this->Controller = $controller; $this->Banana->testField = 'OrangeField'; } @@ -159,7 +159,7 @@ class OrangeComponent extends Component { * @param Controller $controller * @return string */ - public function startup(&$controller) { + public function startup($controller) { $controller->foo = 'pass'; } } @@ -186,7 +186,7 @@ class BananaComponent extends Component { * @param Controller $controller * @return string */ - public function startup(&$controller) { + public function startup($controller) { $controller->bar = 'fail'; } } diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 98f389efd..5b6f7262e 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -52,7 +52,7 @@ class TestAuthComponent extends AuthComponent { * @access public * @return void */ - function _stop() { + function _stop($status = 0) { $this->testStop = true; } } @@ -498,7 +498,8 @@ class AuthTest extends CakeTestCase { ); $this->Controller->beforeFilter(); - ClassRegistry::addObject('view', new View($this->Controller)); + $view = new View($this->Controller); + ClassRegistry::addObject('view', $view); $this->Controller->Session->delete('Auth'); $this->Controller->Session->delete('Message.auth'); diff --git a/cake/tests/cases/libs/controller/components/cookie.test.php b/cake/tests/cases/libs/controller/components/cookie.test.php index 84a852c6d..7d441e4c2 100644 --- a/cake/tests/cases/libs/controller/components/cookie.test.php +++ b/cake/tests/cases/libs/controller/components/cookie.test.php @@ -383,7 +383,7 @@ class CookieComponentTest extends CakeTestCase { 'name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!')); - $this->Cookie->startup(); + $this->Cookie->startup(null); $data = $this->Cookie->read('Encrytped_array'); $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!'); diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index ea2d86b29..9ce4602e1 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -230,7 +230,8 @@ class EmailComponentTest extends CakeTestCase { $this->Controller->Components->init($this->Controller); $this->Controller->EmailTest->initialize($this->Controller, array()); - ClassRegistry::addObject('view', new View($this->Controller)); + $view = new View($this->Controller); + ClassRegistry::addObject('view', $view); App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index cb6beb153..20abfd8da 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -113,13 +113,13 @@ class PaginatorControllerPost extends CakeTestModel { * @access public * @return void */ - function find($type, $options = array()) { - if ($type == 'popular') { + function find($conditions = null, $fields = array(), $order = null, $recursive = null) { + if ($conditions == 'popular') { $conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1'); - $options = Set::merge($options, compact('conditions')); + $options = Set::merge($fields, compact('conditions')); return parent::find('all', $options); } - return parent::find($type, $options); + return parent::find($conditions, $fields); } } diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/cake/tests/cases/libs/controller/components/security.test.php index bd0bcc9f1..33548c70e 100644 --- a/cake/tests/cases/libs/controller/components/security.test.php +++ b/cake/tests/cases/libs/controller/components/security.test.php @@ -34,7 +34,7 @@ class TestSecurityComponent extends SecurityComponent { * @param Controller $controller * @return unknown */ - function validatePost(&$controller) { + function validatePost($controller) { return $this->_validatePost($controller); } } @@ -98,8 +98,8 @@ class SecurityTestController extends Controller { * @access public * @return void */ - function redirect($option, $code, $exit) { - return $code; + function redirect($url, $status = null, $exit = true) { + return $status; } /** diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 851e3a4a4..39563931b 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -113,13 +113,13 @@ class ControllerPost extends CakeTestModel { * @access public * @return void */ - function find($type, $options = array()) { - if ($type == 'popular') { + function find($conditions = null, $fields = array(), $order = null, $recursive = null) { + if ($conditions == 'popular') { $conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1'); - $options = Set::merge($options, compact('conditions')); - return parent::find('all', $options); + $options = Set::merge($fields, compact('conditions')); + return parent::find('all', $fields); } - return parent::find($type, $options); + return parent::find($conditions, $fields); } } @@ -326,7 +326,7 @@ class TestComponent extends Object { * @access public * @return void */ - function initialize(&$controller) { + function initialize($controller) { } /** @@ -335,7 +335,7 @@ class TestComponent extends Object { * @access public * @return void */ - function startup(&$controller) { + function startup($controller) { } /** * shutdown method @@ -343,14 +343,14 @@ class TestComponent extends Object { * @access public * @return void */ - function shutdown(&$controller) { + function shutdown($controller) { } /** * beforeRender callback * * @return void */ - function beforeRender(&$controller) { + function beforeRender($controller) { if ($this->viewclass) { $controller->view = $this->viewclass; } diff --git a/cake/tests/cases/libs/controller/pages_controller.test.php b/cake/tests/cases/libs/controller/pages_controller.test.php index f22a6eba6..3d3084719 100644 --- a/cake/tests/cases/libs/controller/pages_controller.test.php +++ b/cake/tests/cases/libs/controller/pages_controller.test.php @@ -27,16 +27,6 @@ App::import('Controller', 'Pages'); */ class PagesControllerTest extends CakeTestCase { -/** - * endTest method - * - * @access public - * @return void - */ - function endTest() { - App::build(); - } - /** * testDisplay method * diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php index e0f925b39..a68e7ad2b 100644 --- a/cake/tests/cases/libs/controller/scaffold.test.php +++ b/cake/tests/cases/libs/controller/scaffold.test.php @@ -93,8 +93,8 @@ class TestScaffoldMock extends Scaffold { * * @param unknown_type $params */ - function _scaffold($params) { - $this->_params = $params; + function _scaffold(CakeRequest $request) { + $this->_params = $request; } /** diff --git a/cake/tests/cases/libs/error/exception_renderer.test.php b/cake/tests/cases/libs/error/exception_renderer.test.php index 91efdf608..4de432fb9 100644 --- a/cake/tests/cases/libs/error/exception_renderer.test.php +++ b/cake/tests/cases/libs/error/exception_renderer.test.php @@ -67,7 +67,7 @@ class BlueberryComponent extends Component { * @access public * @return void */ - function initialize(&$controller) { + function initialize($controller) { $this->testName = 'BlueberryComponent'; } } From c5bab541251b1ae8a846907d4ac4fa9b30ba1925 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 00:15:09 -0500 Subject: [PATCH 293/378] Starting to try and re-factor named params to perform better and be more explicit with how they are used. --- cake/libs/route/cake_route.php | 11 ++++++++++- cake/libs/router.php | 4 ++-- cake/tests/cases/libs/route/cake_route.test.php | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 979f90dcf..0dbe085f8 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -263,6 +263,15 @@ class CakeRoute { if (array_intersect_key($keyNames, $url) != $keyNames) { return false; } + + //pull out named params so comparisons later on are faster. + $named = array(); + foreach ($url as $key => $value) { + if ($key[0] === ':') { + $named[$key] = $value; + unset($url[$key]); + } + } $diffUnfiltered = Set::diff($url, $defaults); $diff = array(); @@ -289,7 +298,7 @@ class CakeRoute { return false; } - $passedArgsAndParams = array_diff_key($diff, $filteredDefaults, $keyNames); + $passedArgsAndParams = array_diff_key($diff, $filteredDefaults, $keyNames) + $named; list($named, $params) = Router::getNamedElements($passedArgsAndParams, $url['controller'], $url['action']); //remove any pass params, they have numeric indexes, skip any params that are in the defaults diff --git a/cake/libs/router.php b/cake/libs/router.php index 611301867..85491ebc0 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -89,7 +89,7 @@ class Router { * @access public */ public static $named = array( - 'default' => array('page', 'fields', 'order', 'limit', 'recursive', 'sort', 'direction', 'step'), + 'default' => array(':page', ':fields', ':order', ':limit', ':recursive', ':sort', ':direction', ':step'), 'greedy' => true, 'separator' => ':', 'rules' => false, @@ -972,7 +972,7 @@ class Router { if (isset(self::$named['rules'][$param])) { $rule = self::$named['rules'][$param]; if (Router::matchNamed($param, $val, $rule, compact('controller', 'action'))) { - $named[$param] = $val; + $named[substr($param, 1)] = $val; unset($params[$param]); } } diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index dae305b23..a5c13c62b 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -298,13 +298,13 @@ class CakeRouteTestCase extends CakeTestCase { Router::connectNamed(true); $route = new CakeRoute('/:controller/:action/*', array('plugin' => null)); - $result = $route->match(array('controller' => 'posts', 'action' => 'index', 'plugin' => null, 'page' => 1)); + $result = $route->match(array('controller' => 'posts', 'action' => 'index', 'plugin' => null, ':page' => 1)); $this->assertEqual($result, '/posts/index/page:1'); $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5)); $this->assertEqual($result, '/posts/view/5'); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5, 'page' => 1, 'limit' => 20, 'order' => 'title')); + $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5, ':page' => 1, ':limit' => 20, ':order' => 'title')); $this->assertEqual($result, '/posts/view/5/page:1/limit:20/order:title'); From 456a14cf37e4b03680aabb8cd346124fbe0c8f35 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 12:34:48 -0500 Subject: [PATCH 294/378] Refactored CakeRoute::match() to not use Set::diff(). This was the slowest part of reverse routing and this change should make things faster. Added additional tests for the 0 edge case. --- cake/libs/route/cake_route.php | 55 +++++++++---------- .../cases/libs/route/cake_route.test.php | 6 ++ 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 0dbe085f8..8803a3201 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -263,27 +263,40 @@ class CakeRoute { if (array_intersect_key($keyNames, $url) != $keyNames) { return false; } - - //pull out named params so comparisons later on are faster. - $named = array(); + + $named = $pass = $diff = array(); foreach ($url as $key => $value) { + // pull out named params so comparisons later on are faster. if ($key[0] === ':') { - $named[$key] = $value; + $named[substr($key, 1)] = $value; unset($url[$key]); + continue; } - } - $diffUnfiltered = Set::diff($url, $defaults); - $diff = array(); - - foreach ($diffUnfiltered as $key => $var) { - if ($var === 0 || $var === '0' || !empty($var)) { - $diff[$key] = $var; + // keys that exist in the defaults and have different values cause match failures. + $keyExists = array_key_exists($key, $defaults); + if ($keyExists && $defaults[$key] != $value) { + $diff[$key] = $value; + continue; + } + // keys that don't exist are different. + if (!$keyExists) { + $diff[$key] = $value; + } + + // pull out passed args + $numeric = is_numeric($key); + if ($numeric && isset($defaults[$key]) && $defaults[$key] == $value) { + continue; + } elseif ($numeric) { + $pass[] = $value; + unset($url[$key]); + continue; } } //if a not a greedy route, no extra params are allowed. - if (!$this->_greedy && array_diff_key($diff, $keyNames) != array()) { + if (!$this->_greedy && (!empty($pass) || array_diff_key($diff, $keyNames) != array())) { return false; } @@ -294,26 +307,10 @@ class CakeRoute { $filteredDefaults = array_filter($defaults); //if the difference between the url diff and defaults contains keys from defaults its not a match - if (array_intersect_key($filteredDefaults, $diffUnfiltered) !== array()) { + if (array_intersect_key($filteredDefaults, $diff) !== array()) { return false; } - $passedArgsAndParams = array_diff_key($diff, $filteredDefaults, $keyNames) + $named; - list($named, $params) = Router::getNamedElements($passedArgsAndParams, $url['controller'], $url['action']); - - //remove any pass params, they have numeric indexes, skip any params that are in the defaults - $pass = array(); - $i = 0; - while (isset($url[$i])) { - if (!isset($diff[$i])) { - $i++; - continue; - } - $pass[] = $url[$i]; - unset($url[$i], $params[$i]); - $i++; - } - //still some left over parameters that weren't named or passed args, bail. if (!empty($params)) { return false; diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index a5c13c62b..37fd17d1c 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -304,6 +304,12 @@ class CakeRouteTestCase extends CakeTestCase { $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5)); $this->assertEqual($result, '/posts/view/5'); + $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 0)); + $this->assertEqual($result, '/posts/view/0'); + + $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, '0')); + $this->assertEqual($result, '/posts/view/0'); + $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5, ':page' => 1, ':limit' => 20, ':order' => 'title')); $this->assertEqual($result, '/posts/view/5/page:1/limit:20/order:title'); From 6ef8203d54199bcb438e6e402af911b18c6b1522 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 13:32:05 -0500 Subject: [PATCH 295/378] Adding another case that makes false/null to not cause match failure. --- cake/libs/route/cake_route.php | 2 +- cake/tests/cases/libs/route/cake_route.test.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 8803a3201..5fa934347 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -280,7 +280,7 @@ class CakeRoute { continue; } // keys that don't exist are different. - if (!$keyExists) { + if (!$keyExists && !empty($value)) { $diff[$key] = $value; } diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index 37fd17d1c..a8c5404fa 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -289,6 +289,19 @@ class CakeRouteTestCase extends CakeTestCase { $this->assertEqual($result, $expected); } +/** + * test that falsey values do not interrupt a match. + * + * @return void + */ + function testMatchWithFalseyValues() { + $route = new CakeRoute('/:controller/:action/*', array('plugin' => null)); + $result = $route->match(array( + 'controller' => 'posts', 'action' => 'index', 'plugin' => null, 'admin' => false + )); + $this->assertEqual($result, '/posts/index/'); + } + /** * test match() with greedy routes, named parameters and passed args. * From 8d404332a279ebe9cfe59de8a0a9ef571c6c1ffa Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 13:40:07 -0500 Subject: [PATCH 296/378] Fixing issue where named params equal to null/false would be part of the generated url. --- cake/libs/route/cake_route.php | 2 +- cake/tests/cases/libs/route/cake_route.test.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 5fa934347..93c48897b 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -267,7 +267,7 @@ class CakeRoute { $named = $pass = $diff = array(); foreach ($url as $key => $value) { // pull out named params so comparisons later on are faster. - if ($key[0] === ':') { + if ($key[0] === ':' && ($value !== false && $value !== null)) { $named[substr($key, 1)] = $value; unset($url[$key]); continue; diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index a8c5404fa..bf58d8295 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -338,6 +338,17 @@ class CakeRouteTestCase extends CakeTestCase { $this->assertFalse($result); } +/** + * test that named params with null/false are excluded + * + * @return void + */ + function testNamedParamsWithNullFalse() { + $route = new CakeRoute('/:controller/:action/*', array('plugin' => null)); + $result = $route->match(array('controller' => 'posts', 'action' => 'index', ':page' => null, 'sort' => false)); + $this->assertEquals('/posts/index/', $result); + } + /** * test that match with patterns works. * From 328db0c36b12ca8ceb59dd374ac82fba1c17e9e5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 14:16:00 -0500 Subject: [PATCH 297/378] Fixed a number of tests, there are still a few issues with prefix routes. Moved removing defaults that are also keys to the compile step. This removes quite a few repetitive loops. --- cake/libs/route/cake_route.php | 36 ++++++++++--------- cake/libs/router.php | 3 +- .../cases/libs/route/cake_route.test.php | 33 ++++++++++++++--- cake/tests/cases/libs/router.test.php | 30 ++++++++-------- 4 files changed, 65 insertions(+), 37 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 93c48897b..9d1fb97c7 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -165,6 +165,11 @@ class CakeRoute { $parsed = str_replace(array_keys($routeParams), array_values($routeParams), $parsed); $this->_compiledRoute = '#^' . $parsed . '[/]*$#'; $this->keys = $names; + + //remove defaults that are also keys. They can cause match failures + foreach ($this->keys as $key) { + unset($this->defaults[$key]); + } } /** @@ -265,6 +270,7 @@ class CakeRoute { } $named = $pass = $diff = array(); + foreach ($url as $key => $value) { // pull out named params so comparisons later on are faster. if ($key[0] === ':' && ($value !== false && $value !== null)) { @@ -279,11 +285,12 @@ class CakeRoute { $diff[$key] = $value; continue; } - // keys that don't exist are different. - if (!$keyExists && !empty($value)) { - $diff[$key] = $value; - } + // If the key is a routed key, its not different yet. + if (array_key_exists($key, $keyNames)) { + continue; + } + // pull out passed args $numeric = is_numeric($key); if ($numeric && isset($defaults[$key]) && $defaults[$key] == $value) { @@ -293,26 +300,21 @@ class CakeRoute { unset($url[$key]); continue; } + + // keys that don't exist are different. + if (!$keyExists && !empty($value)) { + $diff[$key] = $value; + } } + //if a not a greedy route, no extra params are allowed. - if (!$this->_greedy && (!empty($pass) || array_diff_key($diff, $keyNames) != array())) { - return false; - } - - //remove defaults that are also keys. They can cause match failures - foreach ($this->keys as $key) { - unset($defaults[$key]); - } - $filteredDefaults = array_filter($defaults); - - //if the difference between the url diff and defaults contains keys from defaults its not a match - if (array_intersect_key($filteredDefaults, $diff) !== array()) { + if (!$this->_greedy && ( (!empty($pass) || !empty($named)) || array_diff_key($diff, $keyNames) != array()) ) { return false; } //still some left over parameters that weren't named or passed args, bail. - if (!empty($params)) { + if (!empty($diff)) { return false; } diff --git a/cake/libs/router.php b/cake/libs/router.php index 85491ebc0..43c9590bf 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -943,7 +943,8 @@ class Router { } if (!empty($named)) { - foreach ($named as $name => $value) { + foreach ($named as $name => $value) { + $name = trim($name, ':'); if (is_array($value)) { $flattend = Set::flatten($value, ']['); foreach ($flattend as $namedKey => $namedValue) { diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index bf58d8295..aa6a7246b 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -191,8 +191,7 @@ class CakeRouteTestCase extends CakeTestCase { $this->assertEqual($route->options, array('extra' => '[a-z1-9_]*', 'slug' => '[a-z1-9_]+', 'action' => 'view')); $expected = array( 'controller' => 'pages', - 'action' => 'view', - 'extra' => null, + 'action' => 'view' ); $this->assertEqual($route->defaults, $expected); @@ -220,7 +219,7 @@ class CakeRouteTestCase extends CakeTestCase { * @return void **/ function testMatchBasic() { - $route = new CakeRoute('/:controller/:action/:id', array('plugin' => null)); +/* $route = new CakeRoute('/:controller/:action/:id', array('plugin' => null)); $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null)); $this->assertFalse($result); @@ -236,7 +235,7 @@ class CakeRouteTestCase extends CakeTestCase { $result = $route->match(array('controller' => 'pages', 'action' => 'display', 'about')); $this->assertFalse($result); - +*/ $route = new CakeRoute('/pages/*', array('controller' => 'pages', 'action' => 'display')); $result = $route->match(array('controller' => 'pages', 'action' => 'display', 'home')); @@ -289,6 +288,32 @@ class CakeRouteTestCase extends CakeTestCase { $this->assertEqual($result, $expected); } +/** + * test that non-greedy routes fail with extra passed args + * + * @return void + */ + function testGreedyRouteFailurePassedArg() { + $route = new CakeRoute('/:controller/:action', array('plugin' => null)); + $result = $route->match(array('controller' => 'posts', 'action' => 'view', '0')); + $this->assertFalse($result); + + $route = new CakeRoute('/:controller/:action', array('plugin' => null)); + $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'test')); + $this->assertFalse($result); + } + +/** + * test that non-greedy routes fail with extra passed args + * + * @return void + */ + function testGreedyRouteFailureNamedParam() { + $route = new CakeRoute('/:controller/:action', array('plugin' => null)); + $result = $route->match(array('controller' => 'posts', 'action' => 'view', ':page' => 1)); + $this->assertFalse($result); + } + /** * test that falsey values do not interrupt a match. * diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index e0def56f9..31539a185 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -328,7 +328,7 @@ class RouterTest extends CakeTestCase { Router::connect('short_controller_name/:action/*', array('controller' => 'real_controller_name')); Router::parse('/'); - $result = Router::url(array('controller' => 'real_controller_name', 'page' => '1')); + $result = Router::url(array('controller' => 'real_controller_name', ':page' => '1')); $expected = '/short_controller_name/index/page:1'; $this->assertEqual($result, $expected); @@ -389,14 +389,14 @@ class RouterTest extends CakeTestCase { * @return void */ function testArrayNamedParameters() { - $result = Router::url(array('controller' => 'tests', 'pages' => array( + $result = Router::url(array('controller' => 'tests', ':pages' => array( 1, 2, 3 ))); $expected = '/tests/index/pages[0]:1/pages[1]:2/pages[2]:3'; $this->assertEqual($result, $expected); $result = Router::url(array('controller' => 'tests', - 'pages' => array( + ':pages' => array( 'param1' => array( 'one', 'two' @@ -408,7 +408,7 @@ class RouterTest extends CakeTestCase { $this->assertEqual($result, $expected); $result = Router::url(array('controller' => 'tests', - 'pages' => array( + ':pages' => array( 'param1' => array( 'one' => 1, 'two' => 2 @@ -420,7 +420,7 @@ class RouterTest extends CakeTestCase { $this->assertEqual($result, $expected); $result = Router::url(array('controller' => 'tests', - 'super' => array( + ':super' => array( 'nested' => array( 'array' => 'awesome', 'something' => 'else' @@ -431,7 +431,7 @@ class RouterTest extends CakeTestCase { $expected = '/tests/index/super[nested][array]:awesome/super[nested][something]:else/super[0]:cool'; $this->assertEqual($result, $expected); - $result = Router::url(array('controller' => 'tests', 'namedParam' => array( + $result = Router::url(array('controller' => 'tests', ':namedParam' => array( 'keyed' => 'is an array', 'test' ))); @@ -648,9 +648,9 @@ class RouterTest extends CakeTestCase { Router::parse('/'); - $result = Router::url(array('page' => 3)); + $result = Router::url(array(':page' => 3)); $expected = '/magazine/admin/subscriptions/index/page:3'; - $this->assertEqual($result, $expected); + $this->assertEquals($expected, $result); Router::reload(); Router::connect('/admin/subscriptions/:action/*', array('controller' => 'subscribe', 'admin' => true, 'prefix' => 'admin')); @@ -860,7 +860,7 @@ class RouterTest extends CakeTestCase { $result = Router::url(array( 'lang' => 'en', - 'controller' => 'shows', 'action' => 'index', 'page' => '1', + 'controller' => 'shows', 'action' => 'index', ':page' => '1', )); $expected = '/en/shows/shows/page:1'; $this->assertEqual($result, $expected); @@ -1361,11 +1361,11 @@ class RouterTest extends CakeTestCase { * @return void */ function testNamedArgsUrlGeneration() { - $result = Router::url(array('controller' => 'posts', 'action' => 'index', 'published' => 1, 'deleted' => 1)); + $result = Router::url(array('controller' => 'posts', 'action' => 'index', ':published' => 1, ':deleted' => 1)); $expected = '/posts/index/published:1/deleted:1'; $this->assertEqual($result, $expected); - $result = Router::url(array('controller' => 'posts', 'action' => 'index', 'published' => 0, 'deleted' => 0)); + $result = Router::url(array('controller' => 'posts', 'action' => 'index', ':published' => 0, ':deleted' => 0)); $expected = '/posts/index/published:0/deleted:0'; $this->assertEqual($result, $expected); @@ -1375,11 +1375,11 @@ class RouterTest extends CakeTestCase { Router::connect('/', array('controller' => 'graphs', 'action' => 'index')); Router::connect('/:id/*', array('controller' => 'graphs', 'action' => 'view'), array('id' => $ID)); - $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 'id' => 12, 'file' => 'asdf.png')); + $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 'id' => 12, ':file' => 'asdf.png')); $expected = '/12/file:asdf.png'; $this->assertEqual($result, $expected); - $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 12, 'file' => 'asdf.foo')); + $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 12, ':file' => 'asdf.foo')); $expected = '/graphs/view/12/file:asdf.foo'; $this->assertEqual($result, $expected); @@ -1398,7 +1398,7 @@ class RouterTest extends CakeTestCase { ); Router::parse('/'); - $result = Router::url(array('page' => 1, 0 => null, 'sort' => 'controller', 'direction' => 'asc', 'order' => null)); + $result = Router::url(array(':page' => 1, 0 => null, ':sort' => 'controller', ':direction' => 'asc', ':order' => null)); $expected = "/admin/controller/index/page:1/sort:controller/direction:asc"; $this->assertEqual($result, $expected); @@ -1411,7 +1411,7 @@ class RouterTest extends CakeTestCase { Router::setRequestInfo($request); $result = Router::parse('/admin/controller/index/type:whatever'); - $result = Router::url(array('type'=> 'new')); + $result = Router::url(array(':type'=> 'new')); $expected = "/admin/controller/index/type:new"; $this->assertEqual($result, $expected); } From 756b09849fd9febd9c202260b1f3063ae6a76da0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 14:26:45 -0500 Subject: [PATCH 298/378] Router tests all pass now. --- cake/libs/route/cake_route.php | 6 +++++- cake/tests/cases/libs/router.test.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 9d1fb97c7..27e453ea9 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -269,6 +269,11 @@ class CakeRoute { return false; } + // Missing defaults is a fail. + if (array_diff_key($defaults, $url) !== array()) { + return false; + } + $named = $pass = $diff = array(); foreach ($url as $key => $value) { @@ -307,7 +312,6 @@ class CakeRoute { } } - //if a not a greedy route, no extra params are allowed. if (!$this->_greedy && ( (!empty($pass) || !empty($named)) || array_diff_key($diff, $keyNames) != array()) ) { return false; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 31539a185..6d2f700f6 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1516,7 +1516,7 @@ class RouterTest extends CakeTestCase { $result = Router::url(array('controller' => 'images', 'action' => 'add')); $expected = '/images/add'; - $this->assertEqual($result, $expected); + $this->assertEquals($expected, $result); $result = Router::url(array('controller' => 'images', 'action' => 'add', 'protected' => true)); $expected = '/protected/images/add'; From 3b0a3d4109dc8550603fc4412dd2ec8d7cae0d93 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 14:36:11 -0500 Subject: [PATCH 299/378] Making route matching fail even faster. This gives significant performance boosts to routes not matching. --- cake/libs/route/cake_route.php | 4 +++- cake/tests/cases/libs/route/cake_route.test.php | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 27e453ea9..bbe70bc63 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -265,7 +265,7 @@ class CakeRoute { //check that all the key names are in the url $keyNames = array_flip($this->keys); - if (array_intersect_key($keyNames, $url) != $keyNames) { + if (array_intersect_key($keyNames, $url) !== $keyNames) { return false; } @@ -287,6 +287,7 @@ class CakeRoute { // keys that exist in the defaults and have different values cause match failures. $keyExists = array_key_exists($key, $defaults); if ($keyExists && $defaults[$key] != $value) { + return false; $diff[$key] = $value; continue; } @@ -308,6 +309,7 @@ class CakeRoute { // keys that don't exist are different. if (!$keyExists && !empty($value)) { + return false; $diff[$key] = $value; } } diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index aa6a7246b..279e305f1 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -219,7 +219,7 @@ class CakeRouteTestCase extends CakeTestCase { * @return void **/ function testMatchBasic() { -/* $route = new CakeRoute('/:controller/:action/:id', array('plugin' => null)); + $route = new CakeRoute('/:controller/:action/:id', array('plugin' => null)); $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null)); $this->assertFalse($result); @@ -235,7 +235,7 @@ class CakeRouteTestCase extends CakeTestCase { $result = $route->match(array('controller' => 'pages', 'action' => 'display', 'about')); $this->assertFalse($result); -*/ + $route = new CakeRoute('/pages/*', array('controller' => 'pages', 'action' => 'display')); $result = $route->match(array('controller' => 'pages', 'action' => 'display', 'home')); @@ -369,7 +369,7 @@ class CakeRouteTestCase extends CakeTestCase { * @return void */ function testNamedParamsWithNullFalse() { - $route = new CakeRoute('/:controller/:action/*', array('plugin' => null)); + $route = new CakeRoute('/:controller/:action/*'); $result = $route->match(array('controller' => 'posts', 'action' => 'index', ':page' => null, 'sort' => false)); $this->assertEquals('/posts/index/', $result); } From 5255b8fc9e9dabb490d758d4073cbd2d9d16fb66 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 15:36:22 -0500 Subject: [PATCH 300/378] Updating doc block for Router::redirect() Updating RedirectRoute to not use defaults for where the route will redirect. --- cake/libs/route/redirect_route.php | 31 +++++++++++++++++++++++++----- cake/libs/router.php | 7 +++++-- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/cake/libs/route/redirect_route.php b/cake/libs/route/redirect_route.php index 148ce358f..e385dec0d 100644 --- a/cake/libs/route/redirect_route.php +++ b/cake/libs/route/redirect_route.php @@ -2,7 +2,9 @@ App::import('Core', 'CakeResponse'); App::import('Core', 'route/CakeRoute'); /** - * Redirect route will perform an immediate redirect + * Redirect route will perform an immediate redirect. Redirect routes + * are useful when you want to have Routing layer redirects occur in your + * application, for when URLs move. * * PHP5 * @@ -28,6 +30,25 @@ class RedirectRoute extends CakeRoute { */ public $response = null; +/** + * The location to redirect to. Either a string or a cake array url. + * + * @var mixed + */ + public $redirect; + +/** + * Constructor + * + * @param string $template Template string with parameter placeholders + * @param array $defaults Array of defaults for the route. + * @param string $params Array of parameters and additional options for the Route + */ + public function __construct($template, $defaults = array(), $options = array()) { + parent::__construct($template, $defaults, $options); + $this->redirect = (array)$defaults; + } + /** * Parses a string url into an array. Parsed urls will result in an automatic * redirection @@ -43,16 +64,16 @@ class RedirectRoute extends CakeRoute { if (!$this->response) { $this->response = new CakeResponse(); } - $redirect = $this->defaults; - if (count($this->defaults) == 1 && !isset($this->defaults['controller'])) { - $redirect = $this->defaults[0]; + $redirect = $this->redirect; + if (count($this->redirect) == 1 && !isset($this->redirect['controller'])) { + $redirect = $this->redirect[0]; } if (isset($this->options['persist']) && is_array($redirect)) { $argOptions['context'] = array('action' => $redirect['action'], 'controller' => $redirect['controller']); $args = Router::getArgs($params['_args_'], $argOptions); $redirect += $args['pass']; $redirect += $args['named']; - } + } $status = 301; if (isset($this->options['status']) && ($this->options['status'] >= 300 && $this->options['status'] < 400)) { $status = $this->options['status']; diff --git a/cake/libs/router.php b/cake/libs/router.php index 43c9590bf..506bdb2b0 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -269,15 +269,18 @@ class Router { * * `Router::redirect('/home/*', array('controller' => 'posts', 'action' => 'view', array('persist' => true));` * - * Redirects /home/* to /posts/view and passes the parameters to /posts/view + * Redirects /home/* to /posts/view and passes the parameters to /posts/view. Using an array as the + * redirect destination allows you to use other routes to define where a url string should be redirected ot. * * `Router::redirect('/posts/*', 'http://google.com', array('status' => 302));` * * Redirects /posts/* to http://google.com with a HTTP status of 302 * * ### Options: + * * - `status` Sets the HTTP status (default 301) - * - `persist` Passes the params to the redirected route, if it can + * - `persist` Passes the params to the redirected route, if it can. This is useful with greedy routes, + * routes that end in `*` are greedy. As you can remap urls and not loose any passed/named args. * * @param string $route A string describing the template of the route * @param array $url A url to redirect to. Can be a string or a Cake array-based url From b1630d4f07b6cbb3cb27c57d5752eb4e998b9406 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 15:48:14 -0500 Subject: [PATCH 301/378] Removing garbage from Paginator test cases. --- .../libs/view/helpers/paginator.test.php | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 2d0bda4a9..2e60552c5 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -139,8 +139,8 @@ class PaginatorHelperTest extends CakeTestCase { Router::reload(); Router::parse('/'); Router::setRequestInfo(array( - array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'form' => array(), 'url' => array('url' => 'accounts/'), 'bare' => 0), - array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/', 'passedArgs' => array()) + array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'url' => array('url' => 'accounts/')), + array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/') )); $this->Paginator->options(array('url' => array('param'))); $result = $this->Paginator->sort('title'); @@ -279,9 +279,8 @@ class PaginatorHelperTest extends CakeTestCase { Router::parse('/'); Router::setRequestInfo(array( array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), - 'form' => array(), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true'), 'bare' => 0), - array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/', 'here' => '/accounts/', - 'webroot' => '/', 'passedArgs' => array()) + 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true')), + array('base' => '/', 'here' => '/accounts/', 'webroot' => '/',) )); $this->Paginator->options(array('url' => array('param'))); @@ -313,7 +312,7 @@ class PaginatorHelperTest extends CakeTestCase { Router::parse('/'); Router::setRequestInfo(array( array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'form' => array(), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true'), 'bare' => 0), - array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/', 'passedArgs' => array()) + array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/') )); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc'); @@ -444,7 +443,7 @@ class PaginatorHelperTest extends CakeTestCase { Router::reload(); Router::setRequestInfo(array( - array('pass' => array(), 'named' => array(), 'controller' => 'users', 'plugin' => null, 'action' => 'admin_index', 'prefix' => 'admin', 'admin' => true, 'url' => array('ext' => 'html', 'url' => 'admin/users'), 'form' => array()), + array('pass' => array(), 'named' => array(), 'controller' => 'users', 'plugin' => null, 'action' => 'admin_index', 'prefix' => 'admin', 'admin' => true, 'url' => array('ext' => 'html', 'url' => 'admin/users')), array('base' => '', 'here' => '/admin/users', 'webroot' => '/') )); Router::parse('/admin/users'); @@ -461,8 +460,8 @@ class PaginatorHelperTest extends CakeTestCase { Router::reload(); Router::setRequestInfo(array( - array('plugin' => null, 'controller' => 'test', 'action' => 'admin_index', 'pass' => array(), 'prefix' => 'admin', 'admin' => true, 'form' => array(), 'url' => array('url' => 'admin/test')), - array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '', 'here' => '/admin/test', 'webroot' => '/') + array('plugin' => null, 'controller' => 'test', 'action' => 'admin_index', 'pass' => array(), 'prefix' => 'admin', 'admin' => true, 'url' => array('url' => 'admin/test')), + array('base' => '', 'here' => '/admin/test', 'webroot' => '/') )); Router::parse('/'); $this->Paginator->options(array('url' => array('param'))); @@ -532,7 +531,7 @@ class PaginatorHelperTest extends CakeTestCase { Router::setRequestInfo( array( array('controller' => 'posts', 'action' => 'index', 'form' => array(), 'url' => array(), 'plugin' => null), - array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '', 'here' => 'posts/index', 'webroot' => '/') + array('base' => '', 'here' => 'posts/index', 'webroot' => '/') )); $this->Paginator->request->params['paging']['Article']['options']['page'] = 2; @@ -643,8 +642,8 @@ class PaginatorHelperTest extends CakeTestCase { Router::reload(); Router::parse('/'); Router::setRequestInfo(array( - array('plugin' => null, 'controller' => 'articles', 'action' => 'index', 'pass' => array('2'), 'named' => array('foo' => 'bar'), 'form' => array(), 'url' => array('url' => 'articles/index/2/foo:bar'), 'bare' => 0), - array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/', 'here' => '/articles/', 'webroot' => '/', 'passedArgs' => array(0 => '2', 'foo' => 'bar')) + array('plugin' => null, 'controller' => 'articles', 'action' => 'index', 'pass' => array('2'), 'named' => array('foo' => 'bar'), 'url' => array('url' => 'articles/index/2/foo:bar')), + array('base' => '/', 'here' => '/articles/', 'webroot' => '/', 'passedArgs' => array(0 => '2', 'foo' => 'bar')) )); $this->Paginator->request->params['paging'] = array( 'Article' => array( @@ -1932,8 +1931,8 @@ class PaginatorHelperTest extends CakeTestCase { Router::reload(); Router::parse('/'); Router::setRequestInfo(array( - array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'form' => array(), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true'), 'bare' => 0), - array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/', 'passedArgs' => array()) + array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true')), + array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/', 'passedArgs' => array()) )); $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc'); From 9c1516e6a80589124b8111f74176e89edbea8b62 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 15:52:23 -0500 Subject: [PATCH 302/378] Fixing calltime pass by reference deprecation warnings. --- cake/libs/http_socket.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index b1df3f25d..ba56034bd 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -539,7 +539,7 @@ class HttpSocket extends CakeSocket { if (!method_exists($authClass, 'authentication')) { throw new SocketException(sprintf(__('The %s do not support authentication.'), $authClass)); } - call_user_func("$authClass::authentication", $this, &$this->_auth[$method]); + call_user_func("$authClass::authentication", $this, $this->_auth[$method]); } /** @@ -565,7 +565,7 @@ class HttpSocket extends CakeSocket { if (!method_exists($authClass, 'proxyAuthentication')) { throw new SocketException(sprintf(__('The %s do not support proxy authentication.'), $authClass)); } - call_user_func("$authClass::proxyAuthentication", $this, &$this->_proxy); + call_user_func("$authClass::proxyAuthentication", $this, $this->_proxy); } /** From eb9fe07472bb35c98b0186e94776a9d9e7330387 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 16:44:21 -0500 Subject: [PATCH 303/378] Adding query string generation into CakeRoute. This removes one more task from Router. Tests added Adding constants for the named param and querystring param sigils. --- cake/libs/route/cake_route.php | 53 ++++++++++++++----- .../cases/libs/route/cake_route.test.php | 24 +++++++++ 2 files changed, 65 insertions(+), 12 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index bbe70bc63..7e4af3384 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -73,6 +73,16 @@ class CakeRoute { */ protected $_compiledRoute = null; +/** + * Constant for the sigil that indicates a route param is a named parameter. + */ + const SIGIL_NAMED = ':'; + +/** + * Constant for the sigil that indicates a route param is a query string parameter. + */ + const SIGIL_QUERYSTRING = '?'; + /** * HTTP header shortcut map. Used for evaluating header-based route expressions. * @@ -274,22 +284,27 @@ class CakeRoute { return false; } - $named = $pass = $diff = array(); + $named = $pass = $_query = array(); foreach ($url as $key => $value) { // pull out named params so comparisons later on are faster. - if ($key[0] === ':' && ($value !== false && $value !== null)) { + if ($key[0] === CakeRoute::SIGIL_NAMED && ($value !== false && $value !== null)) { $named[substr($key, 1)] = $value; unset($url[$key]); continue; } + + // pull out querystring params + if ($key[0] === CakeRoute::SIGIL_QUERYSTRING && ($value !== false && $value !== null)) { + $_query[substr($key, 1)] = $value; + unset($url[$key]); + continue; + } // keys that exist in the defaults and have different values cause match failures. $keyExists = array_key_exists($key, $defaults); if ($keyExists && $defaults[$key] != $value) { return false; - $diff[$key] = $value; - continue; } // If the key is a routed key, its not different yet. @@ -310,17 +325,11 @@ class CakeRoute { // keys that don't exist are different. if (!$keyExists && !empty($value)) { return false; - $diff[$key] = $value; } } //if a not a greedy route, no extra params are allowed. - if (!$this->_greedy && ( (!empty($pass) || !empty($named)) || array_diff_key($diff, $keyNames) != array()) ) { - return false; - } - - //still some left over parameters that weren't named or passed args, bail. - if (!empty($diff)) { + if (!$this->_greedy && (!empty($pass) || !empty($named))) { return false; } @@ -332,7 +341,7 @@ class CakeRoute { } } } - return $this->_writeUrl(array_merge($url, compact('pass', 'named'))); + return $this->_writeUrl(array_merge($url, compact('pass', 'named', '_query'))); } /** @@ -385,7 +394,27 @@ class CakeRoute { if (strpos($this->template, '*')) { $out = str_replace('*', $params['pass'], $out); } + if (!empty($params['_query'])) { + $out .= $this->queryString($params['_query']); + } $out = str_replace('//', '/', $out); return $out; } + +/** + * Generates a well-formed querystring from $q + * + * Will compose an array or nested array into a proper querystring. + * + * @param mixed $q An array of parameters to compose into a query string. + * @param bool $escape Whether or not to use escaped & + * @return string + */ + public function queryString($q, $escape = false) { + $join = '&'; + if ($escape === true) { + $join = '&'; + } + return '?' . http_build_query($q, null, $join); + } } \ No newline at end of file diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index 279e305f1..5e6860fba 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -472,4 +472,28 @@ class CakeRouteTestCase extends CakeTestCase { $result = $route->parse('/blog/foobar'); $this->assertFalse($result); } + +/** + * test sigil based query string params + * + * @return void + */ + function testQueryStringParams() { + $route = new CakeRoute('/:controller/:action/*'); + $result = $route->match(array('controller' => 'posts', 'action' => 'index', '?test' => 'value')); + $expected = '/posts/index/?test=value'; + $this->assertEquals($expected, $result); + + $result = $route->match(array( + 'controller' => 'posts', 'action' => 'index', '?test' => array(1, 2, 3) + )); + $expected = '/posts/index/?test%5B0%5D=1&test%5B1%5D=2&test%5B2%5D=3'; + $this->assertEquals($expected, $result); + + $result = $route->match(array( + 'controller' => 'posts', 'action' => 'index', '?test' => 'value', '?other' => 'value' + )); + $expected = '/posts/index/?test=value&other=value'; + $this->assertEquals($expected, $result); + } } \ No newline at end of file From 319e622151669ad2bfe0f6ec27629bd21073229c Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 16:51:54 -0500 Subject: [PATCH 304/378] Added another test for querystring params. Querystring params should not be affected by greedy routes, as they are not really controlled by internal routing. --- cake/tests/cases/libs/route/cake_route.test.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index 5e6860fba..3107e0084 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -496,4 +496,16 @@ class CakeRouteTestCase extends CakeTestCase { $expected = '/posts/index/?test=value&other=value'; $this->assertEquals($expected, $result); } + +/** + * test that querystring params work with non greedy routes. + * + * @return void + */ + function testQueryStringNonGreedy() { + $route = new CakeRoute('/:controller/:action'); + $result = $route->match(array('controller' => 'posts', 'action' => 'index', '?test' => 'value')); + $expected = '/posts/index?test=value'; + $this->assertEquals($expected, $result); + } } \ No newline at end of file From 7c6af5bfec02caa636f5722890f22ff501dac64b Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 17:01:26 -0500 Subject: [PATCH 305/378] Making a test actually test what its supposed to. --- cake/tests/cases/libs/router.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 6d2f700f6..e05e50149 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1350,7 +1350,7 @@ class RouterTest extends CakeTestCase { Router::reload(); Router::connect('/:controller/:action/*'); Router::connectNamed(array('page'), array('default' => false, 'greedy' => false)); - $result = Router::parse('/categories/index?limit=5'); + $result = Router::parse('/categories/index/limit=5'); $this->assertTrue(empty($result['named'])); } From a6cca7c03613dd007ccf8f21c36af1b63f7cd2df Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 17:09:30 -0500 Subject: [PATCH 306/378] Extracting a method from paginator component. --- cake/libs/controller/components/paginator.php | 83 +++++++++++-------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index 9bf89f991..4a0bd2ffc 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -64,42 +64,7 @@ class PaginatorComponent extends Component { } $assoc = null; - if (is_string($object)) { - $assoc = null; - if (strpos($object, '.') !== false) { - list($object, $assoc) = pluginSplit($object); - } - - if ($assoc && isset($this->Controller->{$object}->{$assoc})) { - $object = $this->Controller->{$object}->{$assoc}; - } elseif ( - $assoc && isset($this->Controller->{$this->Controller->modelClass}) && - isset($this->Controller->{$this->Controller->modelClass}->{$assoc} - )) { - $object = $this->Controller->{$this->Controller->modelClass}->{$assoc}; - } elseif (isset($this->Controller->{$object})) { - $object = $this->Controller->{$object}; - } elseif ( - isset($this->Controller->{$this->Controller->modelClass}) && isset($this->Controller->{$this->Controller->modelClass}->{$object} - )) { - $object = $this->Controller->{$this->Controller->modelClass}->{$object}; - } - } elseif (empty($object) || $object === null) { - if (isset($this->Controller->{$this->Controller->modelClass})) { - $object = $this->Controller->{$this->Controller->modelClass}; - } else { - $className = null; - $name = $this->Controller->uses[0]; - if (strpos($this->Controller->uses[0], '.') !== false) { - list($name, $className) = explode('.', $this->Controller->uses[0]); - } - if ($className) { - $object = $this->Controller->{$className}; - } else { - $object = $this->Controller->{$name}; - } - } - } + $object = $this->_getObject($object); if (!is_object($object)) { throw new MissingModelException($object); @@ -252,4 +217,50 @@ class PaginatorComponent extends Component { } return $results; } + +/** + * Get the object pagination will occur on. + * + * @param mixed $object The object you are looking for. + * @return mixed The model object to paginate on. + */ + protected function _getObject($object) { + if (is_string($object)) { + $assoc = null; + if (strpos($object, '.') !== false) { + list($object, $assoc) = pluginSplit($object); + } + + if ($assoc && isset($this->Controller->{$object}->{$assoc})) { + $object = $this->Controller->{$object}->{$assoc}; + } elseif ( + $assoc && isset($this->Controller->{$this->Controller->modelClass}) && + isset($this->Controller->{$this->Controller->modelClass}->{$assoc} + )) { + $object = $this->Controller->{$this->Controller->modelClass}->{$assoc}; + } elseif (isset($this->Controller->{$object})) { + $object = $this->Controller->{$object}; + } elseif ( + isset($this->Controller->{$this->Controller->modelClass}) && isset($this->Controller->{$this->Controller->modelClass}->{$object} + )) { + $object = $this->Controller->{$this->Controller->modelClass}->{$object}; + } + } elseif (empty($object) || $object === null) { + if (isset($this->Controller->{$this->Controller->modelClass})) { + $object = $this->Controller->{$this->Controller->modelClass}; + } else { + $className = null; + $name = $this->Controller->uses[0]; + if (strpos($this->Controller->uses[0], '.') !== false) { + list($name, $className) = explode('.', $this->Controller->uses[0]); + } + if ($className) { + $object = $this->Controller->{$className}; + } else { + $object = $this->Controller->{$name}; + } + } + } + return $object; + } } \ No newline at end of file From 6b9d9f4aea1f542eda766ea6bb68520739bfdaaf Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 17:17:43 -0500 Subject: [PATCH 307/378] Reapplying changes in [33d2f9a6ed7adfee0aedd0fd20d9f31368ef1836] as they got lost when the paginator component was extracted. --- cake/libs/controller/components/paginator.php | 5 ++- .../controller/components/paginator.test.php | 39 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index 4a0bd2ffc..26e36b367 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -43,7 +43,7 @@ class PaginatorComponent extends Component { * @param array $settings Array of configuration settings. */ public function __construct(ComponentCollection $collection, $settings = array()) { - $settings = array_merge(array('page' => 1, 'limit' => 20), (array)$settings); + $settings = array_merge(array('page' => 1, 'limit' => 20, 'maxLimit' => 100), (array)$settings); $this->Controller = $collection->getController(); parent::__construct($collection, $settings); } @@ -146,6 +146,7 @@ class PaginatorComponent extends Component { if (empty($options['limit']) || $options['limit'] < 1) { $options['limit'] = 1; } + $options['limit'] = min((int)$options['limit'], $options['maxLimit']); extract($options); @@ -181,7 +182,7 @@ class PaginatorComponent extends Component { } elseif (intval($page) < 1) { $options['page'] = $page = 1; } - $page = $options['page'] = (integer)$page; + $page = $options['page'] = (int)$page; if (method_exists($object, 'paginate')) { $results = $object->paginate( diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index 20abfd8da..82efa4b02 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -486,4 +486,43 @@ class PaginatorTest extends CakeTestCase { $Controller->constructClasses(); $Controller->Paginator->paginate('MissingModel'); } + +/** + * testPaginateMaxLimit + * + * @return void + * @access public + */ + function testPaginateMaxLimit() { + $request = new CakeRequest('controller_posts/index'); + $request->params['pass'] = $request->params['named'] = array(); + + $Controller = new Controller($request); + + $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->passedArgs[] = '1'; + $Controller->params['url'] = array(); + $Controller->constructClasses(); + + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000'); + $result = $Controller->paginate('ControllerPost'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 100); + + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000', 'maxLimit' => 1000); + $result = $Controller->paginate('ControllerPost'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 100); + + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '10'); + $result = $Controller->paginate('ControllerPost'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 10); + + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000'); + $Controller->paginate = array('maxLimit' => 2000); + $result = $Controller->paginate('ControllerPost'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 1000); + + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '5000'); + $result = $Controller->paginate('ControllerPost'); + $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 2000); + } } \ No newline at end of file From 54c52d85fb559fb25dfa25c6864b0f4eb0d4e0cf Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 17:28:28 -0500 Subject: [PATCH 308/378] Fixing failing tests in PaginatorComponent. --- cake/libs/controller/components/paginator.php | 2 +- .../controller/components/paginator.test.php | 92 ++++++++++++------- 2 files changed, 58 insertions(+), 36 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index 26e36b367..1dcd23bb5 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -141,7 +141,7 @@ class PaginatorComponent extends Component { unset($defaults[0]); } - $options = array_merge(array('page' => 1, 'limit' => 20), $defaults, $options); + $options = array_merge(array('page' => 1, 'limit' => 20, 'maxLimit' => 100), $defaults, $options); $options['limit'] = (int) $options['limit']; if (empty($options['limit']) || $options['limit'] < 1) { $options['limit'] = 1; diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index 82efa4b02..4efa5e785 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -269,13 +269,13 @@ class PaginatorTest extends CakeTestCase { $this->assertEqual($results, array(1, 3, 2)); $Controller->passedArgs = array('page' => '1 " onclick="alert(\'xss\');">'); - $Controller->Paginator->settings = array('limit' => 1); + $Controller->Paginator->settings = array('limit' => 1, 'maxLimit' => 10); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1, 'XSS exploit opened %s'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['options']['page'], 1, 'XSS exploit opened %s'); $Controller->passedArgs = array(); - $Controller->Paginator->settings = array('limit' => 0); + $Controller->Paginator->settings = array('limit' => 0, 'maxLimit' => 10); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3); @@ -283,7 +283,7 @@ class PaginatorTest extends CakeTestCase { $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true); $Controller->passedArgs = array(); - $Controller->Paginator->settings = array('limit' => 'garbage!'); + $Controller->Paginator->settings = array('limit' => 'garbage!', 'maxLimit' => 10); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3); @@ -291,7 +291,7 @@ class PaginatorTest extends CakeTestCase { $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true); $Controller->passedArgs = array(); - $Controller->Paginator->settings = array('limit' => '-1'); + $Controller->Paginator->settings = array('limit' => '-1', 'maxLimit' => 10); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3); @@ -323,19 +323,23 @@ class PaginatorTest extends CakeTestCase { $this->assertTrue(!isset($Controller->PaginatorControllerPost->lastQuery['contain'])); $Controller->passedArgs = array('page' => '-1'); - $Controller->Paginator->settings = array('PaginatorControllerPost' => array('contain' => array('PaginatorControllerComment'))); + $Controller->Paginator->settings = array( + 'PaginatorControllerPost' => array('contain' => array('PaginatorControllerComment'), 'maxLimit' => 10), + ); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.id'), array(1, 2, 3)); $this->assertTrue(isset($Controller->PaginatorControllerPost->lastQuery['contain'])); - $Controller->Paginator->settings = array('PaginatorControllerPost' => array('popular', 'fields' => array('id', 'title'))); + $Controller->Paginator->settings = array( + 'PaginatorControllerPost' => array('popular', 'fields' => array('id', 'title'), 'maxLimit' => 10), + ); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.id'), array(2, 3)); $this->assertEqual($Controller->PaginatorControllerPost->lastQuery['conditions'], array('PaginatorControllerPost.id > ' => '1')); $Controller->passedArgs = array('limit' => 12); - $Controller->Paginator->settings = array('limit' => 30); + $Controller->Paginator->settings = array('limit' => 30, 'maxLimit' => 100); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $paging = $Controller->params['paging']['PaginatorControllerPost']; @@ -347,18 +351,31 @@ class PaginatorTest extends CakeTestCase { $Controller->params['url'] = array(); $Controller->constructClasses(); $Controller->Paginator->settings = array( - 'ControllerPaginateModel' => array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id') + 'ControllerPaginateModel' => array( + 'contain' => array('ControllerPaginateModel'), + 'group' => 'Comment.author_id', + 'maxLimit' => 10 + ) ); $result = $Controller->Paginator->paginate('ControllerPaginateModel'); - $expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id'); + $expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id', 'maxLimit' => 10); $this->assertEqual($Controller->ControllerPaginateModel->extra, $expected); $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); $Controller->Paginator->settings = array( - 'ControllerPaginateModel' => array('foo', 'contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id') + 'ControllerPaginateModel' => array( + 'foo', 'contain' => array('ControllerPaginateModel'), + 'group' => 'Comment.author_id', + 'maxLimit' => 10 + ) ); $Controller->Paginator->paginate('ControllerPaginateModel'); - $expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id', 'type' => 'foo'); + $expected = array( + 'contain' => array('ControllerPaginateModel'), + 'group' => 'Comment.author_id', + 'type' => 'foo', + 'maxLimit' => 10 + ); $this->assertEqual($Controller->ControllerPaginateModel->extra, $expected); $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); } @@ -383,15 +400,17 @@ class PaginatorTest extends CakeTestCase { 'order' => '', 'limit' => 5, 'page' => 1, - 'recursive' => -1 + 'recursive' => -1, + 'maxLimit' => 10 ); $conditions = array(); - $Controller->Paginator->paginate('PaginatorControllerPost',$conditions); + $Controller->Paginator->paginate('PaginatorControllerPost', $conditions); $expected = array( 'fields' => array(), 'order' => '', 'limit' => 5, + 'maxLimit' => 10, 'page' => 1, 'recursive' => -1, 'conditions' => array() @@ -414,7 +433,9 @@ class PaginatorTest extends CakeTestCase { $Controller->params['url'] = array(); $Controller->constructClasses(); - $Controller->Paginator->settings = array('PaginatorControllerPost' => array('popular', 'fields' => array('id', 'title'))); + $Controller->Paginator->settings = array( + 'PaginatorControllerPost' => array('popular', 'fields' => array('id', 'title'), 'maxLimit' => 10) + ); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.id'), array(2, 3)); @@ -437,7 +458,7 @@ class PaginatorTest extends CakeTestCase { $Controller->modelClass = 'PaginatorControllerPost'; $Controller->params['url'] = array(); $Controller->constructClasses(); - $Controller->Paginator->settings = array('order' => 'PaginatorControllerPost.id DESC'); + $Controller->Paginator->settings = array('order' => 'PaginatorControllerPost.id DESC', 'maxLimit' => 10); $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['defaults']['order'], 'PaginatorControllerPost.id DESC'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['order'], 'PaginatorControllerPost.id DESC'); @@ -463,7 +484,8 @@ class PaginatorTest extends CakeTestCase { $Controller->Paginator->settings = array( 'fields' => array('id', 'title', 'offset_test'), - 'order' => array('offset_test' => 'DESC') + 'order' => array('offset_test' => 'DESC'), + 'maxLimit' => 10 ); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.offset_test'), array(4, 3, 2)); @@ -484,7 +506,7 @@ class PaginatorTest extends CakeTestCase { $Controller = new PaginatorTestController($request); $Controller->constructClasses(); - $Controller->Paginator->paginate('MissingModel'); + $Controller->Paginator->paginate('MissingModel'); } /** @@ -496,33 +518,33 @@ class PaginatorTest extends CakeTestCase { function testPaginateMaxLimit() { $request = new CakeRequest('controller_posts/index'); $request->params['pass'] = $request->params['named'] = array(); - + $Controller = new Controller($request); - - $Controller->uses = array('ControllerPost', 'ControllerComment'); + + $Controller->uses = array('PaginatorControllerPost', 'ControllerComment'); $Controller->passedArgs[] = '1'; $Controller->params['url'] = array(); $Controller->constructClasses(); - + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000'); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 100); - + $result = $Controller->paginate('PaginatorControllerPost'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 100); + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000', 'maxLimit' => 1000); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 100); - + $result = $Controller->paginate('PaginatorControllerPost'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 100); + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '10'); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 10); - + $result = $Controller->paginate('PaginatorControllerPost'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 10); + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000'); $Controller->paginate = array('maxLimit' => 2000); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 1000); - + $result = $Controller->paginate('PaginatorControllerPost'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 1000); + $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '5000'); - $result = $Controller->paginate('ControllerPost'); - $this->assertEqual($Controller->params['paging']['ControllerPost']['options']['limit'], 2000); + $result = $Controller->paginate('PaginatorControllerPost'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 2000); } } \ No newline at end of file From 7585b2941efb44b2dc47333b46ab9ede18ec7755 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 00:38:20 -0500 Subject: [PATCH 309/378] Adding paramType to the test cases. --- cake/libs/controller/components/paginator.php | 23 ++++++-- .../controller/components/paginator.test.php | 55 +++++++++++++------ 2 files changed, 57 insertions(+), 21 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index 1dcd23bb5..554e58d99 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -30,11 +30,25 @@ class PaginatorComponent extends Component { /** - * Pagination settings + * Pagination settings. These settings control pagination at a general level. + * You can also define sub arrays for pagination settings for specific models. + * + * - `maxLimit` The maximum limit users can choose to view. Defaults to 100 + * - `limit` The initial number of items per page. Defaults to 20. + * - `page` The starting page, defaults to 1. + * - `paramType` What type of parameters you want pagination to use? + * - `named` Use named parameters. + * - `querystring` Use query string parameters. + * - `route` Use routed parameters, these require you to setup routes that include the pagination params * * @var array */ - public $settings = array(); + public $settings = array( + 'page' => 1, + 'limit' => 20, + 'maxLimit' => 100, + 'paramType' => 'named' + ); /** * Constructor @@ -43,7 +57,7 @@ class PaginatorComponent extends Component { * @param array $settings Array of configuration settings. */ public function __construct(ComponentCollection $collection, $settings = array()) { - $settings = array_merge(array('page' => 1, 'limit' => 20, 'maxLimit' => 100), (array)$settings); + $settings = array_merge($this->settings, (array)$settings); $this->Controller = $collection->getController(); parent::__construct($collection, $settings); } @@ -203,7 +217,8 @@ class PaginatorComponent extends Component { 'nextPage' => ($count > ($page * $limit)), 'pageCount' => $pageCount, 'defaults' => array_merge(array('limit' => 20, 'step' => 1), $defaults), - 'options' => $options + 'options' => $options, + 'paramType' => $options['paramType'] ); if (!isset($this->Controller->request['paging'])) { $this->Controller->request['paging'] = array(); diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index 4efa5e785..096c523c5 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -269,13 +269,13 @@ class PaginatorTest extends CakeTestCase { $this->assertEqual($results, array(1, 3, 2)); $Controller->passedArgs = array('page' => '1 " onclick="alert(\'xss\');">'); - $Controller->Paginator->settings = array('limit' => 1, 'maxLimit' => 10); + $Controller->Paginator->settings = array('limit' => 1, 'maxLimit' => 10, 'paramType' => 'named'); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1, 'XSS exploit opened %s'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['options']['page'], 1, 'XSS exploit opened %s'); $Controller->passedArgs = array(); - $Controller->Paginator->settings = array('limit' => 0, 'maxLimit' => 10); + $Controller->Paginator->settings = array('limit' => 0, 'maxLimit' => 10, 'paramType' => 'named'); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3); @@ -283,7 +283,7 @@ class PaginatorTest extends CakeTestCase { $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true); $Controller->passedArgs = array(); - $Controller->Paginator->settings = array('limit' => 'garbage!', 'maxLimit' => 10); + $Controller->Paginator->settings = array('limit' => 'garbage!', 'maxLimit' => 10, 'paramType' => 'named'); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3); @@ -291,7 +291,7 @@ class PaginatorTest extends CakeTestCase { $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true); $Controller->passedArgs = array(); - $Controller->Paginator->settings = array('limit' => '-1', 'maxLimit' => 10); + $Controller->Paginator->settings = array('limit' => '-1', 'maxLimit' => 10, 'paramType' => 'named'); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3); @@ -324,7 +324,11 @@ class PaginatorTest extends CakeTestCase { $Controller->passedArgs = array('page' => '-1'); $Controller->Paginator->settings = array( - 'PaginatorControllerPost' => array('contain' => array('PaginatorControllerComment'), 'maxLimit' => 10), + 'PaginatorControllerPost' => array( + 'contain' => array('PaginatorControllerComment'), + 'maxLimit' => 10, + 'paramType' => 'named' + ), ); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); @@ -332,14 +336,16 @@ class PaginatorTest extends CakeTestCase { $this->assertTrue(isset($Controller->PaginatorControllerPost->lastQuery['contain'])); $Controller->Paginator->settings = array( - 'PaginatorControllerPost' => array('popular', 'fields' => array('id', 'title'), 'maxLimit' => 10), + 'PaginatorControllerPost' => array( + 'popular', 'fields' => array('id', 'title'), 'maxLimit' => 10, 'paramType' => 'named' + ), ); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.id'), array(2, 3)); $this->assertEqual($Controller->PaginatorControllerPost->lastQuery['conditions'], array('PaginatorControllerPost.id > ' => '1')); $Controller->passedArgs = array('limit' => 12); - $Controller->Paginator->settings = array('limit' => 30, 'maxLimit' => 100); + $Controller->Paginator->settings = array('limit' => 30, 'maxLimit' => 100, 'paramType' => 'named'); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $paging = $Controller->params['paging']['PaginatorControllerPost']; @@ -354,11 +360,17 @@ class PaginatorTest extends CakeTestCase { 'ControllerPaginateModel' => array( 'contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id', - 'maxLimit' => 10 + 'maxLimit' => 10, + 'paramType' => 'named' ) ); $result = $Controller->Paginator->paginate('ControllerPaginateModel'); - $expected = array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id', 'maxLimit' => 10); + $expected = array( + 'contain' => array('ControllerPaginateModel'), + 'group' => 'Comment.author_id', + 'maxLimit' => 10, + 'paramType' => 'named' + ); $this->assertEqual($Controller->ControllerPaginateModel->extra, $expected); $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); @@ -366,7 +378,8 @@ class PaginatorTest extends CakeTestCase { 'ControllerPaginateModel' => array( 'foo', 'contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id', - 'maxLimit' => 10 + 'maxLimit' => 10, + 'paramType' => 'named' ) ); $Controller->Paginator->paginate('ControllerPaginateModel'); @@ -374,7 +387,8 @@ class PaginatorTest extends CakeTestCase { 'contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id', 'type' => 'foo', - 'maxLimit' => 10 + 'maxLimit' => 10, + 'paramType' => 'named' ); $this->assertEqual($Controller->ControllerPaginateModel->extra, $expected); $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); @@ -401,7 +415,8 @@ class PaginatorTest extends CakeTestCase { 'limit' => 5, 'page' => 1, 'recursive' => -1, - 'maxLimit' => 10 + 'maxLimit' => 10, + 'paramType' => 'named' ); $conditions = array(); $Controller->Paginator->paginate('PaginatorControllerPost', $conditions); @@ -413,7 +428,8 @@ class PaginatorTest extends CakeTestCase { 'maxLimit' => 10, 'page' => 1, 'recursive' => -1, - 'conditions' => array() + 'conditions' => array(), + 'paramType' => 'named' ); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options'],$expected); } @@ -434,7 +450,9 @@ class PaginatorTest extends CakeTestCase { $Controller->constructClasses(); $Controller->Paginator->settings = array( - 'PaginatorControllerPost' => array('popular', 'fields' => array('id', 'title'), 'maxLimit' => 10) + 'PaginatorControllerPost' => array( + 'popular', 'fields' => array('id', 'title'), 'maxLimit' => 10, 'paramType' => 'named' + ) ); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); @@ -458,7 +476,9 @@ class PaginatorTest extends CakeTestCase { $Controller->modelClass = 'PaginatorControllerPost'; $Controller->params['url'] = array(); $Controller->constructClasses(); - $Controller->Paginator->settings = array('order' => 'PaginatorControllerPost.id DESC', 'maxLimit' => 10); + $Controller->Paginator->settings = array( + 'order' => 'PaginatorControllerPost.id DESC', 'maxLimit' => 10, 'paramType' => 'named' + ); $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['defaults']['order'], 'PaginatorControllerPost.id DESC'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['order'], 'PaginatorControllerPost.id DESC'); @@ -485,7 +505,8 @@ class PaginatorTest extends CakeTestCase { $Controller->Paginator->settings = array( 'fields' => array('id', 'title', 'offset_test'), 'order' => array('offset_test' => 'DESC'), - 'maxLimit' => 10 + 'maxLimit' => 10, + 'paramType' => 'named' ); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.offset_test'), array(4, 3, 2)); @@ -539,7 +560,7 @@ class PaginatorTest extends CakeTestCase { $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 10); $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000'); - $Controller->paginate = array('maxLimit' => 2000); + $Controller->paginate = array('maxLimit' => 2000, 'paramType' => 'named'); $result = $Controller->paginate('PaginatorControllerPost'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 1000); From 6b3db0a3eb0ce3437b015b5ce07fc7afffc0602f Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 01:42:23 -0500 Subject: [PATCH 310/378] Pulling out parameter merging logic into a method, this allows specific typing of parameter merging (named, querystring, route). Also simplifies whitelisting of request parameters. Tests added for merging and whitelisting. --- cake/libs/controller/components/paginator.php | 59 ++++++ .../controller/components/paginator.test.php | 190 +++++++++++++++--- 2 files changed, 216 insertions(+), 33 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index 554e58d99..c0e237297 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -50,6 +50,17 @@ class PaginatorComponent extends Component { 'paramType' => 'named' ); +/** + * A list of request parameters users are allowed to set. Modifying + * this list will allow users to have more influence over pagination, + * be careful with what you permit. + * + * @var array + */ + public $whitelist = array( + 'limit', 'sort', 'page', 'direction' + ); + /** * Constructor * @@ -83,6 +94,9 @@ class PaginatorComponent extends Component { if (!is_object($object)) { throw new MissingModelException($object); } + + $options = $this->mergeOptions($object->alias, $scope, $whitelist); + $options = array_merge( $this->Controller->request->params, $this->Controller->request->query, @@ -279,4 +293,49 @@ class PaginatorComponent extends Component { } return $object; } + +/** + * Merges the various options that Pagination uses. + * Pulls settings together from the following places: + * + * - General pagination settings + * - Model specific settings. + * - Request parameters + * - $options argument. + * + * The result of this method is the aggregate of all the option sets combined together. + * + * @param string $alias Model alias being paginated, if the general settings has a key with this value + * that key's settings will be used for pagination instead of the general ones. + * @param string $options Per call options. + * @param string $whitelist A whitelist of options that are allowed from the request parameters. Modifying + * this array will allow you to permit more or less input from the user. + * @return array Array of merged options. + */ + public function mergeOptions($alias, $options, $whitelist = array()) { + if (isset($this->settings[$alias])) { + $defaults = $this->settings[$alias]; + } else { + $defaults = $this->settings; + } + if (empty($defaults['paramType'])) { + $defaults['paramType'] = 'named'; + } + switch ($defaults['paramType']) { + case 'named': + $request = $this->Controller->request->params['named']; + break; + case 'querystring': + $request = $this->Controller->request->query; + break; + case 'route': + $request = $this->Controller->request->params; + unset($request['pass'], $request['named']); + } + + $whitelist = array_flip(array_merge($this->whitelist, $whitelist)); + $request = array_intersect_key($request, $whitelist); + + return array_merge($defaults, $request, $options); + } } \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index 096c523c5..25bf12a99 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -20,6 +20,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Controller', 'Controller', false); +App::import('Component', 'Paginator'); App::import('Core', array('CakeRequest', 'CakeResponse')); /** @@ -210,6 +211,20 @@ class PaginatorTest extends CakeTestCase { */ public $fixtures = array('core.post', 'core.comment'); +/** + * setup + * + * @return void + */ + function setUp() { + parent::setUp(); + $this->request = new CakeRequest('controller_posts/index'); + $this->request->params['pass'] = $this->request->params['named'] = array(); + $this->Controller = new Controller($this->request); + $this->Paginator = new PaginatorComponent($this->getMock('ComponentCollection'), array()); + $this->Paginator->Controller = $this->Controller; + } + /** * testPaginate method * @@ -217,10 +232,7 @@ class PaginatorTest extends CakeTestCase { * @return void */ function testPaginate() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new PaginatorTestController($request); + $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); $Controller->passedArgs[] = '1'; $Controller->params['url'] = array(); @@ -306,10 +318,7 @@ class PaginatorTest extends CakeTestCase { * @return void */ function testPaginateExtraParams() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new PaginatorTestController($request); + $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); $Controller->passedArgs[] = '1'; @@ -352,7 +361,7 @@ class PaginatorTest extends CakeTestCase { $this->assertEqual($Controller->PaginatorControllerPost->lastQuery['limit'], 12); $this->assertEqual($paging['options']['limit'], 12); - $Controller = new PaginatorTestController($request); + $Controller = new PaginatorTestController($this->request); $Controller->uses = array('ControllerPaginateModel'); $Controller->params['url'] = array(); $Controller->constructClasses(); @@ -400,10 +409,7 @@ class PaginatorTest extends CakeTestCase { * @return void */ public function testPaginatePassedArgs() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new PaginatorTestController($request); + $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost'); $Controller->passedArgs[] = array('1', '2', '3'); $Controller->params['url'] = array(); @@ -440,10 +446,7 @@ class PaginatorTest extends CakeTestCase { * @return void */ function testPaginateSpecialType() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new PaginatorTestController($request); + $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); $Controller->passedArgs[] = '1'; $Controller->params['url'] = array(); @@ -469,10 +472,7 @@ class PaginatorTest extends CakeTestCase { * @return void */ function testDefaultPaginateParams() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new PaginatorTestController($request); + $Controller = new PaginatorTestController($this->request); $Controller->modelClass = 'PaginatorControllerPost'; $Controller->params['url'] = array(); $Controller->constructClasses(); @@ -491,10 +491,7 @@ class PaginatorTest extends CakeTestCase { * @return void */ function testPaginateOrderVirtualField() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new PaginatorTestController($request); + $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); $Controller->params['url'] = array(); $Controller->constructClasses(); @@ -522,10 +519,7 @@ class PaginatorTest extends CakeTestCase { * @expectedException MissingModelException */ function testPaginateMissingModel() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new PaginatorTestController($request); + $Controller = new PaginatorTestController($this->request); $Controller->constructClasses(); $Controller->Paginator->paginate('MissingModel'); } @@ -537,10 +531,7 @@ class PaginatorTest extends CakeTestCase { * @access public */ function testPaginateMaxLimit() { - $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - - $Controller = new Controller($request); + $Controller = new Controller($this->request); $Controller->uses = array('PaginatorControllerPost', 'ControllerComment'); $Controller->passedArgs[] = '1'; @@ -568,4 +559,137 @@ class PaginatorTest extends CakeTestCase { $result = $Controller->paginate('PaginatorControllerPost'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 2000); } + +/** + * test that option merging prefers specific models + * + * @return void + */ + function testMergeOptionsModelSpecific() { + $this->Paginator->settings = array( + 'page' => 1, + 'limit' => 20, + 'maxLimit' => 100, + 'paramType' => 'named', + 'Post' => array( + 'page' => 1, + 'limit' => 10, + 'maxLimit' => 50, + 'paramType' => 'named', + ) + ); + $result = $this->Paginator->mergeOptions('Silly', array()); + $this->assertEquals($this->Paginator->settings, $result); + + $result = $this->Paginator->mergeOptions('Silly', array('limit' => 10)); + $this->assertEquals(10, $result['limit']); + + $result = $this->Paginator->mergeOptions('Post', array('sort' => 'title')); + $expected = array('page' => 1, 'limit' => 10, 'paramType' => 'named', 'sort' => 'title', 'maxLimit' => 50); + $this->assertEquals($expected, $result); + } + +/** + * test mergeOptions with named params. + * + * @return void + */ + function testMergeOptionsNamedParams() { + $this->request->params['named'] = array( + 'page' => 10, + 'limit' => 10 + ); + $this->Paginator->settings = array( + 'page' => 1, + 'limit' => 20, + 'maxLimit' => 100, + 'paramType' => 'named', + ); + $result = $this->Paginator->mergeOptions('Post', array()); + $expected = array('page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named'); + $this->assertEquals($expected, $result); + + $result = $this->Paginator->mergeOptions('Post', array('page' => 100)); + $this->assertEquals(100, $result['page'], 'Passed options should replace request params'); + } + +/** + * test merging options from the querystring. + * + * @return void + */ + function testMergeOptionsQueryString() { + $this->request->params['named'] = array( + 'page' => 10, + 'limit' => 10 + ); + $this->request->query = array( + 'page' => 99, + 'limit' => 75 + ); + $this->Paginator->settings = array( + 'page' => 1, + 'limit' => 20, + 'maxLimit' => 100, + 'paramType' => 'querystring', + ); + $result = $this->Paginator->mergeOptions('Post', array()); + $expected = array('page' => 99, 'limit' => 75, 'maxLimit' => 100, 'paramType' => 'querystring'); + $this->assertEquals($expected, $result); + + $result = $this->Paginator->mergeOptions('Post', array('page' => 100)); + $this->assertEquals(100, $result['page'], 'Passed options should replace request params'); + } + +/** + * test that the default whitelist doesn't let people screw with things they should not be allowed to. + * + * @return void + */ + function testMergeOptionsDefaultWhiteList() { + $this->request->params['named'] = array( + 'page' => 10, + 'limit' => 10, + 'fields' => array('bad.stuff'), + 'recursive' => 1000, + 'conditions' => array('bad.stuff'), + 'contain' => array('bad') + ); + $this->Paginator->settings = array( + 'page' => 1, + 'limit' => 20, + 'maxLimit' => 100, + 'paramType' => 'named', + ); + $result = $this->Paginator->mergeOptions('Post', array()); + $expected = array('page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named'); + $this->assertEquals($expected, $result); + } + +/** + * test that modifying the whitelist works. + * + * @return void + */ + function testMergeOptionsExtraWhitelist() { + $this->request->params['named'] = array( + 'page' => 10, + 'limit' => 10, + 'fields' => array('bad.stuff'), + 'recursive' => 1000, + 'conditions' => array('bad.stuff'), + 'contain' => array('bad') + ); + $this->Paginator->settings = array( + 'page' => 1, + 'limit' => 20, + 'maxLimit' => 100, + 'paramType' => 'named', + ); + $result = $this->Paginator->mergeOptions('Post', array(), array('fields')); + $expected = array( + 'page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named', 'fields' => array('bad.stuff') + ); + $this->assertEquals($expected, $result); + } } \ No newline at end of file From 7b11eeb6e001a9dfaa3d41b36cf350e2cd977ccd Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 01:57:51 -0500 Subject: [PATCH 311/378] Updating tests to not use the deprecated Controller::$passedArgs. Removing messy and hard to understand defaults + whitelisting from paginate() now that it has a separate method. --- cake/libs/controller/components/paginator.php | 42 +++----------- .../controller/components/paginator.test.php | 56 ++++++++++--------- 2 files changed, 38 insertions(+), 60 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index c0e237297..bb33177e1 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -94,21 +94,9 @@ class PaginatorComponent extends Component { if (!is_object($object)) { throw new MissingModelException($object); } - + $options = $this->mergeOptions($object->alias, $scope, $whitelist); - $options = array_merge( - $this->Controller->request->params, - $this->Controller->request->query, - $this->Controller->passedArgs - ); - - if (isset($this->settings[$object->alias])) { - $defaults = $this->settings[$object->alias]; - } else { - $defaults = $this->settings; - } - if (isset($options['show'])) { $options['limit'] = $options['show']; } @@ -142,34 +130,21 @@ class PaginatorComponent extends Component { $options['order'][$alias . '.' . $field] = $value; } } - $vars = array('fields', 'order', 'limit', 'page', 'recursive'); - $keys = array_keys($options); - $count = count($keys); - for ($i = 0; $i < $count; $i++) { - if (!in_array($keys[$i], $vars, true)) { - unset($options[$keys[$i]]); - } - if (empty($whitelist) && ($keys[$i] === 'fields' || $keys[$i] === 'recursive')) { - unset($options[$keys[$i]]); - } elseif (!empty($whitelist) && !in_array($keys[$i], $whitelist)) { - unset($options[$keys[$i]]); - } - } $conditions = $fields = $order = $limit = $page = $recursive = null; - if (!isset($defaults['conditions'])) { - $defaults['conditions'] = array(); + if (!isset($options['conditions'])) { + $options['conditions'] = array(); } $type = 'all'; - if (isset($defaults[0])) { - $type = $defaults[0]; - unset($defaults[0]); + if (isset($options[0])) { + $type = $options[0]; + unset($options[0]); } - $options = array_merge(array('page' => 1, 'limit' => 20, 'maxLimit' => 100), $defaults, $options); + $options = array_merge(array('page' => 1, 'limit' => 20, 'maxLimit' => 100), $options); $options['limit'] = (int) $options['limit']; if (empty($options['limit']) || $options['limit'] < 1) { $options['limit'] = 1; @@ -187,7 +162,7 @@ class PaginatorComponent extends Component { $recursive = $object->recursive; } - $extra = array_diff_key($defaults, compact( + $extra = array_diff_key($options, compact( 'conditions', 'fields', 'order', 'limit', 'page', 'recursive' )); if ($type !== 'all') { @@ -230,7 +205,6 @@ class PaginatorComponent extends Component { 'prevPage' => ($page > 1), 'nextPage' => ($count > ($page * $limit)), 'pageCount' => $pageCount, - 'defaults' => array_merge(array('limit' => 20, 'step' => 1), $defaults), 'options' => $options, 'paramType' => $options['paramType'] ); diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index 25bf12a99..063dfaf02 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -234,8 +234,8 @@ class PaginatorTest extends CakeTestCase { function testPaginate() { $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); - $Controller->passedArgs[] = '1'; - $Controller->params['url'] = array(); + $Controller->request->params['pass'] = array('1'); + $Controller->request->query = array(); $Controller->constructClasses(); $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); @@ -250,43 +250,45 @@ class PaginatorTest extends CakeTestCase { $results = Set::extract($Controller->Paginator->paginate(), '{n}.PaginatorControllerPost.id'); $this->assertEqual($results, array(1, 2, 3)); - $Controller->passedArgs = array('page' => '-1'); + $Controller->request->params['named'] = array('page' => '-1'); $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertEqual($results, array(1, 2, 3)); - $Controller->passedArgs = array('sort' => 'PaginatorControllerPost.id', 'direction' => 'asc'); + $Controller->request->params['named'] = array('sort' => 'PaginatorControllerPost.id', 'direction' => 'asc'); $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertEqual($results, array(1, 2, 3)); - $Controller->passedArgs = array('sort' => 'PaginatorControllerPost.id', 'direction' => 'desc'); + $Controller->request->params['named'] = array('sort' => 'PaginatorControllerPost.id', 'direction' => 'desc'); $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertEqual($results, array(3, 2, 1)); - $Controller->passedArgs = array('sort' => 'id', 'direction' => 'desc'); + $Controller->request->params['named'] = array('sort' => 'id', 'direction' => 'desc'); $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertEqual($results, array(3, 2, 1)); - $Controller->passedArgs = array('sort' => 'NotExisting.field', 'direction' => 'desc'); + $Controller->request->params['named'] = array('sort' => 'NotExisting.field', 'direction' => 'desc'); $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1, 'Invalid field in query %s'); $this->assertEqual($results, array(1, 2, 3)); - $Controller->passedArgs = array('sort' => 'PaginatorControllerPost.author_id', 'direction' => 'allYourBase'); + $Controller->request->params['named'] = array( + 'sort' => 'PaginatorControllerPost.author_id', 'direction' => 'allYourBase' + ); $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEqual($Controller->PaginatorControllerPost->lastQuery['order'][0], array('PaginatorControllerPost.author_id' => 'asc')); $this->assertEqual($results, array(1, 3, 2)); - $Controller->passedArgs = array('page' => '1 " onclick="alert(\'xss\');">'); + $Controller->request->params['named'] = array('page' => '1 " onclick="alert(\'xss\');">'); $Controller->Paginator->settings = array('limit' => 1, 'maxLimit' => 10, 'paramType' => 'named'); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1, 'XSS exploit opened %s'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['options']['page'], 1, 'XSS exploit opened %s'); - $Controller->passedArgs = array(); + $Controller->request->params['named'] = array(); $Controller->Paginator->settings = array('limit' => 0, 'maxLimit' => 10, 'paramType' => 'named'); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); @@ -294,7 +296,7 @@ class PaginatorTest extends CakeTestCase { $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['prevPage'], false); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true); - $Controller->passedArgs = array(); + $Controller->request->params['named'] = array(); $Controller->Paginator->settings = array('limit' => 'garbage!', 'maxLimit' => 10, 'paramType' => 'named'); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); @@ -302,7 +304,7 @@ class PaginatorTest extends CakeTestCase { $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['prevPage'], false); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true); - $Controller->passedArgs = array(); + $Controller->request->params['named'] = array(); $Controller->Paginator->settings = array('limit' => '-1', 'maxLimit' => 10, 'paramType' => 'named'); $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); @@ -321,17 +323,17 @@ class PaginatorTest extends CakeTestCase { $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); - $Controller->passedArgs[] = '1'; + $Controller->request->params['pass'] = array('1'); $Controller->params['url'] = array(); $Controller->constructClasses(); - $Controller->passedArgs = array('page' => '-1', 'contain' => array('PaginatorControllerComment')); + $Controller->request->params['named'] = array('page' => '-1', 'contain' => array('PaginatorControllerComment')); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.id'), array(1, 2, 3)); $this->assertTrue(!isset($Controller->PaginatorControllerPost->lastQuery['contain'])); - $Controller->passedArgs = array('page' => '-1'); + $Controller->request->params['named'] = array('page' => '-1'); $Controller->Paginator->settings = array( 'PaginatorControllerPost' => array( 'contain' => array('PaginatorControllerComment'), @@ -353,7 +355,7 @@ class PaginatorTest extends CakeTestCase { $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.id'), array(2, 3)); $this->assertEqual($Controller->PaginatorControllerPost->lastQuery['conditions'], array('PaginatorControllerPost.id > ' => '1')); - $Controller->passedArgs = array('limit' => 12); + $Controller->request->params['named'] = array('limit' => 12); $Controller->Paginator->settings = array('limit' => 30, 'maxLimit' => 100, 'paramType' => 'named'); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $paging = $Controller->params['paging']['PaginatorControllerPost']; @@ -363,7 +365,7 @@ class PaginatorTest extends CakeTestCase { $Controller = new PaginatorTestController($this->request); $Controller->uses = array('ControllerPaginateModel'); - $Controller->params['url'] = array(); + $Controller->request->query = array(); $Controller->constructClasses(); $Controller->Paginator->settings = array( 'ControllerPaginateModel' => array( @@ -411,7 +413,7 @@ class PaginatorTest extends CakeTestCase { public function testPaginatePassedArgs() { $Controller = new PaginatorTestController($this->request); $Controller->uses = array('PaginatorControllerPost'); - $Controller->passedArgs[] = array('1', '2', '3'); + $Controller->request->params['pass'] = array('1', '2', '3'); $Controller->params['url'] = array(); $Controller->constructClasses(); @@ -461,7 +463,6 @@ class PaginatorTest extends CakeTestCase { $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.id'), array(2, 3)); $this->assertEqual($Controller->PaginatorControllerPost->lastQuery['conditions'], array('PaginatorControllerPost.id > ' => '1')); - $this->assertFalse(isset($Controller->params['paging']['PaginatorControllerPost']['defaults'][0])); $this->assertFalse(isset($Controller->params['paging']['PaginatorControllerPost']['options'][0])); } @@ -480,7 +481,6 @@ class PaginatorTest extends CakeTestCase { 'order' => 'PaginatorControllerPost.id DESC', 'maxLimit' => 10, 'paramType' => 'named' ); $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); - $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['defaults']['order'], 'PaginatorControllerPost.id DESC'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['order'], 'PaginatorControllerPost.id DESC'); $this->assertEqual($results, array(3, 2, 1)); } @@ -508,7 +508,7 @@ class PaginatorTest extends CakeTestCase { $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.offset_test'), array(4, 3, 2)); - $Controller->passedArgs = array('sort' => 'offset_test', 'direction' => 'asc'); + $Controller->request->params['named'] = array('sort' => 'offset_test', 'direction' => 'asc'); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.offset_test'), array(2, 3, 4)); } @@ -538,24 +538,28 @@ class PaginatorTest extends CakeTestCase { $Controller->params['url'] = array(); $Controller->constructClasses(); - $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000'); + $Controller->request->params['named'] = array( + 'contain' => array('ControllerComment'), 'limit' => '1000' + ); $result = $Controller->paginate('PaginatorControllerPost'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 100); - $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000', 'maxLimit' => 1000); + $Controller->request->params['named'] = array( + 'contain' => array('ControllerComment'), 'limit' => '1000', 'maxLimit' => 1000 + ); $result = $Controller->paginate('PaginatorControllerPost'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 100); - $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '10'); + $Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '10'); $result = $Controller->paginate('PaginatorControllerPost'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 10); - $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '1000'); + $Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '1000'); $Controller->paginate = array('maxLimit' => 2000, 'paramType' => 'named'); $result = $Controller->paginate('PaginatorControllerPost'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 1000); - $Controller->passedArgs = array('contain' => array('ControllerComment'), 'limit' => '5000'); + $Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '5000'); $result = $Controller->paginate('PaginatorControllerPost'); $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 2000); } From 108a6611a8f7945f491952060e9c1c9152ee066d Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 02:11:39 -0500 Subject: [PATCH 312/378] Moving validation of sorting to a separate method. This makes it easier to test, extends and read. Tests added. --- cake/libs/controller/components/paginator.php | 76 +++++++++++-------- .../controller/components/paginator.test.php | 41 ++++++++++ 2 files changed, 86 insertions(+), 31 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index bb33177e1..9755d47f2 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -95,41 +95,12 @@ class PaginatorComponent extends Component { throw new MissingModelException($object); } - $options = $this->mergeOptions($object->alias, $scope, $whitelist); - if (isset($options['show'])) { $options['limit'] = $options['show']; } - if (isset($options['sort'])) { - $direction = null; - if (isset($options['direction'])) { - $direction = strtolower($options['direction']); - } - if ($direction != 'asc' && $direction != 'desc') { - $direction = 'asc'; - } - $options['order'] = array($options['sort'] => $direction); - } - - if (!empty($options['order']) && is_array($options['order'])) { - $alias = $object->alias ; - $key = $field = key($options['order']); - - if (strpos($key, '.') !== false) { - list($alias, $field) = explode('.', $key); - } - $value = $options['order'][$key]; - unset($options['order'][$key]); - - if ($object->hasField($field)) { - $options['order'][$alias . '.' . $field] = $value; - } elseif ($object->hasField($field, true)) { - $options['order'][$field] = $value; - } elseif (isset($object->{$alias}) && $object->{$alias}->hasField($field)) { - $options['order'][$alias . '.' . $field] = $value; - } - } + $options = $this->mergeOptions($object->alias, $scope, $whitelist); + $options = $this->validateSort($object, $options); $conditions = $fields = $order = $limit = $page = $recursive = null; @@ -312,4 +283,47 @@ class PaginatorComponent extends Component { return array_merge($defaults, $request, $options); } + +/** + * Validate that the desired sorting can be performed on the $object. Only fields or + * virtualFields can be sorted on. The direction param will also be sanitized. Lastly + * sort + direction keys will be converted into the model friendly order key. + * + * @param Model $object The model being paginated. + * @param array $options The pagination options being used for this request. + * @return array An array of options with sort + direction removed and replaced with order if possible. + */ + public function validateSort($object, $options) { + if (isset($options['sort'])) { + $direction = null; + if (isset($options['direction'])) { + $direction = strtolower($options['direction']); + } + if ($direction != 'asc' && $direction != 'desc') { + $direction = 'asc'; + } + $options['order'] = array($options['sort'] => $direction); + } + + if (!empty($options['order']) && is_array($options['order'])) { + $alias = $object->alias ; + $key = $field = key($options['order']); + + if (strpos($key, '.') !== false) { + list($alias, $field) = explode('.', $key); + } + $value = $options['order'][$key]; + unset($options['order'][$key]); + + if ($object->hasField($field)) { + $options['order'][$alias . '.' . $field] = $value; + } elseif ($object->hasField($field, true)) { + $options['order'][$field] = $value; + } elseif (isset($object->{$alias}) && $object->{$alias}->hasField($field)) { + $options['order'][$alias . '.' . $field] = $value; + } + } + + return $options; + } } \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index 063dfaf02..9fb22993e 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -696,4 +696,45 @@ class PaginatorTest extends CakeTestCase { ); $this->assertEquals($expected, $result); } + +/** + * test that invalid directions are ignored. + * + * @return void + */ + function testValidateSortInvalidDirection() { + $model = $this->getMock('Model'); + $model->alias = 'model'; + $model->expects($this->any())->method('hasField')->will($this->returnValue(true)); + + $options = array('sort' => 'something', 'direction' => 'boogers'); + $result = $this->Paginator->validateSort($model, $options); + + $this->assertEquals('asc', $result['order']['model.something']); + } + +/** + * test that virtual fields work. + * + * @return void + */ + function testValidateSortVirtualField() { + $model = $this->getMock('Model'); + $model->alias = 'model'; + + $model->expects($this->at(0)) + ->method('hasField') + ->with('something') + ->will($this->returnValue(false)); + + $model->expects($this->at(1)) + ->method('hasField') + ->with('something', true) + ->will($this->returnValue(true)); + + $options = array('sort' => 'something', 'direction' => 'desc'); + $result = $this->Paginator->validateSort($model, $options); + + $this->assertEquals('desc', $result['order']['something']); + } } \ No newline at end of file From 1e741de84bbb822bd131f459c5cbe5651987b967 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 02:14:37 -0500 Subject: [PATCH 313/378] Removing show alias, it was undocumented and untested. --- cake/libs/controller/components/paginator.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index 9755d47f2..847ea3ead 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -95,10 +95,6 @@ class PaginatorComponent extends Component { throw new MissingModelException($object); } - if (isset($options['show'])) { - $options['limit'] = $options['show']; - } - $options = $this->mergeOptions($object->alias, $scope, $whitelist); $options = $this->validateSort($object, $options); From e9d3fcf5cfe6fc1b3e40c5041e92e4ca8c2f7516 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 02:28:38 -0500 Subject: [PATCH 314/378] Moving limit checking into a separate method, and adding tests. Removing $scope from being passed down to the options, it previously only allowed additional conditions to be set. Updated tests. --- cake/libs/controller/components/paginator.php | 40 ++++++++++------- .../controller/components/paginator.test.php | 45 ++++++++++++------- 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index 847ea3ead..5d05a1a9e 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -77,7 +77,7 @@ class PaginatorComponent extends Component { * Handles automatic pagination of model records. * * @param mixed $object Model to paginate (e.g: model instance, or 'Model', or 'Model.InnerModel') - * @param mixed $scope Conditions to use while paginating + * @param mixed $scope Additional find conditions to use while paginating * @param array $whitelist List of allowed options for paging * @return array Model query results */ @@ -87,7 +87,6 @@ class PaginatorComponent extends Component { $scope = $object; $object = null; } - $assoc = null; $object = $this->_getObject($object); @@ -95,8 +94,9 @@ class PaginatorComponent extends Component { throw new MissingModelException($object); } - $options = $this->mergeOptions($object->alias, $scope, $whitelist); + $options = $this->mergeOptions($object->alias, $whitelist); $options = $this->validateSort($object, $options); + $options = $this->checkLimit($options); $conditions = $fields = $order = $limit = $page = $recursive = null; @@ -111,13 +111,6 @@ class PaginatorComponent extends Component { unset($options[0]); } - $options = array_merge(array('page' => 1, 'limit' => 20, 'maxLimit' => 100), $options); - $options['limit'] = (int) $options['limit']; - if (empty($options['limit']) || $options['limit'] < 1) { - $options['limit'] = 1; - } - $options['limit'] = min((int)$options['limit'], $options['maxLimit']); - extract($options); if (is_array($scope) && !empty($scope)) { @@ -248,20 +241,20 @@ class PaginatorComponent extends Component { * * @param string $alias Model alias being paginated, if the general settings has a key with this value * that key's settings will be used for pagination instead of the general ones. - * @param string $options Per call options. * @param string $whitelist A whitelist of options that are allowed from the request parameters. Modifying * this array will allow you to permit more or less input from the user. * @return array Array of merged options. */ - public function mergeOptions($alias, $options, $whitelist = array()) { + public function mergeOptions($alias, $whitelist = array()) { if (isset($this->settings[$alias])) { $defaults = $this->settings[$alias]; } else { $defaults = $this->settings; } - if (empty($defaults['paramType'])) { - $defaults['paramType'] = 'named'; - } + $defaults = array_merge( + array('page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named'), + $defaults + ); switch ($defaults['paramType']) { case 'named': $request = $this->Controller->request->params['named']; @@ -277,7 +270,7 @@ class PaginatorComponent extends Component { $whitelist = array_flip(array_merge($this->whitelist, $whitelist)); $request = array_intersect_key($request, $whitelist); - return array_merge($defaults, $request, $options); + return array_merge($defaults, $request); } /** @@ -322,4 +315,19 @@ class PaginatorComponent extends Component { return $options; } + +/** + * Check the limit parameter and ensure its within the maxLimit bounds. + * + * @param array $options An array of options with a limit key to be checked. + * @return array An array of options for pagination + */ + public function checkLimit($options) { + $options['limit'] = (int) $options['limit']; + if (empty($options['limit']) || $options['limit'] < 1) { + $options['limit'] = 1; + } + $options['limit'] = min((int)$options['limit'], $options['maxLimit']); + return $options; + } } \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index 9fb22993e..ecb9f812f 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -582,14 +582,11 @@ class PaginatorTest extends CakeTestCase { 'paramType' => 'named', ) ); - $result = $this->Paginator->mergeOptions('Silly', array()); + $result = $this->Paginator->mergeOptions('Silly'); $this->assertEquals($this->Paginator->settings, $result); - $result = $this->Paginator->mergeOptions('Silly', array('limit' => 10)); - $this->assertEquals(10, $result['limit']); - - $result = $this->Paginator->mergeOptions('Post', array('sort' => 'title')); - $expected = array('page' => 1, 'limit' => 10, 'paramType' => 'named', 'sort' => 'title', 'maxLimit' => 50); + $result = $this->Paginator->mergeOptions('Post'); + $expected = array('page' => 1, 'limit' => 10, 'paramType' => 'named', 'maxLimit' => 50); $this->assertEquals($expected, $result); } @@ -609,12 +606,9 @@ class PaginatorTest extends CakeTestCase { 'maxLimit' => 100, 'paramType' => 'named', ); - $result = $this->Paginator->mergeOptions('Post', array()); + $result = $this->Paginator->mergeOptions('Post'); $expected = array('page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named'); $this->assertEquals($expected, $result); - - $result = $this->Paginator->mergeOptions('Post', array('page' => 100)); - $this->assertEquals(100, $result['page'], 'Passed options should replace request params'); } /** @@ -637,12 +631,9 @@ class PaginatorTest extends CakeTestCase { 'maxLimit' => 100, 'paramType' => 'querystring', ); - $result = $this->Paginator->mergeOptions('Post', array()); + $result = $this->Paginator->mergeOptions('Post'); $expected = array('page' => 99, 'limit' => 75, 'maxLimit' => 100, 'paramType' => 'querystring'); $this->assertEquals($expected, $result); - - $result = $this->Paginator->mergeOptions('Post', array('page' => 100)); - $this->assertEquals(100, $result['page'], 'Passed options should replace request params'); } /** @@ -665,7 +656,7 @@ class PaginatorTest extends CakeTestCase { 'maxLimit' => 100, 'paramType' => 'named', ); - $result = $this->Paginator->mergeOptions('Post', array()); + $result = $this->Paginator->mergeOptions('Post'); $expected = array('page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named'); $this->assertEquals($expected, $result); } @@ -690,7 +681,7 @@ class PaginatorTest extends CakeTestCase { 'maxLimit' => 100, 'paramType' => 'named', ); - $result = $this->Paginator->mergeOptions('Post', array(), array('fields')); + $result = $this->Paginator->mergeOptions('Post', array('fields')); $expected = array( 'page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named', 'fields' => array('bad.stuff') ); @@ -737,4 +728,26 @@ class PaginatorTest extends CakeTestCase { $this->assertEquals('desc', $result['order']['something']); } + +/** + * test that maxLimit is respected + * + * @return void + */ + function testCheckLimit() { + $result = $this->Paginator->checkLimit(array('limit' => 1000000, 'maxLimit' => 100)); + $this->assertEquals(100, $result['limit']); + + $result = $this->Paginator->checkLimit(array('limit' => 'sheep!', 'maxLimit' => 100)); + $this->assertEquals(1, $result['limit']); + + $result = $this->Paginator->checkLimit(array('limit' => '-1', 'maxLimit' => 100)); + $this->assertEquals(1, $result['limit']); + + $result = $this->Paginator->checkLimit(array('limit' => null, 'maxLimit' => 100)); + $this->assertEquals(1, $result['limit']); + + $result = $this->Paginator->checkLimit(array('limit' => 0, 'maxLimit' => 100)); + $this->assertEquals(1, $result['limit']); + } } \ No newline at end of file From f54479e5665fbc01eb23262b6c6a75a3babbd061 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 12:20:12 -0500 Subject: [PATCH 315/378] Adding some docblock info about pagination. --- cake/libs/controller/components/paginator.php | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index 5d05a1a9e..c2fefef55 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -19,13 +19,39 @@ */ /** - * PaginatorComponent + * This component is used to handle automatic model data pagination. The primary way to use this + * component is to call the paginate() method. There is a convience wrapper on Controller as well. * - * This component is used to handle automatic model data pagination + * ### Configuring pagination + * + * You configure pagination using the PaginatorComponent::$settings. This allows you to configure + * the default pagination behavior in general or for a specific model. General settings are used when there + * are no specific model configuration, or the model you are paginating does not have specific settings. + * + * {{{ + * $this->Paginator->settings = array( + * 'limit' => 20, + * 'maxLimit' => 100 + * ); + * }}} + * + * The above settings will be used to paginate any model. You can configure model specific settings by + * keying the settings with the model name. + * + * {{{ + * $this->Paginator->settings = array( + * 'Post' => array( + * 'limit' => 20, + * 'maxLimit' => 100 + * ), + * 'Comment' => array( ... ) + * ); + * }}} + * + * This would allow you to have different pagination settings for `Comment` and `Post` models. * * @package cake * @subpackage cake.cake.libs.controller.components - * */ class PaginatorComponent extends Component { From ef84d86cf537afec5000982f892f2c60432e0146 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 12:26:28 -0500 Subject: [PATCH 316/378] Reformatting code, and removing merging of defaults key in the helper. It no longer exists. --- cake/libs/controller/components/paginator.php | 5 ++++- cake/libs/view/helpers/paginator.php | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index c2fefef55..a774e934e 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -202,7 +202,10 @@ class PaginatorComponent extends Component { array($object->alias => $paging) ); - if (!in_array('Paginator', $this->Controller->helpers) && !array_key_exists('Paginator', $this->Controller->helpers)) { + if ( + !in_array('Paginator', $this->Controller->helpers) && + !array_key_exists('Paginator', $this->Controller->helpers) + ) { $this->Controller->helpers[] = 'Paginator'; } return $results; diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 11b897226..6fde140e6 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -112,7 +112,6 @@ class PaginatorHelper extends AppHelper { */ public function beforeRender($viewFile) { $this->options['url'] = array_merge($this->request->params['pass'], $this->request->params['named']); - parent::beforeRender($viewFile); } @@ -191,7 +190,7 @@ class PaginatorHelper extends AppHelper { public function sortKey($model = null, $options = array()) { if (empty($options)) { $params = $this->params($model); - $options = array_merge($params['defaults'], $params['options']); + $options = $params['options']; } if (isset($options['sort']) && !empty($options['sort'])) { @@ -217,7 +216,7 @@ class PaginatorHelper extends AppHelper { if (empty($options)) { $params = $this->params($model); - $options = array_merge($params['defaults'], $params['options']); + $options = $params['options']; } if (isset($options['direction'])) { From 833bdbcc0b0ffa050605034d20b1f4ef2b87b665 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 12:43:29 -0500 Subject: [PATCH 317/378] Reformatting paging params. Removing defaults from the paging params as they are no longer being used. --- cake/libs/view/helpers/paginator.php | 4 +- .../libs/view/helpers/paginator.test.php | 392 ++++++++++++++---- 2 files changed, 301 insertions(+), 95 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 6fde140e6..5708b9afe 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -367,9 +367,7 @@ class PaginatorHelper extends AppHelper { */ public function url($options = array(), $asArray = false, $model = null) { $paging = $this->params($model); - $url = array_merge(array_filter(Set::diff(array_merge( - $paging['defaults'], $paging['options']), $paging['defaults'])), $options - ); + $url = array_merge(array_filter($paging['options']), $options); if (isset($url['order'])) { $sort = $direction = null; diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 2e60552c5..fa6718d55 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -52,11 +52,6 @@ class PaginatorHelperTest extends CakeTestCase { 'prevPage' => false, 'nextPage' => true, 'pageCount' => 7, - 'defaults' => array( - 'order' => array('Article.date' => 'asc'), - 'limit' => 9, - 'conditions' => array() - ), 'options' => array( 'order' => array('Article.date' => 'asc'), 'limit' => 9, @@ -649,9 +644,6 @@ class PaginatorHelperTest extends CakeTestCase { 'Article' => array( 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 8, - 'defaults' => array( - 'limit' => 3, 'step' => 1, 'order' => array(), 'conditions' => array() - ), 'options' => array( 'page' => 1, 'limit' => 3, 'order' => array(), 'conditions' => array() ) @@ -706,10 +698,21 @@ class PaginatorHelperTest extends CakeTestCase { * @return void */ function testPagingLinks() { - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5, - 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 1, + 'current' => 3, + 'count' => 13, + 'prevPage' => false, + 'nextPage' => true, + 'pageCount' => 5, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $expected = array( @@ -779,10 +782,21 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 1, 'current' => 1, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5, - 'defaults' => array(), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 1, + 'current' => 1, + 'count' => 13, + 'prevPage' => false, + 'nextPage' => true, + 'pageCount' => 5, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->prev('<< Previous', null, 'Disabled'); @@ -809,10 +823,21 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5, - 'defaults' => array(), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 1, + 'current' => 3, + 'count' => 13, + 'prevPage' => false, + 'nextPage' => true, + 'pageCount' => 5, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $this->Paginator->request->params['paging']['Client']['page'] = 2; @@ -837,11 +862,22 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true, 'nextPage' => false, 'pageCount' => 2, - 'defaults' => array(), - 'options' => array('page' => 2, 'limit' => 10, 'order' => array(), 'conditions' => array()) - )); + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 2, + 'current' => 1, + 'count' => 13, + 'prevPage' => true, + 'nextPage' => false, + 'pageCount' => 2, + 'options' => array( + 'page' => 2, + 'limit' => 10, + 'order' => array(), + 'conditions' => array() + ) + ) + ); $result = $this->Paginator->prev('Prev'); $expected = array( 'Paginator->request->params['paging'] = array( 'Client' => array( - 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, - 'nextPage' => true, 'pageCount' => 5, - 'defaults' => array( - 'limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array() - ), + 'page' => 1, + 'current' => 3, + 'count' => 13, + 'prevPage' => false, + 'nextPage' => true, + 'pageCount' => 5, 'options' => array( 'page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array() ) @@ -924,14 +961,32 @@ class PaginatorHelperTest extends CakeTestCase { // Multiple Model Paginate $this->Paginator->request->params['paging'] = array( 'Client' => array( - 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5, - 'defaults' => array( 'limit'=>3, 'order' => array('Client.name' => 'DESC')), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()) + 'page' => 1, + 'current' => 3, + 'count' => 13, + 'prevPage' => false, + 'nextPage' => true, + 'pageCount' => 5, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) ), 'Server' => array( - 'page' => 1, 'current' => 1, 'count' => 5, 'prevPage' => false, 'nextPage' => false, 'pageCount' => 5, - 'defaults' => array(), - 'options' => array('page' => 1, 'limit' => 5, 'order' => array('Server.name' => 'ASC'), 'conditions' => array()) + 'page' => 1, + 'current' => 1, + 'count' => 5, + 'prevPage' => false, + 'nextPage' => false, + 'pageCount' => 5, + 'options' => array( + 'page' => 1, + 'limit' => 5, + 'order' => array('Server.name' => 'ASC'), + 'conditions' => array() + ) ) ); $result = $this->Paginator->next('Next', array('model' => 'Client')); @@ -1030,10 +1085,21 @@ class PaginatorHelperTest extends CakeTestCase { * @return void */ function testNumbers() { - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 8, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, - 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 8, + 'current' => 3, + 'count' => 30, + 'prevPage' => false, + 'nextPage' => 2, + 'pageCount' => 15, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->numbers(); $expected = array( @@ -1119,10 +1185,21 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 1, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, - 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 1, + 'current' => 3, + 'count' => 30, + 'prevPage' => false, + 'nextPage' => 2, + 'pageCount' => 15, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->numbers(); $expected = array( @@ -1147,10 +1224,21 @@ class PaginatorHelperTest extends CakeTestCase { $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 14, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, - 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 14, + 'current' => 3, + 'count' => 30, + 'prevPage' => false, + 'nextPage' => 2, + 'pageCount' => 15, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->numbers(); $expected = array( @@ -1174,10 +1262,21 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 2, 'current' => 3, 'count' => 27, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 9, - 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 2, + 'current' => 3, + 'count' => 27, + 'prevPage' => false, + 'nextPage' => 2, + 'pageCount' => 9, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->numbers(array('first' => 1)); @@ -1224,10 +1323,21 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, - 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 15, + 'current' => 3, + 'count' => 30, + 'prevPage' => false, + 'nextPage' => 2, + 'pageCount' => 15, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->numbers(array('first' => 1)); @@ -1255,10 +1365,21 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 10, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, - 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 10, + 'current' => 3, + 'count' => 30, + 'prevPage' => false, + 'nextPage' => 2, + 'pageCount' => 15, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1)); @@ -1287,10 +1408,21 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 6, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42, - 'defaults' => array('limit' => 15, 'step' => 1, 'page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), - 'options' => array('page' => 6, 'limit' => 15, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 6, + 'current' => 15, + 'count' => 623, + 'prevPage' => 1, + 'nextPage' => 1, + 'pageCount' => 42, + 'options' => array( + 'page' => 6, + 'limit' => 15, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1)); @@ -1319,10 +1451,21 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 37, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42, - 'defaults' => array('limit' => 15, 'step' => 1, 'page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), - 'options' => array('page' => 37, 'limit' => 15, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 37, + 'current' => 15, + 'count' => 623, + 'prevPage' => 1, + 'nextPage' => 1, + 'pageCount' => 42, + 'options' => array( + 'page' => 37, + 'limit' => 15, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1)); @@ -1384,10 +1527,20 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 2, 'current' => 10, 'count' => 31, 'prevPage' => true, 'nextPage' => true, 'pageCount' => 4, - 'defaults' => array('limit' => 10), - 'options' => array('page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 2, + 'current' => 10, + 'count' => 31, + 'prevPage' => true, + 'nextPage' => true, + 'pageCount' => 4, + 'options' => array( + 'page' => 1, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->numbers(); $expected = array( @@ -1402,10 +1555,21 @@ class PaginatorHelperTest extends CakeTestCase { $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 4895, 'current' => 10, 'count' => 48962, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 4897, - 'defaults' => array('limit' => 10), - 'options' => array('page' => 4894, 'limit' => 10, 'order' => 'Client.name DESC', 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 4895, + 'current' => 10, + 'count' => 48962, + 'prevPage' => 1, + 'nextPage' => 1, + 'pageCount' => 4897, + 'options' => array( + 'page' => 4894, + 'limit' => 10, + 'order' => 'Client.name DESC', + 'conditions' => array() + ) + ) ); $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2)); @@ -1619,20 +1783,42 @@ class PaginatorHelperTest extends CakeTestCase { * @return void */ function testFirstAndLast() { - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 1, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, - 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 1, + 'current' => 3, + 'count' => 30, + 'prevPage' => false, + 'nextPage' => 2, + 'pageCount' => 15, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->first(); $expected = ''; $this->assertEqual($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 4, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, - 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 4, + 'current' => 3, + 'count' => 30, + 'prevPage' => false, + 'nextPage' => 2, + 'pageCount' => 15, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->first(); @@ -1702,19 +1888,41 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, - 'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 15, + 'current' => 3, + 'count' => 30, + 'prevPage' => false, + 'nextPage' => 2, + 'pageCount' => 15, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->last(); $expected = ''; $this->assertEqual($result, $expected); - $this->Paginator->request->params['paging'] = array('Client' => array( - 'page' => 4, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, - 'defaults' => array('limit' => 3), - 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) + $this->Paginator->request->params['paging'] = array( + 'Client' => array( + 'page' => 4, + 'current' => 3, + 'count' => 30, + 'prevPage' => false, + 'nextPage' => 2, + 'pageCount' => 15, + 'options' => array( + 'page' => 1, + 'limit' => 3, + 'order' => array('Client.name' => 'DESC'), + 'conditions' => array() + ) + ) ); $result = $this->Paginator->first(); From 8c3ceff50d0bf8b7042954156300cec2b4382095 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 12:58:07 -0500 Subject: [PATCH 318/378] Making paging.options only contain options that are not in the defaults. This replaces the many diffs that were calculated on each url generation between paging.options and paging.defaults. --- cake/libs/controller/components/paginator.php | 47 ++++++++++------ .../controller/components/paginator.test.php | 56 +++++-------------- 2 files changed, 44 insertions(+), 59 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index a774e934e..e660276e3 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -184,14 +184,18 @@ class PaginatorComponent extends Component { } $results = $object->find($type, array_merge($parameters, $extra)); } + $defaults = $this->getDefaults($object->alias); + unset($defaults[0]); + $paging = array( - 'page' => $page, - 'current' => count($results), - 'count' => $count, - 'prevPage' => ($page > 1), - 'nextPage' => ($count > ($page * $limit)), - 'pageCount' => $pageCount, - 'options' => $options, + 'page' => $page, + 'current' => count($results), + 'count' => $count, + 'prevPage' => ($page > 1), + 'nextPage' => ($count > ($page * $limit)), + 'pageCount' => $pageCount, + 'order' => $order, + 'options' => Set::diff($options, $defaults), 'paramType' => $options['paramType'] ); if (!isset($this->Controller->request['paging'])) { @@ -275,15 +279,7 @@ class PaginatorComponent extends Component { * @return array Array of merged options. */ public function mergeOptions($alias, $whitelist = array()) { - if (isset($this->settings[$alias])) { - $defaults = $this->settings[$alias]; - } else { - $defaults = $this->settings; - } - $defaults = array_merge( - array('page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named'), - $defaults - ); + $defaults = $this->getDefaults($alias); switch ($defaults['paramType']) { case 'named': $request = $this->Controller->request->params['named']; @@ -302,6 +298,25 @@ class PaginatorComponent extends Component { return array_merge($defaults, $request); } +/** + * Get the default settings for a $model. If there are no settings for a specific model, the general settings + * will be used. + * + * @param string $alias Model name to get default settings for. + * @return array + */ + public function getDefaults($alias) { + if (isset($this->settings[$alias])) { + $defaults = $this->settings[$alias]; + } else { + $defaults = $this->settings; + } + return array_merge( + array('page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named'), + $defaults + ); + } + /** * Validate that the desired sorting can be performed on the $object. Only fields or * virtualFields can be sorted on. The direction param will also be sanitized. Lastly diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index ecb9f812f..9268d9615 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -285,8 +285,7 @@ class PaginatorTest extends CakeTestCase { $Controller->request->params['named'] = array('page' => '1 " onclick="alert(\'xss\');">'); $Controller->Paginator->settings = array('limit' => 1, 'maxLimit' => 10, 'paramType' => 'named'); $Controller->Paginator->paginate('PaginatorControllerPost'); - $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1, 'XSS exploit opened %s'); - $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['options']['page'], 1, 'XSS exploit opened %s'); + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1, 'XSS exploit opened'); $Controller->request->params['named'] = array(); $Controller->Paginator->settings = array('limit' => 0, 'maxLimit' => 10, 'paramType' => 'named'); @@ -405,43 +404,6 @@ class PaginatorTest extends CakeTestCase { $this->assertEqual($Controller->ControllerPaginateModel->extraCount, $expected); } -/** - * testPaginatePassedArgs method - * - * @return void - */ - public function testPaginatePassedArgs() { - $Controller = new PaginatorTestController($this->request); - $Controller->uses = array('PaginatorControllerPost'); - $Controller->request->params['pass'] = array('1', '2', '3'); - $Controller->params['url'] = array(); - $Controller->constructClasses(); - - $Controller->Paginator->settings = array( - 'fields' => array(), - 'order' => '', - 'limit' => 5, - 'page' => 1, - 'recursive' => -1, - 'maxLimit' => 10, - 'paramType' => 'named' - ); - $conditions = array(); - $Controller->Paginator->paginate('PaginatorControllerPost', $conditions); - - $expected = array( - 'fields' => array(), - 'order' => '', - 'limit' => 5, - 'maxLimit' => 10, - 'page' => 1, - 'recursive' => -1, - 'conditions' => array(), - 'paramType' => 'named' - ); - $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options'],$expected); - } - /** * Test that special paginate types are called and that the type param doesn't leak out into defaults or options. * @@ -456,13 +418,19 @@ class PaginatorTest extends CakeTestCase { $Controller->Paginator->settings = array( 'PaginatorControllerPost' => array( - 'popular', 'fields' => array('id', 'title'), 'maxLimit' => 10, 'paramType' => 'named' + 'popular', + 'fields' => array('id', 'title'), + 'maxLimit' => 10, + 'paramType' => 'named' ) ); $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEqual(Set::extract($result, '{n}.PaginatorControllerPost.id'), array(2, 3)); - $this->assertEqual($Controller->PaginatorControllerPost->lastQuery['conditions'], array('PaginatorControllerPost.id > ' => '1')); + $this->assertEqual( + $Controller->PaginatorControllerPost->lastQuery['conditions'], + array('PaginatorControllerPost.id > ' => '1') + ); $this->assertFalse(isset($Controller->params['paging']['PaginatorControllerPost']['options'][0])); } @@ -478,10 +446,12 @@ class PaginatorTest extends CakeTestCase { $Controller->params['url'] = array(); $Controller->constructClasses(); $Controller->Paginator->settings = array( - 'order' => 'PaginatorControllerPost.id DESC', 'maxLimit' => 10, 'paramType' => 'named' + 'order' => 'PaginatorControllerPost.id DESC', + 'maxLimit' => 10, + 'paramType' => 'named' ); $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); - $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['order'], 'PaginatorControllerPost.id DESC'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['order'], 'PaginatorControllerPost.id DESC'); $this->assertEqual($results, array(3, 2, 1)); } From 176d5520f624f821de8bb7ce1ddd95b63eacba99 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 13:09:52 -0500 Subject: [PATCH 319/378] Making paging params match those that would be generated by PaginatorComponent. --- .../libs/view/helpers/paginator.test.php | 112 +++++------------- 1 file changed, 32 insertions(+), 80 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index fa6718d55..c8ca15a05 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -53,8 +53,6 @@ class PaginatorHelperTest extends CakeTestCase { 'nextPage' => true, 'pageCount' => 7, 'options' => array( - 'order' => array('Article.date' => 'asc'), - 'limit' => 9, 'page' => 1, 'conditions' => array() ) @@ -138,6 +136,21 @@ class PaginatorHelperTest extends CakeTestCase { array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/') )); $this->Paginator->options(array('url' => array('param'))); + $this->Paginator->request['paging'] = array( + 'Article' => array( + 'current' => 9, + 'count' => 62, + 'prevPage' => false, + 'nextPage' => true, + 'pageCount' => 7, + 'options' => array( + 'page' => 1, + 'order' => array('date' => 'asc'), + 'conditions' => array() + ) + ) + ); + $result = $this->Paginator->sort('title'); $expected = array( 'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'), @@ -645,7 +658,9 @@ class PaginatorHelperTest extends CakeTestCase { 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 8, 'options' => array( - 'page' => 1, 'limit' => 3, 'order' => array(), 'conditions' => array() + 'page' => 1, + 'order' => array(), + 'conditions' => array() ) ) ); @@ -708,9 +723,6 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 5, 'options' => array( 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() ) ) ); @@ -792,9 +804,6 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 5, 'options' => array( 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() ) ) ); @@ -834,8 +843,7 @@ class PaginatorHelperTest extends CakeTestCase { 'options' => array( 'page' => 1, 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() + 'order' => array('Client.name' => 'DESC'), ) ) ); @@ -873,7 +881,7 @@ class PaginatorHelperTest extends CakeTestCase { 'options' => array( 'page' => 2, 'limit' => 10, - 'order' => array(), + 'order' => array(), 'conditions' => array() ) ) @@ -926,7 +934,7 @@ class PaginatorHelperTest extends CakeTestCase { 'nextPage' => true, 'pageCount' => 5, 'options' => array( - 'page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array() + 'page' => 1, ) ) ); @@ -969,9 +977,6 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 5, 'options' => array( 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() ) ), 'Server' => array( @@ -983,9 +988,6 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 5, 'options' => array( 'page' => 1, - 'limit' => 5, - 'order' => array('Server.name' => 'ASC'), - 'conditions' => array() ) ) ); @@ -1094,10 +1096,7 @@ class PaginatorHelperTest extends CakeTestCase { 'nextPage' => 2, 'pageCount' => 15, 'options' => array( - 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() + 'page' => 1, ) ) ); @@ -1194,10 +1193,7 @@ class PaginatorHelperTest extends CakeTestCase { 'nextPage' => 2, 'pageCount' => 15, 'options' => array( - 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() + 'page' => 1, ) ) ); @@ -1233,10 +1229,7 @@ class PaginatorHelperTest extends CakeTestCase { 'nextPage' => 2, 'pageCount' => 15, 'options' => array( - 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() + 'page' => 1, ) ) ); @@ -1271,10 +1264,7 @@ class PaginatorHelperTest extends CakeTestCase { 'nextPage' => 2, 'pageCount' => 9, 'options' => array( - 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() + 'page' => 1, ) ) ); @@ -1332,10 +1322,7 @@ class PaginatorHelperTest extends CakeTestCase { 'nextPage' => 2, 'pageCount' => 15, 'options' => array( - 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() + 'page' => 1, ) ) ); @@ -1374,10 +1361,7 @@ class PaginatorHelperTest extends CakeTestCase { 'nextPage' => 2, 'pageCount' => 15, 'options' => array( - 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() + 'page' => 1, ) ) ); @@ -1418,9 +1402,6 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 42, 'options' => array( 'page' => 6, - 'limit' => 15, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() ) ) ); @@ -1460,10 +1441,7 @@ class PaginatorHelperTest extends CakeTestCase { 'nextPage' => 1, 'pageCount' => 42, 'options' => array( - 'page' => 37, - 'limit' => 15, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() + 'page' => 37, ) ) ); @@ -1502,17 +1480,8 @@ class PaginatorHelperTest extends CakeTestCase { 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 3, - 'defaults' => array( - 'limit' => 3, - 'step' => 1, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() - ), 'options' => array( 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() ) ) ); @@ -1538,7 +1507,6 @@ class PaginatorHelperTest extends CakeTestCase { 'options' => array( 'page' => 1, 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() ) ) ); @@ -1565,9 +1533,6 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 4897, 'options' => array( 'page' => 4894, - 'limit' => 10, - 'order' => 'Client.name DESC', - 'conditions' => array() ) ) ); @@ -1791,12 +1756,7 @@ class PaginatorHelperTest extends CakeTestCase { 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, - 'options' => array( - 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() - ) + 'options' => array() ) ); @@ -1814,9 +1774,6 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 15, 'options' => array( 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() ) ) ); @@ -1898,9 +1855,6 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 15, 'options' => array( 'page' => 1, - 'limit' => 3, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() ) ) ); @@ -1913,14 +1867,12 @@ class PaginatorHelperTest extends CakeTestCase { 'page' => 4, 'current' => 3, 'count' => 30, - 'prevPage' => false, + 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, 'options' => array( - 'page' => 1, - 'limit' => 3, + 'page' => 1, 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() ) ) ); @@ -2139,7 +2091,7 @@ class PaginatorHelperTest extends CakeTestCase { Router::reload(); Router::parse('/'); Router::setRequestInfo(array( - array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true')), + array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'url' => array('url' => 'accounts/')), array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/', 'passedArgs' => array()) )); From cc2d8e2fece90d9024ea54a249081293f67ee249 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 13:15:04 -0500 Subject: [PATCH 320/378] Moving limit from the options to the normal paging params. This fixes a few notice errors. --- cake/libs/controller/components/paginator.php | 1 + cake/libs/view/helpers/paginator.php | 4 ++-- .../libs/controller/components/paginator.test.php | 2 ++ cake/tests/cases/libs/view/helpers/paginator.test.php | 10 +--------- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index e660276e3..caa911c06 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -195,6 +195,7 @@ class PaginatorComponent extends Component { 'nextPage' => ($count > ($page * $limit)), 'pageCount' => $pageCount, 'order' => $order, + 'limit' => $limit, 'options' => Set::diff($options, $defaults), 'paramType' => $options['paramType'] ); diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 5708b9afe..2651579f5 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -525,9 +525,9 @@ class PaginatorHelper extends AppHelper { } $start = 0; if ($paging['count'] >= 1) { - $start = (($paging['page'] - 1) * $paging['options']['limit']) + 1; + $start = (($paging['page'] - 1) * $paging['limit']) + 1; } - $end = $start + $paging['options']['limit'] - 1; + $end = $start + $paging['limit'] - 1; if ($paging['count'] < $end) { $end = $paging['count']; } diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index 9268d9615..1f6168b66 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -306,6 +306,8 @@ class PaginatorTest extends CakeTestCase { $Controller->request->params['named'] = array(); $Controller->Paginator->settings = array('limit' => '-1', 'maxLimit' => 10, 'paramType' => 'named'); $Controller->Paginator->paginate('PaginatorControllerPost'); + + $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['limit'], 1); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3); $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['prevPage'], false); diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index c8ca15a05..27e9f94a9 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -1966,18 +1966,10 @@ class PaginatorHelperTest extends CakeTestCase { 'prevPage' => false, 'nextPage' => true, 'pageCount' => 5, - 'defaults' => array( - 'limit' => 3, - 'step' => 1, - 'order' => array('Client.name' => 'DESC'), - 'conditions' => array() - ), + 'limit' => 3, 'options' => array( 'page' => 1, - 'limit' => 3, 'order' => array('Client.name' => 'DESC'), - 'conditions' => array(), - 'separator' => 'of' ), ) ); From da46ad494b4a3c3ce171de39c68e586e22a77e3f Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 13:53:11 -0500 Subject: [PATCH 321/378] Deleting duplicate tests. Moving a test out into a separate method. --- .../controller/components/paginator.test.php | 107 ++++++++++-------- 1 file changed, 62 insertions(+), 45 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index 1f6168b66..df3779f1e 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -223,6 +223,8 @@ class PaginatorTest extends CakeTestCase { $this->Controller = new Controller($this->request); $this->Paginator = new PaginatorComponent($this->getMock('ComponentCollection'), array()); $this->Paginator->Controller = $this->Controller; + $this->Controller->Post = $this->getMock('Model'); + $this->Controller->Post->alias = 'Post'; } /** @@ -282,11 +284,6 @@ class PaginatorTest extends CakeTestCase { $this->assertEqual($Controller->PaginatorControllerPost->lastQuery['order'][0], array('PaginatorControllerPost.author_id' => 'asc')); $this->assertEqual($results, array(1, 3, 2)); - $Controller->request->params['named'] = array('page' => '1 " onclick="alert(\'xss\');">'); - $Controller->Paginator->settings = array('limit' => 1, 'maxLimit' => 10, 'paramType' => 'named'); - $Controller->Paginator->paginate('PaginatorControllerPost'); - $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1, 'XSS exploit opened'); - $Controller->request->params['named'] = array(); $Controller->Paginator->settings = array('limit' => 0, 'maxLimit' => 10, 'paramType' => 'named'); $Controller->Paginator->paginate('PaginatorControllerPost'); @@ -314,6 +311,26 @@ class PaginatorTest extends CakeTestCase { $this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['nextPage'], true); } +/** + * Test that non-numeric values are rejected for page, and limit + * + * @return void + */ + function testPageParamCasting() { + $this->Controller->Post->expects($this->at(0)) + ->method('find') + ->will($this->returnValue(2)); + + $this->Controller->Post->expects($this->at(1)) + ->method('find') + ->will($this->returnValue(array('stuff'))); + + $this->request->params['named'] = array('page' => '1 " onclick="alert(\'xss\');">'); + $this->Paginator->settings = array('limit' => 1, 'maxLimit' => 10, 'paramType' => 'named'); + $this->Paginator->paginate('Post'); + $this->assertSame(1, $this->request->params['paging']['Post']['page'], 'XSS exploit opened'); + } + /** * testPaginateExtraParams method * @@ -496,46 +513,6 @@ class PaginatorTest extends CakeTestCase { $Controller->Paginator->paginate('MissingModel'); } -/** - * testPaginateMaxLimit - * - * @return void - * @access public - */ - function testPaginateMaxLimit() { - $Controller = new Controller($this->request); - - $Controller->uses = array('PaginatorControllerPost', 'ControllerComment'); - $Controller->passedArgs[] = '1'; - $Controller->params['url'] = array(); - $Controller->constructClasses(); - - $Controller->request->params['named'] = array( - 'contain' => array('ControllerComment'), 'limit' => '1000' - ); - $result = $Controller->paginate('PaginatorControllerPost'); - $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 100); - - $Controller->request->params['named'] = array( - 'contain' => array('ControllerComment'), 'limit' => '1000', 'maxLimit' => 1000 - ); - $result = $Controller->paginate('PaginatorControllerPost'); - $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 100); - - $Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '10'); - $result = $Controller->paginate('PaginatorControllerPost'); - $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 10); - - $Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '1000'); - $Controller->paginate = array('maxLimit' => 2000, 'paramType' => 'named'); - $result = $Controller->paginate('PaginatorControllerPost'); - $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 1000); - - $Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '5000'); - $result = $Controller->paginate('PaginatorControllerPost'); - $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 2000); - } - /** * test that option merging prefers specific models * @@ -722,4 +699,44 @@ class PaginatorTest extends CakeTestCase { $result = $this->Paginator->checkLimit(array('limit' => 0, 'maxLimit' => 100)); $this->assertEquals(1, $result['limit']); } + +/** + * testPaginateMaxLimit + * + * @return void + * @access public + */ + function testPaginateMaxLimit() { + $Controller = new Controller($this->request); + + $Controller->uses = array('PaginatorControllerPost', 'ControllerComment'); + $Controller->passedArgs[] = '1'; + $Controller->params['url'] = array(); + $Controller->constructClasses(); + + $Controller->request->params['named'] = array( + 'contain' => array('ControllerComment'), 'limit' => '1000' + ); + $result = $Controller->paginate('PaginatorControllerPost'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 100); + + $Controller->request->params['named'] = array( + 'contain' => array('ControllerComment'), 'limit' => '1000', 'maxLimit' => 1000 + ); + $result = $Controller->paginate('PaginatorControllerPost'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 100); + + $Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '10'); + $result = $Controller->paginate('PaginatorControllerPost'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 10); + + $Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '1000'); + $Controller->paginate = array('maxLimit' => 2000, 'paramType' => 'named'); + $result = $Controller->paginate('PaginatorControllerPost'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 1000); + + $Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '5000'); + $result = $Controller->paginate('PaginatorControllerPost'); + $this->assertEqual($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 2000); + } } \ No newline at end of file From c83a4703a3779db9446a93fe15938a64a8ca18fb Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 16:47:22 -0500 Subject: [PATCH 322/378] Implementing ability to change pagination params to use querystring variables. Tests added. --- cake/libs/view/helpers/paginator.php | 45 ++++++- .../libs/view/helpers/paginator.test.php | 117 ++++++++++++------ 2 files changed, 121 insertions(+), 41 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 2651579f5..5caaf7ed9 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -68,14 +68,22 @@ class PaginatorHelper extends AppHelper { * - `$options['escape']` Defines if the title field for the link should be escaped (default: true). * - `$options['update']` DOM id of the element updated with the results of the AJAX call. * If this key isn't specified Paginator will use plain HTML links. - * - `$options['indicator']` DOM id of the element that will be shown when doing AJAX requests. **Only supported by - * AjaxHelper** + * - `$options['paramType']` The type of parameters to use when creating links. Valid options are + * 'querystring', 'named', and 'route'. See PaginatorComponent::$settings for more information. * * @var array * @access public */ public $options = array(); +/** + * A list of keys that will be turned into `$this->options['paramType']` url parameters when links + * are generated + * + * @var array + */ + public $convertKeys = array('page', 'limit', 'sort', 'direction'); + /** * Constructor for the helper. Sets up the helper that is used for creating 'AJAX' links. * @@ -111,7 +119,12 @@ class PaginatorHelper extends AppHelper { * @return void */ public function beforeRender($viewFile) { - $this->options['url'] = array_merge($this->request->params['pass'], $this->request->params['named']); + $named = $this->request->params['named']; + foreach ($named as $key => $val) { + $named[CakeRoute::SIGIL_NAMED . $key] = $val; + unset($named[$key]); + } + $this->options['url'] = array_merge($this->request->params['pass'], $named); parent::beforeRender($viewFile); } @@ -377,6 +390,7 @@ class PaginatorHelper extends AppHelper { unset($url['order']); $url = array_merge($url, compact('sort', 'direction')); } + $url = $this->_convertUrlKeys($url, $paging['paramType']); if ($asArray) { return $url; @@ -384,6 +398,31 @@ class PaginatorHelper extends AppHelper { return parent::url($url); } +/** + * Converts the keys being used into the format set by options.paramType + * + * @param array $url Array of url params to convert + * @return converted url params. + */ + protected function _convertUrlKeys($url, $type) { + $prefix = ''; + switch ($type) { + case 'named': + $prefix = CakeRoute::SIGIL_NAMED; + break; + case 'querystring': + $prefix = CakeRoute::SIGIL_QUERYSTRING; + break; + } + foreach ($this->convertKeys as $key) { + if (isset($url[$key])) { + $url[$prefix . $key] = $url[$key]; + unset($url[$key]); + } + } + return $url; + } + /** * Protected method for generating prev/next links * diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 27e9f94a9..ab400702b 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -55,7 +55,8 @@ class PaginatorHelperTest extends CakeTestCase { 'options' => array( 'page' => 1, 'conditions' => array() - ) + ), + 'paramType' => 'named' ) ) )); @@ -147,7 +148,8 @@ class PaginatorHelperTest extends CakeTestCase { 'page' => 1, 'order' => array('date' => 'asc'), 'conditions' => array() - ) + ), + 'paramType' => 'named' ) ); @@ -651,7 +653,7 @@ class PaginatorHelperTest extends CakeTestCase { Router::parse('/'); Router::setRequestInfo(array( array('plugin' => null, 'controller' => 'articles', 'action' => 'index', 'pass' => array('2'), 'named' => array('foo' => 'bar'), 'url' => array('url' => 'articles/index/2/foo:bar')), - array('base' => '/', 'here' => '/articles/', 'webroot' => '/', 'passedArgs' => array(0 => '2', 'foo' => 'bar')) + array('base' => '/', 'here' => '/articles/', 'webroot' => '/') )); $this->Paginator->request->params['paging'] = array( 'Article' => array( @@ -661,7 +663,8 @@ class PaginatorHelperTest extends CakeTestCase { 'page' => 1, 'order' => array(), 'conditions' => array() - ) + ), + 'paramType' => 'named' ) ); @@ -671,7 +674,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->sort('title'); $expected = array( - 'a' => array('href' => '/articles/index/2/page:1/foo:bar/sort:title/direction:asc'), + 'a' => array('href' => '/articles/index/2/foo:bar/page:1/sort:title/direction:asc'), 'Title', '/a' ); @@ -681,24 +684,24 @@ class PaginatorHelperTest extends CakeTestCase { $expected = array( array('span' => array('class' => 'current')), '1', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/page:2/foo:bar')), '2', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar/page:2')), '2', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/page:3/foo:bar')), '3', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar/page:3')), '3', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/page:4/foo:bar')), '4', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar/page:4')), '4', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/page:5/foo:bar')), '5', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar/page:5')), '5', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/page:6/foo:bar')), '6', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar/page:6')), '6', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/page:7/foo:bar')), '7', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar/page:7')), '7', '/a', '/span', ); $this->assertTags($result, $expected); $result = $this->Paginator->next('Next'); $expected = array( ' array('href' => '/articles/index/2/page:2/foo:bar', 'class' => 'next'), + 'a' => array('href' => '/articles/index/2/foo:bar/page:2', 'class' => 'next'), 'Next', '/a', '/span' @@ -723,7 +726,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 5, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); @@ -804,7 +808,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 5, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); @@ -844,7 +849,8 @@ class PaginatorHelperTest extends CakeTestCase { 'page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), - ) + ), + 'paramType' => 'named' ) ); @@ -883,7 +889,8 @@ class PaginatorHelperTest extends CakeTestCase { 'limit' => 10, 'order' => array(), 'conditions' => array() - ) + ), + 'paramType' => 'named' ) ); $result = $this->Paginator->prev('Prev'); @@ -903,14 +910,15 @@ class PaginatorHelperTest extends CakeTestCase { 'defaults' => array(), 'options' => array( 'page' => 2, 'limit' => 10, 'order' => array(), 'conditions' => array() - ) + ), + 'paramType' => 'named' ) ); $this->Paginator->options(array('url' => array(12, 'page' => 3))); - $result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar'))); + $result = $this->Paginator->prev('Prev', array('url' => array(':foo' => 'bar'))); $expected = array( ' array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev'), + 'a' => array('href' => '/index/12/foo:bar/page:1/limit:10', 'class' => 'prev'), 'Prev', '/a', '/span' @@ -935,7 +943,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 5, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); $result = $this->Paginator->prev('<< Previous', array('escape' => false)); @@ -977,7 +986,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 5, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ), 'Server' => array( 'page' => 1, @@ -988,7 +998,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 5, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); $result = $this->Paginator->next('Next', array('model' => 'Client')); @@ -1097,7 +1108,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 15, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); $result = $this->Paginator->numbers(); @@ -1194,7 +1206,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 15, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); $result = $this->Paginator->numbers(); @@ -1230,7 +1243,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 15, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); $result = $this->Paginator->numbers(); @@ -1265,7 +1279,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 9, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); @@ -1323,7 +1338,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 15, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); @@ -1362,7 +1378,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 15, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); @@ -1402,7 +1419,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 42, 'options' => array( 'page' => 6, - ) + ), + 'paramType' => 'named' ) ); @@ -1442,7 +1460,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 42, 'options' => array( 'page' => 37, - ) + ), + 'paramType' => 'named' ) ); @@ -1482,7 +1501,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 3, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); $options = array('modulus' => 10); @@ -1507,7 +1527,8 @@ class PaginatorHelperTest extends CakeTestCase { 'options' => array( 'page' => 1, 'order' => array('Client.name' => 'DESC'), - ) + ), + 'paramType' => 'named' ) ); $result = $this->Paginator->numbers(); @@ -1533,7 +1554,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 4897, 'options' => array( 'page' => 4894, - ) + ), + 'paramType' => 'named' ) ); @@ -1756,7 +1778,8 @@ class PaginatorHelperTest extends CakeTestCase { 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15, - 'options' => array() + 'options' => array(), + 'paramType' => 'named' ) ); @@ -1774,7 +1797,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 15, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); @@ -1855,7 +1879,8 @@ class PaginatorHelperTest extends CakeTestCase { 'pageCount' => 15, 'options' => array( 'page' => 1, - ) + ), + 'paramType' => 'named' ) ); $result = $this->Paginator->last(); @@ -1873,7 +1898,8 @@ class PaginatorHelperTest extends CakeTestCase { 'options' => array( 'page' => 1, 'order' => array('Client.name' => 'DESC'), - ) + ), + 'paramType' => 'named' ) ); @@ -1971,6 +1997,7 @@ class PaginatorHelperTest extends CakeTestCase { 'page' => 1, 'order' => array('Client.name' => 'DESC'), ), + 'paramType' => 'named' ) ); $input = 'Page %page% of %pages%, showing %current% records out of %count% total, '; @@ -2152,7 +2179,8 @@ class PaginatorHelperTest extends CakeTestCase { 'nextPage' => true, 'pageCount' => 7, 'defaults' => array(), - 'options' => array() + 'options' => array(), + 'paramType' => 'named' ) ); $Paginator->PaginatorMockJs = $mock; @@ -2162,4 +2190,17 @@ class PaginatorHelperTest extends CakeTestCase { $this->expectException(); $Paginator = new PaginatorHelper($this->View, array('ajax' => 'Form')); } + +/** + * test that querystring links can be generated. + * + * @return void + */ + function testQuerystringLinkGeneration() { + $this->Paginator->request->params['paging']['Article']['paramType'] = 'querystring'; + $result = $this->Paginator->url(array('page' => '4')); + $expected = '/index?page=4'; + $this->assertEquals($expected, $result); + } + } From 5df2678ba9fce1728d5f6a885a166fb25cd724a2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 17:09:34 -0500 Subject: [PATCH 323/378] Fixing named params that were missing the : and fixing Router::reverse() so it adds in the : --- cake/libs/router.php | 21 +++++++++++++++------ cake/tests/cases/libs/router.test.php | 16 ++++++++-------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 506bdb2b0..f4cfa32fd 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -897,7 +897,7 @@ class Router { * @see Router::url() */ protected static function _handleNoRoute($url) { - $named = $args = array(); + $named = $args = $query = array(); $skip = array_merge( array('bare', 'action', 'controller', 'plugin', 'prefix'), self::$_prefixes @@ -908,10 +908,13 @@ class Router { // Remove this once parsed URL parameters can be inserted into 'pass' for ($i = 0; $i < $count; $i++) { + $key = $keys[$i]; if (is_numeric($keys[$i])) { - $args[] = $url[$keys[$i]]; - } else { - $named[$keys[$i]] = $url[$keys[$i]]; + $args[] = $url[$key]; + } elseif ($key[0] === CakeRoute::SIGIL_NAMED) { + $named[substr($key, 1)] = $url[$key]; + } elseif ($key[0] === CakeRoute::SIGIL_QUERYSTRING) { + $query[substr($key, 1)] = $url[$key]; } } @@ -923,7 +926,7 @@ class Router { } } - if (empty($named) && empty($args) && (!isset($url['action']) || $url['action'] === 'index')) { + if (empty($named) && empty($args) && empty($query) && (!isset($url['action']) || $url['action'] === 'index')) { $url['action'] = null; } @@ -947,7 +950,6 @@ class Router { if (!empty($named)) { foreach ($named as $name => $value) { - $name = trim($name, ':'); if (is_array($value)) { $flattend = Set::flatten($value, ']['); foreach ($flattend as $namedKey => $namedValue) { @@ -958,6 +960,9 @@ class Router { } } } + if (!empty($query)) { + $output .= Router::queryString($query); + } return $output; } @@ -1070,6 +1075,10 @@ class Router { $params['pass'], $params['named'], $params['paging'], $params['models'], $params['url'], $url['url'], $params['autoRender'], $params['bare'], $params['requested'], $params['return'] ); + foreach ($named as $key => $value) { + $named[CakeRoute::SIGIL_NAMED . $key] = $value; + unset($named[$key]); + } $params = array_merge($params, $pass, $named); if (!empty($url)) { $params['?'] = $url; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index e05e50149..d9a57afc8 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -630,7 +630,7 @@ class RouterTest extends CakeTestCase { $request->webroot = '/'; Router::setRequestInfo($request); - $result = Router::url(array('page' => 2)); + $result = Router::url(array(':page' => 2)); $expected = '/admin/registrations/index/page:2'; $this->assertEqual($result, $expected); @@ -1546,12 +1546,12 @@ class RouterTest extends CakeTestCase { $expected = '/protected/others/edit/1'; $this->assertEqual($result, $expected); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'page' => 1)); + $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, ':page' => 1)); $expected = '/protected/others/edit/1/page:1'; $this->assertEqual($result, $expected); Router::connectNamed(array('random')); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'random' => 'my-value')); + $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, ':random' => 'my-value')); $expected = '/protected/others/edit/1/random:my-value'; $this->assertEqual($result, $expected); } @@ -1610,12 +1610,12 @@ class RouterTest extends CakeTestCase { $expected = '/protected/others/edit/1'; $this->assertEqual($result, $expected); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'page' => 1)); + $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, ':page' => 1)); $expected = '/protected/others/edit/1/page:1'; $this->assertEqual($result, $expected); Router::connectNamed(array('random')); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'random' => 'my-value')); + $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, ':random' => 'my-value')); $expected = '/protected/others/edit/1/random:my-value'; $this->assertEqual($result, $expected); } @@ -1721,7 +1721,7 @@ class RouterTest extends CakeTestCase { $this->assertEqual($result, $expected); $result = Router::url(array('controller' => 'my_controller', 'action' => 'my_action', 'base' => true)); - $expected = '/base/my_controller/my_action/base:1'; + $expected = '/base/my_controller/my_action'; $this->assertEqual($result, $expected); } @@ -1908,7 +1908,7 @@ class RouterTest extends CakeTestCase { $expected = array('pass' => array(), 'named' => array(), 'prefix' => 'members', 'plugin' => null, 'controller' => 'posts', 'action' => 'index', 'members' => true); $this->assertEqual($result, $expected); - $result = Router::url(array('members' => true, 'controller' => 'posts', 'action' =>'index', 'page' => 2)); + $result = Router::url(array('members' => true, 'controller' => 'posts', 'action' =>'index', ':page' => 2)); $expected = '/base/members/posts/index/page:2'; $this->assertEqual($result, $expected); @@ -2083,7 +2083,7 @@ class RouterTest extends CakeTestCase { $this->assertEqual($result, $expected); $result = Router::url(array('action' => 'test_another_action', 'locale' => 'badness')); - $expected = '/test/test_another_action/locale:badness'; + $expected = '/test/test_another_action'; $this->assertEqual($result, $expected); } From 51e2b16d46d96023d5ec4e11fcb32e9c52d91ce5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 17:24:38 -0500 Subject: [PATCH 324/378] Removing pagination test from Containable test case, it doesn't make sense there. --- .../libs/model/behaviors/containable.test.php | 106 ------------------ 1 file changed, 106 deletions(-) diff --git a/cake/tests/cases/libs/model/behaviors/containable.test.php b/cake/tests/cases/libs/model/behaviors/containable.test.php index d2ccdc5aa..b5dbabe52 100644 --- a/cake/tests/cases/libs/model/behaviors/containable.test.php +++ b/cake/tests/cases/libs/model/behaviors/containable.test.php @@ -3191,112 +3191,6 @@ class ContainableBehaviorTest extends CakeTestCase { $this->assertEqual($result, $expected); } -/** - * testPaginate method - * - * @access public - * @return void - */ - function testPaginate() { - App::import('Core', 'Controller'); - $Controller = new Controller($this->getMock('CakeRequest')); - $Controller->uses = array('Article'); - $Controller->passedArgs[] = '1'; - $Controller->request->params['url'] = array(); - $Controller->constructClasses(); - - $Controller->paginate = array('Article' => array('fields' => array('title'), 'contain' => array('User(user)'))); - $result = $Controller->paginate('Article'); - $expected = array( - array('Article' => array('title' => 'First Article'), 'User' => array('user' => 'mariano', 'id' => 1)), - array('Article' => array('title' => 'Second Article'), 'User' => array('user' => 'larry', 'id' => 3)), - array('Article' => array('title' => 'Third Article'), 'User' => array('user' => 'mariano', 'id' => 1)), - ); - $this->assertEqual($result, $expected); - - $r = $Controller->Article->find('all'); - $this->assertTrue(Set::matches('/Article[id=1]', $r)); - $this->assertTrue(Set::matches('/User[id=1]', $r)); - $this->assertTrue(Set::matches('/Tag[id=1]', $r)); - - $Controller->paginate = array('Article' => array('contain' => array('Comment(comment)' => 'User(user)'), 'fields' => array('title'))); - $result = $Controller->paginate('Article'); - $expected = array( - array( - 'Article' => array('title' => 'First Article', 'id' => 1), - 'Comment' => array( - array( - 'comment' => 'First Comment for First Article', - 'user_id' => 2, - 'article_id' => 1, - 'User' => array('user' => 'nate') - ), - array( - 'comment' => 'Second Comment for First Article', - 'user_id' => 4, - 'article_id' => 1, - 'User' => array('user' => 'garrett') - ), - array( - 'comment' => 'Third Comment for First Article', - 'user_id' => 1, - 'article_id' => 1, - 'User' => array('user' => 'mariano') - ), - array( - 'comment' => 'Fourth Comment for First Article', - 'user_id' => 1, - 'article_id' => 1, - 'User' => array('user' => 'mariano') - ) - ) - ), - array( - 'Article' => array('title' => 'Second Article', 'id' => 2), - 'Comment' => array( - array( - 'comment' => 'First Comment for Second Article', - 'user_id' => 1, - 'article_id' => 2, - 'User' => array('user' => 'mariano') - ), - array( - 'comment' => 'Second Comment for Second Article', - 'user_id' => 2, - 'article_id' => 2, - 'User' => array('user' => 'nate') - ) - ) - ), - array( - 'Article' => array('title' => 'Third Article', 'id' => 3), - 'Comment' => array() - ), - ); - $this->assertEqual($result, $expected); - - $r = $Controller->Article->find('all'); - $this->assertTrue(Set::matches('/Article[id=1]', $r)); - $this->assertTrue(Set::matches('/User[id=1]', $r)); - $this->assertTrue(Set::matches('/Tag[id=1]', $r)); - - $Controller->Article->unbindModel(array('hasMany' => array('Comment'), 'belongsTo' => array('User'), 'hasAndBelongsToMany' => array('Tag')), false); - $Controller->Article->bindModel(array('hasMany' => array('Comment'), 'belongsTo' => array('User')), false); - - $Controller->paginate = array('Article' => array('contain' => array('Comment(comment)', 'User(user)'), 'fields' => array('title'))); - $r = $Controller->paginate('Article'); - $this->assertTrue(Set::matches('/Article[id=1]', $r)); - $this->assertTrue(Set::matches('/User[id=1]', $r)); - $this->assertTrue(Set::matches('/Comment[article_id=1]', $r)); - $this->assertFalse(Set::matches('/Comment[id=1]', $r)); - - $r = $this->Article->find('all'); - $this->assertTrue(Set::matches('/Article[id=1]', $r)); - $this->assertTrue(Set::matches('/User[id=1]', $r)); - $this->assertTrue(Set::matches('/Comment[article_id=1]', $r)); - $this->assertTrue(Set::matches('/Comment[id=1]', $r)); - } - /** * testOriginalAssociations method * From 4c3736a68aa16c7c6d815c86b9ed2dec12433fa2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 17:38:21 -0500 Subject: [PATCH 325/378] Making more tests pass with the named parameter changes. --- cake/libs/http_socket.php | 4 ++-- cake/libs/route/redirect_route.php | 7 +++---- cake/tests/cases/libs/controller/controller.test.php | 3 ++- cake/tests/cases/libs/view/helper.test.php | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index ba56034bd..1a486742c 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -539,7 +539,7 @@ class HttpSocket extends CakeSocket { if (!method_exists($authClass, 'authentication')) { throw new SocketException(sprintf(__('The %s do not support authentication.'), $authClass)); } - call_user_func("$authClass::authentication", $this, $this->_auth[$method]); + call_user_func_array("$authClass::authentication", array($this, &$this->_auth[$method])); } /** @@ -565,7 +565,7 @@ class HttpSocket extends CakeSocket { if (!method_exists($authClass, 'proxyAuthentication')) { throw new SocketException(sprintf(__('The %s do not support proxy authentication.'), $authClass)); } - call_user_func("$authClass::proxyAuthentication", $this, $this->_proxy); + call_user_func_array("$authClass::proxyAuthentication", array($this, &$this->_proxy)); } /** diff --git a/cake/libs/route/redirect_route.php b/cake/libs/route/redirect_route.php index e385dec0d..d9beaa42d 100644 --- a/cake/libs/route/redirect_route.php +++ b/cake/libs/route/redirect_route.php @@ -70,16 +70,15 @@ class RedirectRoute extends CakeRoute { } if (isset($this->options['persist']) && is_array($redirect)) { $argOptions['context'] = array('action' => $redirect['action'], 'controller' => $redirect['controller']); - $args = Router::getArgs($params['_args_'], $argOptions); - $redirect += $args['pass']; - $redirect += $args['named']; + $redirect += Router::getArgs($params['_args_'], $argOptions) + array('url' => array()); + $redirect = Router::reverse($redirect); } $status = 301; if (isset($this->options['status']) && ($this->options['status'] >= 300 && $this->options['status'] < 400)) { $status = $this->options['status']; } $this->response->header(array('Location' => Router::url($redirect, true))); - $this->response->statusCode($status); + $this->response->statusCode($status); $this->response->send(); } diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 39563931b..91165cd22 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -1266,7 +1266,8 @@ class ControllerTest extends CakeTestCase { $Controller->passedArgs[] = '1'; $Controller->params['url'] = array(); $Controller->constructClasses(); - $this->assertEqual($Controller->paginate, array('page' => 1, 'limit' => 20)); + $expected = array('page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named'); + $this->assertEqual($Controller->paginate, $expected); $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); $this->assertEqual($results, array(1, 2, 3)); diff --git a/cake/tests/cases/libs/view/helper.test.php b/cake/tests/cases/libs/view/helper.test.php index 4ef761091..9e57e3028 100644 --- a/cake/tests/cases/libs/view/helper.test.php +++ b/cake/tests/cases/libs/view/helper.test.php @@ -477,7 +477,7 @@ class HelperTest extends CakeTestCase { $result = $this->Helper->url('/controller/action/1?one=1&two=2'); $this->assertEqual($result, '/controller/action/1?one=1&two=2'); - $result = $this->Helper->url(array('controller' => 'posts', 'action' => 'index', 'page' => '1" onclick="alert(\'XSS\');"')); + $result = $this->Helper->url(array('controller' => 'posts', 'action' => 'index', ':page' => '1" onclick="alert(\'XSS\');"')); $this->assertEqual($result, "/posts/index/page:1" onclick="alert('XSS');""); $result = $this->Helper->url('/controller/action/1/param:this+one+more'); @@ -490,12 +490,12 @@ class HelperTest extends CakeTestCase { $this->assertEqual($result, '/controller/action/1/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24'); $result = $this->Helper->url(array( - 'controller' => 'posts', 'action' => 'index', 'param' => '%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24' + 'controller' => 'posts', 'action' => 'index', ':param' => '%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24' )); $this->assertEqual($result, "/posts/index/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24"); $result = $this->Helper->url(array( - 'controller' => 'posts', 'action' => 'index', 'page' => '1', + 'controller' => 'posts', 'action' => 'index', ':page' => '1', '?' => array('one' => 'value', 'two' => 'value', 'three' => 'purple') )); $this->assertEqual($result, "/posts/index/page:1?one=value&two=value&three=purple"); From 025ba238863cb52c51ce916491f3da11c6010a03 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 20:05:57 -0500 Subject: [PATCH 326/378] Removing whitespace and adding some more documentation. --- cake/libs/router.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index f4cfa32fd..8d76a7ba5 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -300,7 +300,9 @@ class Router { } /** - * Specifies what named parameters CakePHP should be parsing. The most common setups are: + * Specifies what named parameters CakePHP should be parsing out of incoming urls. By default + * CakePHP will parse every named parameter out of incoming URLs. However, if you want to take more + * control over how named parameters are parsed you can use one of the following setups: * * Do not parse any named parameters: * @@ -342,8 +344,6 @@ class Router { * @return array */ public static function connectNamed($named, $options = array()) { - - if (isset($options['argSeparator'])) { self::$named['separator'] = $options['argSeparator']; unset($options['argSeparator']); @@ -385,7 +385,6 @@ class Router { * @return void */ public static function defaults($connect = true) { - self::$_connectDefaults = $connect; } @@ -403,7 +402,6 @@ class Router { * @return array Array of mapped resources */ public static function mapResources($controller, $options = array()) { - $options = array_merge(array('prefix' => '/', 'id' => self::$__named['ID'] . '|' . self::$__named['UUID']), $options); $prefix = $options['prefix']; @@ -430,7 +428,6 @@ class Router { * @return array A list of prefixes used in connected routes */ public static function prefixes() { - return self::$_prefixes; } @@ -441,8 +438,6 @@ class Router { * @return array Parsed elements from URL */ public static function parse($url) { - - if (!self::$_defaultsMapped && self::$_connectDefaults) { self::__connectDefaultRoutes(); } From d3fc29c8e83642a20fe9f96d0d782e903d524180 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 21:49:17 -0500 Subject: [PATCH 327/378] Adding more documentation to connectNamed(). Changing argSeparator -> separator, as it is less typing and easier to remember. --- cake/libs/router.php | 18 +++++++++++++----- cake/tests/cases/libs/router.test.php | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 8d76a7ba5..29e38dc3a 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -89,7 +89,7 @@ class Router { * @access public */ public static $named = array( - 'default' => array(':page', ':fields', ':order', ':limit', ':recursive', ':sort', ':direction', ':step'), + 'default' => array('page', 'fields', 'order', 'limit', 'recursive', 'sort', 'direction', 'step'), 'greedy' => true, 'separator' => ':', 'rules' => false, @@ -316,7 +316,7 @@ class Router { * * {{{ Router::connectNamed(array('page' => '[\d]+'), array('default' => false, 'greedy' => false)); }}} * - * Parse only the page parameter no mater what. + * Parse only the page parameter no matter what. * * {{{ Router::connectNamed(array('page'), array('default' => false, 'greedy' => false)); }}} * @@ -338,15 +338,23 @@ class Router { * ); * }}} * + * ### Options + * + * - `greedy` Setting this to true will make Router parse all named params. Setting it to false will + * parse only the connected named params. + * - `default` Set this to true to merge in the default set of named parameters. + * - `reset` Set to true to clear existing rules and start fresh. + * - `separator` Change the string used to separate the key & value in a named parameter. Defaults to `:` + * * @param array $named A list of named parameters. Key value pairs are accepted where values are * either regex strings to match, or arrays as seen above. * @param array $options Allows to control all settings: separator, greedy, reset, default * @return array */ public static function connectNamed($named, $options = array()) { - if (isset($options['argSeparator'])) { - self::$named['separator'] = $options['argSeparator']; - unset($options['argSeparator']); + if (isset($options['separator'])) { + self::$named['separator'] = $options['separator']; + unset($options['separator']); } if ($named === true || $named === false) { diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index d9a57afc8..c44f27619 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1335,14 +1335,14 @@ class RouterTest extends CakeTestCase { Router::reload(); Router::connect('/foo/*', array('controller' => 'bar', 'action' => 'fubar')); - Router::connectNamed(array(), array('argSeparator' => '=')); + Router::connectNamed(array(), array('separator' => '=')); $result = Router::parse('/foo/param1=value1/param2=value2'); $expected = array('pass' => array(), 'named' => array('param1' => 'value1', 'param2' => 'value2'), 'controller' => 'bar', 'action' => 'fubar', 'plugin' => null); $this->assertEqual($result, $expected); Router::reload(); Router::connect('/controller/action/*', array('controller' => 'controller', 'action' => 'action'), array('named' => array('param1' => 'value[\d]'))); - Router::connectNamed(array(), array('greedy' => false, 'argSeparator' => '=')); + Router::connectNamed(array(), array('greedy' => false, 'separator' => '=')); $result = Router::parse('/controller/action/param1=value1/param2=value2'); $expected = array('pass' => array('param2=value2'), 'named' => array('param1' => 'value1'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); $this->assertEqual($result, $expected); From b49b49a5ef4656f23d51bcfcf8553338a50df9bb Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 22:17:57 -0500 Subject: [PATCH 328/378] Removing named parameter sigils. --- cake/libs/route/cake_route.php | 42 +++++++++++-------- cake/libs/router.php | 4 +- .../cases/libs/route/cake_route.test.php | 12 +++--- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 7e4af3384..364b18641 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -284,27 +284,19 @@ class CakeRoute { return false; } + $greedyNamed = Router::$named['greedy']; + $allowedNamedParams = Router::$named['rules']; + $named = $pass = $_query = array(); foreach ($url as $key => $value) { - // pull out named params so comparisons later on are faster. - if ($key[0] === CakeRoute::SIGIL_NAMED && ($value !== false && $value !== null)) { - $named[substr($key, 1)] = $value; - unset($url[$key]); - continue; - } - - // pull out querystring params - if ($key[0] === CakeRoute::SIGIL_QUERYSTRING && ($value !== false && $value !== null)) { - $_query[substr($key, 1)] = $value; - unset($url[$key]); - continue; - } - // keys that exist in the defaults and have different values cause match failures. - $keyExists = array_key_exists($key, $defaults); - if ($keyExists && $defaults[$key] != $value) { + // keys that exist in the defaults and have different values is a match failure. + $defaultExists = array_key_exists($key, $defaults); + if ($defaultExists && $defaults[$key] != $value) { return false; + } elseif ($defaultExists) { + continue; } // If the key is a routed key, its not different yet. @@ -322,8 +314,24 @@ class CakeRoute { continue; } + // pull out querystring params + if ($key[0] === CakeRoute::SIGIL_QUERYSTRING && ($value !== false && $value !== null)) { + $_query[substr($key, 1)] = $value; + unset($url[$key]); + continue; + } + + // pull out named params if named params are greedy or a rule exists. + if ( + ($greedyNamed || isset($allowedNamedParams[$key])) && + ($value !== false && $value !== null) + ) { + $named[$key] = $value; + continue; + } + // keys that don't exist are different. - if (!$keyExists && !empty($value)) { + if (!$defaultExists && !empty($value)) { return false; } } diff --git a/cake/libs/router.php b/cake/libs/router.php index 29e38dc3a..76e801aec 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -914,10 +914,10 @@ class Router { $key = $keys[$i]; if (is_numeric($keys[$i])) { $args[] = $url[$key]; - } elseif ($key[0] === CakeRoute::SIGIL_NAMED) { - $named[substr($key, 1)] = $url[$key]; } elseif ($key[0] === CakeRoute::SIGIL_QUERYSTRING) { $query[substr($key, 1)] = $url[$key]; + } else { + $named[$key] = $url[$key]; } } diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index 3107e0084..0831ab814 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -310,7 +310,7 @@ class CakeRouteTestCase extends CakeTestCase { */ function testGreedyRouteFailureNamedParam() { $route = new CakeRoute('/:controller/:action', array('plugin' => null)); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', ':page' => 1)); + $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'page' => 1)); $this->assertFalse($result); } @@ -334,9 +334,9 @@ class CakeRouteTestCase extends CakeTestCase { */ function testMatchWithNamedParametersAndPassedArgs() { Router::connectNamed(true); - +/* $route = new CakeRoute('/:controller/:action/*', array('plugin' => null)); - $result = $route->match(array('controller' => 'posts', 'action' => 'index', 'plugin' => null, ':page' => 1)); + $result = $route->match(array('controller' => 'posts', 'action' => 'index', 'plugin' => null, 'page' => 1)); $this->assertEqual($result, '/posts/index/page:1'); $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5)); @@ -348,9 +348,9 @@ class CakeRouteTestCase extends CakeTestCase { $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, '0')); $this->assertEqual($result, '/posts/view/0'); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5, ':page' => 1, ':limit' => 20, ':order' => 'title')); + $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5, 'page' => 1, 'limit' => 20, 'order' => 'title')); $this->assertEqual($result, '/posts/view/5/page:1/limit:20/order:title'); - +*/ $route = new CakeRoute('/test2/*', array('controller' => 'pages', 'action' => 'display', 2)); $result = $route->match(array('controller' => 'pages', 'action' => 'display', 1)); @@ -370,7 +370,7 @@ class CakeRouteTestCase extends CakeTestCase { */ function testNamedParamsWithNullFalse() { $route = new CakeRoute('/:controller/:action/*'); - $result = $route->match(array('controller' => 'posts', 'action' => 'index', ':page' => null, 'sort' => false)); + $result = $route->match(array('controller' => 'posts', 'action' => 'index', 'page' => null, 'sort' => false)); $this->assertEquals('/posts/index/', $result); } From e5588f746c9885288a572db5f1f4bd2cd00da597 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 19 Dec 2010 23:11:02 -0500 Subject: [PATCH 329/378] Reversing changes that required a : sigil for named parameters. Also removing ?foo style parameters for querystring args. Having two ways to create querystring args was not sitting well with me. Tests updated. --- cake/libs/controller/components/paginator.php | 3 +- cake/libs/route/cake_route.php | 20 --------- cake/libs/router.php | 6 --- cake/libs/view/helpers/paginator.php | 22 +++------- .../cases/libs/route/cake_route.test.php | 39 +--------------- cake/tests/cases/libs/router.test.php | 44 +++++++++---------- cake/tests/cases/libs/view/helper.test.php | 6 +-- .../libs/view/helpers/paginator.test.php | 22 +++++----- 8 files changed, 46 insertions(+), 116 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index caa911c06..b69f75a2b 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -63,9 +63,8 @@ class PaginatorComponent extends Component { * - `limit` The initial number of items per page. Defaults to 20. * - `page` The starting page, defaults to 1. * - `paramType` What type of parameters you want pagination to use? - * - `named` Use named parameters. + * - `named` Use named parameters / routed parameters. * - `querystring` Use query string parameters. - * - `route` Use routed parameters, these require you to setup routes that include the pagination params * * @var array */ diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 364b18641..a3a9413e9 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -73,16 +73,6 @@ class CakeRoute { */ protected $_compiledRoute = null; -/** - * Constant for the sigil that indicates a route param is a named parameter. - */ - const SIGIL_NAMED = ':'; - -/** - * Constant for the sigil that indicates a route param is a query string parameter. - */ - const SIGIL_QUERYSTRING = '?'; - /** * HTTP header shortcut map. Used for evaluating header-based route expressions. * @@ -314,13 +304,6 @@ class CakeRoute { continue; } - // pull out querystring params - if ($key[0] === CakeRoute::SIGIL_QUERYSTRING && ($value !== false && $value !== null)) { - $_query[substr($key, 1)] = $value; - unset($url[$key]); - continue; - } - // pull out named params if named params are greedy or a rule exists. if ( ($greedyNamed || isset($allowedNamedParams[$key])) && @@ -402,9 +385,6 @@ class CakeRoute { if (strpos($this->template, '*')) { $out = str_replace('*', $params['pass'], $out); } - if (!empty($params['_query'])) { - $out .= $this->queryString($params['_query']); - } $out = str_replace('//', '/', $out); return $out; } diff --git a/cake/libs/router.php b/cake/libs/router.php index 76e801aec..7e9157fde 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -914,8 +914,6 @@ class Router { $key = $keys[$i]; if (is_numeric($keys[$i])) { $args[] = $url[$key]; - } elseif ($key[0] === CakeRoute::SIGIL_QUERYSTRING) { - $query[substr($key, 1)] = $url[$key]; } else { $named[$key] = $url[$key]; } @@ -1078,10 +1076,6 @@ class Router { $params['pass'], $params['named'], $params['paging'], $params['models'], $params['url'], $url['url'], $params['autoRender'], $params['bare'], $params['requested'], $params['return'] ); - foreach ($named as $key => $value) { - $named[CakeRoute::SIGIL_NAMED . $key] = $value; - unset($named[$key]); - } $params = array_merge($params, $pass, $named); if (!empty($url)) { $params['?'] = $url; diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 5caaf7ed9..69da3a24a 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -119,12 +119,7 @@ class PaginatorHelper extends AppHelper { * @return void */ public function beforeRender($viewFile) { - $named = $this->request->params['named']; - foreach ($named as $key => $val) { - $named[CakeRoute::SIGIL_NAMED . $key] = $val; - unset($named[$key]); - } - $this->options['url'] = array_merge($this->request->params['pass'], $named); + $this->options['url'] = array_merge($this->request->params['pass'], $this->request->params['named']); parent::beforeRender($viewFile); } @@ -405,18 +400,15 @@ class PaginatorHelper extends AppHelper { * @return converted url params. */ protected function _convertUrlKeys($url, $type) { - $prefix = ''; - switch ($type) { - case 'named': - $prefix = CakeRoute::SIGIL_NAMED; - break; - case 'querystring': - $prefix = CakeRoute::SIGIL_QUERYSTRING; - break; + if ($type == 'named') { + return $url; + } + if (!isset($url['?'])) { + $url['?'] = array(); } foreach ($this->convertKeys as $key) { if (isset($url[$key])) { - $url[$prefix . $key] = $url[$key]; + $url['?'][$key] = $url[$key]; unset($url[$key]); } } diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index 0831ab814..c1433451c 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -334,7 +334,7 @@ class CakeRouteTestCase extends CakeTestCase { */ function testMatchWithNamedParametersAndPassedArgs() { Router::connectNamed(true); -/* + $route = new CakeRoute('/:controller/:action/*', array('plugin' => null)); $result = $route->match(array('controller' => 'posts', 'action' => 'index', 'plugin' => null, 'page' => 1)); $this->assertEqual($result, '/posts/index/page:1'); @@ -350,7 +350,7 @@ class CakeRouteTestCase extends CakeTestCase { $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5, 'page' => 1, 'limit' => 20, 'order' => 'title')); $this->assertEqual($result, '/posts/view/5/page:1/limit:20/order:title'); -*/ + $route = new CakeRoute('/test2/*', array('controller' => 'pages', 'action' => 'display', 2)); $result = $route->match(array('controller' => 'pages', 'action' => 'display', 1)); @@ -473,39 +473,4 @@ class CakeRouteTestCase extends CakeTestCase { $this->assertFalse($result); } -/** - * test sigil based query string params - * - * @return void - */ - function testQueryStringParams() { - $route = new CakeRoute('/:controller/:action/*'); - $result = $route->match(array('controller' => 'posts', 'action' => 'index', '?test' => 'value')); - $expected = '/posts/index/?test=value'; - $this->assertEquals($expected, $result); - - $result = $route->match(array( - 'controller' => 'posts', 'action' => 'index', '?test' => array(1, 2, 3) - )); - $expected = '/posts/index/?test%5B0%5D=1&test%5B1%5D=2&test%5B2%5D=3'; - $this->assertEquals($expected, $result); - - $result = $route->match(array( - 'controller' => 'posts', 'action' => 'index', '?test' => 'value', '?other' => 'value' - )); - $expected = '/posts/index/?test=value&other=value'; - $this->assertEquals($expected, $result); - } - -/** - * test that querystring params work with non greedy routes. - * - * @return void - */ - function testQueryStringNonGreedy() { - $route = new CakeRoute('/:controller/:action'); - $result = $route->match(array('controller' => 'posts', 'action' => 'index', '?test' => 'value')); - $expected = '/posts/index?test=value'; - $this->assertEquals($expected, $result); - } } \ No newline at end of file diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index c44f27619..c1ed8fb43 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -328,7 +328,7 @@ class RouterTest extends CakeTestCase { Router::connect('short_controller_name/:action/*', array('controller' => 'real_controller_name')); Router::parse('/'); - $result = Router::url(array('controller' => 'real_controller_name', ':page' => '1')); + $result = Router::url(array('controller' => 'real_controller_name', 'page' => '1')); $expected = '/short_controller_name/index/page:1'; $this->assertEqual($result, $expected); @@ -389,14 +389,14 @@ class RouterTest extends CakeTestCase { * @return void */ function testArrayNamedParameters() { - $result = Router::url(array('controller' => 'tests', ':pages' => array( + $result = Router::url(array('controller' => 'tests', 'pages' => array( 1, 2, 3 ))); $expected = '/tests/index/pages[0]:1/pages[1]:2/pages[2]:3'; $this->assertEqual($result, $expected); $result = Router::url(array('controller' => 'tests', - ':pages' => array( + 'pages' => array( 'param1' => array( 'one', 'two' @@ -408,7 +408,7 @@ class RouterTest extends CakeTestCase { $this->assertEqual($result, $expected); $result = Router::url(array('controller' => 'tests', - ':pages' => array( + 'pages' => array( 'param1' => array( 'one' => 1, 'two' => 2 @@ -420,7 +420,7 @@ class RouterTest extends CakeTestCase { $this->assertEqual($result, $expected); $result = Router::url(array('controller' => 'tests', - ':super' => array( + 'super' => array( 'nested' => array( 'array' => 'awesome', 'something' => 'else' @@ -431,7 +431,7 @@ class RouterTest extends CakeTestCase { $expected = '/tests/index/super[nested][array]:awesome/super[nested][something]:else/super[0]:cool'; $this->assertEqual($result, $expected); - $result = Router::url(array('controller' => 'tests', ':namedParam' => array( + $result = Router::url(array('controller' => 'tests', 'namedParam' => array( 'keyed' => 'is an array', 'test' ))); @@ -630,7 +630,7 @@ class RouterTest extends CakeTestCase { $request->webroot = '/'; Router::setRequestInfo($request); - $result = Router::url(array(':page' => 2)); + $result = Router::url(array('page' => 2)); $expected = '/admin/registrations/index/page:2'; $this->assertEqual($result, $expected); @@ -648,7 +648,7 @@ class RouterTest extends CakeTestCase { Router::parse('/'); - $result = Router::url(array(':page' => 3)); + $result = Router::url(array('page' => 3)); $expected = '/magazine/admin/subscriptions/index/page:3'; $this->assertEquals($expected, $result); @@ -860,7 +860,7 @@ class RouterTest extends CakeTestCase { $result = Router::url(array( 'lang' => 'en', - 'controller' => 'shows', 'action' => 'index', ':page' => '1', + 'controller' => 'shows', 'action' => 'index', 'page' => '1', )); $expected = '/en/shows/shows/page:1'; $this->assertEqual($result, $expected); @@ -1361,11 +1361,11 @@ class RouterTest extends CakeTestCase { * @return void */ function testNamedArgsUrlGeneration() { - $result = Router::url(array('controller' => 'posts', 'action' => 'index', ':published' => 1, ':deleted' => 1)); + $result = Router::url(array('controller' => 'posts', 'action' => 'index', 'published' => 1, 'deleted' => 1)); $expected = '/posts/index/published:1/deleted:1'; $this->assertEqual($result, $expected); - $result = Router::url(array('controller' => 'posts', 'action' => 'index', ':published' => 0, ':deleted' => 0)); + $result = Router::url(array('controller' => 'posts', 'action' => 'index', 'published' => 0, 'deleted' => 0)); $expected = '/posts/index/published:0/deleted:0'; $this->assertEqual($result, $expected); @@ -1375,11 +1375,11 @@ class RouterTest extends CakeTestCase { Router::connect('/', array('controller' => 'graphs', 'action' => 'index')); Router::connect('/:id/*', array('controller' => 'graphs', 'action' => 'view'), array('id' => $ID)); - $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 'id' => 12, ':file' => 'asdf.png')); + $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 'id' => 12, 'file' => 'asdf.png')); $expected = '/12/file:asdf.png'; $this->assertEqual($result, $expected); - $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 12, ':file' => 'asdf.foo')); + $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 12, 'file' => 'asdf.foo')); $expected = '/graphs/view/12/file:asdf.foo'; $this->assertEqual($result, $expected); @@ -1398,7 +1398,7 @@ class RouterTest extends CakeTestCase { ); Router::parse('/'); - $result = Router::url(array(':page' => 1, 0 => null, ':sort' => 'controller', ':direction' => 'asc', ':order' => null)); + $result = Router::url(array('page' => 1, 0 => null, 'sort' => 'controller', 'direction' => 'asc', 'order' => null)); $expected = "/admin/controller/index/page:1/sort:controller/direction:asc"; $this->assertEqual($result, $expected); @@ -1411,7 +1411,7 @@ class RouterTest extends CakeTestCase { Router::setRequestInfo($request); $result = Router::parse('/admin/controller/index/type:whatever'); - $result = Router::url(array(':type'=> 'new')); + $result = Router::url(array('type'=> 'new')); $expected = "/admin/controller/index/type:new"; $this->assertEqual($result, $expected); } @@ -1546,12 +1546,12 @@ class RouterTest extends CakeTestCase { $expected = '/protected/others/edit/1'; $this->assertEqual($result, $expected); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, ':page' => 1)); + $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'page' => 1)); $expected = '/protected/others/edit/1/page:1'; $this->assertEqual($result, $expected); Router::connectNamed(array('random')); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, ':random' => 'my-value')); + $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'random' => 'my-value')); $expected = '/protected/others/edit/1/random:my-value'; $this->assertEqual($result, $expected); } @@ -1610,12 +1610,12 @@ class RouterTest extends CakeTestCase { $expected = '/protected/others/edit/1'; $this->assertEqual($result, $expected); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, ':page' => 1)); + $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'page' => 1)); $expected = '/protected/others/edit/1/page:1'; $this->assertEqual($result, $expected); Router::connectNamed(array('random')); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, ':random' => 'my-value')); + $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'random' => 'my-value')); $expected = '/protected/others/edit/1/random:my-value'; $this->assertEqual($result, $expected); } @@ -1721,7 +1721,7 @@ class RouterTest extends CakeTestCase { $this->assertEqual($result, $expected); $result = Router::url(array('controller' => 'my_controller', 'action' => 'my_action', 'base' => true)); - $expected = '/base/my_controller/my_action'; + $expected = '/base/my_controller/my_action/base:1'; $this->assertEqual($result, $expected); } @@ -1908,7 +1908,7 @@ class RouterTest extends CakeTestCase { $expected = array('pass' => array(), 'named' => array(), 'prefix' => 'members', 'plugin' => null, 'controller' => 'posts', 'action' => 'index', 'members' => true); $this->assertEqual($result, $expected); - $result = Router::url(array('members' => true, 'controller' => 'posts', 'action' =>'index', ':page' => 2)); + $result = Router::url(array('members' => true, 'controller' => 'posts', 'action' =>'index', 'page' => 2)); $expected = '/base/members/posts/index/page:2'; $this->assertEqual($result, $expected); @@ -2083,7 +2083,7 @@ class RouterTest extends CakeTestCase { $this->assertEqual($result, $expected); $result = Router::url(array('action' => 'test_another_action', 'locale' => 'badness')); - $expected = '/test/test_another_action'; + $expected = '/test/test_another_action/locale:badness'; $this->assertEqual($result, $expected); } diff --git a/cake/tests/cases/libs/view/helper.test.php b/cake/tests/cases/libs/view/helper.test.php index 9e57e3028..4ef761091 100644 --- a/cake/tests/cases/libs/view/helper.test.php +++ b/cake/tests/cases/libs/view/helper.test.php @@ -477,7 +477,7 @@ class HelperTest extends CakeTestCase { $result = $this->Helper->url('/controller/action/1?one=1&two=2'); $this->assertEqual($result, '/controller/action/1?one=1&two=2'); - $result = $this->Helper->url(array('controller' => 'posts', 'action' => 'index', ':page' => '1" onclick="alert(\'XSS\');"')); + $result = $this->Helper->url(array('controller' => 'posts', 'action' => 'index', 'page' => '1" onclick="alert(\'XSS\');"')); $this->assertEqual($result, "/posts/index/page:1" onclick="alert('XSS');""); $result = $this->Helper->url('/controller/action/1/param:this+one+more'); @@ -490,12 +490,12 @@ class HelperTest extends CakeTestCase { $this->assertEqual($result, '/controller/action/1/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24'); $result = $this->Helper->url(array( - 'controller' => 'posts', 'action' => 'index', ':param' => '%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24' + 'controller' => 'posts', 'action' => 'index', 'param' => '%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24' )); $this->assertEqual($result, "/posts/index/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24"); $result = $this->Helper->url(array( - 'controller' => 'posts', 'action' => 'index', ':page' => '1', + 'controller' => 'posts', 'action' => 'index', 'page' => '1', '?' => array('one' => 'value', 'two' => 'value', 'three' => 'purple') )); $this->assertEqual($result, "/posts/index/page:1?one=value&two=value&three=purple"); diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index ab400702b..c52ec5e92 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -674,7 +674,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->sort('title'); $expected = array( - 'a' => array('href' => '/articles/index/2/foo:bar/page:1/sort:title/direction:asc'), + 'a' => array('href' => '/articles/index/2/page:1/foo:bar/sort:title/direction:asc'), 'Title', '/a' ); @@ -684,24 +684,24 @@ class PaginatorHelperTest extends CakeTestCase { $expected = array( array('span' => array('class' => 'current')), '1', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar/page:2')), '2', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/page:2/foo:bar')), '2', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar/page:3')), '3', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/page:3/foo:bar')), '3', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar/page:4')), '4', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/page:4/foo:bar')), '4', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar/page:5')), '5', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/page:5/foo:bar')), '5', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar/page:6')), '6', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/page:6/foo:bar')), '6', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar/page:7')), '7', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/page:7/foo:bar')), '7', '/a', '/span', ); $this->assertTags($result, $expected); $result = $this->Paginator->next('Next'); $expected = array( ' array('href' => '/articles/index/2/foo:bar/page:2', 'class' => 'next'), + 'a' => array('href' => '/articles/index/2/page:2/foo:bar', 'class' => 'next'), 'Next', '/a', '/span' @@ -915,10 +915,10 @@ class PaginatorHelperTest extends CakeTestCase { ) ); $this->Paginator->options(array('url' => array(12, 'page' => 3))); - $result = $this->Paginator->prev('Prev', array('url' => array(':foo' => 'bar'))); + $result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar'))); $expected = array( ' array('href' => '/index/12/foo:bar/page:1/limit:10', 'class' => 'prev'), + 'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev'), 'Prev', '/a', '/span' @@ -2199,7 +2199,7 @@ class PaginatorHelperTest extends CakeTestCase { function testQuerystringLinkGeneration() { $this->Paginator->request->params['paging']['Article']['paramType'] = 'querystring'; $result = $this->Paginator->url(array('page' => '4')); - $expected = '/index?page=4'; + $expected = '/?page=4'; $this->assertEquals($expected, $result); } From d7e411650fee8ebb1b33b24d63c66c806649807e Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 20 Dec 2010 13:39:22 -0500 Subject: [PATCH 330/378] Moving some tests around so its easier to figure out what's being tested. Adding a querystring test. --- .../libs/view/helpers/paginator.test.php | 110 +++++++++--------- 1 file changed, 53 insertions(+), 57 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index c52ec5e92..54602424f 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -47,6 +47,7 @@ class PaginatorHelperTest extends CakeTestCase { $this->Paginator->request->addParams(array( 'paging' => array( 'Article' => array( + 'page' => 2, 'current' => 9, 'count' => 62, 'prevPage' => false, @@ -1763,6 +1764,51 @@ class PaginatorHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * test first() and last() with tag options + * + * @return void + */ + function testFirstAndLastTag() { + $result = $this->Paginator->first('<<', array('tag' => 'li')); + $expected = array( + ' array('href' => '/index/page:1'), + '<<', + '/a', + '/li' + ); + $this->assertTags($result, $expected); + + $result = $this->Paginator->last(2, array('tag' => 'li')); + + $expected = array( + '...', + ' array('href' => '/index/page:6')), '6', '/a', + '/li', + ' | ', + ' array('href' => '/index/page:7')), '7', '/a', + '/li', + ); + $this->assertTags($result, $expected); + } + +/** + * test that on the last page you don't get a link ot the last page. + * + * @return void + */ + function testLastNoOutput() { + $this->Paginator->request->params['paging']['Article']['page'] = 15; + $this->Paginator->request->params['paging']['Article']['pageCount'] = 15; + + $result = $this->Paginator->last(); + $expected = ''; + $this->assertEqual($result, $expected); + } + /** * testFirstAndLast method * @@ -1787,20 +1833,7 @@ class PaginatorHelperTest extends CakeTestCase { $expected = ''; $this->assertEqual($result, $expected); - $this->Paginator->request->params['paging'] = array( - 'Client' => array( - 'page' => 4, - 'current' => 3, - 'count' => 30, - 'prevPage' => false, - 'nextPage' => 2, - 'pageCount' => 15, - 'options' => array( - 'page' => 1, - ), - 'paramType' => 'named' - ) - ); + $this->Paginator->request->params['paging']['Client']['page'] = 4; $result = $this->Paginator->first(); $expected = array( @@ -1812,16 +1845,6 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $result = $this->Paginator->first('<<', array('tag' => 'li')); - $expected = array( - ' array('href' => '/index/page:1'), - '<<', - '/a', - '/li' - ); - $this->assertTags($result, $expected); - $result = $this->Paginator->last(); $expected = array( 'assertTags($result, $expected); - $result = $this->Paginator->last(2, array('tag' => 'li')); - $expected = array( - '...', - ' array('href' => '/index/page:14')), '14', '/a', - '/li', - ' | ', - ' array('href' => '/index/page:15')), '15', '/a', - '/li', - ); - $this->assertTags($result, $expected); - - $this->Paginator->request->params['paging'] = array( - 'Client' => array( - 'page' => 15, - 'current' => 3, - 'count' => 30, - 'prevPage' => false, - 'nextPage' => 2, - 'pageCount' => 15, - 'options' => array( - 'page' => 1, - ), - 'paramType' => 'named' - ) - ); - $result = $this->Paginator->last(); - $expected = ''; - $this->assertEqual($result, $expected); - $this->Paginator->request->params['paging'] = array( 'Client' => array( 'page' => 4, @@ -2192,15 +2184,19 @@ class PaginatorHelperTest extends CakeTestCase { } /** - * test that querystring links can be generated. + * test that querystring urls can be generated. * * @return void */ - function testQuerystringLinkGeneration() { + function testQuerystringUrlGeneration() { $this->Paginator->request->params['paging']['Article']['paramType'] = 'querystring'; $result = $this->Paginator->url(array('page' => '4')); $expected = '/?page=4'; $this->assertEquals($expected, $result); + + $result = $this->Paginator->url(array('page' => '4', 'limit' => 10, 'something' => 'else')); + $expected = '/index/something:else?page=4&limit=10'; + $this->assertEquals($expected, $result); } } From 0b90195a5256118858c35369b1e2cfef75e025da Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 20 Dec 2010 13:59:09 -0500 Subject: [PATCH 331/378] Adding tests for creating next/prev links with querystrings. Removing code that doesn't seem to do anything, no tests fail when its removed. --- cake/libs/view/helpers/paginator.php | 3 +- .../libs/view/helpers/paginator.test.php | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 69da3a24a..6f7145643 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -357,11 +357,10 @@ class PaginatorHelper extends AppHelper { $url = array_merge((array)$options['url'], (array)$url); unset($options['url']); } + $url = $this->url($url, true, $model); $obj = isset($options['update']) ? $this->_ajaxHelperClass : 'Html'; - $url = array_merge(array('page' => $this->current($model)), $url); - $url = array_merge(Set::filter($url, true), array_intersect_key($url, array('plugin' => true))); return $this->{$obj}->link($title, $url, $options); } diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 54602424f..2bad399f4 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -2199,4 +2199,36 @@ class PaginatorHelperTest extends CakeTestCase { $this->assertEquals($expected, $result); } +/** + * test querystring paging link. + * + * @return void + */ + function testQuerystringNextAndPrev() { + $this->Paginator->request->params['paging']['Article']['paramType'] = 'querystring'; + $this->Paginator->request->params['paging']['Article']['page'] = 2; + $this->Paginator->request->params['paging']['Article']['nextPage'] = true; + $this->Paginator->request->params['paging']['Article']['prevPage'] = true; + + $result = $this->Paginator->next('Next'); + $expected = array( + ' array('href' => '/?page=3', 'class' => 'next'), + 'Next', + '/a', + '/span' + ); + $this->assertTags($result, $expected); + + $result = $this->Paginator->prev('Prev'); + $expected = array( + ' array('href' => '/?page=1', 'class' => 'prev'), + 'Prev', + '/a', + '/span' + ); + $this->assertTags($result, $expected); + } + } From abc6a28ecaac6b74972408ae1aceaf39b77725ca Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 20 Dec 2010 14:02:12 -0500 Subject: [PATCH 332/378] Increasing code coverage. --- .../cases/libs/view/helpers/paginator.test.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 2bad399f4..b0c5ae18c 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -2231,4 +2231,17 @@ class PaginatorHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * test the current() method + * + * @return void + */ + function testCurrent() { + $result = $this->Paginator->current(); + $this->assertEquals($this->Paginator->request->params['paging']['Article']['page'], $result); + + $result = $this->Paginator->current('Incorrect'); + $this->assertEquals(1, $result); + } + } From 6f62c22cbc0ca1aed6ee80cee1a3ec141171f7aa Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 20 Dec 2010 20:27:27 -0500 Subject: [PATCH 333/378] Fixing fencepost errors. Splitting tests up into smaller groups. --- cake/libs/view/helpers/paginator.php | 4 +- .../libs/view/helpers/paginator.test.php | 119 ++++++++++-------- 2 files changed, 68 insertions(+), 55 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 6f7145643..f7369e408 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -754,7 +754,7 @@ class PaginatorHelper extends AppHelper { $out = ''; - if (is_int($first) && $params['page'] > $first) { + if (is_int($first) && $params['page'] >= $first) { if ($after === null) { $after = $ellipsis; } @@ -811,7 +811,7 @@ class PaginatorHelper extends AppHelper { $out = ''; $lower = $params['pageCount'] - $last + 1; - if (is_int($last) && $params['page'] < $lower) { + if (is_int($last) && $params['page'] <= $lower) { if ($before === null) { $before = $ellipsis; } diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index b0c5ae18c..b5e37983b 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -1810,31 +1810,45 @@ class PaginatorHelperTest extends CakeTestCase { } /** - * testFirstAndLast method + * test first() on the first page. * - * @access public * @return void */ - function testFirstAndLast() { - $this->Paginator->request->params['paging'] = array( - 'Client' => array( - 'page' => 1, - 'current' => 3, - 'count' => 30, - 'prevPage' => false, - 'nextPage' => 2, - 'pageCount' => 15, - 'options' => array(), - 'paramType' => 'named' - ) - ); + function testFirstEmpty() { + $this->Paginator->request->params['paging']['Article']['page'] = 1; $result = $this->Paginator->first(); $expected = ''; $this->assertEqual($result, $expected); + } - $this->Paginator->request->params['paging']['Client']['page'] = 4; +/** + * test first() and options() + * + * @return void + */ + function testFirstFullBaseUrl() { + $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'DESC'); + $this->Paginator->options(array('url' => array('full_base' => true))); + + $result = $this->Paginator->first(); + $expected = array( + ' array('href' => FULL_BASE_URL . '/index/page:1/sort:Article.title/direction:DESC')), + '<< first', + '/a', + '/span', + ); + $this->assertTags($result, $expected); + } + +/** + * test first() on the fence-post + * + * @return void + */ + function testFirstBoundaries() { $result = $this->Paginator->first(); $expected = array( 'assertTags($result, $expected); + $result = $this->Paginator->first(2); + $expected = array( + ' array('href' => '/index/page:1')), '1', '/a', + '/span', + ' | ', + ' array('href' => '/index/page:2')), '2', '/a', + '/span' + ); + $this->assertTags($result, $expected); + } + +/** + * test Last method + * + * @access public + * @return void + */ + function testLast() { $result = $this->Paginator->last(); $expected = array( ' array('href' => '/index/page:15'), + 'a' => array('href' => '/index/page:7'), 'last >>', '/a', '/span' @@ -1859,26 +1893,35 @@ class PaginatorHelperTest extends CakeTestCase { $expected = array( '...', ' array('href' => '/index/page:15'), - '15', + 'a' => array('href' => '/index/page:7'), + '7', '/a', '/span' ); $this->assertTags($result, $expected); + $this->Paginator->request->params['paging']['Article']['page'] = 6; + $result = $this->Paginator->last(2); $expected = array( '...', ' array('href' => '/index/page:14')), '14', '/a', + array('a' => array('href' => '/index/page:6')), '6', '/a', '/span', ' | ', ' array('href' => '/index/page:15')), '15', '/a', + array('a' => array('href' => '/index/page:7')), '7', '/a', '/span', ); $this->assertTags($result, $expected); - + } + +/** + * undocumented function + * + * @return void + */ + function testLastOptions() { $this->Paginator->request->params['paging'] = array( 'Client' => array( 'page' => 4, @@ -1895,14 +1938,6 @@ class PaginatorHelperTest extends CakeTestCase { ) ); - $result = $this->Paginator->first(); - $expected = array( - ' array('href' => '/index/page:1/sort:Client.name/direction:DESC')), '<< first', '/a', - '/span', - ); - $this->assertTags($result, $expected); - $result = $this->Paginator->last(); $expected = array( 'assertTags($result, $expected); - + $result = $this->Paginator->last(1); $expected = array( '...', @@ -1933,19 +1968,6 @@ class PaginatorHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $result = $this->Paginator->last(2, array('ellipsis' => '~~~')); - $expected = array( - '~~~', - ' array('href' => '/index/page:14/sort:Client.name/direction:DESC')), '14', '/a', - '/span', - ' | ', - ' array('href' => '/index/page:15/sort:Client.name/direction:DESC')), '15', '/a', - '/span', - ); - $this->assertTags($result, $expected); - $result = $this->Paginator->last(2, array('ellipsis' => '...')); $expected = array( array('span' => array('class' => 'ellipsis')), '...', '/span', @@ -1958,15 +1980,6 @@ class PaginatorHelperTest extends CakeTestCase { '/span', ); $this->assertTags($result, $expected); - - $this->Paginator->options(array('url' => array('full_base' => true))); - $result = $this->Paginator->first(); - $expected = array( - ' array('href' => FULL_BASE_URL . '/index/page:1/sort:Client.name/direction:DESC')), '<< first', '/a', - '/span', - ); - $this->assertTags($result, $expected); } /** From f85567a5666f7f9b5c52a93b8d146ff575f87593 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 21 Dec 2010 20:53:39 -0500 Subject: [PATCH 334/378] Removing @author tags that snuck in. --- cake/libs/cake_log.php | 1 - cake/tests/cases/libs/view/view.test.php | 1 - 2 files changed, 2 deletions(-) diff --git a/cake/libs/cake_log.php b/cake/libs/cake_log.php index afc8df033..997698ed9 100644 --- a/cake/libs/cake_log.php +++ b/cake/libs/cake_log.php @@ -50,7 +50,6 @@ interface CakeLogInterface { * @param string $type * @param string $message * @return void - * @author Mark Story */ public function write($type, $message); } diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index 9e4d7a44a..e50934dd9 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -121,7 +121,6 @@ class TestView extends View { * @param string $loadHelpers * @param string $cached * @return void - * @author Mark Story */ function render_($___viewFn, $___dataForView, $loadHelpers = true, $cached = false) { return $this->_render($___viewFn, $___dataForView, $loadHelpers, $cached); From 4312a26b2ff39945066daf78b0eb3954274eae0e Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 21 Dec 2010 21:59:25 -0500 Subject: [PATCH 335/378] Removing View::$autoRender it wasn't used. Removing @access tags, which just restated the visibility keywords. Adding documentation to a number of parameters and methods. --- cake/libs/cache.php | 26 ++++++++++--- cake/libs/view/view.php | 82 +++++++++++++++++------------------------ 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/cake/libs/cache.php b/cake/libs/cache.php index 17ba3f8d7..008c71b15 100644 --- a/cake/libs/cache.php +++ b/cake/libs/cache.php @@ -13,17 +13,33 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0.4933 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ /** - * Caching for CakePHP. + * Cache provides a consistent interface to Caching in your application. It allows you + * to use several different Cache engines, without coupling your application to a specific + * implementation. It also allows you to change out cache storage or configuration without effecting + * the rest of your application. * - * @package cake - * @subpackage cake.cake.libs + * You can configure Cache engines in your application's `bootstrap.php` file. A sample configuration would + * be + * + * {{{ + * Cache::config('shared', array( + * 'engine' => 'Apc', + * 'prefix' => 'my_app_' + * )); + * }}} + * + * This would configure an APC cache engine to the 'shared' alias. You could then read and write + * to that cache alias by using it for the `$config` parameter in the various Cache methods. In + * general all Cache operations are supported by all cache engines. However, Cache::increment() and + * Cache::decrement() are not supported by File caching. + * + * @package cake.libs */ class Cache { diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index af035292f..dba1a147b 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -25,12 +25,16 @@ App::import('View', 'HelperCollection', false); App::import('View', 'Helper', false); /** - * View, the V in the MVC triad. + * View, the V in the MVC triad. View interacts with Helpers and view variables passed + * in from the controller to render the results of the controller action. Often this is HTML, + * but can also take the form of JSON, XML, PDF's or streaming files. * - * Class holding methods for displaying presentation data. + * CakePHP uses a two-step-view pattern. This means that the view content is rendered first, + * and then inserted into the selected layout. A special `$content_for_layout` variable is available + * in the layout, and it contains the rendered view. This also means you can pass data from the view to the + * layout using `$this->set()` * - * @package cake - * @subpackage cake.cake.libs.view + * @package cake.libs.view */ class View extends Object { @@ -53,7 +57,6 @@ class View extends Object { * Name of the controller. * * @var string Name of controller - * @access public */ public $name = null; @@ -68,7 +71,6 @@ class View extends Object { * An array of names of built-in helpers to include. * * @var mixed A single name as a string or a list of names as an array. - * @access public */ public $helpers = array('Html'); @@ -83,7 +85,6 @@ class View extends Object { * Variables for the view * * @var array - * @access public */ public $viewVars = array(); @@ -91,7 +92,6 @@ class View extends Object { * Name of layout to use with this View. * * @var string - * @access public */ public $layout = 'default'; @@ -103,18 +103,10 @@ class View extends Object { public $layoutPath = null; /** - * Turns on or off Cake's conventional mode of rendering views. On by default. + * Turns on or off Cake's conventional mode of applying layout files. On by default. + * Setting to off means that layouts will not be automatically applied to rendered views. * * @var boolean - * @access public - */ - public $autoRender = true; - -/** - * Turns on or off Cake's conventional mode of finding layout files. On by default. - * - * @var boolean - * @access public */ public $autoLayout = true; @@ -122,23 +114,21 @@ class View extends Object { * File extension. Defaults to Cake's template ".ctp". * * @var string - * @access public */ public $ext = '.ctp'; /** - * Sub-directory for this view file. + * Sub-directory for this view file. This is often used for extension based routing. + * for example with an `xml` extension, $subDir would be `xml/` * * @var string - * @access public */ public $subDir = null; /** - * Theme name. + * Theme name. If you are using themes, you should remember to use ThemeView as well. * * @var string - * @access public */ public $theme = null; @@ -147,7 +137,6 @@ class View extends Object { * * @see Controller::$cacheAction * @var mixed - * @access public */ public $cacheAction = false; @@ -155,7 +144,6 @@ class View extends Object { * holds current errors for the model validation * * @var array - * @access public */ public $validationErrors = array(); @@ -163,7 +151,6 @@ class View extends Object { * True when the view has been rendered. * * @var boolean - * @access public */ public $hasRendered = false; @@ -171,7 +158,6 @@ class View extends Object { * True if in scope of model-specific region * * @var boolean - * @access public */ public $modelScope = false; @@ -179,7 +165,6 @@ class View extends Object { * Name of current model this view context is attached to * * @var string - * @access public */ public $model = null; @@ -187,7 +172,6 @@ class View extends Object { * Name of association model this view context is attached to * * @var string - * @access public */ public $association = null; @@ -195,7 +179,6 @@ class View extends Object { * Name of current model field this view context is attached to * * @var string - * @access public */ public $field = null; @@ -203,7 +186,6 @@ class View extends Object { * Suffix of current field this view context is attached to * * @var string - * @access public */ public $fieldSuffix = null; @@ -211,7 +193,6 @@ class View extends Object { * The current model ID this view context is attached to * * @var mixed - * @access public */ public $modelId = null; @@ -219,7 +200,6 @@ class View extends Object { * List of generated DOM UUIDs * * @var array - * @access public */ public $uuids = array(); @@ -227,7 +207,6 @@ class View extends Object { * Holds View output. * * @var string - * @access public */ public $output = false; @@ -254,10 +233,9 @@ class View extends Object { * List of variables to collect from the associated controller * * @var array - * @access protected */ private $__passedVars = array( - 'viewVars', 'autoLayout', 'autoRender', 'ext', 'helpers', 'layout', 'name', + 'viewVars', 'autoLayout', 'ext', 'helpers', 'layout', 'name', 'layoutPath', 'viewPath', 'request', 'plugin', 'passedArgs', 'cacheAction' ); @@ -265,7 +243,6 @@ class View extends Object { * Scripts (and/or other tags) for the layout * * @var array - * @access protected */ protected $_scripts = array(); @@ -273,7 +250,6 @@ class View extends Object { * Holds an array of paths. * * @var array - * @access private */ private $__paths = array(); @@ -304,9 +280,8 @@ class View extends Object { /** * Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string. * - * This realizes the concept of Elements, (or "partial layouts") - * and the $params array is used to send data to be used in the - * Element. Elements can be cached through use of the cache key. + * This realizes the concept of Elements, (or "partial layouts") and the $params array is used to send + * data to be used in the element. Elements can be cached improving performance by using the `cache` option. * * ### Special params * @@ -381,9 +356,20 @@ class View extends Object { * Renders view for given action and layout. If $file is given, that is used * for a view filename (e.g. customFunkyView.ctp). * - * @param string $action Name of action to render for - * @param string $layout Layout to use - * @param string $file Custom filename for view + * Render triggers helper callbacks, which are fired before and after the view are rendered, + * as well as before and after the layout. The helper callbacks are called + * + * - `beforeRender` + * - `afterRender` + * - `beforeLayout` + * - `afterLayout` + * + * If View::$autoRender is false and no `$layout` is provided, the view will be returned bare. + * + * @param string $action Name of action to render for, this will be used as the filename to render, unless + * $file is give as well. + * @param string $layout Layout to use. + * @param string $file Custom filename for view. Providing this will render a specific file for the given action. * @return string Rendered Element * @throws CakeException if there is an error in the view. */ @@ -582,7 +568,7 @@ class View extends Object { /** * Allows a template or element to set a variable that will be available in - * a layout or other element. Analagous to Controller::set. + * a layout or other element. Analagous to Controller::set(). * * @param mixed $one A string or an array of data. * @param mixed $two Value in case $one is a string (which then works as the key). @@ -648,12 +634,10 @@ class View extends Object { * array of data. * * @param string $___viewFn Filename of the view - * @param array $___dataForView Data to include in rendered view - * @param boolean $loadHelpers Boolean to indicate that helpers should be loaded. - * @param boolean $cached Whether or not to trigger the creation of a cache file. + * @param array $___dataForView Data to include in rendered view. If empty the current View::$viewVars will be used. * @return string Rendered output */ - protected function _render($___viewFn, $___dataForView = array(), $loadHelpers = true, $cached = false) { + protected function _render($___viewFn, $___dataForView = array()) { if (empty($___dataForView)) { $___dataForView = $this->viewVars; } From d5589d26bd6b8c25b90deac6c557fbcf3fe78107 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 21 Dec 2010 22:27:17 -0500 Subject: [PATCH 336/378] more doc blocks. --- cake/libs/controller/controller.php | 40 ++++++++++++++++++++--------- cake/libs/router.php | 20 ++++++++++++--- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index de0553b01..7f91f5dd9 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -27,15 +27,28 @@ App::import('Controller', 'Component', false); App::import('View', 'View', false); /** - * Controller - * * Application controller class for organization of business logic. * Provides basic functionality, such as rendering views inside layouts, * automatic model availability, redirection, callbacks, and more. * - * @package cake - * @subpackage cake.cake.libs.controller - * @link http://book.cakephp.org/view/956/Introduction + * Controllers should provide a number of 'action' methods. These are public methods on the controller + * that are not prefixed with a '_' and not part of Controller. Each action serves as an endpoint for + * performing a specific action on a resource or collection of resources. For example adding or editing a new + * object, or listing a set of objects. + * + * You can access request parameters, using `$this->request`. The request object contains all the POST, GET and FILES + * that were part of the request. + * + * After performing the required actions, controllers are responsible for creating a response. This usually + * takes the form of a generated View, or possibly a redirection to another controller action. In either case + * `$this->response` allows you to manipulate all aspects of the response. + * + * Controllers are created by Dispatcher based on request parameters and routing. By default controllers and actions + * use conventional names. For example `/posts/index` maps to `PostsController::index()`. You can re-map urls + * using Router::connect(). + * + * @package cake.libs.controller + * @link http://book.cakephp.org/view/956/Introduction */ class Controller extends Object { @@ -148,7 +161,7 @@ class Controller extends Object { public $autoLayout = true; /** - * Instance of Component used to handle callbacks. + * Instance of ComponentCollection used to handle callbacks. * * @var string */ @@ -240,7 +253,8 @@ class Controller extends Object { public $scaffold = false; /** - * Holds current methods of the controller + * Holds current methods of the controller. This is a list of all the methods reachable + * via url. Modifying this array, will allow you to change which methods can be reached. * * @var array */ @@ -550,7 +564,7 @@ class Controller extends Object { * * @return mixed Associative array of the HTTP codes as keys, and the message * strings as values, or null of the given $code does not exist. - * @deprecated + * @deprecated Use CakeResponse::httpCodes(); */ public function httpCodes($code = null) { return $this->response->httpCodes($code); @@ -671,7 +685,7 @@ class Controller extends Object { * * @param string $status The header message that is being set. * @return void - * @deprecated + * @deprecated Use CakeResponse::header() */ public function header($status) { $this->response->header($status); @@ -859,7 +873,7 @@ class Controller extends Object { * * @return void * @link http://book.cakephp.org/view/988/disableCache - * @deprecated + * @deprecated Use CakeResponse::disableCache() */ public function disableCache() { $this->response->disableCache(); @@ -960,7 +974,8 @@ class Controller extends Object { } /** - * Called before the controller action. + * Called before the controller action. You can use this method to configure and customize components + * or perform logic that needs to happen before each controller action. * * @link http://book.cakephp.org/view/984/Callbacks */ @@ -968,7 +983,8 @@ class Controller extends Object { } /** - * Called after the controller action is run, but before the view is rendered. + * Called after the controller action is run, but before the view is rendered. You can use this method + * to perform logic or set view variables that are required on every request. * * @link http://book.cakephp.org/view/984/Callbacks */ diff --git a/cake/libs/router.php b/cake/libs/router.php index 611301867..ac0ae9d50 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -22,10 +22,23 @@ App::import('Core', 'CakeRequest'); App::import('Core', 'route/CakeRoute'); /** - * Parses the request URL into controller, action, and parameters. + * Parses the request URL into controller, action, and parameters. Uses the connected routes + * to match the incoming url string to parameters that will allow the request to be dispatched. Also + * handles converting parameter lists into url strings, using the connected routes. Routing allows you to decouple + * the way the world interacts with your application (urls) and the implementation (controllers and actions). * - * @package cake - * @subpackage cake.cake.libs + * ### Connecting routes + * + * Connecting routes is done using Router::connect(). When parsing incoming requests or reverse matching + * parameters, routes are enumerated in the order they were connected. You can modify the order of connected + * routes using Router::promote(). For more information on routes and how to connect them see Router::connect(). + * + * ### Named parameters + * + * Named parameters allow you to embed key:value pairs into path segments. This allows you create hash + * structures using urls. You can define how named parameters work in your application using Router::connectNamed() + * + * @package cake.libs */ class Router { @@ -276,6 +289,7 @@ class Router { * Redirects /posts/* to http://google.com with a HTTP status of 302 * * ### Options: + * * - `status` Sets the HTTP status (default 301) * - `persist` Passes the params to the redirected route, if it can * From afbc73a3b5f4602f85ef881ff1cdb2851d3e8c3e Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 21 Dec 2010 22:36:37 -0500 Subject: [PATCH 337/378] More documentation. --- cake/libs/cake_request.php | 16 +++++++++++++--- cake/libs/cake_response.php | 22 ++++++++++++++++------ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 580f51296..23c925883 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -519,7 +519,8 @@ class CakeRequest implements ArrayAccess { } /** - * Add parameters to the request's parsed parameter set. This will overwrite any existing parameters + * Add parameters to the request's parsed parameter set. This will overwrite any existing parameters. + * This modifies the parameters available through `$request->params`. * * @param array $params Array of parameters to merge in * @return The current object, you can chain this method. @@ -531,6 +532,7 @@ class CakeRequest implements ArrayAccess { /** * Add paths to the requests' paths vars. This will overwrite any existing paths. + * Provides an easy way to modify, here, webroot and base. * * @param array $paths Array of paths to merge in * @return the current object, you can chain this method. @@ -605,11 +607,11 @@ class CakeRequest implements ArrayAccess { * * #### Get all types: * - * `$request->accepts();` + * `$this->request->accepts();` * * #### Check for a single type: * - * `$request->accepts('json');` + * `$this->request->accepts('json');` * * @param string $type The content type to check for. Leave null to get all types a client accepts. * @return mixed Either an array of all the types the client accepts or a boolean if they accept the @@ -632,6 +634,14 @@ class CakeRequest implements ArrayAccess { /** * Get the lanaguages accepted by the client, or check if a specific language is accepted. * + * Get the list of accepted languages: + * + * {{{ CakeRequest::acceptLanguage(); }}} + * + * Check if a specific language is accepted: + * + * {{{ CakeRequest::acceptLanguage('es-es'); }}} + * * @param string $language The language to test. * @return If a $language is provided, a boolean. Otherwise the array of accepted languages. */ diff --git a/cake/libs/cake_response.php b/cake/libs/cake_response.php index 6c3d751c2..df2ab71a0 100644 --- a/cake/libs/cake_response.php +++ b/cake/libs/cake_response.php @@ -1,9 +1,6 @@ 'application/keynote'));` * * ### Replacing a content type definition + * * e.g `type(array('jpg' => 'text/plain'));` * * @param string $contentType @@ -624,7 +633,8 @@ class CakeResponse { } /** - * Sets the correct output buffering handler to send a compressed response + * Sets the correct output buffering handler to send a compressed response. Responses will + * be compressed with zlib, if the extension is available. * * @return boolean false if client does not accept compressed responses or no handler is available, true otherwise */ @@ -636,7 +646,7 @@ class CakeResponse { } /** - * Sets the correct headers to instruct the browser to dowload the response as a file + * Sets the correct headers to instruct the browser to dowload the response as a file. * * @param string $filename the name of the file as the browser will download the response * @return void From 1c6b261ff1d2d7cb3845184c77b586ee25496eba Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 21 Dec 2010 23:11:23 -0500 Subject: [PATCH 338/378] Correcting and expanding documentation on console classes. --- cake/console/libs/console_error_handler.php | 21 +++------ cake/console/libs/console_input.php | 2 +- cake/console/libs/console_input_argument.php | 34 ++++++++++++-- cake/console/libs/console_input_option.php | 46 +++++++++++++++++-- .../console/libs/console_input_subcommand.php | 25 ++++++++-- cake/console/libs/console_option_parser.php | 28 +++++------ cake/console/libs/console_output.php | 10 ++-- cake/console/libs/help_formatter.php | 7 ++- 8 files changed, 123 insertions(+), 50 deletions(-) diff --git a/cake/console/libs/console_error_handler.php b/cake/console/libs/console_error_handler.php index 120c09d74..bd2228c7a 100644 --- a/cake/console/libs/console_error_handler.php +++ b/cake/console/libs/console_error_handler.php @@ -51,8 +51,9 @@ class ConsoleErrorHandler extends ErrorHandler { } /** - * Handle a exception in the console environment. + * Handle a exception in the console environment. Prints a message to stderr. * + * @param Exception $exception The exception to handle * @return void */ public static function handleException(Exception $exception) { @@ -67,6 +68,11 @@ class ConsoleErrorHandler extends ErrorHandler { /** * Handle errors in the console environment. * + * @param int $code Error code + * @param string $description Description of the error. + * @param string $file The file the error occurred in. + * @param int $line The line the error ocurrred on. + * @param array $context The backtrace of the error. * @return void */ public static function handleError($code, $description, $file = null, $line = null, $context = null) { @@ -84,17 +90,4 @@ class ConsoleErrorHandler extends ErrorHandler { } } -/** - * undocumented function - * - * @return void - */ - public function render() { - $this->stderr->write(sprintf( - __("Error: %s\n%s"), - $this->error->getMessage(), - $this->error->getTraceAsString() - )); - } - } diff --git a/cake/console/libs/console_input.php b/cake/console/libs/console_input.php index 33127ae9b..751035f53 100644 --- a/cake/console/libs/console_input.php +++ b/cake/console/libs/console_input.php @@ -33,7 +33,7 @@ class ConsoleInput { /** * Constructor * - * @return void + * @param string $handle The location of the stream to use as input. */ public function __construct($handle = 'php://stdin') { $this->_input = fopen($handle, 'r'); diff --git a/cake/console/libs/console_input_argument.php b/cake/console/libs/console_input_argument.php index 200582353..34ce98414 100644 --- a/cake/console/libs/console_input_argument.php +++ b/cake/console/libs/console_input_argument.php @@ -25,8 +25,33 @@ * @package cake.console */ class ConsoleInputArgument { +/** + * Name of the argument. + * + * @var string + */ + protected $_name; - protected $_name, $_help, $_required, $_choices; +/** + * Help string + * + * @var string + */ + protected $_help; + +/** + * Is this option required? + * + * @var boolean + */ + protected $_required; + +/** + * An array of valid choices for this argument. + * + * @var array + */ + protected $_choices; /** * Make a new Input Argument @@ -34,8 +59,7 @@ class ConsoleInputArgument { * @param mixed $name The long name of the option, or an array with all the properites. * @param string $help The help text for this option * @param boolean $required Whether this argument is required. Missing required args will trigger exceptions - * @param arraty $choices Valid choices for this option. - * @return void + * @param array $choices Valid choices for this option. */ public function __construct($name, $help = '', $required = false, $choices = array()) { if (is_array($name) && isset($name['name'])) { @@ -60,7 +84,7 @@ class ConsoleInputArgument { } /** - * Generate the help for this this argument. + * Generate the help for this argument. * * @param int $width The width to make the name of the option. * @return string @@ -125,7 +149,7 @@ class ConsoleInputArgument { } /** - * Append this argument to the passed in SimpleXml object. + * Append this arguments XML representation to the passed in SimpleXml object. * * @param SimpleXmlElement The parent element. * @return SimpleXmlElement The parent with this argument appended. diff --git a/cake/console/libs/console_input_option.php b/cake/console/libs/console_input_option.php index 56b01d448..925d64dd4 100644 --- a/cake/console/libs/console_input_option.php +++ b/cake/console/libs/console_input_option.php @@ -26,8 +26,47 @@ * @package cake.console */ class ConsoleInputOption { +/** + * Name of the option + * + * @var string + */ + protected $_name; - protected $_name, $_short, $_help, $_boolean, $_default, $_choices; +/** + * Short (1 character) alias for the option. + * + * @var string + */ + protected $_short; + +/** + * Help text for the option. + * + * @var string + */ + protected $_help; + +/** + * Is the option a boolean option. Boolean options do not consume a parameter. + * + * @var boolean + */ + protected $_boolean; + +/** + * Default value for the option + * + * @var mixed + */ + protected $_default; + +/** + * An array of choices for the option. + * + * @var array + */ + protected $_choices; /** * Make a new Input Option @@ -37,8 +76,7 @@ class ConsoleInputOption { * @param string $help The help text for this option * @param boolean $boolean Whether this option is a boolean option. Boolean options don't consume extra tokens * @param string $default The default value for this option. - * @param arraty $choices Valid choices for this option. - * @return void + * @param array $choices Valid choices for this option. */ public function __construct($name, $short = null, $help = '', $boolean = false, $default = '', $choices = array()) { if (is_array($name) && isset($name['name'])) { @@ -117,7 +155,7 @@ class ConsoleInputOption { /** * Get the default value for this option * - * @return void + * @return mixed */ public function defaultValue() { return $this->_default; diff --git a/cake/console/libs/console_input_subcommand.php b/cake/console/libs/console_input_subcommand.php index 76bd19d2f..d628425c8 100644 --- a/cake/console/libs/console_input_subcommand.php +++ b/cake/console/libs/console_input_subcommand.php @@ -27,15 +27,34 @@ */ class ConsoleInputSubcommand { - protected $_name, $_help, $_parser; +/** + * Name of the subcommand + * + * @var string + */ + protected $_name; + +/** + * Help string for the subcommand + * + * @var string + */ + protected $_help; + +/** + * The ConsoleOptionParser for this subcommand. + * + * @var ConsoleOptionParser + */ + protected $_parser; /** * Make a new Subcommand * * @param mixed $name The long name of the subcommand, or an array with all the properites. * @param string $help The help text for this option - * @param ConsoleOptionParser $parser A parser for this subcommand. - * @return void + * @param mixed $parser A parser for this subcommand. Either a ConsoleOptionParser, or an array that can be + * used with ConsoleOptionParser::buildFromArray() */ public function __construct($name, $help = '', $parser = null) { if (is_array($name) && isset($name['name'])) { diff --git a/cake/console/libs/console_option_parser.php b/cake/console/libs/console_option_parser.php index 5af733e2d..6e9dcce39 100644 --- a/cake/console/libs/console_option_parser.php +++ b/cake/console/libs/console_option_parser.php @@ -88,7 +88,7 @@ class ConsoleOptionParser { * preceeded by one - and are only one character long. They usually match with a long option, * and provide a more terse alternative. * - * #### Using Options + * ### Using Options * * Options can be defined with both long and short forms. By using `$parser->addOption()` * you can define new options. The name of the option is used as its long form, and you @@ -195,7 +195,7 @@ class ConsoleOptionParser { } /** - * Get or set the command name for shell/task + * Get or set the command name for shell/task. * * @param string $text The text to set, or null if you want to read * @return mixed If reading, the value of the command. If setting $this will be returned @@ -209,7 +209,7 @@ class ConsoleOptionParser { } /** - * Get or set the description text for shell/task + * Get or set the description text for shell/task. * * @param mixed $text The text to set, or null if you want to read. . If an array the text will be imploded with "\n" * @return mixed If reading, the value of the description. If setting $this will be returned @@ -247,7 +247,7 @@ class ConsoleOptionParser { * Add an option to the option parser. Options allow you to define optional or required * parameters for your console application. Options are defined by the parameters they use. * - * ### Params + * ### Options * * - `short` - The single letter variant for this option, leave undefined for none. * - `help` - Help text for this option. Used when generating help for the option. @@ -260,11 +260,12 @@ class ConsoleOptionParser { * - `choices` A list of valid choices for this option. If left empty all values are valid.. * An exception will be raised when parse() encounters an invalid value. * - * @param string $name The long name you want to the value to be parsed out as when options are parsed. + * @param mixed $name The long name you want to the value to be parsed out as when options are parsed. + * Will also accept an instance of ConsoleInputOption * @param array $params An array of parameters that define the behavior of the option * @return returns $this. */ - public function addOption($name, $params = array()) { + public function addOption($name, $options = array()) { if (is_object($name) && $name instanceof ConsoleInputOption) { $option = $name; $name = $option->name(); @@ -277,7 +278,7 @@ class ConsoleOptionParser { 'boolean' => false, 'choices' => array() ); - $options = array_merge($defaults, $params); + $options = array_merge($defaults, $options); $option = new ConsoleInputOption($options); } $this->_options[$name] = $option; @@ -300,7 +301,7 @@ class ConsoleOptionParser { * - `choices` A list of valid choices for this argument. If left empty all values are valid.. * An exception will be raised when parse() encounters an invalid value. * - * @param string $name The name of the argument. + * @param mixed $name The name of the argument. Will also accept an instance of ConsoleInputArgument * @param array $params Parameters for the argument, see above. * @return $this. */ @@ -357,21 +358,20 @@ class ConsoleOptionParser { /** * Append a subcommand to the subcommand list. - * Subcommands are usually methods on your Shell, but can also be used to document - * Tasks + * Subcommands are usually methods on your Shell, but can also be used to document Tasks. * - * ### Params + * ### Options * * - `help` - Help text for the subcommand. * - `parser` - A ConsoleOptionParser for the subcommand. This allows you to create method * specific option parsers. When help is generated for a subcommand, if a parser is present * it will be used. * - * @param string $name Name of the subcommand + * @param mixed $name Name of the subcommand. Will also accept an instance of ConsoleInputSubcommand * @param array $params Array of params, see above. * @return $this. */ - public function addSubcommand($name, $params = array()) { + public function addSubcommand($name, $options = array()) { if (is_object($name) && $name instanceof ConsoleInputSubcommand) { $command = $name; $name = $command->name(); @@ -381,7 +381,7 @@ class ConsoleOptionParser { 'help' => '', 'parser' => null ); - $options = array_merge($defaults, $params); + $options = array_merge($defaults, $options); $command = new ConsoleInputSubcommand($options); } $this->_subcommands[$name] = $command; diff --git a/cake/console/libs/console_output.php b/cake/console/libs/console_output.php index ef47266f0..5f89ac100 100644 --- a/cake/console/libs/console_output.php +++ b/cake/console/libs/console_output.php @@ -21,7 +21,7 @@ * Object wrapper for outputing information from a shell application. * Can be connected to any stream resource that can be used with fopen() * - * Can generate colourzied output on consoles that support it. There are a few + * Can generate colourized output on consoles that support it. There are a few * built in styles * * - `error` Error messages. @@ -143,8 +143,8 @@ class ConsoleOutput { * * Checks for a pretty console enviornment. Ansicon allows pretty consoles * on windows, and is supported. - * - * @return void + * + * @param string $stream The identifier of the stream to write output to. */ public function __construct($stream = 'php://stdout') { $this->_output = fopen($stream, 'w'); @@ -156,7 +156,7 @@ class ConsoleOutput { /** * Outputs a single or multiple messages to stdout. If no parameters - * are passed outputs just a newline. + * are passed, outputs just a newline. * * @param mixed $message A string or a an array of strings to output * @param integer $newlines Number of newlines to append @@ -216,7 +216,7 @@ class ConsoleOutput { } /** - * Writes a message to the output stream + * Writes a message to the output stream. * * @param string $message Message to write. * @return boolean success diff --git a/cake/console/libs/help_formatter.php b/cake/console/libs/help_formatter.php index 002689899..2afdd5e90 100644 --- a/cake/console/libs/help_formatter.php +++ b/cake/console/libs/help_formatter.php @@ -12,9 +12,6 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console - * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Core', 'String', false); @@ -28,12 +25,14 @@ App::import('Core', 'String', false); * * Xml output is useful for intergration with other tools like IDE's or other build tools. * + * @package cake.console + * @since CakePHP(tm) v 2.0 */ class HelpFormatter { /** * Build the help formatter for a an OptionParser * - * @return void + * @param ConsoleOptionParser $parser The option parser help is being generated for. */ public function __construct(ConsoleOptionParser $parser) { $this->_parser = $parser; From af2a5123b5753f78d50a73fffcfc2462a293488c Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 21 Dec 2010 23:14:17 -0500 Subject: [PATCH 339/378] Fixing issue where prefixes would not be correctly loaded for a request. --- cake/libs/router.php | 1 + 1 file changed, 1 insertion(+) diff --git a/cake/libs/router.php b/cake/libs/router.php index ac0ae9d50..2cd9128b4 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -711,6 +711,7 @@ class Router { public static function reload() { if (empty(self::$_initialState)) { self::$_initialState = get_class_vars('Router'); + self::_setPrefixes(); return; } foreach (self::$_initialState as $key => $val) { From 3c6fc55eed7d7dbc41b6600456459972e4175085 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 21 Dec 2010 23:45:47 -0500 Subject: [PATCH 340/378] Removing strlower() calls as they are not needed in php5 land. --- cake/libs/controller/components/security.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index b3ae711d8..90a934aea 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -319,7 +319,6 @@ class SecurityComponent extends Component { } $this->loginOptions = array_merge($base, $this->loginOptions); $this->_requireMethod('Login', $args); - if (isset($this->loginOptions['users'])) { $this->loginUsers =& $this->loginOptions['users']; } @@ -555,9 +554,9 @@ class SecurityComponent extends Component { */ protected function _loginRequired($controller) { if (is_array($this->requireLogin) && !empty($this->requireLogin)) { - $requireLogin = array_map('strtolower', $this->requireLogin); + $requireLogin = $this->requireLogin; - if (in_array($this->_action, $requireLogin) || $this->requireLogin == array('*')) { + if (in_array($this->_action, $this->requireLogin) || $this->requireLogin == array('*')) { $login = $this->loginCredentials($this->loginOptions['type']); if ($login == null) { From 27477bbac31ad10dc503cd75d4b0deeb665450e2 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 23 Dec 2010 00:32:53 -0200 Subject: [PATCH 341/378] Removing extra parameter. --- cake/console/templates/default/views/form.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/console/templates/default/views/form.ctp b/cake/console/templates/default/views/form.ctp index 455648ed7..85fef3fa0 100644 --- a/cake/console/templates/default/views/form.ctp +++ b/cake/console/templates/default/views/form.ctp @@ -20,7 +20,7 @@
    Form->create('{$modelClass}');?>\n";?>
    - ", Inflector::humanize($action), $singularHumanName); ?> + ", Inflector::humanize($action), $singularHumanName); ?> Date: Wed, 22 Dec 2010 21:49:53 -0500 Subject: [PATCH 342/378] Adding a doc block and code sample for MediaView. --- cake/libs/view/media.php | 50 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/cake/libs/view/media.php b/cake/libs/view/media.php index 5bc0d179e..fec019906 100644 --- a/cake/libs/view/media.php +++ b/cake/libs/view/media.php @@ -19,6 +19,41 @@ */ App::import('View', 'View', false); +/** + * Media View provides a custom view implementation for sending files to visitors. Its great + * for making the response of a controller action be a file that is saved somewhere on the filesystem. + * + * An example use comes from the CakePHP internals. MediaView is used to serve plugin and theme assets, + * as they are not normally accessible from an application's webroot. Unlike other views, MediaView + * uses several viewVars that have special meaning: + * + * - `id` The filename on the server's filesystem, including extension. + * - `name` The filename that will be sent to the user, specified without the extension. + * - `download` Set to true to set a `Content-Disposition` header. This is ideal for file downloads. + * - `extension` The extension of the file being served. This is used to set the mimetype + * - `path` The absolute path, including the trailing / on the server's filesystem to `id`. + * - `mimeType` The mime type of the file if CakeResponse doesn't know about it. + * + * ### Usage + * + * {{{ + * class ExampleController extends AppController { + * function download () { + * $this->view = 'Media'; + * $params = array( + * 'id' => 'example.zip', + * 'name' => 'example', + * 'download' => true, + * 'extension' => 'zip', + * 'path' => APP . 'files' . DS + * ); + * $this->set($params); + * } + * } + * }}} + * + * @package cake.libs.view + */ class MediaView extends View { /** * Indicates whether response gzip compression was enabled for this class @@ -34,11 +69,10 @@ class MediaView extends View { */ public $response = null; - /** * Constructor * - * @param object $controller + * @param object $controller The controller with viewVars */ function __construct($controller = null) { parent::__construct($controller); @@ -53,7 +87,7 @@ class MediaView extends View { /** * Display or download the given file * - * @return unknown + * @return mixed */ function render() { $name = $download = $extension = $id = $modified = $path = $size = $cache = $mimeType = $compress = null; @@ -160,6 +194,12 @@ class MediaView extends View { return false; } +/** + * Reads out a file handle, and echos the content to the client. + * + * @param resource $handle A file handle or stream + * @return void + */ protected function _sendFile($handle) { $chunkSize = 8192; $buffer = ''; @@ -180,6 +220,7 @@ class MediaView extends View { /** * Returns true if connection is still active + * * @return boolean */ protected function _isActive() { @@ -188,6 +229,7 @@ class MediaView extends View { /** * Clears the contents of the topmost output buffer and discards them + * * @return boolean */ protected function _clearBuffer() { @@ -196,6 +238,8 @@ class MediaView extends View { /** * Flushes the contents of the output buffer + * + * @return void */ protected function _flushBuffer() { @flush(); From 98c356a9c53be1480b563c80794f0ba031f3af99 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 22 Dec 2010 22:26:43 -0500 Subject: [PATCH 343/378] Adding some more documentation to ModelBehavior as well as basic usage. --- cake/libs/model/model_behavior.php | 49 +++++++++++++++++++----------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/cake/libs/model/model_behavior.php b/cake/libs/model/model_behavior.php index d0093e95e..0cf027163 100644 --- a/cake/libs/model/model_behavior.php +++ b/cake/libs/model/model_behavior.php @@ -23,10 +23,26 @@ /** * Model behavior base class. * - * Defines the Behavior interface, and contains common model interaction functionality. + * Defines the Behavior interface, and contains common model interaction functionality. Behaviors + * allow you to simulate mixins, and create resuable blocks of application logic, that can be reused across + * several models. Behaviors also provide a way to hook into model callbacks and augment their behavior. * - * @package cake - * @subpackage cake.cake.libs.model + * ### Mixin methods + * + * Behaviors can provide mixin like features by declaring public methods. These methods should expect + * the model instance to be shifted onto the parameter list. + * + * {{{ + * function doSomething($model, $arg1, $arg2) { + * //do something + * } + * }}} + * + * Would be called like `$this->Model->doSomething($arg1, $arg2);`. + * + * @package cake.libs.model + * @see Model::$actsAs + * @see BehaviorCollection::load() */ class ModelBehavior extends Object { @@ -37,7 +53,6 @@ class ModelBehavior extends Object { * associative array, keyed off of the model name. * * @var array - * @access public * @see Model::$alias */ public $settings = array(); @@ -49,7 +64,6 @@ class ModelBehavior extends Object { * the findBy* / findAllBy* magic methods. * * @var array - * @access public */ public $mapMethods = array(); @@ -66,7 +80,6 @@ class ModelBehavior extends Object { * detached from a model using Model::detach(). * * @param object $model Model using this behavior - * @access public * @see BehaviorCollection::detach() */ function cleanup($model) { @@ -76,31 +89,33 @@ class ModelBehavior extends Object { } /** - * Before find callback + * beforeFind can be used to cancel find operations, or modify the query that will be executed. + * By returning null/false you can abort a find. By returning an array you can modify/replace the query + * that is going to be run. * * @param object $model Model using this behavior * @param array $queryData Data used to execute this query, i.e. conditions, order, etc. * @return mixed False or null will abort the operation. You can return an array to replace the * $query that will be eventually run. - * @access public */ public function beforeFind($model, $query) { return true; } /** - * After find callback. Can be used to modify any results returned by find and findAll. + * After find callback. Can be used to modify any results returned by find. * * @param object $model Model using this behavior * @param mixed $results The results of the find operation * @param boolean $primary Whether this model is being queried directly (vs. being queried as an association) * @return mixed An array value will replace the value of $results - any other value will be ignored. - * @access public */ public function afterFind($model, $results, $primary) { } /** - * Before validate callback + * beforeValidate is called before a model is validated, you can use this callback to + * add behavior validation rules into a models validate array. Returning false + * will allow you to make the validation fail. * * @param object $model Model using this behavior * @return mixed False or null will abort the operation. Any other result will continue. @@ -111,18 +126,18 @@ class ModelBehavior extends Object { } /** - * Before save callback + * beforeSave is called before a model is saved. Returning false from a beforeSave callback + * will abort the save operation. * * @param object $model Model using this behavior * @return mixed False if the operation should abort. Any other result will continue. - * @access public */ public function beforeSave($model) { return true; } /** - * After save callback + * afterSave is called after a model is saved. * * @param object $model Model using this behavior * @param boolean $created True if this save created a new record @@ -132,7 +147,8 @@ class ModelBehavior extends Object { } /** - * Before delete callback + * Before delete is called before any delete occurs on the attached model, but after the model's + * beforeDelete is called. Returning false from a beforeDelete will abort the delete. * * @param object $model Model using this behavior * @param boolean $cascade If true records that depend on this record will also be deleted @@ -144,7 +160,7 @@ class ModelBehavior extends Object { } /** - * After delete callback + * After delete is called after any delete occurs on the attached model. * * @param object $model Model using this behavior */ @@ -166,7 +182,6 @@ class ModelBehavior extends Object { * * @param object $model Model using this behavior * @param string $field Field to be added to $model's whitelist - * @access protected * @return void */ function _addToWhitelist($model, $field) { From a37b3a15984d24162fe3cf1abbdb15ce34330142 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 22 Dec 2010 22:33:17 -0500 Subject: [PATCH 344/378] Adding more documentation to DboSource. --- cake/libs/model/datasources/dbo_source.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 52be136e9..da92471a1 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -253,9 +253,10 @@ class DboSource extends DataSource { /** - * Returns an object to represent a database identifier in a query + * Returns an object to represent a database identifier in a query. Expression objects + * are not sanitized or esacped. * - * @param string $identifier + * @param string $identifier A SQL expression to be used as an identifier * @return object An object representing a database identifier to be used in a query */ public function identifier($identifier) { @@ -266,9 +267,10 @@ class DboSource extends DataSource { } /** - * Returns an object to represent a database expression in a query + * Returns an object to represent a database expression in a query. Expression objects + * are not sanitized or esacped. * - * @param string $expression + * @param string $expression An arbitrary SQL expression to be inserted into a query. * @return object An object representing a database expression to be used in a query */ public function expression($expression) { @@ -282,6 +284,7 @@ class DboSource extends DataSource { * Executes given SQL statement. * * @param string $sql SQL statement + * @param array $params Additional options for the query. * @return boolean */ public function rawQuery($sql, $params = array()) { @@ -381,6 +384,7 @@ class DboSource extends DataSource { * Returns number of affected rows in previous database operation. If no previous operation exists, * this returns false. * + * @param string $source * @return integer Number of affected rows */ function lastAffected($source = null) { @@ -394,6 +398,7 @@ class DboSource extends DataSource { * Returns number of rows in previous resultset. If no previous resultset exists, * this returns false. * + * @param string $source * @return integer Number of rows in resultset */ function lastNumRows($source = null) { @@ -498,6 +503,7 @@ class DboSource extends DataSource { /** * Returns a row from current resultset as an array * + * @param string $sql Some SQL to be executed. * @return array The fetched row as an array */ public function fetchRow($sql = null) { @@ -575,7 +581,7 @@ class DboSource extends DataSource { /** * Modifies $result array to place virtual fields in model entry where they belongs to * - * @param array $resut REference to the fetched row + * @param array $resut Reference to the fetched row * @return void */ public function fetchVirtualField(&$result) { @@ -736,6 +742,7 @@ class DboSource extends DataSource { * Get the query log as an array. * * @param boolean $sorted Get the queries sorted by time taken, defaults to false. + * @param boolean $clear If True the existing log will cleared. * @return array Array of queries run as an array */ public function getLog($sorted = false, $clear = true) { From 8eaba29c3f3840f74d2e824524e17ac99de22081 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 22 Dec 2010 23:19:04 -0500 Subject: [PATCH 345/378] Fixing an entirely wrong condition that prevented routes from being loaded. --- cake/libs/dispatcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/dispatcher.php b/cake/libs/dispatcher.php index 0b498b5b2..5352f9d4a 100644 --- a/cake/libs/dispatcher.php +++ b/cake/libs/dispatcher.php @@ -195,7 +195,7 @@ class Dispatcher { * @return CakeRequest The request object with routing params set. */ public function parseParams(CakeRequest $request, $additionalParams = array()) { - if (count(Router::$routes) > 0) { + if (count(Router::$routes) == 0) { $namedExpressions = Router::getNamedExpressions(); extract($namedExpressions); $this->__loadRoutes(); From e20ea8ad7234d8fcbc486ba95865be0dd69d60c1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 24 Dec 2010 12:54:04 -0500 Subject: [PATCH 346/378] Renaming Dispatcher::__loadRoutes -> Dispatcher::_loadRoutes to match naming conventions. Updating method name usage, as assertType is deprecated as of PHPUnit 3.5.6 --- cake/libs/dispatcher.php | 5 ++--- .../cases/console/libs/help_formatter.test.php | 2 +- .../console/libs/task_collection.test.php | 12 ++++++------ cake/tests/cases/console/shells/shell.test.php | 6 +++--- .../cases/libs/controller/component.test.php | 14 +++++++------- .../controller/component_collection.test.php | 12 ++++++------ .../cases/libs/controller/controller.test.php | 6 +++--- .../cases/libs/controller_test_case.test.php | 7 +++---- cake/tests/cases/libs/debugger.test.php | 6 +++--- .../libs/error/exception_renderer.test.php | 4 ++-- .../libs/model/model_integration.test.php | 18 +++++++++--------- .../cases/libs/object_collection.test.php | 4 ++-- .../libs/session/database_session.test.php | 2 +- cake/tests/cases/libs/test_manager.test.php | 2 +- cake/tests/cases/libs/view/helper.test.php | 4 ++-- .../cases/libs/view/helper_collection.test.php | 12 ++++++------ cake/tests/cases/libs/view/view.test.php | 6 +++--- cake/tests/fixtures/fixturized_test_case.php | 2 +- cake/tests/lib/cake_test_case.php | 2 +- cake/tests/lib/controller_test_case.php | 5 ++--- 20 files changed, 64 insertions(+), 67 deletions(-) diff --git a/cake/libs/dispatcher.php b/cake/libs/dispatcher.php index 5352f9d4a..f9b7b059d 100644 --- a/cake/libs/dispatcher.php +++ b/cake/libs/dispatcher.php @@ -198,7 +198,7 @@ class Dispatcher { if (count(Router::$routes) == 0) { $namedExpressions = Router::getNamedExpressions(); extract($namedExpressions); - $this->__loadRoutes(); + $this->_loadRoutes(); } $params = Router::parse($request->url); @@ -254,9 +254,8 @@ class Dispatcher { * Loads route configuration * * @return void - * @access protected */ - protected function __loadRoutes() { + protected function _loadRoutes() { include CONFIGS . 'routes.php'; } diff --git a/cake/tests/cases/console/libs/help_formatter.test.php b/cake/tests/cases/console/libs/help_formatter.test.php index a957843b1..5caae1490 100644 --- a/cake/tests/cases/console/libs/help_formatter.test.php +++ b/cake/tests/cases/console/libs/help_formatter.test.php @@ -435,6 +435,6 @@ TEXT; $formatter = new HelpFormatter($parser); $result = $formatter->xml(false); - $this->assertType('SimpleXmlElement', $result); + $this->assertInstanceOf('SimpleXmlElement', $result); } } diff --git a/cake/tests/cases/console/libs/task_collection.test.php b/cake/tests/cases/console/libs/task_collection.test.php index b89de158c..3bbbd12c8 100644 --- a/cake/tests/cases/console/libs/task_collection.test.php +++ b/cake/tests/cases/console/libs/task_collection.test.php @@ -49,8 +49,8 @@ class TaskCollectionTest extends CakeTestCase { */ function testLoad() { $result = $this->Tasks->load('DbConfig'); - $this->assertType('DbConfigTask', $result); - $this->assertType('DbConfigTask', $this->Tasks->DbConfig); + $this->assertInstanceOf('DbConfigTask', $result); + $this->assertInstanceOf('DbConfigTask', $this->Tasks->DbConfig); $result = $this->Tasks->attached(); $this->assertEquals(array('DbConfig'), $result, 'attached() results are wrong.'); @@ -65,8 +65,8 @@ class TaskCollectionTest extends CakeTestCase { */ function testLoadWithEnableFalse() { $result = $this->Tasks->load('DbConfig', array(), false); - $this->assertType('DbConfigTask', $result); - $this->assertType('DbConfigTask', $this->Tasks->DbConfig); + $this->assertInstanceOf('DbConfigTask', $result); + $this->assertInstanceOf('DbConfigTask', $this->Tasks->DbConfig); $this->assertFalse($this->Tasks->enabled('DbConfig'), 'DbConfigTask should be disabled'); } @@ -94,8 +94,8 @@ class TaskCollectionTest extends CakeTestCase { $this->Tasks = new TaskCollection($shell, $dispatcher); $result = $this->Tasks->load('TestPlugin.OtherTask'); - $this->assertType('OtherTaskTask', $result, 'Task class is wrong.'); - $this->assertType('OtherTaskTask', $this->Tasks->OtherTask, 'Class is wrong'); + $this->assertInstanceOf('OtherTaskTask', $result, 'Task class is wrong.'); + $this->assertInstanceOf('OtherTaskTask', $this->Tasks->OtherTask, 'Class is wrong'); } /** diff --git a/cake/tests/cases/console/shells/shell.test.php b/cake/tests/cases/console/shells/shell.test.php index 91c623cda..900ebaad8 100644 --- a/cake/tests/cases/console/shells/shell.test.php +++ b/cake/tests/cases/console/shells/shell.test.php @@ -143,9 +143,9 @@ class ShellTest extends CakeTestCase { */ public function testConstruct() { $this->assertEqual($this->Shell->name, 'ShellTestShell'); - $this->assertType('ConsoleInput', $this->Shell->stdin); - $this->assertType('ConsoleOutput', $this->Shell->stdout); - $this->assertType('ConsoleOutput', $this->Shell->stderr); + $this->assertInstanceOf('ConsoleInput', $this->Shell->stdin); + $this->assertInstanceOf('ConsoleOutput', $this->Shell->stdout); + $this->assertInstanceOf('ConsoleOutput', $this->Shell->stderr); } /** diff --git a/cake/tests/cases/libs/controller/component.test.php b/cake/tests/cases/libs/controller/component.test.php index 3c8dc99c6..e42c1e0b6 100644 --- a/cake/tests/cases/libs/controller/component.test.php +++ b/cake/tests/cases/libs/controller/component.test.php @@ -284,7 +284,7 @@ class ComponentTest extends CakeTestCase { $Collection = new ComponentCollection(); $Component = new AppleComponent($Collection); - $this->assertType('OrangeComponent', $Component->Orange, 'class is wrong'); + $this->assertInstanceOf('OrangeComponent', $Component->Orange, 'class is wrong'); } /** @@ -296,8 +296,8 @@ class ComponentTest extends CakeTestCase { $Collection = new ComponentCollection(); $Apple = new AppleComponent($Collection); - $this->assertType('OrangeComponent', $Apple->Orange, 'class is wrong'); - $this->assertType('BananaComponent', $Apple->Orange->Banana, 'class is wrong'); + $this->assertInstanceOf('OrangeComponent', $Apple->Orange, 'class is wrong'); + $this->assertInstanceOf('BananaComponent', $Apple->Orange->Banana, 'class is wrong'); $this->assertTrue(empty($Apple->Session)); $this->assertTrue(empty($Apple->Orange->Session)); } @@ -311,7 +311,7 @@ class ComponentTest extends CakeTestCase { $Collection = new ComponentCollection(); $Apple = $Collection->load('Apple'); - $this->assertType('OrangeComponent', $Apple->Orange, 'class is wrong'); + $this->assertInstanceOf('OrangeComponent', $Apple->Orange, 'class is wrong'); $result = $Collection->enabled(); $this->assertEquals(array('Apple'), $result, 'Too many components enabled.'); } @@ -346,9 +346,9 @@ class ComponentTest extends CakeTestCase { $Controller->beforeFilter(); $Controller->Components->trigger('startup', array(&$Controller)); - $this->assertType('SomethingWithEmailComponent', $Controller->SomethingWithEmail); - $this->assertType('EmailComponent', $Controller->SomethingWithEmail->Email); - $this->assertType('ComponentTestController', $Controller->SomethingWithEmail->Email->Controller); + $this->assertInstanceOf('SomethingWithEmailComponent', $Controller->SomethingWithEmail); + $this->assertInstanceOf('EmailComponent', $Controller->SomethingWithEmail->Email); + $this->assertInstanceOf('ComponentTestController', $Controller->SomethingWithEmail->Email->Controller); } } diff --git a/cake/tests/cases/libs/controller/component_collection.test.php b/cake/tests/cases/libs/controller/component_collection.test.php index ecdac7775..3e0e7bc53 100644 --- a/cake/tests/cases/libs/controller/component_collection.test.php +++ b/cake/tests/cases/libs/controller/component_collection.test.php @@ -47,8 +47,8 @@ class ComponentCollectionTest extends CakeTestCase { */ function testLoad() { $result = $this->Components->load('Cookie'); - $this->assertType('CookieComponent', $result); - $this->assertType('CookieComponent', $this->Components->Cookie); + $this->assertInstanceOf('CookieComponent', $result); + $this->assertInstanceOf('CookieComponent', $this->Components->Cookie); $result = $this->Components->attached(); $this->assertEquals(array('Cookie'), $result, 'attached() results are wrong.'); @@ -66,8 +66,8 @@ class ComponentCollectionTest extends CakeTestCase { */ function testLoadWithEnableFalse() { $result = $this->Components->load('Cookie', array('enabled' => false)); - $this->assertType('CookieComponent', $result); - $this->assertType('CookieComponent', $this->Components->Cookie); + $this->assertInstanceOf('CookieComponent', $result); + $this->assertInstanceOf('CookieComponent', $this->Components->Cookie); $this->assertFalse($this->Components->enabled('Cookie'), 'Cookie should be disabled'); } @@ -91,8 +91,8 @@ class ComponentCollectionTest extends CakeTestCase { 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), )); $result = $this->Components->load('TestPlugin.OtherComponent'); - $this->assertType('OtherComponentComponent', $result, 'Component class is wrong.'); - $this->assertType('OtherComponentComponent', $this->Components->OtherComponent, 'Class is wrong'); + $this->assertInstanceOf('OtherComponentComponent', $result, 'Component class is wrong.'); + $this->assertInstanceOf('OtherComponentComponent', $this->Components->OtherComponent, 'Class is wrong'); App::build(); } diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 39563931b..0ab068cb6 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -462,7 +462,7 @@ class ControllerTest extends CakeTestCase { $result = $Controller->loadModel('Comment'); $this->assertTrue($result); - $this->assertType('Comment', $Controller->Comment); + $this->assertInstanceOf('Comment', $Controller->Comment); $this->assertTrue(in_array('Comment', $Controller->modelNames)); ClassRegistry::flush(); @@ -1248,8 +1248,8 @@ class ControllerTest extends CakeTestCase { $Controller = new TestController($request); $Controller->constructClasses(); - $this->assertType('SecurityComponent', $Controller->Security); - $this->assertType('ControllerComment', $Controller->ControllerComment); + $this->assertInstanceOf('SecurityComponent', $Controller->Security); + $this->assertInstanceOf('ControllerComment', $Controller->ControllerComment); } /** diff --git a/cake/tests/cases/libs/controller_test_case.test.php b/cake/tests/cases/libs/controller_test_case.test.php index c457da428..585e07bb2 100644 --- a/cake/tests/cases/libs/controller_test_case.test.php +++ b/cake/tests/cases/libs/controller_test_case.test.php @@ -171,7 +171,7 @@ class ControllerTestCaseTest extends CakeTestCase { ) )); $this->assertNull($Posts->Post->save(array())); - $this->assertIsA($Posts->Post->find('all'), 'array'); + $this->assertInternalType('array', $Posts->Post->find('all')); $Posts = $this->Case->generate('Posts', array( 'models' => array('Post'), @@ -198,7 +198,7 @@ class ControllerTestCaseTest extends CakeTestCase { function testTestAction() { $Controller = $this->Case->generate('TestsApps'); $this->Case->testAction('/tests_apps/index'); - $this->assertIsA($this->Case->controller->viewVars, 'array'); + $this->assertInternalType('array', $this->Case->controller->viewVars); $this->Case->testAction('/tests_apps/set_action'); $results = $this->Case->controller->viewVars; @@ -254,8 +254,7 @@ class ControllerTestCaseTest extends CakeTestCase { include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php'; $this->Case->loadRoutes = false; - - $result = $this->Case->testAction('/tests_apps/index.json', array('return' => 'view')); + $result = $this->Case->testAction('/tests_apps/missing_action.json', array('return' => 'view')); } /** diff --git a/cake/tests/cases/libs/debugger.test.php b/cake/tests/cases/libs/debugger.test.php index d6ea5ac8e..21e7d8057 100644 --- a/cake/tests/cases/libs/debugger.test.php +++ b/cake/tests/cases/libs/debugger.test.php @@ -232,7 +232,6 @@ class DebuggerTest extends CakeTestCase { View::$viewVars = array View::$layout = "default" View::$layoutPath = NULL - View::$autoRender = true View::$autoLayout = true View::$ext = ".ctp" View::$subDir = NULL @@ -250,8 +249,9 @@ class DebuggerTest extends CakeTestCase { View::$output = false View::$request = NULL View::$elementCache = "default"'; - $result = str_replace(array("\t", "\r\n", "\n"), "", strtolower($result)); - $expected = str_replace(array("\t", "\r\n", "\n"), "", strtolower($expected)); + + $result = str_replace(array("\t", "\r\n", "\n"), "", $result); + $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected); $this->assertEqual($result, $expected); } diff --git a/cake/tests/cases/libs/error/exception_renderer.test.php b/cake/tests/cases/libs/error/exception_renderer.test.php index 4de432fb9..0b147958f 100644 --- a/cake/tests/cases/libs/error/exception_renderer.test.php +++ b/cake/tests/cases/libs/error/exception_renderer.test.php @@ -265,7 +265,7 @@ class ExceptionRendererTest extends CakeTestCase { $exception = new NotFoundException('Page not found'); $ExceptionRenderer = new ExceptionRenderer($exception); - $this->assertType('CakeErrorController', $ExceptionRenderer->controller); + $this->assertInstanceOf('CakeErrorController', $ExceptionRenderer->controller); $this->assertEquals('error400', $ExceptionRenderer->method); $this->assertEquals($exception, $ExceptionRenderer->error); } @@ -280,7 +280,7 @@ class ExceptionRendererTest extends CakeTestCase { $exception = new MissingActionException('Page not found'); $ExceptionRenderer = new ExceptionRenderer($exception); - $this->assertType('CakeErrorController', $ExceptionRenderer->controller); + $this->assertInstanceOf('CakeErrorController', $ExceptionRenderer->controller); $this->assertEquals('error400', $ExceptionRenderer->method); $this->assertEquals($exception, $ExceptionRenderer->error); } diff --git a/cake/tests/cases/libs/model/model_integration.test.php b/cake/tests/cases/libs/model/model_integration.test.php index a8b5a6796..2770657f1 100644 --- a/cake/tests/cases/libs/model/model_integration.test.php +++ b/cake/tests/cases/libs/model/model_integration.test.php @@ -61,27 +61,27 @@ class ModelIntegrationTest extends BaseModelTest { $Article = new ArticleFeatured(); $this->assertTrue(isset($Article->belongsTo['User'])); $this->assertFalse(property_exists($Article, 'User')); - $this->assertType('User', $Article->User); + $this->assertInstanceOf('User', $Article->User); $this->assertTrue(isset($Article->belongsTo['Category'])); $this->assertFalse(property_exists($Article, 'Category')); $this->assertTrue(isset($Article->Category)); - $this->assertType('Category', $Article->Category); + $this->assertInstanceOf('Category', $Article->Category); $this->assertTrue(isset($Article->hasMany['Comment'])); $this->assertFalse(property_exists($Article, 'Comment')); $this->assertTrue(isset($Article->Comment)); - $this->assertType('Comment', $Article->Comment); + $this->assertInstanceOf('Comment', $Article->Comment); $this->assertTrue(isset($Article->hasAndBelongsToMany['Tag'])); //There was not enough information to setup the association (joinTable and associationForeignKey) //so the model was not lazy loaded $this->assertTrue(property_exists($Article, 'Tag')); $this->assertTrue(isset($Article->Tag)); - $this->assertType('Tag', $Article->Tag); + $this->assertInstanceOf('Tag', $Article->Tag); $this->assertFalse(property_exists($Article, 'ArticleFeaturedsTag')); - $this->assertType('AppModel', $Article->ArticleFeaturedsTag); + $this->assertInstanceOf('AppModel', $Article->ArticleFeaturedsTag); $this->assertEquals($Article->hasAndBelongsToMany['Tag']['joinTable'], 'article_featureds_tags'); $this->assertEquals($Article->hasAndBelongsToMany['Tag']['associationForeignKey'], 'tag_id'); } @@ -97,10 +97,10 @@ class ModelIntegrationTest extends BaseModelTest { $Article = new ArticleB(); $this->assertTrue(isset($Article->hasAndBelongsToMany['TagB'])); $this->assertFalse(property_exists($Article, 'TagB')); - $this->assertType('TagB', $Article->TagB); + $this->assertInstanceOf('TagB', $Article->TagB); $this->assertFalse(property_exists($Article, 'ArticlesTag')); - $this->assertType('AppModel', $Article->ArticlesTag); + $this->assertInstanceOf('AppModel', $Article->ArticlesTag); $UuidTag = new UuidTag(); $this->assertTrue(isset($UuidTag->hasAndBelongsToMany['Fruit'])); @@ -110,7 +110,7 @@ class ModelIntegrationTest extends BaseModelTest { $this->assertFalse(property_exists($UuidTag, 'FruitsUuidTag')); $this->assertTrue(isset($UuidTag->FruitsUuidTag)); - $this->assertType('FruitsUuidTag', $UuidTag->FruitsUuidTag); + $this->assertInstanceOf('FruitsUuidTag', $UuidTag->FruitsUuidTag); } /** @@ -129,7 +129,7 @@ class ModelIntegrationTest extends BaseModelTest { $Article->bindModel(array('belongsTo' => array('User'))); $this->assertTrue(isset($Article->belongsTo['User'])); $this->assertFalse(property_exists($Article, 'User')); - $this->assertType('User', $Article->User); + $this->assertInstanceOf('User', $Article->User); } /** diff --git a/cake/tests/cases/libs/object_collection.test.php b/cake/tests/cases/libs/object_collection.test.php index 3eecfd70d..26ab24951 100644 --- a/cake/tests/cases/libs/object_collection.test.php +++ b/cake/tests/cases/libs/object_collection.test.php @@ -98,8 +98,8 @@ class ObjectCollectionTest extends CakeTestCase { */ function testLoad() { $result = $this->Objects->load('First'); - $this->assertType('FirstGenericObject', $result); - $this->assertType('FirstGenericObject', $this->Objects->First); + $this->assertInstanceOf('FirstGenericObject', $result); + $this->assertInstanceOf('FirstGenericObject', $this->Objects->First); $result = $this->Objects->attached(); $this->assertEquals(array('First'), $result, 'attached() results are wrong.'); diff --git a/cake/tests/cases/libs/session/database_session.test.php b/cake/tests/cases/libs/session/database_session.test.php index 013ea6f2d..deb867db6 100644 --- a/cake/tests/cases/libs/session/database_session.test.php +++ b/cake/tests/cases/libs/session/database_session.test.php @@ -96,7 +96,7 @@ class DatabaseSessionTest extends CakeTestCase { $storage = new DatabaseSession(); $session = ClassRegistry::getObject('session'); - $this->assertType('SessionTestModel', $session); + $this->assertInstanceOf('SessionTestModel', $session); $this->assertEquals('Session', $session->alias); $this->assertEquals('test', $session->useDbConfig); } diff --git a/cake/tests/cases/libs/test_manager.test.php b/cake/tests/cases/libs/test_manager.test.php index ae4c90dc1..b0cbbc6e3 100644 --- a/cake/tests/cases/libs/test_manager.test.php +++ b/cake/tests/cases/libs/test_manager.test.php @@ -106,7 +106,7 @@ class TestManagerTest extends CakeTestCase { $file = 'libs/test_manager.test.php'; $result = $this->TestManager->runTestCase($file, $this->Reporter, true); $this->assertEquals(1, $this->_countFiles); - $this->assertType('PHPUnit_Framework_TestResult', $result); + $this->assertInstanceOf('PHPUnit_Framework_TestResult', $result); } } diff --git a/cake/tests/cases/libs/view/helper.test.php b/cake/tests/cases/libs/view/helper.test.php index 4ef761091..025dffae1 100644 --- a/cake/tests/cases/libs/view/helper.test.php +++ b/cake/tests/cases/libs/view/helper.test.php @@ -858,8 +858,8 @@ class HelperTest extends CakeTestCase { 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), )); $Helper = new TestHelper($this->View); - $this->assertType('OtherHelperHelper', $Helper->OtherHelper); - $this->assertType('HtmlHelper', $Helper->Html); + $this->assertInstanceOf('OtherHelperHelper', $Helper->OtherHelper); + $this->assertInstanceOf('HtmlHelper', $Helper->Html); App::build(); } diff --git a/cake/tests/cases/libs/view/helper_collection.test.php b/cake/tests/cases/libs/view/helper_collection.test.php index d5f1480dd..d3b7698fe 100644 --- a/cake/tests/cases/libs/view/helper_collection.test.php +++ b/cake/tests/cases/libs/view/helper_collection.test.php @@ -48,8 +48,8 @@ class HelperCollectionTest extends CakeTestCase { */ function testLoad() { $result = $this->Helpers->load('Html'); - $this->assertType('HtmlHelper', $result); - $this->assertType('HtmlHelper', $this->Helpers->Html); + $this->assertInstanceOf('HtmlHelper', $result); + $this->assertInstanceOf('HtmlHelper', $this->Helpers->Html); $result = $this->Helpers->attached(); $this->assertEquals(array('Html'), $result, 'attached() results are wrong.'); @@ -64,8 +64,8 @@ class HelperCollectionTest extends CakeTestCase { */ function testLoadWithEnabledFalse() { $result = $this->Helpers->load('Html', array('enabled' => false)); - $this->assertType('HtmlHelper', $result); - $this->assertType('HtmlHelper', $this->Helpers->Html); + $this->assertInstanceOf('HtmlHelper', $result); + $this->assertInstanceOf('HtmlHelper', $this->Helpers->Html); $this->assertFalse($this->Helpers->enabled('Html'), 'Html should be disabled'); } @@ -90,8 +90,8 @@ class HelperCollectionTest extends CakeTestCase { 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), )); $result = $this->Helpers->load('TestPlugin.OtherHelper'); - $this->assertType('OtherHelperHelper', $result, 'Helper class is wrong.'); - $this->assertType('OtherHelperHelper', $this->Helpers->OtherHelper, 'Class is wrong'); + $this->assertInstanceOf('OtherHelperHelper', $result, 'Helper class is wrong.'); + $this->assertInstanceOf('OtherHelperHelper', $this->Helpers->OtherHelper, 'Class is wrong'); App::build(); } diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index e50934dd9..30ff72866 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -546,7 +546,7 @@ class ViewTest extends CakeTestCase { function test__get() { $View = new View($this->PostsController); $View->loadHelper('Html'); - $this->assertType('HtmlHelper', $View->Html); + $this->assertInstanceOf('HtmlHelper', $View->Html); } /** @@ -561,8 +561,8 @@ class ViewTest extends CakeTestCase { $View->helpers = array('Html', 'Form'); $View->loadHelpers(); - $this->assertType('HtmlHelper', $View->Html, 'Object type is wrong.'); - $this->assertType('FormHelper', $View->Form, 'Object type is wrong.'); + $this->assertInstanceOf('HtmlHelper', $View->Html, 'Object type is wrong.'); + $this->assertInstanceOf('FormHelper', $View->Form, 'Object type is wrong.'); } /** diff --git a/cake/tests/fixtures/fixturized_test_case.php b/cake/tests/fixtures/fixturized_test_case.php index c9b932b3e..ad2486784 100644 --- a/cake/tests/fixtures/fixturized_test_case.php +++ b/cake/tests/fixtures/fixturized_test_case.php @@ -22,7 +22,7 @@ class FixturizedTestCase extends CakeTestCase { * @return void */ public function testFixturePresent() { - $this->assertType('CakeFixtureManager', $this->fixtureManager); + $this->assertInstanceOf('CakeFixtureManager', $this->fixtureManager); } /** diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index 184dc7912..1a8131679 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -494,7 +494,7 @@ class CakeTestCase extends PHPUnit_Framework_TestCase { * @return void */ protected function assertIsA($object, $type, $message = '') { - return $this->assertType($type, $object, $message); + return $this->assertInstanceOf($type, $object, $message); } /** diff --git a/cake/tests/lib/controller_test_case.php b/cake/tests/lib/controller_test_case.php index 63188b059..91940f928 100644 --- a/cake/tests/lib/controller_test_case.php +++ b/cake/tests/lib/controller_test_case.php @@ -65,10 +65,9 @@ class ControllerTestDispatcher extends Dispatcher { * Loads routes and resets if the test case dictates it should * * @return void - * @access private */ - protected function __loadRoutes() { - parent::__loadRoutes(); + protected function _loadRoutes() { + parent::_loadRoutes(); if (!$this->loadRoutes) { Router::reload(); } From 3fc8a1f8c19fad555efafbb0b14c986456f0abaf Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 24 Dec 2010 12:54:18 -0500 Subject: [PATCH 347/378] Removing whitespace. --- cake/libs/router.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 2cd9128b4..6b4d7dcf6 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -353,8 +353,6 @@ class Router { * @return array */ public static function connectNamed($named, $options = array()) { - - if (isset($options['argSeparator'])) { self::$named['separator'] = $options['argSeparator']; unset($options['argSeparator']); @@ -396,7 +394,6 @@ class Router { * @return void */ public static function defaults($connect = true) { - self::$_connectDefaults = $connect; } @@ -414,7 +411,6 @@ class Router { * @return array Array of mapped resources */ public static function mapResources($controller, $options = array()) { - $options = array_merge(array('prefix' => '/', 'id' => self::$__named['ID'] . '|' . self::$__named['UUID']), $options); $prefix = $options['prefix']; @@ -441,7 +437,6 @@ class Router { * @return array A list of prefixes used in connected routes */ public static function prefixes() { - return self::$_prefixes; } @@ -452,8 +447,6 @@ class Router { * @return array Parsed elements from URL */ public static function parse($url) { - - if (!self::$_defaultsMapped && self::$_connectDefaults) { self::__connectDefaultRoutes(); } From ff18fe4e3e16d1ce43843b73714538ea658b792a Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 24 Dec 2010 16:52:15 -0200 Subject: [PATCH 348/378] Optimization in postLink and create methods from FormHelper. --- cake/libs/view/helpers/form.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 06a465e84..4fdf5d9dd 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -210,11 +210,13 @@ class FormHelper extends AppHelper { } } - $object = $this->_introspectModel($model); - $this->setEntity($model . '.', true); + if ($model !== false) { + $object = $this->_introspectModel($model); + $this->setEntity($model . '.', true); + } $modelEntity = $this->model(); - if (isset($this->fieldset[$modelEntity]['key'])) { + if ($model !== false && isset($this->fieldset[$modelEntity]['key'])) { $data = $this->fieldset[$modelEntity]; $recordExists = ( isset($this->request->data[$model]) && @@ -1322,6 +1324,7 @@ class FormHelper extends AppHelper { unset($options['confirm']); } + $url = $this->url($url); $formName = uniqid('post_'); $out = $this->create(false, array('url' => $url, 'name' => $formName, 'id' => $formName, 'style' => 'display:none;')); if (isset($options['data']) && is_array($options['data'])) { From ef77e60cb023acc27dfb9c92f990c0852ee6cd17 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 24 Dec 2010 13:57:20 -0500 Subject: [PATCH 349/378] Removing @subpackage tags, moving contents of @subpackage into @package. Removing duplicate cake.cake in @package tags. Renaming cake.app -> app --- app/config/acl.ini.php | 3 +- app/config/bootstrap.php | 3 +- app/config/core.php | 3 +- app/config/database.php.default | 6 +- app/config/routes.php | 3 +- app/config/schema/db_acl.php | 3 +- app/config/schema/i18n.php | 3 +- app/config/schema/sessions.php | 3 +- app/console/cake | 3 +- app/console/cake.bat | 5 +- app/console/cake.php | 3 +- app/index.php | 3 +- app/webroot/css.php | 3 +- app/webroot/css/cake.generic.css | 3 +- app/webroot/index.php | 3 +- app/webroot/test.php | 3 +- cake/VERSION.txt | 3 +- cake/basics.php | 1 - cake/bootstrap.php | 1 - cake/config/config.php | 3 +- cake/config/paths.php | 3 +- cake/config/unicode/casefolding/0080_00ff.php | 3 +- cake/config/unicode/casefolding/0100_017f.php | 3 +- cake/config/unicode/casefolding/0180_024F.php | 3 +- cake/config/unicode/casefolding/0250_02af.php | 3 +- cake/config/unicode/casefolding/0370_03ff.php | 3 +- cake/config/unicode/casefolding/0400_04ff.php | 3 +- cake/config/unicode/casefolding/0500_052f.php | 3 +- cake/config/unicode/casefolding/0530_058f.php | 3 +- cake/config/unicode/casefolding/1e00_1eff.php | 3 +- cake/config/unicode/casefolding/1f00_1fff.php | 3 +- cake/config/unicode/casefolding/2100_214f.php | 3 +- cake/config/unicode/casefolding/2150_218f.php | 3 +- cake/config/unicode/casefolding/2460_24ff.php | 3 +- cake/config/unicode/casefolding/2c00_2c5f.php | 3 +- cake/config/unicode/casefolding/2c60_2c7f.php | 3 +- cake/config/unicode/casefolding/2c80_2cff.php | 3 +- cake/config/unicode/casefolding/ff00_ffef.php | 3 +- cake/console/cake | 5 +- cake/console/cake.bat | 5 +- cake/console/cake.php | 3 +- cake/console/libs/console_error_handler.php | 6 +- cake/console/libs/console_input.php | 3 +- cake/console/libs/console_input_argument.php | 3 +- cake/console/libs/console_input_option.php | 3 +- .../console/libs/console_input_subcommand.php | 3 +- cake/console/libs/console_option_parser.php | 6 +- cake/console/libs/console_output.php | 3 +- cake/console/libs/task_collection.php | 3 +- cake/console/shell_dispatcher.php | 6 +- cake/console/shells/acl.php | 6 +- cake/console/shells/api.php | 6 +- cake/console/shells/app_shell.php | 6 +- cake/console/shells/bake.php | 6 +- cake/console/shells/command_list.php | 3 +- cake/console/shells/console.php | 6 +- cake/console/shells/i18n.php | 6 +- cake/console/shells/schema.php | 6 +- cake/console/shells/shell.php | 6 +- cake/console/shells/tasks/bake.php | 3 +- cake/console/shells/tasks/controller.php | 6 +- cake/console/shells/tasks/db_config.php | 6 +- cake/console/shells/tasks/extract.php | 6 +- cake/console/shells/tasks/fixture.php | 6 +- cake/console/shells/tasks/model.php | 6 +- cake/console/shells/tasks/plugin.php | 6 +- cake/console/shells/tasks/project.php | 6 +- cake/console/shells/tasks/template.php | 3 +- cake/console/shells/tasks/test.php | 6 +- cake/console/shells/tasks/view.php | 6 +- cake/console/shells/testsuite.php | 3 +- .../default/actions/controller_actions.ctp | 3 +- .../templates/default/classes/controller.ctp | 3 +- .../templates/default/classes/fixture.ctp | 3 +- .../templates/default/classes/model.ctp | 3 +- .../templates/default/classes/test.ctp | 3 +- cake/console/templates/default/views/form.ctp | 3 +- .../console/templates/default/views/index.ctp | 3 +- cake/console/templates/default/views/view.ctp | 3 +- .../console/templates/skel/app_controller.php | 6 +- cake/console/templates/skel/app_helper.php | 2 - cake/console/templates/skel/app_model.php | 6 +- .../console/templates/skel/config/acl.ini.php | 3 +- .../templates/skel/config/bootstrap.php | 3 +- cake/console/templates/skel/config/core.php | 3 +- .../skel/config/database.php.default | 6 +- cake/console/templates/skel/config/routes.php | 3 +- .../templates/skel/config/schema/db_acl.php | 3 +- .../templates/skel/config/schema/i18n.php | 3 +- .../templates/skel/config/schema/sessions.php | 3 +- cake/console/templates/skel/console/cake | 3 +- cake/console/templates/skel/console/cake.bat | 3 +- cake/console/templates/skel/console/cake.php | 3 +- .../skel/controllers/pages_controller.php | 6 +- cake/console/templates/skel/index.php | 3 +- .../views/elements/email/html/default.ctp | 3 +- .../views/elements/email/text/default.ctp | 3 +- .../templates/skel/views/layouts/ajax.ctp | 3 +- .../templates/skel/views/layouts/default.ctp | 3 +- .../skel/views/layouts/email/html/default.ctp | 3 +- .../skel/views/layouts/email/text/default.ctp | 3 +- .../templates/skel/views/layouts/flash.ctp | 3 +- cake/console/templates/skel/webroot/css.php | 3 +- .../skel/webroot/css/cake.generic.css | 3 +- cake/console/templates/skel/webroot/index.php | 3 +- cake/console/templates/skel/webroot/test.php | 3 +- cake/libs/app.php | 6 +- cake/libs/cache.php | 3 +- cake/libs/cache/apc.php | 6 +- cake/libs/cache/file.php | 6 +- cake/libs/cache/memcache.php | 6 +- cake/libs/cache/xcache.php | 6 +- cake/libs/cake_log.php | 6 +- cake/libs/cake_request.php | 1 - cake/libs/cake_response.php | 3 +- cake/libs/cake_session.php | 6 +- cake/libs/cake_socket.php | 6 +- cake/libs/class_registry.php | 6 +- cake/libs/config/ini_reader.php | 3 +- cake/libs/config/php_reader.php | 3 +- cake/libs/configure.php | 6 +- cake/libs/controller/app_controller.php | 6 +- .../libs/controller/cake_error_controller.php | 3 +- cake/libs/controller/component.php | 6 +- cake/libs/controller/component_collection.php | 3 +- cake/libs/controller/components/acl.php | 15 +- cake/libs/controller/components/auth.php | 6 +- cake/libs/controller/components/cookie.php | 6 +- cake/libs/controller/components/email.php | 6 +- cake/libs/controller/components/paginator.php | 6 +- .../controller/components/request_handler.php | 6 +- cake/libs/controller/components/security.php | 6 +- cake/libs/controller/components/session.php | 6 +- cake/libs/controller/controller.php | 3 +- cake/libs/controller/pages_controller.php | 6 +- cake/libs/controller/scaffold.php | 6 +- cake/libs/debugger.php | 6 +- cake/libs/dispatcher.php | 4 +- cake/libs/error/error_handler.php | 6 +- cake/libs/error/exception_renderer.php | 6 +- cake/libs/error/exceptions.php | 3 +- cake/libs/file.php | 6 +- cake/libs/folder.php | 6 +- cake/libs/http/basic_authentication.php | 6 +- cake/libs/http/digest_authentication.php | 6 +- cake/libs/http_response.php | 3 +- cake/libs/http_socket.php | 6 +- cake/libs/i18n.php | 6 +- cake/libs/inflector.php | 6 +- cake/libs/l10n.php | 6 +- cake/libs/log/file_log.php | 6 +- cake/libs/magic_db.php | 7 +- cake/libs/model/app_model.php | 6 +- cake/libs/model/behavior_collection.php | 6 +- cake/libs/model/behaviors/acl.php | 6 +- cake/libs/model/behaviors/containable.php | 6 +- cake/libs/model/behaviors/translate.php | 9 +- cake/libs/model/behaviors/tree.php | 6 +- cake/libs/model/cake_schema.php | 6 +- cake/libs/model/connection_manager.php | 6 +- cake/libs/model/datasources/datasource.php | 6 +- cake/libs/model/datasources/dbo/dbo_mssql.php | 6 +- cake/libs/model/datasources/dbo/dbo_mysql.php | 6 +- .../libs/model/datasources/dbo/dbo_oracle.php | 6 +- .../model/datasources/dbo/dbo_postgres.php | 6 +- .../libs/model/datasources/dbo/dbo_sqlite.php | 5 +- cake/libs/model/datasources/dbo_source.php | 6 +- cake/libs/model/db_acl.php | 18 +- cake/libs/model/model.php | 6 +- cake/libs/model/model_behavior.php | 3 +- cake/libs/multibyte.php | 6 +- cake/libs/object.php | 5 +- cake/libs/route/cake_route.php | 3 +- cake/libs/route/plugin_short_route.php | 3 +- cake/libs/route/redirect_route.php | 3 +- cake/libs/router.php | 3 +- cake/libs/sanitize.php | 6 +- cake/libs/security.php | 6 +- cake/libs/session/cache_session.php | 6 +- cake/libs/session/database_session.php | 5 +- cake/libs/set.php | 6 +- cake/libs/string.php | 6 +- cake/libs/validation.php | 6 +- .../libs/view/elements/email/html/default.ctp | 3 +- .../libs/view/elements/email/text/default.ctp | 3 +- .../view/elements/exception_stack_trace.ctp | 3 +- cake/libs/view/elements/sql_dump.ctp | 3 +- cake/libs/view/errors/error400.ctp | 3 +- cake/libs/view/errors/error500.ctp | 3 +- cake/libs/view/errors/missing_action.ctp | 3 +- .../view/errors/missing_behavior_class.ctp | 3 +- .../view/errors/missing_behavior_file.ctp | 3 +- .../view/errors/missing_component_class.ctp | 3 +- .../view/errors/missing_component_file.ctp | 3 +- cake/libs/view/errors/missing_connection.ctp | 3 +- cake/libs/view/errors/missing_controller.ctp | 3 +- cake/libs/view/errors/missing_database.ctp | 3 +- .../libs/view/errors/missing_helper_class.ctp | 3 +- cake/libs/view/errors/missing_helper_file.ctp | 3 +- cake/libs/view/errors/missing_layout.ctp | 3 +- cake/libs/view/errors/missing_table.ctp | 3 +- cake/libs/view/errors/missing_view.ctp | 3 +- cake/libs/view/errors/private_action.ctp | 3 +- cake/libs/view/errors/scaffold_error.ctp | 3 +- cake/libs/view/helper.php | 6 +- cake/libs/view/helper_collection.php | 3 +- cake/libs/view/helpers/app_helper.php | 5 +- cake/libs/view/helpers/cache.php | 6 +- cake/libs/view/helpers/form.php | 14 +- cake/libs/view/helpers/html.php | 6 +- cake/libs/view/helpers/jquery_engine.php | 3 +- cake/libs/view/helpers/js.php | 6 +- cake/libs/view/helpers/mootools_engine.php | 3 +- cake/libs/view/helpers/number.php | 6 +- cake/libs/view/helpers/paginator.php | 6 +- cake/libs/view/helpers/prototype_engine.php | 3 +- cake/libs/view/helpers/rss.php | 6 +- cake/libs/view/helpers/session.php | 6 +- cake/libs/view/helpers/text.php | 6 +- cake/libs/view/helpers/time.php | 6 +- cake/libs/view/layouts/ajax.ctp | 3 +- cake/libs/view/layouts/default.ctp | 3 +- cake/libs/view/layouts/email/html/default.ctp | 3 +- cake/libs/view/layouts/email/text/default.ctp | 3 +- cake/libs/view/layouts/flash.ctp | 3 +- cake/libs/view/media.php | 3 +- cake/libs/view/pages/home.ctp | 3 +- cake/libs/view/scaffold.php | 3 +- cake/libs/view/scaffolds/form.ctp | 3 +- cake/libs/view/scaffolds/index.ctp | 3 +- cake/libs/view/scaffolds/view.ctp | 3 +- cake/libs/view/theme.php | 6 +- cake/libs/view/view.php | 3 +- cake/libs/xml.php | 3 +- cake/tests/cases/basics.test.php | 6 +- cake/tests/cases/console/all_console.test.php | 6 +- .../cases/console/all_console_libs.test.php | 6 +- cake/tests/cases/console/all_shells.test.php | 6 +- cake/tests/cases/console/all_tasks.test.php | 6 +- .../libs/console_error_handler.test.php | 3 +- .../libs/console_option_parser.test.php | 3 +- .../console/libs/console_output.test.php | 3 +- .../console/libs/task_collection.test.php | 3 +- .../cases/console/shell_dispatcher.test.php | 9 +- cake/tests/cases/console/shells/acl.test.php | 6 +- cake/tests/cases/console/shells/api.test.php | 6 +- cake/tests/cases/console/shells/bake.test.php | 3 +- .../console/shells/command_list.test.php | 3 +- .../cases/console/shells/schema.test.php | 9 +- .../tests/cases/console/shells/shell.test.php | 15 +- .../console/shells/tasks/controller.test.php | 6 +- .../console/shells/tasks/db_config.test.php | 6 +- .../console/shells/tasks/extract.test.php | 6 +- .../console/shells/tasks/fixture.test.php | 6 +- .../cases/console/shells/tasks/model.test.php | 6 +- .../console/shells/tasks/plugin.test.php | 6 +- .../console/shells/tasks/project.test.php | 6 +- .../console/shells/tasks/template.test.php | 6 +- .../cases/console/shells/tasks/test.test.php | 16 +- .../cases/console/shells/tasks/view.test.php | 14 +- .../cases/console/shells/testsuite.test.php | 3 +- cake/tests/cases/libs/all_behaviors.test.php | 6 +- .../cases/libs/all_cache_engines.test.php | 6 +- cake/tests/cases/libs/all_components.test.php | 6 +- cake/tests/cases/libs/all_configure.test.php | 6 +- .../tests/cases/libs/all_controllers.test.php | 6 +- cake/tests/cases/libs/all_database.test.php | 6 +- cake/tests/cases/libs/all_error.test.php | 6 +- cake/tests/cases/libs/all_helpers.test.php | 6 +- cake/tests/cases/libs/all_js_helpers.test.php | 6 +- cake/tests/cases/libs/all_libs.test.php | 6 +- .../cases/libs/all_localization.test.php | 6 +- cake/tests/cases/libs/all_model.test.php | 6 +- cake/tests/cases/libs/all_routing.test.php | 6 +- cake/tests/cases/libs/all_socket.test.php | 6 +- cake/tests/cases/libs/all_test_suite.test.php | 6 +- cake/tests/cases/libs/all_tests.test.php | 6 +- cake/tests/cases/libs/all_views.test.php | 6 +- cake/tests/cases/libs/all_xml.test.php | 6 +- cake/tests/cases/libs/app.test.php | 3 +- cake/tests/cases/libs/cache.test.php | 6 +- cake/tests/cases/libs/cache/apc.test.php | 6 +- cake/tests/cases/libs/cache/file.test.php | 6 +- cake/tests/cases/libs/cache/memcache.test.php | 6 +- cake/tests/cases/libs/cache/xcache.test.php | 6 +- cake/tests/cases/libs/cake_log.test.php | 6 +- cake/tests/cases/libs/cake_request.test.php | 3 +- cake/tests/cases/libs/cake_session.test.php | 6 +- cake/tests/cases/libs/cake_socket.test.php | 6 +- cake/tests/cases/libs/cake_test_case.test.php | 6 +- .../cases/libs/cake_test_fixture.test.php | 17 +- cake/tests/cases/libs/class_registry.test.php | 27 +- .../cases/libs/config/ini_reader.test.php | 3 +- .../cases/libs/config/php_reader.test.php | 3 +- cake/tests/cases/libs/configure.test.php | 6 +- .../cases/libs/controller/component.test.php | 30 +- .../controller/component_collection.test.php | 3 +- .../libs/controller/components/acl.test.php | 21 +- .../libs/controller/components/auth.test.php | 19 +- .../controller/components/cookie.test.php | 9 +- .../libs/controller/components/email.test.php | 12 +- .../controller/components/paginator.test.php | 15 +- .../components/request_handler.test.php | 12 +- .../controller/components/security.test.php | 10 +- .../controller/components/session.test.php | 12 +- .../cases/libs/controller/controller.test.php | 33 +- .../controller/controller_merge_vars.test.php | 5 +- .../libs/controller/pages_controller.test.php | 6 +- .../cases/libs/controller/scaffold.test.php | 33 +- .../cases/libs/controller_test_case.test.php | 12 +- cake/tests/cases/libs/debugger.test.php | 9 +- cake/tests/cases/libs/dispatcher.test.php | 39 +- .../cases/libs/error/error_handler.test.php | 6 +- .../libs/error/exception_renderer.test.php | 18 +- cake/tests/cases/libs/file.test.php | 6 +- cake/tests/cases/libs/folder.test.php | 6 +- .../cases/libs/html_coverage_report.test.php | 1 - .../libs/http/basic_authentication.test.php | 6 +- .../libs/http/digest_authentication.test.php | 6 +- cake/tests/cases/libs/http_response.test.php | 9 +- cake/tests/cases/libs/http_socket.test.php | 8 +- cake/tests/cases/libs/i18n.test.php | 6 +- cake/tests/cases/libs/inflector.test.php | 4 +- cake/tests/cases/libs/l10n.test.php | 6 +- cake/tests/cases/libs/log/file_log.test.php | 6 +- cake/tests/cases/libs/magic_db.test.php | 12 +- .../libs/model/behavior_collection.test.php | 27 +- .../cases/libs/model/behaviors/acl.test.php | 11 +- .../libs/model/behaviors/containable.test.php | 6 +- .../libs/model/behaviors/translate.test.php | 6 +- .../cases/libs/model/behaviors/tree.test.php | 15 +- .../cases/libs/model/cake_schema.test.php | 35 +- .../libs/model/connection_manager.test.php | 6 +- .../model/datasources/dbo/dbo_mssql.test.php | 15 +- .../model/datasources/dbo/dbo_mysql.test.php | 6 +- .../model/datasources/dbo/dbo_oracle.test.php | 6 +- .../datasources/dbo/dbo_postgres.test.php | 15 +- .../model/datasources/dbo/dbo_sqlite.test.php | 9 +- .../model/datasources/dbo_source.test.php | 6 +- cake/tests/cases/libs/model/db_acl.test.php | 27 +- cake/tests/cases/libs/model/model.test.php | 6 +- .../cases/libs/model/model_delete.test.php | 6 +- .../libs/model/model_integration.test.php | 6 +- .../cases/libs/model/model_read.test.php | 6 +- .../libs/model/model_validation.test.php | 6 +- .../cases/libs/model/model_write.test.php | 6 +- cake/tests/cases/libs/model/models.php | 396 ++++++------------ cake/tests/cases/libs/multibyte.test.php | 6 +- cake/tests/cases/libs/object.test.php | 21 +- .../cases/libs/object_collection.test.php | 3 +- cake/tests/cases/libs/router.test.php | 6 +- cake/tests/cases/libs/sanitize.test.php | 12 +- cake/tests/cases/libs/security.test.php | 6 +- .../cases/libs/session/cache_session.test.php | 3 +- .../libs/session/database_session.test.php | 3 +- cake/tests/cases/libs/set.test.php | 6 +- cake/tests/cases/libs/string.test.php | 6 +- cake/tests/cases/libs/test_manager.test.php | 6 +- cake/tests/cases/libs/validation.test.php | 9 +- cake/tests/cases/libs/view/helper.test.php | 21 +- .../libs/view/helper_collection.test.php | 3 +- .../cases/libs/view/helpers/cache.test.php | 9 +- .../cases/libs/view/helpers/form.test.php | 27 +- .../cases/libs/view/helpers/html.test.php | 9 +- .../libs/view/helpers/jquery_engine.test.php | 2 +- .../tests/cases/libs/view/helpers/js.test.php | 6 +- .../view/helpers/mootools_engine.test.php | 2 +- .../cases/libs/view/helpers/number.test.php | 6 +- .../libs/view/helpers/paginator.test.php | 6 +- .../view/helpers/prototype_engine.test.php | 2 +- .../cases/libs/view/helpers/rss.test.php | 6 +- .../cases/libs/view/helpers/session.test.php | 6 +- .../cases/libs/view/helpers/text.test.php | 6 +- .../cases/libs/view/helpers/time.test.php | 6 +- cake/tests/cases/libs/view/media.test.php | 6 +- cake/tests/cases/libs/view/theme.test.php | 12 +- cake/tests/cases/libs/view/view.test.php | 15 +- cake/tests/cases/libs/xml.test.php | 12 +- cake/tests/fixtures/account_fixture.php | 6 +- cake/tests/fixtures/aco_action_fixture.php | 6 +- cake/tests/fixtures/aco_fixture.php | 6 +- cake/tests/fixtures/aco_two_fixture.php | 6 +- cake/tests/fixtures/ad_fixture.php | 6 +- cake/tests/fixtures/advertisement_fixture.php | 6 +- cake/tests/fixtures/after_tree_fixture.php | 6 +- .../fixtures/another_article_fixture.php | 6 +- cake/tests/fixtures/apple_fixture.php | 6 +- cake/tests/fixtures/aro_fixture.php | 6 +- cake/tests/fixtures/aro_two_fixture.php | 6 +- cake/tests/fixtures/aros_aco_fixture.php | 6 +- cake/tests/fixtures/aros_aco_two_fixture.php | 6 +- .../fixtures/article_featured_fixture.php | 6 +- .../article_featureds_tags_fixture.php | 6 +- cake/tests/fixtures/article_fixture.php | 6 +- cake/tests/fixtures/articles_tag_fixture.php | 6 +- cake/tests/fixtures/assert_tags_test_case.php | 3 +- cake/tests/fixtures/attachment_fixture.php | 6 +- .../auth_user_custom_field_fixture.php | 6 +- cake/tests/fixtures/auth_user_fixture.php | 6 +- cake/tests/fixtures/author_fixture.php | 6 +- cake/tests/fixtures/bake_article_fixture.php | 6 +- .../bake_articles_bake_tag_fixture.php | 6 +- cake/tests/fixtures/bake_comment_fixture.php | 6 +- cake/tests/fixtures/bake_tag_fixture.php | 6 +- cake/tests/fixtures/basket_fixture.php | 6 +- cake/tests/fixtures/bid_fixture.php | 6 +- cake/tests/fixtures/binary_test_fixture.php | 6 +- cake/tests/fixtures/book_fixture.php | 6 +- .../fixtures/cache_test_model_fixture.php | 6 +- cake/tests/fixtures/callback_fixture.php | 6 +- cake/tests/fixtures/campaign_fixture.php | 6 +- cake/tests/fixtures/category_fixture.php | 6 +- .../fixtures/category_thread_fixture.php | 6 +- cake/tests/fixtures/cd_fixture.php | 6 +- cake/tests/fixtures/comment_fixture.php | 6 +- .../fixtures/content_account_fixture.php | 6 +- cake/tests/fixtures/content_fixture.php | 6 +- .../fixtures/counter_cache_post_fixture.php | 6 +- ...e_post_nonstandard_primary_key_fixture.php | 6 +- .../fixtures/counter_cache_user_fixture.php | 6 +- ...e_user_nonstandard_primary_key_fixture.php | 6 +- cake/tests/fixtures/data_test_fixture.php | 6 +- cake/tests/fixtures/datatype_fixture.php | 6 +- cake/tests/fixtures/dependency_fixture.php | 6 +- cake/tests/fixtures/device_fixture.php | 6 +- .../fixtures/device_type_category_fixture.php | 6 +- cake/tests/fixtures/device_type_fixture.php | 6 +- .../fixtures/document_directory_fixture.php | 6 +- cake/tests/fixtures/document_fixture.php | 6 +- .../exterior_type_category_fixture.php | 6 +- cake/tests/fixtures/feature_set_fixture.php | 6 +- cake/tests/fixtures/featured_fixture.php | 6 +- cake/tests/fixtures/film_file_fixture.php | 6 +- cake/tests/fixtures/fixturized_test_case.php | 3 +- cake/tests/fixtures/flag_tree_fixture.php | 6 +- cake/tests/fixtures/fruit_fixture.php | 6 +- .../fixtures/fruits_uuid_tag_fixture.php | 6 +- .../fixtures/group_update_all_fixture.php | 6 +- cake/tests/fixtures/home_fixture.php | 6 +- cake/tests/fixtures/image_fixture.php | 6 +- cake/tests/fixtures/item_fixture.php | 6 +- .../fixtures/items_portfolio_fixture.php | 6 +- cake/tests/fixtures/join_a_b_fixture.php | 6 +- cake/tests/fixtures/join_a_c_fixture.php | 6 +- cake/tests/fixtures/join_a_fixture.php | 6 +- cake/tests/fixtures/join_b_fixture.php | 6 +- cake/tests/fixtures/join_c_fixture.php | 6 +- cake/tests/fixtures/join_thing_fixture.php | 6 +- cake/tests/fixtures/message_fixture.php | 6 +- .../my_categories_my_products_fixture.php | 6 +- .../my_categories_my_users_fixture.php | 6 +- cake/tests/fixtures/my_category_fixture.php | 6 +- cake/tests/fixtures/my_product_fixture.php | 6 +- cake/tests/fixtures/my_user_fixture.php | 6 +- cake/tests/fixtures/node_fixture.php | 6 +- cake/tests/fixtures/number_tree_fixture.php | 6 +- .../fixtures/number_tree_two_fixture.php | 6 +- .../fixtures/numeric_article_fixture.php | 6 +- .../fixtures/overall_favorite_fixture.php | 6 +- cake/tests/fixtures/person_fixture.php | 6 +- cake/tests/fixtures/portfolio_fixture.php | 6 +- cake/tests/fixtures/post_fixture.php | 6 +- cake/tests/fixtures/posts_tag_fixture.php | 6 +- cake/tests/fixtures/primary_model_fixture.php | 6 +- cake/tests/fixtures/product_fixture.php | 6 +- .../fixtures/product_update_all_fixture.php | 6 +- cake/tests/fixtures/project_fixture.php | 6 +- cake/tests/fixtures/sample_fixture.php | 6 +- .../fixtures/secondary_model_fixture.php | 6 +- cake/tests/fixtures/session_fixture.php | 6 +- .../tests/fixtures/something_else_fixture.php | 6 +- cake/tests/fixtures/something_fixture.php | 6 +- cake/tests/fixtures/stories_tag_fixture.php | 6 +- cake/tests/fixtures/story_fixture.php | 6 +- cake/tests/fixtures/syfile_fixture.php | 6 +- cake/tests/fixtures/tag_fixture.php | 6 +- .../fixtures/test_plugin_article_fixture.php | 6 +- .../fixtures/test_plugin_comment_fixture.php | 6 +- .../fixtures/the_paper_monkies_fixture.php | 6 +- cake/tests/fixtures/thread_fixture.php | 6 +- .../fixtures/translate_article_fixture.php | 6 +- cake/tests/fixtures/translate_fixture.php | 6 +- .../fixtures/translate_table_fixture.php | 6 +- .../translate_with_prefix_fixture.php | 6 +- .../fixtures/translated_article_fixture.php | 6 +- .../fixtures/translated_item_fixture.php | 6 +- .../fixtures/unconventional_tree_fixture.php | 6 +- .../fixtures/underscore_field_fixture.php | 6 +- cake/tests/fixtures/user_fixture.php | 6 +- cake/tests/fixtures/uuid_fixture.php | 6 +- cake/tests/fixtures/uuid_tag_fixture.php | 6 +- cake/tests/fixtures/uuid_tree_fixture.php | 6 +- cake/tests/fixtures/uuiditem_fixture.php | 6 +- .../uuiditems_uuidportfolio_fixture.php | 6 +- ...ditems_uuidportfolio_numericid_fixture.php | 6 +- cake/tests/fixtures/uuidportfolio_fixture.php | 6 +- cake/tests/lib/cake_fixture_manager.php | 3 +- cake/tests/lib/cake_test_case.php | 6 +- cake/tests/lib/cake_test_fixture.php | 6 +- cake/tests/lib/cake_test_model.php | 6 +- cake/tests/lib/cake_test_suite.php | 3 +- cake/tests/lib/cake_test_suite_dispatcher.php | 3 +- cake/tests/lib/cake_web_test_case.php | 6 +- cake/tests/lib/controller_test_case.php | 12 +- .../lib/coverage/base_coverage_report.php | 1 - .../lib/coverage/html_coverage_report.php | 1 - .../lib/coverage/text_coverage_report.php | 1 - .../tests/lib/reporter/cake_base_reporter.php | 5 +- .../tests/lib/reporter/cake_html_reporter.php | 5 +- .../tests/lib/reporter/cake_text_reporter.php | 5 +- cake/tests/lib/templates/footer.php | 3 +- cake/tests/lib/templates/header.php | 3 +- cake/tests/lib/templates/menu.php | 3 +- .../lib/templates/missing_conenction.php | 3 +- cake/tests/lib/templates/phpunit.php | 3 +- cake/tests/lib/templates/xdebug.php | 3 +- cake/tests/lib/test_manager.php | 6 +- cake/tests/lib/test_runner.php | 6 +- cake/tests/test_app/config/acl.ini.php | 3 +- cake/tests/test_app/config/routes.php | 3 +- cake/tests/test_app/console/shells/sample.php | 3 +- .../controllers/tests_apps_controller.php | 3 +- .../tests_apps_posts_controller.php | 3 +- .../test_app/libs/cache/test_app_cache.php | 3 +- cake/tests/test_app/libs/library.php | 3 +- cake/tests/test_app/libs/log/test_app_log.php | 3 +- .../behaviors/persister_one_behavior.php | 6 +- .../behaviors/persister_two_behavior.php | 6 +- cake/tests/test_app/models/comment.php | 3 +- cake/tests/test_app/models/persister_one.php | 3 +- cake/tests/test_app/models/persister_two.php | 3 +- cake/tests/test_app/models/post.php | 3 +- .../plugins/test_plugin/config/load.php | 3 +- .../plugins/test_plugin/config/more.load.php | 3 +- .../test_plugin/config/schema/schema.php | 3 +- .../test_plugin/console/shells/example.php | 3 +- .../console/shells/tasks/other_task.php | 3 +- .../components/other_component.php | 3 +- .../components/plugins_component.php | 3 +- .../components/test_plugin_component.php | 3 +- .../test_plugin_other_component.php | 3 +- .../controllers/test_plugin_controller.php | 3 +- .../controllers/tests_controller.php | 3 +- .../libs/cache/test_plugin_cache.php | 3 +- .../test_plugin/libs/log/test_plugin_log.php | 3 +- .../test_plugin/libs/test_plugin_library.php | 3 +- .../behaviors/test_plugin_persister_one.php | 6 +- .../behaviors/test_plugin_persister_two.php | 6 +- .../models/test_plugin_auth_user.php | 3 +- .../models/test_plugin_authors.php | 3 +- .../models/test_plugin_comment.php | 3 +- .../test_plugin/models/test_plugin_post.php | 3 +- .../test_plugin_app_controller.php | 3 +- .../test_plugin/test_plugin_app_model.php | 3 +- .../vendors/sample/sample_plugin.php | 3 +- .../plugins/test_plugin/vendors/welcome.php | 3 +- .../views/helpers/other_helper.php | 3 +- .../views/helpers/plugged_helper.php | 3 +- .../console/shells/example.php | 3 +- .../console/shells/welcome.php | 3 +- cake/tests/test_app/vendors/Test/MyTest.php | 3 +- cake/tests/test_app/vendors/Test/hello.php | 3 +- .../sample/configure_test_vendor_sample.php | 3 +- .../test_app/vendors/somename/some.name.php | 3 +- cake/tests/test_app/vendors/welcome.php | 3 +- .../views/elements/email/html/custom.ctp | 3 +- .../views/elements/email/html/default.ctp | 3 +- .../views/elements/email/text/custom.ctp | 3 +- .../views/elements/email/text/default.ctp | 3 +- .../views/elements/email/text/wide.ctp | 3 +- cake/tests/test_app/views/helpers/banana.php | 3 +- cake/tests/test_app/views/layouts/ajax.ctp | 3 +- cake/tests/test_app/views/layouts/ajax2.ctp | 3 +- .../test_app/views/layouts/cache_layout.ctp | 3 +- cake/tests/test_app/views/layouts/default.ctp | 3 +- .../views/layouts/email/html/default.ctp | 3 +- .../views/layouts/email/html/thin.ctp | 3 +- .../views/layouts/email/text/default.ctp | 3 +- cake/tests/test_app/views/layouts/flash.ctp | 3 +- .../test_app/views/layouts/multi_cache.ctp | 3 +- .../views/posts/sequencial_nocache.ctp | 3 +- .../views/posts/test_nocache_tags.ctp | 3 +- index.php | 1 - 583 files changed, 1241 insertions(+), 2436 deletions(-) diff --git a/app/config/acl.ini.php b/app/config/acl.ini.php index c3e055341..3245634aa 100644 --- a/app/config/acl.ini.php +++ b/app/config/acl.ini.php @@ -14,8 +14,7 @@ ; * ; * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) ; * @link http://cakephp.org CakePHP(tm) Project -; * @package cake -; * @subpackage cake.app.config +; * @package app.config ; * @since CakePHP(tm) v 0.10.0.1076 ; * @license MIT License (http://www.opensource.org/licenses/mit-license.php) ; */ diff --git a/app/config/bootstrap.php b/app/config/bootstrap.php index b0c33554b..ceeb85670 100644 --- a/app/config/bootstrap.php +++ b/app/config/bootstrap.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config + * @package app.config * @since CakePHP(tm) v 0.10.8.2117 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/app/config/core.php b/app/config/core.php index c9560d15a..9744da06c 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config + * @package app.config * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/app/config/database.php.default b/app/config/database.php.default index f85b56922..2078240ea 100644 --- a/app/config/database.php.default +++ b/app/config/database.php.default @@ -14,16 +14,14 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config + * @package app.config * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ /** * In this file you set up your database connection details. * - * @package cake - * @subpackage cake.config + * @package cake.config */ /** * Database configuration class. diff --git a/app/config/routes.php b/app/config/routes.php index 4e470c363..cbb816e18 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -16,8 +16,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config + * @package app.config * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/app/config/schema/db_acl.php b/app/config/schema/db_acl.php index d13a20609..25b6ee6df 100644 --- a/app/config/schema/db_acl.php +++ b/app/config/schema/db_acl.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config.sql + * @package app.config.sql * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/app/config/schema/i18n.php b/app/config/schema/i18n.php index 13db98f12..f57bbce7f 100644 --- a/app/config/schema/i18n.php +++ b/app/config/schema/i18n.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config.sql + * @package app.config.sql * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/app/config/schema/sessions.php b/app/config/schema/sessions.php index 584d0002b..e5ae37dc1 100644 --- a/app/config/schema/sessions.php +++ b/app/config/schema/sessions.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config.sql + * @package app.config.sql * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/app/console/cake b/app/console/cake index d4d067d59..bd1b6da06 100755 --- a/app/console/cake +++ b/app/console/cake @@ -12,8 +12,7 @@ # # @copyright Copyright 2005-2010, Cake Software Foundation, Inc. # @link http://cakephp.org CakePHP(tm) Project -# @package cake -# @subpackage cake.app.console +# @package app.console # @since CakePHP(tm) v 2.0 # @license MIT License (http://www.opensource.org/licenses/mit-license.php) # diff --git a/app/console/cake.bat b/app/console/cake.bat index 6499c2f22..ed04546c9 100644 --- a/app/console/cake.bat +++ b/app/console/cake.bat @@ -10,9 +10,8 @@ :: Redistributions of files must retain the above copyright notice. :: :: @copyright Copyright 2005-2010, Cake Software Foundation, Inc. -:: @link http://cakephp.org CakePHP(tm) Project -:: @package cake -:: @subpackage cake.app.console +:: @link http://cakephp.org CakePHP(tm) Project +:: @package app.console :: @since CakePHP(tm) v 2.0 :: @license MIT License (http://www.opensource.org/licenses/mit-license.php) :: diff --git a/app/console/cake.php b/app/console/cake.php index af02ae4ff..9200fd36b 100755 --- a/app/console/cake.php +++ b/app/console/cake.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console + * @package app.console * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/app/index.php b/app/index.php index a9e0270cb..ac4fde167 100644 --- a/app/index.php +++ b/app/index.php @@ -10,8 +10,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app + * @package app * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/app/webroot/css.php b/app/webroot/css.php index 26cddcb14..19ba84dc2 100644 --- a/app/webroot/css.php +++ b/app/webroot/css.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.webroot + * @package app.webroot * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/app/webroot/css/cake.generic.css b/app/webroot/css/cake.generic.css index 4f6f5a2cd..3559401dc 100644 --- a/app/webroot/css/cake.generic.css +++ b/app/webroot/css/cake.generic.css @@ -10,8 +10,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.webroot.css + * @package app.webroot.css * @since CakePHP(tm) * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/app/webroot/index.php b/app/webroot/index.php index 719f172c4..5955688f6 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.webroot + * @package app.webroot * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/app/webroot/test.php b/app/webroot/test.php index 7a27e8e29..eddcc437f 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing - * @package cake - * @subpackage cake.app.webroot + * @package app.webroot * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/VERSION.txt b/cake/VERSION.txt index e5c64475c..90bd8f82d 100644 --- a/cake/VERSION.txt +++ b/cake/VERSION.txt @@ -12,8 +12,7 @@ // // @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) // @link http://cakephp.org -// @package cake -// @subpackage cake.cake.libs +// @package cake.libs // @since CakePHP(tm) v 0.2.9 // @license MIT License (http://www.opensource.org/licenses/mit-license.php) // +--------------------------------------------------------------------------------------------+ // diff --git a/cake/basics.php b/cake/basics.php index a5ee633dd..5a968cdeb 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -15,7 +15,6 @@ * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package cake - * @subpackage cake.cake * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/bootstrap.php b/cake/bootstrap.php index acfc7bb2f..65931eb39 100644 --- a/cake/bootstrap.php +++ b/cake/bootstrap.php @@ -15,7 +15,6 @@ * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package cake - * @subpackage cake.cake * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/config.php b/cake/config/config.php index 071441c21..30b6e24d1 100644 --- a/cake/config/config.php +++ b/cake/config/config.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config + * @package cake.config * @since CakePHP(tm) v 1.1.11.4062 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/paths.php b/cake/config/paths.php index e8ac21c49..365cdb4c1 100644 --- a/cake/config/paths.php +++ b/cake/config/paths.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.app.config + * @package cake.config * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/0080_00ff.php b/cake/config/unicode/casefolding/0080_00ff.php index 0d2fa16be..ef01fe904 100644 --- a/cake/config/unicode/casefolding/0080_00ff.php +++ b/cake/config/unicode/casefolding/0080_00ff.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/0100_017f.php b/cake/config/unicode/casefolding/0100_017f.php index 64ab7d393..1f7f1449c 100644 --- a/cake/config/unicode/casefolding/0100_017f.php +++ b/cake/config/unicode/casefolding/0100_017f.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/0180_024F.php b/cake/config/unicode/casefolding/0180_024F.php index 23c692632..f2a5a849b 100644 --- a/cake/config/unicode/casefolding/0180_024F.php +++ b/cake/config/unicode/casefolding/0180_024F.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/0250_02af.php b/cake/config/unicode/casefolding/0250_02af.php index 1ef96c6af..3140c1312 100644 --- a/cake/config/unicode/casefolding/0250_02af.php +++ b/cake/config/unicode/casefolding/0250_02af.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.6833 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/0370_03ff.php b/cake/config/unicode/casefolding/0370_03ff.php index 50618afb8..7609089da 100644 --- a/cake/config/unicode/casefolding/0370_03ff.php +++ b/cake/config/unicode/casefolding/0370_03ff.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/0400_04ff.php b/cake/config/unicode/casefolding/0400_04ff.php index a04d3df66..3b12b059e 100644 --- a/cake/config/unicode/casefolding/0400_04ff.php +++ b/cake/config/unicode/casefolding/0400_04ff.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/0500_052f.php b/cake/config/unicode/casefolding/0500_052f.php index 661f66d63..453b9b7df 100644 --- a/cake/config/unicode/casefolding/0500_052f.php +++ b/cake/config/unicode/casefolding/0500_052f.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/0530_058f.php b/cake/config/unicode/casefolding/0530_058f.php index 232649ec4..3181438ec 100644 --- a/cake/config/unicode/casefolding/0530_058f.php +++ b/cake/config/unicode/casefolding/0530_058f.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/1e00_1eff.php b/cake/config/unicode/casefolding/1e00_1eff.php index 3a8378691..ed49211a9 100644 --- a/cake/config/unicode/casefolding/1e00_1eff.php +++ b/cake/config/unicode/casefolding/1e00_1eff.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/1f00_1fff.php b/cake/config/unicode/casefolding/1f00_1fff.php index a4040b852..2b0d24bf2 100644 --- a/cake/config/unicode/casefolding/1f00_1fff.php +++ b/cake/config/unicode/casefolding/1f00_1fff.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/2100_214f.php b/cake/config/unicode/casefolding/2100_214f.php index 1685ebb71..a10d613f4 100644 --- a/cake/config/unicode/casefolding/2100_214f.php +++ b/cake/config/unicode/casefolding/2100_214f.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/2150_218f.php b/cake/config/unicode/casefolding/2150_218f.php index 44bf3ff89..6ccd3de8c 100644 --- a/cake/config/unicode/casefolding/2150_218f.php +++ b/cake/config/unicode/casefolding/2150_218f.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/2460_24ff.php b/cake/config/unicode/casefolding/2460_24ff.php index 4376e2b71..2e7a85321 100644 --- a/cake/config/unicode/casefolding/2460_24ff.php +++ b/cake/config/unicode/casefolding/2460_24ff.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/2c00_2c5f.php b/cake/config/unicode/casefolding/2c00_2c5f.php index e8a70bc32..797cf964d 100644 --- a/cake/config/unicode/casefolding/2c00_2c5f.php +++ b/cake/config/unicode/casefolding/2c00_2c5f.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/2c60_2c7f.php b/cake/config/unicode/casefolding/2c60_2c7f.php index dabdb88a2..058193ca6 100644 --- a/cake/config/unicode/casefolding/2c60_2c7f.php +++ b/cake/config/unicode/casefolding/2c60_2c7f.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/2c80_2cff.php b/cake/config/unicode/casefolding/2c80_2cff.php index c0245fa16..d439bc2e7 100644 --- a/cake/config/unicode/casefolding/2c80_2cff.php +++ b/cake/config/unicode/casefolding/2c80_2cff.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/config/unicode/casefolding/ff00_ffef.php b/cake/config/unicode/casefolding/ff00_ffef.php index 74a2b5c4a..0b8106532 100644 --- a/cake/config/unicode/casefolding/ff00_ffef.php +++ b/cake/config/unicode/casefolding/ff00_ffef.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.config.unicode.casefolding + * @package cake.config.unicode.casefolding * @since CakePHP(tm) v 1.2.0.5691 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/cake b/cake/console/cake index d0bdb5cc0..81df781da 100755 --- a/cake/console/cake +++ b/cake/console/cake @@ -12,9 +12,8 @@ # # @copyright Copyright 2005-2010, Cake Software Foundation, Inc. # @link http://cakephp.org CakePHP(tm) Project -# @package cake -# @subpackage cake.cake.console -# @since CakePHP(tm) v 1.2.0.5012 +# @package cake.console +# @since CakePHP(tm) v 1.2.0.5012 # @license MIT License (http://www.opensource.org/licenses/mit-license.php) # ################################################################################ diff --git a/cake/console/cake.bat b/cake/console/cake.bat index cb1831d94..40a271425 100644 --- a/cake/console/cake.bat +++ b/cake/console/cake.bat @@ -10,9 +10,8 @@ :: Redistributions of files must retain the above copyright notice. :: :: @copyright Copyright 2005-2010, Cake Software Foundation, Inc. -:: @link http://cakephp.org CakePHP(tm) Project -:: @package cake -:: @subpackage cake.cake.console +:: @link http://cakephp.org CakePHP(tm) Project +:: @package cake.console :: @since CakePHP(tm) v 1.2.0.5012 :: @license MIT License (http://www.opensource.org/licenses/mit-license.php) :: diff --git a/cake/console/cake.php b/cake/console/cake.php index 02468c38f..c9bce3193 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console + * @package cake.console * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/console_error_handler.php b/cake/console/libs/console_error_handler.php index bd2228c7a..2de7b2e25 100644 --- a/cake/console/libs/console_error_handler.php +++ b/cake/console/libs/console_error_handler.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console + * @package cake.console * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ require_once 'console_output.php'; * Error Handler for Cake console. Does simple printing of the * exception that occurred and the stack trace of the error. * - * @package cake - * @subpackage cake.cake.console + * @package cake.console */ class ConsoleErrorHandler extends ErrorHandler { diff --git a/cake/console/libs/console_input.php b/cake/console/libs/console_input.php index 751035f53..da3551399 100644 --- a/cake/console/libs/console_input.php +++ b/cake/console/libs/console_input.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.console + * @package cake.console * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/console_input_argument.php b/cake/console/libs/console_input_argument.php index 34ce98414..b2e9d4f16 100644 --- a/cake/console/libs/console_input_argument.php +++ b/cake/console/libs/console_input_argument.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console + * @package cake.console * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/console_input_option.php b/cake/console/libs/console_input_option.php index 925d64dd4..c72638eca 100644 --- a/cake/console/libs/console_input_option.php +++ b/cake/console/libs/console_input_option.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console + * @package cake.console * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/console_input_subcommand.php b/cake/console/libs/console_input_subcommand.php index d628425c8..82048b853 100644 --- a/cake/console/libs/console_input_subcommand.php +++ b/cake/console/libs/console_input_subcommand.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console + * @package cake.console * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/console_option_parser.php b/cake/console/libs/console_option_parser.php index 6e9dcce39..2f63651ec 100644 --- a/cake/console/libs/console_option_parser.php +++ b/cake/console/libs/console_option_parser.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console + * @package cake.console * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ require_once CONSOLE_LIBS . 'help_formatter.php'; * for GetOpt compatible option definition. Provides a builder pattern implementation * for creating shell option parsers. * - * @package cake - * @subpackage cake.cake.console + * @package cake.console */ class ConsoleOptionParser { diff --git a/cake/console/libs/console_output.php b/cake/console/libs/console_output.php index 5f89ac100..27c1c4e66 100644 --- a/cake/console/libs/console_output.php +++ b/cake/console/libs/console_output.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console + * @package cake.console * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/task_collection.php b/cake/console/libs/task_collection.php index d28b13b6d..32f0b31a4 100644 --- a/cake/console/libs/task_collection.php +++ b/cake/console/libs/task_collection.php @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/shell_dispatcher.php b/cake/console/shell_dispatcher.php index 029a91442..1b520500b 100644 --- a/cake/console/shell_dispatcher.php +++ b/cake/console/shell_dispatcher.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console + * @package cake.console * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Shell dispatcher handles dispatching cli commands. * - * @package cake - * @subpackage cake.cake.console + * @package cake.console */ class ShellDispatcher { diff --git a/cake/console/shells/acl.php b/cake/console/shells/acl.php index e29e4f4ef..5fe8f70e6 100644 --- a/cake/console/shells/acl.php +++ b/cake/console/shells/acl.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ App::import('Model', 'DbAcl'); * Shell for ACL management. This console is known to have issues with zend.ze1_compatibility_mode * being enabled. Be sure to turn it off when using this shell. * - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs */ class AclShell extends Shell { diff --git a/cake/console/shells/api.php b/cake/console/shells/api.php index 0c036d09d..5abd5d48b 100644 --- a/cake/console/shells/api.php +++ b/cake/console/shells/api.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ App::import('Core', 'File'); /** * API shell to show method signatures of CakePHP core classes. * - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs */ class ApiShell extends Shell { diff --git a/cake/console/shells/app_shell.php b/cake/console/shells/app_shell.php index 59fcc2a09..a624a31ad 100644 --- a/cake/console/shells/app_shell.php +++ b/cake/console/shells/app_shell.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.console.shells + * @package cake.console.shells * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ * Add your application-wide methods in the class below, your shells * will inherit them. * - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs */ class AppShell extends Shell { diff --git a/cake/console/shells/bake.php b/cake/console/shells/bake.php index 7e4dbb016..266b6495c 100644 --- a/cake/console/shells/bake.php +++ b/cake/console/shells/bake.php @@ -16,8 +16,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ /** * Bake is a command-line code generation utility for automating programmer chores. * - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @link http://book.cakephp.org/view/1522/Code-Generation-with-Bake */ class BakeShell extends Shell { diff --git a/cake/console/shells/command_list.php b/cake/console/shells/command_list.php index cd05af4ba..9a198b47c 100644 --- a/cake/console/shells/command_list.php +++ b/cake/console/shells/command_list.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.console.libs + * @package cake.tests.cases.console.libs * @since CakePHP v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/shells/console.php b/cake/console/shells/console.php index 20ab1615d..b3b1033ae 100644 --- a/cake/console/shells/console.php +++ b/cake/console/shells/console.php @@ -12,15 +12,13 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ /** - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs */ class ConsoleShell extends Shell { diff --git a/cake/console/shells/i18n.php b/cake/console/shells/i18n.php index c40160e54..13477eb44 100644 --- a/cake/console/shells/i18n.php +++ b/cake/console/shells/i18n.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @since CakePHP(tm) v 1.2.0.5669 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Shell for I18N management. * - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs */ class I18nShell extends Shell { diff --git a/cake/console/shells/schema.php b/cake/console/shells/schema.php index 969fad12a..ed7090f53 100644 --- a/cake/console/shells/schema.php +++ b/cake/console/shells/schema.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @since CakePHP(tm) v 1.2.0.5550 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,8 +25,7 @@ App::import('Model', 'CakeSchema', false); /** * Schema is a command-line database management utility for automating programmer chores. * - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @link http://book.cakephp.org/view/1523/Schema-management-and-migrations */ class SchemaShell extends Shell { diff --git a/cake/console/shells/shell.php b/cake/console/shells/shell.php index 55c81f94d..ac6240329 100644 --- a/cake/console/shells/shell.php +++ b/cake/console/shells/shell.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ require_once CONSOLE_LIBS . 'console_option_parser.php'; /** * Base class for command-line utilities for automating programmer chores. * - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs */ class Shell extends Object { diff --git a/cake/console/shells/tasks/bake.php b/cake/console/shells/tasks/bake.php index 6a89e187c..61413e6e1 100644 --- a/cake/console/shells/tasks/bake.php +++ b/cake/console/shells/tasks/bake.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/shells/tasks/controller.php b/cake/console/shells/tasks/controller.php index 6ec3c4371..3a17a525c 100644 --- a/cake/console/shells/tasks/controller.php +++ b/cake/console/shells/tasks/controller.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ include_once dirname(__FILE__) . DS . 'bake.php'; /** * Task class for creating and updating controller files. * - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks */ class ControllerTask extends BakeTask { diff --git a/cake/console/shells/tasks/db_config.php b/cake/console/shells/tasks/db_config.php index a98b6b053..7cc811f2d 100644 --- a/cake/console/shells/tasks/db_config.php +++ b/cake/console/shells/tasks/db_config.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Task class for creating and updating the database configuration file. * - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks */ class DbConfigTask extends Shell { diff --git a/cake/console/shells/tasks/extract.php b/cake/console/shells/tasks/extract.php index 34c24314e..451b79417 100644 --- a/cake/console/shells/tasks/extract.php +++ b/cake/console/shells/tasks/extract.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ App::import('Core', 'File'); /** * Language string extractor * - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks */ class ExtractTask extends Shell { diff --git a/cake/console/shells/tasks/fixture.php b/cake/console/shells/tasks/fixture.php index 3bf60f3ae..f19585839 100644 --- a/cake/console/shells/tasks/fixture.php +++ b/cake/console/shells/tasks/fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ include_once dirname(__FILE__) . DS . 'bake.php'; /** * Task class for creating and updating fixtures files. * - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks */ class FixtureTask extends BakeTask { diff --git a/cake/console/shells/tasks/model.php b/cake/console/shells/tasks/model.php index ffa06640a..0af02a635 100644 --- a/cake/console/shells/tasks/model.php +++ b/cake/console/shells/tasks/model.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ include_once dirname(__FILE__) . DS . 'bake.php'; /** * Task class for creating and updating model files. * - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks */ class ModelTask extends BakeTask { diff --git a/cake/console/shells/tasks/plugin.php b/cake/console/shells/tasks/plugin.php index 6ae7bd5cb..1ea700081 100644 --- a/cake/console/shells/tasks/plugin.php +++ b/cake/console/shells/tasks/plugin.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'File'); /** * Task class for creating a plugin * - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks */ class PluginTask extends Shell { diff --git a/cake/console/shells/tasks/project.php b/cake/console/shells/tasks/project.php index bb2a8f34b..c773b57ac 100644 --- a/cake/console/shells/tasks/project.php +++ b/cake/console/shells/tasks/project.php @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.bake + * @package cake.console.bake * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Core', 'File'); /** * Task class for creating new project apps and plugins * - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks */ class ProjectTask extends Shell { diff --git a/cake/console/shells/tasks/template.php b/cake/console/shells/tasks/template.php index 85eed96c6..08dbb30eb 100644 --- a/cake/console/shells/tasks/template.php +++ b/cake/console/shells/tasks/template.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.console.libs.tasks + * @package cake.console.libs.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/shells/tasks/test.php b/cake/console/shells/tasks/test.php index 093457421..3e14c1fe8 100644 --- a/cake/console/shells/tasks/test.php +++ b/cake/console/shells/tasks/test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ App::import('Model', 'ClassRegistry'); /** * Task class for creating and updating test files. * - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks */ class TestTask extends BakeTask { diff --git a/cake/console/shells/tasks/view.php b/cake/console/shells/tasks/view.php index bf8777238..3e23d0d7e 100644 --- a/cake/console/shells/tasks/view.php +++ b/cake/console/shells/tasks/view.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ include_once dirname(__FILE__) . DS . 'bake.php'; /** * Task class for creating and updating view files. * - * @package cake - * @subpackage cake.cake.console.libs.tasks + * @package cake.console.libs.tasks */ class ViewTask extends BakeTask { diff --git a/cake/console/shells/testsuite.php b/cake/console/shells/testsuite.php index 8814242a2..2e477a0a9 100644 --- a/cake/console/shells/testsuite.php +++ b/cake/console/shells/testsuite.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/default/actions/controller_actions.ctp b/cake/console/templates/default/actions/controller_actions.ctp index 0a4c9d311..f80d3d374 100644 --- a/cake/console/templates/default/actions/controller_actions.ctp +++ b/cake/console/templates/default/actions/controller_actions.ctp @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.console.libs.template.objects + * @package cake.console.libs.template.objects * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/default/classes/controller.ctp b/cake/console/templates/default/classes/controller.ctp index a66e0faa5..52f968824 100644 --- a/cake/console/templates/default/classes/controller.ctp +++ b/cake/console/templates/default/classes/controller.ctp @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake. + * @package cake. * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/default/classes/fixture.ctp b/cake/console/templates/default/classes/fixture.ctp index a8d1bbfb2..dd1b5b478 100644 --- a/cake/console/templates/default/classes/fixture.ctp +++ b/cake/console/templates/default/classes/fixture.ctp @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake. + * @package cake. * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/default/classes/model.ctp b/cake/console/templates/default/classes/model.ctp index 222dd0da8..ece196dba 100644 --- a/cake/console/templates/default/classes/model.ctp +++ b/cake/console/templates/default/classes/model.ctp @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.console.libs.templates.objects + * @package cake.console.libs.templates.objects * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/default/classes/test.ctp b/cake/console/templates/default/classes/test.ctp index 5811e8446..f9dd98b0b 100644 --- a/cake/console/templates/default/classes/test.ctp +++ b/cake/console/templates/default/classes/test.ctp @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.console.libs.templates.objects + * @package cake.console.libs.templates.objects * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/default/views/form.ctp b/cake/console/templates/default/views/form.ctp index 85fef3fa0..ce2b525f9 100644 --- a/cake/console/templates/default/views/form.ctp +++ b/cake/console/templates/default/views/form.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.templates.views + * @package cake.console.libs.templates.views * @since CakePHP(tm) v 1.2.0.5234 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/default/views/index.ctp b/cake/console/templates/default/views/index.ctp index 0732fe058..01c834d64 100644 --- a/cake/console/templates/default/views/index.ctp +++ b/cake/console/templates/default/views/index.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.templates.views + * @package cake.console.libs.templates.views * @since CakePHP(tm) v 1.2.0.5234 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/default/views/view.ctp b/cake/console/templates/default/views/view.ctp index 9e791196f..8ed607d83 100644 --- a/cake/console/templates/default/views/view.ctp +++ b/cake/console/templates/default/views/view.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.templates.views + * @package cake.console.libs.templates.views * @since CakePHP(tm) v 1.2.0.5234 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/app_controller.php b/cake/console/templates/skel/app_controller.php index 2139202a3..8573bb7c4 100644 --- a/cake/console/templates/skel/app_controller.php +++ b/cake/console/templates/skel/app_controller.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app + * @package app * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ * Add your application-wide methods in the class below, your controllers * will inherit them. * - * @package cake - * @subpackage cake.app + * @package app */ class AppController extends Controller { } diff --git a/cake/console/templates/skel/app_helper.php b/cake/console/templates/skel/app_helper.php index 2dd482b90..02955a34e 100644 --- a/cake/console/templates/skel/app_helper.php +++ b/cake/console/templates/skel/app_helper.php @@ -16,7 +16,6 @@ * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package cake - * @subpackage cake.cake * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -30,7 +29,6 @@ App::import('Helper', 'Helper', false); * will inherit them. * * @package cake - * @subpackage cake.cake */ class AppHelper extends Helper { } diff --git a/cake/console/templates/skel/app_model.php b/cake/console/templates/skel/app_model.php index bb4236c45..87a130a8a 100644 --- a/cake/console/templates/skel/app_model.php +++ b/cake/console/templates/skel/app_model.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app + * @package app * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ * Add your application-wide methods in the class below, your models * will inherit them. * - * @package cake - * @subpackage cake.app + * @package app */ class AppModel extends Model { } diff --git a/cake/console/templates/skel/config/acl.ini.php b/cake/console/templates/skel/config/acl.ini.php index 7a90814db..3da8e407f 100644 --- a/cake/console/templates/skel/config/acl.ini.php +++ b/cake/console/templates/skel/config/acl.ini.php @@ -14,8 +14,7 @@ ; * ; * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) ; * @link http://cakephp.org CakePHP(tm) Project -; * @package cake -; * @subpackage cake.app.config +; * @package app.config ; * @since CakePHP(tm) v 0.10.0.1076 ; * @license MIT License (http://www.opensource.org/licenses/mit-license.php) ; */ diff --git a/cake/console/templates/skel/config/bootstrap.php b/cake/console/templates/skel/config/bootstrap.php index f4a85e10f..697274852 100644 --- a/cake/console/templates/skel/config/bootstrap.php +++ b/cake/console/templates/skel/config/bootstrap.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config + * @package app.config * @since CakePHP(tm) v 0.10.8.2117 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/config/core.php b/cake/console/templates/skel/config/core.php index c9560d15a..9744da06c 100644 --- a/cake/console/templates/skel/config/core.php +++ b/cake/console/templates/skel/config/core.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config + * @package app.config * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/config/database.php.default b/cake/console/templates/skel/config/database.php.default index 8003d2bbb..0952dac47 100644 --- a/cake/console/templates/skel/config/database.php.default +++ b/cake/console/templates/skel/config/database.php.default @@ -14,16 +14,14 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config + * @package app.config * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ /** * In this file you set up your database connection details. * - * @package cake - * @subpackage cake.config + * @package cake.config */ /** * Database configuration class. diff --git a/cake/console/templates/skel/config/routes.php b/cake/console/templates/skel/config/routes.php index 8aa7561ba..b6089eb2d 100644 --- a/cake/console/templates/skel/config/routes.php +++ b/cake/console/templates/skel/config/routes.php @@ -16,8 +16,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config + * @package app.config * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/config/schema/db_acl.php b/cake/console/templates/skel/config/schema/db_acl.php index 511250f62..8400e85ed 100644 --- a/cake/console/templates/skel/config/schema/db_acl.php +++ b/cake/console/templates/skel/config/schema/db_acl.php @@ -16,8 +16,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config.sql + * @package app.config.sql * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/config/schema/i18n.php b/cake/console/templates/skel/config/schema/i18n.php index a2f02ea72..504f00812 100644 --- a/cake/console/templates/skel/config/schema/i18n.php +++ b/cake/console/templates/skel/config/schema/i18n.php @@ -16,8 +16,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config.sql + * @package app.config.sql * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/config/schema/sessions.php b/cake/console/templates/skel/config/schema/sessions.php index 8a37814f4..29a40a566 100644 --- a/cake/console/templates/skel/config/schema/sessions.php +++ b/cake/console/templates/skel/config/schema/sessions.php @@ -16,8 +16,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config.sql + * @package app.config.sql * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/console/cake b/cake/console/templates/skel/console/cake index d4d067d59..bd1b6da06 100644 --- a/cake/console/templates/skel/console/cake +++ b/cake/console/templates/skel/console/cake @@ -12,8 +12,7 @@ # # @copyright Copyright 2005-2010, Cake Software Foundation, Inc. # @link http://cakephp.org CakePHP(tm) Project -# @package cake -# @subpackage cake.app.console +# @package app.console # @since CakePHP(tm) v 2.0 # @license MIT License (http://www.opensource.org/licenses/mit-license.php) # diff --git a/cake/console/templates/skel/console/cake.bat b/cake/console/templates/skel/console/cake.bat index 84ed04a4f..ed04546c9 100644 --- a/cake/console/templates/skel/console/cake.bat +++ b/cake/console/templates/skel/console/cake.bat @@ -11,8 +11,7 @@ :: :: @copyright Copyright 2005-2010, Cake Software Foundation, Inc. :: @link http://cakephp.org CakePHP(tm) Project -:: @package cake -:: @subpackage cake.app.console +:: @package app.console :: @since CakePHP(tm) v 2.0 :: @license MIT License (http://www.opensource.org/licenses/mit-license.php) :: diff --git a/cake/console/templates/skel/console/cake.php b/cake/console/templates/skel/console/cake.php index 8ccac0bfb..d4f4ef1c0 100644 --- a/cake/console/templates/skel/console/cake.php +++ b/cake/console/templates/skel/console/cake.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console + * @package app.console * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/controllers/pages_controller.php b/cake/console/templates/skel/controllers/pages_controller.php index 650adda94..f0cf2ce27 100644 --- a/cake/console/templates/skel/controllers/pages_controller.php +++ b/cake/console/templates/skel/controllers/pages_controller.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller + * @package cake.libs.controller * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ * * Override this controller by placing a copy in controllers directory of an application * - * @package cake - * @subpackage cake.cake.libs.controller + * @package cake.libs.controller */ class PagesController extends AppController { diff --git a/cake/console/templates/skel/index.php b/cake/console/templates/skel/index.php index a9e0270cb..ac4fde167 100644 --- a/cake/console/templates/skel/index.php +++ b/cake/console/templates/skel/index.php @@ -10,8 +10,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app + * @package app * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/views/elements/email/html/default.ctp b/cake/console/templates/skel/views/elements/email/html/default.ctp index 45a84c9e0..3ab3f4cc6 100644 --- a/cake/console/templates/skel/views/elements/email/html/default.ctp +++ b/cake/console/templates/skel/views/elements/email/html/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.elements.email.html + * @package cake.libs.view.templates.elements.email.html * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/views/elements/email/text/default.ctp b/cake/console/templates/skel/views/elements/email/text/default.ctp index 9d384e3f8..7655f1430 100644 --- a/cake/console/templates/skel/views/elements/email/text/default.ctp +++ b/cake/console/templates/skel/views/elements/email/text/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.elements.email.text + * @package cake.libs.view.templates.elements.email.text * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/views/layouts/ajax.ctp b/cake/console/templates/skel/views/layouts/ajax.ctp index dadf156ed..93371552b 100644 --- a/cake/console/templates/skel/views/layouts/ajax.ctp +++ b/cake/console/templates/skel/views/layouts/ajax.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts + * @package cake.libs.view.templates.layouts * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/views/layouts/default.ctp b/cake/console/templates/skel/views/layouts/default.ctp index a07b907b3..e8b6b3c50 100644 --- a/cake/console/templates/skel/views/layouts/default.ctp +++ b/cake/console/templates/skel/views/layouts/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.templates.skel.views.layouts + * @package cake.console.libs.templates.skel.views.layouts * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/views/layouts/email/html/default.ctp b/cake/console/templates/skel/views/layouts/email/html/default.ctp index 8b5a339f8..cc4364bb1 100644 --- a/cake/console/templates/skel/views/layouts/email/html/default.ctp +++ b/cake/console/templates/skel/views/layouts/email/html/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts.email.html + * @package cake.libs.view.templates.layouts.email.html * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/views/layouts/email/text/default.ctp b/cake/console/templates/skel/views/layouts/email/text/default.ctp index e509b1b32..f85bd7ea2 100644 --- a/cake/console/templates/skel/views/layouts/email/text/default.ctp +++ b/cake/console/templates/skel/views/layouts/email/text/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts.email.text + * @package cake.libs.view.templates.layouts.email.text * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/views/layouts/flash.ctp b/cake/console/templates/skel/views/layouts/flash.ctp index bfd9a4621..554fb377c 100644 --- a/cake/console/templates/skel/views/layouts/flash.ctp +++ b/cake/console/templates/skel/views/layouts/flash.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts + * @package cake.libs.view.templates.layouts * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/webroot/css.php b/cake/console/templates/skel/webroot/css.php index 9a1313877..59505c4e9 100644 --- a/cake/console/templates/skel/webroot/css.php +++ b/cake/console/templates/skel/webroot/css.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.webroot + * @package app.webroot * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/webroot/css/cake.generic.css b/cake/console/templates/skel/webroot/css/cake.generic.css index 7f978afc0..66deb64a8 100644 --- a/cake/console/templates/skel/webroot/css/cake.generic.css +++ b/cake/console/templates/skel/webroot/css/cake.generic.css @@ -10,8 +10,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.webroot.css + * @package app.webroot.css * @since CakePHP(tm) * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/webroot/index.php b/cake/console/templates/skel/webroot/index.php index 719f172c4..5955688f6 100644 --- a/cake/console/templates/skel/webroot/index.php +++ b/cake/console/templates/skel/webroot/index.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.webroot + * @package app.webroot * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/templates/skel/webroot/test.php b/cake/console/templates/skel/webroot/test.php index 7a27e8e29..eddcc437f 100644 --- a/cake/console/templates/skel/webroot/test.php +++ b/cake/console/templates/skel/webroot/test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing - * @package cake - * @subpackage cake.app.webroot + * @package app.webroot * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/app.php b/cake/libs/app.php index f18bb0719..7d8868814 100644 --- a/cake/libs/app.php +++ b/cake/libs/app.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0.6001 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -43,8 +42,7 @@ * which application controllers App knows about. * * @link http://book.cakephp.org/view/933/The-App-Class - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class App { diff --git a/cake/libs/cache.php b/cake/libs/cache.php index 008c71b15..66f255b34 100644 --- a/cake/libs/cache.php +++ b/cake/libs/cache.php @@ -472,8 +472,7 @@ class Cache { /** * Storage engine for CakePHP caching * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ abstract class CacheEngine { diff --git a/cake/libs/cache/apc.php b/cake/libs/cache/apc.php index dbc4df8cc..544a0c908 100644 --- a/cake/libs/cache/apc.php +++ b/cake/libs/cache/apc.php @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.cache + * @package cake.libs.cache * @since CakePHP(tm) v 1.2.0.4933 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ /** * APC storage engine for cache * - * @package cake - * @subpackage cake.cake.libs.cache + * @package cake.libs.cache */ class ApcEngine extends CacheEngine { diff --git a/cake/libs/cache/file.php b/cake/libs/cache/file.php index 7560d8113..46ff892a3 100644 --- a/cake/libs/cache/file.php +++ b/cake/libs/cache/file.php @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.cache + * @package cake.libs.cache * @since CakePHP(tm) v 1.2.0.4933 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * File Storage engine for cache * * @todo use the File and Folder classes (if it's not a too big performance hit) - * @package cake - * @subpackage cake.cake.libs.cache + * @package cake.libs.cache */ class FileEngine extends CacheEngine { diff --git a/cake/libs/cache/memcache.php b/cake/libs/cache/memcache.php index d4a1dbfa8..79d98376e 100644 --- a/cake/libs/cache/memcache.php +++ b/cake/libs/cache/memcache.php @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.cache + * @package cake.libs.cache * @since CakePHP(tm) v 1.2.0.4933 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ * control you have over expire times far in the future. See MemcacheEngine::write() for * more information. * - * @package cake - * @subpackage cake.cake.libs.cache + * @package cake.libs.cache */ class MemcacheEngine extends CacheEngine { diff --git a/cake/libs/cache/xcache.php b/cake/libs/cache/xcache.php index be8f53c22..53b0d08b9 100644 --- a/cake/libs/cache/xcache.php +++ b/cake/libs/cache/xcache.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.cache + * @package cake.libs.cache * @since CakePHP(tm) v 1.2.0.4947 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ * Xcache storage engine for cache * * @link http://trac.lighttpd.net/xcache/ Xcache - * @package cake - * @subpackage cake.cake.libs.cache + * @package cake.libs.cache */ class XcacheEngine extends CacheEngine { diff --git a/cake/libs/cake_log.php b/cake/libs/cake_log.php index 997698ed9..e632c2898 100644 --- a/cake/libs/cake_log.php +++ b/cake/libs/cake_log.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -59,8 +58,7 @@ interface CakeLogInterface { * using CakeLogs's methods. If you don't configure any adapters, and write to the logs * a default FileLog will be autoconfigured for you. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class CakeLog { diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 23c925883..b7a10058e 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -12,7 +12,6 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/cake_response.php b/cake/libs/cake_response.php index df2ab71a0..9c200cbcb 100644 --- a/cake/libs/cake_response.php +++ b/cake/libs/cake_response.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php index 2d201f81d..a08fd49c3 100644 --- a/cake/libs/cake_session.php +++ b/cake/libs/cake_session.php @@ -17,8 +17,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v .0.10.0.1222 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -32,8 +31,7 @@ if (!class_exists('Security')) { * Cake abstracts the handling of sessions. There are several convenient methods to access session information. * This class is the implementation of those methods. They are mostly used by the Session Component. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class CakeSession { diff --git a/cake/libs/cake_socket.php b/cake/libs/cake_socket.php index e6f51ee54..82610ff92 100644 --- a/cake/libs/cake_socket.php +++ b/cake/libs/cake_socket.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ App::import('Core', 'Validation'); * * Core base class for network communication. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class CakeSocket { diff --git a/cake/libs/class_registry.php b/cake/libs/class_registry.php index 4e7b22c38..25659089f 100644 --- a/cake/libs/class_registry.php +++ b/cake/libs/class_registry.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 0.9.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ * If you try to add an object with the same key twice, nothing will come of it. * If you need a second instance of an object, give it another key. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class ClassRegistry { diff --git a/cake/libs/config/ini_reader.php b/cake/libs/config/ini_reader.php index e901d4e18..915bf9498 100644 --- a/cake/libs/config/ini_reader.php +++ b/cake/libs/config/ini_reader.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.libs.config + * @package cake.libs.config * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/config/php_reader.php b/cake/libs/config/php_reader.php index 1e2734d12..c122f0808 100644 --- a/cake/libs/config/php_reader.php +++ b/cake/libs/config/php_reader.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.libs.config * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/configure.php b/cake/libs/configure.php index ce05b018e..1546ae087 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.0.0.2363 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ * as methods for loading additional configuration files or storing runtime configuration * for future use. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @link http://book.cakephp.org/view/924/The-Configuration-Class */ class Configure { diff --git a/cake/libs/controller/app_controller.php b/cake/libs/controller/app_controller.php index c8423a41b..07c117dff 100644 --- a/cake/libs/controller/app_controller.php +++ b/cake/libs/controller/app_controller.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller + * @package cake.libs.controller * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -28,8 +27,7 @@ * Add your application-wide methods in the class below, your controllers * will inherit them. * - * @package cake - * @subpackage cake.cake.libs.controller + * @package cake.libs.controller * @link http://book.cakephp.org/view/957/The-App-Controller */ class AppController extends Controller { diff --git a/cake/libs/controller/cake_error_controller.php b/cake/libs/controller/cake_error_controller.php index 443024840..f55649672 100644 --- a/cake/libs/controller/cake_error_controller.php +++ b/cake/libs/controller/cake_error_controller.php @@ -4,8 +4,7 @@ * * Controller used by ErrorHandler to render error views. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class CakeErrorController extends AppController { public $name = 'CakeError'; diff --git a/cake/libs/controller/component.php b/cake/libs/controller/component.php index 95ceb00b8..f55840d1f 100644 --- a/cake/libs/controller/component.php +++ b/cake/libs/controller/component.php @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller + * @package cake.libs.controller * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -35,8 +34,7 @@ App::import('Controller', 'ComponentCollection', false); * but before Controller::afterFilter(). * - `beforeRedirect()` - Fired before a redirect() is done. * - * @package cake - * @subpackage cake.cake.libs.controller + * @package cake.libs.controller * @link http://book.cakephp.org/view/993/Components * @see Controller::$components */ diff --git a/cake/libs/controller/component_collection.php b/cake/libs/controller/component_collection.php index b644902a9..3d9e23c47 100644 --- a/cake/libs/controller/component_collection.php +++ b/cake/libs/controller/component_collection.php @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.libs.controller + * @package cake.libs.controller * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/controller/components/acl.php b/cake/libs/controller/components/acl.php index 1b7b31486..6795ab335 100644 --- a/cake/libs/controller/components/acl.php +++ b/cake/libs/controller/components/acl.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ * You can define by changing `Configure::write('Acl.classname', 'DbAcl');` in your core.php. Concrete ACL * implementations should extend `AclBase` and implement the methods it defines. * - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @link http://book.cakephp.org/view/1242/Access-Control-Lists */ class AclComponent extends Component { @@ -186,8 +184,7 @@ class AclComponent extends Component { * Access Control List interface. * Implementing classes are used by AclComponent to perform ACL checks in Cake. * - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components */ interface AclInterface { @@ -255,8 +252,7 @@ interface AclInterface { * edit * }}} * - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model */ class DbAcl extends Object implements AclInterface { @@ -525,8 +521,7 @@ class DbAcl extends Object implements AclInterface { * IniAcl implements an access control system using an INI file. An example * of the ini file used can be found in /config/acl.ini.php. * - * @package cake - * @subpackage cake.cake.libs.model.iniacl + * @package cake.libs.model.iniacl */ class IniAcl extends Object implements AclInterface { diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index f8e74f3a1..063960f91 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -28,8 +27,7 @@ App::import('Core', 'Security', false); * * Binds access control with user authentication and session management. * - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @link http://book.cakephp.org/view/1250/Authentication */ class AuthComponent extends Component { diff --git a/cake/libs/controller/components/cookie.php b/cake/libs/controller/components/cookie.php index f8aac83a0..87fb4a802 100644 --- a/cake/libs/controller/components/cookie.php +++ b/cake/libs/controller/components/cookie.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @since CakePHP(tm) v 1.2.0.4213 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -28,8 +27,7 @@ App::import('Core', 'Security'); * * Cookie handling for the controller. * - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @link http://book.cakephp.org/view/1280/Cookies * */ diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index bcb854be3..031ef8543 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @since CakePHP(tm) v 1.2.0.3467 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ App::import('Core', 'Multibyte'); * This component is used for handling Internet Message Format based * based on the standard outlined in http://www.rfc-editor.org/rfc/rfc2822.txt * - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @link http://book.cakephp.org/view/1283/Email * */ diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index 9bf89f991..fe6a34bdd 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This component is used to handle automatic model data pagination * - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * */ class PaginatorComponent extends Component { diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php index b688c755d..3889f716c 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/cake/libs/controller/components/request_handler.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @since CakePHP(tm) v 0.10.4.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ /** * Request object for handling HTTP requests * - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @link http://book.cakephp.org/view/1291/Request-Handling * */ diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index 90a934aea..daf0bc8bb 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @since CakePHP(tm) v 0.10.8.2156 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Core', 'Security', false); /** * SecurityComponent * - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @link http://book.cakephp.org/view/1296/Security-Component */ class SecurityComponent extends Component { diff --git a/cake/libs/controller/components/session.php b/cake/libs/controller/components/session.php index af4474c6c..09a9f6da6 100644 --- a/cake/libs/controller/components/session.php +++ b/cake/libs/controller/components/session.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @since CakePHP(tm) v 0.10.0.1232 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,8 +25,7 @@ if (!class_exists('cakesession')) { * * Session handling from the controller. * - * @package cake - * @subpackage cake.cake.libs.controller.components + * @package cake.libs.controller.components * @link http://book.cakephp.org/view/1310/Sessions * */ diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 7f91f5dd9..758d41225 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller + * @package cake.libs.controller * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/controller/pages_controller.php b/cake/libs/controller/pages_controller.php index bc7a380e7..65e8b0465 100644 --- a/cake/libs/controller/pages_controller.php +++ b/cake/libs/controller/pages_controller.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller + * @package cake.libs.controller * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ * * Override this controller by placing a copy in controllers directory of an application * - * @package cake - * @subpackage cake.cake.libs.controller + * @package cake.libs.controller * @link http://book.cakephp.org/view/958/The-Pages-Controller */ class PagesController extends AppController { diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index c58fba7d1..97a2533d7 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.controller + * @package cake.libs.controller * @since Cake v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -29,8 +28,7 @@ App::import('View', 'Scaffold'); * and afford the web developer an early look at the data, and the possibility to over-ride * scaffolded actions with custom-made ones. * - * @package cake - * @subpackage cake.cake.libs.controller + * @package cake.libs.controller */ class Scaffold { diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php index 33f665a2c..942aa1c63 100644 --- a/cake/libs/debugger.php +++ b/cake/libs/debugger.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.4560 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -36,8 +35,7 @@ if (!class_exists('String')) { * * Debugger overrides PHP's default error handling to provide stack traces and enhanced logging * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @link http://book.cakephp.org/view/1191/Using-the-Debugger-Class */ class Debugger { diff --git a/cake/libs/dispatcher.php b/cake/libs/dispatcher.php index f9b7b059d..f8c833bc9 100644 --- a/cake/libs/dispatcher.php +++ b/cake/libs/dispatcher.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake + * @package cake.libs * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -35,7 +34,6 @@ App::import('Controller', 'Controller', false); * the controller. * * @package cake - * @subpackage cake.cake */ class Dispatcher { diff --git a/cake/libs/error/error_handler.php b/cake/libs/error/error_handler.php index b25582fac..775bd8d43 100644 --- a/cake/libs/error/error_handler.php +++ b/cake/libs/error/error_handler.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs.error * @since CakePHP(tm) v 0.10.5.1732 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -88,8 +87,7 @@ * * Would enable handling for all non Notice errors. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs.error * @see ExceptionRenderer for more information on how to customize exception rendering. */ class ErrorHandler { diff --git a/cake/libs/error/exception_renderer.php b/cake/libs/error/exception_renderer.php index 6666f4414..5745564df 100644 --- a/cake/libs/error/exception_renderer.php +++ b/cake/libs/error/exception_renderer.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs.error * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -45,8 +44,7 @@ * can configure your class in your core.php, with `Configure::write('Exception.renderer', 'MyClass');` * You should place any custom exception renderers in `app/libs`. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs.error */ class ExceptionRenderer { diff --git a/cake/libs/error/exceptions.php b/cake/libs/error/exceptions.php index dc8538334..75224c557 100644 --- a/cake/libs/error/exceptions.php +++ b/cake/libs/error/exceptions.php @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.libs + * @package cake.libs.error * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/file.php b/cake/libs/file.php index 47f922d9d..49d030e4d 100644 --- a/cake/libs/file.php +++ b/cake/libs/file.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -29,8 +28,7 @@ if (!class_exists('Folder')) { /** * Convenience class for reading, writing and appending to files. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class File { diff --git a/cake/libs/folder.php b/cake/libs/folder.php index 733315a1a..02b097227 100644 --- a/cake/libs/folder.php +++ b/cake/libs/folder.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ * Folder structure browser, lists folders and files. * Provides an Object interface for Common directory related tasks. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class Folder { diff --git a/cake/libs/http/basic_authentication.php b/cake/libs/http/basic_authentication.php index 111246210..49b12fc5f 100644 --- a/cake/libs/http/basic_authentication.php +++ b/cake/libs/http/basic_authentication.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.http + * @package cake.libs.http * @since CakePHP(tm) v 2.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Basic authentication * - * @package cake - * @subpackage cake.cake.libs.http + * @package cake.libs.http */ class BasicAuthentication { diff --git a/cake/libs/http/digest_authentication.php b/cake/libs/http/digest_authentication.php index 21f7ea8e6..14275f4e5 100644 --- a/cake/libs/http/digest_authentication.php +++ b/cake/libs/http/digest_authentication.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.http + * @package cake.libs.http * @since CakePHP(tm) v 2.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Digest authentication * - * @package cake - * @subpackage cake.cake.libs.http + * @package cake.libs.http */ class DigestAuthentication { diff --git a/cake/libs/http_response.php b/cake/libs/http_response.php index ade1b14f4..51aff7a78 100644 --- a/cake/libs/http_response.php +++ b/cake/libs/http_response.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 2.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index b1df3f25d..c4b36f1ff 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,8 +25,7 @@ App::import('Core', 'Router'); * Core base class for HTTP network communication. HttpSocket can be used as an * Object Oriented replacement for cURL in many places. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class HttpSocket extends CakeSocket { diff --git a/cake/libs/i18n.php b/cake/libs/i18n.php index 05ec9c9e8..63cc47b19 100644 --- a/cake/libs/i18n.php +++ b/cake/libs/i18n.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0.4116 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ App::import('Core', 'Multibyte'); /** * I18n handles translation of Text and time format strings. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class I18n { diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index d1bf78cfa..0e3eb0278 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,8 +25,7 @@ * Inflector pluralizes and singularizes English nouns. * Used by Cake's naming conventions throughout the framework. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @link http://book.cakephp.org/view/1478/Inflector */ class Inflector { diff --git a/cake/libs/l10n.php b/cake/libs/l10n.php index 4f5868412..2da41af34 100644 --- a/cake/libs/l10n.php +++ b/cake/libs/l10n.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0.4116 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'CakeRequest'); /** * Localization * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class L10n { diff --git a/cake/libs/log/file_log.php b/cake/libs/log/file_log.php index fbd4cff3e..c7adb306d 100644 --- a/cake/libs/log/file_log.php +++ b/cake/libs/log/file_log.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.log + * @package cake.libs.log * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ * File Storage stream for Logging. Writes logs to different files * based on the type of log it is. * - * @package cake - * @subpackage cake.cake.libs.log + * @package cake.libs.log */ class FileLog implements CakeLogInterface { diff --git a/cake/libs/magic_db.php b/cake/libs/magic_db.php index 1a3143b4e..07c3686af 100644 --- a/cake/libs/magic_db.php +++ b/cake/libs/magic_db.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -28,7 +27,7 @@ if (!class_exists('File')) { * A class to parse and use the MagicDb for file type analysis * * @package cake.tests - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class MagicDb extends Object { @@ -173,7 +172,7 @@ class MagicDb extends Object { * undocumented class * * @package cake.tests - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class MagicFileResource extends Object{ diff --git a/cake/libs/model/app_model.php b/cake/libs/model/app_model.php index e18dca1c1..4af1eb2e5 100644 --- a/cake/libs/model/app_model.php +++ b/cake/libs/model/app_model.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -28,8 +27,7 @@ * Create the same file in app/app_model.php * Add your application-wide methods to the class, your models will inherit them. * - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model */ class AppModel extends Model { } diff --git a/cake/libs/model/behavior_collection.php b/cake/libs/model/behavior_collection.php index c2f397b82..da9970560 100644 --- a/cake/libs/model/behavior_collection.php +++ b/cake/libs/model/behavior_collection.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model * @since CakePHP(tm) v 1.2.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,8 +25,7 @@ App::import('Core', 'ObjectCollection'); * * Defines the Behavior interface, and contains common model interaction functionality. * - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model */ class BehaviorCollection extends ObjectCollection { diff --git a/cake/libs/model/behaviors/acl.php b/cake/libs/model/behaviors/acl.php index fc2893bfa..b03586657 100644 --- a/cake/libs/model/behaviors/acl.php +++ b/cake/libs/model/behaviors/acl.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.cake.libs.model.behaviors + * @package cake.libs.model.behaviors * @since CakePHP v 1.2.0.4487 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ /** * ACL behavior * - * @package cake - * @subpackage cake.cake.libs.model.behaviors + * @package cake.libs.model.behaviors * @link http://book.cakephp.org/view/1320/ACL */ class AclBehavior extends ModelBehavior { diff --git a/cake/libs/model/behaviors/containable.php b/cake/libs/model/behaviors/containable.php index 508dcf87f..03963a723 100644 --- a/cake/libs/model/behaviors/containable.php +++ b/cake/libs/model/behaviors/containable.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @since CakePHP(tm) v 1.2.0.5669 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ * Behavior to allow for dynamic and atomic manipulation of a Model's associations used for a find call. Most useful for limiting * the amount of associations and data returned. * - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs * @link http://book.cakephp.org/view/1323/Containable */ class ContainableBehavior extends ModelBehavior { diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index e480a720f..3f0c462d5 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model.behaviors + * @package cake.libs.model.behaviors * @since CakePHP(tm) v 1.2.0.4525 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Translate behavior * - * @package cake - * @subpackage cake.cake.libs.model.behaviors + * @package cake.libs.model.behaviors * @link http://book.cakephp.org/view/1328/Translate */ class TranslateBehavior extends ModelBehavior { @@ -501,8 +499,7 @@ class TranslateBehavior extends ModelBehavior { } /** - * @package cake - * @subpackage cake.cake.libs.model.behaviors + * @package cake.libs.model.behaviors */ class I18nModel extends AppModel { public $name = 'I18nModel'; diff --git a/cake/libs/model/behaviors/tree.php b/cake/libs/model/behaviors/tree.php index 9bec6f0ae..032d9e1a9 100644 --- a/cake/libs/model/behaviors/tree.php +++ b/cake/libs/model/behaviors/tree.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.cake.libs.model.behaviors + * @package cake.libs.model.behaviors * @since CakePHP v 1.2.0.4487 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,8 +25,7 @@ * Enables a model object to act as a node-based tree. Using Modified Preorder Tree Traversal * * @see http://en.wikipedia.org/wiki/Tree_traversal - * @package cake - * @subpackage cake.cake.libs.model.behaviors + * @package cake.libs.model.behaviors * @link http://book.cakephp.org/view/1339/Tree */ class TreeBehavior extends ModelBehavior { diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index fc4e32d28..a38e0ed7b 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model * @since CakePHP(tm) v 1.2.0.5550 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Core', 'ConnectionManager'); /** * Base Class for Schema management * - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model */ class CakeSchema extends Object { diff --git a/cake/libs/model/connection_manager.php b/cake/libs/model/connection_manager.php index 42b2c5003..9581431fc 100644 --- a/cake/libs/model/connection_manager.php +++ b/cake/libs/model/connection_manager.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model * @since CakePHP(tm) v 0.10.x.1402 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ include_once CONFIGS . 'database.php'; /** * Manages loaded instances of DataSource objects * - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model */ class ConnectionManager { diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index 166c5362c..d38e8bf10 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model.datasources + * @package cake.libs.model.datasources * @since CakePHP(tm) v 0.10.5.1790 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * DataSource base class * - * @package cake - * @subpackage cake.cake.libs.model.datasources + * @package cake.libs.model.datasources */ class DataSource extends Object { diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php index 4fa73bf8e..91db76c5f 100644 --- a/cake/libs/model/datasources/dbo/dbo_mssql.php +++ b/cake/libs/model/datasources/dbo/dbo_mssql.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model.datasources.dbo + * @package cake.libs.model.datasources.dbo * @since CakePHP(tm) v 0.10.5.1790 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * Long description for class * - * @package cake - * @subpackage cake.cake.libs.model.datasources.dbo + * @package cake.libs.model.datasources.dbo */ class DboMssql extends DboSource { diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index f39b50420..1d6052f6a 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model.datasources.dbo + * @package cake.libs.model.datasources.dbo * @since CakePHP(tm) v 0.10.5.1790 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * Provides connection and SQL generation for MySQL RDMS * - * @package cake - * @subpackage cake.cake.libs.model.datasources.dbo + * @package cake.libs.model.datasources.dbo */ class DboMysql extends DboSource { diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php index fb5df6806..4b4444211 100644 --- a/cake/libs/model/datasources/dbo/dbo_oracle.php +++ b/cake/libs/model/datasources/dbo/dbo_oracle.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model.datasources.dbo + * @package cake.libs.model.datasources.dbo * @since CakePHP v 1.2.0.4041 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * Long description for class * - * @package cake - * @subpackage cake.cake.libs.model.datasources.dbo + * @package cake.libs.model.datasources.dbo */ class DboOracle extends DboSource { diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 7e001344d..e5e12d2bc 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model.datasources.dbo + * @package cake.libs.model.datasources.dbo * @since CakePHP(tm) v 0.9.1.114 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * Long description for class * - * @package cake - * @subpackage cake.cake.libs.model.datasources.dbo + * @package cake.libs.model.datasources.dbo */ class DboPostgres extends DboSource { diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index e4a50b4c2..f2bcda3fd 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model.datasources.dbo + * @package cake.libs.model.datasources.dbo * @since CakePHP(tm) v 0.9.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,7 +23,7 @@ * A DboSource adapter for SQLite 3 using PDO * * @package datasources - * @subpackage cake.cake.libs.model.datasources.dbo + * @package cake.libs.model.datasources.dbo */ class DboSqlite extends DboSource { diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index da92471a1..717e5ca92 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model.datasources + * @package cake.libs.model.datasources * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ App::import('Core', 'String'); * * Creates DBO-descendant objects from a given db connection configuration * - * @package cake - * @subpackage cake.cake.libs.model.datasources + * @package cake.libs.model.datasources */ class DboSource extends DataSource { diff --git a/cake/libs/model/db_acl.php b/cake/libs/model/db_acl.php index 70826bdb7..e8a31cef7 100644 --- a/cake/libs/model/db_acl.php +++ b/cake/libs/model/db_acl.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -29,8 +28,7 @@ App::import('Model', 'App'); * ACL Node * * - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model */ class AclNode extends AppModel { @@ -193,8 +191,7 @@ class AclNode extends AppModel { /** * Access Control Object * - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model */ class Aco extends AclNode { @@ -218,8 +215,7 @@ class Aco extends AclNode { /** * Action for Access Control Object * - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model */ class AcoAction extends AppModel { @@ -243,8 +239,7 @@ class AcoAction extends AppModel { /** * Access Request Object * - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model */ class Aro extends AclNode { @@ -268,8 +263,7 @@ class Aro extends AclNode { /** * Permissions linking AROs with ACOs * - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model */ class Permission extends AppModel { diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 7c8b5f2e6..b55616028 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model * @since CakePHP(tm) v 0.10.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -38,8 +37,7 @@ App::import('Model', 'ConnectionManager', false); * (i.e. class 'User' => table 'users'; class 'Man' => table 'men') * The table is required to have at least 'id auto_increment' primary key. * - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model * @link http://book.cakephp.org/view/1000/Models */ class Model extends Object { diff --git a/cake/libs/model/model_behavior.php b/cake/libs/model/model_behavior.php index 0cf027163..482bd2e1e 100644 --- a/cake/libs/model/model_behavior.php +++ b/cake/libs/model/model_behavior.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.model + * @package cake.libs.model * @since CakePHP(tm) v 1.2.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/multibyte.php b/cake/libs/multibyte.php index 69c23188f..123d3d11b 100644 --- a/cake/libs/multibyte.php +++ b/cake/libs/multibyte.php @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0.6833 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -256,8 +255,7 @@ if (!function_exists('mb_encode_mimeheader')) { * Multibyte handling methods. * * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class Multibyte { diff --git a/cake/libs/object.php b/cake/libs/object.php index 0f1d49030..c574402ce 100644 --- a/cake/libs/object.php +++ b/cake/libs/object.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -28,7 +27,7 @@ * to call other Controllers' Actions from anywhere. * * @package cake - * @subpackage cake.cake.libs + * @package cake.cake.libs */ class Object { diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 979f90dcf..eb64b2b62 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -16,8 +16,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs.route * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/route/plugin_short_route.php b/cake/libs/route/plugin_short_route.php index 1c1c4330b..9509c5d32 100644 --- a/cake/libs/route/plugin_short_route.php +++ b/cake/libs/route/plugin_short_route.php @@ -14,8 +14,7 @@ App::import('Core', 'route/CakeRoute'); * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs.route * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/route/redirect_route.php b/cake/libs/route/redirect_route.php index 148ce358f..1a8f6ecbd 100644 --- a/cake/libs/route/redirect_route.php +++ b/cake/libs/route/redirect_route.php @@ -14,8 +14,7 @@ App::import('Core', 'route/CakeRoute'); * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.route + * @package cake.libs.route * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/router.php b/cake/libs/router.php index 6b4d7dcf6..3a11ac4f4 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/sanitize.php b/cake/libs/sanitize.php index 34ed32e79..d538b46bd 100644 --- a/cake/libs/sanitize.php +++ b/cake/libs/sanitize.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,8 +25,7 @@ * Removal of alpahnumeric characters, SQL-safe slash-added strings, HTML-friendly strings, * and all of the above on arrays. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class Sanitize { diff --git a/cake/libs/security.php b/cake/libs/security.php index 348402de2..e8b01e2b8 100644 --- a/cake/libs/security.php +++ b/cake/libs/security.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v .0.10.0.1233 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Security Library contains utility methods related to security * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class Security { diff --git a/cake/libs/session/cache_session.php b/cake/libs/session/cache_session.php index 5c8f2eae5..9b1b4ded0 100644 --- a/cake/libs/session/cache_session.php +++ b/cake/libs/session/cache_session.php @@ -12,15 +12,15 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ /** * CacheSession provides method for saving sessions into a Cache engine. Used with CakeSession * - * @package cake.libs + * @package cake.libs.session + * @see CakeSession for configuration information. */ class CacheSession implements CakeSessionHandlerInterface { /** diff --git a/cake/libs/session/database_session.php b/cake/libs/session/database_session.php index e10fe5a93..574d1f5c0 100644 --- a/cake/libs/session/database_session.php +++ b/cake/libs/session/database_session.php @@ -12,15 +12,14 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ /** * DatabaseSession provides methods to be used with CakeSession. * - * @package cake.libs + * @package cake.libs.session */ class DatabaseSession implements CakeSessionHandlerInterface { diff --git a/cake/libs/set.php b/cake/libs/set.php index 294b8ac7d..14282682d 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Class used for manipulation of arrays. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class Set { diff --git a/cake/libs/string.php b/cake/libs/string.php index affcc263b..8fc0a2ddf 100644 --- a/cake/libs/string.php +++ b/cake/libs/string.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0.5551 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ * String handling methods. * * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs */ class String { diff --git a/cake/libs/validation.php b/cake/libs/validation.php index adda137c0..aefa47756 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0.3830 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ if (!class_exists('Multibyte')) { /** * Offers different validation methods. * - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP v 1.2.0.3830 */ class Validation { diff --git a/cake/libs/view/elements/email/html/default.ctp b/cake/libs/view/elements/email/html/default.ctp index 45a84c9e0..3ab3f4cc6 100644 --- a/cake/libs/view/elements/email/html/default.ctp +++ b/cake/libs/view/elements/email/html/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.elements.email.html + * @package cake.libs.view.templates.elements.email.html * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/elements/email/text/default.ctp b/cake/libs/view/elements/email/text/default.ctp index 9d384e3f8..7655f1430 100644 --- a/cake/libs/view/elements/email/text/default.ctp +++ b/cake/libs/view/elements/email/text/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.elements.email.text + * @package cake.libs.view.templates.elements.email.text * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/elements/exception_stack_trace.ctp b/cake/libs/view/elements/exception_stack_trace.ctp index 9219e21ae..247c45169 100644 --- a/cake/libs/view/elements/exception_stack_trace.ctp +++ b/cake/libs/view/elements/exception_stack_trace.ctp @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.elements + * @package cake.libs.view.templates.elements * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/elements/sql_dump.ctp b/cake/libs/view/elements/sql_dump.ctp index 025d5ae93..b770dfbaa 100644 --- a/cake/libs/view/elements/sql_dump.ctp +++ b/cake/libs/view/elements/sql_dump.ctp @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.elements + * @package cake.libs.view.templates.elements * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/error400.ctp b/cake/libs/view/errors/error400.ctp index 4d1660517..b6487ee91 100644 --- a/cake/libs/view/errors/error400.ctp +++ b/cake/libs/view/errors/error400.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/error500.ctp b/cake/libs/view/errors/error500.ctp index b5bdcfde0..e032b9eed 100644 --- a/cake/libs/view/errors/error500.ctp +++ b/cake/libs/view/errors/error500.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_action.ctp b/cake/libs/view/errors/missing_action.ctp index 19cfe6222..5b6fdb970 100644 --- a/cake/libs/view/errors/missing_action.ctp +++ b/cake/libs/view/errors/missing_action.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_behavior_class.ctp b/cake/libs/view/errors/missing_behavior_class.ctp index eb19034b8..e7c454069 100644 --- a/cake/libs/view/errors/missing_behavior_class.ctp +++ b/cake/libs/view/errors/missing_behavior_class.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_behavior_file.ctp b/cake/libs/view/errors/missing_behavior_file.ctp index 6f90206c1..09e90b350 100644 --- a/cake/libs/view/errors/missing_behavior_file.ctp +++ b/cake/libs/view/errors/missing_behavior_file.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_component_class.ctp b/cake/libs/view/errors/missing_component_class.ctp index ccb0497ef..cf06671dc 100644 --- a/cake/libs/view/errors/missing_component_class.ctp +++ b/cake/libs/view/errors/missing_component_class.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_component_file.ctp b/cake/libs/view/errors/missing_component_file.ctp index 592238fb4..527afc9c3 100644 --- a/cake/libs/view/errors/missing_component_file.ctp +++ b/cake/libs/view/errors/missing_component_file.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_connection.ctp b/cake/libs/view/errors/missing_connection.ctp index 2f11f4f5f..dfda66e3a 100644 --- a/cake/libs/view/errors/missing_connection.ctp +++ b/cake/libs/view/errors/missing_connection.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_controller.ctp b/cake/libs/view/errors/missing_controller.ctp index d45d8d31c..7f9e7d27f 100644 --- a/cake/libs/view/errors/missing_controller.ctp +++ b/cake/libs/view/errors/missing_controller.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_database.ctp b/cake/libs/view/errors/missing_database.ctp index d3e4944f6..7aa2d5e80 100644 --- a/cake/libs/view/errors/missing_database.ctp +++ b/cake/libs/view/errors/missing_database.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_helper_class.ctp b/cake/libs/view/errors/missing_helper_class.ctp index 9742a1563..842ded905 100644 --- a/cake/libs/view/errors/missing_helper_class.ctp +++ b/cake/libs/view/errors/missing_helper_class.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_helper_file.ctp b/cake/libs/view/errors/missing_helper_file.ctp index 69bf38e30..6ba0e9b6f 100644 --- a/cake/libs/view/errors/missing_helper_file.ctp +++ b/cake/libs/view/errors/missing_helper_file.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_layout.ctp b/cake/libs/view/errors/missing_layout.ctp index 28445cc77..011e59a64 100644 --- a/cake/libs/view/errors/missing_layout.ctp +++ b/cake/libs/view/errors/missing_layout.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_table.ctp b/cake/libs/view/errors/missing_table.ctp index b639856fe..1288dd06a 100644 --- a/cake/libs/view/errors/missing_table.ctp +++ b/cake/libs/view/errors/missing_table.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/missing_view.ctp b/cake/libs/view/errors/missing_view.ctp index 658f4d1ce..9d8c7cb91 100644 --- a/cake/libs/view/errors/missing_view.ctp +++ b/cake/libs/view/errors/missing_view.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/private_action.ctp b/cake/libs/view/errors/private_action.ctp index c91062ba2..833f42112 100644 --- a/cake/libs/view/errors/private_action.ctp +++ b/cake/libs/view/errors/private_action.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/errors/scaffold_error.ctp b/cake/libs/view/errors/scaffold_error.ctp index 931cbdca5..40f09c90a 100644 --- a/cake/libs/view/errors/scaffold_error.ctp +++ b/cake/libs/view/errors/scaffold_error.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.errors + * @package cake.libs.view.templates.errors * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index 6397cf722..c83dd9b03 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view + * @package cake.libs.view * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -28,8 +27,7 @@ if (!class_exists('Router')) { * Abstract base class for all other Helpers in CakePHP. * Provides common methods and features. * - * @package cake - * @subpackage cake.cake.libs.view + * @package cake.libs.view */ class Helper extends Object { diff --git a/cake/libs/view/helper_collection.php b/cake/libs/view/helper_collection.php index 18b700812..9d5fcbf17 100644 --- a/cake/libs/view/helper_collection.php +++ b/cake/libs/view/helper_collection.php @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view + * @package cake.libs.view * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/helpers/app_helper.php b/cake/libs/view/helpers/app_helper.php index d09503bb0..9ded31b9c 100644 --- a/cake/libs/view/helpers/app_helper.php +++ b/cake/libs/view/helpers/app_helper.php @@ -15,8 +15,6 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -29,8 +27,7 @@ App::import('View', 'Helper', false); * Add your application-wide methods in the class below, your helpers * will inherit them. * - * @package cake - * @subpackage cake.cake + * @package cake.libs.view.helpers */ class AppHelper extends Helper { } diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 6a1c430ea..34f1c9ef3 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @since CakePHP(tm) v 1.0.0.2277 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ * When using CacheHelper you don't call any of its methods, they are all automatically * called by View, and use the $cacheAction settings set in the controller. * - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @link http://book.cakephp.org/view/1376/Cache */ class CacheHelper extends AppHelper { diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 4fdf5d9dd..dd1c7d85f 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -12,12 +12,11 @@ * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * - * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) - * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.helpers - * @since CakePHP(tm) v 0.10.0.1076 - * @license MIT License (http://www.opensource.org/licenses/mit-license.php) + * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://cakephp.org CakePHP(tm) Project + * @package cake.libs.view.helpers + * @since CakePHP(tm) v 0.10.0.1076 + * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ /** @@ -25,8 +24,7 @@ * * Automatic generation of HTML FORMs from given data. * - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @link http://book.cakephp.org/view/1383/Form */ class FormHelper extends AppHelper { diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index b0965c449..c5165515f 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @since CakePHP(tm) v 0.9.1 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ * * HtmlHelper encloses all methods needed while working with HTML pages. * - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @link http://book.cakephp.org/view/1434/HTML */ class HtmlHelper extends AppHelper { diff --git a/cake/libs/view/helpers/jquery_engine.php b/cake/libs/view/helpers/jquery_engine.php index f09c70c33..b0864fba1 100644 --- a/cake/libs/view/helpers/jquery_engine.php +++ b/cake/libs/view/helpers/jquery_engine.php @@ -18,8 +18,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.view.helpers + * @package cake.libs.view.helpers * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Helper', 'Js'); diff --git a/cake/libs/view/helpers/js.php b/cake/libs/view/helpers/js.php index 41f0ffbd5..e285481ad 100644 --- a/cake/libs/view/helpers/js.php +++ b/cake/libs/view/helpers/js.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @since CakePHP v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ * JsHelper provides an abstract interface for authoring JavaScript with a * given client-side library. * - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers */ class JsHelper extends AppHelper { /** diff --git a/cake/libs/view/helpers/mootools_engine.php b/cake/libs/view/helpers/mootools_engine.php index bd0b676dd..5064db644 100644 --- a/cake/libs/view/helpers/mootools_engine.php +++ b/cake/libs/view/helpers/mootools_engine.php @@ -20,8 +20,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.libs.view.helpers + * @package cake.libs.view.helpers * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/helpers/number.php b/cake/libs/view/helpers/number.php index 03e01eea2..c88cd8ff2 100644 --- a/cake/libs/view/helpers/number.php +++ b/cake/libs/view/helpers/number.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ * * Methods to make numbers more readable. * - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @link http://book.cakephp.org/view/1452/Number */ class NumberHelper extends AppHelper { diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 11b897226..8c3c3a434 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * PaginationHelper encloses all methods needed when working with pagination. * - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @link http://book.cakephp.org/view/1458/Paginator */ class PaginatorHelper extends AppHelper { diff --git a/cake/libs/view/helpers/prototype_engine.php b/cake/libs/view/helpers/prototype_engine.php index 7f3e230b4..69a088f79 100644 --- a/cake/libs/view/helpers/prototype_engine.php +++ b/cake/libs/view/helpers/prototype_engine.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.libs.view.helpers + * @package cake.libs.view.helpers * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/helpers/rss.php b/cake/libs/view/helpers/rss.php index ae1ab6239..c1b7d219d 100644 --- a/cake/libs/view/helpers/rss.php +++ b/cake/libs/view/helpers/rss.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'Xml'); /** * RSS Helper class for easy output RSS structures. * - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @link http://book.cakephp.org/view/1460/RSS */ class RssHelper extends AppHelper { diff --git a/cake/libs/view/helpers/session.php b/cake/libs/view/helpers/session.php index b12fa3190..fb26c91c7 100644 --- a/cake/libs/view/helpers/session.php +++ b/cake/libs/view/helpers/session.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @since CakePHP(tm) v 1.1.7.3328 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ if (!class_exists('CakeSession')) { * * Session reading from the view. * - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @link http://book.cakephp.org/view/1465/Session */ class SessionHelper extends AppHelper { diff --git a/cake/libs/view/helpers/text.php b/cake/libs/view/helpers/text.php index 3f6933bbd..12eff3893 100644 --- a/cake/libs/view/helpers/text.php +++ b/cake/libs/view/helpers/text.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -36,8 +35,7 @@ if (!class_exists('Multibyte')) { * * Text manipulations: Highlight, excerpt, truncate, strip of links, convert email addresses to mailto: links... * - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @link http://book.cakephp.org/view/1469/Text */ class TextHelper extends AppHelper { diff --git a/cake/libs/view/helpers/time.php b/cake/libs/view/helpers/time.php index 31093a556..f65b62de0 100644 --- a/cake/libs/view/helpers/time.php +++ b/cake/libs/view/helpers/time.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * Manipulation of time data. * - * @package cake - * @subpackage cake.cake.libs.view.helpers + * @package cake.libs.view.helpers * @link http://book.cakephp.org/view/1470/Time */ class TimeHelper extends AppHelper { diff --git a/cake/libs/view/layouts/ajax.ctp b/cake/libs/view/layouts/ajax.ctp index dadf156ed..93371552b 100644 --- a/cake/libs/view/layouts/ajax.ctp +++ b/cake/libs/view/layouts/ajax.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts + * @package cake.libs.view.templates.layouts * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/layouts/default.ctp b/cake/libs/view/layouts/default.ctp index 30ec1a7dc..f247f3c35 100644 --- a/cake/libs/view/layouts/default.ctp +++ b/cake/libs/view/layouts/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts + * @package cake.libs.view.templates.layouts * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/layouts/email/html/default.ctp b/cake/libs/view/layouts/email/html/default.ctp index 41ce9a42d..7a8a1e7df 100644 --- a/cake/libs/view/layouts/email/html/default.ctp +++ b/cake/libs/view/layouts/email/html/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts.email.html + * @package cake.libs.view.templates.layouts.email.html * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/layouts/email/text/default.ctp b/cake/libs/view/layouts/email/text/default.ctp index 979535832..236b8ebb3 100644 --- a/cake/libs/view/layouts/email/text/default.ctp +++ b/cake/libs/view/layouts/email/text/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts.email.text + * @package cake.libs.view.templates.layouts.email.text * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/layouts/flash.ctp b/cake/libs/view/layouts/flash.ctp index 970589df0..cbe4c5abc 100644 --- a/cake/libs/view/layouts/flash.ctp +++ b/cake/libs/view/layouts/flash.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts + * @package cake.libs.view.templates.layouts * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/media.php b/cake/libs/view/media.php index fec019906..880383b30 100644 --- a/cake/libs/view/media.php +++ b/cake/libs/view/media.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view + * @package cake.libs.view * @since CakePHP(tm) v 1.2.0.5714 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/pages/home.ctp b/cake/libs/view/pages/home.ctp index 95ead2a18..5fddec45c 100644 --- a/cake/libs/view/pages/home.ctp +++ b/cake/libs/view/pages/home.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.pages + * @package cake.libs.view.templates.pages * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/scaffold.php b/cake/libs/view/scaffold.php index ed8daa358..6f051a211 100644 --- a/cake/libs/view/scaffold.php +++ b/cake/libs/view/scaffold.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view + * @package cake.libs.view * @since Cake v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/scaffolds/form.ctp b/cake/libs/view/scaffolds/form.ctp index 7fb2c4c8b..1a3992e38 100644 --- a/cake/libs/view/scaffolds/form.ctp +++ b/cake/libs/view/scaffolds/form.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.scaffolds + * @package cake.libs.view.templates.scaffolds * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/scaffolds/index.ctp b/cake/libs/view/scaffolds/index.ctp index d92b88320..c3da1d4d8 100644 --- a/cake/libs/view/scaffolds/index.ctp +++ b/cake/libs/view/scaffolds/index.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.console.libs.templates.views + * @package cake.console.libs.templates.views * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/scaffolds/view.ctp b/cake/libs/view/scaffolds/view.ctp index 963c59acc..c31b7397f 100644 --- a/cake/libs/view/scaffolds/view.ctp +++ b/cake/libs/view/scaffolds/view.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.scaffolds + * @package cake.libs.view.templates.scaffolds * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/view/theme.php b/cake/libs/view/theme.php index 80e56ae42..24e06e29b 100644 --- a/cake/libs/view/theme.php +++ b/cake/libs/view/theme.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view + * @package cake.libs.view * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -29,8 +28,7 @@ App::import('View', 'View'); * * Example of theme path with `$this->theme = 'super_hot';` Would be `app/views/themed/super_hot/posts` * - * @package cake - * @subpackage cake.cake.libs.view + * @package cake.libs.view */ class ThemeView extends View { /** diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index dba1a147b..ef1d46b9f 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view + * @package cake.libs.view * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/libs/xml.php b/cake/libs/xml.php index 0027d1631..1a90ddf94 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP v .0.10.3.1400 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php index 524c8857a..c5f4c3ca3 100644 --- a/cake/tests/cases/basics.test.php +++ b/cake/tests/cases/basics.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Core', 'Folder'); /** * BasicsTest class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class BasicsTest extends CakeTestCase { diff --git a/cake/tests/cases/console/all_console.test.php b/cake/tests/cases/console/all_console.test.php index 101a8faba..305ebbfc3 100644 --- a/cake/tests/cases/console/all_console.test.php +++ b/cake/tests/cases/console/all_console.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run all console classes. * - * @package cake - * @subpackage cake.tests.cases.console + * @package cake.tests.cases.console */ class AllConsoleTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/console/all_console_libs.test.php b/cake/tests/cases/console/all_console_libs.test.php index 70fb8746d..ad1f60fbd 100644 --- a/cake/tests/cases/console/all_console_libs.test.php +++ b/cake/tests/cases/console/all_console_libs.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run all console lib classes. * - * @package cake - * @subpackage cake.tests.cases.console + * @package cake.tests.cases.console */ class AllConsoleLibsTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/console/all_shells.test.php b/cake/tests/cases/console/all_shells.test.php index 7f657af82..e8ca96ac5 100644 --- a/cake/tests/cases/console/all_shells.test.php +++ b/cake/tests/cases/console/all_shells.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run all top level shell classes. * - * @package cake - * @subpackage cake.tests.cases.console + * @package cake.tests.cases.console */ class AllShellsTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/console/all_tasks.test.php b/cake/tests/cases/console/all_tasks.test.php index 51decf3d1..91ca6abdc 100644 --- a/cake/tests/cases/console/all_tasks.test.php +++ b/cake/tests/cases/console/all_tasks.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run all the task tests. * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllTasksTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/console/libs/console_error_handler.test.php b/cake/tests/cases/console/libs/console_error_handler.test.php index f00232bfb..51d16ab0f 100644 --- a/cake/tests/cases/console/libs/console_error_handler.test.php +++ b/cake/tests/cases/console/libs/console_error_handler.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.tests.cases.console + * @package cake.tests.cases.console * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/console/libs/console_option_parser.test.php b/cake/tests/cases/console/libs/console_option_parser.test.php index e010bbaf4..fac420ecd 100644 --- a/cake/tests/cases/console/libs/console_option_parser.test.php +++ b/cake/tests/cases/console/libs/console_option_parser.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.console + * @package cake.tests.cases.console * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/console/libs/console_output.test.php b/cake/tests/cases/console/libs/console_output.test.php index 9e9c8710d..d2af99d04 100644 --- a/cake/tests/cases/console/libs/console_output.test.php +++ b/cake/tests/cases/console/libs/console_output.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.console + * @package cake.tests.cases.console * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/console/libs/task_collection.test.php b/cake/tests/cases/console/libs/task_collection.test.php index 3bbbd12c8..27a43e619 100644 --- a/cake/tests/cases/console/libs/task_collection.test.php +++ b/cake/tests/cases/console/libs/task_collection.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/console/shell_dispatcher.test.php b/cake/tests/cases/console/shell_dispatcher.test.php index 2da5bbe81..eb6fd2bd6 100644 --- a/cake/tests/cases/console/shell_dispatcher.test.php +++ b/cake/tests/cases/console/shell_dispatcher.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.console + * @package cake.tests.cases.console * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; /** * TestShellDispatcher class * - * @package cake - * @subpackage cake.tests.cases.console + * @package cake.tests.cases.console */ class TestShellDispatcher extends ShellDispatcher { @@ -105,8 +103,7 @@ class TestShellDispatcher extends ShellDispatcher { /** * ShellDispatcherTest * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class ShellDispatcherTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/acl.test.php b/cake/tests/cases/console/shells/acl.test.php index 0bb6489b1..b13d593b4 100644 --- a/cake/tests/cases/console/shells/acl.test.php +++ b/cake/tests/cases/console/shells/acl.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; /** * AclShellTest class * - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class AclShellTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/api.test.php b/cake/tests/cases/console/shells/api.test.php index 7ed9b85a3..e43c55d33 100644 --- a/cake/tests/cases/console/shells/api.test.php +++ b/cake/tests/cases/console/shells/api.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,8 +25,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; /** * ApiShellTest class * - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class ApiShellTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/bake.test.php b/cake/tests/cases/console/shells/bake.test.php index 89383b1ff..7b2767389 100644 --- a/cake/tests/cases/console/shells/bake.test.php +++ b/cake/tests/cases/console/shells/bake.test.php @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/console/shells/command_list.test.php b/cake/tests/cases/console/shells/command_list.test.php index bdabc2230..7b518730a 100644 --- a/cake/tests/cases/console/shells/command_list.test.php +++ b/cake/tests/cases/console/shells/command_list.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.console.libs + * @package cake.tests.cases.console.libs * @since CakePHP v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/console/shells/schema.test.php b/cake/tests/cases/console/shells/schema.test.php index 6a7a619a1..d18b7a478 100644 --- a/cake/tests/cases/console/shells/schema.test.php +++ b/cake/tests/cases/console/shells/schema.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.console.libs.Shells + * @package cake.tests.cases.console.libs.Shells * @since CakePHP v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -28,8 +27,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; /** * Test for Schema database management * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class SchemaShellTestSchema extends CakeSchema { @@ -89,8 +87,7 @@ class SchemaShellTestSchema extends CakeSchema { /** * SchemaShellTest class * - * @package cake - * @subpackage cake.tests.cases.console.libs.Shells + * @package cake.tests.cases.console.libs.Shells */ class SchemaShellTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/shell.test.php b/cake/tests/cases/console/shells/shell.test.php index 900ebaad8..ac5d77faf 100644 --- a/cake/tests/cases/console/shells/shell.test.php +++ b/cake/tests/cases/console/shells/shell.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.console.libs + * @package cake.tests.cases.console.libs * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; /** * ShellTestShell class * - * @package cake - * @subpackage cake.tests.cases.console.libs + * @package cake.tests.cases.console.libs */ class ShellTestShell extends Shell { @@ -88,8 +86,7 @@ class TestMergeShell extends Shell { /** * TestAppleTask class * - * @package cake - * @subpackage cake.tests.cases.console.libs + * @package cake.tests.cases.console.libs */ class TestAppleTask extends Shell { } @@ -97,8 +94,7 @@ class TestAppleTask extends Shell { /** * TestBananaTask class * - * @package cake - * @subpackage cake.tests.cases.console.libs + * @package cake.tests.cases.console.libs */ class TestBananaTask extends Shell { } @@ -106,8 +102,7 @@ class TestBananaTask extends Shell { /** * ShellTest class * - * @package cake - * @subpackage cake.tests.cases.console.libs + * @package cake.tests.cases.console.libs */ class ShellTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/tasks/controller.test.php b/cake/tests/cases/console/shells/tasks/controller.test.php index 86ff8fb77..5abda16c9 100644 --- a/cake/tests/cases/console/shells/tasks/controller.test.php +++ b/cake/tests/cases/console/shells/tasks/controller.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -49,8 +48,7 @@ if (!$imported) { /** * ControllerTaskTest class * - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class ControllerTaskTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/tasks/db_config.test.php b/cake/tests/cases/console/shells/tasks/db_config.test.php index aca87ac94..6d37ffbb8 100644 --- a/cake/tests/cases/console/shells/tasks/db_config.test.php +++ b/cake/tests/cases/console/shells/tasks/db_config.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -48,8 +47,7 @@ class TEST_DATABASE_CONFIG { /** * DbConfigTest class * - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class DbConfigTaskTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/tasks/extract.test.php b/cake/tests/cases/console/shells/tasks/extract.test.php index 21993e0d4..0b2fbf4bc 100644 --- a/cake/tests/cases/console/shells/tasks/extract.test.php +++ b/cake/tests/cases/console/shells/tasks/extract.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -28,8 +27,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; /** * ExtractTaskTest class * - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class ExtractTaskTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/tasks/fixture.test.php b/cake/tests/cases/console/shells/tasks/fixture.test.php index 7121f7fd1..9265fdfb6 100644 --- a/cake/tests/cases/console/shells/tasks/fixture.test.php +++ b/cake/tests/cases/console/shells/tasks/fixture.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -29,8 +28,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; /** * FixtureTaskTest class * - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class FixtureTaskTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/tasks/model.test.php b/cake/tests/cases/console/shells/tasks/model.test.php index ac2a2c7fc..98ad033cd 100644 --- a/cake/tests/cases/console/shells/tasks/model.test.php +++ b/cake/tests/cases/console/shells/tasks/model.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP v 1.2.6 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -31,8 +30,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; /** * ModelTaskTest class * - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class ModelTaskTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/tasks/plugin.test.php b/cake/tests/cases/console/shells/tasks/plugin.test.php index 327b258c2..22131744e 100644 --- a/cake/tests/cases/console/shells/tasks/plugin.test.php +++ b/cake/tests/cases/console/shells/tasks/plugin.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2009, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP v 1.3.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -32,8 +31,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; /** * PluginTaskPlugin class * - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class PluginTaskTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/tasks/project.test.php b/cake/tests/cases/console/shells/tasks/project.test.php index 8e92b7949..65a5b4a52 100644 --- a/cake/tests/cases/console/shells/tasks/project.test.php +++ b/cake/tests/cases/console/shells/tasks/project.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP v 1.3.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -29,8 +28,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; /** * ProjectTask Test class * - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class ProjectTaskTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/tasks/template.test.php b/cake/tests/cases/console/shells/tasks/template.test.php index bbd81404d..0085d4f75 100644 --- a/cake/tests/cases/console/shells/tasks/template.test.php +++ b/cake/tests/cases/console/shells/tasks/template.test.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -28,8 +27,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; /** * TemplateTaskTest class * - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class TemplateTaskTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/tasks/test.test.php b/cake/tests/cases/console/shells/tasks/test.test.php index 14b603e54..394098a38 100644 --- a/cake/tests/cases/console/shells/tasks/test.test.php +++ b/cake/tests/cases/console/shells/tasks/test.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -34,7 +33,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; * Test Article model * * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class TestTaskArticle extends Model { @@ -111,7 +110,7 @@ class TestTaskArticle extends Model { * Tag Testing Model * * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class TestTaskTag extends Model { @@ -151,7 +150,7 @@ class TestTaskTag extends Model { * Simulated plugin * * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class TestTaskAppModel extends Model { } @@ -160,7 +159,7 @@ class TestTaskAppModel extends Model { * Testing AppMode (TaskComment) * * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class TestTaskComment extends TestTaskAppModel { @@ -198,7 +197,7 @@ class TestTaskComment extends TestTaskAppModel { * Test Task Comments Controller * * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class TestTaskCommentsController extends Controller { @@ -222,8 +221,7 @@ class TestTaskCommentsController extends Controller { /** * TestTaskTest class * - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class TestTaskTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/tasks/view.test.php b/cake/tests/cases/console/shells/tasks/view.test.php index 5a2dfcce5..99f1afdf9 100644 --- a/cake/tests/cases/console/shells/tasks/view.test.php +++ b/cake/tests/cases/console/shells/tasks/view.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -34,7 +33,7 @@ require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; * Test View Task Comment Model * * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class ViewTaskComment extends Model { @@ -72,7 +71,7 @@ class ViewTaskComment extends Model { * Test View Task Article Model * * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class ViewTaskArticle extends Model { @@ -97,7 +96,7 @@ class ViewTaskArticle extends Model { * Test View Task Comments Controller * * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class ViewTaskCommentsController extends Controller { @@ -130,7 +129,7 @@ class ViewTaskCommentsController extends Controller { * Test View Task Articles Controller * * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class ViewTaskArticlesController extends Controller { @@ -202,8 +201,7 @@ class ViewTaskArticlesController extends Controller { /** * ViewTaskTest class * - * @package cake - * @subpackage cake.tests.cases.console.libs.tasks + * @package cake.tests.cases.console.libs.tasks */ class ViewTaskTest extends CakeTestCase { diff --git a/cake/tests/cases/console/shells/testsuite.test.php b/cake/tests/cases/console/shells/testsuite.test.php index bfe463dbf..c57d1573b 100644 --- a/cake/tests/cases/console/shells/testsuite.test.php +++ b/cake/tests/cases/console/shells/testsuite.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.tests.libs + * @package cake.tests.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/libs/all_behaviors.test.php b/cake/tests/cases/libs/all_behaviors.test.php index b27a1cfe4..88720d386 100644 --- a/cake/tests/cases/libs/all_behaviors.test.php +++ b/cake/tests/cases/libs/all_behaviors.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ * * This test group will run all test in the cases/libs/models/behaviors directory * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllBehaviorsTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_cache_engines.test.php b/cake/tests/cases/libs/all_cache_engines.test.php index 64d2da93c..5c03437cd 100644 --- a/cake/tests/cases/libs/all_cache_engines.test.php +++ b/cake/tests/cases/libs/all_cache_engines.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run cache engine tests. * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllCacheEnginesTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_components.test.php b/cake/tests/cases/libs/all_components.test.php index 6724303ca..28e59aadf 100644 --- a/cake/tests/cases/libs/all_components.test.php +++ b/cake/tests/cases/libs/all_components.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run component class tests * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class AllComponentsTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_configure.test.php b/cake/tests/cases/libs/all_configure.test.php index 6b1b23fc8..6e35aef74 100644 --- a/cake/tests/cases/libs/all_configure.test.php +++ b/cake/tests/cases/libs/all_configure.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run cache engine tests. * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllConfigureTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_controllers.test.php b/cake/tests/cases/libs/all_controllers.test.php index ab3cf5581..8164896d9 100644 --- a/cake/tests/cases/libs/all_controllers.test.php +++ b/cake/tests/cases/libs/all_controllers.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run cache engine tests. * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllControllersTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_database.test.php b/cake/tests/cases/libs/all_database.test.php index 8c4fc024a..21cef27b6 100644 --- a/cake/tests/cases/libs/all_database.test.php +++ b/cake/tests/cases/libs/all_database.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run database tests not in model or behavior group. * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllDatabaseTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_error.test.php b/cake/tests/cases/libs/all_error.test.php index e37176908..b64c87542 100644 --- a/cake/tests/cases/libs/all_error.test.php +++ b/cake/tests/cases/libs/all_error.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run error handling related tests. * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllErrorTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_helpers.test.php b/cake/tests/cases/libs/all_helpers.test.php index 389290d27..247a10deb 100644 --- a/cake/tests/cases/libs/all_helpers.test.php +++ b/cake/tests/cases/libs/all_helpers.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run all test in the cases/libs/view/helpers directory. * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllHelpersTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_js_helpers.test.php b/cake/tests/cases/libs/all_js_helpers.test.php index b17e6b4fc..9dd0ab750 100644 --- a/cake/tests/cases/libs/all_js_helpers.test.php +++ b/cake/tests/cases/libs/all_js_helpers.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * This test group will run all test in the cases/libs/view/helpers directory related * to Js helper and its engines * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllJavascriptHelpersTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_libs.test.php b/cake/tests/cases/libs/all_libs.test.php index b0a070b49..ba0388850 100644 --- a/cake/tests/cases/libs/all_libs.test.php +++ b/cake/tests/cases/libs/all_libs.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run all non mvc related lib class tests * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class AllLibsTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_localization.test.php b/cake/tests/cases/libs/all_localization.test.php index ce7d0cc95..d30ab86b0 100644 --- a/cake/tests/cases/libs/all_localization.test.php +++ b/cake/tests/cases/libs/all_localization.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run i18n/l10n tests * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class AllLocalizationTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_model.test.php b/cake/tests/cases/libs/all_model.test.php index fb99184c0..bf968b0c3 100644 --- a/cake/tests/cases/libs/all_model.test.php +++ b/cake/tests/cases/libs/all_model.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run model class tests * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllModelTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_routing.test.php b/cake/tests/cases/libs/all_routing.test.php index cf1ff215e..68f0520f9 100644 --- a/cake/tests/cases/libs/all_routing.test.php +++ b/cake/tests/cases/libs/all_routing.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run view class tests (view, theme) * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllRoutingTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_socket.test.php b/cake/tests/cases/libs/all_socket.test.php index 01af39255..811822f9e 100644 --- a/cake/tests/cases/libs/all_socket.test.php +++ b/cake/tests/cases/libs/all_socket.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run socket class tests * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllSocketTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_test_suite.test.php b/cake/tests/cases/libs/all_test_suite.test.php index f1d52c2dc..b85ea0a19 100644 --- a/cake/tests/cases/libs/all_test_suite.test.php +++ b/cake/tests/cases/libs/all_test_suite.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run socket class tests * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllTestSuiteTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_tests.test.php b/cake/tests/cases/libs/all_tests.test.php index b3c94cb82..f7bdc72d3 100644 --- a/cake/tests/cases/libs/all_tests.test.php +++ b/cake/tests/cases/libs/all_tests.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ * * This test group will run all test in the cases/libs/models/behaviors directory * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllTests extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_views.test.php b/cake/tests/cases/libs/all_views.test.php index a84cd0c6d..0201426e4 100644 --- a/cake/tests/cases/libs/all_views.test.php +++ b/cake/tests/cases/libs/all_views.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run view class tests (view, theme) * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllViewsTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/all_xml.test.php b/cake/tests/cases/libs/all_xml.test.php index aed5b21d1..e56714ab0 100644 --- a/cake/tests/cases/libs/all_xml.test.php +++ b/cake/tests/cases/libs/all_xml.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ * * This test group will run xml class tests * - * @package cake - * @subpackage cake.tests.groups + * @package cake.tests.groups */ class AllXmlTest extends PHPUnit_Framework_TestSuite { diff --git a/cake/tests/cases/libs/app.test.php b/cake/tests/cases/libs/app.test.php index cbebd4bf3..6e7793072 100644 --- a/cake/tests/cases/libs/app.test.php +++ b/cake/tests/cases/libs/app.test.php @@ -3,8 +3,7 @@ /** * AppImportTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class AppImportTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/cache.test.php b/cake/tests/cases/libs/cache.test.php index ad24b70d3..0a35c9794 100644 --- a/cake/tests/cases/libs/cache.test.php +++ b/cake/tests/cases/libs/cache.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ if (!class_exists('Cache')) { /** * CacheTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class CacheTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/cache/apc.test.php b/cake/tests/cases/libs/cache/apc.test.php index bfdcea470..0abd07778 100644 --- a/cake/tests/cases/libs/cache/apc.test.php +++ b/cake/tests/cases/libs/cache/apc.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.cache + * @package cake.tests.cases.libs.cache * @since CakePHP(tm) v 1.2.0.5434 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ if (!class_exists('Cache')) { /** * ApcEngineTest class * - * @package cake - * @subpackage cake.tests.cases.libs.cache + * @package cake.tests.cases.libs.cache */ class ApcEngineTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/cache/file.test.php b/cake/tests/cases/libs/cache/file.test.php index 33361f040..fb6741a7a 100644 --- a/cake/tests/cases/libs/cache/file.test.php +++ b/cake/tests/cases/libs/cache/file.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.cache + * @package cake.tests.cases.libs.cache * @since CakePHP(tm) v 1.2.0.5434 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ if (!class_exists('Cache')) { /** * FileEngineTest class * - * @package cake - * @subpackage cake.tests.cases.libs.cache + * @package cake.tests.cases.libs.cache */ class FileEngineTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/cache/memcache.test.php b/cake/tests/cases/libs/cache/memcache.test.php index e69e243a2..42324a8bc 100644 --- a/cake/tests/cases/libs/cache/memcache.test.php +++ b/cake/tests/cases/libs/cache/memcache.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.cache + * @package cake.tests.cases.libs.cache * @since CakePHP(tm) v 1.2.0.5434 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -37,8 +36,7 @@ class TestMemcacheEngine extends MemcacheEngine { /** * MemcacheEngineTest class * - * @package cake - * @subpackage cake.tests.cases.libs.cache + * @package cake.tests.cases.libs.cache */ class MemcacheEngineTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/cache/xcache.test.php b/cake/tests/cases/libs/cache/xcache.test.php index d889d713c..eea1c4b2c 100644 --- a/cake/tests/cases/libs/cache/xcache.test.php +++ b/cake/tests/cases/libs/cache/xcache.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.cache + * @package cake.tests.cases.libs.cache * @since CakePHP(tm) v 1.2.0.5434 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ if (!class_exists('Cache')) { /** * XcacheEngineTest class * - * @package cake - * @subpackage cake.tests.cases.libs.cache + * @package cake.tests.cases.libs.cache */ class XcacheEngineTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/cake_log.test.php b/cake/tests/cases/libs/cake_log.test.php index 72fe1e8e8..0d21cb5b2 100644 --- a/cake/tests/cases/libs/cake_log.test.php +++ b/cake/tests/cases/libs/cake_log.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Core', 'log/FileLog'); /** * CakeLogTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class CakeLogTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index f423ac19d..58cc50631 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/libs/cake_session.test.php b/cake/tests/cases/libs/cake_session.test.php index e25c9416d..3673121fd 100644 --- a/cake/tests/cases/libs/cake_session.test.php +++ b/cake/tests/cases/libs/cake_session.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -34,8 +33,7 @@ class TestCakeSession extends CakeSession { /** * CakeSessionTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class CakeSessionTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/cake_socket.test.php b/cake/tests/cases/libs/cake_socket.test.php index ce84dedfb..ac12b4553 100644 --- a/cake/tests/cases/libs/cake_socket.test.php +++ b/cake/tests/cases/libs/cake_socket.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'CakeSocket'); /** * SocketTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class CakeSocketTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/cake_test_case.test.php b/cake/tests/cases/libs/cake_test_case.test.php index f9e5e8410..505dd8a08 100644 --- a/cake/tests/cases/libs/cake_test_case.test.php +++ b/cake/tests/cases/libs/cake_test_case.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.cake.libs. + * @package cake.libs. * @since CakePHP v 1.2.0.4487 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -31,8 +30,7 @@ if (!class_exists('AppController')) { /** * CakeTestCaseTest * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class CakeTestCaseTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/cake_test_fixture.test.php b/cake/tests/cases/libs/cake_test_fixture.test.php index 2042eb922..82c08be98 100644 --- a/cake/tests/cases/libs/cake_test_fixture.test.php +++ b/cake/tests/cases/libs/cake_test_fixture.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.libs + * @package cake.tests.libs * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Datasource', 'DboSource', false); /** * CakeTestFixtureTestFixture class * - * @package cake - * @subpackage cake.cake.tests.cases.libs + * @package cake.tests.cases.libs */ class CakeTestFixtureTestFixture extends CakeTestFixture { @@ -67,8 +65,7 @@ class CakeTestFixtureTestFixture extends CakeTestFixture { /** * CakeTestFixtureImportFixture class * - * @package cake - * @subpackage cake.cake.tests.cases.libs + * @package cake.tests.cases.libs */ class CakeTestFixtureImportFixture extends CakeTestFixture { @@ -90,8 +87,7 @@ class CakeTestFixtureImportFixture extends CakeTestFixture { /** * CakeTestFixtureDefaultImportFixture class * - * @package cake - * @subpackage cake.cake.tests.cases.libs + * @package cake.tests.cases.libs */ class CakeTestFixtureDefaultImportFixture extends CakeTestFixture { @@ -107,7 +103,7 @@ class CakeTestFixtureDefaultImportFixture extends CakeTestFixture { * FixtureImportTestModel class * * @package default - * @subpackage cake.cake.tests.cases.libs. + * @package cake.tests.cases.libs. */ class FixtureImportTestModel extends Model { public $name = 'FixtureImport'; @@ -125,8 +121,7 @@ class FixturePrefixTest extends Model { /** * Test case for CakeTestFixture * - * @package cake - * @subpackage cake.cake.tests.cases.libs + * @package cake.tests.cases.libs */ class CakeTestFixtureTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/class_registry.test.php b/cake/tests/cases/libs/class_registry.test.php index 7c0c14b23..21aa081b1 100644 --- a/cake/tests/cases/libs/class_registry.test.php +++ b/cake/tests/cases/libs/class_registry.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'ClassRegistry'); /** * ClassRegisterModel class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class ClassRegisterModel extends CakeTestModel { @@ -39,8 +37,7 @@ class ClassRegisterModel extends CakeTestModel { /** * RegisterArticle class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class RegisterArticle extends ClassRegisterModel { @@ -56,8 +53,7 @@ class RegisterArticle extends ClassRegisterModel { /** * RegisterArticleFeatured class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class RegisterArticleFeatured extends ClassRegisterModel { @@ -73,8 +69,7 @@ class RegisterArticleFeatured extends ClassRegisterModel { /** * RegisterArticleTag class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class RegisterArticleTag extends ClassRegisterModel { @@ -90,8 +85,7 @@ class RegisterArticleTag extends ClassRegisterModel { /** * RegistryPluginAppModel class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class RegistryPluginAppModel extends ClassRegisterModel { @@ -107,8 +101,7 @@ class RegistryPluginAppModel extends ClassRegisterModel { /** * TestRegistryPluginModel class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class TestRegistryPluginModel extends RegistryPluginAppModel { @@ -124,8 +117,7 @@ class TestRegistryPluginModel extends RegistryPluginAppModel { /** * RegisterCategory class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class RegisterCategory extends ClassRegisterModel { @@ -141,8 +133,7 @@ class RegisterCategory extends ClassRegisterModel { /** * ClassRegistryTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class ClassRegistryTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/config/ini_reader.test.php b/cake/tests/cases/libs/config/ini_reader.test.php index b0bd31ee0..2fb8eb2dd 100644 --- a/cake/tests/cases/libs/config/ini_reader.test.php +++ b/cake/tests/cases/libs/config/ini_reader.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/libs/config/php_reader.test.php b/cake/tests/cases/libs/config/php_reader.test.php index 539f56666..63957ea62 100644 --- a/cake/tests/cases/libs/config/php_reader.test.php +++ b/cake/tests/cases/libs/config/php_reader.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index eb9cb63b5..e58874e21 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ App::import('Core', 'config/PhpReader'); /** * ConfigureTest * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class ConfigureTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/controller/component.test.php b/cake/tests/cases/libs/controller/component.test.php index e42c1e0b6..eb01dae61 100644 --- a/cake/tests/cases/libs/controller/component.test.php +++ b/cake/tests/cases/libs/controller/component.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller * @since CakePHP(tm) v 1.2.0.5436 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Controller', 'Component', false); /** * ParamTestComponent * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ParamTestComponent extends Component { @@ -66,8 +64,7 @@ class ParamTestComponent extends Component { /** * ComponentTestController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ComponentTestController extends Controller { @@ -92,8 +89,7 @@ class ComponentTestController extends Controller { /** * AppleComponent class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class AppleComponent extends Component { @@ -128,8 +124,7 @@ class AppleComponent extends Component { /** * OrangeComponent class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class OrangeComponent extends Component { @@ -167,8 +162,7 @@ class OrangeComponent extends Component { /** * BananaComponent class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class BananaComponent extends Component { @@ -194,8 +188,7 @@ class BananaComponent extends Component { /** * MutuallyReferencingOneComponent class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class MutuallyReferencingOneComponent extends Component { @@ -211,8 +204,7 @@ class MutuallyReferencingOneComponent extends Component { /** * MutuallyReferencingTwoComponent class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class MutuallyReferencingTwoComponent extends Component { @@ -228,8 +220,7 @@ class MutuallyReferencingTwoComponent extends Component { /** * SomethingWithEmailComponent class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class SomethingWithEmailComponent extends Component { @@ -246,8 +237,7 @@ class SomethingWithEmailComponent extends Component { /** * ComponentTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ComponentTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/controller/component_collection.test.php b/cake/tests/cases/libs/controller/component_collection.test.php index 3e0e7bc53..3d84142d2 100644 --- a/cake/tests/cases/libs/controller/component_collection.test.php +++ b/cake/tests/cases/libs/controller/component_collection.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/libs/controller/components/acl.test.php b/cake/tests/cases/libs/controller/components/acl.test.php index 544ff44b1..4e10cce48 100644 --- a/cake/tests/cases/libs/controller/components/acl.test.php +++ b/cake/tests/cases/libs/controller/components/acl.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components * @since CakePHP(tm) v 1.2.0.5435 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('model' . DS . 'db_acl'); /** * AclNodeTwoTestBase class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class AclNodeTwoTestBase extends AclNode { @@ -48,8 +46,7 @@ class AclNodeTwoTestBase extends AclNode { /** * AroTwoTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class AroTwoTest extends AclNodeTwoTestBase { @@ -81,8 +78,7 @@ class AroTwoTest extends AclNodeTwoTestBase { /** * AcoTwoTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class AcoTwoTest extends AclNodeTwoTestBase { @@ -114,8 +110,7 @@ class AcoTwoTest extends AclNodeTwoTestBase { /** * PermissionTwoTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class PermissionTwoTest extends CakeTestModel { @@ -163,8 +158,7 @@ class PermissionTwoTest extends CakeTestModel { /** * DbAclTwoTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class DbAclTwoTest extends DbAcl { @@ -185,8 +179,7 @@ class DbAclTwoTest extends DbAcl { /** * Short description for class. * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class AclComponentTest extends CakeTestCase { /** diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 5b6f7262e..371edd2ed 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components * @since CakePHP(tm) v 1.2.0.5347 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,7 +25,7 @@ App::import('Core', 'Xml'); * TestAuthComponent class * * @package cake -* @subpackage cake.tests.cases.libs.controller.components +* @package cake.tests.cases.libs.controller.components */ class TestAuthComponent extends AuthComponent { @@ -61,7 +60,7 @@ class TestAuthComponent extends AuthComponent { * AuthUser class * * @package cake -* @subpackage cake.tests.cases.libs.controller.components +* @package cake.tests.cases.libs.controller.components */ class AuthUser extends CakeTestModel { @@ -122,8 +121,7 @@ class AuthUser extends CakeTestModel { /** * AuthUserCustomField class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class AuthUserCustomField extends AuthUser { @@ -140,7 +138,7 @@ class AuthUserCustomField extends AuthUser { * UuidUser class * * @package cake -* @subpackage cake.tests.cases.libs.controller.components +* @package cake.tests.cases.libs.controller.components */ class UuidUser extends CakeTestModel { @@ -210,7 +208,7 @@ class UuidUser extends CakeTestModel { * AuthTestController class * * @package cake -* @subpackage cake.tests.cases.libs.controller.components +* @package cake.tests.cases.libs.controller.components */ class AuthTestController extends Controller { @@ -364,8 +362,7 @@ class AuthTestController extends Controller { /** * AjaxAuthController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class AjaxAuthController extends Controller { @@ -444,7 +441,7 @@ class AjaxAuthController extends Controller { * AuthTest class * * @package cake -* @subpackage cake.tests.cases.libs.controller.components +* @package cake.tests.cases.libs.controller.components */ class AuthTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/controller/components/cookie.test.php b/cake/tests/cases/libs/controller/components/cookie.test.php index 7d441e4c2..0dc3ccd38 100644 --- a/cake/tests/cases/libs/controller/components/cookie.test.php +++ b/cake/tests/cases/libs/controller/components/cookie.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components * @since CakePHP(tm) v 1.2.0.5435 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Component', 'Cookie'); /** * CookieComponentTestController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class CookieComponentTestController extends Controller { @@ -55,8 +53,7 @@ class CookieComponentTestController extends Controller { /** * CookieComponentTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class CookieComponentTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index 9ce4602e1..411a93c09 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components * @since CakePHP(tm) v 1.2.0.5347 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,8 +25,7 @@ App::import('Core', 'CakeSocket'); /** * EmailTestComponent class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class EmailTestComponent extends EmailComponent { @@ -153,8 +151,7 @@ class EmailTestComponent extends EmailComponent { /** * EmailTestController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class EmailTestController extends Controller { @@ -194,8 +191,7 @@ class EmailTestController extends Controller { /** * EmailTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class EmailComponentTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index 20abfd8da..f7d094f7b 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ App::import('Core', array('CakeRequest', 'CakeResponse')); /** * PaginatorTestController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class PaginatorTestController extends Controller { /** @@ -57,8 +55,7 @@ class PaginatorTestController extends Controller { /** * PaginatorControllerPost class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class PaginatorControllerPost extends CakeTestModel { @@ -126,8 +123,7 @@ class PaginatorControllerPost extends CakeTestModel { /** * ControllerPaginateModel class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class ControllerPaginateModel extends CakeTestModel { @@ -170,8 +166,7 @@ class ControllerPaginateModel extends CakeTestModel { /** * PaginatorControllerCommentclass * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class PaginatorControllerComment extends CakeTestModel { diff --git a/cake/tests/cases/libs/controller/components/request_handler.test.php b/cake/tests/cases/libs/controller/components/request_handler.test.php index a9fe81d81..3ce9ccc4e 100644 --- a/cake/tests/cases/libs/controller/components/request_handler.test.php +++ b/cake/tests/cases/libs/controller/components/request_handler.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components * @since CakePHP(tm) v 1.2.0.5435 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ App::import('Core', array('CakeRequest', 'CakeResponse')); /** * RequestHandlerTestController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class RequestHandlerTestController extends Controller { @@ -80,8 +78,7 @@ class RequestHandlerTestController extends Controller { /** * RequestHandlerTestDisabledController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class RequestHandlerTestDisabledController extends Controller { @@ -106,8 +103,7 @@ class RequestHandlerTestDisabledController extends Controller { /** * RequestHandlerComponentTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class RequestHandlerComponentTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/cake/tests/cases/libs/controller/components/security.test.php index 33548c70e..cb7197392 100644 --- a/cake/tests/cases/libs/controller/components/security.test.php +++ b/cake/tests/cases/libs/controller/components/security.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components * @since CakePHP(tm) v 1.2.0.5435 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,7 +23,7 @@ App::import('Component', 'Security'); * TestSecurityComponent * * @package cake -* @subpackage cake.tests.cases.libs.controller.components +* @package cake.tests.cases.libs.controller.components */ class TestSecurityComponent extends SecurityComponent { @@ -43,7 +42,7 @@ class TestSecurityComponent extends SecurityComponent { * SecurityTestController * * @package cake -* @subpackage cake.tests.cases.libs.controller.components +* @package cake.tests.cases.libs.controller.components */ class SecurityTestController extends Controller { @@ -116,8 +115,7 @@ class SecurityTestController extends Controller { /** * SecurityComponentTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class SecurityComponentTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/controller/components/session.test.php b/cake/tests/cases/libs/controller/components/session.test.php index a2fa96410..938d8dd00 100644 --- a/cake/tests/cases/libs/controller/components/session.test.php +++ b/cake/tests/cases/libs/controller/components/session.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components * @since CakePHP(tm) v 1.2.0.5436 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Component', 'Session'); /** * SessionTestController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class SessionTestController extends Controller { @@ -49,8 +47,7 @@ class SessionTestController extends Controller { /** * OrangeSessionTestController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class OrangeSessionTestController extends Controller { @@ -75,8 +72,7 @@ class OrangeSessionTestController extends Controller { /** * SessionComponentTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class SessionComponentTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 0ab068cb6..266132684 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller * @since CakePHP(tm) v 1.2.0.5436 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,8 +25,7 @@ App::import('Component', 'Cookie'); /** * AppController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ControllerTestAppController extends Controller { /** @@ -57,8 +55,7 @@ class ControllerTestAppController extends Controller { /** * ControllerPost class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ControllerPost extends CakeTestModel { @@ -126,8 +123,7 @@ class ControllerPost extends CakeTestModel { /** * ControllerPostsController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ControllerCommentsController extends ControllerTestAppController { @@ -145,8 +141,7 @@ class ControllerCommentsController extends ControllerTestAppController { /** * ControllerComment class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ControllerComment extends CakeTestModel { @@ -186,8 +181,7 @@ class ControllerComment extends CakeTestModel { /** * ControllerAlias class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ControllerAlias extends CakeTestModel { @@ -219,8 +213,7 @@ class ControllerAlias extends CakeTestModel { /** * NameTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class NameTest extends CakeTestModel { @@ -250,8 +243,7 @@ class NameTest extends CakeTestModel { /** * TestController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class TestController extends ControllerTestAppController { @@ -307,8 +299,7 @@ class TestController extends ControllerTestAppController { /** * TestComponent class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class TestComponent extends Object { @@ -360,8 +351,7 @@ class TestComponent extends Object { /** * AnotherTestController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class AnotherTestController extends ControllerTestAppController { @@ -385,8 +375,7 @@ class AnotherTestController extends ControllerTestAppController { /** * ControllerTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ControllerTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/controller/controller_merge_vars.test.php b/cake/tests/cases/libs/controller/controller_merge_vars.test.php index b90a6b6e9..80e12d88c 100644 --- a/cake/tests/cases/libs/controller/controller_merge_vars.test.php +++ b/cake/tests/cases/libs/controller/controller_merge_vars.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller * @since CakePHP(tm) v 1.2.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,7 +24,7 @@ App::import('Core', 'Controller'); * Test case AppController * * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class MergeVarsAppController extends Controller { diff --git a/cake/tests/cases/libs/controller/pages_controller.test.php b/cake/tests/cases/libs/controller/pages_controller.test.php index 3d3084719..1d9d3febc 100644 --- a/cake/tests/cases/libs/controller/pages_controller.test.php +++ b/cake/tests/cases/libs/controller/pages_controller.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller * @since CakePHP(tm) v 1.2.0.5436 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Controller', 'Pages'); /** * PagesControllerTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class PagesControllerTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php index a68e7ad2b..031d8a0c5 100644 --- a/cake/tests/cases/libs/controller/scaffold.test.php +++ b/cake/tests/cases/libs/controller/scaffold.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller * @since CakePHP(tm) v 1.2.0.5436 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Core', 'Controller', false); /** * ScaffoldMockController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ScaffoldMockController extends Controller { @@ -48,8 +46,7 @@ class ScaffoldMockController extends Controller { /** * ScaffoldMockControllerWithFields class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ScaffoldMockControllerWithFields extends Controller { @@ -83,8 +80,7 @@ class ScaffoldMockControllerWithFields extends Controller { /** * TestScaffoldMock class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class TestScaffoldMock extends Scaffold { @@ -110,8 +106,7 @@ class TestScaffoldMock extends Scaffold { /** * ScaffoldMock class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ScaffoldMock extends CakeTestModel { @@ -166,8 +161,7 @@ class ScaffoldMock extends CakeTestModel { /** * ScaffoldUser class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ScaffoldUser extends CakeTestModel { @@ -196,8 +190,7 @@ class ScaffoldUser extends CakeTestModel { /** * ScaffoldComment class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ScaffoldComment extends CakeTestModel { @@ -226,8 +219,7 @@ class ScaffoldComment extends CakeTestModel { /** * ScaffoldTag class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ScaffoldTag extends CakeTestModel { /** @@ -241,8 +233,7 @@ class ScaffoldTag extends CakeTestModel { /** * TestScaffoldView class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class TestScaffoldView extends ScaffoldView { @@ -261,8 +252,7 @@ class TestScaffoldView extends ScaffoldView { /** * ScaffoldViewTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ScaffoldViewTest extends CakeTestCase { @@ -661,8 +651,7 @@ class ScaffoldViewTest extends CakeTestCase { /** * Scaffold Test class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class ScaffoldTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/controller_test_case.test.php b/cake/tests/cases/libs/controller_test_case.test.php index 585e07bb2..72bb959cb 100644 --- a/cake/tests/cases/libs/controller_test_case.test.php +++ b/cake/tests/cases/libs/controller_test_case.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.cake.libs. + * @package cake.libs. * @since CakePHP v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,15 +26,13 @@ require_once dirname(__FILE__) . DS . 'model' . DS . 'models.php'; /** * AppController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ if (!class_exists('AppController')) { /** * AppController class * - * @package cake - * @subpackage cake.tests.cases.libs.controller + * @package cake.tests.cases.libs.controller */ class AppController extends Controller { /** @@ -87,8 +84,7 @@ if (!class_exists('PostsController')) { /** * ControllerTestCaseTest * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class ControllerTestCaseTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/debugger.test.php b/cake/tests/cases/libs/debugger.test.php index 21e7d8057..a76945566 100644 --- a/cake/tests/cases/libs/debugger.test.php +++ b/cake/tests/cases/libs/debugger.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'Debugger'); /** * DebugggerTestCaseDebuggger class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class DebuggerTestCaseDebugger extends Debugger { } @@ -31,8 +29,7 @@ class DebuggerTestCaseDebugger extends Debugger { /** * DebuggerTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class DebuggerTest extends CakeTestCase { // !!! diff --git a/cake/tests/cases/libs/dispatcher.test.php b/cake/tests/cases/libs/dispatcher.test.php index 0192e6740..20fab006b 100644 --- a/cake/tests/cases/libs/dispatcher.test.php +++ b/cake/tests/cases/libs/dispatcher.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -40,8 +39,7 @@ class DispatcherMockCakeResponse extends CakeResponse { /** * TestDispatcher class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class TestDispatcher extends Dispatcher { @@ -75,8 +73,7 @@ class TestDispatcher extends Dispatcher { /** * MyPluginAppController class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class MyPluginAppController extends AppController { } @@ -84,8 +81,7 @@ class MyPluginAppController extends AppController { /** * MyPluginController class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class MyPluginController extends MyPluginAppController { @@ -137,8 +133,7 @@ class MyPluginController extends MyPluginAppController { /** * SomePagesController class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class SomePagesController extends AppController { @@ -199,8 +194,7 @@ class SomePagesController extends AppController { /** * OtherPagesController class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class OtherPagesController extends MyPluginAppController { @@ -243,8 +237,7 @@ class OtherPagesController extends MyPluginAppController { /** * TestDispatchPagesController class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class TestDispatchPagesController extends AppController { @@ -286,8 +279,7 @@ class TestDispatchPagesController extends AppController { /** * ArticlesTestAppController class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class ArticlesTestAppController extends AppController { } @@ -295,8 +287,7 @@ class ArticlesTestAppController extends AppController { /** * ArticlesTestController class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class ArticlesTestController extends ArticlesTestAppController { @@ -337,8 +328,7 @@ class ArticlesTestController extends ArticlesTestAppController { /** * SomePostsController class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class SomePostsController extends AppController { @@ -402,8 +392,7 @@ class SomePostsController extends AppController { /** * TestCachedPagesController class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class TestCachedPagesController extends Controller { @@ -498,8 +487,7 @@ class TestCachedPagesController extends Controller { /** * TimesheetsController class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class TimesheetsController extends Controller { @@ -532,8 +520,7 @@ class TimesheetsController extends Controller { /** * DispatcherTest class * - * @package cake - * @subpackage cake.tests.cases + * @package cake.tests.cases */ class DispatcherTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/error/error_handler.test.php b/cake/tests/cases/libs/error/error_handler.test.php index c6f33d600..ee5e43bca 100644 --- a/cake/tests/cases/libs/error/error_handler.test.php +++ b/cake/tests/cases/libs/error/error_handler.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Core', array('ErrorHandler', 'Controller', 'Router')); /** * ErrorHandlerTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class ErrorHandlerTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/error/exception_renderer.test.php b/cake/tests/cases/libs/error/exception_renderer.test.php index 0b147958f..1bc7e8bf0 100644 --- a/cake/tests/cases/libs/error/exception_renderer.test.php +++ b/cake/tests/cases/libs/error/exception_renderer.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Core', array('ExceptionRenderer', 'Controller', 'Component')); /** * Short description for class. * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class AuthBlueberryUser extends CakeTestModel { @@ -48,8 +46,7 @@ class AuthBlueberryUser extends CakeTestModel { /** * BlueberryComponent class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class BlueberryComponent extends Component { @@ -75,8 +72,7 @@ class BlueberryComponent extends Component { /** * TestErrorController class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class TestErrorController extends Controller { @@ -121,8 +117,7 @@ class TestErrorController extends Controller { /** * MyCustomExceptionRenderer class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class MyCustomExceptionRenderer extends ExceptionRenderer { @@ -146,8 +141,7 @@ class MissingWidgetThingException extends NotFoundException { } /** * ExceptionRendererTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class ExceptionRendererTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/file.test.php b/cake/tests/cases/libs/file.test.php index 2895deb88..d120ff8f3 100644 --- a/cake/tests/cases/libs/file.test.php +++ b/cake/tests/cases/libs/file.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'File'); /** * FileTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class FileTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/folder.test.php b/cake/tests/cases/libs/folder.test.php index 472385243..b30bfc616 100644 --- a/cake/tests/cases/libs/folder.test.php +++ b/cake/tests/cases/libs/folder.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'File'); /** * FolderTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class FolderTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/html_coverage_report.test.php b/cake/tests/cases/libs/html_coverage_report.test.php index 39f41fb60..90fe7f69a 100644 --- a/cake/tests/cases/libs/html_coverage_report.test.php +++ b/cake/tests/cases/libs/html_coverage_report.test.php @@ -13,7 +13,6 @@ * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package cake - * @subpackage cake.cake * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/libs/http/basic_authentication.test.php b/cake/tests/cases/libs/http/basic_authentication.test.php index f886a6686..990ed0750 100644 --- a/cake/tests/cases/libs/http/basic_authentication.test.php +++ b/cake/tests/cases/libs/http/basic_authentication.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.http + * @package cake.tests.cases.libs.http * @since CakePHP(tm) v 2.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ App::import('Lib', 'http/BasicAuthentication'); /** * BasicMethodTest class * - * @package cake - * @subpackage cake.tests.cases.libs.http + * @package cake.tests.cases.libs.http */ class BasicMethodTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/http/digest_authentication.test.php b/cake/tests/cases/libs/http/digest_authentication.test.php index 2166aee24..17832ce45 100644 --- a/cake/tests/cases/libs/http/digest_authentication.test.php +++ b/cake/tests/cases/libs/http/digest_authentication.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.http + * @package cake.tests.cases.libs.http * @since CakePHP(tm) v 2.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -51,8 +50,7 @@ class DigestHttpSocket extends HttpSocket { /** * DigestAuthenticationTest class * - * @package cake - * @subpackage cake.tests.cases.libs.http + * @package cake.tests.cases.libs.http */ class DigestAuthenticationTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/http_response.test.php b/cake/tests/cases/libs/http_response.test.php index 5d1647ebf..9155bb8a3 100644 --- a/cake/tests/cases/libs/http_response.test.php +++ b/cake/tests/cases/libs/http_response.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'HttpResponse'); /** * TestHttpResponse class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class TestHttpResponse extends HttpResponse { @@ -83,8 +81,7 @@ class TestHttpResponse extends HttpResponse { /** * HttpResponseTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class HttpResponseTest extends CakeTestCase { /** diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index cefd649e2..94de48389 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,7 +22,7 @@ App::import('Core', 'HttpSocket'); * TestAuthentication class * * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class TestAuthentication { @@ -168,8 +167,7 @@ class TestHttpSocket extends HttpSocket { /** * HttpSocketTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class HttpSocketTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/i18n.test.php b/cake/tests/cases/libs/i18n.test.php index 1ca37bcb1..5fdf3a93a 100644 --- a/cake/tests/cases/libs/i18n.test.php +++ b/cake/tests/cases/libs/i18n.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'i18n'); /** * I18nTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class I18nTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/inflector.test.php b/cake/tests/cases/libs/inflector.test.php index 4d383c887..3c04e0363 100644 --- a/cake/tests/cases/libs/inflector.test.php +++ b/cake/tests/cases/libs/inflector.test.php @@ -15,7 +15,7 @@ * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing * @package cake.tests - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license Open Group Test Suite License (http://www.opensource.org/licenses/opengroup.php) */ @@ -30,7 +30,7 @@ App::import('Core', 'Inflector'); * Short description for class. * * @package cake.tests - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class InflectorTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/l10n.test.php b/cake/tests/cases/libs/l10n.test.php index a1b35aee1..dd7a5a79c 100644 --- a/cake/tests/cases/libs/l10n.test.php +++ b/cake/tests/cases/libs/l10n.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'l10n'); /** * L10nTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class L10nTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/log/file_log.test.php b/cake/tests/cases/libs/log/file_log.test.php index f07ab9771..d861426b3 100644 --- a/cake/tests/cases/libs/log/file_log.test.php +++ b/cake/tests/cases/libs/log/file_log.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.log + * @package cake.tests.cases.libs.log * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'log/FileLog'); /** * CakeLogTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class FileLogTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/magic_db.test.php b/cake/tests/cases/libs/magic_db.test.php index e871a541d..80586925b 100644 --- a/cake/tests/cases/libs/magic_db.test.php +++ b/cake/tests/cases/libs/magic_db.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ if (!class_exists('MagicDb')) { /** * The test class for the MagicDb class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class MagicDbTest extends UnitTestCase { /** @@ -144,14 +142,12 @@ class MagicDbTest extends UnitTestCase { /** * Test data holding object for MagicDb tests * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ /** * MagicDbTestData class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class MagicDbTestData extends Object { /** diff --git a/cake/tests/cases/libs/model/behavior_collection.test.php b/cake/tests/cases/libs/model/behavior_collection.test.php index 27c71e2f9..efe549297 100644 --- a/cake/tests/cases/libs/model/behavior_collection.test.php +++ b/cake/tests/cases/libs/model/behavior_collection.test.php @@ -14,8 +14,7 @@ * * @copyright CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model * @since 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ require_once dirname(__FILE__) . DS . 'models.php'; /** * TestBehavior class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TestBehavior extends ModelBehavior { @@ -340,8 +338,7 @@ class TestBehavior extends ModelBehavior { /** * Test2Behavior class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Test2Behavior extends TestBehavior{ } @@ -349,8 +346,7 @@ class Test2Behavior extends TestBehavior{ /** * Test3Behavior class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Test3Behavior extends TestBehavior{ } @@ -358,8 +354,7 @@ class Test3Behavior extends TestBehavior{ /** * Test4Behavior class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Test4Behavior extends ModelBehavior{ function setup($model, $config = null) { @@ -372,8 +367,7 @@ class Test4Behavior extends ModelBehavior{ /** * Test5Behavior class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Test5Behavior extends ModelBehavior{ function setup($model, $config = null) { @@ -386,8 +380,7 @@ class Test5Behavior extends ModelBehavior{ /** * Test6Behavior class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Test6Behavior extends ModelBehavior{ function setup($model, $config = null) { @@ -400,8 +393,7 @@ class Test6Behavior extends ModelBehavior{ /** * Test7Behavior class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Test7Behavior extends ModelBehavior{ function setup($model, $config = null) { @@ -414,8 +406,7 @@ class Test7Behavior extends ModelBehavior{ /** * BehaviorCollection class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class BehaviorCollectionTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/behaviors/acl.test.php b/cake/tests/cases/libs/model/behaviors/acl.test.php index a7705dcd9..e3ec6daf9 100644 --- a/cake/tests/cases/libs/model/behaviors/acl.test.php +++ b/cake/tests/cases/libs/model/behaviors/acl.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.cake.libs.tests.model.behaviors.acl + * @package cake.libs.tests.model.behaviors.acl * @since CakePHP v 1.2.0.4487 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,7 +25,7 @@ App::import('Core', 'db_acl'); * Test Person class - self joined model * * @package cake -* @subpackage cake.tests.cases.libs.model.behaviors +* @package cake.tests.cases.libs.model.behaviors */ class AclPerson extends CakeTestModel { @@ -106,7 +105,7 @@ class AclPerson extends CakeTestModel { * AclUser class * * @package cake -* @subpackage cake.tests.cases.libs.model.behaviors +* @package cake.tests.cases.libs.model.behaviors */ class AclUser extends CakeTestModel { @@ -147,7 +146,7 @@ class AclUser extends CakeTestModel { * AclPost class * * @package cake -* @subpackage cake.tests.cases.libs.model.behaviors +* @package cake.tests.cases.libs.model.behaviors */ class AclPost extends CakeTestModel { @@ -188,7 +187,7 @@ class AclPost extends CakeTestModel { * AclBehaviorTest class * * @package cake -* @subpackage cake.tests.cases.libs.controller.components +* @package cake.tests.cases.libs.controller.components */ class AclBehaviorTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/behaviors/containable.test.php b/cake/tests/cases/libs/model/behaviors/containable.test.php index d2ccdc5aa..2c190f04b 100644 --- a/cake/tests/cases/libs/model/behaviors/containable.test.php +++ b/cake/tests/cases/libs/model/behaviors/containable.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.model.behaviors + * @package cake.tests.cases.libs.model.behaviors * @since CakePHP(tm) v 1.2.0.5669 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ require_once(dirname(dirname(__FILE__)) . DS . 'models.php'); /** * ContainableTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model.behaviors + * @package cake.tests.cases.libs.model.behaviors */ class ContainableBehaviorTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/behaviors/translate.test.php b/cake/tests/cases/libs/model/behaviors/translate.test.php index ee13fe3bb..24f39807d 100644 --- a/cake/tests/cases/libs/model/behaviors/translate.test.php +++ b/cake/tests/cases/libs/model/behaviors/translate.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.model.behaviors + * @package cake.tests.cases.libs.model.behaviors * @since CakePHP(tm) v 1.2.0.5669 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ require_once(dirname(dirname(__FILE__)) . DS . 'models.php'); /** * TranslateBehaviorTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model.behaviors + * @package cake.tests.cases.libs.model.behaviors */ class TranslateBehaviorTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/behaviors/tree.test.php b/cake/tests/cases/libs/model/behaviors/tree.test.php index 75375459f..96e4e174d 100644 --- a/cake/tests/cases/libs/model/behaviors/tree.test.php +++ b/cake/tests/cases/libs/model/behaviors/tree.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.model.behaviors + * @package cake.tests.cases.libs.model.behaviors * @since CakePHP(tm) v 1.2.0.5330 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ require_once(dirname(dirname(__FILE__)) . DS . 'models.php'); /** * NumberTreeTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model.behaviors + * @package cake.tests.cases.libs.model.behaviors */ class NumberTreeTest extends CakeTestCase { @@ -1279,8 +1277,7 @@ class NumberTreeTest extends CakeTestCase { /** * ScopedTreeTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model.behaviors + * @package cake.tests.cases.libs.model.behaviors */ class ScopedTreeTest extends CakeTestCase { @@ -1580,8 +1577,7 @@ class ScopedTreeTest extends CakeTestCase { /** * AfterTreeTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model.behaviors + * @package cake.tests.cases.libs.model.behaviors */ class AfterTreeTest extends CakeTestCase { @@ -1636,8 +1632,7 @@ class AfterTreeTest extends CakeTestCase { /** * UuidTreeTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model.behaviors + * @package cake.tests.cases.libs.model.behaviors */ class UuidTreeTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/cake_schema.test.php b/cake/tests/cases/libs/model/cake_schema.test.php index ff5c8ffdd..62050194d 100644 --- a/cake/tests/cases/libs/model/cake_schema.test.php +++ b/cake/tests/cases/libs/model/cake_schema.test.php @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5550 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Model', 'CakeSchema', false); /** * Test for Schema database management * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class MyAppSchema extends CakeSchema { @@ -125,8 +123,7 @@ class MyAppSchema extends CakeSchema { /** * TestAppSchema class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TestAppSchema extends CakeSchema { @@ -239,8 +236,7 @@ class TestAppSchema extends CakeSchema { /** * SchmeaPost class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class SchemaPost extends CakeTestModel { @@ -280,8 +276,7 @@ class SchemaPost extends CakeTestModel { /** * SchemaComment class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class SchemaComment extends CakeTestModel { @@ -313,8 +308,7 @@ class SchemaComment extends CakeTestModel { /** * SchemaTag class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class SchemaTag extends CakeTestModel { @@ -346,8 +340,7 @@ class SchemaTag extends CakeTestModel { /** * SchemaDatatype class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class SchemaDatatype extends CakeTestModel { @@ -377,7 +370,7 @@ class SchemaDatatype extends CakeTestModel { * * @uses CakeTestModel * @package - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Testdescribe extends CakeTestModel { @@ -393,8 +386,7 @@ class Testdescribe extends CakeTestModel { /** * SchemaCrossDatabase class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class SchemaCrossDatabase extends CakeTestModel { @@ -426,8 +418,7 @@ class SchemaCrossDatabase extends CakeTestModel { /** * SchemaCrossDatabaseFixture class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class SchemaCrossDatabaseFixture extends CakeTestFixture { @@ -472,8 +463,7 @@ class SchemaCrossDatabaseFixture extends CakeTestFixture { /** * SchemaPrefixAuthUser class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class SchemaPrefixAuthUser extends CakeTestModel { /** @@ -499,8 +489,7 @@ class SchemaPrefixAuthUser extends CakeTestModel { /** * CakeSchemaTest * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class CakeSchemaTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/connection_manager.test.php b/cake/tests/cases/libs/model/connection_manager.test.php index 04212fa4a..54f022963 100644 --- a/cake/tests/cases/libs/model/connection_manager.test.php +++ b/cake/tests/cases/libs/model/connection_manager.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5550 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'ConnectionManager'); /** * ConnectionManagerTest * - * @package cake - * @subpackage cake.tests.cases.models + * @package cake.tests.cases.models */ class ConnectionManagerTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php index 8ea86d221..1b25e9435 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,8 +25,7 @@ require_once LIBS.'model'.DS.'datasources'.DS.'dbo'.DS.'dbo_mssql.php'; /** * DboMssqlTestDb class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources.dbo + * @package cake.tests.cases.libs.model.datasources.dbo */ class DboMssqlTestDb extends DboMssql { @@ -130,8 +128,7 @@ class DboMssqlTestDb extends DboMssql { /** * MssqlTestModel class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class MssqlTestModel extends Model { @@ -232,8 +229,7 @@ class MssqlTestModel extends Model { /** * MssqlClientTestModel class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class MssqlClientTestModel extends Model { /** @@ -267,8 +263,7 @@ class MssqlClientTestModel extends Model { /** * DboMssqlTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources.dbo + * @package cake.tests.cases.libs.model.datasources.dbo */ class DboMssqlTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index bd29b5d39..1e4c0ed93 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php'; /** * DboMysqlTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources.dbo + * @package cake.tests.cases.libs.model.datasources.dbo */ class DboMysqlTest extends CakeTestCase { /** diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php index 3efa451bd..592b1eac0 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ require_once LIBS . 'model' . DS . 'datasources' . DS . 'dbo' . DS . 'dbo_oracle /** * DboOracleTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources.dbo + * @package cake.tests.cases.libs.model.datasources.dbo */ class DboOracleTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index c71836f5d..35b465f63 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php'; /** * DboPostgresTestDb class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class DboPostgresTestDb extends DboPostgres { @@ -63,8 +61,7 @@ class DboPostgresTestDb extends DboPostgres { /** * PostgresTestModel class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class PostgresTestModel extends Model { @@ -157,8 +154,7 @@ class PostgresTestModel extends Model { /** * PostgresClientTestModel class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class PostgresClientTestModel extends Model { @@ -198,8 +194,7 @@ class PostgresClientTestModel extends Model { /** * DboPostgresTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources.dbo + * @package cake.tests.cases.libs.model.datasources.dbo */ class DboPostgresTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php index b42b6209a..a1fc1cd4a 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs + * @package cake.libs * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', array('Model', 'DataSource', 'DboSource', 'DboSqlite')); /** * DboSqliteTestDb class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class DboSqliteTestDb extends DboSqlite { @@ -61,8 +59,7 @@ class DboSqliteTestDb extends DboSqlite { /** * DboSqliteTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources.dbo + * @package cake.tests.cases.libs.model.datasources.dbo */ class DboSqliteTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index fa5edf6c6..66b4a9cc1 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ require_once dirname(dirname(__FILE__)) . DS . 'models.php'; /** * DboSourceTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class DboSourceTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/db_acl.test.php b/cake/tests/cases/libs/model/db_acl.test.php index fb0a9f3f3..537f2f361 100644 --- a/cake/tests/cases/libs/model/db_acl.test.php +++ b/cake/tests/cases/libs/model/db_acl.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.controller.components.dbacl.models + * @package cake.tests.cases.libs.controller.components.dbacl.models * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Core', 'db_acl'); /** * DB ACL wrapper test class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class DbAclNodeTestBase extends AclNode { @@ -48,8 +46,7 @@ class DbAclNodeTestBase extends AclNode { /** * Aro Test Wrapper * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class DbAroTest extends DbAclNodeTestBase { @@ -81,8 +78,7 @@ class DbAroTest extends DbAclNodeTestBase { /** * Aco Test Wrapper * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class DbAcoTest extends DbAclNodeTestBase { @@ -114,8 +110,7 @@ class DbAcoTest extends DbAclNodeTestBase { /** * Permission Test Wrapper * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class DbPermissionTest extends CakeTestModel { @@ -155,8 +150,7 @@ class DbPermissionTest extends CakeTestModel { /** * DboActionTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class DbAcoActionTest extends CakeTestModel { @@ -188,8 +182,7 @@ class DbAcoActionTest extends CakeTestModel { /** * DbAroUserTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class DbAroUserTest extends CakeTestModel { @@ -227,8 +220,7 @@ class DbAroUserTest extends CakeTestModel { /** * TestDbAcl class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components + * @package cake.tests.cases.libs.controller.components */ class TestDbAcl extends DbAcl { @@ -249,8 +241,7 @@ class TestDbAcl extends DbAcl { /** * AclNodeTest class * - * @package cake - * @subpackage cake.tests.cases.libs.controller.components.dbacl.models + * @package cake.tests.cases.libs.controller.components.dbacl.models */ class AclNodeTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index 9809b3a0d..3fa31afd6 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); /** * ModelBaseTest * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ abstract class BaseModelTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/model/model_delete.test.php b/cake/tests/cases/libs/model/model_delete.test.php index e61865e57..ae4045743 100644 --- a/cake/tests/cases/libs/model/model_delete.test.php +++ b/cake/tests/cases/libs/model/model_delete.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ require_once dirname(__FILE__) . DS . 'model.test.php'; /** * ModelDeleteTest * - * @package cake - * @subpackage cake.tests.cases.libs.model.operations + * @package cake.tests.cases.libs.model.operations */ class ModelDeleteTest extends BaseModelTest { diff --git a/cake/tests/cases/libs/model/model_integration.test.php b/cake/tests/cases/libs/model/model_integration.test.php index 2770657f1..fdd410bde 100644 --- a/cake/tests/cases/libs/model/model_integration.test.php +++ b/cake/tests/cases/libs/model/model_integration.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -45,8 +44,7 @@ class DboMock extends DboSource { /** * ModelIntegrationTest * - * @package cake - * @subpackage cake.tests.cases.libs.model.operations + * @package cake.tests.cases.libs.model.operations */ class ModelIntegrationTest extends BaseModelTest { diff --git a/cake/tests/cases/libs/model/model_read.test.php b/cake/tests/cases/libs/model/model_read.test.php index 93808578c..5be36aaf3 100755 --- a/cake/tests/cases/libs/model/model_read.test.php +++ b/cake/tests/cases/libs/model/model_read.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ require_once dirname(__FILE__) . DS . 'model.test.php'; /** * ModelReadTest * - * @package cake - * @subpackage cake.tests.cases.libs.model.operations + * @package cake.tests.cases.libs.model.operations */ class ModelReadTest extends BaseModelTest { diff --git a/cake/tests/cases/libs/model/model_validation.test.php b/cake/tests/cases/libs/model/model_validation.test.php index d921618c0..0da3c18e9 100644 --- a/cake/tests/cases/libs/model/model_validation.test.php +++ b/cake/tests/cases/libs/model/model_validation.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ require_once dirname(__FILE__) . DS . 'model.test.php'; /** * ModelValidationTest * - * @package cake - * @subpackage cake.tests.cases.libs.model.operations + * @package cake.tests.cases.libs.model.operations */ class ModelValidationTest extends BaseModelTest { diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index c726ea47f..44a6585c6 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ require_once dirname(__FILE__) . DS . 'model.test.php'; /** * ModelWriteTest * - * @package cake - * @subpackage cake.tests.cases.libs.model.operations + * @package cake.tests.cases.libs.model.operations */ class ModelWriteTest extends BaseModelTest { diff --git a/cake/tests/cases/libs/model/models.php b/cake/tests/cases/libs/model/models.php index b116962b0..6c61254fb 100644 --- a/cake/tests/cases/libs/model/models.php +++ b/cake/tests/cases/libs/model/models.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model * @since CakePHP(tm) v 1.2.0.6464 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); /** * Test class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Test extends CakeTestModel { @@ -65,8 +63,7 @@ class Test extends CakeTestModel { /** * TestAlias class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TestAlias extends CakeTestModel { @@ -113,8 +110,7 @@ class TestAlias extends CakeTestModel { /** * TestValidate class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TestValidate extends CakeTestModel { @@ -178,8 +174,7 @@ class TestValidate extends CakeTestModel { /** * User class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class User extends CakeTestModel { @@ -203,8 +198,7 @@ class User extends CakeTestModel { /** * Article class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Article extends CakeTestModel { @@ -302,8 +296,7 @@ class BeforeDeleteComment extends CakeTestModel { /** * NumericArticle class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class NumericArticle extends CakeTestModel { @@ -327,8 +320,7 @@ class NumericArticle extends CakeTestModel { /** * Article10 class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Article10 extends CakeTestModel { @@ -360,8 +352,7 @@ class Article10 extends CakeTestModel { /** * ArticleFeatured class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ArticleFeatured extends CakeTestModel { @@ -417,8 +408,7 @@ class ArticleFeatured extends CakeTestModel { /** * Featured class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Featured extends CakeTestModel { @@ -442,8 +432,7 @@ class Featured extends CakeTestModel { /** * Tag class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Tag extends CakeTestModel { @@ -459,8 +448,7 @@ class Tag extends CakeTestModel { /** * ArticlesTag class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ArticlesTag extends CakeTestModel { @@ -476,8 +464,7 @@ class ArticlesTag extends CakeTestModel { /** * ArticleFeaturedsTag class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ArticleFeaturedsTag extends CakeTestModel { @@ -493,8 +480,7 @@ class ArticleFeaturedsTag extends CakeTestModel { /** * Comment class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Comment extends CakeTestModel { @@ -526,8 +512,7 @@ class Comment extends CakeTestModel { /** * Modified Comment Class has afterFind Callback * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ModifiedComment extends CakeTestModel { @@ -571,8 +556,7 @@ class ModifiedComment extends CakeTestModel { /** * Modified Comment Class has afterFind Callback * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class AgainModifiedComment extends CakeTestModel { @@ -616,8 +600,7 @@ class AgainModifiedComment extends CakeTestModel { /** * MergeVarPluginAppModel class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class MergeVarPluginAppModel extends AppModel { @@ -634,8 +617,7 @@ class MergeVarPluginAppModel extends AppModel { /** * MergeVarPluginPost class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class MergeVarPluginPost extends MergeVarPluginAppModel { @@ -659,8 +641,7 @@ class MergeVarPluginPost extends MergeVarPluginAppModel { /** * MergeVarPluginComment class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class MergeVarPluginComment extends MergeVarPluginAppModel { @@ -685,8 +666,7 @@ class MergeVarPluginComment extends MergeVarPluginAppModel { /** * Attachment class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Attachment extends CakeTestModel { @@ -702,8 +682,7 @@ class Attachment extends CakeTestModel { /** * Category class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Category extends CakeTestModel { @@ -719,8 +698,7 @@ class Category extends CakeTestModel { /** * CategoryThread class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class CategoryThread extends CakeTestModel { @@ -744,8 +722,7 @@ class CategoryThread extends CakeTestModel { /** * Apple class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Apple extends CakeTestModel { @@ -793,8 +770,7 @@ class Apple extends CakeTestModel { /** * Sample class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Sample extends CakeTestModel { @@ -818,8 +794,7 @@ class Sample extends CakeTestModel { /** * AnotherArticle class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class AnotherArticle extends CakeTestModel { @@ -843,8 +818,7 @@ class AnotherArticle extends CakeTestModel { /** * Advertisement class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Advertisement extends CakeTestModel { @@ -868,8 +842,7 @@ class Advertisement extends CakeTestModel { /** * Home class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Home extends CakeTestModel { @@ -893,8 +866,7 @@ class Home extends CakeTestModel { /** * Post class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Post extends CakeTestModel { @@ -930,8 +902,7 @@ class Post extends CakeTestModel { /** * Author class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Author extends CakeTestModel { @@ -967,8 +938,7 @@ class Author extends CakeTestModel { /** * ModifiedAuthor class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ModifiedAuthor extends Author { @@ -998,8 +968,7 @@ class ModifiedAuthor extends Author { /** * Project class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Project extends CakeTestModel { @@ -1023,8 +992,7 @@ class Project extends CakeTestModel { /** * Thread class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Thread extends CakeTestModel { @@ -1056,8 +1024,7 @@ class Thread extends CakeTestModel { /** * Message class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Message extends CakeTestModel { @@ -1081,8 +1048,7 @@ class Message extends CakeTestModel { /** * Bid class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Bid extends CakeTestModel { @@ -1106,8 +1072,7 @@ class Bid extends CakeTestModel { /** * NodeAfterFind class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class NodeAfterFind extends CakeTestModel { @@ -1174,8 +1139,7 @@ class NodeAfterFind extends CakeTestModel { /** * NodeAfterFindSample class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class NodeAfterFindSample extends CakeTestModel { @@ -1207,8 +1171,7 @@ class NodeAfterFindSample extends CakeTestModel { /** * NodeNoAfterFind class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class NodeNoAfterFind extends CakeTestModel { @@ -1264,8 +1227,7 @@ class NodeNoAfterFind extends CakeTestModel { /** * Node class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Node extends CakeTestModel{ @@ -1297,8 +1259,7 @@ class Node extends CakeTestModel{ /** * Dependency class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Dependency extends CakeTestModel { @@ -1314,8 +1275,7 @@ class Dependency extends CakeTestModel { /** * ModelA class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ModelA extends CakeTestModel { @@ -1347,8 +1307,7 @@ class ModelA extends CakeTestModel { /** * ModelB class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ModelB extends CakeTestModel { @@ -1380,8 +1339,7 @@ class ModelB extends CakeTestModel { /** * ModelC class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ModelC extends CakeTestModel { @@ -1413,8 +1371,7 @@ class ModelC extends CakeTestModel { /** * ModelD class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ModelD extends CakeTestModel { @@ -1438,8 +1395,7 @@ class ModelD extends CakeTestModel { /** * Something class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Something extends CakeTestModel { @@ -1463,8 +1419,7 @@ class Something extends CakeTestModel { /** * SomethingElse class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class SomethingElse extends CakeTestModel { @@ -1488,8 +1443,7 @@ class SomethingElse extends CakeTestModel { /** * JoinThing class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class JoinThing extends CakeTestModel { @@ -1513,8 +1467,7 @@ class JoinThing extends CakeTestModel { /** * Portfolio class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Portfolio extends CakeTestModel { @@ -1538,8 +1491,7 @@ class Portfolio extends CakeTestModel { /** * Item class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Item extends CakeTestModel { @@ -1571,8 +1523,7 @@ class Item extends CakeTestModel { /** * ItemsPortfolio class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ItemsPortfolio extends CakeTestModel { @@ -1588,8 +1539,7 @@ class ItemsPortfolio extends CakeTestModel { /** * Syfile class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Syfile extends CakeTestModel { @@ -1613,8 +1563,7 @@ class Syfile extends CakeTestModel { /** * Image class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Image extends CakeTestModel { @@ -1630,8 +1579,7 @@ class Image extends CakeTestModel { /** * DeviceType class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class DeviceType extends CakeTestModel { @@ -1675,8 +1623,7 @@ class DeviceType extends CakeTestModel { /** * DeviceTypeCategory class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class DeviceTypeCategory extends CakeTestModel { @@ -1692,8 +1639,7 @@ class DeviceTypeCategory extends CakeTestModel { /** * FeatureSet class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class FeatureSet extends CakeTestModel { @@ -1709,8 +1655,7 @@ class FeatureSet extends CakeTestModel { /** * ExteriorTypeCategory class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ExteriorTypeCategory extends CakeTestModel { @@ -1734,8 +1679,7 @@ class ExteriorTypeCategory extends CakeTestModel { /** * Document class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Document extends CakeTestModel { @@ -1759,8 +1703,7 @@ class Document extends CakeTestModel { /** * Device class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Device extends CakeTestModel { @@ -1776,8 +1719,7 @@ class Device extends CakeTestModel { /** * DocumentDirectory class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class DocumentDirectory extends CakeTestModel { @@ -1793,8 +1735,7 @@ class DocumentDirectory extends CakeTestModel { /** * PrimaryModel class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class PrimaryModel extends CakeTestModel { @@ -1810,8 +1751,7 @@ class PrimaryModel extends CakeTestModel { /** * SecondaryModel class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class SecondaryModel extends CakeTestModel { @@ -1827,8 +1767,7 @@ class SecondaryModel extends CakeTestModel { /** * JoinA class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class JoinA extends CakeTestModel { @@ -1852,8 +1791,7 @@ class JoinA extends CakeTestModel { /** * JoinB class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class JoinB extends CakeTestModel { @@ -1877,8 +1815,7 @@ class JoinB extends CakeTestModel { /** * JoinC class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class JoinC extends CakeTestModel { @@ -1902,8 +1839,7 @@ class JoinC extends CakeTestModel { /** * ThePaper class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ThePaper extends CakeTestModel { @@ -1943,8 +1879,7 @@ class ThePaper extends CakeTestModel { /** * Monkey class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Monkey extends CakeTestModel { @@ -1968,8 +1903,7 @@ class Monkey extends CakeTestModel { /** * AssociationTest1 class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class AssociationTest1 extends CakeTestModel { @@ -2003,8 +1937,7 @@ class AssociationTest1 extends CakeTestModel { /** * AssociationTest2 class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class AssociationTest2 extends CakeTestModel { @@ -2038,8 +1971,7 @@ class AssociationTest2 extends CakeTestModel { /** * Callback class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Callback extends CakeTestModel { @@ -2047,8 +1979,7 @@ class Callback extends CakeTestModel { /** * CallbackPostTestModel class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class CallbackPostTestModel extends CakeTestModel { public $useTable = 'posts'; @@ -2099,8 +2030,7 @@ class CallbackPostTestModel extends CakeTestModel { /** * Uuid class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Uuid extends CakeTestModel { @@ -2116,8 +2046,7 @@ class Uuid extends CakeTestModel { /** * DataTest class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class DataTest extends CakeTestModel { @@ -2133,8 +2062,7 @@ class DataTest extends CakeTestModel { /** * TheVoid class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TheVoid extends CakeTestModel { @@ -2158,8 +2086,7 @@ class TheVoid extends CakeTestModel { /** * ValidationTest1 class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ValidationTest1 extends CakeTestModel { @@ -2250,8 +2177,7 @@ class ValidationTest1 extends CakeTestModel { /** * ValidationTest2 class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ValidationTest2 extends CakeTestModel { @@ -2312,8 +2238,7 @@ class ValidationTest2 extends CakeTestModel { /** * Person class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Person extends CakeTestModel { @@ -2343,8 +2268,7 @@ class Person extends CakeTestModel { /** * UnderscoreField class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class UnderscoreField extends CakeTestModel { @@ -2360,8 +2284,7 @@ class UnderscoreField extends CakeTestModel { /** * Product class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Product extends CakeTestModel { @@ -2377,8 +2300,7 @@ class Product extends CakeTestModel { /** * Story class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Story extends CakeTestModel { @@ -2418,8 +2340,7 @@ class Story extends CakeTestModel { /** * Cd class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Cd extends CakeTestModel { @@ -2443,8 +2364,7 @@ class Cd extends CakeTestModel { /** * Book class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Book extends CakeTestModel { @@ -2468,8 +2388,7 @@ class Book extends CakeTestModel { /** * OverallFavorite class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class OverallFavorite extends CakeTestModel { @@ -2485,8 +2404,7 @@ class OverallFavorite extends CakeTestModel { /** * MyUser class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class MyUser extends CakeTestModel { @@ -2510,8 +2428,7 @@ class MyUser extends CakeTestModel { /** * MyCategory class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class MyCategory extends CakeTestModel { @@ -2535,8 +2452,7 @@ class MyCategory extends CakeTestModel { /** * MyProduct class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class MyProduct extends CakeTestModel { @@ -2560,8 +2476,7 @@ class MyProduct extends CakeTestModel { /** * MyCategoriesMyUser class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class MyCategoriesMyUser extends CakeTestModel { @@ -2577,8 +2492,7 @@ class MyCategoriesMyUser extends CakeTestModel { /** * MyCategoriesMyProduct class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class MyCategoriesMyProduct extends CakeTestModel { @@ -2595,8 +2509,7 @@ class MyCategoriesMyProduct extends CakeTestModel { /** * NumberTree class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class NumberTree extends CakeTestModel { @@ -2662,8 +2575,7 @@ class NumberTree extends CakeTestModel { /** * NumberTreeTwo class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class NumberTreeTwo extends NumberTree { @@ -2687,8 +2599,7 @@ class NumberTreeTwo extends NumberTree { /** * FlagTree class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class FlagTree extends NumberTree { @@ -2704,8 +2615,7 @@ class FlagTree extends NumberTree { /** * UnconventionalTree class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class UnconventionalTree extends NumberTree { @@ -2728,8 +2638,7 @@ class UnconventionalTree extends NumberTree { /** * UuidTree class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class UuidTree extends NumberTree { @@ -2745,8 +2654,7 @@ class UuidTree extends NumberTree { /** * Campaign class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Campaign extends CakeTestModel { @@ -2770,8 +2678,7 @@ class Campaign extends CakeTestModel { /** * Ad class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Ad extends CakeTestModel { @@ -2803,8 +2710,7 @@ class Ad extends CakeTestModel { /** * AfterTree class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class AfterTree extends NumberTree { @@ -2834,8 +2740,7 @@ class AfterTree extends NumberTree { /** * Nonconformant Content class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Content extends CakeTestModel { @@ -2875,8 +2780,7 @@ class Content extends CakeTestModel { /** * Nonconformant Account class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Account extends CakeTestModel { @@ -2908,8 +2812,7 @@ class Account extends CakeTestModel { /** * Nonconformant ContentAccount class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class ContentAccount extends CakeTestModel { @@ -2941,8 +2844,7 @@ class ContentAccount extends CakeTestModel { /** * FilmFile class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class FilmFile extends CakeTestModel { public $name = 'FilmFile'; @@ -2951,8 +2853,7 @@ class FilmFile extends CakeTestModel { /** * Basket test model * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Basket extends CakeTestModel { public $name = 'Basket'; @@ -2971,8 +2872,7 @@ class Basket extends CakeTestModel { /** * TestPluginArticle class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TestPluginArticle extends CakeTestModel { @@ -3010,8 +2910,7 @@ class TestPluginArticle extends CakeTestModel { /** * TestPluginComment class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TestPluginComment extends CakeTestModel { @@ -3041,8 +2940,7 @@ class TestPluginComment extends CakeTestModel { /** * Uuidportfolio class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Uuidportfolio extends CakeTestModel { @@ -3066,8 +2964,7 @@ class Uuidportfolio extends CakeTestModel { /** * Uuiditem class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class Uuiditem extends CakeTestModel { @@ -3092,8 +2989,7 @@ class Uuiditem extends CakeTestModel { /** * UuiditemsPortfolio class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class UuiditemsUuidportfolio extends CakeTestModel { @@ -3109,8 +3005,7 @@ class UuiditemsUuidportfolio extends CakeTestModel { /** * UuiditemsPortfolioNumericid class * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class UuiditemsUuidportfolioNumericid extends CakeTestModel { @@ -3126,8 +3021,7 @@ class UuiditemsUuidportfolioNumericid extends CakeTestModel { /** * TranslateTestModel class. * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TranslateTestModel extends CakeTestModel { @@ -3159,8 +3053,7 @@ class TranslateTestModel extends CakeTestModel { /** * TranslateTestModel class. * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TranslateWithPrefix extends CakeTestModel { /** @@ -3188,8 +3081,7 @@ class TranslateWithPrefix extends CakeTestModel { /** * TranslatedItem class. * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TranslatedItem extends CakeTestModel { @@ -3229,8 +3121,7 @@ class TranslatedItem extends CakeTestModel { /** * TranslatedItem class. * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TranslatedItem2 extends CakeTestModel { /** @@ -3265,8 +3156,7 @@ class TranslatedItem2 extends CakeTestModel { /** * TranslatedItemWithTable class. * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TranslatedItemWithTable extends CakeTestModel { @@ -3322,8 +3212,7 @@ class TranslatedItemWithTable extends CakeTestModel { /** * TranslateArticleModel class. * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TranslateArticleModel extends CakeTestModel { @@ -3355,8 +3244,7 @@ class TranslateArticleModel extends CakeTestModel { /** * TranslatedArticle class. * - * @package cake - * @subpackage cake.tests.cases.libs.model + * @package cake.tests.cases.libs.model */ class TranslatedArticle extends CakeTestModel { @@ -3564,8 +3452,7 @@ class TransactionTestModel extends CakeTestModel { /** * TestModel class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class TestModel extends CakeTestModel { @@ -3644,8 +3531,7 @@ class TestModel extends CakeTestModel { /** * TestModel2 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class TestModel2 extends CakeTestModel { @@ -3669,8 +3555,7 @@ class TestModel2 extends CakeTestModel { /** * TestModel4 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class TestModel3 extends CakeTestModel { @@ -3694,8 +3579,7 @@ class TestModel3 extends CakeTestModel { /** * TestModel4 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class TestModel4 extends CakeTestModel { @@ -3785,8 +3669,7 @@ class TestModel4 extends CakeTestModel { /** * TestModel4TestModel7 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class TestModel4TestModel7 extends CakeTestModel { @@ -3834,8 +3717,7 @@ class TestModel4TestModel7 extends CakeTestModel { /** * TestModel5 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class TestModel5 extends CakeTestModel { @@ -3908,8 +3790,7 @@ class TestModel5 extends CakeTestModel { /** * TestModel6 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class TestModel6 extends CakeTestModel { @@ -3971,8 +3852,7 @@ class TestModel6 extends CakeTestModel { /** * TestModel7 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class TestModel7 extends CakeTestModel { @@ -4022,8 +3902,7 @@ class TestModel7 extends CakeTestModel { /** * TestModel8 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class TestModel8 extends CakeTestModel { @@ -4088,8 +3967,7 @@ class TestModel8 extends CakeTestModel { /** * TestModel9 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class TestModel9 extends CakeTestModel { @@ -4152,8 +4030,7 @@ class TestModel9 extends CakeTestModel { /** * Level class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class Level extends CakeTestModel { @@ -4216,8 +4093,7 @@ class Level extends CakeTestModel { /** * Group class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class Group extends CakeTestModel { @@ -4283,8 +4159,7 @@ class Group extends CakeTestModel { /** * User2 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class User2 extends CakeTestModel { @@ -4361,8 +4236,7 @@ class User2 extends CakeTestModel { /** * Category2 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class Category2 extends CakeTestModel { @@ -4450,8 +4324,7 @@ class Category2 extends CakeTestModel { /** * Article2 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class Article2 extends CakeTestModel { @@ -4527,8 +4400,7 @@ class Article2 extends CakeTestModel { /** * CategoryFeatured2 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class CategoryFeatured2 extends CakeTestModel { @@ -4579,8 +4451,7 @@ class CategoryFeatured2 extends CakeTestModel { /** * Featured2 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class Featured2 extends CakeTestModel { @@ -4642,8 +4513,7 @@ class Featured2 extends CakeTestModel { /** * Comment2 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class Comment2 extends CakeTestModel { @@ -4701,8 +4571,7 @@ class Comment2 extends CakeTestModel { /** * ArticleFeatured2 class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class ArticleFeatured2 extends CakeTestModel { @@ -4788,8 +4657,7 @@ class ArticleFeatured2 extends CakeTestModel { /** * MysqlTestModel class * - * @package cake - * @subpackage cake.tests.cases.libs.model.datasources + * @package cake.tests.cases.libs.model.datasources */ class MysqlTestModel extends Model { diff --git a/cake/tests/cases/libs/multibyte.test.php b/cake/tests/cases/libs/multibyte.test.php index 9ec3538ea..f9998cdf9 100644 --- a/cake/tests/cases/libs/multibyte.test.php +++ b/cake/tests/cases/libs/multibyte.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.6833 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'Multibyte'); /** * MultibyteTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class MultibyteTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/object.test.php b/cake/tests/cases/libs/object.test.php index a371cf9f2..45126a053 100644 --- a/cake/tests/cases/libs/object.test.php +++ b/cake/tests/cases/libs/object.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', array('Object', 'Controller', 'Model')); /** * RequestActionPost class * - * @package cake - * @subpackage cake.tests.cases.libs.object + * @package cake.tests.cases.libs.object */ class RequestActionPost extends CakeTestModel { @@ -47,8 +45,7 @@ class RequestActionPost extends CakeTestModel { /** * RequestActionController class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class RequestActionController extends Controller { @@ -134,8 +131,7 @@ class RequestActionController extends Controller { /** * RequestActionPersistentController class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class RequestActionPersistentController extends Controller { @@ -168,8 +164,7 @@ class RequestActionPersistentController extends Controller { /** * TestObject class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class TestObject extends Object { @@ -319,8 +314,7 @@ class TestObject extends Object { /** * ObjectTestModel class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class ObjectTestModel extends CakeTestModel { public $useTable = false; @@ -330,8 +324,7 @@ class ObjectTestModel extends CakeTestModel { /** * Object Test class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class ObjectTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/object_collection.test.php b/cake/tests/cases/libs/object_collection.test.php index 26ab24951..cfb177378 100644 --- a/cake/tests/cases/libs/object_collection.test.php +++ b/cake/tests/cases/libs/object_collection.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index e0def56f9..963642cfc 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ if (!defined('FULL_BASE_URL')) { /** * RouterTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class RouterTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/sanitize.test.php b/cake/tests/cases/libs/sanitize.test.php index 35013ca53..c3f420782 100644 --- a/cake/tests/cases/libs/sanitize.test.php +++ b/cake/tests/cases/libs/sanitize.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5428 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'Sanitize'); /** * DataTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class SanitizeDataTest extends CakeTestModel { @@ -47,8 +45,7 @@ class SanitizeDataTest extends CakeTestModel { /** * Article class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class SanitizeArticle extends CakeTestModel { @@ -72,8 +69,7 @@ class SanitizeArticle extends CakeTestModel { /** * SanitizeTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class SanitizeTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/security.test.php b/cake/tests/cases/libs/security.test.php index da37e7e7c..a1c7a18af 100644 --- a/cake/tests/cases/libs/security.test.php +++ b/cake/tests/cases/libs/security.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'Security'); /** * SecurityTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class SecurityTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/session/cache_session.test.php b/cake/tests/cases/libs/session/cache_session.test.php index 264318c2a..9f0572cd0 100644 --- a/cake/tests/cases/libs/session/cache_session.test.php +++ b/cake/tests/cases/libs/session/cache_session.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases.libs.session + * @package cake.tests.cases.libs.session * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/libs/session/database_session.test.php b/cake/tests/cases/libs/session/database_session.test.php index deb867db6..b3c457c2d 100644 --- a/cake/tests/cases/libs/session/database_session.test.php +++ b/cake/tests/cases/libs/session/database_session.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.cases.libs.session + * @package cake.tests.cases.libs.session * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index a4d6a5427..c648940bb 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'Set'); /** * SetTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class SetTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/string.test.php b/cake/tests/cases/libs/string.test.php index 1e5e84d54..124e252d7 100644 --- a/cake/tests/cases/libs/string.test.php +++ b/cake/tests/cases/libs/string.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'String'); /** * StringTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class StringTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/test_manager.test.php b/cake/tests/cases/libs/test_manager.test.php index b0cbbc6e3..524e77fc3 100644 --- a/cake/tests/cases/libs/test_manager.test.php +++ b/cake/tests/cases/libs/test_manager.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -30,8 +29,7 @@ class TestTestManager extends TestManager { /** * TestManagerTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class TestManagerTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/validation.test.php b/cake/tests/cases/libs/validation.test.php index 002902a9d..2766823b9 100644 --- a/cake/tests/cases/libs/validation.test.php +++ b/cake/tests/cases/libs/validation.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'Validation'); /** * CustomValidator class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class CustomValidator { @@ -88,8 +86,7 @@ class TestDeValidation { /** * Test Case for Validation Class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class ValidationTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/helper.test.php b/cake/tests/cases/libs/view/helper.test.php index 025dffae1..44b38f903 100644 --- a/cake/tests/cases/libs/view/helper.test.php +++ b/cake/tests/cases/libs/view/helper.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', array('View', 'Helper', 'Router')); /** * HelperTestPost class * - * @package cake - * @subpackage cake.tests.cases.libs.view + * @package cake.tests.cases.libs.view */ class HelperTestPost extends Model { @@ -66,8 +64,7 @@ class HelperTestPost extends Model { /** * HelperTestComment class * - * @package cake - * @subpackage cake.tests.cases.libs.view + * @package cake.tests.cases.libs.view */ class HelperTestComment extends Model { @@ -101,8 +98,7 @@ class HelperTestComment extends Model { /** * HelperTestTag class * - * @package cake - * @subpackage cake.tests.cases.libs.view + * @package cake.tests.cases.libs.view */ class HelperTestTag extends Model { @@ -134,8 +130,7 @@ class HelperTestTag extends Model { /** * HelperTestPostsTag class * - * @package cake - * @subpackage cake.tests.cases.libs.view + * @package cake.tests.cases.libs.view */ class HelperTestPostsTag extends Model { @@ -187,8 +182,7 @@ class TestHelper extends Helper { /** * Html5TestHelper class * - * @package cake - * @subpackage cake.tests.cases.libs.view + * @package cake.tests.cases.libs.view */ class Html5TestHelper extends TestHelper { @@ -217,8 +211,7 @@ class Html5TestHelper extends TestHelper { /** * HelperTest class * - * @package cake - * @subpackage cake.tests.cases.libs.view + * @package cake.tests.cases.libs.view */ class HelperTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/helper_collection.test.php b/cake/tests/cases/libs/view/helper_collection.test.php index d3b7698fe..e87d67a2b 100644 --- a/cake/tests/cases/libs/view/helper_collection.test.php +++ b/cake/tests/cases/libs/view/helper_collection.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/cake/tests/cases/libs/view/helpers/cache.test.php index 95d8e9a01..cc08e4d83 100644 --- a/cake/tests/cases/libs/view/helpers/cache.test.php +++ b/cake/tests/cases/libs/view/helpers/cache.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Helper', 'Cache'); /** * CacheTestController class * - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class CacheTestController extends Controller { @@ -55,8 +53,7 @@ class CacheTestController extends Controller { /** * CacheHelperTest class * - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class CacheHelperTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 8c01f95eb..dccaf21c0 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,7 +24,7 @@ App::import('Helper', 'Form'); * ContactTestController class * * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class ContactTestController extends Controller { @@ -50,7 +49,7 @@ class ContactTestController extends Controller { * Contact class * * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class Contact extends CakeTestModel { @@ -147,7 +146,7 @@ class Contact extends CakeTestModel { * ContactTagsContact class * * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class ContactTagsContact extends CakeTestModel { @@ -195,7 +194,7 @@ class ContactTagsContact extends CakeTestModel { * ContactNonStandardPk class * * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class ContactNonStandardPk extends Contact { @@ -233,7 +232,7 @@ class ContactNonStandardPk extends Contact { * ContactTag class * * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class ContactTag extends Model { @@ -263,7 +262,7 @@ class ContactTag extends Model { * UserForm class * * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class UserForm extends CakeTestModel { @@ -323,7 +322,7 @@ class UserForm extends CakeTestModel { * OpenidUrl class * * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class OpenidUrl extends CakeTestModel { @@ -399,7 +398,7 @@ class OpenidUrl extends CakeTestModel { * ValidateUser class * * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class ValidateUser extends CakeTestModel { @@ -468,7 +467,7 @@ class ValidateUser extends CakeTestModel { * ValidateProfile class * * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class ValidateProfile extends CakeTestModel { @@ -548,7 +547,7 @@ class ValidateProfile extends CakeTestModel { * ValidateItem class * * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class ValidateItem extends CakeTestModel { @@ -617,7 +616,7 @@ class ValidateItem extends CakeTestModel { * TestMail class * * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class TestMail extends CakeTestModel { @@ -650,7 +649,7 @@ class TestMail extends CakeTestModel { * FormHelperTest class * * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class FormHelperTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index 2defe93ab..142fe91b5 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ if (!defined('FULL_BASE_URL')) { /** * TheHtmlTestController class * - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class TheHtmlTestController extends Controller { @@ -52,8 +50,7 @@ class TheHtmlTestController extends Controller { /** * HtmlHelperTest class * - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class HtmlHelperTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/helpers/jquery_engine.test.php b/cake/tests/cases/libs/view/helpers/jquery_engine.test.php index 87c2b8b2b..868581ff6 100644 --- a/cake/tests/cases/libs/view/helpers/jquery_engine.test.php +++ b/cake/tests/cases/libs/view/helpers/jquery_engine.test.php @@ -15,7 +15,7 @@ * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project * @package cake.tests - * @subpackage cake.tests.cases.views.helpers + * @package cake.tests.cases.views.helpers * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Helper', array('Html', 'Js', 'JqueryEngine')); diff --git a/cake/tests/cases/libs/view/helpers/js.test.php b/cake/tests/cases/libs/view/helpers/js.test.php index 1fd1602a7..8926ab94e 100644 --- a/cake/tests/cases/libs/view/helpers/js.test.php +++ b/cake/tests/cases/libs/view/helpers/js.test.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -64,8 +63,7 @@ class OptionEngineHelper extends JsBaseEngineHelper { /** * JsHelper TestCase. * - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class JsHelperTest extends CakeTestCase { /** diff --git a/cake/tests/cases/libs/view/helpers/mootools_engine.test.php b/cake/tests/cases/libs/view/helpers/mootools_engine.test.php index 53af75a80..1b44d4497 100644 --- a/cake/tests/cases/libs/view/helpers/mootools_engine.test.php +++ b/cake/tests/cases/libs/view/helpers/mootools_engine.test.php @@ -17,7 +17,7 @@ * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project * @package cake.tests - * @subpackage cake.tests.cases.views.helpers + * @package cake.tests.cases.views.helpers * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Helper', array('Html', 'Js', 'MootoolsEngine')); diff --git a/cake/tests/cases/libs/view/helpers/number.test.php b/cake/tests/cases/libs/view/helpers/number.test.php index 30022d2cd..99857df99 100644 --- a/cake/tests/cases/libs/view/helpers/number.test.php +++ b/cake/tests/cases/libs/view/helpers/number.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('View', 'View'); /** * NumberHelperTest class * - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class NumberHelperTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 2d0bda4a9..a1f01ea1e 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ if (!defined('FULL_BASE_URL')) { /** * PaginatorHelperTest class * - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class PaginatorHelperTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php b/cake/tests/cases/libs/view/helpers/prototype_engine.test.php index 395b25cd7..86b8d3a73 100644 --- a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php +++ b/cake/tests/cases/libs/view/helpers/prototype_engine.test.php @@ -15,7 +15,7 @@ * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project * @package cake.tests - * @subpackage cake.tests.cases.views.helpers + * @package cake.tests.cases.views.helpers * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Helper', array('Html', 'Js', 'PrototypeEngine')); diff --git a/cake/tests/cases/libs/view/helpers/rss.test.php b/cake/tests/cases/libs/view/helpers/rss.test.php index f836d890f..93c344d67 100644 --- a/cake/tests/cases/libs/view/helpers/rss.test.php +++ b/cake/tests/cases/libs/view/helpers/rss.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Helper', array('Rss', 'Time')); /** * RssHelperTest class * - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class RssHelperTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/helpers/session.test.php b/cake/tests/cases/libs/view/helpers/session.test.php index c61421bd1..cf5169243 100644 --- a/cake/tests/cases/libs/view/helpers/session.test.php +++ b/cake/tests/cases/libs/view/helpers/session.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Helper', array('Session')); /** * SessionHelperTest class * - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class SessionHelperTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/helpers/text.test.php b/cake/tests/cases/libs/view/helpers/text.test.php index cdb5dcecb..03ad9ee2f 100644 --- a/cake/tests/cases/libs/view/helpers/text.test.php +++ b/cake/tests/cases/libs/view/helpers/text.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Helper', 'Text'); /** * TextHelperTest class * - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class TextHelperTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index 668467296..67481f5a4 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ App::import('Core', 'View'); /** * TimeHelperTest class * - * @package cake - * @subpackage cake.tests.cases.libs.view.helpers + * @package cake.tests.cases.libs.view.helpers */ class TimeHelperTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/media.test.php b/cake/tests/cases/libs/view/media.test.php index 39b9d190d..115f74505 100644 --- a/cake/tests/cases/libs/view/media.test.php +++ b/cake/tests/cases/libs/view/media.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', array('Media', 'Controller', 'CakeResponse')); /** * MediaViewTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class MediaViewTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/theme.test.php b/cake/tests/cases/libs/view/theme.test.php index 314d38ba7..dc03b6663 100644 --- a/cake/tests/cases/libs/view/theme.test.php +++ b/cake/tests/cases/libs/view/theme.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ App::import('Core', 'Controller'); /** * ThemePostsController class * - * @package cake - * @subpackage cake.tests.cases.libs.view + * @package cake.tests.cases.libs.view */ class ThemePostsController extends Controller { @@ -57,8 +55,7 @@ class ThemePostsController extends Controller { /** * TestThemeView class * - * @package cake - * @subpackage cake.tests.cases.libs.view + * @package cake.tests.cases.libs.view */ class TestThemeView extends ThemeView { @@ -101,8 +98,7 @@ class TestThemeView extends ThemeView { /** * ThemeViewTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class ThemeViewTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index 30ff72866..70ef8a6ca 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ App::import('Core', array('ErrorHandler')); /** * ViewPostsController class * - * @package cake - * @subpackage cake.tests.cases.libs.view + * @package cake.tests.cases.libs.view */ class ViewPostsController extends Controller { @@ -74,8 +72,7 @@ class ViewPostsController extends Controller { /** * TestView class * - * @package cake - * @subpackage cake.tests.cases.libs.view + * @package cake.tests.cases.libs.view */ class TestView extends View { @@ -139,8 +136,7 @@ class TestView extends View { /** * TestAfterHelper class * - * @package cake - * @subpackage cake.tests.cases.libs.view + * @package cake.tests.cases.libs.view */ class TestAfterHelper extends Helper { @@ -176,8 +172,7 @@ class TestAfterHelper extends Helper { /** * ViewTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class ViewTest extends CakeTestCase { diff --git a/cake/tests/cases/libs/xml.test.php b/cake/tests/cases/libs/xml.test.php index 666a4f45d..169c38933 100644 --- a/cake/tests/cases/libs/xml.test.php +++ b/cake/tests/cases/libs/xml.test.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ App::import('Core', 'Xml'); /** * Article class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class XmlArticle extends CakeTestModel { @@ -50,8 +48,7 @@ class XmlArticle extends CakeTestModel { /** * User class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class XmlUser extends CakeTestModel { @@ -73,8 +70,7 @@ class XmlUser extends CakeTestModel { /** * XmlTest class * - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs */ class XmlTest extends CakeTestCase { diff --git a/cake/tests/fixtures/account_fixture.php b/cake/tests/fixtures/account_fixture.php index f4f948dfa..756d92355 100644 --- a/cake/tests/fixtures/account_fixture.php +++ b/cake/tests/fixtures/account_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AccountFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/aco_action_fixture.php b/cake/tests/fixtures/aco_action_fixture.php index e95de48e8..93fc08664 100644 --- a/cake/tests/fixtures/aco_action_fixture.php +++ b/cake/tests/fixtures/aco_action_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AcoActionFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/aco_fixture.php b/cake/tests/fixtures/aco_fixture.php index be296aaf8..77c625781 100644 --- a/cake/tests/fixtures/aco_fixture.php +++ b/cake/tests/fixtures/aco_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AcoFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/aco_two_fixture.php b/cake/tests/fixtures/aco_two_fixture.php index d277beea1..a45c2dc6e 100644 --- a/cake/tests/fixtures/aco_two_fixture.php +++ b/cake/tests/fixtures/aco_two_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AcoTwoFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/ad_fixture.php b/cake/tests/fixtures/ad_fixture.php index c6f955da4..56989b072 100644 --- a/cake/tests/fixtures/ad_fixture.php +++ b/cake/tests/fixtures/ad_fixture.php @@ -13,8 +13,7 @@ * * @copyright CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * @link http://www.cakephp.org - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ /** * AdFixture class * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AdFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/advertisement_fixture.php b/cake/tests/fixtures/advertisement_fixture.php index 8c1e8b629..32c7bca5e 100644 --- a/cake/tests/fixtures/advertisement_fixture.php +++ b/cake/tests/fixtures/advertisement_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AdvertisementFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/after_tree_fixture.php b/cake/tests/fixtures/after_tree_fixture.php index 098863888..1c5fa8e9c 100644 --- a/cake/tests/fixtures/after_tree_fixture.php +++ b/cake/tests/fixtures/after_tree_fixture.php @@ -13,8 +13,7 @@ * * @copyright CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * @link http://www.cakephp.org - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ /** * AdFixture class * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AfterTreeFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/another_article_fixture.php b/cake/tests/fixtures/another_article_fixture.php index d0807c788..a62287a06 100644 --- a/cake/tests/fixtures/another_article_fixture.php +++ b/cake/tests/fixtures/another_article_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AnotherArticleFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/apple_fixture.php b/cake/tests/fixtures/apple_fixture.php index 0de5f3bea..e0e9d3e88 100644 --- a/cake/tests/fixtures/apple_fixture.php +++ b/cake/tests/fixtures/apple_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AppleFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/aro_fixture.php b/cake/tests/fixtures/aro_fixture.php index f224dfc97..f0f5adceb 100644 --- a/cake/tests/fixtures/aro_fixture.php +++ b/cake/tests/fixtures/aro_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AroFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/aro_two_fixture.php b/cake/tests/fixtures/aro_two_fixture.php index 86b774720..409be3489 100644 --- a/cake/tests/fixtures/aro_two_fixture.php +++ b/cake/tests/fixtures/aro_two_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AroTwoFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/aros_aco_fixture.php b/cake/tests/fixtures/aros_aco_fixture.php index 6c204fc49..4265bf011 100644 --- a/cake/tests/fixtures/aros_aco_fixture.php +++ b/cake/tests/fixtures/aros_aco_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ArosAcoFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/aros_aco_two_fixture.php b/cake/tests/fixtures/aros_aco_two_fixture.php index 9c3251d64..e62e48306 100644 --- a/cake/tests/fixtures/aros_aco_two_fixture.php +++ b/cake/tests/fixtures/aros_aco_two_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ArosAcoTwoFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/article_featured_fixture.php b/cake/tests/fixtures/article_featured_fixture.php index 64c4bc38c..062813621 100644 --- a/cake/tests/fixtures/article_featured_fixture.php +++ b/cake/tests/fixtures/article_featured_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ArticleFeaturedFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/article_featureds_tags_fixture.php b/cake/tests/fixtures/article_featureds_tags_fixture.php index e84b863d5..60c8c7096 100644 --- a/cake/tests/fixtures/article_featureds_tags_fixture.php +++ b/cake/tests/fixtures/article_featureds_tags_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ArticleFeaturedsTagsFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/article_fixture.php b/cake/tests/fixtures/article_fixture.php index b6f21e7b3..41b256da1 100644 --- a/cake/tests/fixtures/article_fixture.php +++ b/cake/tests/fixtures/article_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ArticleFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/articles_tag_fixture.php b/cake/tests/fixtures/articles_tag_fixture.php index 1091901a6..c475d87a4 100644 --- a/cake/tests/fixtures/articles_tag_fixture.php +++ b/cake/tests/fixtures/articles_tag_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ArticlesTagFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/assert_tags_test_case.php b/cake/tests/fixtures/assert_tags_test_case.php index 27cc08d19..1cef87aea 100644 --- a/cake/tests/fixtures/assert_tags_test_case.php +++ b/cake/tests/fixtures/assert_tags_test_case.php @@ -5,8 +5,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); /** * This class helpes in indirectly testing the functionaliteies of CakeTestCase::assertTags * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AssertTagsTestCase extends CakeTestCase { diff --git a/cake/tests/fixtures/attachment_fixture.php b/cake/tests/fixtures/attachment_fixture.php index d43defa4f..748c10d78 100644 --- a/cake/tests/fixtures/attachment_fixture.php +++ b/cake/tests/fixtures/attachment_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AttachmentFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/auth_user_custom_field_fixture.php b/cake/tests/fixtures/auth_user_custom_field_fixture.php index fb727e6a7..8c82b6717 100644 --- a/cake/tests/fixtures/auth_user_custom_field_fixture.php +++ b/cake/tests/fixtures/auth_user_custom_field_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.1.8013 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AuthUserCustomFieldFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/auth_user_fixture.php b/cake/tests/fixtures/auth_user_fixture.php index 2613b3d64..5efc6be2e 100644 --- a/cake/tests/fixtures/auth_user_fixture.php +++ b/cake/tests/fixtures/auth_user_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AuthUserFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/author_fixture.php b/cake/tests/fixtures/author_fixture.php index 2f9381621..8f705f4fe 100644 --- a/cake/tests/fixtures/author_fixture.php +++ b/cake/tests/fixtures/author_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class AuthorFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/bake_article_fixture.php b/cake/tests/fixtures/bake_article_fixture.php index 304bd6b3c..8543ee6ba 100644 --- a/cake/tests/fixtures/bake_article_fixture.php +++ b/cake/tests/fixtures/bake_article_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class BakeArticleFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/bake_articles_bake_tag_fixture.php b/cake/tests/fixtures/bake_articles_bake_tag_fixture.php index d1f6ef5d8..d046718b3 100644 --- a/cake/tests/fixtures/bake_articles_bake_tag_fixture.php +++ b/cake/tests/fixtures/bake_articles_bake_tag_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class BakeArticlesBakeTagFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/bake_comment_fixture.php b/cake/tests/fixtures/bake_comment_fixture.php index 8de6696be..b75d0821b 100644 --- a/cake/tests/fixtures/bake_comment_fixture.php +++ b/cake/tests/fixtures/bake_comment_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * BakeCommentFixture fixture for testing bake * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class BakeCommentFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/bake_tag_fixture.php b/cake/tests/fixtures/bake_tag_fixture.php index e5057385e..74dfa473b 100644 --- a/cake/tests/fixtures/bake_tag_fixture.php +++ b/cake/tests/fixtures/bake_tag_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class BakeTagFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/basket_fixture.php b/cake/tests/fixtures/basket_fixture.php index 7ad9f8d0d..3984c65b1 100644 --- a/cake/tests/fixtures/basket_fixture.php +++ b/cake/tests/fixtures/basket_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class BasketFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/bid_fixture.php b/cake/tests/fixtures/bid_fixture.php index dd1b4c130..df915dc71 100644 --- a/cake/tests/fixtures/bid_fixture.php +++ b/cake/tests/fixtures/bid_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class BidFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/binary_test_fixture.php b/cake/tests/fixtures/binary_test_fixture.php index f1cd03351..868ee4c5c 100644 --- a/cake/tests/fixtures/binary_test_fixture.php +++ b/cake/tests/fixtures/binary_test_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6700 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class BinaryTestFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/book_fixture.php b/cake/tests/fixtures/book_fixture.php index 83e1b6f09..bf85000af 100644 --- a/cake/tests/fixtures/book_fixture.php +++ b/cake/tests/fixtures/book_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.7198 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class BookFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/cache_test_model_fixture.php b/cake/tests/fixtures/cache_test_model_fixture.php index ace714d5b..84b1a64b1 100644 --- a/cake/tests/fixtures/cache_test_model_fixture.php +++ b/cake/tests/fixtures/cache_test_model_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class CacheTestModelFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/callback_fixture.php b/cake/tests/fixtures/callback_fixture.php index 6d6103ca0..f28c6277f 100644 --- a/cake/tests/fixtures/callback_fixture.php +++ b/cake/tests/fixtures/callback_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class CallbackFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/campaign_fixture.php b/cake/tests/fixtures/campaign_fixture.php index 1d4fb7edb..ec0411b76 100644 --- a/cake/tests/fixtures/campaign_fixture.php +++ b/cake/tests/fixtures/campaign_fixture.php @@ -13,8 +13,7 @@ * * @copyright CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * @link http://www.cakephp.org - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ /** * CampaignFixture class * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class CampaignFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/category_fixture.php b/cake/tests/fixtures/category_fixture.php index 419699773..7ea0fba2d 100644 --- a/cake/tests/fixtures/category_fixture.php +++ b/cake/tests/fixtures/category_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class CategoryFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/category_thread_fixture.php b/cake/tests/fixtures/category_thread_fixture.php index 65b840cbc..92563dd7b 100644 --- a/cake/tests/fixtures/category_thread_fixture.php +++ b/cake/tests/fixtures/category_thread_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class CategoryThreadFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/cd_fixture.php b/cake/tests/fixtures/cd_fixture.php index 59b4952cf..c2e668c0a 100644 --- a/cake/tests/fixtures/cd_fixture.php +++ b/cake/tests/fixtures/cd_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.7198 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class CdFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/comment_fixture.php b/cake/tests/fixtures/comment_fixture.php index 559c78e00..2f5cfaa26 100644 --- a/cake/tests/fixtures/comment_fixture.php +++ b/cake/tests/fixtures/comment_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class CommentFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/content_account_fixture.php b/cake/tests/fixtures/content_account_fixture.php index b765fc403..4cf803a22 100644 --- a/cake/tests/fixtures/content_account_fixture.php +++ b/cake/tests/fixtures/content_account_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ContentAccountFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/content_fixture.php b/cake/tests/fixtures/content_fixture.php index a7e9eb5ca..067410fbf 100644 --- a/cake/tests/fixtures/content_fixture.php +++ b/cake/tests/fixtures/content_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ContentFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/counter_cache_post_fixture.php b/cake/tests/fixtures/counter_cache_post_fixture.php index 9aa3f2ce1..ea7ec7b9b 100644 --- a/cake/tests/fixtures/counter_cache_post_fixture.php +++ b/cake/tests/fixtures/counter_cache_post_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class CounterCachePostFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php b/cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php index efa9c553c..cdb05f0da 100644 --- a/cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php +++ b/cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class CounterCachePostNonstandardPrimaryKeyFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/counter_cache_user_fixture.php b/cake/tests/fixtures/counter_cache_user_fixture.php index 9ebc2e3ac..4d47c33cd 100644 --- a/cake/tests/fixtures/counter_cache_user_fixture.php +++ b/cake/tests/fixtures/counter_cache_user_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class CounterCacheUserFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php b/cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php index 3134f4650..3fe938bc6 100644 --- a/cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php +++ b/cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class CounterCacheUserNonstandardPrimaryKeyFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/data_test_fixture.php b/cake/tests/fixtures/data_test_fixture.php index 43c4fd7d3..273777c2f 100644 --- a/cake/tests/fixtures/data_test_fixture.php +++ b/cake/tests/fixtures/data_test_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6700 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class DataTestFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/datatype_fixture.php b/cake/tests/fixtures/datatype_fixture.php index 9bfaad3d7..39055a018 100644 --- a/cake/tests/fixtures/datatype_fixture.php +++ b/cake/tests/fixtures/datatype_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.7026 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class DatatypeFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/dependency_fixture.php b/cake/tests/fixtures/dependency_fixture.php index 5514e696e..d9765317a 100644 --- a/cake/tests/fixtures/dependency_fixture.php +++ b/cake/tests/fixtures/dependency_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6879//Correct version number as needed** * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for file. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6879//Correct version number as needed** */ class DependencyFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/device_fixture.php b/cake/tests/fixtures/device_fixture.php index c927feeda..8371cbe21 100644 --- a/cake/tests/fixtures/device_fixture.php +++ b/cake/tests/fixtures/device_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class DeviceFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/device_type_category_fixture.php b/cake/tests/fixtures/device_type_category_fixture.php index 6750ac7ed..7feb7b97c 100644 --- a/cake/tests/fixtures/device_type_category_fixture.php +++ b/cake/tests/fixtures/device_type_category_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class DeviceTypeCategoryFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/device_type_fixture.php b/cake/tests/fixtures/device_type_fixture.php index ecbdb2091..ddd82adc1 100644 --- a/cake/tests/fixtures/device_type_fixture.php +++ b/cake/tests/fixtures/device_type_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class DeviceTypeFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/document_directory_fixture.php b/cake/tests/fixtures/document_directory_fixture.php index 485cdeca4..732eae1f2 100644 --- a/cake/tests/fixtures/document_directory_fixture.php +++ b/cake/tests/fixtures/document_directory_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class DocumentDirectoryFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/document_fixture.php b/cake/tests/fixtures/document_fixture.php index 5d9f438bf..93c1ec4ae 100644 --- a/cake/tests/fixtures/document_fixture.php +++ b/cake/tests/fixtures/document_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class DocumentFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/exterior_type_category_fixture.php b/cake/tests/fixtures/exterior_type_category_fixture.php index f7b609ed7..cbc27668c 100644 --- a/cake/tests/fixtures/exterior_type_category_fixture.php +++ b/cake/tests/fixtures/exterior_type_category_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ExteriorTypeCategoryFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/feature_set_fixture.php b/cake/tests/fixtures/feature_set_fixture.php index 3e26310ff..a42084973 100644 --- a/cake/tests/fixtures/feature_set_fixture.php +++ b/cake/tests/fixtures/feature_set_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class FeatureSetFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/featured_fixture.php b/cake/tests/fixtures/featured_fixture.php index 4777e2d36..1070e2732 100644 --- a/cake/tests/fixtures/featured_fixture.php +++ b/cake/tests/fixtures/featured_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class FeaturedFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/film_file_fixture.php b/cake/tests/fixtures/film_file_fixture.php index fa9fe736b..9a07df3cd 100644 --- a/cake/tests/fixtures/film_file_fixture.php +++ b/cake/tests/fixtures/film_file_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class FilmFileFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/fixturized_test_case.php b/cake/tests/fixtures/fixturized_test_case.php index ad2486784..810a2089f 100644 --- a/cake/tests/fixtures/fixturized_test_case.php +++ b/cake/tests/fixtures/fixturized_test_case.php @@ -5,8 +5,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); /** * This class helps in testing the life-cycle of fixtures inside a CakeTestCase * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class FixturizedTestCase extends CakeTestCase { diff --git a/cake/tests/fixtures/flag_tree_fixture.php b/cake/tests/fixtures/flag_tree_fixture.php index 31c39e1a6..229ad81eb 100644 --- a/cake/tests/fixtures/flag_tree_fixture.php +++ b/cake/tests/fixtures/flag_tree_fixture.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.5331 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ * * Like Number Tree, but uses a flag for testing scope parameters * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class FlagTreeFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/fruit_fixture.php b/cake/tests/fixtures/fruit_fixture.php index 484b99478..abd9eeaa4 100644 --- a/cake/tests/fixtures/fruit_fixture.php +++ b/cake/tests/fixtures/fruit_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.7953 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class FruitFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/fruits_uuid_tag_fixture.php b/cake/tests/fixtures/fruits_uuid_tag_fixture.php index 8d7cff938..afa328b38 100644 --- a/cake/tests/fixtures/fruits_uuid_tag_fixture.php +++ b/cake/tests/fixtures/fruits_uuid_tag_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.7953 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class FruitsUuidTagFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/group_update_all_fixture.php b/cake/tests/fixtures/group_update_all_fixture.php index e1dd56bcc..ebd320b99 100644 --- a/cake/tests/fixtures/group_update_all_fixture.php +++ b/cake/tests/fixtures/group_update_all_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class GroupUpdateAllFixture extends CakeTestFixture { public $name = 'GroupUpdateAll'; diff --git a/cake/tests/fixtures/home_fixture.php b/cake/tests/fixtures/home_fixture.php index e3988bcc4..2f90ea64a 100644 --- a/cake/tests/fixtures/home_fixture.php +++ b/cake/tests/fixtures/home_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class HomeFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/image_fixture.php b/cake/tests/fixtures/image_fixture.php index 369b877b9..1eaaae118 100644 --- a/cake/tests/fixtures/image_fixture.php +++ b/cake/tests/fixtures/image_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ImageFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/item_fixture.php b/cake/tests/fixtures/item_fixture.php index fdca77fcb..8aa2487a1 100644 --- a/cake/tests/fixtures/item_fixture.php +++ b/cake/tests/fixtures/item_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ItemFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/items_portfolio_fixture.php b/cake/tests/fixtures/items_portfolio_fixture.php index 88029e048..fd128a1eb 100644 --- a/cake/tests/fixtures/items_portfolio_fixture.php +++ b/cake/tests/fixtures/items_portfolio_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ItemsPortfolioFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/join_a_b_fixture.php b/cake/tests/fixtures/join_a_b_fixture.php index f9d9776a3..d979f30c4 100644 --- a/cake/tests/fixtures/join_a_b_fixture.php +++ b/cake/tests/fixtures/join_a_b_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6317 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class JoinABFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/join_a_c_fixture.php b/cake/tests/fixtures/join_a_c_fixture.php index b8c9786ca..f66fa499f 100644 --- a/cake/tests/fixtures/join_a_c_fixture.php +++ b/cake/tests/fixtures/join_a_c_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6317 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class JoinACFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/join_a_fixture.php b/cake/tests/fixtures/join_a_fixture.php index 0910b132d..891697321 100644 --- a/cake/tests/fixtures/join_a_fixture.php +++ b/cake/tests/fixtures/join_a_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6317 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class JoinAFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/join_b_fixture.php b/cake/tests/fixtures/join_b_fixture.php index e9f5a9019..a636e7243 100644 --- a/cake/tests/fixtures/join_b_fixture.php +++ b/cake/tests/fixtures/join_b_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6317 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class JoinBFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/join_c_fixture.php b/cake/tests/fixtures/join_c_fixture.php index c50a606e8..d858a5e11 100644 --- a/cake/tests/fixtures/join_c_fixture.php +++ b/cake/tests/fixtures/join_c_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6317 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class JoinCFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/join_thing_fixture.php b/cake/tests/fixtures/join_thing_fixture.php index 75c009f28..13b8dc8f6 100644 --- a/cake/tests/fixtures/join_thing_fixture.php +++ b/cake/tests/fixtures/join_thing_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class JoinThingFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/message_fixture.php b/cake/tests/fixtures/message_fixture.php index 0c62b85f9..e491f031f 100644 --- a/cake/tests/fixtures/message_fixture.php +++ b/cake/tests/fixtures/message_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class MessageFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/my_categories_my_products_fixture.php b/cake/tests/fixtures/my_categories_my_products_fixture.php index a20ad3daa..d33fafa86 100644 --- a/cake/tests/fixtures/my_categories_my_products_fixture.php +++ b/cake/tests/fixtures/my_categories_my_products_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class MyCategoriesMyProductsFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/my_categories_my_users_fixture.php b/cake/tests/fixtures/my_categories_my_users_fixture.php index 0366794dd..c6c557e0f 100644 --- a/cake/tests/fixtures/my_categories_my_users_fixture.php +++ b/cake/tests/fixtures/my_categories_my_users_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class MyCategoriesMyUsersFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/my_category_fixture.php b/cake/tests/fixtures/my_category_fixture.php index ba1225a1c..954a2d429 100644 --- a/cake/tests/fixtures/my_category_fixture.php +++ b/cake/tests/fixtures/my_category_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class MyCategoryFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/my_product_fixture.php b/cake/tests/fixtures/my_product_fixture.php index e934e4447..424c820c9 100644 --- a/cake/tests/fixtures/my_product_fixture.php +++ b/cake/tests/fixtures/my_product_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class MyProductFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/my_user_fixture.php b/cake/tests/fixtures/my_user_fixture.php index fb2d0c236..09922a594 100644 --- a/cake/tests/fixtures/my_user_fixture.php +++ b/cake/tests/fixtures/my_user_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class MyUserFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/node_fixture.php b/cake/tests/fixtures/node_fixture.php index e5f88c49d..3e527eb0e 100644 --- a/cake/tests/fixtures/node_fixture.php +++ b/cake/tests/fixtures/node_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6879 //Correct version number as needed** * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for file. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6879 //Correct version number as needed** */ class NodeFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/number_tree_fixture.php b/cake/tests/fixtures/number_tree_fixture.php index 80ce2970e..84ea86fce 100644 --- a/cake/tests/fixtures/number_tree_fixture.php +++ b/cake/tests/fixtures/number_tree_fixture.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.5331 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ * * Generates a tree of data for use testing the tree behavior * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class NumberTreeFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/number_tree_two_fixture.php b/cake/tests/fixtures/number_tree_two_fixture.php index 20f154844..2414acb60 100644 --- a/cake/tests/fixtures/number_tree_two_fixture.php +++ b/cake/tests/fixtures/number_tree_two_fixture.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.5331 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,8 +24,7 @@ * * Generates a tree of data for use testing the tree behavior * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class NumberTreeTwoFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/numeric_article_fixture.php b/cake/tests/fixtures/numeric_article_fixture.php index dc5b3b45f..06f86e289 100644 --- a/cake/tests/fixtures/numeric_article_fixture.php +++ b/cake/tests/fixtures/numeric_article_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class NumericArticleFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/overall_favorite_fixture.php b/cake/tests/fixtures/overall_favorite_fixture.php index ddb555496..fb46f74d1 100644 --- a/cake/tests/fixtures/overall_favorite_fixture.php +++ b/cake/tests/fixtures/overall_favorite_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.7198 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class OverallFavoriteFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/person_fixture.php b/cake/tests/fixtures/person_fixture.php index ae8b9391d..652b1dc31 100644 --- a/cake/tests/fixtures/person_fixture.php +++ b/cake/tests/fixtures/person_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6700 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class PersonFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/portfolio_fixture.php b/cake/tests/fixtures/portfolio_fixture.php index 40a18c7b7..a3c9c3985 100644 --- a/cake/tests/fixtures/portfolio_fixture.php +++ b/cake/tests/fixtures/portfolio_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class PortfolioFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/post_fixture.php b/cake/tests/fixtures/post_fixture.php index 98264bd68..dcc808a60 100644 --- a/cake/tests/fixtures/post_fixture.php +++ b/cake/tests/fixtures/post_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class PostFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/posts_tag_fixture.php b/cake/tests/fixtures/posts_tag_fixture.php index cddf3e4ee..9a1217569 100644 --- a/cake/tests/fixtures/posts_tag_fixture.php +++ b/cake/tests/fixtures/posts_tag_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class PostsTagFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/primary_model_fixture.php b/cake/tests/fixtures/primary_model_fixture.php index 4194f97a7..058489f58 100644 --- a/cake/tests/fixtures/primary_model_fixture.php +++ b/cake/tests/fixtures/primary_model_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class PrimaryModelFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/product_fixture.php b/cake/tests/fixtures/product_fixture.php index 207ae2073..effee768a 100644 --- a/cake/tests/fixtures/product_fixture.php +++ b/cake/tests/fixtures/product_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ProductFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/product_update_all_fixture.php b/cake/tests/fixtures/product_update_all_fixture.php index 6ca5377f9..80d11cb2f 100644 --- a/cake/tests/fixtures/product_update_all_fixture.php +++ b/cake/tests/fixtures/product_update_all_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ProductUpdateAllFixture extends CakeTestFixture { public $name = 'ProductUpdateAll'; diff --git a/cake/tests/fixtures/project_fixture.php b/cake/tests/fixtures/project_fixture.php index d28aa1578..961cf532a 100644 --- a/cake/tests/fixtures/project_fixture.php +++ b/cake/tests/fixtures/project_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ProjectFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/sample_fixture.php b/cake/tests/fixtures/sample_fixture.php index f5e915765..fa150a748 100644 --- a/cake/tests/fixtures/sample_fixture.php +++ b/cake/tests/fixtures/sample_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class SampleFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/secondary_model_fixture.php b/cake/tests/fixtures/secondary_model_fixture.php index c273850d5..0fcf88699 100644 --- a/cake/tests/fixtures/secondary_model_fixture.php +++ b/cake/tests/fixtures/secondary_model_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class SecondaryModelFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/session_fixture.php b/cake/tests/fixtures/session_fixture.php index d517730b1..cbbc89d5c 100644 --- a/cake/tests/fixtures/session_fixture.php +++ b/cake/tests/fixtures/session_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class SessionFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/something_else_fixture.php b/cake/tests/fixtures/something_else_fixture.php index 5b57d72b1..b6d965298 100644 --- a/cake/tests/fixtures/something_else_fixture.php +++ b/cake/tests/fixtures/something_else_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class SomethingElseFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/something_fixture.php b/cake/tests/fixtures/something_fixture.php index c0dfccd6f..356b533ca 100644 --- a/cake/tests/fixtures/something_fixture.php +++ b/cake/tests/fixtures/something_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class SomethingFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/stories_tag_fixture.php b/cake/tests/fixtures/stories_tag_fixture.php index cc2bcf619..4e441b64f 100644 --- a/cake/tests/fixtures/stories_tag_fixture.php +++ b/cake/tests/fixtures/stories_tag_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class StoriesTagFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/story_fixture.php b/cake/tests/fixtures/story_fixture.php index 4604a202f..3a8cdfa6a 100644 --- a/cake/tests/fixtures/story_fixture.php +++ b/cake/tests/fixtures/story_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class StoryFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/syfile_fixture.php b/cake/tests/fixtures/syfile_fixture.php index 59fb672f9..f143adc33 100644 --- a/cake/tests/fixtures/syfile_fixture.php +++ b/cake/tests/fixtures/syfile_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class SyfileFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/tag_fixture.php b/cake/tests/fixtures/tag_fixture.php index a56e4c485..fb792236c 100644 --- a/cake/tests/fixtures/tag_fixture.php +++ b/cake/tests/fixtures/tag_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class TagFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/test_plugin_article_fixture.php b/cake/tests/fixtures/test_plugin_article_fixture.php index af5dfd8ea..79c3c36ff 100644 --- a/cake/tests/fixtures/test_plugin_article_fixture.php +++ b/cake/tests/fixtures/test_plugin_article_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 7660 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class TestPluginArticleFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/test_plugin_comment_fixture.php b/cake/tests/fixtures/test_plugin_comment_fixture.php index 854e098bf..d70038e32 100644 --- a/cake/tests/fixtures/test_plugin_comment_fixture.php +++ b/cake/tests/fixtures/test_plugin_comment_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 7660 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class TestPluginCommentFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/the_paper_monkies_fixture.php b/cake/tests/fixtures/the_paper_monkies_fixture.php index 24060d815..4d64767ce 100644 --- a/cake/tests/fixtures/the_paper_monkies_fixture.php +++ b/cake/tests/fixtures/the_paper_monkies_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ThePaperMonkiesFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/thread_fixture.php b/cake/tests/fixtures/thread_fixture.php index 76bb1d28b..ed24b6b82 100644 --- a/cake/tests/fixtures/thread_fixture.php +++ b/cake/tests/fixtures/thread_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class ThreadFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/translate_article_fixture.php b/cake/tests/fixtures/translate_article_fixture.php index 756153814..d28417539 100644 --- a/cake/tests/fixtures/translate_article_fixture.php +++ b/cake/tests/fixtures/translate_article_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.5669 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class TranslateArticleFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/translate_fixture.php b/cake/tests/fixtures/translate_fixture.php index bc7926a4d..730dfad64 100644 --- a/cake/tests/fixtures/translate_fixture.php +++ b/cake/tests/fixtures/translate_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.5669 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class TranslateFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/translate_table_fixture.php b/cake/tests/fixtures/translate_table_fixture.php index bae466c86..08a0a3d9a 100644 --- a/cake/tests/fixtures/translate_table_fixture.php +++ b/cake/tests/fixtures/translate_table_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.5669 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class TranslateTableFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/translate_with_prefix_fixture.php b/cake/tests/fixtures/translate_with_prefix_fixture.php index 04549b02e..87045605f 100644 --- a/cake/tests/fixtures/translate_with_prefix_fixture.php +++ b/cake/tests/fixtures/translate_with_prefix_fixture.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.5669 * @version $Revision$ * @modifiedby $LastChangedBy$ @@ -26,8 +25,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class TranslateWithPrefixFixture extends CakeTestFixture { /** diff --git a/cake/tests/fixtures/translated_article_fixture.php b/cake/tests/fixtures/translated_article_fixture.php index 978a8b5f3..b5238baae 100644 --- a/cake/tests/fixtures/translated_article_fixture.php +++ b/cake/tests/fixtures/translated_article_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.5669 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class TranslatedArticleFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/translated_item_fixture.php b/cake/tests/fixtures/translated_item_fixture.php index 91a0571eb..95eede406 100644 --- a/cake/tests/fixtures/translated_item_fixture.php +++ b/cake/tests/fixtures/translated_item_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.5669 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class TranslatedItemFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/unconventional_tree_fixture.php b/cake/tests/fixtures/unconventional_tree_fixture.php index 7d1b39838..ea57f6f06 100644 --- a/cake/tests/fixtures/unconventional_tree_fixture.php +++ b/cake/tests/fixtures/unconventional_tree_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.7879 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ * Like Number tree, but doesn't use the default values for lft and rght or parent_id * * @uses CakeTestFixture - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class UnconventionalTreeFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/underscore_field_fixture.php b/cake/tests/fixtures/underscore_field_fixture.php index 3322284b1..1962e403d 100644 --- a/cake/tests/fixtures/underscore_field_fixture.php +++ b/cake/tests/fixtures/underscore_field_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * UnderscoreFieldFixture class * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class UnderscoreFieldFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/user_fixture.php b/cake/tests/fixtures/user_fixture.php index 86683d2e9..2adb7841f 100644 --- a/cake/tests/fixtures/user_fixture.php +++ b/cake/tests/fixtures/user_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class UserFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/uuid_fixture.php b/cake/tests/fixtures/uuid_fixture.php index 559dc810b..50f735ceb 100644 --- a/cake/tests/fixtures/uuid_fixture.php +++ b/cake/tests/fixtures/uuid_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.6700 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class UuidFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/uuid_tag_fixture.php b/cake/tests/fixtures/uuid_tag_fixture.php index a126903e8..94e1ba7bc 100644 --- a/cake/tests/fixtures/uuid_tag_fixture.php +++ b/cake/tests/fixtures/uuid_tag_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.7953 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class UuidTagFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/uuid_tree_fixture.php b/cake/tests/fixtures/uuid_tree_fixture.php index c34bc2c3c..5828533e2 100644 --- a/cake/tests/fixtures/uuid_tree_fixture.php +++ b/cake/tests/fixtures/uuid_tree_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.7984 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ * UuidTreeFixture class * * @uses CakeTestFixture - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class UuidTreeFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/uuiditem_fixture.php b/cake/tests/fixtures/uuiditem_fixture.php index 1e70eb287..5b6e15e8e 100644 --- a/cake/tests/fixtures/uuiditem_fixture.php +++ b/cake/tests/fixtures/uuiditem_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class UuiditemFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/uuiditems_uuidportfolio_fixture.php b/cake/tests/fixtures/uuiditems_uuidportfolio_fixture.php index 94a5a2e49..eeafb752d 100644 --- a/cake/tests/fixtures/uuiditems_uuidportfolio_fixture.php +++ b/cake/tests/fixtures/uuiditems_uuidportfolio_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class UuiditemsUuidportfolioFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php b/cake/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php index c4ae9c768..f8f6baedc 100644 --- a/cake/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php +++ b/cake/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class UuiditemsUuidportfolioNumericidFixture extends CakeTestFixture { diff --git a/cake/tests/fixtures/uuidportfolio_fixture.php b/cake/tests/fixtures/uuidportfolio_fixture.php index fb3745d3b..3c6b86f28 100644 --- a/cake/tests/fixtures/uuidportfolio_fixture.php +++ b/cake/tests/fixtures/uuidportfolio_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Short description for class. * - * @package cake - * @subpackage cake.tests.fixtures + * @package cake.tests.fixtures */ class UuidportfolioFixture extends CakeTestFixture { diff --git a/cake/tests/lib/cake_fixture_manager.php b/cake/tests/lib/cake_fixture_manager.php index 099da5557..2615847ca 100644 --- a/cake/tests/lib/cake_fixture_manager.php +++ b/cake/tests/lib/cake_fixture_manager.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.tests.libs + * @package cake.tests.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index 1a8131679..7581bd6a8 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.libs + * @package cake.tests.libs * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ require_once CAKE_TESTS_LIB . 'cake_test_fixture.php'; /** * CakeTestCase class * - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib */ class CakeTestCase extends PHPUnit_Framework_TestCase { diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index b7676cf5c..ec56d09ec 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.libs + * @package cake.tests.libs * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,8 +22,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); /** * Short description for class. * - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib */ class CakeTestFixture { diff --git a/cake/tests/lib/cake_test_model.php b/cake/tests/lib/cake_test_model.php index 819c3cbe2..a896a50d9 100644 --- a/cake/tests/lib/cake_test_model.php +++ b/cake/tests/lib/cake_test_model.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.libs + * @package cake.tests.libs * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,8 +21,7 @@ require_once LIBS.'model'.DS.'model.php'; /** * Short description for class. * - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib */ class CakeTestModel extends Model { public $useDbConfig = 'test'; diff --git a/cake/tests/lib/cake_test_suite.php b/cake/tests/lib/cake_test_suite.php index c1ad5adb5..f7d7497d5 100644 --- a/cake/tests/lib/cake_test_suite.php +++ b/cake/tests/lib/cake_test_suite.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.tests.libs + * @package cake.tests.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 4642dc2b4..36937ed2c 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/lib/cake_web_test_case.php b/cake/tests/lib/cake_web_test_case.php index 8a98e3525..256e75933 100644 --- a/cake/tests/lib/cake_web_test_case.php +++ b/cake/tests/lib/cake_web_test_case.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,8 +20,7 @@ /** * Simple wrapper for the WebTestCase provided by SimpleTest * - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib */ class CakeWebTestCase extends WebTestCase { } diff --git a/cake/tests/lib/controller_test_case.php b/cake/tests/lib/controller_test_case.php index 91940f928..97e71303e 100644 --- a/cake/tests/lib/controller_test_case.php +++ b/cake/tests/lib/controller_test_case.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.libs + * @package cake.tests.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ App::import('Core', array('Router', 'CakeRequest', 'CakeResponse', 'Helper')); /** * ControllerTestDispatcher class * - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib */ class ControllerTestDispatcher extends Dispatcher { @@ -77,8 +75,7 @@ class ControllerTestDispatcher extends Dispatcher { /** * InterceptContentHelper class * - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib */ class InterceptContentHelper extends Helper { @@ -96,8 +93,7 @@ class InterceptContentHelper extends Helper { /** * ControllerTestCase class * - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib */ class ControllerTestCase extends CakeTestCase { diff --git a/cake/tests/lib/coverage/base_coverage_report.php b/cake/tests/lib/coverage/base_coverage_report.php index d532f06d6..7960a6e75 100644 --- a/cake/tests/lib/coverage/base_coverage_report.php +++ b/cake/tests/lib/coverage/base_coverage_report.php @@ -14,7 +14,6 @@ * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package cake - * @subpackage cake.cake * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/lib/coverage/html_coverage_report.php b/cake/tests/lib/coverage/html_coverage_report.php index ae4fa081c..bdd18e972 100644 --- a/cake/tests/lib/coverage/html_coverage_report.php +++ b/cake/tests/lib/coverage/html_coverage_report.php @@ -13,7 +13,6 @@ * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package cake - * @subpackage cake.cake * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/lib/coverage/text_coverage_report.php b/cake/tests/lib/coverage/text_coverage_report.php index 3450f2b36..66e84d32e 100644 --- a/cake/tests/lib/coverage/text_coverage_report.php +++ b/cake/tests/lib/coverage/text_coverage_report.php @@ -13,7 +13,6 @@ * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package cake - * @subpackage cake.cake * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index f20bf1928..9f4b3d3ec 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.libs.reporter + * @package cake.tests.libs.reporter * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,7 +23,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); * CakeBaseReporter contains common reporting features used in the CakePHP Test suite * * @package cake - * @subpackage cake.tests.lib + * @package cake.tests.lib */ class CakeBaseReporter implements PHPUnit_Framework_TestListener { diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 2b66df509..63153ba9c 100755 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.libs.reporter + * @package cake.tests.libs.reporter * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,7 +25,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); * in an HTML format / context. * * @package cake - * @subpackage cake.tests.lib + * @package cake.tests.lib */ class CakeHtmlReporter extends CakeBaseReporter { diff --git a/cake/tests/lib/reporter/cake_text_reporter.php b/cake/tests/lib/reporter/cake_text_reporter.php index 070855c1b..cf4cea447 100644 --- a/cake/tests/lib/reporter/cake_text_reporter.php +++ b/cake/tests/lib/reporter/cake_text_reporter.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.libs.reporter + * @package cake.tests.libs.reporter * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -26,7 +25,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); * CakeTextReporter contains reporting features used for plain text based output * * @package cake - * @subpackage cake.tests.lib + * @package cake.tests.lib */ class CakeTextReporter extends CakeBaseReporter { diff --git a/cake/tests/lib/templates/footer.php b/cake/tests/lib/templates/footer.php index e9b6c6746..0f6ab6a69 100644 --- a/cake/tests/lib/templates/footer.php +++ b/cake/tests/lib/templates/footer.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/lib/templates/header.php b/cake/tests/lib/templates/header.php index 5f80658c1..df19f02d9 100644 --- a/cake/tests/lib/templates/header.php +++ b/cake/tests/lib/templates/header.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/lib/templates/menu.php b/cake/tests/lib/templates/menu.php index a596ac139..bb81dc7cf 100644 --- a/cake/tests/lib/templates/menu.php +++ b/cake/tests/lib/templates/menu.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/lib/templates/missing_conenction.php b/cake/tests/lib/templates/missing_conenction.php index 37c242507..eb88d1aaa 100644 --- a/cake/tests/lib/templates/missing_conenction.php +++ b/cake/tests/lib/templates/missing_conenction.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.libs + * @package cake.tests.libs * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/lib/templates/phpunit.php b/cake/tests/lib/templates/phpunit.php index 4a865523b..0e525d5ab 100644 --- a/cake/tests/lib/templates/phpunit.php +++ b/cake/tests/lib/templates/phpunit.php @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.libs + * @package cake.tests.libs * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/lib/templates/xdebug.php b/cake/tests/lib/templates/xdebug.php index 5722a91ff..f826509eb 100644 --- a/cake/tests/lib/templates/xdebug.php +++ b/cake/tests/lib/templates/xdebug.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.libs + * @package cake.tests.libs * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 9322db04e..7cb6a3fdd 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -29,8 +28,7 @@ require_once CAKE_TESTS_LIB . 'cake_test_suite.php'; * TestManager is the base class that handles loading and initiating the running * of TestCase and TestSuite classes that the user has selected. * - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib */ class TestManager { /** diff --git a/cake/tests/lib/test_runner.php b/cake/tests/lib/test_runner.php index c2ca7f809..22def2a23 100644 --- a/cake/tests/lib/test_runner.php +++ b/cake/tests/lib/test_runner.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.tests.libs + * @package cake.tests.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -27,8 +26,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); /** * Class to customize loading of test suites from CLI * - * @package cake - * @subpackage cake.cake.tests.lib + * @package cake.tests.lib */ class TestRunner extends PHPUnit_TextUI_Command { diff --git a/cake/tests/test_app/config/acl.ini.php b/cake/tests/test_app/config/acl.ini.php index 3c53bfde1..d2f06fc4d 100644 --- a/cake/tests/test_app/config/acl.ini.php +++ b/cake/tests/test_app/config/acl.ini.php @@ -14,8 +14,7 @@ ; * ; * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) ; * @link http://cakephp.org CakePHP(tm) Project -; * @package cake -; * @subpackage cake.app.config +;; * @package app.config ; * @since CakePHP(tm) v 0.10.0.1076 ; * @license MIT License (http://www.opensource.org/licenses/mit-license.php) ; */ diff --git a/cake/tests/test_app/config/routes.php b/cake/tests/test_app/config/routes.php index 17fdccf25..8d401d581 100644 --- a/cake/tests/test_app/config/routes.php +++ b/cake/tests/test_app/config/routes.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.test_app.config + * @package cake.tests.test_app.config * @since CakePHP v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/console/shells/sample.php b/cake/tests/test_app/console/shells/sample.php index 8994803e8..aa892b1ec 100644 --- a/cake/tests/test_app/console/shells/sample.php +++ b/cake/tests/test_app/console/shells/sample.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.vendors.shells + * @package cake.tests.test_app.vendors.shells * @since CakePHP(tm) v 1.2.0.7871 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/controllers/tests_apps_controller.php b/cake/tests/test_app/controllers/tests_apps_controller.php index f7f2faf9f..24f193b48 100644 --- a/cake/tests/test_app/controllers/tests_apps_controller.php +++ b/cake/tests/test_app/controllers/tests_apps_controller.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers + * @package cake.tests.test_app.plugins.test_plugin.views.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/controllers/tests_apps_posts_controller.php b/cake/tests/test_app/controllers/tests_apps_posts_controller.php index 0b11bd068..af28f42c4 100644 --- a/cake/tests/test_app/controllers/tests_apps_posts_controller.php +++ b/cake/tests/test_app/controllers/tests_apps_posts_controller.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers + * @package cake.tests.test_app.plugins.test_plugin.views.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/libs/cache/test_app_cache.php b/cake/tests/test_app/libs/cache/test_app_cache.php index d138764d3..1a8a47ac0 100644 --- a/cake/tests/test_app/libs/cache/test_app_cache.php +++ b/cake/tests/test_app/libs/cache/test_app_cache.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/libs/library.php b/cake/tests/test_app/libs/library.php index 5047e0868..10fc5f10f 100644 --- a/cake/tests/test_app/libs/library.php +++ b/cake/tests/test_app/libs/library.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/libs/log/test_app_log.php b/cake/tests/test_app/libs/log/test_app_log.php index bd65581dc..129e1b65d 100644 --- a/cake/tests/test_app/libs/log/test_app_log.php +++ b/cake/tests/test_app/libs/log/test_app_log.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/models/behaviors/persister_one_behavior.php b/cake/tests/test_app/models/behaviors/persister_one_behavior.php index eebe0ba5d..8ef3cf6af 100644 --- a/cake/tests/test_app/models/behaviors/persister_one_behavior.php +++ b/cake/tests/test_app/models/behaviors/persister_one_behavior.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.test_app.models + * @package cake.tests.test_app.models * @since CakePHP(tm) v 1.2.0.5669 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ * Behavior to allow for dynamic and atomic manipulation of a Model's associations used for a find call. Most useful for limiting * the amount of associations and data returned. * - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs */ class PersisterOneBehaviorBehavior extends ModelBehavior { } diff --git a/cake/tests/test_app/models/behaviors/persister_two_behavior.php b/cake/tests/test_app/models/behaviors/persister_two_behavior.php index e17180e24..6cbd0483b 100644 --- a/cake/tests/test_app/models/behaviors/persister_two_behavior.php +++ b/cake/tests/test_app/models/behaviors/persister_two_behavior.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.test_app.models + * @package cake.tests.test_app.models * @since CakePHP(tm) v 1.2.0.5669 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,8 +23,7 @@ * Behavior to allow for dynamic and atomic manipulation of a Model's associations used for a find call. Most useful for limiting * the amount of associations and data returned. * - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs */ class PersisterTwoBehaviorBehavior extends ModelBehavior { } diff --git a/cake/tests/test_app/models/comment.php b/cake/tests/test_app/models/comment.php index 9ded58dde..0f0b142d8 100644 --- a/cake/tests/test_app/models/comment.php +++ b/cake/tests/test_app/models/comment.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.cake.libs. + * @package cake.libs. * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/models/persister_one.php b/cake/tests/test_app/models/persister_one.php index a13bc3c65..26e1b1dd6 100644 --- a/cake/tests/test_app/models/persister_one.php +++ b/cake/tests/test_app/models/persister_one.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.test_app.models + * @package cake.tests.test_app.models * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/models/persister_two.php b/cake/tests/test_app/models/persister_two.php index b157e7850..68313cd6e 100644 --- a/cake/tests/test_app/models/persister_two.php +++ b/cake/tests/test_app/models/persister_two.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.tests.test_app.models + * @package cake.tests.test_app.models * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/models/post.php b/cake/tests/test_app/models/post.php index 2155d970d..5a1c15370 100644 --- a/cake/tests/test_app/models/post.php +++ b/cake/tests/test_app/models/post.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.cake.libs. + * @package cake.libs. * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/config/load.php b/cake/tests/test_app/plugins/test_plugin/config/load.php index 709468c0a..07576e051 100644 --- a/cake/tests/test_app/plugins/test_plugin/config/load.php +++ b/cake/tests/test_app/plugins/test_plugin/config/load.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app + * @package cake.tests.test_app * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/config/more.load.php b/cake/tests/test_app/plugins/test_plugin/config/more.load.php index bedf5cff0..f0c9744f8 100644 --- a/cake/tests/test_app/plugins/test_plugin/config/more.load.php +++ b/cake/tests/test_app/plugins/test_plugin/config/more.load.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app + * @package cake.tests.test_app * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/config/schema/schema.php b/cake/tests/test_app/plugins/test_plugin/config/schema/schema.php index fd3a283c8..9f9bd3571 100644 --- a/cake/tests/test_app/plugins/test_plugin/config/schema/schema.php +++ b/cake/tests/test_app/plugins/test_plugin/config/schema/schema.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config.sql + * @package app.config.sql * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/console/shells/example.php b/cake/tests/test_app/plugins/test_plugin/console/shells/example.php index 8380eb901..76e750913 100644 --- a/cake/tests/test_app/plugins/test_plugin/console/shells/example.php +++ b/cake/tests/test_app/plugins/test_plugin/console/shells/example.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.vendors.shells + * @package cake.tests.test_app.plugins.test_plugin.vendors.shells * @since CakePHP(tm) v 1.2.0.7871 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/console/shells/tasks/other_task.php b/cake/tests/test_app/plugins/test_plugin/console/shells/tasks/other_task.php index 4c4dc2823..ca6668b2f 100644 --- a/cake/tests/test_app/plugins/test_plugin/console/shells/tasks/other_task.php +++ b/cake/tests/test_app/plugins/test_plugin/console/shells/tasks/other_task.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.vendors.shells + * @package cake.tests.test_app.plugins.test_plugin.vendors.shells * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/components/other_component.php b/cake/tests/test_app/plugins/test_plugin/controllers/components/other_component.php index 08168bb27..cff9b4a0d 100644 --- a/cake/tests/test_app/plugins/test_plugin/controllers/components/other_component.php +++ b/cake/tests/test_app/plugins/test_plugin/controllers/components/other_component.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers + * @package cake.tests.test_app.plugins.test_plugin.views.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php b/cake/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php index b3bd6f25f..8c478bba6 100644 --- a/cake/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php +++ b/cake/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers + * @package cake.tests.test_app.plugins.test_plugin.views.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php b/cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php index 78e87ce56..c09948394 100644 --- a/cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php +++ b/cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers + * @package cake.tests.test_app.plugins.test_plugin.views.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php b/cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php index 3b2bb344d..28acded03 100644 --- a/cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php +++ b/cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers + * @package cake.tests.test_app.plugins.test_plugin.views.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/test_plugin_controller.php b/cake/tests/test_app/plugins/test_plugin/controllers/test_plugin_controller.php index 87fd60dc7..2ad779059 100644 --- a/cake/tests/test_app/plugins/test_plugin/controllers/test_plugin_controller.php +++ b/cake/tests/test_app/plugins/test_plugin/controllers/test_plugin_controller.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers + * @package cake.tests.test_app.plugins.test_plugin.views.helpers * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/tests_controller.php b/cake/tests/test_app/plugins/test_plugin/controllers/tests_controller.php index ea74c447e..36d67e950 100644 --- a/cake/tests/test_app/plugins/test_plugin/controllers/tests_controller.php +++ b/cake/tests/test_app/plugins/test_plugin/controllers/tests_controller.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers + * @package cake.tests.test_app.plugins.test_plugin.views.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/libs/cache/test_plugin_cache.php b/cake/tests/test_app/plugins/test_plugin/libs/cache/test_plugin_cache.php index 3342755dc..a1afa5d46 100644 --- a/cake/tests/test_app/plugins/test_plugin/libs/cache/test_plugin_cache.php +++ b/cake/tests/test_app/plugins/test_plugin/libs/cache/test_plugin_cache.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/libs/log/test_plugin_log.php b/cake/tests/test_app/plugins/test_plugin/libs/log/test_plugin_log.php index 3ce8c9837..3072ca08e 100644 --- a/cake/tests/test_app/plugins/test_plugin/libs/log/test_plugin_log.php +++ b/cake/tests/test_app/plugins/test_plugin/libs/log/test_plugin_log.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/libs/test_plugin_library.php b/cake/tests/test_app/plugins/test_plugin/libs/test_plugin_library.php index decf3ef66..647e33177 100644 --- a/cake/tests/test_app/plugins/test_plugin/libs/test_plugin_library.php +++ b/cake/tests/test_app/plugins/test_plugin/libs/test_plugin_library.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_one.php b/cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_one.php index 4a54e3554..669ac584c 100644 --- a/cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_one.php +++ b/cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_one.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.test_app.models + * @package cake.tests.test_app.models * @since CakePHP(tm) v 1.2.0.5669 * @version $Revision$ * @modifiedby $LastChangedBy$ @@ -27,8 +26,7 @@ * Behavior to allow for dynamic and atomic manipulation of a Model's associations used for a find call. Most useful for limiting * the amount of associations and data returned. * - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs */ class TestPluginPersisterOneBehavior extends ModelBehavior { } diff --git a/cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_two.php b/cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_two.php index 90ba761e0..162078e51 100644 --- a/cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_two.php +++ b/cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_two.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.tests.test_app.models + * @package cake.tests.test_app.models * @since CakePHP(tm) v 1.2.0.5669 * @version $Revision$ * @modifiedby $LastChangedBy$ @@ -27,8 +26,7 @@ * Behavior to allow for dynamic and atomic manipulation of a Model's associations used for a find call. Most useful for limiting * the amount of associations and data returned. * - * @package cake - * @subpackage cake.cake.console.libs + * @package cake.console.libs */ class TestPluginPersisterTwoBehavior extends ModelBehavior { } diff --git a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php b/cake/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php index 430d5c446..74519a19d 100644 --- a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php +++ b/cake/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.cake.tests.test_app.plugins.test_plugin + * @package cake.tests.test_app.plugins.test_plugin * @since CakePHP v 1.2.0.4487 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_authors.php b/cake/tests/test_app/plugins/test_plugin/models/test_plugin_authors.php index ac9782643..0edd39cf1 100644 --- a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_authors.php +++ b/cake/tests/test_app/plugins/test_plugin/models/test_plugin_authors.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2006-2008, Cake Software Foundation, Inc. * @link http://cakefoundation.org/projects/info/cakephp CakePHP Project - * @package cake - * @subpackage cake.cake.libs. + * @package cake.libs. * @since CakePHP v 1.2.0.7726 * @version $Revision$ * @modifiedby $LastChangedBy$ diff --git a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_comment.php b/cake/tests/test_app/plugins/test_plugin/models/test_plugin_comment.php index 781841fa2..afef031a3 100644 --- a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_comment.php +++ b/cake/tests/test_app/plugins/test_plugin/models/test_plugin_comment.php @@ -15,8 +15,7 @@ * * @copyright Copyright 2006-2008, Cake Software Foundation, Inc. * @link http://cakefoundation.org/projects/info/cakephp CakePHP Project - * @package cake - * @subpackage cake.cake.libs. + * @package cake.libs. * @since CakePHP v 1.2.0.7726 * @version $Revision$ * @modifiedby $LastChangedBy$ diff --git a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_post.php b/cake/tests/test_app/plugins/test_plugin/models/test_plugin_post.php index 0c6090a76..b0441191f 100644 --- a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_post.php +++ b/cake/tests/test_app/plugins/test_plugin/models/test_plugin_post.php @@ -14,8 +14,7 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake - * @subpackage cake.cake.tests.test_app.plugins.test_plugin + * @package cake.tests.test_app.plugins.test_plugin * @since CakePHP v 1.2.0.4487 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php b/cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php index 89b70da0d..f8c2265d5 100644 --- a/cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php +++ b/cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/test_plugin_app_model.php b/cake/tests/test_app/plugins/test_plugin/test_plugin_app_model.php index 5f6162fcc..6dc24ad8b 100644 --- a/cake/tests/test_app/plugins/test_plugin/test_plugin_app_model.php +++ b/cake/tests/test_app/plugins/test_plugin/test_plugin_app_model.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.cases.libs + * @package cake.tests.cases.libs * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php b/cake/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php index 2566444f9..435b67a84 100644 --- a/cake/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php +++ b/cake/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.vendors.sample + * @package cake.tests.test_app.plugins.test_plugin.vendors.sample * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/vendors/welcome.php b/cake/tests/test_app/plugins/test_plugin/vendors/welcome.php index 50dbe616f..41d62cbd0 100644 --- a/cake/tests/test_app/plugins/test_plugin/vendors/welcome.php +++ b/cake/tests/test_app/plugins/test_plugin/vendors/welcome.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.vendors + * @package cake.tests.test_app.plugins.test_plugin.vendors * @since CakePHP(tm) v 1.2.0.7629 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php b/cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php index 07b109f6b..eb70d228c 100644 --- a/cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php +++ b/cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers + * @package cake.tests.test_app.plugins.test_plugin.views.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php b/cake/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php index fee89f004..d92752535 100644 --- a/cake/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php +++ b/cake/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers + * @package cake.tests.test_app.plugins.test_plugin.views.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin_two/console/shells/example.php b/cake/tests/test_app/plugins/test_plugin_two/console/shells/example.php index dea25fd74..290188779 100644 --- a/cake/tests/test_app/plugins/test_plugin_two/console/shells/example.php +++ b/cake/tests/test_app/plugins/test_plugin_two/console/shells/example.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin_two.vendors.shells + * @package cake.tests.test_app.plugins.test_plugin_two.vendors.shells * @since CakePHP(tm) v 1.2.0.7871 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/plugins/test_plugin_two/console/shells/welcome.php b/cake/tests/test_app/plugins/test_plugin_two/console/shells/welcome.php index 7c091ea92..7c7da0c3a 100644 --- a/cake/tests/test_app/plugins/test_plugin_two/console/shells/welcome.php +++ b/cake/tests/test_app/plugins/test_plugin_two/console/shells/welcome.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.plugins.test_plugin_two.vendors.shells + * @package cake.tests.test_app.plugins.test_plugin_two.vendors.shells * @since CakePHP(tm) v 1.2.0.7871 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/vendors/Test/MyTest.php b/cake/tests/test_app/vendors/Test/MyTest.php index 888c9395d..d1a94d55b 100644 --- a/cake/tests/test_app/vendors/Test/MyTest.php +++ b/cake/tests/test_app/vendors/Test/MyTest.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.vendors.somename + * @package cake.tests.test_app.vendors.somename * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/vendors/Test/hello.php b/cake/tests/test_app/vendors/Test/hello.php index e6cd3fbba..7f886aef0 100644 --- a/cake/tests/test_app/vendors/Test/hello.php +++ b/cake/tests/test_app/vendors/Test/hello.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.vendors.Test + * @package cake.tests.test_app.vendors.Test * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/vendors/sample/configure_test_vendor_sample.php b/cake/tests/test_app/vendors/sample/configure_test_vendor_sample.php index 16ba606ba..58e797165 100644 --- a/cake/tests/test_app/vendors/sample/configure_test_vendor_sample.php +++ b/cake/tests/test_app/vendors/sample/configure_test_vendor_sample.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.vendors.sample + * @package cake.tests.test_app.vendors.sample * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/vendors/somename/some.name.php b/cake/tests/test_app/vendors/somename/some.name.php index 54c144fe3..1394bf894 100644 --- a/cake/tests/test_app/vendors/somename/some.name.php +++ b/cake/tests/test_app/vendors/somename/some.name.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.vendors.somename + * @package cake.tests.test_app.vendors.somename * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/vendors/welcome.php b/cake/tests/test_app/vendors/welcome.php index dedd3e196..6b36caf0c 100644 --- a/cake/tests/test_app/vendors/welcome.php +++ b/cake/tests/test_app/vendors/welcome.php @@ -12,8 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake - * @subpackage cake.tests.test_app.vendors + * @package cake.tests.test_app.vendors * @since CakePHP(tm) v 1.2.0.7629 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/elements/email/html/custom.ctp b/cake/tests/test_app/views/elements/email/html/custom.ctp index 6b46d7c65..6d1b5702a 100644 --- a/cake/tests/test_app/views/elements/email/html/custom.ctp +++ b/cake/tests/test_app/views/elements/email/html/custom.ctp @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.elements.email.html + * @package cake.libs.view.templates.elements.email.html * @since CakePHP(tm) v 0.10.0.1076 * @version $Revision$ * @modifiedby $LastChangedBy$ diff --git a/cake/tests/test_app/views/elements/email/html/default.ctp b/cake/tests/test_app/views/elements/email/html/default.ctp index de87b4eb8..8efbaa94d 100644 --- a/cake/tests/test_app/views/elements/email/html/default.ctp +++ b/cake/tests/test_app/views/elements/email/html/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.elements.email.html + * @package cake.libs.view.templates.elements.email.html * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/elements/email/text/custom.ctp b/cake/tests/test_app/views/elements/email/text/custom.ctp index 623dba240..601023b74 100644 --- a/cake/tests/test_app/views/elements/email/text/custom.ctp +++ b/cake/tests/test_app/views/elements/email/text/custom.ctp @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.elements.email.text + * @package cake.libs.view.templates.elements.email.text * @since CakePHP(tm) v 0.10.0.1076 * @version $Revision$ * @modifiedby $LastChangedBy$ diff --git a/cake/tests/test_app/views/elements/email/text/default.ctp b/cake/tests/test_app/views/elements/email/text/default.ctp index 9d384e3f8..7655f1430 100644 --- a/cake/tests/test_app/views/elements/email/text/default.ctp +++ b/cake/tests/test_app/views/elements/email/text/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.elements.email.text + * @package cake.libs.view.templates.elements.email.text * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/elements/email/text/wide.ctp b/cake/tests/test_app/views/elements/email/text/wide.ctp index 67b03b057..1e476fbee 100644 --- a/cake/tests/test_app/views/elements/email/text/wide.ctp +++ b/cake/tests/test_app/views/elements/email/text/wide.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.elements.email.text + * @package cake.libs.view.templates.elements.email.text * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/helpers/banana.php b/cake/tests/test_app/views/helpers/banana.php index 0489d80f2..f57db5219 100644 --- a/cake/tests/test_app/views/helpers/banana.php +++ b/cake/tests/test_app/views/helpers/banana.php @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts + * @package cake.libs.view.templates.layouts * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/layouts/ajax.ctp b/cake/tests/test_app/views/layouts/ajax.ctp index dadf156ed..93371552b 100644 --- a/cake/tests/test_app/views/layouts/ajax.ctp +++ b/cake/tests/test_app/views/layouts/ajax.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts + * @package cake.libs.view.templates.layouts * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/layouts/ajax2.ctp b/cake/tests/test_app/views/layouts/ajax2.ctp index 0fa4fbacb..673abbaab 100644 --- a/cake/tests/test_app/views/layouts/ajax2.ctp +++ b/cake/tests/test_app/views/layouts/ajax2.ctp @@ -13,8 +13,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts + * @package cake.libs.view.templates.layouts * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/layouts/cache_layout.ctp b/cake/tests/test_app/views/layouts/cache_layout.ctp index 1fd6ff624..d76c26936 100644 --- a/cake/tests/test_app/views/layouts/cache_layout.ctp +++ b/cake/tests/test_app/views/layouts/cache_layout.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts + * @package cake.libs.view.templates.layouts * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/layouts/default.ctp b/cake/tests/test_app/views/layouts/default.ctp index f75592f05..21dacb2d9 100644 --- a/cake/tests/test_app/views/layouts/default.ctp +++ b/cake/tests/test_app/views/layouts/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.pages + * @package cake.libs.view.templates.pages * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/layouts/email/html/default.ctp b/cake/tests/test_app/views/layouts/email/html/default.ctp index 8b5a339f8..cc4364bb1 100644 --- a/cake/tests/test_app/views/layouts/email/html/default.ctp +++ b/cake/tests/test_app/views/layouts/email/html/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts.email.html + * @package cake.libs.view.templates.layouts.email.html * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/layouts/email/html/thin.ctp b/cake/tests/test_app/views/layouts/email/html/thin.ctp index 21ef3747f..87ece8384 100644 --- a/cake/tests/test_app/views/layouts/email/html/thin.ctp +++ b/cake/tests/test_app/views/layouts/email/html/thin.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts.email.html + * @package cake.libs.view.templates.layouts.email.html * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/layouts/email/text/default.ctp b/cake/tests/test_app/views/layouts/email/text/default.ctp index eb9a46daa..ad1aee411 100644 --- a/cake/tests/test_app/views/layouts/email/text/default.ctp +++ b/cake/tests/test_app/views/layouts/email/text/default.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts.email.text + * @package cake.libs.view.templates.layouts.email.text * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/layouts/flash.ctp b/cake/tests/test_app/views/layouts/flash.ctp index 1b7745cf2..bed0624c4 100644 --- a/cake/tests/test_app/views/layouts/flash.ctp +++ b/cake/tests/test_app/views/layouts/flash.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts + * @package cake.libs.view.templates.layouts * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/layouts/multi_cache.ctp b/cake/tests/test_app/views/layouts/multi_cache.ctp index d3bb46503..d14ce36de 100644 --- a/cake/tests/test_app/views/layouts/multi_cache.ctp +++ b/cake/tests/test_app/views/layouts/multi_cache.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts + * @package cake.libs.view.templates.layouts * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/posts/sequencial_nocache.ctp b/cake/tests/test_app/views/posts/sequencial_nocache.ctp index 7fa93fa5c..c6aa3eb09 100644 --- a/cake/tests/test_app/views/posts/sequencial_nocache.ctp +++ b/cake/tests/test_app/views/posts/sequencial_nocache.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.pages + * @package cake.libs.view.templates.pages * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/tests/test_app/views/posts/test_nocache_tags.ctp b/cake/tests/test_app/views/posts/test_nocache_tags.ctp index b3ee6f828..745ef4ad9 100644 --- a/cake/tests/test_app/views/posts/test_nocache_tags.ctp +++ b/cake/tests/test_app/views/posts/test_nocache_tags.ctp @@ -11,8 +11,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.pages + * @package cake.libs.view.templates.pages * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/index.php b/index.php index cb0352b8a..265576a3c 100644 --- a/index.php +++ b/index.php @@ -17,7 +17,6 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ From d8589323a95fbf08348339087d73944dc1a861c2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 24 Dec 2010 14:22:40 -0500 Subject: [PATCH 350/378] Missed a package tag. --- cake/libs/object.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cake/libs/object.php b/cake/libs/object.php index c574402ce..9096ae121 100644 --- a/cake/libs/object.php +++ b/cake/libs/object.php @@ -26,8 +26,7 @@ * Also includes methods for logging and the special method RequestAction, * to call other Controllers' Actions from anywhere. * - * @package cake - * @package cake.cake.libs + * @package cake.libs */ class Object { From 2385d9c79a4f9356033f062856b1a5af438d33a4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 24 Dec 2010 14:26:26 -0500 Subject: [PATCH 351/378] Updating console class @package tags. --- cake/console/libs/console_error_handler.php | 2 +- cake/console/libs/console_input.php | 2 +- cake/console/libs/console_input_argument.php | 2 +- cake/console/libs/console_input_option.php | 2 +- cake/console/libs/console_input_subcommand.php | 2 +- cake/console/libs/console_option_parser.php | 2 +- cake/console/libs/console_output.php | 2 +- cake/console/libs/help_formatter.php | 2 +- cake/console/shells/acl.php | 2 +- cake/console/shells/api.php | 2 +- cake/console/shells/bake.php | 2 +- cake/console/shells/command_list.php | 3 +-- cake/console/shells/console.php | 4 ++-- cake/console/shells/i18n.php | 4 ++-- cake/console/shells/schema.php | 4 ++-- cake/console/shells/shell.php | 4 ++-- cake/console/shells/tasks/bake.php | 2 +- cake/console/shells/tasks/controller.php | 4 ++-- cake/console/shells/tasks/db_config.php | 4 ++-- cake/console/shells/tasks/extract.php | 4 ++-- cake/console/shells/tasks/fixture.php | 4 ++-- cake/console/shells/tasks/model.php | 4 ++-- cake/console/shells/tasks/plugin.php | 4 ++-- cake/console/shells/tasks/project.php | 4 ++-- cake/console/shells/tasks/template.php | 2 +- cake/console/shells/tasks/test.php | 4 ++-- cake/console/shells/tasks/view.php | 2 +- cake/console/shells/testsuite.php | 2 +- 28 files changed, 40 insertions(+), 41 deletions(-) diff --git a/cake/console/libs/console_error_handler.php b/cake/console/libs/console_error_handler.php index 2de7b2e25..e49e3f968 100644 --- a/cake/console/libs/console_error_handler.php +++ b/cake/console/libs/console_error_handler.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console + * @package cake.console.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/console_input.php b/cake/console/libs/console_input.php index da3551399..00361e453 100644 --- a/cake/console/libs/console_input.php +++ b/cake/console/libs/console_input.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console + * @package cake.console.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/console_input_argument.php b/cake/console/libs/console_input_argument.php index b2e9d4f16..5877fca37 100644 --- a/cake/console/libs/console_input_argument.php +++ b/cake/console/libs/console_input_argument.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console + * @package cake.console.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/console_input_option.php b/cake/console/libs/console_input_option.php index c72638eca..cbcc2179a 100644 --- a/cake/console/libs/console_input_option.php +++ b/cake/console/libs/console_input_option.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console + * @package cake.console.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/console_input_subcommand.php b/cake/console/libs/console_input_subcommand.php index 82048b853..a8878e937 100644 --- a/cake/console/libs/console_input_subcommand.php +++ b/cake/console/libs/console_input_subcommand.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console + * @package cake.console.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/console_option_parser.php b/cake/console/libs/console_option_parser.php index 2f63651ec..17eefe1eb 100644 --- a/cake/console/libs/console_option_parser.php +++ b/cake/console/libs/console_option_parser.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console + * @package cake.console.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/console_output.php b/cake/console/libs/console_output.php index 27c1c4e66..f9020d411 100644 --- a/cake/console/libs/console_output.php +++ b/cake/console/libs/console_output.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console + * @package cake.console.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/libs/help_formatter.php b/cake/console/libs/help_formatter.php index 2afdd5e90..f454fa8b2 100644 --- a/cake/console/libs/help_formatter.php +++ b/cake/console/libs/help_formatter.php @@ -25,7 +25,7 @@ App::import('Core', 'String', false); * * Xml output is useful for intergration with other tools like IDE's or other build tools. * - * @package cake.console + * @package cake.console.libs * @since CakePHP(tm) v 2.0 */ class HelpFormatter { diff --git a/cake/console/shells/acl.php b/cake/console/shells/acl.php index 5fe8f70e6..b4d458ba7 100644 --- a/cake/console/shells/acl.php +++ b/cake/console/shells/acl.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs + * @package cake.console.shells * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/shells/api.php b/cake/console/shells/api.php index 5abd5d48b..05cf326b8 100644 --- a/cake/console/shells/api.php +++ b/cake/console/shells/api.php @@ -14,7 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs + * @package cake.console.shells * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/shells/bake.php b/cake/console/shells/bake.php index 266b6495c..ec741ed3a 100644 --- a/cake/console/shells/bake.php +++ b/cake/console/shells/bake.php @@ -16,7 +16,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs + * @package cake.console.shells * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/shells/command_list.php b/cake/console/shells/command_list.php index 9a198b47c..e9323c6f7 100644 --- a/cake/console/shells/command_list.php +++ b/cake/console/shells/command_list.php @@ -12,7 +12,6 @@ * * @copyright Copyright 2006-2010, Cake Software Foundation, Inc. * @link http://cakephp.org CakePHP Project - * @package cake.tests.cases.console.libs * @since CakePHP v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -20,7 +19,7 @@ /** * Shows a list of commands available from the console. * - * @package cake.console.libs + * @package cake.console.shells */ class CommandListShell extends Shell { diff --git a/cake/console/shells/console.php b/cake/console/shells/console.php index b3b1033ae..44cc13d45 100644 --- a/cake/console/shells/console.php +++ b/cake/console/shells/console.php @@ -12,13 +12,13 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs + * @package cake.console.shells * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ /** - * @package cake.console.libs + * @package cake.console.shells */ class ConsoleShell extends Shell { diff --git a/cake/console/shells/i18n.php b/cake/console/shells/i18n.php index 13477eb44..0a2bdeef6 100644 --- a/cake/console/shells/i18n.php +++ b/cake/console/shells/i18n.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs + * @package cake.console.shells * @since CakePHP(tm) v 1.2.0.5669 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -20,7 +20,7 @@ /** * Shell for I18N management. * - * @package cake.console.libs + * @package cake.console.shells */ class I18nShell extends Shell { diff --git a/cake/console/shells/schema.php b/cake/console/shells/schema.php index ed7090f53..c0fe44751 100644 --- a/cake/console/shells/schema.php +++ b/cake/console/shells/schema.php @@ -15,7 +15,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs + * @package cake.console.shells * @since CakePHP(tm) v 1.2.0.5550 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -25,7 +25,7 @@ App::import('Model', 'CakeSchema', false); /** * Schema is a command-line database management utility for automating programmer chores. * - * @package cake.console.libs + * @package cake.console.shells * @link http://book.cakephp.org/view/1523/Schema-management-and-migrations */ class SchemaShell extends Shell { diff --git a/cake/console/shells/shell.php b/cake/console/shells/shell.php index ac6240329..797b88f96 100644 --- a/cake/console/shells/shell.php +++ b/cake/console/shells/shell.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs + * @package cake.console.shells * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -24,7 +24,7 @@ require_once CONSOLE_LIBS . 'console_option_parser.php'; /** * Base class for command-line utilities for automating programmer chores. * - * @package cake.console.libs + * @package cake.console.shells */ class Shell extends Object { diff --git a/cake/console/shells/tasks/bake.php b/cake/console/shells/tasks/bake.php index 61413e6e1..bd7f59e69 100644 --- a/cake/console/shells/tasks/bake.php +++ b/cake/console/shells/tasks/bake.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/shells/tasks/controller.php b/cake/console/shells/tasks/controller.php index 3a17a525c..f1cac43eb 100644 --- a/cake/console/shells/tasks/controller.php +++ b/cake/console/shells/tasks/controller.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,7 +22,7 @@ include_once dirname(__FILE__) . DS . 'bake.php'; /** * Task class for creating and updating controller files. * - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks */ class ControllerTask extends BakeTask { diff --git a/cake/console/shells/tasks/db_config.php b/cake/console/shells/tasks/db_config.php index 7cc811f2d..c3c2b36e1 100644 --- a/cake/console/shells/tasks/db_config.php +++ b/cake/console/shells/tasks/db_config.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -20,7 +20,7 @@ /** * Task class for creating and updating the database configuration file. * - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks */ class DbConfigTask extends Shell { diff --git a/cake/console/shells/tasks/extract.php b/cake/console/shells/tasks/extract.php index 451b79417..9965876e2 100644 --- a/cake/console/shells/tasks/extract.php +++ b/cake/console/shells/tasks/extract.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs + * @package cake.console.shells.tasks * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -20,7 +20,7 @@ App::import('Core', 'File'); /** * Language string extractor * - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks */ class ExtractTask extends Shell { diff --git a/cake/console/shells/tasks/fixture.php b/cake/console/shells/tasks/fixture.php index f19585839..8fd60782b 100644 --- a/cake/console/shells/tasks/fixture.php +++ b/cake/console/shells/tasks/fixture.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -20,7 +20,7 @@ include_once dirname(__FILE__) . DS . 'bake.php'; /** * Task class for creating and updating fixtures files. * - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks */ class FixtureTask extends BakeTask { diff --git a/cake/console/shells/tasks/model.php b/cake/console/shells/tasks/model.php index 0af02a635..5ac132dd1 100644 --- a/cake/console/shells/tasks/model.php +++ b/cake/console/shells/tasks/model.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,7 +22,7 @@ include_once dirname(__FILE__) . DS . 'bake.php'; /** * Task class for creating and updating model files. * - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks */ class ModelTask extends BakeTask { diff --git a/cake/console/shells/tasks/plugin.php b/cake/console/shells/tasks/plugin.php index 1ea700081..118273d45 100644 --- a/cake/console/shells/tasks/plugin.php +++ b/cake/console/shells/tasks/plugin.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,7 +21,7 @@ App::import('Core', 'File'); /** * Task class for creating a plugin * - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks */ class PluginTask extends Shell { diff --git a/cake/console/shells/tasks/project.php b/cake/console/shells/tasks/project.php index c773b57ac..433ce9616 100644 --- a/cake/console/shells/tasks/project.php +++ b/cake/console/shells/tasks/project.php @@ -13,7 +13,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.bake + * @package cake.console.shells.tasks * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -22,7 +22,7 @@ App::import('Core', 'File'); /** * Task class for creating new project apps and plugins * - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks */ class ProjectTask extends Shell { diff --git a/cake/console/shells/tasks/template.php b/cake/console/shells/tasks/template.php index 08dbb30eb..108ffa8a4 100644 --- a/cake/console/shells/tasks/template.php +++ b/cake/console/shells/tasks/template.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ diff --git a/cake/console/shells/tasks/test.php b/cake/console/shells/tasks/test.php index 3e14c1fe8..0fe453040 100644 --- a/cake/console/shells/tasks/test.php +++ b/cake/console/shells/tasks/test.php @@ -12,7 +12,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -23,7 +23,7 @@ App::import('Model', 'ClassRegistry'); /** * Task class for creating and updating test files. * - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks */ class TestTask extends BakeTask { diff --git a/cake/console/shells/tasks/view.php b/cake/console/shells/tasks/view.php index 3e23d0d7e..51c84f2f3 100644 --- a/cake/console/shells/tasks/view.php +++ b/cake/console/shells/tasks/view.php @@ -22,7 +22,7 @@ include_once dirname(__FILE__) . DS . 'bake.php'; /** * Task class for creating and updating view files. * - * @package cake.console.libs.tasks + * @package cake.console.shells.tasks */ class ViewTask extends BakeTask { diff --git a/cake/console/shells/testsuite.php b/cake/console/shells/testsuite.php index 2e477a0a9..b8eb079b8 100644 --- a/cake/console/shells/testsuite.php +++ b/cake/console/shells/testsuite.php @@ -14,7 +14,7 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake.console.libs + * @package cake.console.shells * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ From 4009b6b2c7598e7ea7f857437389028e515b728a Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 24 Dec 2010 14:33:41 -0500 Subject: [PATCH 352/378] Fixing more @package tags, and removing duplicate tags in classes. --- cake/console/libs/console_error_handler.php | 2 +- cake/console/libs/console_input.php | 2 +- cake/console/libs/console_input_argument.php | 2 +- cake/console/libs/console_input_option.php | 2 +- cake/console/libs/console_input_subcommand.php | 2 +- cake/console/libs/console_option_parser.php | 2 +- cake/console/libs/console_output.php | 2 +- cake/libs/magic_db.php | 6 ++---- cake/libs/model/datasources/dbo/dbo_sqlite.php | 1 - 9 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cake/console/libs/console_error_handler.php b/cake/console/libs/console_error_handler.php index e49e3f968..80136bbcf 100644 --- a/cake/console/libs/console_error_handler.php +++ b/cake/console/libs/console_error_handler.php @@ -23,7 +23,7 @@ require_once 'console_output.php'; * Error Handler for Cake console. Does simple printing of the * exception that occurred and the stack trace of the error. * - * @package cake.console + * @package cake.console.libs */ class ConsoleErrorHandler extends ErrorHandler { diff --git a/cake/console/libs/console_input.php b/cake/console/libs/console_input.php index 00361e453..8378b2e85 100644 --- a/cake/console/libs/console_input.php +++ b/cake/console/libs/console_input.php @@ -19,7 +19,7 @@ /** * Object wrapper for interacting with stdin * - * @package cake.console + * @package cake.console.libs */ class ConsoleInput { /** diff --git a/cake/console/libs/console_input_argument.php b/cake/console/libs/console_input_argument.php index 5877fca37..263475e9d 100644 --- a/cake/console/libs/console_input_argument.php +++ b/cake/console/libs/console_input_argument.php @@ -21,7 +21,7 @@ * ConsoleOptionParser creates these when you use addArgument() * * @see ConsoleOptionParser::addArgument() - * @package cake.console + * @package cake.console.libs */ class ConsoleInputArgument { /** diff --git a/cake/console/libs/console_input_option.php b/cake/console/libs/console_input_option.php index cbcc2179a..3c9049248 100644 --- a/cake/console/libs/console_input_option.php +++ b/cake/console/libs/console_input_option.php @@ -22,7 +22,7 @@ * ConsoleOptionParser creates these when you use addOption() * * @see ConsoleOptionParser::addOption() - * @package cake.console + * @package cake.console.libs */ class ConsoleInputOption { /** diff --git a/cake/console/libs/console_input_subcommand.php b/cake/console/libs/console_input_subcommand.php index a8878e937..b2903aec2 100644 --- a/cake/console/libs/console_input_subcommand.php +++ b/cake/console/libs/console_input_subcommand.php @@ -22,7 +22,7 @@ * ConsoleOptionParser creates these when you use addSubcommand() * * @see ConsoleOptionParser::addSubcommand() - * @package cake.console + * @package cake.console.libs */ class ConsoleInputSubcommand { diff --git a/cake/console/libs/console_option_parser.php b/cake/console/libs/console_option_parser.php index 17eefe1eb..a96a0759a 100644 --- a/cake/console/libs/console_option_parser.php +++ b/cake/console/libs/console_option_parser.php @@ -26,7 +26,7 @@ require_once CONSOLE_LIBS . 'help_formatter.php'; * for GetOpt compatible option definition. Provides a builder pattern implementation * for creating shell option parsers. * - * @package cake.console + * @package cake.console.libs */ class ConsoleOptionParser { diff --git a/cake/console/libs/console_output.php b/cake/console/libs/console_output.php index f9020d411..7d41da4d7 100644 --- a/cake/console/libs/console_output.php +++ b/cake/console/libs/console_output.php @@ -41,7 +41,7 @@ * See ConsoleOutput::styles() to learn more about defining your own styles. Nested styles are not supported * at this time. * - * @package cake.console + * @package cake.console.libs */ class ConsoleOutput { /** diff --git a/cake/libs/magic_db.php b/cake/libs/magic_db.php index 07c3686af..86a91d82d 100644 --- a/cake/libs/magic_db.php +++ b/cake/libs/magic_db.php @@ -26,8 +26,7 @@ if (!class_exists('File')) { /** * A class to parse and use the MagicDb for file type analysis * - * @package cake.tests - * @package cake.tests.cases.libs + * @package cake.libs */ class MagicDb extends Object { @@ -171,8 +170,7 @@ class MagicDb extends Object { /** * undocumented class * - * @package cake.tests - * @package cake.tests.cases.libs + * @package cake.libs */ class MagicFileResource extends Object{ diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index f2bcda3fd..66859261e 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -22,7 +22,6 @@ * * A DboSource adapter for SQLite 3 using PDO * - * @package datasources * @package cake.libs.model.datasources.dbo */ class DboSqlite extends DboSource { From 83d12ce690e0a2d497ae687ad6d4e6dc20192e2f Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 26 Dec 2010 13:01:20 -0500 Subject: [PATCH 353/378] Removing deprecated $this->params in Helpers, it got missed somehow. Removing PaginatorHelper::$convertKeys. Its just a regular option now. Added some documentation. --- cake/libs/view/helper.php | 1 - cake/libs/view/helpers/paginator.php | 37 +++++++++++++--------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index c83dd9b03..16ea94798 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -137,7 +137,6 @@ class Helper extends Object { */ public function __construct(View $View, $settings = array()) { $this->_View = $View; - $this->params = $View->params; $this->request = $View->request; if (!empty($this->helpers)) { $this->_helperMap = ObjectCollection::normalizeObjectArray($this->helpers); diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 90f80baa7..cf0584655 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -53,34 +53,30 @@ class PaginatorHelper extends AppHelper { * * The values that may be specified are: * - * - `$options['format']` Format of the counter. Supported formats are 'range' and 'pages' + * - `$options['format']` Format of the counter. Supported formats are 'range' and 'pages' * and custom (default). In the default mode the supplied string is parsed and constants are replaced * by their actual values. * Constants: %page%, %pages%, %current%, %count%, %start%, %end% . - * - `$options['separator']` The separator of the actual page and number of pages (default: ' of '). - * - `$options['url']` Url of the action. See Router::url() - * - `$options['url']['sort']` the key that the recordset is sorted. - * - `$options['url']['direction']` Direction of the sorting (default: 'asc'). - * - `$options['url']['page']` Page # to display. - * - `$options['model']` The name of the model. - * - `$options['escape']` Defines if the title field for the link should be escaped (default: true). - * - `$options['update']` DOM id of the element updated with the results of the AJAX call. + * - `$options['separator']` The separator of the actual page and number of pages (default: ' of '). + * - `$options['url']` Url of the action. See Router::url() + * - `$options['url']['sort']` the key that the recordset is sorted. + * - `$options['url']['direction']` Direction of the sorting (default: 'asc'). + * - `$options['url']['page']` Page # to display. + * - `$options['model']` The name of the model. + * - `$options['escape']` Defines if the title field for the link should be escaped (default: true). + * - `$options['update']` DOM id of the element updated with the results of the AJAX call. * If this key isn't specified Paginator will use plain HTML links. - * - `$options['paramType']` The type of parameters to use when creating links. Valid options are + * - `$options['paramType']` The type of parameters to use when creating links. Valid options are * 'querystring', 'named', and 'route'. See PaginatorComponent::$settings for more information. + * - `convertKeys` - A list of keys in url arrays that should be converted to querysting params + * if paramType == 'querystring'. * * @var array * @access public */ - public $options = array(); - -/** - * A list of keys that will be turned into `$this->options['paramType']` url parameters when links - * are generated - * - * @var array - */ - public $convertKeys = array('page', 'limit', 'sort', 'direction'); + public $options = array( + 'convertKeys' => array('page', 'limit', 'sort', 'direction') + ); /** * Constructor for the helper. Sets up the helper that is used for creating 'AJAX' links. @@ -355,6 +351,7 @@ class PaginatorHelper extends AppHelper { $url = array_merge((array)$options['url'], (array)$url); unset($options['url']); } + unset($options['convertKeys']); $url = $this->url($url, true, $model); @@ -403,7 +400,7 @@ class PaginatorHelper extends AppHelper { if (!isset($url['?'])) { $url['?'] = array(); } - foreach ($this->convertKeys as $key) { + foreach ($this->options['convertKeys'] as $key) { if (isset($url[$key])) { $url['?'][$key] = $url[$key]; unset($url[$key]); From edf567b9f9d485be69c7d3f5e955cb3901f789b2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 26 Dec 2010 13:24:05 -0500 Subject: [PATCH 354/378] Adding convertKeys to PaginatorHelper::options(). Added a test case. Fixes #1390 --- cake/libs/view/helpers/paginator.php | 5 ++++- .../cases/libs/view/helpers/paginator.test.php | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index cf0584655..59acc1f49 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -66,7 +66,7 @@ class PaginatorHelper extends AppHelper { * - `$options['escape']` Defines if the title field for the link should be escaped (default: true). * - `$options['update']` DOM id of the element updated with the results of the AJAX call. * If this key isn't specified Paginator will use plain HTML links. - * - `$options['paramType']` The type of parameters to use when creating links. Valid options are + * - `$options['paging']['paramType']` The type of parameters to use when creating links. Valid options are * 'querystring', 'named', and 'route'. See PaginatorComponent::$settings for more information. * - `convertKeys` - A list of keys in url arrays that should be converted to querysting params * if paramType == 'querystring'. @@ -163,6 +163,9 @@ class PaginatorHelper extends AppHelper { ); unset($options[$model]); } + if (!empty($options['convertKeys'])) { + $options['convertKeys'] = array_merge($this->options['convertKeys'], $options['convertKeys']); + } $this->options = array_filter(array_merge($this->options, $options)); } diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 63272aad7..5176b3340 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -2242,6 +2242,22 @@ class PaginatorHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * test that additional keys can be flagged as query string args. + * + * @return void + */ + function testOptionsConvertKeys() { + $this->Paginator->options(array( + 'convertKeys' => array('something'), + 'Article' => array('paramType' => 'querystring') + )); + $result = $this->Paginator->url(array('page' => '4', 'something' => 'bar')); + $expected = '/?page=4&something=bar'; + $this->assertEquals($expected, $result); + } + + /** * test the current() method * From 769da1a7c87f993968efda28314e8ba76fe5c9fe Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 26 Dec 2010 14:25:57 -0500 Subject: [PATCH 355/378] Adding basic BehaviorCollection::hasMethod implementation. Tests added. --- cake/libs/model/behavior_collection.php | 19 +++++++++ .../libs/model/behavior_collection.test.php | 41 ++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/behavior_collection.php b/cake/libs/model/behavior_collection.php index da9970560..848894cb9 100644 --- a/cake/libs/model/behavior_collection.php +++ b/cake/libs/model/behavior_collection.php @@ -237,4 +237,23 @@ class BehaviorCollection extends ObjectCollection { return $this->__methods; } +/** + * Check to see if a behavior in this collection implements the provided method. Will + * also check mappedMethods. + * + * @param string $method The method to find. + * @return boolean Method was found. + */ + public function hasMethod($method) { + if (isset($this->__methods[$method])) { + return true; + } + foreach ($this->__mappedMethods as $pattern => $target) { + if (preg_match($pattern . 'i', $method)) { + return true; + } + } + return false; + } + } diff --git a/cake/tests/cases/libs/model/behavior_collection.test.php b/cake/tests/cases/libs/model/behavior_collection.test.php index efe549297..4b4ab980d 100644 --- a/cake/tests/cases/libs/model/behavior_collection.test.php +++ b/cake/tests/cases/libs/model/behavior_collection.test.php @@ -340,7 +340,16 @@ class TestBehavior extends ModelBehavior { * * @package cake.tests.cases.libs.model */ -class Test2Behavior extends TestBehavior{ +class Test2Behavior extends TestBehavior { + public $mapMethods = array('/mappingRobot(\w+)/' => 'mapped'); + + function resolveMethod($model, $stuff) { + + } + + function mapped($model, $method, $query) { + + } } /** @@ -1116,4 +1125,34 @@ class BehaviorCollectionTest extends CakeTestCase { $Sample->Behaviors->trigger('beforeTest', array(&$Sample)); } + +/** + * test that hasMethod works with basic functions. + * + * @return void + */ + function testHasMethodBasic() { + $Sample = new Sample(); + $Collection = new BehaviorCollection(); + $Collection->init('Sample', array('Test', 'Test2')); + + $this->assertTrue($Collection->hasMethod('testMethod')); + $this->assertTrue($Collection->hasMethod('resolveMethod')); + + $this->assertFalse($Collection->hasMethod('No method')); + } + +/** + * test that hasMethod works with mapped methods. + * + * @return void + */ + function testHasMethodMappedMethods() { + $Sample = new Sample(); + $Collection = new BehaviorCollection(); + $Collection->init('Sample', array('Test', 'Test2')); + + $this->assertTrue($Collection->hasMethod('look for the remote in the couch')); + $this->assertTrue($Collection->hasMethod('mappingRobotOnTheRoof')); + } } From 0c4b665ad020512409c602f3152e3672da510d14 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 26 Dec 2010 17:09:20 -0500 Subject: [PATCH 356/378] Adding ability for BehaviorCollection::hasMethod() to return the callback. Re-factored BehaviorCollection::dispatchMethod to be simpler and faster. Changing now BehaviorCollection stores callbacks so they look like normal php callback arrays. --- cake/libs/model/behavior_collection.php | 63 +++++++++---------- .../libs/model/behavior_collection.test.php | 27 +++++++- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/cake/libs/model/behavior_collection.php b/cake/libs/model/behavior_collection.php index 848894cb9..fbf1081fc 100644 --- a/cake/libs/model/behavior_collection.php +++ b/cake/libs/model/behavior_collection.php @@ -128,7 +128,7 @@ class BehaviorCollection extends ObjectCollection { $this->_loaded[$name]->setup(ClassRegistry::getObject($this->modelName), $config); foreach ($this->_loaded[$name]->mapMethods as $method => $alias) { - $this->__mappedMethods[$method] = array($alias, $name); + $this->__mappedMethods[$method] = array($name, $alias); } $methods = get_class_methods($this->_loaded[$name]); $parentMethods = array_flip(get_class_methods('ModelBehavior')); @@ -144,7 +144,7 @@ class BehaviorCollection extends ObjectCollection { !in_array($m, $callbacks) ); if ($methodAllowed) { - $this->__methods[$m] = array($m, $name); + $this->__methods[$m] = array($name, $m); } } } @@ -171,7 +171,7 @@ class BehaviorCollection extends ObjectCollection { unset($this->_loaded[$name]); } foreach ($this->__methods as $m => $callback) { - if (is_array($callback) && $callback[1] == $name) { + if (is_array($callback) && $callback[0] == $name) { unset($this->__methods[$m]); } } @@ -194,42 +194,29 @@ class BehaviorCollection extends ObjectCollection { * * @return array All methods for all behaviors attached to this object */ - public function dispatchMethod(&$model, $method, $params = array(), $strict = false) { - $methods = array_keys($this->__methods); - $check = array_flip($methods); - $found = isset($check[$method]); - $call = null; - - if ($strict && !$found) { + public function dispatchMethod($model, $method, $params = array(), $strict = false) { + $method = $this->hasMethod($method, true); + + if ($strict && empty($method)) { trigger_error(__("BehaviorCollection::dispatchMethod() - Method %s not found in any attached behavior", $method), E_USER_WARNING); return null; - } elseif ($found) { - $methods = array_combine($methods, array_values($this->__methods)); - $call = $methods[$method]; - } else { - $count = count($this->__mappedMethods); - $mapped = array_keys($this->__mappedMethods); - - for ($i = 0; $i < $count; $i++) { - if (preg_match($mapped[$i] . 'i', $method)) { - $call = $this->__mappedMethods[$mapped[$i]]; - array_unshift($params, $method); - break; - } - } } - - if (!empty($call)) { - return call_user_func_array( - array(&$this->_loaded[$call[1]], $call[0]), - array_merge(array(&$model), $params) - ); + if (empty($method)) { + return array('unhandled'); } - return array('unhandled'); + if (count($method) === 3) { + array_unshift($params, $method[2]); + unset($method[2]); + } + return call_user_func_array( + array($this->_loaded[$method[0]], $method[1]), + array_merge(array(&$model), $params) + ); } /** - * Gets the method list for attached behaviors, i.e. all public, non-callback methods + * Gets the method list for attached behaviors, i.e. all public, non-callback methods. + * This does not include mappedMethods. * * @return array All public methods for all behaviors attached to this collection */ @@ -242,14 +229,20 @@ class BehaviorCollection extends ObjectCollection { * also check mappedMethods. * * @param string $method The method to find. - * @return boolean Method was found. + * @param boolean $callback Return the callback for the method. + * @return mixed If $callback is false, a boolean will be returnned, if its true, an array + * containing callback information will be returnned. For mapped methods the array will have 3 elements. */ - public function hasMethod($method) { + public function hasMethod($method, $callback = false) { if (isset($this->__methods[$method])) { - return true; + return $callback ? $this->__methods[$method] : true; } foreach ($this->__mappedMethods as $pattern => $target) { if (preg_match($pattern . 'i', $method)) { + if ($callback) { + $target[] = $method; + return $target; + } return true; } } diff --git a/cake/tests/cases/libs/model/behavior_collection.test.php b/cake/tests/cases/libs/model/behavior_collection.test.php index 4b4ab980d..b7f547d99 100644 --- a/cake/tests/cases/libs/model/behavior_collection.test.php +++ b/cake/tests/cases/libs/model/behavior_collection.test.php @@ -1151,8 +1151,33 @@ class BehaviorCollectionTest extends CakeTestCase { $Sample = new Sample(); $Collection = new BehaviorCollection(); $Collection->init('Sample', array('Test', 'Test2')); - + $this->assertTrue($Collection->hasMethod('look for the remote in the couch')); $this->assertTrue($Collection->hasMethod('mappingRobotOnTheRoof')); } + +/** + * test hasMethod returrning a 'callback' + * + * @return void + */ + function testHasMethodAsCallback() { + $Sample = new Sample(); + $Collection = new BehaviorCollection(); + $Collection->init('Sample', array('Test', 'Test2')); + + $result = $Collection->hasMethod('testMethod', true); + $expected = array('Test', 'testMethod'); + $this->assertEquals($expected, $result); + + $result = $Collection->hasMethod('resolveMethod', true); + $expected = array('Test2', 'resolveMethod'); + $this->assertEquals($expected, $result); + + $result = $Collection->hasMethod('mappingRobotOnTheRoof', true); + $expected = array('Test2', 'mapped', 'mappingRobotOnTheRoof'); + $this->assertEquals($expected, $result); + } + + } From ad5a1ca6b7d28850acd05283aef666cfc54eff67 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 26 Dec 2010 17:10:16 -0500 Subject: [PATCH 357/378] Making __methods and __mappedMethods protected instead of private. --- cake/libs/model/behavior_collection.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cake/libs/model/behavior_collection.php b/cake/libs/model/behavior_collection.php index fbf1081fc..e4823bb11 100644 --- a/cake/libs/model/behavior_collection.php +++ b/cake/libs/model/behavior_collection.php @@ -42,14 +42,14 @@ class BehaviorCollection extends ObjectCollection { * * @var array */ - private $__methods = array(); + protected $_methods = array(); /** * Keeps a list of all methods which have been mapped with regular expressions * * @var array */ - private $__mappedMethods = array(); + protected $_mappedMethods = array(); /** * Attaches a model object and loads a list of behaviors @@ -128,7 +128,7 @@ class BehaviorCollection extends ObjectCollection { $this->_loaded[$name]->setup(ClassRegistry::getObject($this->modelName), $config); foreach ($this->_loaded[$name]->mapMethods as $method => $alias) { - $this->__mappedMethods[$method] = array($name, $alias); + $this->_mappedMethods[$method] = array($name, $alias); } $methods = get_class_methods($this->_loaded[$name]); $parentMethods = array_flip(get_class_methods('ModelBehavior')); @@ -140,11 +140,11 @@ class BehaviorCollection extends ObjectCollection { foreach ($methods as $m) { if (!isset($parentMethods[$m])) { $methodAllowed = ( - $m[0] != '_' && !array_key_exists($m, $this->__methods) && + $m[0] != '_' && !array_key_exists($m, $this->_methods) && !in_array($m, $callbacks) ); if ($methodAllowed) { - $this->__methods[$m] = array($name, $m); + $this->_methods[$m] = array($name, $m); } } } @@ -170,9 +170,9 @@ class BehaviorCollection extends ObjectCollection { $this->_loaded[$name]->cleanup(ClassRegistry::getObject($this->modelName)); unset($this->_loaded[$name]); } - foreach ($this->__methods as $m => $callback) { + foreach ($this->_methods as $m => $callback) { if (is_array($callback) && $callback[0] == $name) { - unset($this->__methods[$m]); + unset($this->_methods[$m]); } } $this->_enabled = array_values(array_diff($this->_enabled, (array)$name)); @@ -221,7 +221,7 @@ class BehaviorCollection extends ObjectCollection { * @return array All public methods for all behaviors attached to this collection */ public function methods() { - return $this->__methods; + return $this->_methods; } /** @@ -234,10 +234,10 @@ class BehaviorCollection extends ObjectCollection { * containing callback information will be returnned. For mapped methods the array will have 3 elements. */ public function hasMethod($method, $callback = false) { - if (isset($this->__methods[$method])) { - return $callback ? $this->__methods[$method] : true; + if (isset($this->_methods[$method])) { + return $callback ? $this->_methods[$method] : true; } - foreach ($this->__mappedMethods as $pattern => $target) { + foreach ($this->_mappedMethods as $pattern => $target) { if (preg_match($pattern . 'i', $method)) { if ($callback) { $target[] = $method; From 3022e2d785268731ae0a7830c1fa93a6c9b24bef Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 26 Dec 2010 17:21:49 -0500 Subject: [PATCH 358/378] Adding documentation. --- cake/libs/model/behavior_collection.php | 9 ++++++++- cake/libs/model/model_behavior.php | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/behavior_collection.php b/cake/libs/model/behavior_collection.php index e4823bb11..965c315f4 100644 --- a/cake/libs/model/behavior_collection.php +++ b/cake/libs/model/behavior_collection.php @@ -190,8 +190,15 @@ class BehaviorCollection extends ObjectCollection { } /** - * Dispatches a behavior method + * Dispatches a behavior method. Will call either normal methods or mapped methods. * + * If a method is not handeled by the BehaviorCollection, and $strict is false, a + * special return of `array('unhandled')` will be returned to signal the method was not found. + * + * @param Model $model The model the method was originally called on. + * @param string $method The method called. + * @param array $params Parameters for the called method. + * @param boolean $strict If methods are not found, trigger an error. * @return array All methods for all behaviors attached to this object */ public function dispatchMethod($model, $method, $params = array(), $strict = false) { diff --git a/cake/libs/model/model_behavior.php b/cake/libs/model/model_behavior.php index 482bd2e1e..7ff613b71 100644 --- a/cake/libs/model/model_behavior.php +++ b/cake/libs/model/model_behavior.php @@ -39,6 +39,25 @@ * * Would be called like `$this->Model->doSomething($arg1, $arg2);`. * + * ### Mapped methods + * + * Behaviors can also define mapped methods. Mapped methods use pattern matching for method invocation. This + * allows you to create methods similar to Model::findAllByXXX methods on your behaviors. Mapped methods need to + * be declared in your behaviors `$mapMethods` array. The method signature for a mapped method is slightly different + * than a normal behavior mixin method. + * + * {{{ + * var $mapMethods = array('/do(\w+)/' => 'doSomething'); + * + * function doSomething($model, $method, $arg1, $arg2) { + * //do something + * } + * }}} + * + * The above will map every doXXX() method call to the behavior. As you can see, the model is + * still the first parameter, but the called method name will be the 2nd parameter. This allows + * you to munge the method name for additional information, much like Model::findAllByXX. + * * @package cake.libs.model * @see Model::$actsAs * @see BehaviorCollection::load() From c5fa93b0fb81141b1fcf51d8bc6bbe3436fed54c Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 26 Dec 2010 17:26:18 -0500 Subject: [PATCH 359/378] Removing test that is testing methods covered in ObjectCollection test case. --- .../libs/model/behavior_collection.test.php | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/cake/tests/cases/libs/model/behavior_collection.test.php b/cake/tests/cases/libs/model/behavior_collection.test.php index b7f547d99..6fa7756b7 100644 --- a/cake/tests/cases/libs/model/behavior_collection.test.php +++ b/cake/tests/cases/libs/model/behavior_collection.test.php @@ -1035,34 +1035,6 @@ class BehaviorCollectionTest extends CakeTestCase { $this->assertTrue($Apple->testData('one', 'two', 'three', 'four', 'five', 'six')); } -/** - * testBehaviorTrigger method - * - * @access public - * @return void - */ - function testBehaviorTrigger() { - $Apple = new Apple(); - $Apple->Behaviors->attach('Test'); - $Apple->Behaviors->attach('Test2'); - $Apple->Behaviors->attach('Test3'); - - $Apple->beforeTestResult = array(); - $Apple->Behaviors->trigger('beforeTest', array(&$Apple)); - $expected = array('testbehavior', 'test2behavior', 'test3behavior'); - $this->assertIdentical($Apple->beforeTestResult, $expected); - - $Apple->beforeTestResult = array(); - $Apple->Behaviors->trigger('beforeTest', array(&$Apple), array('break' => true, 'breakOn' => 'test2behavior')); - $expected = array('testbehavior', 'test2behavior'); - $this->assertIdentical($Apple->beforeTestResult, $expected); - - $Apple->beforeTestResult = array(); - $Apple->Behaviors->trigger('beforeTest', array($Apple), array('break' => true, 'breakOn' => array('test2behavior', 'test3behavior'))); - $expected = array('testbehavior', 'test2behavior'); - $this->assertIdentical($Apple->beforeTestResult, $expected); - } - /** * undocumented function * From fd3b4b2cd51ed5f2356156e8fa7d7cdd5d052564 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 26 Dec 2010 17:35:22 -0500 Subject: [PATCH 360/378] Adding Model::hasMethod() and tests. --- cake/libs/model/model.php | 17 ++++++++++++++ .../libs/model/model_integration.test.php | 23 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index b55616028..396da7d4e 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1066,6 +1066,23 @@ class Model extends Object { return false; } +/** + * Check that a method is callable on a model. This will check both the model's own methods, its + * inherited methods and methods that could be callable through behaviors. + * + * @param string $method The method to be called. + * @return boolean True on method being callable. + */ + public function hasMethod($method) { + if (method_exists($this, $method)) { + return true; + } + if ($this->Behaviors->hasMethod($method)) { + return true; + } + return false; + } + /** * Returns true if the supplied field is a model Virtual Field * diff --git a/cake/tests/cases/libs/model/model_integration.test.php b/cake/tests/cases/libs/model/model_integration.test.php index fdd410bde..94714a276 100644 --- a/cake/tests/cases/libs/model/model_integration.test.php +++ b/cake/tests/cases/libs/model/model_integration.test.php @@ -2008,4 +2008,27 @@ class ModelIntegrationTest extends BaseModelTest { $expected = $db->name('Domain.DomainHandle'); $this->assertEqual($result, $expected); } + +/** + * test that model->hasMethod checks self and behaviors. + * + * @return void + */ + function testHasMethod() { + $Article = new Article(); + $Article->Behaviors = $this->getMock('BehaviorCollection'); + + $Article->Behaviors->expects($this->at(0)) + ->method('hasMethod') + ->will($this->returnValue(true)); + + $Article->Behaviors->expects($this->at(1)) + ->method('hasMethod') + ->will($this->returnValue(false)); + + $this->assertTrue($Article->hasMethod('find')); + + $this->assertTrue($Article->hasMethod('pass')); + $this->assertFalse($Article->hasMethod('fail')); + } } From f62a067d7cfffb6e711a25abe02287235a36034b Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 26 Dec 2010 17:40:34 -0500 Subject: [PATCH 361/378] Making it possible for behaviors to define paginate and paginateCount. Updated test to ensure the component calls the correct methods. Fixes #1373 --- cake/libs/controller/components/paginator.php | 4 ++-- .../libs/controller/components/paginator.test.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index 086de0584..7fbae137a 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -152,7 +152,7 @@ class PaginatorComponent extends Component { $extra['type'] = $type; } - if (method_exists($object, 'paginateCount')) { + if ($object->hasMethod('paginateCount')) { $count = $object->paginateCount($conditions, $recursive, $extra); } else { $parameters = compact('conditions'); @@ -170,7 +170,7 @@ class PaginatorComponent extends Component { } $page = $options['page'] = (int)$page; - if (method_exists($object, 'paginate')) { + if ($object->hasMethod('paginate')) { $results = $object->paginate( $conditions, $fields, $order, $limit, $page, $recursive, $extra ); diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index 6a337eb44..e8c925fc4 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -313,10 +313,20 @@ class PaginatorTest extends CakeTestCase { */ function testPageParamCasting() { $this->Controller->Post->expects($this->at(0)) + ->method('hasMethod') + ->with('paginateCount') + ->will($this->returnValue(false)); + + $this->Controller->Post->expects($this->at(1)) ->method('find') ->will($this->returnValue(2)); - $this->Controller->Post->expects($this->at(1)) + $this->Controller->Post->expects($this->at(2)) + ->method('hasMethod') + ->with('paginate') + ->will($this->returnValue(false)); + + $this->Controller->Post->expects($this->at(3)) ->method('find') ->will($this->returnValue(array('stuff'))); From 6f1eca79ac80f469a68389d2af3cc8d451130194 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 18 Dec 2010 15:52:23 -0500 Subject: [PATCH 362/378] Fixing calltime pass by reference deprecation warnings. --- cake/libs/http_socket.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index c4b36f1ff..84a4e84f3 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -537,7 +537,7 @@ class HttpSocket extends CakeSocket { if (!method_exists($authClass, 'authentication')) { throw new SocketException(sprintf(__('The %s do not support authentication.'), $authClass)); } - call_user_func("$authClass::authentication", $this, &$this->_auth[$method]); + call_user_func("$authClass::authentication", $this, $this->_auth[$method]); } /** @@ -563,7 +563,7 @@ class HttpSocket extends CakeSocket { if (!method_exists($authClass, 'proxyAuthentication')) { throw new SocketException(sprintf(__('The %s do not support proxy authentication.'), $authClass)); } - call_user_func("$authClass::proxyAuthentication", $this, &$this->_proxy); + call_user_func("$authClass::proxyAuthentication", $this, $this->_proxy); } /** From be963385dc6e7bb9e812d0acab6d0d0e27b795df Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 26 Dec 2010 20:16:48 -0500 Subject: [PATCH 363/378] Updating version numbers for 2.0.0-dev --- cake/VERSION.txt | 3 ++- cake/config/config.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cake/VERSION.txt b/cake/VERSION.txt index 90bd8f82d..3157f1e00 100644 --- a/cake/VERSION.txt +++ b/cake/VERSION.txt @@ -17,7 +17,8 @@ // @license MIT License (http://www.opensource.org/licenses/mit-license.php) // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -1.3.6 +2.0.0-dev + diff --git a/cake/config/config.php b/cake/config/config.php index 30b6e24d1..906fa844a 100644 --- a/cake/config/config.php +++ b/cake/config/config.php @@ -16,4 +16,4 @@ * @since CakePHP(tm) v 1.1.11.4062 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -return $config['Cake.version'] = '1.3.6'; +return $config['Cake.version'] = '2.0.0-dev'; From 5ce66d3031a0d0f4ab14ddeef9128d136b1fcaf3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 26 Dec 2010 21:30:43 -0500 Subject: [PATCH 364/378] Changing how PaginatorComponent::paginate()'s $whitelist param works. It now serves as the whitelist for fields ordering can be done on. It previously allowed you to whitelist things you passed into paginate(), which was kind of useless. Updated tests. Fixes #430 --- cake/libs/controller/components/paginator.php | 31 ++++++++++--------- .../controller/components/paginator.test.php | 19 +++++++++++- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index 7fbae137a..c857b573e 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -74,7 +74,7 @@ class PaginatorComponent extends Component { ); /** - * A list of request parameters users are allowed to set. Modifying + * A list of parameters users are allowed to set using request parameters. Modifying * this list will allow users to have more influence over pagination, * be careful with what you permit. * @@ -101,7 +101,8 @@ class PaginatorComponent extends Component { * * @param mixed $object Model to paginate (e.g: model instance, or 'Model', or 'Model.InnerModel') * @param mixed $scope Additional find conditions to use while paginating - * @param array $whitelist List of allowed options for paging + * @param array $whitelist List of allowed fields for ordering. This allows you to prevent ordering + * on non-indexed, or undesirable columns. * @return array Model query results */ public function paginate($object = null, $scope = array(), $whitelist = array()) { @@ -117,8 +118,8 @@ class PaginatorComponent extends Component { throw new MissingModelException($object); } - $options = $this->mergeOptions($object->alias, $whitelist); - $options = $this->validateSort($object, $options); + $options = $this->mergeOptions($object->alias); + $options = $this->validateSort($object, $options, $whitelist); $options = $this->checkLimit($options); $conditions = $fields = $order = $limit = $page = $recursive = null; @@ -272,11 +273,9 @@ class PaginatorComponent extends Component { * * @param string $alias Model alias being paginated, if the general settings has a key with this value * that key's settings will be used for pagination instead of the general ones. - * @param string $whitelist A whitelist of options that are allowed from the request parameters. Modifying - * this array will allow you to permit more or less input from the user. * @return array Array of merged options. */ - public function mergeOptions($alias, $whitelist = array()) { + public function mergeOptions($alias) { $defaults = $this->getDefaults($alias); switch ($defaults['paramType']) { case 'named': @@ -285,14 +284,8 @@ class PaginatorComponent extends Component { case 'querystring': $request = $this->Controller->request->query; break; - case 'route': - $request = $this->Controller->request->params; - unset($request['pass'], $request['named']); } - - $whitelist = array_flip(array_merge($this->whitelist, $whitelist)); - $request = array_intersect_key($request, $whitelist); - + $request = array_intersect_key($request, array_flip($this->whitelist)); return array_merge($defaults, $request); } @@ -322,9 +315,10 @@ class PaginatorComponent extends Component { * * @param Model $object The model being paginated. * @param array $options The pagination options being used for this request. + * @param array $whitelist The list of columns that can be used for sorting. If empty all keys are allowed. * @return array An array of options with sort + direction removed and replaced with order if possible. */ - public function validateSort($object, $options) { + public function validateSort($object, $options, $whitelist = array()) { if (isset($options['sort'])) { $direction = null; if (isset($options['direction'])) { @@ -335,6 +329,13 @@ class PaginatorComponent extends Component { } $options['order'] = array($options['sort'] => $direction); } + + if (!empty($whitelist)) { + $field = key($options['order']); + if (!in_array($field, $whitelist)) { + $options['order'] = null; + } + } if (!empty($options['order']) && is_array($options['order'])) { $alias = $object->alias ; diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/cake/tests/cases/libs/controller/components/paginator.test.php index e8c925fc4..cbaecb2b9 100644 --- a/cake/tests/cases/libs/controller/components/paginator.test.php +++ b/cake/tests/cases/libs/controller/components/paginator.test.php @@ -635,7 +635,8 @@ class PaginatorTest extends CakeTestCase { 'maxLimit' => 100, 'paramType' => 'named', ); - $result = $this->Paginator->mergeOptions('Post', array('fields')); + $this->Paginator->whitelist[] = 'fields'; + $result = $this->Paginator->mergeOptions('Post'); $expected = array( 'page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named', 'fields' => array('bad.stuff') ); @@ -658,6 +659,22 @@ class PaginatorTest extends CakeTestCase { $this->assertEquals('asc', $result['order']['model.something']); } +/** + * test that fields not in whitelist won't be part of order conditions. + * + * @return void + */ + function testValidateSortWhitelistFailure() { + $model = $this->getMock('Model'); + $model->alias = 'model'; + $model->expects($this->any())->method('hasField')->will($this->returnValue(true)); + + $options = array('sort' => 'body', 'direction' => 'asc'); + $result = $this->Paginator->validateSort($model, $options, array('title', 'id')); + + $this->assertNull($result['order']); + } + /** * test that virtual fields work. * From 3d966be1e839ec74829b19fbe03b8f996807a13c Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 27 Dec 2010 00:06:07 -0500 Subject: [PATCH 365/378] Fixing fatal error caused by Debugger not being loaded when viewing the default home page. --- cake/console/templates/default/views/home.ctp | 1 + cake/libs/view/pages/home.ctp | 1 + 2 files changed, 2 insertions(+) diff --git a/cake/console/templates/default/views/home.ctp b/cake/console/templates/default/views/home.ctp index 2dd42a698..22217b2fb 100644 --- a/cake/console/templates/default/views/home.ctp +++ b/cake/console/templates/default/views/home.ctp @@ -2,6 +2,7 @@ $output = "

    Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!

    \n"; $output .=" 0): Debugger::checkSecurityKeys(); endif; diff --git a/cake/libs/view/pages/home.ctp b/cake/libs/view/pages/home.ctp index 5fddec45c..9951a08c0 100644 --- a/cake/libs/view/pages/home.ctp +++ b/cake/libs/view/pages/home.ctp @@ -18,6 +18,7 @@ if (Configure::read() == 0): throw new NotFoundException(); endif; +App::import('Core', 'Debugger'); ?>

    From b82ad15c5eb40f6e9cee539a1c0b63a1fbf49f16 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 27 Dec 2010 00:19:59 -0500 Subject: [PATCH 366/378] Fixing issue in console when baking a new project, from outside the installation directory you would get an error because database.php could not be found. Fixes #1406 --- cake/libs/model/connection_manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/connection_manager.php b/cake/libs/model/connection_manager.php index 9581431fc..f8916877e 100644 --- a/cake/libs/model/connection_manager.php +++ b/cake/libs/model/connection_manager.php @@ -19,7 +19,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ require LIBS . 'model' . DS . 'datasources' . DS . 'datasource.php'; -include_once CONFIGS . 'database.php'; +config('database'); /** * Manages loaded instances of DataSource objects From 65394604a751ccfdc8124f1f29b85a33a3d1b217 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 19 Feb 2010 10:27:16 +0100 Subject: [PATCH 367/378] Give PaginatorHelper's next/prev links the correct 'rel' attribute It's a good idea to give links such as next/prev the 'rel' attribute. See the following pages for more information: http://www.w3.org/TR/html4/struct/links.html#edef-A http://www.w3.org/TR/html4/types.html#type-links Signed-off-by: mark_story --- cake/libs/view/helpers/paginator.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 59acc1f49..c7377e13e 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -252,6 +252,10 @@ class PaginatorHelper extends AppHelper { * @return string A "previous" link or $disabledTitle text if the link is disabled. */ public function prev($title = '<< Previous', $options = array(), $disabledTitle = null, $disabledOptions = array()) { + $defaults = array( + 'rel' => 'prev' + ); + $options = array_merge($defaults, (array)$options); return $this->__pagingLink('Prev', $title, $options, $disabledTitle, $disabledOptions); } @@ -271,6 +275,10 @@ class PaginatorHelper extends AppHelper { * @return string A "next" link or or $disabledTitle text if the link is disabled. */ public function next($title = 'Next >>', $options = array(), $disabledTitle = null, $disabledOptions = array()) { + $defaults = array( + 'rel' => 'next' + ); + $options = array_merge($defaults, (array)$options); return $this->__pagingLink('Next', $title, $options, $disabledTitle, $disabledOptions); } From af608f68ef70ed17e0663cd37ae2f18bc85fb032 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 27 Dec 2010 10:38:30 -0500 Subject: [PATCH 368/378] Updating test cases for the addition of rel attributes to links generated by PaginatorHelper. Also removed rel attributes for disabled elements, as they are probably not link tags. Fixes #370 --- cake/libs/view/helpers/paginator.php | 1 + .../libs/view/helpers/paginator.test.php | 48 ++++++++++++------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index c7377e13e..fc4ba0862 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -454,6 +454,7 @@ class PaginatorHelper extends AppHelper { if ($this->{$check}($model)) { return $this->Html->tag($tag, $this->link($title, $url, array_merge($options, compact('escape', 'class')))); } else { + unset($options['rel']); return $this->Html->tag($tag, $title, array_merge($options, compact('escape', 'class'))); } } diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 5176b3340..671c4f46a 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -460,7 +460,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('Next'); $expected = array( ' array('href' => '/admin/users/index/page:2', 'class' => 'next'), + 'a' => array('href' => '/admin/users/index/page:2', 'class' => 'next', 'rel' => 'next'), 'Next', '/a', '/span' @@ -563,7 +563,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('next', array('url' => $options)); $expected = array( ' array('href' => '/members/posts/index/page:3', 'class' => 'next'), + 'a' => array('href' => '/members/posts/index/page:3', 'class' => 'next', 'rel' => 'next'), 'next', '/a', '/span' @@ -573,7 +573,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->prev('prev', array('url' => $options)); $expected = array( ' array('href' => '/members/posts/index/page:1', 'class' => 'prev'), + 'a' => array('href' => '/members/posts/index/page:1', 'class' => 'prev', 'rel' => 'prev'), 'prev', '/a', '/span' @@ -700,7 +700,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('Next'); $expected = array( ' array('href' => '/articles/index/2/page:2/foo:bar', 'class' => 'next'), + 'a' => array('href' => '/articles/index/2/page:2/foo:bar', 'class' => 'next', 'rel' => 'next'), 'Next', '/a', '/span' @@ -750,7 +750,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $expected = array( ' array('href' => '/index/page:1', 'class' => 'prev'), + 'a' => array('href' => '/index/page:1', 'class' => 'prev', 'rel' => 'prev'), '<< Previous', '/a', '/span' @@ -760,7 +760,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('Next'); $expected = array( ' array('href' => '/index/page:3', 'class' => 'next'), + 'a' => array('href' => '/index/page:3', 'class' => 'next', 'rel' => 'next'), 'Next', '/a', '/span' @@ -770,7 +770,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('Next', array('tag' => 'li')); $expected = array( ' array('href' => '/index/page:3', 'class' => 'next'), + 'a' => array('href' => '/index/page:3', 'class' => 'next', 'rel' => 'next'), 'Next', '/a', '/li' @@ -780,7 +780,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->prev('<< Previous', array('escape' => true)); $expected = array( ' array('href' => '/index/page:1', 'class' => 'prev'), + 'a' => array('href' => '/index/page:1', 'class' => 'prev', 'rel' => 'prev'), '<< Previous', '/a', '/span' @@ -790,7 +790,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->prev('<< Previous', array('escape' => false)); $expected = array( ' array('href' => '/index/page:1', 'class' => 'prev'), + 'a' => array('href' => '/index/page:1', 'class' => 'prev', 'rel' => 'prev'), 'preg:/<< Previous/', '/a', '/span' @@ -858,7 +858,11 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $expected = array( ' array('href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC', 'class' => 'prev'), + 'a' => array( + 'href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC', + 'class' => 'prev', + 'rel' => 'prev' + ), '<< Previous', '/a', '/span' @@ -868,7 +872,11 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('Next'); $expected = array( ' array('href' => '/index/page:3/limit:3/sort:Client.name/direction:DESC', 'class' => 'next'), + 'a' => array( + 'href' => '/index/page:3/limit:3/sort:Client.name/direction:DESC', + 'class' => 'next', + 'rel' => 'next' + ), 'Next', '/a', '/span' @@ -895,7 +903,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->prev('Prev'); $expected = array( ' array('href' => '/index/page:1/limit:10', 'class' => 'prev'), + 'a' => array('href' => '/index/page:1/limit:10', 'class' => 'prev', 'rel' => 'prev'), 'Prev', '/a', '/span' @@ -917,7 +925,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar'))); $expected = array( ' array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev'), + 'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev', 'rel' => 'prev'), 'Prev', '/a', '/span' @@ -957,7 +965,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('Next >>', array('escape' => false)); $expected = array( ' array('href' => '/index/page:2', 'class' => 'next'), + 'a' => array('href' => '/index/page:2', 'class' => 'next', 'rel' => 'next'), 'preg:/Next >>/', '/a', '/span' @@ -1004,7 +1012,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('Next', array('model' => 'Client')); $expected = array( ' array('href' => '/index/page:2', 'class' => 'next'), + 'a' => array('href' => '/index/page:2', 'class' => 'next', 'rel' => 'next'), 'Next', '/a', '/span' @@ -2130,7 +2138,11 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('Next'); $expected = array( ' array('href' => '/officespace/accounts/index/page:2/sort:Article.title/direction:asc', 'class' => 'next'), + 'a' => array( + 'href' => '/officespace/accounts/index/page:2/sort:Article.title/direction:asc', + 'class' => 'next', + 'rel' => 'next' + ), 'Next', '/a', '/span', @@ -2224,7 +2236,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('Next'); $expected = array( ' array('href' => '/?page=3', 'class' => 'next'), + 'a' => array('href' => '/?page=3', 'class' => 'next', 'rel' => 'next'), 'Next', '/a', '/span' @@ -2234,7 +2246,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->prev('Prev'); $expected = array( ' array('href' => '/?page=1', 'class' => 'prev'), + 'a' => array('href' => '/?page=1', 'class' => 'prev', 'rel' => 'prev'), 'Prev', '/a', '/span' From fd88d575130787dc10e0ccd4c4ba337cfc767c7e Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 27 Dec 2010 10:40:21 -0500 Subject: [PATCH 369/378] Fixing option documentation. --- cake/libs/view/helpers/paginator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index fc4ba0862..f217d8fae 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -730,7 +730,7 @@ class PaginatorHelper extends AppHelper { * ### Options: * * - `tag` The tag wrapping tag you want to use, defaults to 'span' - * - `before` Content to insert before the link/tag + * - `after` Content to insert after the link/tag * - `model` The model to use defaults to PaginatorHelper::defaultModel() * - `separator` Content between the generated links, defaults to ' | ' * - `ellipsis` Content for ellipsis, defaults to '...' From e003bd6ea9a74c52b35595cdd859e1546d2e0577 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 27 Dec 2010 10:48:38 -0500 Subject: [PATCH 370/378] Adding rel attributes for first and last links. These attribute values are part of the html5 spec, and fit with the intention of #370 --- cake/libs/view/helpers/paginator.php | 8 +++++--- .../libs/view/helpers/paginator.test.php | 20 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index f217d8fae..5966d11c0 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -743,14 +743,14 @@ class PaginatorHelper extends AppHelper { $options = array_merge( array( 'tag' => 'span', - 'after'=> null, + 'after' => null, 'model' => $this->defaultModel(), 'separator' => ' | ', - 'ellipsis' => '...', + 'ellipsis' => '...' ), (array)$options); - $params = array_merge(array('page'=> 1), (array)$this->params($options['model'])); + $params = array_merge(array('page' => 1), (array)$this->params($options['model'])); unset($options['model']); if ($params['pageCount'] <= 1) { @@ -773,6 +773,7 @@ class PaginatorHelper extends AppHelper { } $out .= $after; } elseif ($params['page'] > 1) { + $options += array('rel' => 'first'); $out = $this->Html->tag($tag, $this->link($first, array('page' => 1), $options)) . $after; } @@ -830,6 +831,7 @@ class PaginatorHelper extends AppHelper { } $out = $before . $out; } elseif ($params['page'] < $params['pageCount']) { + $options += array('rel' => 'last'); $out = $before . $this->Html->tag( $tag, $this->link($last, array('page' => $params['pageCount']), $options )); diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 671c4f46a..7b600819f 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -1179,7 +1179,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->numbers(true); $expected = array( - array('span' => array()), array('a' => array('href' => '/index/page:1')), 'first', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/index/page:1', 'rel' => 'first')), 'first', '/a', '/span', ' | ', array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span', ' | ', @@ -1199,7 +1199,7 @@ class PaginatorHelperTest extends CakeTestCase { ' | ', array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/index/page:15')), 'last', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/index/page:15', 'rel' => 'last')), 'last', '/a', '/span', ); $this->assertTags($result, $expected); @@ -1779,7 +1779,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->first('<<', array('tag' => 'li')); $expected = array( ' array('href' => '/index/page:1'), + 'a' => array('href' => '/index/page:1', 'rel' => 'first'), '<<', '/a', '/li' @@ -1841,7 +1841,9 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->first(); $expected = array( ' array('href' => FULL_BASE_URL . '/index/page:1/sort:Article.title/direction:DESC')), + array('a' => array( + 'href' => FULL_BASE_URL . '/index/page:1/sort:Article.title/direction:DESC', 'rel' => 'first' + )), '<< first', '/a', '/span', @@ -1858,7 +1860,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->first(); $expected = array( ' array('href' => '/index/page:1'), + 'a' => array('href' => '/index/page:1', 'rel' => 'first'), '<< first', '/a', '/span' @@ -1888,7 +1890,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->last(); $expected = array( ' array('href' => '/index/page:7'), + 'a' => array('href' => '/index/page:7', 'rel' => 'last'), 'last >>', '/a', '/span' @@ -1947,7 +1949,11 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->last(); $expected = array( ' array('href' => '/index/page:15/sort:Client.name/direction:DESC')), 'last >>', '/a', + array('a' => array( + 'href' => '/index/page:15/sort:Client.name/direction:DESC', + 'rel' => 'last' + )), + 'last >>', '/a', '/span', ); $this->assertTags($result, $expected); From b6b4f4a3df8cfc6571cb392d9ae1e674187675db Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 27 Dec 2010 15:34:56 -0500 Subject: [PATCH 371/378] Fixing deprecated access to $this->data. --- cake/console/templates/default/actions/controller_actions.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/console/templates/default/actions/controller_actions.ctp b/cake/console/templates/default/actions/controller_actions.ctp index f80d3d374..e6f0f8e83 100644 --- a/cake/console/templates/default/actions/controller_actions.ctp +++ b/cake/console/templates/default/actions/controller_actions.ctp @@ -85,7 +85,7 @@ } } else { - $this->data = $this->->read(null, $id); + $this->request->data = $this->->read(null, $id); } Date: Mon, 27 Dec 2010 23:30:10 -0500 Subject: [PATCH 372/378] Adding usage and expanding doc blocks for PaginatorHelper. --- cake/libs/view/helpers/paginator.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 5966d11c0..b83561d24 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -725,7 +725,16 @@ class PaginatorHelper extends AppHelper { } /** - * Returns a first or set of numbers for the first pages + * Returns a first or set of numbers for the first pages. + * + * `echo $this->Paginator->first('< first');` + * + * Creates a single link for the first page. Will output nothing if you are on the first page. + * + * `echo $this->Paginator->first(3);` + * + * Will create links for the first 3 pages, once you get to the third or greater page. Prior to that + * nothing will be output. * * ### Options: * @@ -735,8 +744,9 @@ class PaginatorHelper extends AppHelper { * - `separator` Content between the generated links, defaults to ' | ' * - `ellipsis` Content for ellipsis, defaults to '...' * - * @param mixed $first if string use as label for the link, if numeric print page numbers - * @param mixed $options + * @param mixed $first if string use as label for the link. If numeric, the number of page links + * you want at the beginning of the range. + * @param mixed $options An array of options. * @return string numbers string. */ public function first($first = '<< first', $options = array()) { @@ -781,7 +791,15 @@ class PaginatorHelper extends AppHelper { } /** - * Returns a last or set of numbers for the last pages + * Returns a last or set of numbers for the last pages. + * + * `echo $this->Paginator->last('last >');` + * + * Creates a single link for the last page. Will output nothing if you are on the last page. + * + * `echo $this->Paginator->last(3);` + * + * Will create links for the last 3 pages. Once you enter the page range, no output will be created. * * ### Options: * From eb38b8b60c34d9db2585052a40cf34c89eca89a3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 27 Dec 2010 23:40:10 -0500 Subject: [PATCH 373/378] Fixing more boundary issues with first() and last(). When you entered a first/last range a wonky page link would be generated. Tests added. --- cake/libs/view/helpers/paginator.php | 4 ++-- cake/tests/cases/libs/view/helpers/paginator.test.php | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index b83561d24..a28767364 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -782,7 +782,7 @@ class PaginatorHelper extends AppHelper { } } $out .= $after; - } elseif ($params['page'] > 1) { + } elseif ($params['page'] > 1 && is_string($first)) { $options += array('rel' => 'first'); $out = $this->Html->tag($tag, $this->link($first, array('page' => 1), $options)) . $after; @@ -848,7 +848,7 @@ class PaginatorHelper extends AppHelper { } } $out = $before . $out; - } elseif ($params['page'] < $params['pageCount']) { + } elseif ($params['page'] < $params['pageCount'] && is_string($last)) { $options += array('rel' => 'last'); $out = $before . $this->Html->tag( $tag, $this->link($last, array('page' => $params['pageCount']), $options diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 7b600819f..ce4497536 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -1878,6 +1878,10 @@ class PaginatorHelperTest extends CakeTestCase { '/span' ); $this->assertTags($result, $expected); + + $this->Paginator->request->params['paging']['Article']['page'] = 2; + $result = $this->Paginator->first(3); + $this->assertEquals('', $result, 'When inside the first links range, no links should be made'); } /** @@ -1922,6 +1926,9 @@ class PaginatorHelperTest extends CakeTestCase { '/span', ); $this->assertTags($result, $expected); + + $result = $this->Paginator->last(3); + $this->assertEquals('', $result, 'When inside the last links range, no links should be made'); } /** From ab552c22a1a26eeaceb7fe33bc1835885accf4af Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 28 Dec 2010 00:09:47 -0500 Subject: [PATCH 374/378] Adding a usage sample to Paginator->numbers() --- cake/libs/view/helpers/paginator.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index a28767364..aaba58297 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -602,7 +602,12 @@ class PaginatorHelper extends AppHelper { /** * Returns a set of numbers for the paged result set - * uses a modulus to decide how many numbers to show on each side of the current page (default: 8) + * uses a modulus to decide how many numbers to show on each side of the current page (default: 8). + * + * `$this->Paginator->numbers(array('first' => 2, 'last' => 2));` + * + * Using the first and last options you can create links to the beginning and end of the page set. + * * * ### Options * @@ -613,9 +618,9 @@ class PaginatorHelper extends AppHelper { * - `separator` Separator content defaults to ' | ' * - `tag` The tag to wrap links in, defaults to 'span' * - `first` Whether you want first links generated, set to an integer to define the number of 'first' - * links to generate + * links to generate. * - `last` Whether you want last links generated, set to an integer to define the number of 'last' - * links to generate + * links to generate. * - `ellipsis` Ellipsis content, defaults to '...' * * @param mixed $options Options for the numbers, (before, after, model, modulus, separator) From 7dd1eea28562344a7504fe4b4572ee5e11a3693f Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 28 Dec 2010 22:18:31 -0500 Subject: [PATCH 375/378] Updating documentation for paginator helper, and component. --- cake/libs/controller/components/paginator.php | 9 ++++--- cake/libs/view/helpers/paginator.php | 25 ++++++++++--------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/cake/libs/controller/components/paginator.php b/cake/libs/controller/components/paginator.php index c857b573e..5c0c4b940 100644 --- a/cake/libs/controller/components/paginator.php +++ b/cake/libs/controller/components/paginator.php @@ -267,9 +267,9 @@ class PaginatorComponent extends Component { * - General pagination settings * - Model specific settings. * - Request parameters - * - $options argument. * - * The result of this method is the aggregate of all the option sets combined together. + * The result of this method is the aggregate of all the option sets combined together. You can change + * PaginatorComponent::$whitelist to modify which options/values can be set using request parameters. * * @param string $alias Model alias being paginated, if the general settings has a key with this value * that key's settings will be used for pagination instead of the general ones. @@ -294,7 +294,7 @@ class PaginatorComponent extends Component { * will be used. * * @param string $alias Model name to get default settings for. - * @return array + * @return array An array of pagination defaults for a model, or the general settings. */ public function getDefaults($alias) { if (isset($this->settings[$alias])) { @@ -313,6 +313,9 @@ class PaginatorComponent extends Component { * virtualFields can be sorted on. The direction param will also be sanitized. Lastly * sort + direction keys will be converted into the model friendly order key. * + * You can use the whitelist parameter to control which columns/fields are available for sorting. + * This helps prevent users from ordering large result sets on un-indexed values. + * * @param Model $object The model being paginated. * @param array $options The pagination options being used for this request. * @param array $whitelist The list of columns that can be used for sorting. If empty all keys are allowed. diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index aaba58297..8fe9e40ec 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -42,7 +42,8 @@ class PaginatorHelper extends AppHelper { private $__defaultModel = null; /** - * The class used for 'Ajax' pagination links. + * The class used for 'Ajax' pagination links. Defaults to JsHelper. You should make sure + * that JsHelper is defined as a helper before PaginatorHelper, if you want to customize the JsHelper. * * @var string */ @@ -53,20 +54,20 @@ class PaginatorHelper extends AppHelper { * * The values that may be specified are: * - * - `$options['format']` Format of the counter. Supported formats are 'range' and 'pages' + * - `format` Format of the counter. Supported formats are 'range' and 'pages' * and custom (default). In the default mode the supplied string is parsed and constants are replaced * by their actual values. - * Constants: %page%, %pages%, %current%, %count%, %start%, %end% . - * - `$options['separator']` The separator of the actual page and number of pages (default: ' of '). - * - `$options['url']` Url of the action. See Router::url() - * - `$options['url']['sort']` the key that the recordset is sorted. - * - `$options['url']['direction']` Direction of the sorting (default: 'asc'). - * - `$options['url']['page']` Page # to display. - * - `$options['model']` The name of the model. - * - `$options['escape']` Defines if the title field for the link should be escaped (default: true). - * - `$options['update']` DOM id of the element updated with the results of the AJAX call. + * placeholders: %page%, %pages%, %current%, %count%, %start%, %end% . + * - `separator` The separator of the actual page and number of pages (default: ' of '). + * - `url` Url of the action. See Router::url() + * - `url['sort']` the key that the recordset is sorted. + * - `url['direction']` Direction of the sorting (default: 'asc'). + * - `url['page']` Page number to use in links. + * - `model` The name of the model. + * - `escape` Defines if the title field for the link should be escaped (default: true). + * - `update` DOM id of the element updated with the results of the AJAX call. * If this key isn't specified Paginator will use plain HTML links. - * - `$options['paging']['paramType']` The type of parameters to use when creating links. Valid options are + * - `paging['paramType']` The type of parameters to use when creating links. Valid options are * 'querystring', 'named', and 'route'. See PaginatorComponent::$settings for more information. * - `convertKeys` - A list of keys in url arrays that should be converted to querysting params * if paramType == 'querystring'. From 2e0f2c75f48695b4685891be8336843da636522f Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 29 Dec 2010 10:44:15 -0500 Subject: [PATCH 376/378] Fixing issue where ClassRegistry would not be loaded when using Models in shells. Fixes #1417 --- cake/console/shells/shell.php | 1 + 1 file changed, 1 insertion(+) diff --git a/cake/console/shells/shell.php b/cake/console/shells/shell.php index 797b88f96..dd59dbb2c 100644 --- a/cake/console/shells/shell.php +++ b/cake/console/shells/shell.php @@ -218,6 +218,7 @@ class Shell extends Object { if ($this->uses === null || $this->uses === false) { return; } + App::import('Core', 'ClassRegistry'); if ($this->uses !== true && !empty($this->uses)) { $uses = is_array($this->uses) ? $this->uses : array($this->uses); From 1f6fba9d9ed2d1503e2f6027aa845dcb81f7e12b Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 31 Dec 2010 16:35:44 -0500 Subject: [PATCH 377/378] Fixing failing test caused by missing space. --- cake/tests/cases/libs/view/helpers/time.test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index 67481f5a4..d71c6cd90 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -337,14 +337,14 @@ class TimeHelperTest extends CakeTestCase { if (date('Y', $time) == date('Y')) { $this->assertEqual(date('M jS, H:i', $time), $this->Time->niceShort($time)); } else { - $this->assertEqual(date('M jSY, H:i', $time), $this->Time->niceShort($time)); + $this->assertEqual(date('M jS Y, H:i', $time), $this->Time->niceShort($time)); } $time = time(); - $this->assertEqual('Today, '.date('H:i', $time), $this->Time->niceShort($time)); + $this->assertEqual('Today, ' . date('H:i', $time), $this->Time->niceShort($time)); $time = time() - DAY; - $this->assertEqual('Yesterday, '.date('H:i', $time), $this->Time->niceShort($time)); + $this->assertEqual('Yesterday, ' . date('H:i', $time), $this->Time->niceShort($time)); } /** From 04c602e3d0dd8d71612415a421c16096d5fc8851 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 31 Dec 2010 16:37:16 -0500 Subject: [PATCH 378/378] Fixing issues with isThisWeek() when the year ends midweek. --- cake/libs/view/helpers/time.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/helpers/time.php b/cake/libs/view/helpers/time.php index f65b62de0..32e9e3050 100644 --- a/cake/libs/view/helpers/time.php +++ b/cake/libs/view/helpers/time.php @@ -282,7 +282,8 @@ class TimeHelper extends AppHelper { } /** - * Returns true if given datetime string is within this week + * Returns true if given datetime string is within this week. + * * @param string $dateString * @param int $userOffset User's offset from GMT (in hours) * @return boolean True if datetime string is within current week @@ -291,7 +292,7 @@ class TimeHelper extends AppHelper { */ public function isThisWeek($dateString, $userOffset = null) { $date = $this->fromString($dateString, $userOffset); - return date('W Y', $date) == date('W Y', time()); + return date('W o', $date) == date('W o', time()); } /**