SequenceGeneratorTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Doctrine\Tests\ORM\Functional;
  3. require_once __DIR__ . '/../../TestInit.php';
  4. /**
  5. * Description of SequenceGeneratorTest
  6. *
  7. * @author robo
  8. */
  9. class SequenceGeneratorTest extends \Doctrine\Tests\OrmFunctionalTestCase
  10. {
  11. public function setUp()
  12. {
  13. parent::setUp();
  14. if (!$this->_em->getConnection()->getDatabasePlatform()->supportsSequences()) {
  15. $this->markTestSkipped('Only working for Databases that support sequences.');
  16. }
  17. try {
  18. $this->_schemaTool->createSchema(array(
  19. $this->_em->getClassMetadata(__NAMESPACE__ . '\SequenceEntity'),
  20. ));
  21. } catch(\Exception $e) {
  22. }
  23. }
  24. public function testHighAllocationSizeSequence()
  25. {
  26. for ($i = 0; $i < 11; $i++) {
  27. $e = new SequenceEntity();
  28. $this->_em->persist($e);
  29. }
  30. $this->_em->flush();
  31. }
  32. }
  33. /**
  34. * @Entity
  35. */
  36. class SequenceEntity
  37. {
  38. /**
  39. * @Id
  40. * @column(type="integer")
  41. * @GeneratedValue(strategy="SEQUENCE")
  42. * @SequenceGenerator(allocationSize=5,sequenceName="person_id_seq")
  43. */
  44. public $id;
  45. }