2008-07-21 00:13:24 +04:00
|
|
|
<?php
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
namespace Doctrine\Tests\Mocks;
|
2009-01-04 19:15:32 +03:00
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
class SequenceMock extends \Doctrine\ORM\Id\SequenceGenerator
|
2008-07-21 00:13:24 +04:00
|
|
|
{
|
|
|
|
private $_sequenceNumber = 0;
|
|
|
|
|
2008-09-07 17:48:40 +04:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param Doctrine_Entity $entity
|
|
|
|
* @override
|
|
|
|
*/
|
2008-12-18 17:08:11 +03:00
|
|
|
public function generate($entity)
|
2008-09-07 17:48:40 +04:00
|
|
|
{
|
|
|
|
return $this->_sequenceNumber++;
|
|
|
|
}
|
|
|
|
|
2008-07-21 00:13:24 +04: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;
|
|
|
|
}
|
|
|
|
|
2008-08-01 22:46:14 +04:00
|
|
|
/* Mock API */
|
|
|
|
|
2008-07-21 00:13:24 +04:00
|
|
|
public function reset()
|
|
|
|
{
|
|
|
|
$this->_sequenceNumber = 0;
|
|
|
|
}
|
2008-08-22 13:05:14 +04:00
|
|
|
|
|
|
|
public function autoinc()
|
|
|
|
{
|
|
|
|
$this->_sequenceNumber++;
|
|
|
|
}
|
2008-07-21 00:13:24 +04:00
|
|
|
}
|
|
|
|
|