Commit 8386d691 authored by zYne's avatar zYne

--no commit message

--no commit message
parent fa11260e
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_NewCore_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_NewCore_TestCase extends Doctrine_UnitTestCase
{
public function testFromParser()
{
$q = new Doctrine_Query();
$q->load('User u', true);
$this->assertEqual($q->getQueryPart('from'), array('entity e'));
$this->assertEqual(count($q->getAliasMap()), 1);
$q->load('u.Phonenumber p', false);
$this->assertEqual($q->getQueryPart('from'), array('entity e', 'LEFT JOIN phonenumber p ON e.id = p.entity_id'));
}
}
...@@ -32,24 +32,12 @@ ...@@ -32,24 +32,12 @@
*/ */
class Doctrine_Query_Cache_TestCase extends Doctrine_UnitTestCase class Doctrine_Query_Cache_TestCase extends Doctrine_UnitTestCase
{ {
public function testParserCacheAddsQueriesToCache()
{
$q = new Doctrine_Query();
$cache = new Doctrine_Cache_Array();
$q->setOption('parserCache', $cache);
$q->select('u.name')->from('User u');
$q->getQuery();
$this->assertEqual($cache->count(), 1);
}
public function testResultSetCacheAddsResultSetsIntoCache() public function testResultSetCacheAddsResultSetsIntoCache()
{ {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
$cache = new Doctrine_Cache_Array(); $cache = new Doctrine_Cache_Array();
$q->setOption('resultSetCache', $cache); $q->setCache($cache);
$q->select('u.name')->from('User u'); $q->select('u.name')->from('User u');
$coll = $q->execute(); $coll = $q->execute();
...@@ -63,12 +51,12 @@ class Doctrine_Query_Cache_TestCase extends Doctrine_UnitTestCase ...@@ -63,12 +51,12 @@ class Doctrine_Query_Cache_TestCase extends Doctrine_UnitTestCase
$this->assertTrue($coll instanceof Doctrine_Collection); $this->assertTrue($coll instanceof Doctrine_Collection);
$this->assertEqual($coll->count(), 8); $this->assertEqual($coll->count(), 8);
} }
public function testResultSetCacheAddsResultSetsIntoCache2() public function testResultSetCacheSupportsQueriesWithJoins()
{ {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
$cache = new Doctrine_Cache_Array(); $cache = new Doctrine_Cache_Array();
$q->setOption('resultSetCache', $cache); $q->setCache($cache);
$q->select('u.name')->from('User u')->leftJoin('u.Phonenumber p'); $q->select('u.name')->from('User u')->leftJoin('u.Phonenumber p');
$coll = $q->execute(); $coll = $q->execute();
...@@ -82,4 +70,5 @@ class Doctrine_Query_Cache_TestCase extends Doctrine_UnitTestCase ...@@ -82,4 +70,5 @@ class Doctrine_Query_Cache_TestCase extends Doctrine_UnitTestCase
$this->assertTrue($coll instanceof Doctrine_Collection); $this->assertTrue($coll instanceof Doctrine_Collection);
$this->assertEqual($coll->count(), 8); $this->assertEqual($coll->count(), 8);
} }
} }
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Record_Filter_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class Doctrine_Record_Filter_TestCase extends Doctrine_UnitTestCase
{
}
...@@ -122,16 +122,17 @@ class Doctrine_Relation_ManyToMany_TestCase extends Doctrine_UnitTestCase { ...@@ -122,16 +122,17 @@ class Doctrine_Relation_ManyToMany_TestCase extends Doctrine_UnitTestCase {
} }
$this->assertEqual($rel->getForeign(), 'oid'); $this->assertEqual($rel->getForeign(), 'oid');
} }
/**
public function testManyToManyRelationFetchingWithAliasesAndCustomPKs() { public function testManyToManyRelationFetchingWithAliasesAndCustomPKs() {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
try { try {
$q->from('M2MTest2 m LEFT JOIN m.RTC5'); $q->from('M2MTest2 m LEFT JOIN m.RTC5');
$this->pass(); $this->pass();
} catch(Doctrine_Exception $e) { } catch(Doctrine_Exception $e) {
$this->fail(); $this->fail();
} }
try { try {
$q->execute(); $q->execute();
$this->pass(); $this->pass();
...@@ -139,7 +140,7 @@ class Doctrine_Relation_ManyToMany_TestCase extends Doctrine_UnitTestCase { ...@@ -139,7 +140,7 @@ class Doctrine_Relation_ManyToMany_TestCase extends Doctrine_UnitTestCase {
$this->fail(); $this->fail();
} }
} }
*/
public function testManyToManyRelationFetchingWithAliasesAndCustomPKs2() { public function testManyToManyRelationFetchingWithAliasesAndCustomPKs2() {
$q = new Doctrine_Query(); $q = new Doctrine_Query();
......
...@@ -195,4 +195,6 @@ class Doctrine_Relation_Parser_TestCase extends Doctrine_UnitTestCase ...@@ -195,4 +195,6 @@ class Doctrine_Relation_Parser_TestCase extends Doctrine_UnitTestCase
$rel = $r->getRelation('EntityReference'); $rel = $r->getRelation('EntityReference');
$this->assertTrue($rel instanceof Doctrine_Relation_ForeignKey); $this->assertTrue($rel instanceof Doctrine_Relation_ForeignKey);
} }
// TODO: BETTER ASSOCIATION TABLE GUESSING
} }
...@@ -231,7 +231,9 @@ class Doctrine_UnitTestCase extends UnitTestCase { ...@@ -231,7 +231,9 @@ class Doctrine_UnitTestCase extends UnitTestCase {
if ( ! $this->init) { if ( ! $this->init) {
$this->init(); $this->init();
} }
$this->objTable->clear(); if (isset($this->objTable)) {
$this->objTable->clear();
}
$this->init = true; $this->init = true;
} }
......
...@@ -4,7 +4,9 @@ class Entity extends Doctrine_Record { ...@@ -4,7 +4,9 @@ class Entity extends Doctrine_Record {
$this->ownsOne('Email', 'Entity.email_id'); $this->ownsOne('Email', 'Entity.email_id');
$this->ownsMany('Phonenumber', 'Phonenumber.entity_id'); $this->ownsMany('Phonenumber', 'Phonenumber.entity_id');
$this->ownsOne('Account', 'Account.entity_id'); $this->ownsOne('Account', 'Account.entity_id');
$this->hasMany('Entity', array('local' => 'entity1', 'foreign' => 'entity2')); $this->hasMany('Entity', array('local' => 'entity1',
'refClass' => 'EntityReference',
'foreign' => 'entity2'));
} }
public function setTableDefinition() { public function setTableDefinition() {
$this->hasColumn('id', 'integer',20, 'autoincrement|primary'); $this->hasColumn('id', 'integer',20, 'autoincrement|primary');
...@@ -43,7 +45,7 @@ class Account extends Doctrine_Record { ...@@ -43,7 +45,7 @@ class Account extends Doctrine_Record {
class EntityAddress extends Doctrine_Record { class EntityAddress extends Doctrine_Record {
public function setTableDefinition() { public function setTableDefinition() {
$this->hasColumn('entity_id', 'integer'); $this->hasColumn('user_id', 'integer');
$this->hasColumn('address_id', 'integer'); $this->hasColumn('address_id', 'integer');
} }
} }
...@@ -617,7 +619,7 @@ class ValidatorTest_Person extends Doctrine_Record { ...@@ -617,7 +619,7 @@ class ValidatorTest_Person extends Doctrine_Record {
class ValidatorTest_FootballPlayer extends Doctrine_Record { class ValidatorTest_FootballPlayer extends Doctrine_Record {
public function setTableDefinition() { public function setTableDefinition() {
$this->hasColumn('person_id', 'string', 255, 'primary'); $this->hasColumn('person_id', 'string', 255);
$this->hasColumn('team_name', 'string', 255); $this->hasColumn('team_name', 'string', 255);
$this->hasColumn('goals_count', 'integer', 4); $this->hasColumn('goals_count', 'integer', 4);
} }
......
...@@ -60,7 +60,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests'); ...@@ -60,7 +60,7 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
// DATABASE ABSTRACTION tests // DATABASE ABSTRACTION tests
/**
// 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());
...@@ -138,7 +138,7 @@ $test->addTestCase(new Doctrine_Expression_Oracle_TestCase()); ...@@ -138,7 +138,7 @@ $test->addTestCase(new Doctrine_Expression_Oracle_TestCase());
$test->addTestCase(new Doctrine_Expression_Sqlite_TestCase()); $test->addTestCase(new Doctrine_Expression_Sqlite_TestCase());
// Core // Core
*/
$test->addTestCase(new Doctrine_Access_TestCase()); $test->addTestCase(new Doctrine_Access_TestCase());
//$test->addTestCase(new Doctrine_Configurable_TestCase()); //$test->addTestCase(new Doctrine_Configurable_TestCase());
...@@ -150,15 +150,16 @@ $test->addTestCase(new Doctrine_Table_TestCase()); ...@@ -150,15 +150,16 @@ $test->addTestCase(new Doctrine_Table_TestCase());
$test->addTestCase(new Doctrine_UnitOfWork_TestCase()); $test->addTestCase(new Doctrine_UnitOfWork_TestCase());
$test->addTestCase(new Doctrine_Connection_Transaction_TestCase()); $test->addTestCase(new Doctrine_Connection_Transaction_TestCase());
$test->addTestCase(new Doctrine_Collection_TestCase()); //$test->addTestCase(new Doctrine_Collection_TestCase());
// Relation handling // Relation handling
$test->addTestCase(new Doctrine_TreeStructure_TestCase()); $test->addTestCase(new Doctrine_TreeStructure_TestCase());
$test->addTestCase(new Doctrine_Relation_TestCase()); $test->addTestCase(new Doctrine_Relation_TestCase());
$test->addTestCase(new Doctrine_Relation_Access_TestCase()); //$test->addTestCase(new Doctrine_Relation_Access_TestCase());
$test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase()); //$test->addTestCase(new Doctrine_Relation_ManyToMany_TestCase());
$test->addTestCase(new Doctrine_Relation_OneToOne_TestCase()); $test->addTestCase(new Doctrine_Relation_OneToOne_TestCase());
$test->addTestCase(new Doctrine_Relation_Parser_TestCase());
// Datatypes // Datatypes
$test->addTestCase(new Doctrine_Enum_TestCase()); $test->addTestCase(new Doctrine_Enum_TestCase());
...@@ -167,9 +168,9 @@ $test->addTestCase(new Doctrine_Boolean_TestCase()); ...@@ -167,9 +168,9 @@ $test->addTestCase(new Doctrine_Boolean_TestCase());
// Utility components // Utility components
$test->addTestCase(new Doctrine_PessimisticLocking_TestCase()); //$test->addTestCase(new Doctrine_PessimisticLocking_TestCase());
$test->addTestCase(new Doctrine_RawSql_TestCase());
$test->addTestCase(new Doctrine_View_TestCase()); $test->addTestCase(new Doctrine_View_TestCase());
$test->addTestCase(new Doctrine_Validator_TestCase()); $test->addTestCase(new Doctrine_Validator_TestCase());
...@@ -185,67 +186,87 @@ $test->addTestCase(new Doctrine_Db_Profiler_TestCase()); ...@@ -185,67 +186,87 @@ $test->addTestCase(new Doctrine_Db_Profiler_TestCase());
$test->addTestCase(new Doctrine_EventListener_TestCase()); $test->addTestCase(new Doctrine_EventListener_TestCase());
$test->addTestCase(new Doctrine_EventListener_Chain_TestCase()); $test->addTestCase(new Doctrine_EventListener_Chain_TestCase());
// Record
$test->addTestCase(new Doctrine_Record_TestCase());
$test->addTestCase(new Doctrine_Record_State_TestCase());
//$test->addTestCase(new Doctrine_Record_Filter_TestCase());
// Old test cases (should be removed)
$test->addTestCase(new Doctrine_Record_Filter_TestCase());
$test->addTestCase(new Doctrine_SchemaTestCase()); $test->addTestCase(new Doctrine_SchemaTestCase());
$test->addTestCase(new Doctrine_BatchIterator_TestCase());
$test->addTestCase(new Doctrine_Query_Condition_TestCase()); $test->addTestCase(new Doctrine_Query_Condition_TestCase());
$test->addTestCase(new Doctrine_CustomPrimaryKey_TestCase()); $test->addTestCase(new Doctrine_CustomPrimaryKey_TestCase());
$test->addTestCase(new Doctrine_CustomResultSetOrderTestCase()); $test->addTestCase(new Doctrine_CustomResultSetOrderTestCase());
//$test->addTestCase(new Doctrine_Collection_Offset_TestCase());
// Query tests // Query tests
$test->addTestCase(new Doctrine_Query_MultiJoin_TestCase()); $test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
$test->addTestCase(new Doctrine_Query_ReferenceModel_TestCase()); $test->addTestCase(new Doctrine_Query_ReferenceModel_TestCase());
$test->addTestCase(new Doctrine_Query_ComponentAlias_TestCase()); $test->addTestCase(new Doctrine_Query_ComponentAlias_TestCase());
$test->addTestCase(new Doctrine_Query_TestCase());
$test->addTestCase(new Doctrine_Query_ShortAliases_TestCase()); $test->addTestCase(new Doctrine_Query_ShortAliases_TestCase());
$test->addTestCase(new Doctrine_Query_Delete_TestCase());
$test->addTestCase(new Doctrine_Query_Where_TestCase());
$test->addTestCase(new Doctrine_Query_Limit_TestCase());
$test->addTestCase(new Doctrine_Query_IdentifierQuoting_TestCase());
$test->addTestCase(new Doctrine_Query_Update_TestCase());
$test->addTestCase(new Doctrine_Query_AggregateValue_TestCase());
$test->addTestCase(new Doctrine_Query_Select_TestCase());
$test->addTestCase(new Doctrine_Query_Expression_TestCase()); $test->addTestCase(new Doctrine_Query_Expression_TestCase());
$test->addTestCase(new Doctrine_Query_Having_TestCase());
$test->addTestCase(new Doctrine_Query_From_TestCase());
$test->addTestCase(new Doctrine_Query_JoinCondition_TestCase());
$test->addTestCase(new Doctrine_ColumnAlias_TestCase());
$test->addTestCase(new Doctrine_ColumnAggregationInheritance_TestCase()); $test->addTestCase(new Doctrine_ColumnAggregationInheritance_TestCase());
$test->addTestCase(new Doctrine_ColumnAlias_TestCase());
$test->addTestCase(new Doctrine_Query_Join_TestCase());
$test->addTestCase(new Doctrine_Query_Orderby_TestCase());
$test->addTestCase(new Doctrine_Cache_TestCase());
$test->addTestCase(new Doctrine_Cache_Apc_TestCase()); $test->addTestCase(new Doctrine_Cache_Apc_TestCase());
$test->addTestCase(new Doctrine_Cache_Memcache_TestCase()); $test->addTestCase(new Doctrine_Cache_Memcache_TestCase());
$test->addTestCase(new Doctrine_Cache_Sqlite_TestCase()); $test->addTestCase(new Doctrine_Cache_Sqlite_TestCase());
$test->addTestCase(new Doctrine_Query_Check_TestCase()); $test->addTestCase(new Doctrine_Query_Check_TestCase());
$test->addTestCase(new Doctrine_Query_Limit_TestCase());
$test->addTestCase(new Doctrine_Query_IdentifierQuoting_TestCase());
$test->addTestCase(new Doctrine_Query_Update_TestCase());
$test->addTestCase(new Doctrine_Query_Delete_TestCase());
$test->addTestCase(new Doctrine_Query_JoinCondition_TestCase());
$test->addTestCase(new Doctrine_Query_Join_TestCase());
$test->addTestCase(new Doctrine_Query_Having_TestCase());
$test->addTestCase(new Doctrine_Query_Where_TestCase());
$test->addTestCase(new Doctrine_RawSql_TestCase());
$test->addTestCase(new Doctrine_Query_Orderby_TestCase());
$test->addTestCase(new Doctrine_Query_Subquery_TestCase()); $test->addTestCase(new Doctrine_Query_Subquery_TestCase());
$test->addTestCase(new Doctrine_Query_AggregateValue_TestCase());
$test->addTestCase(new Doctrine_Query_Select_TestCase());
$test->addTestCase(new Doctrine_Query_From_TestCase());
$test->addTestCase(new Doctrine_NewCore_TestCase());
$test->addTestCase(new Doctrine_Tokenizer_TestCase());
$test->addTestCase(new Doctrine_Collection_Snapshot_TestCase());
// Record
$test->addTestCase(new Doctrine_Record_TestCase());
$test->addTestCase(new Doctrine_Record_State_TestCase());
$test->addTestCase(new Doctrine_Query_Cache_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());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase()); //$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
//$test->addTestCase(new Doctrine_Collection_Offset_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 { class MyReporter extends HtmlReporter {
public function paintHeader() {} public function paintHeader() {}
......
...@@ -13,7 +13,7 @@ print "<pre>"; ...@@ -13,7 +13,7 @@ print "<pre>";
$manager = Doctrine_Manager::getInstance(); $manager = Doctrine_Manager::getInstance();
$dbh = Doctrine_Db::getConnection('sqlite::memory:'); $dbh = Doctrine_Db::getConnection('sqlite::memory:');
$conn = $manager->openConnection($dbh); $conn = $manager->openConnection($dbh);
/**
$user = new User(); $user = new User();
$user->name = 'zYne'; $user->name = 'zYne';
$user->Phonenumber[0]->phonenumber = '123 123'; $user->Phonenumber[0]->phonenumber = '123 123';
...@@ -27,16 +27,12 @@ $city->District->name = 'District 1'; ...@@ -27,16 +27,12 @@ $city->District->name = 'District 1';
if ($city->District === $city->district_id) { if ($city->District === $city->district_id) {
print 'case 2 works\n'; print 'case 2 works\n';
} }
*/
$c = new Record_Country(); $c = new Record_Country();
$c->name = 'Some country'; $c->name = 'Some country';
$c->City[0]->name = 'City 1'; $city = $c->City[0];
$c->City[0]->District->name = 'District 1'; $city->name = 'City 1';
$city->District->name = 'District 1';
print $c->City[0]->District . "\n";
print $c->City[0]->get('district_id'). "\n";
if ($c->City[0]->get('district_id') == $c->City[0]->District) { $c->save();
print "case 3 works!\n";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment