Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAkvcaFEACgkQadOAzz84lo8VqwCfbjZcTW7rVFiKA05apLgETSeW
SHMAoJwgbW1Mr7oEYHvQpEr5tF3IP0sw
=NTlE
-----END PGP SIGNATURE-----
IMHO Zend_Db_TAble_Row object must know, what table it is using.
I suggest to provide such table before populating data there, using
setTable function.
Good luck.
--
Rafał (ert16) Trójniak
WEB : http://trojniak.net/
m@il : ert256@gmail.com
Jid : ert256@gmail.com
GPG key-ID : 3F38968F
4711 E3BC B674 C841 BED8
0F8F 69D3 80CF 3F38 968F
jeremykendall <jeremy@jeremykendall.net>
[Sat, 1 May 2010 08:46:26 -0700 (PDT)] :
>
> I'm getting some unexpected behavior from
> Zend_Db_Table_Row_Abstract::setFromArray(). If I instantiate a new row
> without passing any data and subsequently call setFromArray() to load
> data, Zend_Db_Table_Row::toArray() returns an empty array.
>
> I've never tried to instantiate a row in that manner in an application.
> I ran into this while writing some unit tests. I couldn't find a test
> in ZF that covered this use case, so I whipped one up to demonstrate the
> issue.
>
> Line 663 in Zend_Db_Table_Row_Abstract seems to be causing the issue
> (unless it's my improper use of the class that's the issue) when it calls
> array_intersect with an empty array as the second argument.
>
> Thoughts?
>
> <?php
>
> /**
> * Zend_Db_Table_Row test case.
> */
> class Kendall_Db_Table_Row_ZendRowTest extends
> PHPUnit_Framework_TestCase {
> /**
> * @var Zend_Db_Table_Row
> */
> private $_row;
>
> /**
> * @var array Initial dataset
> */
> private $_data = array();
>
> /**
> * Prepares the environment before running a test.
> */
> protected function setUp() {
>
> parent::setUp();
>
> $this->_data = array(
> 'row_one' => 1,
> 'row_two' => 2,
> 'row_three' => 3
> );
>
> $this->_row = new Zend_Db_Table_Row();
>
> }
>
> /**
> * Cleans up the environment after running a test.
> */
> protected function tearDown() {
> // TODO Auto-generated
> Kendall_Db_Table_Row_ZendRowTest::tearDown() $this->_row = null;
> parent::tearDown();
> }
>
> /**
> * Tests Zend_Db_Table_Row->setFromArray()
> *
> * Test fails with
> * 1) Kendall_Db_Table_Row_ZendRowTest::testSetFromArray
> * Failed asserting that <boolean:false> is true.
> */
> public function testSetFromArrayFailsToSetData() {
> $this->_row->setFromArray($this->_data);
> $this->assertTrue(array_key_exists('row_one',
> $this->_row->toArray()));
> }
>
> /**
> * Tests Zend_Db_Table_Row->setFromArray()
> *
> * This test passes.
> *
> * I think the problem is on
> Zend_Db_Table_Row_Abstract->setFromArray() line 663.
> * Calling array intersect on ($array, $emptyArray) always returns an
> empty array
> */
> public function testSetFromArrayReturnsEmptyArray() {
> $this->_row->setFromArray($this->_data);
> $this->assertEquals(0, count($this->_row->toArray()));
> }
>
> }
>
没有评论:
发表评论