|
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_Test |
|
17 * @subpackage PHPUnit |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id: SimpleTester.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 /** |
|
24 * @see PHPUnit_Extensions_Database_DefaultTester |
|
25 */ |
|
26 require_once "PHPUnit/Extensions/Database/DefaultTester.php"; |
|
27 |
|
28 /** |
|
29 * @see PHPUnit_Extensions_Database_DB_IDatabaseConnection |
|
30 */ |
|
31 require_once "PHPUnit/Extensions/Database/DB/IDatabaseConnection.php"; |
|
32 |
|
33 /** |
|
34 * @see Zend_Test_PHPUnit_Db_Operation_Truncate |
|
35 */ |
|
36 require_once "Zend/Test/PHPUnit/Db/Operation/Truncate.php"; |
|
37 |
|
38 /** |
|
39 * @see Zend_Test_PHPUnit_Db_Operation_Insert |
|
40 */ |
|
41 require_once "Zend/Test/PHPUnit/Db/Operation/Insert.php"; |
|
42 |
|
43 /** |
|
44 * @see PHPUnit_Extensions_Database_Operation_Factory |
|
45 */ |
|
46 require_once "PHPUnit/Extensions/Database/Operation/Factory.php"; |
|
47 |
|
48 /** |
|
49 * @see PHPUnit_Extensions_Database_DataSet_IDataSet |
|
50 */ |
|
51 require_once "PHPUnit/Extensions/Database/DataSet/IDataSet.php"; |
|
52 |
|
53 /** |
|
54 * Simple Tester for Database Tests when the Abstract Test Case cannot be used. |
|
55 * |
|
56 * @uses PHPUnit_Extensions_Database_DefaultTester |
|
57 * @category Zend |
|
58 * @package Zend_Test |
|
59 * @subpackage PHPUnit |
|
60 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
61 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
62 */ |
|
63 class Zend_Test_PHPUnit_Db_SimpleTester extends PHPUnit_Extensions_Database_DefaultTester |
|
64 { |
|
65 /** |
|
66 * Creates a new default database tester using the given connection. |
|
67 * |
|
68 * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection |
|
69 */ |
|
70 public function __construct(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection) |
|
71 { |
|
72 if(!($connection instanceof Zend_Test_PHPUnit_Db_Connection)) { |
|
73 require_once "Zend/Test/PHPUnit/Db/Exception.php"; |
|
74 throw new Zend_Test_PHPUnit_Db_Exception("Not a valid Zend_Test_PHPUnit_Db_Connection instance, ".get_class($connection)." given!"); |
|
75 } |
|
76 |
|
77 $this->connection = $connection; |
|
78 $this->setUpOperation = new PHPUnit_Extensions_Database_Operation_Composite(array( |
|
79 new Zend_Test_PHPUnit_Db_Operation_Truncate(), |
|
80 new Zend_Test_PHPUnit_Db_Operation_Insert(), |
|
81 )); |
|
82 $this->tearDownOperation = PHPUnit_Extensions_Database_Operation_Factory::NONE(); |
|
83 } |
|
84 |
|
85 /** |
|
86 * Set Up the database using the given Dataset and the SetUp strategy "Truncate, then Insert" |
|
87 * |
|
88 * @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet |
|
89 */ |
|
90 public function setUpDatabase(PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet) |
|
91 { |
|
92 $this->setDataSet($dataSet); |
|
93 $this->onSetUp(); |
|
94 } |
|
95 } |