You are here

public function ProxyLogicTest::testCloningCallsClonerWithClonedObject 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::testCloningCallsClonerWithClonedObject()

File

vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/ProxyLogicTest.php, line 232

Class

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

Namespace

Doctrine\Tests\Common\Proxy

Code

public function testCloningCallsClonerWithClonedObject() {
  $lazyObject = $this->lazyObject;
  $test = $this;
  $cb = $this
    ->getMock('stdClass', array(
    'cb',
  ));
  $cb
    ->expects($this
    ->once())
    ->method('cb')
    ->will($this
    ->returnCallback(function (LazyLoadableObject $proxy) use ($lazyObject, $test) {

    /* @var $proxy LazyLoadableObject|Proxy */
    $test
      ->assertNotSame($proxy, $lazyObject);
    $proxy
      ->__setInitializer(null);
    $proxy->publicAssociation = 'clonedAssociation';
  }));
  $this->lazyObject
    ->__setCloner($this
    ->getClosure(array(
    $cb,
    'cb',
  )));
  $cloned = clone $this->lazyObject;
  $this
    ->assertSame('clonedAssociation', $cloned->publicAssociation);
  $this
    ->assertNotSame($cloned, $lazyObject, 'a clone of the lazy object is retrieved');
}