| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/dbal/src/lmbDBAL.class.php'); 10 lmb_require('limb/dbal/src/drivers/lmbDbConnection.interface.php'); 11 lmb_require('limb/dbal/src/drivers/lmbDbQueryStatement.interface.php'); 12 13 Mock::generate('lmbDbConnection', 'MockDbConnection'); 14 Mock::generate('lmbDbQueryStatement', 'MockDbQueryStatement'); 15 16 class lmbDBALTest extends UnitTestCase 17 { 18 protected $toolkit; 19 protected $dsn; 20 protected $conn; 21 22 function setUp() 23 { 24 $this->toolkit = lmbToolkit :: save(); 25 $this->dsn = $this->toolkit->getDefaultDbDSN(); 26 $this->conn = new MockDbConnection(); 27 } 28 29 function tearDown() 30 { 31 lmbToolkit :: restore(); 32 } 33 34 function testSetDefaultDSN() 35 { 36 lmbDBAL :: setDefaultDSN($boo = new lmbObject()); 37 $this->assertEqual($this->toolkit->getDefaultDbDSN(), $boo); 38 } 39 40 function testNewConnection() 41 { 42 $conn = lmbDBAL :: newConnection($this->dsn); 43 $this->assertIsA($conn, 'lmbDbConnection'); 44 } 45 46 function testExecute() 47 { 48 $this->conn->expectOnce('execute', array($sql = 'SELECT 1=1')); 49 lmbDBAL :: execute($sql, $this->conn); 50 } 51 52 function testExecuteDefaultConnection() 53 { 54 $this->toolkit->setDefaultDbConnection($this->conn); 55 $this->conn->expectOnce('execute', array($sql = 'SELECT 1=1')); 56 lmbDBAL :: execute('SELECT 1=1'); 57 } 58 59 function testQuery() 60 { 61 $stmt = new MockDbQueryStatement(); 62 $this->conn->expectOnce('newStatement', array($sql = 'SELECT 1=1')); 63 $this->conn->setReturnValue('newStatement', $stmt, array($sql)); 64 $stmt->expectOnce('getRecordSet'); 65 $stmt->setReturnValue('getRecordSet', 'result'); 66 67 $rs = lmbDBAL :: query($sql, $this->conn); 68 $this->assertEqual($rs, 'result'); 69 } 70 71 function testQueryDefaultConnection() 72 { 73 $this->toolkit->setDefaultDbConnection($this->conn); 74 $stmt = new MockDbQueryStatement(); 75 $this->conn->expectOnce('newStatement', array($sql = 'SELECT 1=1')); 76 $this->conn->setReturnValue('newStatement', $stmt, array($sql)); 77 $stmt->expectOnce('getRecordSet'); 78 $stmt->setReturnValue('getRecordSet', 'result'); 79 80 $rs = lmbDBAL :: query($sql); 81 $this->assertEqual($rs, 'result'); 82 } 83 } 84 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Aug 29 04:49:26 2008 | Cross-referenced by PHPXref 0.7 |