StaticTest.php 3.2 KB

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