3 namespace Doctrine\Tests\ORM\Functional;
5 require_once __DIR__ . '/../../TestInit.php';
8 * Functional Query tests.
12 class ReadOnlyTest extends \Doctrine\Tests\OrmFunctionalTestCase
14 protected function setUp()
19 $this->_schemaTool->createSchema(array(
20 $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\ReadOnlyEntity'),
22 } catch(\Exception $e) {
26 public function testReadOnlyEntityNeverChangeTracked()
28 $readOnly = new ReadOnlyEntity("Test1", 1234);
29 $this->_em->persist($readOnly);
32 $readOnly->name = "Test2";
33 $readOnly->numericValue = 4321;
38 $dbReadOnly = $this->_em->find('Doctrine\Tests\ORM\Functional\ReadOnlyEntity', $readOnly->id);
39 $this->assertEquals("Test1", $dbReadOnly->name);
40 $this->assertEquals(1234, $dbReadOnly->numericValue);
46 public function testClearReadOnly()
48 $readOnly = new ReadOnlyEntity("Test1", 1234);
49 $this->_em->persist($readOnly);
51 $this->_em->getUnitOfWork()->markReadOnly($readOnly);
55 $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly));
61 public function testClearEntitiesReadOnly()
63 $readOnly = new ReadOnlyEntity("Test1", 1234);
64 $this->_em->persist($readOnly);
66 $this->_em->getUnitOfWork()->markReadOnly($readOnly);
68 $this->_em->clear(get_class($readOnly));
70 $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly));
75 * @Entity(readOnly=true)
80 * @Id @GeneratedValue @Column(type="integer")
84 /** @column(type="string") */
86 /** @Column(type="integer") */
89 public function __construct($name, $number)
92 $this->numericValue = $number;