FirebirdTest.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category ZendX
  16. * @package ZendX_Db
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. require_once 'Zend/Db/Table/Relationships/TestCommon.php';
  22. PHPUnit_Util_Filter::addFileToFilter(__FILE__);
  23. class ZendX_Db_Table_Relationships_FirebirdTest extends Zend_Db_Table_Relationships_TestCommon
  24. {
  25. public function testTableRelationshipFindParentRowSelect()
  26. {
  27. $bug_id = $this->_db->quoteIdentifier('bug_id', true);
  28. $account_name = $this->_db->foldCase('account_name');
  29. $table = $this->_table['bugs'];
  30. $select = $table->select()->where('"account_name" = ?', 'goofy');
  31. $childRows = $table->fetchAll("$bug_id = 1");
  32. $this->assertType('Zend_Db_Table_Rowset_Abstract', $childRows,
  33. 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($childRows));
  34. $childRow1 = $childRows->current();
  35. $this->assertType('Zend_Db_Table_Row_Abstract', $childRow1,
  36. 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($childRow1));
  37. $parentRow = $childRow1->findParentRow('Zend_Db_Table_TableAccounts', null, $select);
  38. $this->assertType('Zend_Db_Table_Row_Abstract', $parentRow,
  39. 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($parentRow));
  40. $this->assertEquals('goofy', $parentRow->$account_name);
  41. }
  42. public function testTableRelationshipMagicFindParentRowSelect()
  43. {
  44. $bug_id = $this->_db->quoteIdentifier('bug_id', true);
  45. $account_name = $this->_db->foldCase('account_name');
  46. $table = $this->_table['bugs'];
  47. $select = $table->select()->where('"account_name" = ?', 'goofy');
  48. $childRows = $table->fetchAll("$bug_id = 1");
  49. $this->assertType('Zend_Db_Table_Rowset_Abstract', $childRows,
  50. 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($childRows));
  51. $childRow1 = $childRows->current();
  52. $this->assertType('Zend_Db_Table_Row_Abstract', $childRow1,
  53. 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($childRow1));
  54. $parentRow = $childRow1->findParentZend_Db_Table_TableAccounts($select);
  55. $this->assertType('Zend_Db_Table_Row_Abstract', $parentRow,
  56. 'Expecting object of type Zend_Db_Table_Row_Abstract, got '.get_class($parentRow));
  57. $this->assertEquals('goofy', $parentRow->$account_name);
  58. }
  59. public function testTableRelationshipFindManyToManyRowsetSelect()
  60. {
  61. $product_name = $this->_db->foldCase('product_name');
  62. $bug_id = $this->_db->foldCase('"bug_id"');
  63. $table = $this->_table['bugs'];
  64. $select = $table->select()->where($bug_id . ' = ?', 1)
  65. ->limit(2)
  66. ->order($product_name . ' ASC');
  67. $originRows = $table->find(1);
  68. $originRow1 = $originRows->current();
  69. $destRows = $originRow1->findManyToManyRowset('Zend_Db_Table_TableProducts', 'Zend_Db_Table_TableBugsProducts',
  70. null, null, $select);
  71. $this->assertType('Zend_Db_Table_Rowset_Abstract', $destRows,
  72. 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($destRows));
  73. $this->assertEquals(2, $destRows->count());
  74. $childRow = $destRows->current();
  75. $this->assertEquals('Linux', $childRow->$product_name);
  76. }
  77. public function testTableRelationshipMagicFindManyToManyRowsetSelect()
  78. {
  79. $product_name = $this->_db->foldCase('product_name');
  80. $bug_id = $this->_db->foldCase('"bug_id"');
  81. $table = $this->_table['bugs'];
  82. $select = $table->select()->where($bug_id . ' = ?', 1)
  83. ->limit(2)
  84. ->order($product_name . ' ASC');
  85. $originRows = $table->find(1);
  86. $originRow1 = $originRows->current();
  87. $destRows = $originRow1->findZend_Db_Table_TableProductsViaZend_Db_Table_TableBugsProducts($select);
  88. $this->assertType('Zend_Db_Table_Rowset_Abstract', $destRows,
  89. 'Expecting object of type Zend_Db_Table_Rowset_Abstract, got '.get_class($destRows));
  90. $this->assertEquals(2, $destRows->count());
  91. $childRow = $destRows->current();
  92. $this->assertEquals('Linux', $childRow->$product_name);
  93. }
  94. public function getDriver()
  95. {
  96. return 'Firebird';
  97. }
  98. }