Add tests
This commit is contained in:
parent
0fa7b45a0e
commit
9813c2d5f1
@ -811,8 +811,7 @@ class BasicEntityPersister implements EntityPersister
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array|Criteria $criteria
|
* {@inheritDoc}
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public function count($criteria = array())
|
public function count($criteria = array())
|
||||||
{
|
{
|
||||||
@ -1082,10 +1081,7 @@ class BasicEntityPersister implements EntityPersister
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the COUNT SQL to count entities (optionally based on a criteria)
|
* {@inheritDoc}
|
||||||
*
|
|
||||||
* @param array|Criteria $criteria
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function getCountSQL($criteria = array())
|
public function getCountSQL($criteria = array())
|
||||||
{
|
{
|
||||||
|
@ -74,6 +74,14 @@ interface EntityPersister
|
|||||||
*/
|
*/
|
||||||
public function getSelectSQL($criteria, $assoc = null, $lockMode = null, $limit = null, $offset = null, array $orderBy = null);
|
public function getSelectSQL($criteria, $assoc = null, $lockMode = null, $limit = null, $offset = null, array $orderBy = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the COUNT SQL to count entities (optionally based on a criteria)
|
||||||
|
*
|
||||||
|
* @param array|\Doctrine\Common\Collections\Criteria $criteria
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCountSQL($criteria = array());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expands the parameters from the given criteria and use the correct binding types if found.
|
* Expands the parameters from the given criteria and use the correct binding types if found.
|
||||||
*
|
*
|
||||||
@ -149,6 +157,14 @@ interface EntityPersister
|
|||||||
*/
|
*/
|
||||||
public function delete($entity);
|
public function delete($entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count entities (optionally filtered by a criteria)
|
||||||
|
*
|
||||||
|
* @param array|\Doctrine\Common\Collections\Criteria $criteria
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function count($criteria = array());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name of the table that owns the column the given field is mapped to.
|
* Gets the name of the table that owns the column the given field is mapped to.
|
||||||
*
|
*
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Doctrine\Tests\ORM\Persisters;
|
namespace Doctrine\Tests\ORM\Persisters;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\Criteria;
|
||||||
use Doctrine\DBAL\Types\Type as DBALType;
|
use Doctrine\DBAL\Types\Type as DBALType;
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
use Doctrine\ORM\Persisters\BasicEntityPersister;
|
use Doctrine\ORM\Persisters\BasicEntityPersister;
|
||||||
use Doctrine\Tests\Models\CustomType\CustomTypeParent;
|
use Doctrine\Tests\Models\CustomType\CustomTypeParent;
|
||||||
use Doctrine\Tests\Models\CustomType\CustomTypeChild;
|
use Doctrine\Tests\Models\CustomType\CustomTypeChild;
|
||||||
@ -139,4 +141,23 @@ class BasicEntityPersisterTypeValueSqlTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->_persister->getSelectConditionStatementSQL('id', array(123, null))
|
$this->_persister->getSelectConditionStatementSQL('id', array(123, null))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCountCondition()
|
||||||
|
{
|
||||||
|
$persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\SimpleEntity'));
|
||||||
|
|
||||||
|
// Using a criteria as array
|
||||||
|
$statement = $persister->getCountSQL(array('value' => 'bar'));
|
||||||
|
$this->assertEquals('SELECT COUNT(*) FROM "ddc-1719-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement);
|
||||||
|
|
||||||
|
// Using a criteria object
|
||||||
|
$criteria = new Criteria(Criteria::expr()->eq('value', 'bar'));
|
||||||
|
$statement = $persister->getCountSQL($criteria);
|
||||||
|
$this->assertEquals('SELECT COUNT(*) FROM "ddc-1719-simple-entity" t0 WHERE t0."simple-entity-value" = ?', $statement);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCountEntities()
|
||||||
|
{
|
||||||
|
$this->assertEquals(0, $this->_persister->count());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user