1
0
mirror of synced 2025-01-18 14:31:40 +03:00

Fix tickets #583 and #576

This commit is contained in:
jackbravo 2007-12-01 01:21:55 +00:00
parent 338bd78e66
commit a73a73da66
4 changed files with 96 additions and 3 deletions

View File

@ -436,10 +436,10 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
$data = array(); $data = array();
foreach ($this->getTable()->getFieldNames() as $fieldName) { foreach ($this->getTable()->getFieldNames() as $fieldName) {
if ( ! isset($tmp[$fieldName])) { if (isset($tmp[$fieldName])) {
$data[$fieldName] = self::$_null;
} else {
$data[$fieldName] = $tmp[$fieldName]; $data[$fieldName] = $tmp[$fieldName];
} else if (!isset($this->_data[$fieldName])) {
$data[$fieldName] = self::$_null;
} }
unset($tmp[$fieldName]); unset($tmp[$fieldName]);
} }

View File

@ -0,0 +1,52 @@
<?php
/**
* Doctrine_Ticket_587_TestCase
*
* @package Doctrine
* @author Joaquin Bravo <jackbravo@gmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_Ticket_576_TestCase extends Doctrine_UnitTestCase
{
public function prepareTables()
{
$this->tables = array('Entity');
parent::prepareTables();
}
public function prepareData() { }
public function testInit()
{
$entity = new Entity();
$entity->name = 'myname';
$entity->loginname = 'test';
$entity->save();
}
public function testBug()
{
// load our user and our collection of pages
$user = Doctrine_Query::create()->from('Entity')->fetchOne();
$this->assertEqual($user->name, 'myname');
$this->assertEqual($user->loginname, 'test');
$user->name = null;
$this->assertEqual($user->name, null);
$data = Doctrine_Query::create()
->select('name')
->from('Entity')
->fetchOne(array(), Doctrine::FETCH_ARRAY);
$user->hydrate($data);
$this->assertEqual($user->name, 'myname');
$this->assertEqual($user->loginname, 'test'); // <<----- this is what the bug is about
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Doctrine_Ticket_587_TestCase
*
* @package Doctrine
* @author Joaquin Bravo <jackbravo@gmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_Ticket_583_TestCase extends Doctrine_UnitTestCase
{
public function prepareTables()
{
$this->tables = array('Entity');
parent::prepareTables();
}
public function prepareData() { }
public function testBug()
{
$entity = new Entity();
$entity->name = 'myname';
$entity->save();
// load our user and our collection of pages
$user = Doctrine_Query::create()->select('id')->from('Entity')->fetchOne();
$this->assertEqual($user->name, 'myname');
// load our user and our collection of pages
$user = Doctrine_Query::create()->select('*')->from('Entity')->fetchOne();
$this->assertEqual($user->name, 'myname');
}
}

View File

@ -15,6 +15,8 @@ $tickets->addTestCase(new Doctrine_Ticket_Njero_TestCase());
$tickets->addTestCase(new Doctrine_Ticket_428_TestCase()); $tickets->addTestCase(new Doctrine_Ticket_428_TestCase());
$tickets->addTestCase(new Doctrine_Ticket_480_TestCase()); $tickets->addTestCase(new Doctrine_Ticket_480_TestCase());
$tickets->addTestCase(new Doctrine_Ticket_587_TestCase()); $tickets->addTestCase(new Doctrine_Ticket_587_TestCase());
$tickets->addTestCase(new Doctrine_Ticket_576_TestCase());
$tickets->addTestCase(new Doctrine_Ticket_583_TestCase());
//If you write a ticket testcase add it here like shown above! //If you write a ticket testcase add it here like shown above!
$test->addTestCase($tickets); $test->addTestCase($tickets);