1
0
mirror of synced 2024-12-14 15:16:04 +03:00
doctrine2/tests/Orm/Functional/BasicCRUDTest.php

39 lines
1013 B
PHP

<?php
require_once 'lib/DoctrineTestInit.php';
/**
* Description of BasicCRUDTest
*
* @author robo
*/
class Orm_Functional_BasicCRUDTest extends Doctrine_OrmFunctionalTestCase {
public function testFoo() {
$em = $this->_getEntityManager();
$exporter = new Doctrine_ORM_Export_ClassExporter($em);
$exporter->exportClasses(array($em->getClassMetadata('CmsUser')));
// Create
$user = new CmsUser;
$user->name = 'romanb';
$em->save($user);
$this->assertTrue(is_numeric($user->id));
$this->assertTrue($em->contains($user));
$user2 = new CmsUser;
$user2->name = 'jwage';
$em->save($user2);
$this->assertTrue(is_numeric($user2->id));
$this->assertTrue($em->contains($user2));
// Read
$user3 = $em->find('CmsUser', $user->id);
$this->assertTrue($user === $user3);
$user4 = $em->find('CmsUser', $user2->id);
$this->assertTrue($user2 === $user4);
}
}