1
0
mirror of synced 2024-12-16 08:06:02 +03:00
doctrine2/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php

44 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace Doctrine\Tests\ORM\Functional;
use Doctrine\ORM\Proxy\ProxyFactory;
use Doctrine\ORM\Proxy\ProxyClassGenerator;
use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
require_once __DIR__ . '/../../TestInit.php';
/**
* Tests the generation of a proxy object for lazy loading.
* @author Giorgio Sironi <piccoloprincipeazzurro@gmail.com>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class ReferenceProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase
{
protected function setUp()
{
$this->useModelSet('ecommerce');
parent::setUp();
$this->_factory = new ProxyFactory(
$this->_em,
__DIR__ . '/../../Proxies',
'Doctrine\Tests\Proxies',
true);
}
public function testLazyLoadsFieldValuesFromDatabase()
{
$product = new ECommerceProduct();
$product->setName('Doctrine Cookbook');
2009-07-19 20:54:53 +04:00
$this->_em->persist($product);
$this->_em->flush();
$this->_em->clear();
2009-07-19 20:54:53 +04:00
$id = $product->getId();
$productProxy = $this->_factory->getProxy('Doctrine\Tests\Models\ECommerce\ECommerceProduct', array('id' => $id));
$this->assertEquals('Doctrine Cookbook', $productProxy->getName());
}
}