3 namespace Doctrine\Tests\ORM\Functional;
5 use Doctrine\ORM\Event\PreUpdateEventArgs;
7 require_once __DIR__ . '/../../TestInit.php';
9 class PostgreSQLIdentityStrategyTest extends \Doctrine\Tests\OrmFunctionalTestCase
11 protected function setUp() {
13 if ($this->_em->getConnection()->getDatabasePlatform()->getName() != 'postgresql') {
14 $this->markTestSkipped('This test is special to the PostgreSQL IDENTITY key generation strategy.');
17 $this->_schemaTool->createSchema(array(
18 $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PostgreSQLIdentityEntity'),
20 } catch (\Exception $e) {
21 // Swallow all exceptions. We do not test the schema tool here.
26 protected function tearDown() {
28 // drop sequence manually due to dependency
29 $this->_em->getConnection()->exec('DROP SEQUENCE postgresqlidentityentity_id_seq CASCADE');
32 public function testPreSavePostSaveCallbacksAreInvoked()
34 $entity = new PostgreSQLIdentityEntity();
35 $entity->setValue('hello');
36 $this->_em->persist($entity);
38 $this->assertTrue(is_numeric($entity->getId()));
39 $this->assertTrue($entity->getId() > 0);
40 $this->assertTrue($this->_em->contains($entity));
45 class PostgreSQLIdentityEntity {
46 /** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */
48 /** @Column(type="string") */
50 public function getId() {return $this->id;}
51 public function getValue() {return $this->value;}
52 public function setValue($value) {$this->value = $value;}