From 378ed91ab6ebafde7d361aa8192aaa691a878a1d Mon Sep 17 00:00:00 2001 From: zYne Date: Thu, 5 Jul 2007 21:16:28 +0000 Subject: [PATCH] --- tests/ConnectionTestCase.php | 85 +++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 25 deletions(-) diff --git a/tests/ConnectionTestCase.php b/tests/ConnectionTestCase.php index b9980d23b..3519605e2 100644 --- a/tests/ConnectionTestCase.php +++ b/tests/ConnectionTestCase.php @@ -30,9 +30,11 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase { +class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase +{ - public function testUnknownModule() { + public function testUnknownModule() + { try { $this->connection->unknown; $this->fail(); @@ -40,14 +42,18 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase { $this->pass(); } } - public function testGetModule() { + + public function testGetModule() + { $this->assertTrue($this->connection->unitOfWork instanceof Doctrine_Connection_UnitOfWork); //$this->assertTrue($this->connection->dataDict instanceof Doctrine_DataDict); - $this->assertTrue($this->connection->expression instanceof Doctrine_Expression); + $this->assertTrue($this->connection->expression instanceof Doctrine_Expression_Driver); $this->assertTrue($this->connection->transaction instanceof Doctrine_Transaction); $this->assertTrue($this->connection->export instanceof Doctrine_Export); } - public function testFetchAll() { + + public function testFetchAll() + { $this->conn->exec('DROP TABLE entity'); $this->conn->exec('CREATE TABLE entity (id INT, name TEXT)'); @@ -70,7 +76,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase { ), )); } - public function testFetchOne() { + + public function testFetchOne() + { $c = $this->conn->fetchOne('SELECT COUNT(1) FROM entity'); $this->assertEqual($c, 2); @@ -80,10 +88,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($c, 1); } - public function testFetchAssoc() { - } - public function testFetchColumn() { + public function testFetchColumn() + { $a = $this->conn->fetchColumn('SELECT * FROM entity'); $this->assertEqual($a, array ( @@ -97,7 +104,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase { 0 => '1', )); } - public function testFetchArray() { + + public function testFetchArray() + { $a = $this->conn->fetchArray('SELECT * FROM entity'); $this->assertEqual($a, array ( @@ -112,14 +121,16 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase { 1 => 'zYne', )); } - public function testFetchRow() { + + public function testFetchRow() + { $c = $this->conn->fetchRow('SELECT * FROM entity'); $this->assertEqual($c, array ( 'id' => '1', 'name' => 'zYne', )); - + $c = $this->conn->fetchRow('SELECT * FROM entity WHERE id = ?', array(1)); $this->assertEqual($c, array ( @@ -127,18 +138,26 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase { 'name' => 'zYne', )); } - public function testFetchPairs() { + + public function testFetchPairs() + { $this->conn->exec('DROP TABLE entity'); } - public function testGetManager() { + + public function testGetManager() + { $this->assertTrue($this->connection->getManager() === $this->manager); } - public function testDelete() { + + public function testDelete() + { $user = $this->connection->create('User'); $this->connection->unitOfWork->delete($user); $this->assertEqual($user->state(),Doctrine_Record::STATE_TCLEAN); } - public function testGetTable() { + + public function testGetTable() + { $table = $this->connection->getTable('Group'); $this->assertTrue($table instanceof Doctrine_Table); try { @@ -153,27 +172,41 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase { $this->assertTrue($table instanceof UserTable); } - public function testCreate() { + + public function testCreate() + { $email = $this->connection->create('Email'); $this->assertTrue($email instanceof Email); } - public function testGetDbh() { - $this->assertTrue($this->connection->getDBH() instanceof Doctrine_Db); + + public function testGetDbh() + { + $this->assertTrue($this->connection->getDbh() instanceof PDO); } - public function testCount() { + + public function testCount() + { $this->assertTrue(is_integer(count($this->connection))); } - public function testGetIterator() { + + public function testGetIterator() + { $this->assertTrue($this->connection->getIterator() instanceof ArrayIterator); } - public function testGetState() { + + public function testGetState() + { $this->assertEqual($this->connection->transaction->getState(),Doctrine_Transaction::STATE_SLEEP); $this->assertEqual(Doctrine_Lib::getConnectionStateAsString($this->connection->transaction->getState()), 'open'); } - public function testGetTables() { + + public function testGetTables() + { $this->assertTrue(is_array($this->connection->getTables())); } - public function testRollback() { + + public function testRollback() + { $this->connection->beginTransaction(); $this->assertEqual($this->connection->transaction->getTransactionLevel(),1); $this->assertEqual($this->connection->transaction->getState(), Doctrine_Transaction::STATE_ACTIVE); @@ -181,7 +214,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($this->connection->transaction->getState(), Doctrine_Transaction::STATE_SLEEP); $this->assertEqual($this->connection->transaction->getTransactionLevel(),0); } - public function testNestedTransactions() { + + public function testNestedTransactions() + { $this->assertEqual($this->connection->transaction->getTransactionLevel(),0); $this->connection->beginTransaction(); $this->assertEqual($this->connection->transaction->getTransactionLevel(),1);