Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://git.zendframework.com/zf
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahar Evron committed Jul 25, 2010
6 parents b6f0f08 + a729860 + a4b177e + 5e10b10 + 0db5f75 + bcb7bb1 commit f7074c9
Show file tree
Hide file tree
Showing 45 changed files with 903 additions and 701 deletions.
31 changes: 18 additions & 13 deletions src/DbAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,24 @@
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\Test;

/**
* Testing Database Adapter which acts as a stack for SQL Results
*
* @uses Zend_Db_Adapter_Abstract
* @uses Zend_Db_Profiler
* @uses Zend_Test_DbStatement
* @uses \Zend\Db\Adapter\AbstractAdapter
* @uses \Zend\Db\Profiler\Profiler
* @uses \Zend\Test\DbStatement
* @category Zend
* @package Zend_Test
* @subpackage PHPUnit
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Test_DbAdapter extends Zend_Db_Adapter_Abstract
class DbAdapter extends \Zend\Db\Adapter\AbstractAdapter
{
/**
* @var array
Expand Down Expand Up @@ -69,18 +74,18 @@ class Zend_Test_DbAdapter extends Zend_Db_Adapter_Abstract
*/
public function __construct()
{
$profiler = new Zend_Db_Profiler();
$profiler = new \Zend\Db\Profiler();
$profiler->setEnabled(true);
$this->setProfiler($profiler);
}

