1
0
mirror of synced 2025-01-19 06:51:40 +03:00
doctrine2/tests/Orm/Functional/BasicCRUDTest.php

57 lines
1.4 KiB
PHP
Raw Normal View History

<?php
require_once 'lib/DoctrineTestInit.php';
/**
* Description of BasicCRUDTest
*
* @author robo
*/
class Orm_Functional_BasicCRUDTest extends Doctrine_OrmFunctionalTestCase {
public function testSingleEntityCRUD() {
$em = $this->_getEntityManager();
$exporter = new Doctrine_ORM_Export_ClassExporter($em);
2009-01-08 11:23:24 +00:00
$exporter->exportClasses(array(
$em->getClassMetadata('CmsUser'),
$em->getClassMetadata('CmsPhonenumber')
));
// Create
$user = new CmsUser;
$user->name = 'romanb';
$em->save($user);
$this->assertTrue(is_numeric($user->id));
$this->assertTrue($em->contains($user));
// Read
$user2 = $em->find('CmsUser', $user->id);
$this->assertTrue($user === $user2);
2009-01-08 11:23:24 +00:00
// Add a phonenumber
2009-01-08 11:23:24 +00:00
$ph = new CmsPhonenumber;
$ph->phonenumber = "12345";
$user->addPhonenumber($ph);
$em->flush();
$this->assertTrue($em->contains($ph));
$this->assertTrue($em->contains($user));
2009-01-08 11:23:24 +00:00
// Update
$user->name = 'guilherme';
$em->flush();
$this->assertEquals('guilherme', $user->name);
// Delete
$em->delete($user);
$this->assertTrue($em->getUnitOfWork()->isRegisteredRemoved($user));
$em->flush();
$this->assertFalse($em->getUnitOfWork()->isRegisteredRemoved($user));
}
2009-01-08 11:23:24 +00:00
public function testMore() {
}
}