You are here

public function ProxyLogicTest::testLoadingWithPersisterWillBeTriggeredOnlyOnce in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyLogicTest.php \Doctrine\Tests\Common\Proxy\ProxyLogicTest::testLoadingWithPersisterWillBeTriggeredOnlyOnce()

File

vendor/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);
}