1
0
mirror of synced 2024-12-15 15:46:02 +03:00
doctrine2/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php
kwiateusz 49c735109c Change from assertType to assertInstanceOf.
Now PHPUnit doesn't show warning about deprecation of assertType.
Also some refractoring from assertTrue($a instanceof $b) to assertInstanceOf.
Leading \ in namespaces is not required so I removed it from few assertions.
2011-07-26 11:38:09 +02:00

70 lines
2.1 KiB
PHP

<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\ORM\Query;
require_once __DIR__ . '/../../../TestInit.php';
class DDC371Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC371Parent'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC371Child')
));
}
public function testIssue()
{
$parent = new DDC371Parent;
$parent->data = 'parent';
$parent->children = new \Doctrine\Common\Collections\ArrayCollection;
$child = new DDC371Child;
$child->data = 'child';
$child->parent = $parent;
$parent->children->add($child);
$this->_em->persist($parent);
$this->_em->persist($child);
$this->_em->flush();
$this->_em->clear();
$children = $this->_em->createQuery('select c,p from '.__NAMESPACE__.'\DDC371Child c '
. 'left join c.parent p where c.id = 1 and p.id = 1')
->setHint(Query::HINT_REFRESH, true)
->getResult();
$this->assertEquals(1, count($children));
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $children[0]->parent);
$this->assertFalse($children[0]->parent->children->isInitialized());
$this->assertEquals(0, $children[0]->parent->children->unwrap()->count());
}
}
/** @Entity */
class DDC371Child {
/** @Id @Column(type="integer") @GeneratedValue */
private $id;
/** @Column(type="string") */
public $data;
/** @ManyToOne(targetEntity="DDC371Parent", inversedBy="children") @JoinColumn(name="parentId") */
public $parent;
}
/** @Entity */
class DDC371Parent {
/** @Id @Column(type="integer") @GeneratedValue */
private $id;
/** @Column(type="string") */
public $data;
/** @OneToMany(targetEntity="DDC371Child", mappedBy="parent") */
public $children;
}