This commit is contained in:
parent
a7632ff797
commit
e9c61a566a
@ -43,6 +43,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
|
|||||||
$users = $q->execute();
|
$users = $q->execute();
|
||||||
$this->assertEqual($users[0]->value, 'zYne zYne@example.com');
|
$this->assertEqual($users[0]->value, 'zYne zYne@example.com');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSelectDistinctIsSupported()
|
public function testSelectDistinctIsSupported()
|
||||||
{
|
{
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query();
|
||||||
@ -51,6 +52,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
$this->assertEqual($q->getSql(), "SELECT DISTINCT e.id AS e__id, e.name AS e__name FROM entity e WHERE (e.type = 0)");
|
$this->assertEqual($q->getSql(), "SELECT DISTINCT e.id AS e__id, e.name AS e__name FROM entity e WHERE (e.type = 0)");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSelectDistinctIsSupported2()
|
public function testSelectDistinctIsSupported2()
|
||||||
{
|
{
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query();
|
||||||
@ -59,6 +61,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
$this->assertEqual($q->getSql(), "SELECT DISTINCT e.id AS e__id, e.name AS e__name FROM entity e WHERE (e.type = 0)");
|
$this->assertEqual($q->getSql(), "SELECT DISTINCT e.id AS e__id, e.name AS e__name FROM entity e WHERE (e.type = 0)");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAggregateFunctionWithDistinctKeyword()
|
public function testAggregateFunctionWithDistinctKeyword()
|
||||||
{
|
{
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query();
|
||||||
@ -67,6 +70,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
$this->assertEqual($q->getQuery(), 'SELECT COUNT(DISTINCT e.name) AS e__0 FROM entity e WHERE (e.type = 0)');
|
$this->assertEqual($q->getQuery(), 'SELECT COUNT(DISTINCT e.name) AS e__0 FROM entity e WHERE (e.type = 0)');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAggregateFunction()
|
public function testAggregateFunction()
|
||||||
{
|
{
|
||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query();
|
||||||
@ -110,6 +114,8 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$q->parseQuery('SELECT UNKNOWN(u.id) FROM User');
|
$q->parseQuery('SELECT UNKNOWN(u.id) FROM User');
|
||||||
|
|
||||||
|
$q->getQuery();
|
||||||
$this->fail();
|
$this->fail();
|
||||||
} catch(Doctrine_Query_Exception $e) {
|
} catch(Doctrine_Query_Exception $e) {
|
||||||
$this->pass();
|
$this->pass();
|
||||||
|
@ -30,7 +30,8 @@
|
|||||||
* @since 1.0
|
* @since 1.0
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
class Doctrine_UnitTestCase extends UnitTestCase {
|
class Doctrine_UnitTestCase extends UnitTestCase
|
||||||
|
{
|
||||||
protected $manager;
|
protected $manager;
|
||||||
protected $connection;
|
protected $connection;
|
||||||
protected $objTable;
|
protected $objTable;
|
||||||
@ -55,11 +56,11 @@ class Doctrine_UnitTestCase extends UnitTestCase {
|
|||||||
|
|
||||||
protected $init = false;
|
protected $init = false;
|
||||||
|
|
||||||
public function init() {
|
public function init()
|
||||||
|
{
|
||||||
$name = get_class($this);
|
$name = get_class($this);
|
||||||
|
|
||||||
$this->manager = Doctrine_Manager::getInstance();
|
$this->manager = Doctrine_Manager::getInstance();
|
||||||
$this->manager->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_IMMEDIATE);
|
|
||||||
$this->manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);
|
$this->manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);
|
||||||
|
|
||||||
$this->tables = array_merge($this->tables,
|
$this->tables = array_merge($this->tables,
|
||||||
@ -86,32 +87,35 @@ class Doctrine_UnitTestCase extends UnitTestCase {
|
|||||||
$class = get_class($this);
|
$class = get_class($this);
|
||||||
$e = explode('_', $class);
|
$e = explode('_', $class);
|
||||||
|
|
||||||
$this->driverName = 'main';
|
|
||||||
|
|
||||||
switch($e[1]) {
|
if ( ! $this->driverName) {
|
||||||
case 'Export':
|
$this->driverName = 'main';
|
||||||
case 'Import':
|
|
||||||
case 'Expression':
|
switch($e[1]) {
|
||||||
case 'Transaction':
|
case 'Export':
|
||||||
case 'DataDict':
|
case 'Import':
|
||||||
case 'Sequence':
|
case 'Expression':
|
||||||
$this->driverName = 'Sqlite';
|
case 'Transaction':
|
||||||
break;
|
case 'DataDict':
|
||||||
}
|
case 'Sequence':
|
||||||
|
$this->driverName = 'Sqlite';
|
||||||
if(count($e) > 3) {
|
|
||||||
$driver = $e[2];
|
|
||||||
switch($e[2]) {
|
|
||||||
case 'Firebird':
|
|
||||||
case 'Informix':
|
|
||||||
case 'Mysql':
|
|
||||||
case 'Mssql':
|
|
||||||
case 'Oracle':
|
|
||||||
case 'Pgsql':
|
|
||||||
case 'Sqlite':
|
|
||||||
$this->driverName = $e[2];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(count($e) > 3) {
|
||||||
|
$driver = $e[2];
|
||||||
|
switch($e[2]) {
|
||||||
|
case 'Firebird':
|
||||||
|
case 'Informix':
|
||||||
|
case 'Mysql':
|
||||||
|
case 'Mssql':
|
||||||
|
case 'Oracle':
|
||||||
|
case 'Pgsql':
|
||||||
|
case 'Sqlite':
|
||||||
|
$this->driverName = $e[2];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -141,7 +145,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
|
|||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->listener = new Doctrine_EventListener_Debugger();
|
$this->listener = new Doctrine_EventListener();
|
||||||
$this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener);
|
$this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener);
|
||||||
}
|
}
|
||||||
if ($this->driverName !== 'main') {
|
if ($this->driverName !== 'main') {
|
||||||
@ -183,7 +187,8 @@ class Doctrine_UnitTestCase extends UnitTestCase {
|
|||||||
|
|
||||||
$this->objTable = $this->connection->getTable('User');
|
$this->objTable = $this->connection->getTable('User');
|
||||||
}
|
}
|
||||||
public function prepareData() {
|
public function prepareData()
|
||||||
|
{
|
||||||
$groups = new Doctrine_Collection($this->connection->getTable('Group'));
|
$groups = new Doctrine_Collection($this->connection->getTable('Group'));
|
||||||
|
|
||||||
$groups[0]->name = 'Drama Actors';
|
$groups[0]->name = 'Drama Actors';
|
||||||
@ -240,10 +245,12 @@ class Doctrine_UnitTestCase extends UnitTestCase {
|
|||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
$this->connection->flush();
|
$this->connection->flush();
|
||||||
}
|
}
|
||||||
public function getConnection() {
|
public function getConnection()
|
||||||
|
{
|
||||||
return $this->connection;
|
return $this->connection;
|
||||||
}
|
}
|
||||||
public function assertDeclarationType($type, $type2) {
|
public function assertDeclarationType($type, $type2)
|
||||||
|
{
|
||||||
$dec = $this->getDeclaration($type);
|
$dec = $this->getDeclaration($type);
|
||||||
|
|
||||||
if ( ! is_array($type2)) {
|
if ( ! is_array($type2)) {
|
||||||
@ -252,16 +259,19 @@ class Doctrine_UnitTestCase extends UnitTestCase {
|
|||||||
|
|
||||||
$this->assertEqual($dec['type'], $type2);
|
$this->assertEqual($dec['type'], $type2);
|
||||||
}
|
}
|
||||||
public function getDeclaration($type) {
|
public function getDeclaration($type)
|
||||||
|
{
|
||||||
return $this->dataDict->getPortableDeclaration(array('type' => $type, 'name' => 'colname', 'length' => 1, 'fixed' => true));
|
return $this->dataDict->getPortableDeclaration(array('type' => $type, 'name' => 'colname', 'length' => 1, 'fixed' => true));
|
||||||
}
|
}
|
||||||
public function clearCache() {
|
public function clearCache()
|
||||||
|
{
|
||||||
foreach($this->tables as $name) {
|
foreach($this->tables as $name) {
|
||||||
$table = $this->connection->getTable($name);
|
$table = $this->connection->getTable($name);
|
||||||
$table->getCache()->deleteAll();
|
$table->getCache()->deleteAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function setUp() {
|
public function setUp()
|
||||||
|
{
|
||||||
if ( ! $this->init) {
|
if ( ! $this->init) {
|
||||||
$this->init();
|
$this->init();
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
|
|||||||
/**
|
/**
|
||||||
|
|
||||||
$test->addTestCase(new Doctrine_Ticket330_TestCase());
|
$test->addTestCase(new Doctrine_Ticket330_TestCase());
|
||||||
*/
|
*/
|
||||||
// Connection drivers (not yet fully tested)
|
// Connection drivers (not yet fully tested)
|
||||||
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
|
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
|
||||||
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
|
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
|
||||||
@ -292,12 +292,13 @@ $test->addTestCase(new Doctrine_Query_Select_TestCase());
|
|||||||
$test->addTestCase(new Doctrine_Query_JoinCondition_TestCase());
|
$test->addTestCase(new Doctrine_Query_JoinCondition_TestCase());
|
||||||
|
|
||||||
$test->addTestCase(new Doctrine_Query_MultipleAggregateValue_TestCase());
|
$test->addTestCase(new Doctrine_Query_MultipleAggregateValue_TestCase());
|
||||||
/**
|
|
||||||
|
$test->addTestCase(new Doctrine_Query_TestCase());
|
||||||
|
/**
|
||||||
//$test->addTestCase(new Doctrine_IntegrityAction_TestCase());
|
//$test->addTestCase(new Doctrine_IntegrityAction_TestCase());
|
||||||
*/
|
*/
|
||||||
//$test->addTestCase(new Doctrine_AuditLog_TestCase());
|
//$test->addTestCase(new Doctrine_AuditLog_TestCase());
|
||||||
|
|
||||||
|
|
||||||
// Cache tests
|
// Cache tests
|
||||||
//$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
|
//$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
|
||||||
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
|
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
|
||||||
@ -306,7 +307,7 @@ $test->addTestCase(new Doctrine_Query_MultipleAggregateValue_TestCase());
|
|||||||
//$test->addTestCase(new Doctrine_BatchIterator_TestCase());
|
//$test->addTestCase(new Doctrine_BatchIterator_TestCase());
|
||||||
//$test->addTestCase(new Doctrine_Hydrate_TestCase());
|
//$test->addTestCase(new Doctrine_Hydrate_TestCase());
|
||||||
//$test->addTestCase(new Doctrine_Cache_TestCase());
|
//$test->addTestCase(new Doctrine_Cache_TestCase());
|
||||||
//$test->addTestCase(new Doctrine_Query_TestCase());
|
|
||||||
|
|
||||||
class MyReporter extends HtmlReporter {
|
class MyReporter extends HtmlReporter {
|
||||||
public function paintHeader() {}
|
public function paintHeader() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user