1
0
mirror of synced 2025-02-20 06:03:15 +03:00

added failing test for refresh with eager fetching

This commit is contained in:
Johannes M. Schmitt 2012-07-26 12:54:40 +02:00
parent 1eaa822d2a
commit fc4a07c2b3

View File

@ -21,6 +21,7 @@ class OneToOneEagerLoadingTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainDriver'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOwner'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Waggon'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOrder'),
));
} catch(\Exception $e) {}
}
@ -181,6 +182,21 @@ class OneToOneEagerLoadingTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql']
);
}
public function testEagerLoadingDoesNotBreakRefresh()
{
$train = new Train(new TrainOwner('Johannes'));
$order = new TrainOrder($train);
$this->_em->persist($train);
$this->_em->persist($order);
$this->_em->flush();
$this->_em->getConnection()->exec("UPDATE TrainOrder SET train_id = NULL");
$this->assertSame($train, $order->train);
$this->_em->refresh($order);
$this->assertNull($order->train);
}
}
/**
@ -305,3 +321,20 @@ class Waggon
$this->train = $train;
}
}
/**
* @Entity
*/
class TrainOrder
{
/** @id @generatedValue @column(type="integer") */
public $id;
/** @OneToOne(targetEntity = "Train", fetch = "EAGER") */
public $train;
public function __construct(Train $train)
{
$this->train = $train;
}
}