FirebirdTest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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/Row/TestCommon.php';
  22. PHPUnit_Util_Filter::addFileToFilter(__FILE__);
  23. class ZendX_Db_Table_Row_FirebirdTest extends Zend_Db_Table_Row_TestCommon
  24. {
  25. public function testTableRowSetReadOnly()
  26. {
  27. $table = $this->_table['bugs'];
  28. $bug_status = $this->_db->foldCase('bug_status');
  29. $rowset = $table->find(1);
  30. $row1 = $rowset->current();
  31. $row1->setReadOnly(true);
  32. $this->assertTrue($row1->isReadOnly());
  33. $data = array(
  34. 'bug_id' => $this->_db->nextSequenceId('zfbugs_seq'),
  35. 'bug_description' => 'New Description',
  36. 'bug_status' => 'INVALID'
  37. );
  38. $row2 = $table->createRow($data);
  39. $row2->setReadOnly(true);
  40. try {
  41. $row2->save();
  42. $this->fail('Expected to catch Zend_Db_Table_Row_Exception');
  43. } catch (Zend_Exception $e) {
  44. $this->assertType('Zend_Db_Table_Row_Exception', $e,
  45. 'Expecting object of type Zend_Db_Table_Row_Exception, got '.get_class($e));
  46. $this->assertEquals('This row has been marked read-only', $e->getMessage());
  47. }
  48. $row2->setReadOnly(false);
  49. $row2->save();
  50. $row2->$bug_status = 'VALID';
  51. $row2->setReadOnly(true);
  52. try {
  53. $row2->save();
  54. $this->fail('Expected to catch Zend_Db_Table_Row_Exception');
  55. } catch (Zend_Exception $e) {
  56. $this->assertType('Zend_Db_Table_Row_Exception', $e,
  57. 'Expecting object of type Zend_Db_Table_Row_Exception, got '.get_class($e));
  58. $this->assertEquals('This row has been marked read-only', $e->getMessage());
  59. }
  60. $row2->setReadOnly(false);
  61. $row2->save();
  62. }
  63. public function testTableRowSaveInsert()
  64. {
  65. $table = $this->_table['bugs'];
  66. $data = array(
  67. 'bug_description' => 'New Description',
  68. 'bug_status' => 'INVALID'
  69. );
  70. try {
  71. $row3 = $table->createRow($data);
  72. $this->assertNull($row3->bug_id);
  73. $row3->bug_id = $this->_db->nextSequenceId('zfbugs_seq');
  74. $row3->save();
  75. $this->assertEquals(5, $row3->bug_id);
  76. $this->assertEquals($data['bug_description'], $row3->bug_description);
  77. $this->assertEquals($data['bug_status'], $row3->bug_status);
  78. } catch (Zend_Exception $e) {
  79. $this->fail("Caught exception of type \"".get_class($e)."\" where no exception was expected. Exception message: \"".$e->getMessage()."\"\n");
  80. }
  81. }
  82. public function getDriver()
  83. {
  84. return 'Firebird';
  85. }
  86. }