StaticTest.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 Zend
  16. * @package Zend_Db
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. require_once 'PHPUnit/Framework/TestCase.php';
  22. require_once 'PHPUnit/Util/Filter.php';
  23. PHPUnit_Util_Filter::addFileToFilter(__FILE__);
  24. /**
  25. * @see Zend_Db_Table_Row_TestMockRow
  26. */
  27. require_once dirname(__FILE__) . '/../_files/My/ZendDbTable/Row/TestMockRow.php';
  28. class Zend_Db_Table_Row_StaticTest extends PHPUnit_Framework_TestCase
  29. {
  30. public function testTableRowTransformColumnNotUsedInConstructor()
  31. {
  32. $data = array(
  33. 'column' => 'value1',
  34. 'column_foo' => 'value2',
  35. 'column_bar_baz' => 'value3'
  36. );
  37. $row = new My_ZendDbTable_Row_TestMockRow(array('data' => $data));
  38. $array = $row->toArray();
  39. $this->assertEquals($data, $array);
  40. }
  41. public function testTableRowTransformColumnMagicGet()
  42. {
  43. $data = array(
  44. 'column' => 'value1',
  45. 'column_foo' => 'value2',
  46. 'column_bar_baz' => 'value3'
  47. );
  48. $row = new My_ZendDbTable_Row_TestMockRow(array('data' => $data));
  49. $this->assertEquals('value1', $row->column);
  50. $this->assertEquals('value2', $row->columnFoo);
  51. $this->assertEquals('value3', $row->columnBarBaz);
  52. }
  53. public function testTableRowTransformColumnMagicSet()
  54. {
  55. $data = array(
  56. 'column' => 'value1',
  57. 'column_foo' => 'value2',
  58. 'column_bar_baz' => 'value3'
  59. );
  60. $row = new My_ZendDbTable_Row_TestMockRow(array('data' => $data));
  61. $this->assertEquals('value1', $row->column);
  62. $this->assertEquals('value2', $row->columnFoo);
  63. $this->assertEquals('value3', $row->columnBarBaz);
  64. $row->column = 'another value 1';
  65. $row->columnFoo = 'another value 2';
  66. $row->columnBarBaz = 'another value 3';
  67. $array = $row->toArray();
  68. $this->assertEquals(
  69. array(
  70. 'column' => 'another value 1',
  71. 'column_foo' => 'another value 2',
  72. 'column_bar_baz' => 'another value 3'
  73. ), $array);
  74. }
  75. public function getDriver()
  76. {
  77. return 'Static';
  78. }
  79. }