File indexing completed on 2025-02-23 05:32:49
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Test 0017 * @subpackage PHPUnit 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @see Zend_Test_PHPUnit_Db_Operation_Truncate 0025 */ 0026 // require_once "Zend/Test/PHPUnit/Db/Operation/Truncate.php"; 0027 0028 /** 0029 * @see Zend_Test_PHPUnit_Db_Operation_Insert 0030 */ 0031 // require_once "Zend/Test/PHPUnit/Db/Operation/Insert.php"; 0032 0033 /** 0034 * Simple Tester for Database Tests when the Abstract Test Case cannot be used. 0035 * 0036 * @uses PHPUnit_Extensions_Database_DefaultTester 0037 * @category Zend 0038 * @package Zend_Test 0039 * @subpackage PHPUnit 0040 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0041 * @license http://framework.zend.com/license/new-bsd New BSD License 0042 */ 0043 class Zend_Test_PHPUnit_Db_SimpleTester extends PHPUnit_Extensions_Database_DefaultTester 0044 { 0045 /** 0046 * Creates a new default database tester using the given connection. 0047 * 0048 * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection 0049 */ 0050 public function __construct(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection) 0051 { 0052 if(!($connection instanceof Zend_Test_PHPUnit_Db_Connection)) { 0053 // require_once "Zend/Test/PHPUnit/Db/Exception.php"; 0054 throw new Zend_Test_PHPUnit_Db_Exception("Not a valid Zend_Test_PHPUnit_Db_Connection instance, ".get_class($connection)." given!"); 0055 } 0056 0057 $this->connection = $connection; 0058 $this->setUpOperation = new PHPUnit_Extensions_Database_Operation_Composite(array( 0059 new Zend_Test_PHPUnit_Db_Operation_Truncate(), 0060 new Zend_Test_PHPUnit_Db_Operation_Insert(), 0061 )); 0062 $this->tearDownOperation = PHPUnit_Extensions_Database_Operation_Factory::NONE(); 0063 } 0064 0065 /** 0066 * Set Up the database using the given Dataset and the SetUp strategy "Truncate, then Insert" 0067 * 0068 * @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet 0069 */ 0070 public function setUpDatabase(PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet) 0071 { 0072 $this->setDataSet($dataSet); 0073 $this->onSetUp(); 0074 } 0075 }