2008-07-20 20:13:24 +00:00
|
|
|
<?php
|
|
|
|
|
2009-01-22 19:38:10 +00:00
|
|
|
namespace Doctrine\Tests\Mocks;
|
2009-01-04 16:15:32 +00:00
|
|
|
|
2009-03-30 19:43:05 +00:00
|
|
|
use Doctrine\ORM\EntityManager;
|
|
|
|
|
2009-01-22 19:38:10 +00:00
|
|
|
class SequenceMock extends \Doctrine\ORM\Id\SequenceGenerator
|
2008-07-20 20:13:24 +00:00
|
|
|
{
|
|
|
|
private $_sequenceNumber = 0;
|
2009-05-28 21:34:35 +00:00
|
|
|
|
2009-03-30 19:43:05 +00:00
|
|
|
public function generate(EntityManager $em, $entity)
|
2008-09-07 13:48:40 +00:00
|
|
|
{
|
|
|
|
return $this->_sequenceNumber++;
|
|
|
|
}
|
2009-05-28 21:34:35 +00:00
|
|
|
|
2008-07-20 20:13:24 +00:00
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
public function nextId($seqName, $ondemand = true)
|
|
|
|
{
|
|
|
|
return $this->_sequenceNumber++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
public function lastInsertId($table = null, $field = null)
|
|
|
|
{
|
|
|
|
return $this->_sequenceNumber - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
public function currId($seqName)
|
|
|
|
{
|
|
|
|
return $this->_sequenceNumber;
|
|
|
|
}
|
2009-05-28 21:34:35 +00:00
|
|
|
|
2008-08-01 18:46:14 +00:00
|
|
|
/* Mock API */
|
2009-05-28 21:34:35 +00:00
|
|
|
|
2008-07-20 20:13:24 +00:00
|
|
|
public function reset()
|
|
|
|
{
|
|
|
|
$this->_sequenceNumber = 0;
|
|
|
|
}
|
2009-05-28 21:34:35 +00:00
|
|
|
|
2008-08-22 09:05:14 +00:00
|
|
|
public function autoinc()
|
|
|
|
{
|
|
|
|
$this->_sequenceNumber++;
|
|
|
|
}
|
2008-07-20 20:13:24 +00:00
|
|
|
}
|
|
|
|
|