This commit is contained in:
parent
615dcdb84e
commit
378ed91ab6
@ -30,9 +30,11 @@
|
|||||||
* @since 1.0
|
* @since 1.0
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
|
class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase
|
||||||
|
{
|
||||||
|
|
||||||
public function testUnknownModule() {
|
public function testUnknownModule()
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
$this->connection->unknown;
|
$this->connection->unknown;
|
||||||
$this->fail();
|
$this->fail();
|
||||||
@ -40,14 +42,18 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
|
|||||||
$this->pass();
|
$this->pass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function testGetModule() {
|
|
||||||
|
public function testGetModule()
|
||||||
|
{
|
||||||
$this->assertTrue($this->connection->unitOfWork instanceof Doctrine_Connection_UnitOfWork);
|
$this->assertTrue($this->connection->unitOfWork instanceof Doctrine_Connection_UnitOfWork);
|
||||||
//$this->assertTrue($this->connection->dataDict instanceof Doctrine_DataDict);
|
//$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->transaction instanceof Doctrine_Transaction);
|
||||||
$this->assertTrue($this->connection->export instanceof Doctrine_Export);
|
$this->assertTrue($this->connection->export instanceof Doctrine_Export);
|
||||||
}
|
}
|
||||||
public function testFetchAll() {
|
|
||||||
|
public function testFetchAll()
|
||||||
|
{
|
||||||
$this->conn->exec('DROP TABLE entity');
|
$this->conn->exec('DROP TABLE entity');
|
||||||
$this->conn->exec('CREATE TABLE entity (id INT, name TEXT)');
|
$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');
|
$c = $this->conn->fetchOne('SELECT COUNT(1) FROM entity');
|
||||||
|
|
||||||
$this->assertEqual($c, 2);
|
$this->assertEqual($c, 2);
|
||||||
@ -80,10 +88,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
|
|||||||
$this->assertEqual($c, 1);
|
$this->assertEqual($c, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFetchAssoc() {
|
|
||||||
|
|
||||||
}
|
public function testFetchColumn()
|
||||||
public function testFetchColumn() {
|
{
|
||||||
$a = $this->conn->fetchColumn('SELECT * FROM entity');
|
$a = $this->conn->fetchColumn('SELECT * FROM entity');
|
||||||
|
|
||||||
$this->assertEqual($a, array (
|
$this->assertEqual($a, array (
|
||||||
@ -97,7 +104,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
|
|||||||
0 => '1',
|
0 => '1',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
public function testFetchArray() {
|
|
||||||
|
public function testFetchArray()
|
||||||
|
{
|
||||||
$a = $this->conn->fetchArray('SELECT * FROM entity');
|
$a = $this->conn->fetchArray('SELECT * FROM entity');
|
||||||
|
|
||||||
$this->assertEqual($a, array (
|
$this->assertEqual($a, array (
|
||||||
@ -112,14 +121,16 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
|
|||||||
1 => 'zYne',
|
1 => 'zYne',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
public function testFetchRow() {
|
|
||||||
|
public function testFetchRow()
|
||||||
|
{
|
||||||
$c = $this->conn->fetchRow('SELECT * FROM entity');
|
$c = $this->conn->fetchRow('SELECT * FROM entity');
|
||||||
|
|
||||||
$this->assertEqual($c, array (
|
$this->assertEqual($c, array (
|
||||||
'id' => '1',
|
'id' => '1',
|
||||||
'name' => 'zYne',
|
'name' => 'zYne',
|
||||||
));
|
));
|
||||||
|
|
||||||
$c = $this->conn->fetchRow('SELECT * FROM entity WHERE id = ?', array(1));
|
$c = $this->conn->fetchRow('SELECT * FROM entity WHERE id = ?', array(1));
|
||||||
|
|
||||||
$this->assertEqual($c, array (
|
$this->assertEqual($c, array (
|
||||||
@ -127,18 +138,26 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
|
|||||||
'name' => 'zYne',
|
'name' => 'zYne',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
public function testFetchPairs() {
|
|
||||||
|
public function testFetchPairs()
|
||||||
|
{
|
||||||
$this->conn->exec('DROP TABLE entity');
|
$this->conn->exec('DROP TABLE entity');
|
||||||
}
|
}
|
||||||
public function testGetManager() {
|
|
||||||
|
public function testGetManager()
|
||||||
|
{
|
||||||
$this->assertTrue($this->connection->getManager() === $this->manager);
|
$this->assertTrue($this->connection->getManager() === $this->manager);
|
||||||
}
|
}
|
||||||
public function testDelete() {
|
|
||||||
|
public function testDelete()
|
||||||
|
{
|
||||||
$user = $this->connection->create('User');
|
$user = $this->connection->create('User');
|
||||||
$this->connection->unitOfWork->delete($user);
|
$this->connection->unitOfWork->delete($user);
|
||||||
$this->assertEqual($user->state(),Doctrine_Record::STATE_TCLEAN);
|
$this->assertEqual($user->state(),Doctrine_Record::STATE_TCLEAN);
|
||||||
}
|
}
|
||||||
public function testGetTable() {
|
|
||||||
|
public function testGetTable()
|
||||||
|
{
|
||||||
$table = $this->connection->getTable('Group');
|
$table = $this->connection->getTable('Group');
|
||||||
$this->assertTrue($table instanceof Doctrine_Table);
|
$this->assertTrue($table instanceof Doctrine_Table);
|
||||||
try {
|
try {
|
||||||
@ -153,27 +172,41 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
|
|||||||
$this->assertTrue($table instanceof UserTable);
|
$this->assertTrue($table instanceof UserTable);
|
||||||
|
|
||||||
}
|
}
|
||||||
public function testCreate() {
|
|
||||||
|
public function testCreate()
|
||||||
|
{
|
||||||
$email = $this->connection->create('Email');
|
$email = $this->connection->create('Email');
|
||||||
$this->assertTrue($email instanceof 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)));
|
$this->assertTrue(is_integer(count($this->connection)));
|
||||||
}
|
}
|
||||||
public function testGetIterator() {
|
|
||||||
|
public function testGetIterator()
|
||||||
|
{
|
||||||
$this->assertTrue($this->connection->getIterator() instanceof ArrayIterator);
|
$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($this->connection->transaction->getState(),Doctrine_Transaction::STATE_SLEEP);
|
||||||
$this->assertEqual(Doctrine_Lib::getConnectionStateAsString($this->connection->transaction->getState()), 'open');
|
$this->assertEqual(Doctrine_Lib::getConnectionStateAsString($this->connection->transaction->getState()), 'open');
|
||||||
}
|
}
|
||||||
public function testGetTables() {
|
|
||||||
|
public function testGetTables()
|
||||||
|
{
|
||||||
$this->assertTrue(is_array($this->connection->getTables()));
|
$this->assertTrue(is_array($this->connection->getTables()));
|
||||||
}
|
}
|
||||||
public function testRollback() {
|
|
||||||
|
public function testRollback()
|
||||||
|
{
|
||||||
$this->connection->beginTransaction();
|
$this->connection->beginTransaction();
|
||||||
$this->assertEqual($this->connection->transaction->getTransactionLevel(),1);
|
$this->assertEqual($this->connection->transaction->getTransactionLevel(),1);
|
||||||
$this->assertEqual($this->connection->transaction->getState(), Doctrine_Transaction::STATE_ACTIVE);
|
$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->getState(), Doctrine_Transaction::STATE_SLEEP);
|
||||||
$this->assertEqual($this->connection->transaction->getTransactionLevel(),0);
|
$this->assertEqual($this->connection->transaction->getTransactionLevel(),0);
|
||||||
}
|
}
|
||||||
public function testNestedTransactions() {
|
|
||||||
|
public function testNestedTransactions()
|
||||||
|
{
|
||||||
$this->assertEqual($this->connection->transaction->getTransactionLevel(),0);
|
$this->assertEqual($this->connection->transaction->getTransactionLevel(),0);
|
||||||
$this->connection->beginTransaction();
|
$this->connection->beginTransaction();
|
||||||
$this->assertEqual($this->connection->transaction->getTransactionLevel(),1);
|
$this->assertEqual($this->connection->transaction->getTransactionLevel(),1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user