1
0
mirror of synced 2024-12-14 07:06:04 +03:00
This commit is contained in:
zYne 2007-06-19 11:19:53 +00:00
parent a7632ff797
commit e9c61a566a
3 changed files with 54 additions and 37 deletions

View File

@ -43,6 +43,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
$users = $q->execute();
$this->assertEqual($users[0]->value, 'zYne zYne@example.com');
}
public function testSelectDistinctIsSupported()
{
$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)");
}
public function testSelectDistinctIsSupported2()
{
$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)");
}
public function testAggregateFunctionWithDistinctKeyword()
{
$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)');
}
public function testAggregateFunction()
{
$q = new Doctrine_Query();
@ -110,6 +114,8 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
try {
$q->parseQuery('SELECT UNKNOWN(u.id) FROM User');
$q->getQuery();
$this->fail();
} catch(Doctrine_Query_Exception $e) {
$this->pass();

View File

@ -30,7 +30,8 @@
* @since 1.0
* @version $Revision$
*/
class Doctrine_UnitTestCase extends UnitTestCase {
class Doctrine_UnitTestCase extends UnitTestCase
{
protected $manager;
protected $connection;
protected $objTable;
@ -55,11 +56,11 @@ class Doctrine_UnitTestCase extends UnitTestCase {
protected $init = false;
public function init() {
public function init()
{
$name = get_class($this);
$this->manager = Doctrine_Manager::getInstance();
$this->manager->setAttribute(Doctrine::ATTR_FETCHMODE, Doctrine::FETCH_IMMEDIATE);
$this->manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);
$this->tables = array_merge($this->tables,
@ -86,32 +87,35 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$class = get_class($this);
$e = explode('_', $class);
$this->driverName = 'main';
switch($e[1]) {
case 'Export':
case 'Import':
case 'Expression':
case 'Transaction':
case 'DataDict':
case 'Sequence':
$this->driverName = 'Sqlite';
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];
if ( ! $this->driverName) {
$this->driverName = 'main';
switch($e[1]) {
case 'Export':
case 'Import':
case 'Expression':
case 'Transaction':
case 'DataDict':
case 'Sequence':
$this->driverName = 'Sqlite';
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 {
@ -141,7 +145,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
} else {
}
$this->listener = new Doctrine_EventListener_Debugger();
$this->listener = new Doctrine_EventListener();
$this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener);
}
if ($this->driverName !== 'main') {
@ -183,7 +187,8 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$this->objTable = $this->connection->getTable('User');
}
public function prepareData() {
public function prepareData()
{
$groups = new Doctrine_Collection($this->connection->getTable('Group'));
$groups[0]->name = 'Drama Actors';
@ -240,10 +245,12 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$this->users = $users;
$this->connection->flush();
}
public function getConnection() {
public function getConnection()
{
return $this->connection;
}
public function assertDeclarationType($type, $type2) {
public function assertDeclarationType($type, $type2)
{
$dec = $this->getDeclaration($type);
if ( ! is_array($type2)) {
@ -252,16 +259,19 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$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));
}
public function clearCache() {
public function clearCache()
{
foreach($this->tables as $name) {
$table = $this->connection->getTable($name);
$table->getCache()->deleteAll();
}
}
public function setUp() {
public function setUp()
{
if ( ! $this->init) {
$this->init();
}

View File

@ -71,7 +71,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
/**
$test->addTestCase(new Doctrine_Ticket330_TestCase());
*/
*/
// Connection drivers (not yet fully tested)
$test->addTestCase(new Doctrine_Connection_Pgsql_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_MultipleAggregateValue_TestCase());
/**
$test->addTestCase(new Doctrine_Query_TestCase());
/**
//$test->addTestCase(new Doctrine_IntegrityAction_TestCase());
*/
//$test->addTestCase(new Doctrine_AuditLog_TestCase());
// Cache tests
//$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
//$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_Hydrate_TestCase());
//$test->addTestCase(new Doctrine_Cache_TestCase());
//$test->addTestCase(new Doctrine_Query_TestCase());
class MyReporter extends HtmlReporter {
public function paintHeader() {}