StaticTest.php 3.0 KB

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