From f6a5e7589396854e10e023c25237b47e512ff047 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 14 Apr 2006 11:23:56 +0000 Subject: Adding SQLMap unit tests. Allow sqlmap to use Prado's caching module to cache records. --- tests/unit/SQLMap/TAdodbConnectionTestCase.php | 63 ++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/unit/SQLMap/TAdodbConnectionTestCase.php (limited to 'tests/unit/SQLMap/TAdodbConnectionTestCase.php') diff --git a/tests/unit/SQLMap/TAdodbConnectionTestCase.php b/tests/unit/SQLMap/TAdodbConnectionTestCase.php new file mode 100644 index 00000000..df912c1b --- /dev/null +++ b/tests/unit/SQLMap/TAdodbConnectionTestCase.php @@ -0,0 +1,63 @@ +db_file = dirname(__FILE__).'/resources/test.db'; + copy($file,$this->db_file); + $provider = new TAdodbProvider(); + $provider->importAdodbLibrary(); + } + + function getDsn() + { + return 'sqlite://'.urlencode(realpath($this->db_file)); + } + + function testProviderCreation() + { + $provider = new TAdodbProvider(); + $connection = $provider->getConnection(); + $this->assertTrue($connection instanceof TAdodbConnection); + try + { + $connection->open(); + $this->fail(); + } + catch (TDbConnectionException $e) + { + $this->pass(); + } + } + + + + function testAdodbSqliteConnection() + { + $connection = new TAdodbConnection($this->getDsn()); + $this->assertTrue($connection->open()); + + $statement = "insert into person(per_id, per_first_name, + per_last_name, per_birth_date, per_weight_kg, per_height_m) + values(?, ?, ?, ?, ?, ?)"; + $sql = $connection->prepare($statement); + $connection->execute($sql, + array(2,'mini','me','2000-01-01', 50.5, 145.5)); + + $statement = "select * from person"; + $results = $connection->execute($statement); + $this->assertEquals($results->RecordCount(), 2); + + } +} + +?> \ No newline at end of file -- cgit v1.2.3