1: <?php
2: class AMysql_TestCase extends PHPUnit_Framework_TestCase
3: {
4:
5: public $tableName = 'abstracttest';
6: protected $_amysql;
7:
8: public function setUp() {
9: if ('mysqli' == SQL_DRIVER) {
10: $this->_amysql = new AMysql(
11: AMYSQL_TEST_HOST . ':' . AMYSQL_TEST_PORT,
12: AMYSQL_TEST_USER,
13: AMYSQL_TEST_PASS
14: );
15: $this->_amysql->selectDb(AMYSQL_TEST_DB);
16: }
17: else if ('mysql' == SQL_DRIVER) {
18: if (
19: version_compare(PHP_VERSION, '5.5.0') >= 0 &&
20: function_exists('mysql_connect')
21: ) {
22: error_reporting(error_reporting() & ~E_DEPRECATED);
23: }
24: $conn = mysql_connect(AMYSQL_TEST_HOST, AMYSQL_TEST_USER,
25: AMYSQL_TEST_PASS);
26:
27: $this->_amysql = new AMysql($conn);
28: $this->_amysql->setConnDetails(array(
29: 'host' => AMYSQL_TEST_HOST,
30: 'port' => AMYSQL_TEST_PORT,
31: 'username' => AMYSQL_TEST_USER,
32: 'password' => AMYSQL_TEST_PASS,
33: 'driver' => 'mysql',
34: ));
35: $this->_amysql->selectDb(AMYSQL_TEST_DB);
36: }
37:
38: $this->createTable();
39: }
40:
41: public function createTable() {
42: $this->_amysql->query("DROP TABLE IF EXISTS `$this->tableName`");
43: $sql = <<<EOT
44: CREATE TABLE IF NOT EXISTS `$this->tableName` (
45: `id` int(11) NOT NULL AUTO_INCREMENT,
46: `string` varchar(255) NOT NULL DEFAULT '',
47: PRIMARY KEY (`id`)
48: ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
49: EOT;
50: $this->_amysql->query($sql);
51: }
52:
53: public function tearDown()
54: {
55: if ($this->_amysql) {
56: $this->_amysql->close();
57: $this->_amysql = null;
58: }
59: }
60: }
61: