import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* @subpackage PHPUnit
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: DbAdapter.php 16911 2009-07-21 11:54:03Z matthew $
|
||||
* @version $Id: DbAdapter.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -30,6 +30,11 @@ require_once "Zend/Db/Adapter/Abstract.php";
|
||||
*/
|
||||
require_once "Zend/Test/DbStatement.php";
|
||||
|
||||
/**
|
||||
* @see Zend_Db_Profiler
|
||||
*/
|
||||
require_once 'Zend/Db/Profiler.php';
|
||||
|
||||
/**
|
||||
* Testing Database Adapter which acts as a stack for SQL Results
|
||||
*
|
||||
@ -71,7 +76,10 @@ class Zend_Test_DbAdapter extends Zend_Db_Adapter_Abstract
|
||||
* Empty constructor to make it parameterless.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
{
|
||||
$profiler = new Zend_Db_Profiler();
|
||||
$profiler->setEnabled(true);
|
||||
$this->setProfiler($profiler);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,7 +96,7 @@ class Zend_Test_DbAdapter extends Zend_Db_Adapter_Abstract
|
||||
|
||||
/**
|
||||
* Append a new Insert Id to the {@see lastInsertId}.
|
||||
*
|
||||
*
|
||||
* @param int|string $id
|
||||
* @return Zend_Test_DbAdapter
|
||||
*/
|
||||
@ -214,11 +222,20 @@ class Zend_Test_DbAdapter extends Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
public function prepare($sql)
|
||||
{
|
||||
$queryId = $this->getProfiler()->queryStart($sql);
|
||||
|
||||
if(count($this->_statementStack)) {
|
||||
return array_pop($this->_statementStack);
|
||||
$stmt = array_pop($this->_statementStack);
|
||||
} else {
|
||||
return new Zend_Test_DbStatement();
|
||||
$stmt = new Zend_Test_DbStatement();
|
||||
}
|
||||
|
||||
if($this->getProfiler()->getEnabled() == true) {
|
||||
$qp = $this->getProfiler()->getQueryProfile($queryId);
|
||||
$stmt->setQueryProfile($qp);
|
||||
}
|
||||
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -257,7 +274,7 @@ class Zend_Test_DbAdapter extends Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
protected function _commit()
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -301,7 +318,7 @@ class Zend_Test_DbAdapter extends Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
public function supportsParameters($type)
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage PHPUnit
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: DbStatement.php 16911 2009-07-21 11:54:03Z matthew $
|
||||
* @version $Id: DbStatement.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
require_once "Zend/Db/Statement/Interface.php";
|
||||
@ -48,9 +48,14 @@ class Zend_Test_DbStatement implements Zend_Db_Statement_Interface
|
||||
*/
|
||||
protected $_rowCount = 0;
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
@ -65,7 +70,7 @@ class Zend_Test_DbStatement implements Zend_Db_Statement_Interface
|
||||
|
||||
/**
|
||||
* Create an Insert Statement
|
||||
*
|
||||
*
|
||||
* @param int $affectedRows
|
||||
* @return Zend_Test_DbStatement
|
||||
*/
|
||||
@ -109,6 +114,14 @@ class Zend_Test_DbStatement implements Zend_Db_Statement_Interface
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Zend_Db_Profiler_Query $qp
|
||||
*/
|
||||
public function setQueryProfile(Zend_Db_Profiler_Query $qp)
|
||||
{
|
||||
$this->_queryProfile = $qp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $rowCount
|
||||
*/
|
||||
@ -156,6 +169,9 @@ class Zend_Test_DbStatement implements Zend_Db_Statement_Interface
|
||||
*/
|
||||
public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
|
||||
{
|
||||
if($this->_queryProfile !== null) {
|
||||
$this->_queryProfile->bindParam($parameter, $variable);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -229,6 +245,10 @@ class Zend_Test_DbStatement implements Zend_Db_Statement_Interface
|
||||
*/
|
||||
public function execute(array $params = array())
|
||||
{
|
||||
if($this->_queryProfile !== null) {
|
||||
$this->_queryProfile->bindParams($params);
|
||||
$this->_queryProfile->end();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
* @package Zend_Test
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: DomQuery.php 16874 2009-07-20 12:46:00Z mikaelkael $
|
||||
* @version $Id: DomQuery.php 18234 2009-09-18 14:06:43Z sgehrig $
|
||||
*/
|
||||
|
||||
/** PHPUnit_Framework_Constraint */
|
||||
@ -390,10 +390,14 @@ class Zend_Test_PHPUnit_Constraint_DomQuery extends PHPUnit_Framework_Constraint
|
||||
*/
|
||||
protected function _getNodeContent(DOMNode $node)
|
||||
{
|
||||
$doc = $node->ownerDocument;
|
||||
$content = $doc->saveXML($node);
|
||||
$tag = $node->nodeName;
|
||||
$regex = '|</?' . $tag . '[^>]*>|';
|
||||
return preg_replace($regex, '', $content);
|
||||
if ($node instanceof DOMAttr) {
|
||||
return $node->value;
|
||||
} else {
|
||||
$doc = $node->ownerDocument;
|
||||
$content = $doc->saveXML($node);
|
||||
$tag = $node->nodeName;
|
||||
$regex = '|</?' . $tag . '[^>]*>|';
|
||||
return preg_replace($regex, '', $content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
* @package Zend_Test
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ControllerTestCase.php 16874 2009-07-20 12:46:00Z mikaelkael $
|
||||
* @version $Id: ControllerTestCase.php 18605 2009-10-16 20:23:09Z matthew $
|
||||
*/
|
||||
|
||||
/** PHPUnit_Framework_TestCase */
|
||||
@ -141,7 +141,10 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
|
||||
{
|
||||
$this->reset();
|
||||
if (null !== $this->bootstrap) {
|
||||
if (is_callable($this->bootstrap)) {
|
||||
if ($this->bootstrap instanceof Zend_Application) {
|
||||
$this->bootstrap->bootstrap();
|
||||
$this->_frontController = $this->bootstrap->getBootstrap()->getResource('frontcontroller');
|
||||
} elseif (is_callable($this->bootstrap)) {
|
||||
call_user_func($this->bootstrap);
|
||||
} elseif (is_string($this->bootstrap)) {
|
||||
require_once 'Zend/Loader.php';
|
||||
@ -242,6 +245,10 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
|
||||
*/
|
||||
public function resetRequest()
|
||||
{
|
||||
if ($this->_request instanceof Zend_Controller_Request_HttpTestCase) {
|
||||
$this->_request->clearQuery()
|
||||
->clearPost();
|
||||
}
|
||||
$this->_request = null;
|
||||
return $this;
|
||||
}
|
||||
@ -905,7 +912,10 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
|
||||
{
|
||||
$this->_incrementAssertionCount();
|
||||
if ($module != $this->request->getModuleName()) {
|
||||
$msg = sprintf('Failed asserting last module used was "%s"', $module);
|
||||
$msg = sprintf('Failed asserting last module used <"%s"> was "%s"',
|
||||
$this->request->getModuleName(),
|
||||
$module
|
||||
);
|
||||
if (!empty($message)) {
|
||||
$msg = $message . "\n" . $msg;
|
||||
}
|
||||
@ -943,7 +953,10 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
|
||||
{
|
||||
$this->_incrementAssertionCount();
|
||||
if ($controller != $this->request->getControllerName()) {
|
||||
$msg = sprintf('Failed asserting last controller used was "%s"', $controller);
|
||||
$msg = sprintf('Failed asserting last controller used <"%s"> was "%s"',
|
||||
$this->request->getControllerName(),
|
||||
$controller
|
||||
);
|
||||
if (!empty($message)) {
|
||||
$msg = $message . "\n" . $msg;
|
||||
}
|
||||
@ -962,7 +975,10 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
|
||||
{
|
||||
$this->_incrementAssertionCount();
|
||||
if ($controller == $this->request->getControllerName()) {
|
||||
$msg = sprintf('Failed asserting last controller used was NOT "%s"', $controller);
|
||||
$msg = sprintf('Failed asserting last controller used <"%s"> was NOT "%s"',
|
||||
$this->request->getControllerName(),
|
||||
$controller
|
||||
);
|
||||
if (!empty($message)) {
|
||||
$msg = $message . "\n" . $msg;
|
||||
}
|
||||
@ -981,7 +997,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
|
||||
{
|
||||
$this->_incrementAssertionCount();
|
||||
if ($action != $this->request->getActionName()) {
|
||||
$msg = sprintf('Failed asserting last action used was "%s"', $action);
|
||||
$msg = sprintf('Failed asserting last action used <"%s"> was "%s"', $this->request->getActionName(), $action);
|
||||
if (!empty($message)) {
|
||||
$msg = $message . "\n" . $msg;
|
||||
}
|
||||
@ -1000,7 +1016,7 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
|
||||
{
|
||||
$this->_incrementAssertionCount();
|
||||
if ($action == $this->request->getActionName()) {
|
||||
$msg = sprintf('Failed asserting last action used was NOT "%s"', $action);
|
||||
$msg = sprintf('Failed asserting last action used <"%s"> was NOT "%s"', $this->request->getActionName(), $action);
|
||||
if (!empty($message)) {
|
||||
$msg = $message . "\n" . $msg;
|
||||
}
|
||||
@ -1020,7 +1036,10 @@ abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_Te
|
||||
$this->_incrementAssertionCount();
|
||||
$router = $this->frontController->getRouter();
|
||||
if ($route != $router->getCurrentRouteName()) {
|
||||
$msg = sprintf('Failed asserting route matched was "%s"', $route);
|
||||
$msg = sprintf('Failed asserting matched route was "%s", actual route is %s',
|
||||
$route,
|
||||
$router->getCurrentRouteName()
|
||||
);
|
||||
if (!empty($message)) {
|
||||
$msg = $message . "\n" . $msg;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage PHPUnit
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: DatabaseTestCase.php 16911 2009-07-21 11:54:03Z matthew $
|
||||
* @version $Id: DatabaseTestCase.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -76,7 +76,7 @@ abstract class Zend_Test_PHPUnit_DatabaseTestCase extends PHPUnit_Extensions_Dat
|
||||
|
||||
/**
|
||||
* Convenience function to get access to the database connection.
|
||||
*
|
||||
*
|
||||
* @return Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
protected function getAdapter()
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage PHPUnit
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Connection.php 16607 2009-07-09 21:51:46Z beberlei $
|
||||
* @version $Id: Connection.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -50,7 +50,7 @@ class Zend_Test_PHPUnit_Db_Connection extends PHPUnit_Extensions_Database_DB_Def
|
||||
{
|
||||
/**
|
||||
* Zend_Db_Adapter_Abstract
|
||||
*
|
||||
*
|
||||
* @var Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
protected $_connection;
|
||||
@ -71,7 +71,7 @@ class Zend_Test_PHPUnit_Db_Connection extends PHPUnit_Extensions_Database_DB_Def
|
||||
|
||||
/**
|
||||
* Construct Connection based on Zend_Db_Adapter_Abstract
|
||||
*
|
||||
*
|
||||
* @param Zend_Db_Adapter_Abstract $db
|
||||
* @param string $schema
|
||||
*/
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage PHPUnit
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: DbRowset.php 16607 2009-07-09 21:51:46Z beberlei $
|
||||
* @version $Id: DbRowset.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ class Zend_Test_PHPUnit_Db_DataSet_DbRowset extends PHPUnit_Extensions_Database_
|
||||
{
|
||||
/**
|
||||
* Construct Table object from a Zend_Db_Table_Rowset
|
||||
*
|
||||
*
|
||||
* @param Zend_Db_Table_Rowset_Abstract $rowset
|
||||
* @param string $tableName
|
||||
*/
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage PHPUnit
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: DbTable.php 16670 2009-07-12 13:35:45Z beberlei $
|
||||
* @version $Id: DbTable.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ class Zend_Test_PHPUnit_Db_DataSet_DbTable extends PHPUnit_Extensions_Database_D
|
||||
{
|
||||
/**
|
||||
* Zend_Db_Table object
|
||||
*
|
||||
*
|
||||
* @var Zend_Db_Table_Abstract
|
||||
*/
|
||||
protected $_table = null;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage PHPUnit
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 16607 2009-07-09 21:51:46Z beberlei $
|
||||
* @version $Id: Exception.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -37,5 +37,5 @@ require_once "Zend/Exception.php";
|
||||
*/
|
||||
class Zend_Test_PHPUnit_Db_Exception extends Zend_Exception
|
||||
{
|
||||
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
* @subpackage PHPUnit
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Generic.php 16607 2009-07-09 21:51:46Z beberlei $
|
||||
* @version $Id: Generic.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ class Zend_Test_PHPUnit_Db_Metadata_Generic implements PHPUnit_Extensions_Databa
|
||||
{
|
||||
/**
|
||||
* Zend_Db Connection
|
||||
*
|
||||
*
|
||||
* @var Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
protected $_connection;
|
||||
@ -55,7 +55,7 @@ class Zend_Test_PHPUnit_Db_Metadata_Generic implements PHPUnit_Extensions_Databa
|
||||
|
||||
/**
|
||||
* Cached Table metadata
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_tableMetadata = array();
|
||||
@ -75,7 +75,7 @@ class Zend_Test_PHPUnit_Db_Metadata_Generic implements PHPUnit_Extensions_Databa
|
||||
|
||||
/**
|
||||
* List Tables
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTableNames()
|
||||
@ -85,7 +85,7 @@ class Zend_Test_PHPUnit_Db_Metadata_Generic implements PHPUnit_Extensions_Databa
|
||||
|
||||
/**
|
||||
* Get Table information
|
||||
*
|
||||
*
|
||||
* @param string $tableName
|
||||
* @return array
|
||||
*/
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage PHPUnit
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Truncate.php 16607 2009-07-09 21:51:46Z beberlei $
|
||||
* @version $Id: Truncate.php 19106 2009-11-20 17:15:30Z beberlei $
|
||||
*/
|
||||
|
||||
require_once "PHPUnit/Extensions/Database/Operation/IDatabaseOperation.php";
|
||||
@ -58,10 +58,10 @@ class Zend_Test_PHPUnit_Db_Operation_Truncate implements PHPUnit_Extensions_Data
|
||||
throw new Zend_Test_PHPUnit_Db_Exception("Not a valid Zend_Test_PHPUnit_Db_Connection instance, ".get_class($connection)." given!");
|
||||
}
|
||||
|
||||
foreach ($dataSet as $table) {
|
||||
foreach ($dataSet->getReverseIterator() AS $table) {
|
||||
try {
|
||||
$tableName = $table->getTableMetaData()->getTableName();
|
||||
$this->truncate($connection->getConnection(), $tableName);
|
||||
$this->_truncate($connection->getConnection(), $tableName);
|
||||
} catch (Exception $e) {
|
||||
throw new PHPUnit_Extensions_Database_Operation_Exception('TRUNCATE', 'TRUNCATE '.$tableName.'', array(), $table, $e->getMessage());
|
||||
}
|
||||
@ -70,29 +70,49 @@ class Zend_Test_PHPUnit_Db_Operation_Truncate implements PHPUnit_Extensions_Data
|
||||
|
||||
/**
|
||||
* Truncate a given table.
|
||||
*
|
||||
*
|
||||
* @param Zend_Db_Adapter_Abstract $db
|
||||
* @param string $tableName
|
||||
* @return void
|
||||
*/
|
||||
private function truncate(Zend_Db_Adapter_Abstract $db, $tableName)
|
||||
protected function _truncate(Zend_Db_Adapter_Abstract $db, $tableName)
|
||||
{
|
||||
$tableName = $db->quoteIdentifier($tableName);
|
||||
if($db instanceof Zend_Db_Adapter_Pdo_Sqlite) {
|
||||
$db->query('DELETE FROM '.$tableName);
|
||||
} else if($db instanceof Zend_Db_Adapter_Db2) {
|
||||
if(strstr(PHP_OS, "WIN")) {
|
||||
/*if(strstr(PHP_OS, "WIN")) {
|
||||
$file = tempnam(sys_get_temp_dir(), "zendtestdbibm_");
|
||||
file_put_contents($file, "");
|
||||
$db->query('IMPORT FROM '.$file.' OF DEL REPLACE INTO '.$tableName);
|
||||
unlink($file);
|
||||
} else {
|
||||
$db->query('IMPORT FROM /dev/null OF DEL REPLACE INTO '.$tableName);
|
||||
}
|
||||
} else if($db instanceof Zend_Db_Adapter_Pdo_Mssql) {
|
||||
}*/
|
||||
require_once "Zend/Exception.php";
|
||||
throw Zend_Exception("IBM Db2 TRUNCATE not supported.");
|
||||
} else if($this->_isMssqlOrOracle($db)) {
|
||||
$db->query('TRUNCATE TABLE '.$tableName);
|
||||
} else if($db instanceof Zend_Db_Adapter_Pdo_Pgsql) {
|
||||
$db->query('TRUNCATE '.$tableName.' CASCADE');
|
||||
} else {
|
||||
$db->query('TRUNCATE '.$tableName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if an adapter is for Mssql or Oracle Databases.
|
||||
*
|
||||
* @param Zend_Db_Adapter_Abstract $db
|
||||
* @return bool
|
||||
*/
|
||||
private function _isMssqlOrOracle($db)
|
||||
{
|
||||
return (
|
||||
$db instanceof Zend_Db_Adapter_Pdo_Mssql ||
|
||||
$db instanceof Zend_Db_Adapter_Sqlsrv ||
|
||||
$db instanceof Zend_Db_Adapter_Pdo_Oci ||
|
||||
$db instanceof Zend_Db_Adapter_Oracle
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user