MockHasResult.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Validate
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id $
  21. */
  22. /**
  23. * @see Zend_Db_Adapter_Abstract
  24. */
  25. require_once 'Zend/Db/Adapter/Abstract.php';
  26. /**
  27. * Mock Db adapter for Zend_Validate_Db tests
  28. *
  29. * @category Zend
  30. * @package Zend_Validate
  31. * @subpackage UnitTests
  32. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Db_MockHasResult extends Zend_Db_Adapter_Abstract
  36. {
  37. protected $_supportsParametersValues = array('named' => true, 'positional' => true);
  38. public function setSupportsParametersValues(array $supportsParametersValues)
  39. {
  40. $this->_supportsParametersValues = $supportsParametersValues;
  41. }
  42. /**
  43. * Returns an array to emulate a result
  44. *
  45. * @param string|Zend_Db_Select $sql An SQL SELECT statement.
  46. * @param mixed $bind Data to bind into SELECT placeholders.
  47. * @param mixed $fetchMode Override current fetch mode.
  48. * @return array
  49. */
  50. public function fetchRow($sql, $bind = array(), $fetchMode = null)
  51. {
  52. return array('one' => 'one');
  53. }
  54. /**
  55. * Override for the constructor
  56. * @param array $config
  57. */
  58. public function __construct($config = null)
  59. {
  60. // Do Nothing.
  61. }
  62. /**
  63. * The below methods are un-needed, but need to be implemented for this to
  64. * be a concrete class
  65. */
  66. public function listTables()
  67. {
  68. return null;
  69. }
  70. public function describeTable($tableName, $schemaName = null)
  71. {
  72. return null;
  73. }
  74. protected function _connect()
  75. {
  76. return null;
  77. }
  78. public function isConnected()
  79. {
  80. return null;
  81. }
  82. public function closeConnection()
  83. {
  84. return null;
  85. }
  86. public function prepare($sql)
  87. {
  88. return null;
  89. }
  90. public function lastInsertId($tableName = null, $primaryKey = null)
  91. {
  92. return null;
  93. }
  94. protected function _beginTransaction()
  95. {
  96. return null;
  97. }
  98. protected function _commit()
  99. {
  100. return null;
  101. }
  102. protected function _rollBack()
  103. {
  104. return null;
  105. }
  106. public function setFetchMode($mode)
  107. {
  108. return null;
  109. }
  110. public function limit($sql, $count, $offset = 0)
  111. {
  112. return null;
  113. }
  114. public function supportsParameters($type)
  115. {
  116. if (in_array($type, $this->_supportsParametersValues)) {
  117. return $this->_supportsParametersValues[$type];
  118. }
  119. return false;
  120. }
  121. public function getServerVersion()
  122. {
  123. return null;
  124. }
  125. }