SequenceMock.php 875 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. }