]> src.bluestatic.org Git - isso.git/blob - docs/UnitTest/DatabaseMySQLTest.php
Adding database unit tests and in the Db module, use a new DatabaseException class...
[isso.git] / docs / UnitTest / DatabaseMySQLTest.php
1 <?php
2
3 require_once 'PHPUnit/Framework.php';
4 require_once 'DatabaseTestAbstract.php';
5
6 class DatabaseMySQLTest extends DatabaseTestAbstract
7 {
8 public function setUp()
9 {
10 require_once 'tests.config.php';
11 require_once 'ISSO/Register.php';
12
13 $this->fixture = BSRegister::LoadModule('DbMySql');
14 $this->fixture->connect(TEST_DB_MYSQL_HOST, TEST_DB_MYSQL_USER, TEST_DB_MYSQL_PASSWORD, TEST_DB_MYSQL_DATABASE);
15 $this->fixture->query("
16 CREATE TABLE test
17 (
18 id int auto_increment,
19 textstuff varchar(255),
20 PRIMARY KEY (id)
21 )
22 ");
23 }
24
25 public function tearDown()
26 {
27 $this->fixture->query("DROP TABLE test");
28 $this->fixture = null;
29 }
30
31 public function testConnect()
32 {
33 try
34 {
35 BSRegister::LoadModule('DbMySql')->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--');
36 $this->fail('exception expected');
37 }
38 catch (BSDbException $e)
39 {}
40 }
41 }
42
43 ?>