SequenceMock.php 875B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Doctrine\Tests\Mocks;
  3. use Doctrine\ORM\EntityManager;
  4. class SequenceMock extends \Doctrine\ORM\Id\SequenceGenerator
  5. {
  6. private $_sequenceNumber = 0;
  7. public function generate(EntityManager $em, $entity)
  8. {
  9. return $this->_sequenceNumber++;
  10. }
  11. /**
  12. * @override
  13. */
  14. public function nextId($seqName, $ondemand = true)
  15. {
  16. return $this->_sequenceNumber++;
  17. }
  18. /**
  19. * @override
  20. */
  21. public function lastInsertId($table = null, $field = null)
  22. {
  23. return $this->_sequenceNumber - 1;
  24. }
  25. /**
  26. * @override
  27. */
  28. public function currId($seqName)
  29. {
  30. return $this->_sequenceNumber;
  31. }
  32. /* Mock API */
  33. public function reset()
  34. {
  35. $this->_sequenceNumber = 0;
  36. }
  37. public function autoinc()
  38. {
  39. $this->_sequenceNumber++;
  40. }
  41. }