/**
* Append a new Statement to the SQL Result Stack.
*
* @param Zend_Test_DbStatement $stmt
* @return Zend_Test_DbAdapter
* @param \Zend\Test\DbStatement $stmt
* @return \Zend\Test\DbAdapter
*/
public function appendStatementToStack(Zend_Test_DbStatement $stmt)
public function appendStatementToStack(DbStatement $stmt)
{
array_push($this->_statementStack, $stmt);
return $this;
Expand All @@ -90,7 +95,7 @@ public function appendStatementToStack(Zend_Test_DbStatement $stmt)
* Append a new Insert Id to the {@see lastInsertId}.
*
* @param int|string $id
* @return Zend_Test_DbAdapter
* @return \Zend\Test\DbAdapter
*/
public function appendLastInsertIdToStack($id)
{
Expand Down Expand Up @@ -140,7 +145,7 @@ public function listTables()
*
* @param string $table
* @param array $tableInfo
* @return Zend_Test_DbAdapter
* @return \Zend\Test\DbAdapter
*/
public function setDescribeTable($table, $tableInfo)
{
Expand Down Expand Up @@ -217,7 +222,7 @@ public function closeConnection()
/**
* Prepare a statement and return a PDOStatement-like object.
*
* @param string|Zend_Db_Select $sql SQL query
* @param string|\Zend\DB\Select $sql SQL query
* @return Zend_Db_Statment|PDOStatement
*/
public function prepare($sql)
Expand All @@ -227,7 +232,7 @@ public function prepare($sql)
if(count($this->_statementStack)) {
$stmt = array_pop($this->_statementStack);
} else {
$stmt = new Zend_Test_DbStatement();
$stmt = new DbStatement();
}

if($this->getProfiler()->getEnabled() == true) {
Expand Down Expand Up @@ -290,7 +295,7 @@ protected function _rollBack()
*
* @param integer $mode
* @return void
* @throws Zend_Db_Adapter_Exception
* @throws \Zend\Db\Adapter\Exception
*/
public function setFetchMode($mode)
{
Expand Down
66 changes: 36 additions & 30 deletions src/DbStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,24 @@
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\Test;
use Zend\Db\Statement;

/**
* Testing Database Statement that acts as a stack to SQL resultsets.
*
* @uses Zend_Db_Statement_Exception
* @uses Zend_Db_Statement_Interface
* @uses \Zend\Db\Statement\Exception
* @uses \Zend\Db\Statement
* @category Zend
* @package Zend_Test
* @subpackage PHPUnit
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Test_DbStatement implements Zend_Db_Statement_Interface
class DbStatement implements Statement
{
/**
* @var array
Expand All @@ -49,15 +55,15 @@ class Zend_Test_DbStatement implements Zend_Db_Statement_Interface
protected $_rowCount = 0;

/**
* @var Zend_Db_Profiler_Query
* @var \Zend\Db\Profiler\Query
*/
protected $_queryProfile = null;

/**
* Create a Select statement which returns the given array of rows.
*
* @param array $rows
* @return Zend_Test_DbStatement
* @return \Zend\Test\DbStatement
*/
static public function createSelectStatement(array $rows=array())
{
Expand All @@ -72,7 +78,7 @@ static public function createSelectStatement(array $rows=array())
* Create an Insert Statement
*
* @param int $affectedRows
* @return Zend_Test_DbStatement
* @return \Zend\Test\DbStatement
*/
static public function createInsertStatement($affectedRows=0)
{
Expand All @@ -83,7 +89,7 @@ static public function createInsertStatement($affectedRows=0)
* Create an Delete Statement
*
* @param int $affectedRows
* @return Zend_Test_DbStatement
* @return \Zend\Test\DbStatement
*/
static public function createDeleteStatement($affectedRows=0)
{
Expand All @@ -94,7 +100,7 @@ static public function createDeleteStatement($affectedRows=0)
* Create an Update Statement
*
* @param int $affectedRows
* @return Zend_Test_DbStatement
* @return \Zend\Test\DbStatement
*/
static public function createUpdateStatement($affectedRows=0)
{
Expand All @@ -105,7 +111,7 @@ static public function createUpdateStatement($affectedRows=0)
* Create a Row Count Statement
*
* @param int $affectedRows
* @return Zend_Test_DbStatement
* @return \Zend\Test\DbStatement
*/
static protected function _createRowCountStatement($affectedRows)
{
Expand All @@ -115,9 +121,9 @@ static protected function _createRowCountStatement($affectedRows)
}

/**
* @param Zend_Db_Profiler_Query $qp
* @param \Zend\Db\Profiler\Query $qp
*/
public function setQueryProfile(Zend_Db_Profiler_Query $qp)
public function setQueryProfile(\Zend\Db\Profiler\Query $qp)
{
$this->_queryProfile = $qp;
}
Expand Down Expand Up @@ -149,7 +155,7 @@ public function append($row)
* @param mixed $param Reference to the PHP variable containing the value.
* @param mixed $type OPTIONAL
* @return bool
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function bindColumn($column, &$param, $type = null)
{
Expand All @@ -165,7 +171,7 @@ public function bindColumn($column, &$param, $type = null)
* @param mixed $length OPTIONAL Length of SQL parameter.
* @param mixed $options OPTIONAL Other options.
* @return bool
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
{
Expand All @@ -182,7 +188,7 @@ public function bindParam($parameter, &$variable, $type = null, $length = null,
* @param mixed $value Scalar value to bind to the parameter.
* @param mixed $type OPTIONAL Datatype of the parameter.
* @return bool
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function bindValue($parameter, $value, $type = null)
{
Expand All @@ -193,7 +199,7 @@ public function bindValue($parameter, $value, $type = null)
* Closes the cursor, allowing the statement to be executed again.
*
* @return bool
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function closeCursor()
{
Expand All @@ -205,7 +211,7 @@ public function closeCursor()
* Returns null if the statement has no result set metadata.
*
* @return int The number of columns.
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function columnCount()
{
Expand All @@ -217,7 +223,7 @@ public function columnCount()
* the statement handle.
*
* @return string error code.
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function errorCode()
{
Expand All @@ -229,7 +235,7 @@ public function errorCode()
* last operation on the statement handle.
*
* @return array
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function errorInfo()
{
Expand All @@ -241,7 +247,7 @@ public function errorInfo()
*
* @param array $params OPTIONAL Values to bind to parameter placeholders.
* @return bool
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function execute(array $params = array())
{
Expand All @@ -259,7 +265,7 @@ public function execute(array $params = array())
* @param int $cursor OPTIONAL Absolute, relative, or other.
* @param int $offset OPTIONAL Number for absolute or relative cursors.
* @return mixed Array, object, or scalar depending on fetch mode.
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function fetch($style = null, $cursor = null, $offset = null)
{
Expand All @@ -277,7 +283,7 @@ public function fetch($style = null, $cursor = null, $offset = null)
* @param int $style OPTIONAL Fetch mode.
* @param int $col OPTIONAL Column number, if fetch mode is by column.
* @return array Collection of rows, each in a format by the fetch mode.
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function fetchAll($style = null, $col = null)
{
Expand All @@ -292,7 +298,7 @@ public function fetchAll($style = null, $col = null)
*
* @param int $col OPTIONAL Position of the column to fetch.
* @return string
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function fetchColumn($col = 0)
{
Expand All @@ -302,7 +308,7 @@ public function fetchColumn($col = 0)
return false;
} else {
if(count($row) < $col) {
throw new Zend_Db_Statement_Exception(
throw new Statement\Exception(
"Column Position '".$col."' is out of bounds."
);
}
Expand All @@ -318,12 +324,12 @@ public function fetchColumn($col = 0)
* @param string $class OPTIONAL Name of the class to create.
* @param array $config OPTIONAL Constructor arguments for the class.
* @return mixed One object instance of the specified class.
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function fetchObject($class = 'stdClass', array $config = array())
{
if(!class_exists($class)) {
throw new Zend_Db_Statement_Exception("Class '".$class."' does not exist!");
throw new Statement\Exception("Class '".$class."' does not exist!");
}

$object = new $class();
Expand All @@ -340,7 +346,7 @@ public function fetchObject($class = 'stdClass', array $config = array())
*
* @param string $key Attribute name.
* @return mixed Attribute value.
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function getAttribute($key)
{
Expand All @@ -353,7 +359,7 @@ public function getAttribute($key)
* the results of multiple queries.
*
* @return bool
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function nextRowset()
{
Expand All @@ -366,7 +372,7 @@ public function nextRowset()
* statement object.
*
* @return int The number of rows affected.
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function rowCount()
{
Expand All @@ -379,7 +385,7 @@ public function rowCount()
* @param string $key Attribute name.
* @param mixed $val Attribute value.
* @return bool
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function setAttribute($key, $val)
{
Expand All @@ -391,7 +397,7 @@ public function setAttribute($key, $val)
*
* @param int $mode The fetch mode.
* @return bool
* @throws Zend_Db_Statement_Exception
* @throws \Zend\Db\Statement\Exception
*/
public function setFetchMode($mode)
{
Expand Down
Loading

0 comments on commit f7074c9

Please sign in to comment.