<commit_before><?php


namespace Doctrine\Tests\ORM\Functional;


use Doctrine\ORM\Proxy\Proxy;
use Doctrine\ORM\Tools\ToolsException;

class MergeUninitializedProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase {

    protected function setUp()
    {
        parent::setUp();

        try {
            $this->_schemaTool->createSchema(array(
                    $this->_em->getClassMetadata(__NAMESPACE__ . '\MUPFile'),
                    $this->_em->getClassMetadata(__NAMESPACE__ . '\MUPPicture'),
                ));
        } catch (ToolsException $ignored) {
        }
    }

    public function testMergeDetachedUnInitializedProxy()
    {
        $detachedUninitialized = $this->_em->getReference(MUPFile::CLASSNAME, 123);

        $this->_em->clear();

        $managed = $this->_em->getReference(MUPFile::CLASSNAME, 123);

        $this->assertSame($managed, $this->_em->merge($detachedUninitialized));

        $this->assertFalse($managed->__isInitialized());
        $this->assertFalse($detachedUninitialized->__isInitialized());
    }

    public function testMergeUnserializedUnInitializedProxy()
    {
        $detachedUninitialized = $this->_em->getReference(MUPFile::CLASSNAME, 123);

        $this->_em->clear();

        $managed = $this->_em->getReference(MUPFile::CLASSNAME, 123);

        $this->assertSame(
            $managed,
            $this->_em->merge(unserialize(serialize($this->_em->merge($detachedUninitialized))))
        );

        $this->assertFalse($managed->__isInitialized());
        $this->assertFalse($detachedUninitialized->__isInitialized());
    }

    public function testMergeUnserializedIntoEntity() {

        $file = new MUPFile;

        $picture = new MUPPicture;
        $picture->file = $file;

        $em = $this->_em;
        $em->persist($picture);<commit_msg>#1172 - covering merging of managed proxies<commit_after><?php


namespace Doctrine\Tests\ORM\Functional;


use Doctrine\ORM\Proxy\Proxy;
use Doctrine\ORM\Tools\ToolsException;

class MergeUninitializedProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase {

    protected function setUp()
    {
        parent::setUp();

        try {
            $this->_schemaTool->createSchema(array(
                    $this->_em->getClassMetadata(__NAMESPACE__ . '\MUPFile'),
                    $this->_em->getClassMetadata(__NAMESPACE__ . '\MUPPicture'),
                ));
        } catch (ToolsException $ignored) {
        }
    }

    public function testMergeDetachedUnInitializedProxy()
    {
        $detachedUninitialized = $this->_em->getReference(MUPFile::CLASSNAME, 123);

        $this->_em->clear();

        $managed = $this->_em->getReference(MUPFile::CLASSNAME, 123);

        $this->assertSame($managed, $this->_em->merge($detachedUninitialized));

        $this->assertFalse($managed->__isInitialized());
        $this->assertFalse($detachedUninitialized->__isInitialized());
    }

    public function testMergeUnserializedUnInitializedProxy()
    {
        $detachedUninitialized = $this->_em->getReference(MUPFile::CLASSNAME, 123);

        $this->_em->clear();

        $managed = $this->_em->getReference(MUPFile::CLASSNAME, 123);

        $this->assertSame(
            $managed,
            $this->_em->merge(unserialize(serialize($this->_em->merge($detachedUninitialized))))
        );

        $this->assertFalse($managed->__isInitialized());
        $this->assertFalse($detachedUninitialized->__isInitialized());
    }

    public function testMergeManagedProxy()
    {
        $managed = $this->_em->getReference(MUPFile::CLASSNAME, 123);

        $this->assertSame($managed, $this->_em->merge($managed));

        $this->assertFalse($managed->__isInitialized());
    }

    public function testMergeUnserializedIntoEntity() {

        $file = new MUPFile;

        $picture = new MUPPicture;
        $picture->file = $file;

        $em = $this->_em;
        $em->persist($picture);
{'fraction_non_alphanumeric': 0.14496439471007122, 'fraction_numerical': 0.007884028484231942, 'mean_word_length': 2.894059405940594, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 84, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '982266', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1112, 'n_words': 147}