This commit is contained in:
parent
d14e19a6fb
commit
05d969515e
@ -36,7 +36,7 @@ class Doctrine_Db_Profiler_Query
|
||||
*/
|
||||
protected $query ='';
|
||||
/**
|
||||
* @var integer One of the Zend_Db_Profiler constants for query type, set by $queryType argument in constructor.
|
||||
* @var integer One of the Doctrine_Db_Profiler constants for query type, set by $queryType argument in constructor.
|
||||
*/
|
||||
protected $queryType = 0;
|
||||
|
||||
@ -56,7 +56,7 @@ class Doctrine_Db_Profiler_Query
|
||||
|
||||
/**
|
||||
* Class constructor. A query is about to be started, save the query text ($query) and its
|
||||
* type (one of the Zend_Db_Profiler::* constants).
|
||||
* type (one of the Doctrine_Db_Profiler::* constants).
|
||||
*
|
||||
* @param string $query
|
||||
* @param int $queryType
|
||||
|
25
models/location.php
Normal file
25
models/location.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
class Record_Country extends Doctrine_Record {
|
||||
public function setTableDefinition() {
|
||||
$this->hasColumn('name', 'string', 200);
|
||||
}
|
||||
public function setUp() {
|
||||
$this->hasMany('Record_City as City', 'City.country_id');
|
||||
}
|
||||
}
|
||||
class Record_City extends Doctrine_Record {
|
||||
public function setTableDefinition() {
|
||||
$this->hasColumn('name', 'string', 200);
|
||||
$this->hasColumn('country_id', 'integer');
|
||||
$this->hasColumn('district_id', 'integer');
|
||||
}
|
||||
public function setUp() {
|
||||
$this->hasOne('Record_Country as Country', 'Record_City.country_id');
|
||||
$this->hasOne('Record_District as District', 'Record_City.district_id');
|
||||
}
|
||||
}
|
||||
class Record_District extends Doctrine_Record {
|
||||
public function setTableDefinition() {
|
||||
$this->hasColumn('name', 'string', 200);
|
||||
}
|
||||
}
|
@ -149,3 +149,52 @@ class Doctrine_Query_MultiJoin_TestCase extends Doctrine_UnitTestCase {
|
||||
$users = $query->query("FROM User.Album.Song WHERE User.id IN (4,5) ORDER BY User.Album.Song.title DESC");
|
||||
}
|
||||
}
|
||||
class Record_District extends Record
|
||||
{
|
||||
public function setUp ()
|
||||
{
|
||||
$this->hasOne('Record_Card as Card', 'Record_District.district_id');
|
||||
$this->hasOne('Record_City as City', 'Record_District.city_id');
|
||||
$this->hasMany('Record_Building as Building', 'Record_BuildingDistrict.building_id');
|
||||
}
|
||||
|
||||
public function setTableDefinition ()
|
||||
{
|
||||
$this->setTableName('district');
|
||||
|
||||
$this->hasColumn('district_id', 'integer', 8, array('primary', 'unsigned', 'notnull', 'default' => 0));
|
||||
$this->hasColumn('city_id', 'integer', 8, array('unsigned', 'notnull'));
|
||||
$this->hasColumn('city', 'string', 50, array('notnull', 'default' => ''));
|
||||
$this->hasColumn('district', 'string', 50, array('notnull', 'default' => ''));
|
||||
$this->hasColumn('matchword', 'string', 50);
|
||||
|
||||
$this->has_coord_columns();
|
||||
$this->has_status_columns();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$dql_building =
|
||||
"
|
||||
FROM Record_Building b
|
||||
LEFT JOIN b.District d
|
||||
LEFT JOIN d.City c
|
||||
LEFT JOIN b.Address a
|
||||
WHERE b.building_id = {$id}
|
||||
";
|
||||
|
||||
|
||||
|
||||
$collection = $this->db->query($dql_building);
|
||||
$br = $collection[0];
|
||||
|
||||
echo "building:{$br->building_id}\n";
|
||||
|
||||
foreach ($br->District as $district) {
|
||||
echo "district:{$district->district_id} {$district->district} {$district->City->city}\n";
|
||||
}
|
||||
|
||||
// Notice: Trying to get property of non-object in /www/igglo2_doctrine/core/class/BuildingDAO.php on line 92
|
||||
|
||||
|
||||
|
@ -38,17 +38,4 @@ class Doctrine_Relation_OneToOne_TestCase extends Doctrine_UnitTestCase {
|
||||
$this->assertTrue($country instanceof Record_Country);
|
||||
}
|
||||
}
|
||||
class Record_Country extends Doctrine_Record {
|
||||
public function setTableDefinition() {
|
||||
$this->hasColumn('name', 'string', 200);
|
||||
}
|
||||
}
|
||||
class Record_City extends Doctrine_Record {
|
||||
public function setTableDefinition() {
|
||||
$this->hasColumn('name', 'string', 200);
|
||||
$this->hasColumn('country_id', 'integer');
|
||||
}
|
||||
public function setUp() {
|
||||
$this->hasOne('Record_Country as Country', 'Record_City.country_id');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,4 +31,24 @@
|
||||
* @version $Revision$
|
||||
*/
|
||||
class Doctrine_Sequence_Pgsql_TestCase extends Doctrine_UnitTestCase {
|
||||
public function testCurrIdExecutesSql()
|
||||
{
|
||||
$this->sequence->currId('user');
|
||||
$q = "SELECT (last_number-1) FROM user_sequences WHERE sequence_name='user_seq' OR sequence_name='USER_SEQ'";
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), $q);
|
||||
}
|
||||
public function testNextIdExecutesSql()
|
||||
{
|
||||
$id = $this->sequence->nextId('user');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), "SELECT NEXTVAL('user_seq')");
|
||||
|
||||
}
|
||||
public function testLastInsertIdExecutesSql()
|
||||
{
|
||||
$this->sequence->lastInsertId('user');
|
||||
|
||||
$this->assertEqual($this->adapter->pop(), 'SELECT user_seq.currval');
|
||||
}
|
||||
}
|
||||
|
@ -40,24 +40,36 @@ function autoload($class) {
|
||||
|
||||
require_once dirname(__FILE__) . '/../lib/Doctrine.php';
|
||||
|
||||
|
||||
spl_autoload_register(array('Doctrine', 'autoload'));
|
||||
spl_autoload_register('autoload');
|
||||
|
||||
require_once dirname(__FILE__) . '/../models/location.php';
|
||||
require_once('classes.php');
|
||||
require_once('simpletest/unit_tester.php');
|
||||
require_once('simpletest/reporter.php');
|
||||
require_once('UnitTestCase.php');
|
||||
require_once('DriverTestCase.php');
|
||||
|
||||
|
||||
error_reporting(E_ALL);
|
||||
print '<pre>';
|
||||
|
||||
$test = new GroupTest('Doctrine Framework Unit Tests');
|
||||
|
||||
$test->addTestCase(new Doctrine_Sequence_Mysql_TestCase());
|
||||
$test->addTestCase(new Doctrine_Query_Join_TestCase());
|
||||
/**
|
||||
$test->addTestCase(new Doctrine_Sequence_Firebird_TestCase());
|
||||
$test->addTestCase(new Doctrine_Sequence_Informix_TestCase());
|
||||
$test->addTestCase(new Doctrine_Sequence_Mysql_TestCase());
|
||||
$test->addTestCase(new Doctrine_Sequence_Mssql_TestCase());
|
||||
$test->addTestCase(new Doctrine_Sequence_Pgsql_TestCase());
|
||||
$test->addTestCase(new Doctrine_Sequence_Oracle_TestCase());
|
||||
$test->addTestCase(new Doctrine_Sequence_Sqlite_TestCase());
|
||||
|
||||
|
||||
// DATABASE ABSTRACTION tests
|
||||
/**
|
||||
|
||||
// Connection drivers (not yet fully tested)
|
||||
$test->addTestCase(new Doctrine_Connection_Pgsql_TestCase());
|
||||
$test->addTestCase(new Doctrine_Connection_Oracle_TestCase());
|
||||
@ -89,13 +101,7 @@ $test->addTestCase(new Doctrine_DataDict_Sqlite_TestCase());
|
||||
|
||||
// Sequence module (not yet fully tested)
|
||||
$test->addTestCase(new Doctrine_Sequence_TestCase());
|
||||
$test->addTestCase(new Doctrine_Sequence_Firebird_TestCase());
|
||||
$test->addTestCase(new Doctrine_Sequence_Informix_TestCase());
|
||||
|
||||
$test->addTestCase(new Doctrine_Sequence_Mssql_TestCase());
|
||||
$test->addTestCase(new Doctrine_Sequence_Pgsql_TestCase());
|
||||
$test->addTestCase(new Doctrine_Sequence_Oracle_TestCase());
|
||||
$test->addTestCase(new Doctrine_Sequence_Sqlite_TestCase());
|
||||
|
||||
// Export module (not yet fully tested)
|
||||
$test->addTestCase(new Doctrine_Export_TestCase());
|
||||
|
Loading…
x
Reference in New Issue
Block a user