*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Test / PHPUnit / Db / Operation / DeleteAll.php
blob9c2de4b77fc23af3c37afe6e4668f2a74e461306
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
16 * @package Zend_Test
17 * @subpackage PHPUnit
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: DeleteAll.php 16607 2009-07-09 21:51:46Z beberlei $
23 require_once "PHPUnit/Extensions/Database/Operation/IDatabaseOperation.php";
25 require_once "PHPUnit/Extensions/Database/DB/IDatabaseConnection.php";
27 require_once "PHPUnit/Extensions/Database/DataSet/IDataSet.php";
29 require_once "PHPUnit/Extensions/Database/Operation/Exception.php";
31 /**
32 * @see Zend_Test_PHPUnit_Db_Connection
34 require_once "Zend/Test/PHPUnit/Db/Connection.php";
36 /**
37 * Delete All Operation that can be executed on set up or tear down of a database tester.
39 * @uses PHPUnit_Extensions_Database_Operation_IDatabaseOperation
40 * @category Zend
41 * @package Zend_Test
42 * @subpackage PHPUnit
43 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
44 * @license http://framework.zend.com/license/new-bsd New BSD License
46 class Zend_Test_PHPUnit_Db_Operation_DeleteAll implements PHPUnit_Extensions_Database_Operation_IDatabaseOperation
48 /**
49 * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection
50 * @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet
52 public function execute(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
54 if(!($connection instanceof Zend_Test_PHPUnit_Db_Connection)) {
55 require_once "Zend/Test/PHPUnit/Db/Exception.php";
56 throw new Zend_Test_PHPUnit_Db_Exception("Not a valid Zend_Test_PHPUnit_Db_Connection instance, ".get_class($connection)." given!");
59 foreach ($dataSet as $table) {
60 try {
61 $tableName = $table->getTableMetaData()->getTableName();
62 $connection->getConnection()->delete($tableName);
63 } catch (Exception $e) {
64 require_once "PHPUnit/Extensions/Database/Operation/Exception.php";
65 throw new PHPUnit_Extensions_Database_Operation_Exception('DELETEALL', 'DELETE FROM '.$tableName.'', array(), $table, $e->getMessage());