You are here

public function ProxyLogicTest::testLoadingWithPersisterWillBeTriggeredOnlyOnce in Plug 7

File

lib/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyLogicTest.php, line 286

Class

ProxyLogicTest
Test the generated proxies behavior. These tests make assumptions about the structure of LazyLoadableObject

Namespace

Doctrine\Tests\Common\Proxy

Code

public function testLoadingWithPersisterWillBeTriggeredOnlyOnce() {
  $this->proxyLoader
    ->expects($this
    ->once())
    ->method('load')
    ->with(array(
    'publicIdentifierField' => 'publicIdentifierFieldValue',
    'protectedIdentifierField' => 'protectedIdentifierFieldValue',
  ), $this->lazyObject)
    ->will($this
    ->returnCallback(function ($id, LazyLoadableObject $lazyObject) {

    // setting a value to verify that the persister can actually set something in the object
    $lazyObject->publicAssociation = $id['publicIdentifierField'] . '-test';
    return true;
  }));
  $this->lazyObject
    ->__setInitializer($this
    ->getSuggestedInitializerImplementation());
  $this->lazyObject
    ->__load();
  $this->lazyObject
    ->__load();
  $this
    ->assertSame('publicIdentifierFieldValue-test', $this->lazyObject->publicAssociation);
}