1
0
mirror of synced 2025-01-06 00:57:10 +03:00
This commit is contained in:
zYne 2007-06-14 21:40:22 +00:00
parent 12379bda4a
commit 5b13dcded9
3 changed files with 62 additions and 32 deletions

View File

@ -35,7 +35,11 @@ class Doctrine_ColumnAlias_TestCase extends Doctrine_UnitTestCase
public function prepareData() public function prepareData()
{ } { }
public function prepareTables() public function prepareTables()
{ } {
$this->tables = array('ColumnAliasTest');
parent::prepareTables();
}
public function testAliasesAreSupportedForRecordPropertyAccessors() public function testAliasesAreSupportedForRecordPropertyAccessors()
{ {
@ -74,7 +78,7 @@ class Doctrine_ColumnAlias_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($coll[0]->alias1, 'someone'); $this->assertEqual($coll[0]->alias1, 'someone');
$this->assertEqual($coll[0]->alias2, 187); $this->assertEqual($coll[0]->alias2, 187);
} }
public function testAliasesAreSupportedForDqlAggregateFunctions() public function testAliasesAreSupportedForDqlAggregateFunctions()
{ {
$q = new Doctrine_Query(); $q = new Doctrine_Query();

View File

@ -34,22 +34,24 @@ class Doctrine_CustomPrimaryKey_TestCase extends Doctrine_UnitTestCase {
public function prepareData() { } public function prepareData() { }
public function prepareTables() { public function prepareTables() {
$this->tables = array("CustomPK"); $this->tables = array('CustomPK');
parent::prepareTables();
} }
public function testOperations() { public function testOperations() {
$c = new CustomPK(); $c = new CustomPK();
$this->assertTrue($c instanceof Doctrine_Record); $this->assertTrue($c instanceof Doctrine_Record);
$c->name = "custom pk test"; $c->name = 'custom pk test';
$this->assertEqual($c->obtainIdentifier(), array()); $this->assertEqual($c->obtainIdentifier(), array());
$c->save(); $c->save();
$this->assertEqual($c->obtainIdentifier(), array("uid" => 1)); $this->assertEqual($c->obtainIdentifier(), array('uid' => 1));
$this->connection->clear(); $this->connection->clear();
$c = $this->connection->getTable('CustomPK')->find(1); $c = $this->connection->getTable('CustomPK')->find(1);
$this->assertEqual($c->obtainIdentifier(), array("uid" => 1)); $this->assertEqual($c->obtainIdentifier(), array('uid' => 1));
} }
} }
?> ?>

View File

@ -30,16 +30,20 @@
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
*/ */
class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
{
public function prepareTables() { public function prepareTables()
$this->tables[] = "enumTest"; {
$this->tables[] = "fieldNameTest"; $this->tables[] = 'enumTest';
$this->tables[] = "GzipTest"; $this->tables[] = 'fieldNameTest';
$this->tables[] = 'GzipTest';
$this->tables[] = 'Book';
parent::prepareTables(); parent::prepareTables();
} }
public function testIssetForPrimaryKey() { public function testIssetForPrimaryKey()
{
$this->assertTrue(isset($this->users[0]->id)); $this->assertTrue(isset($this->users[0]->id));
$this->assertTrue(isset($this->users[0]['id'])); $this->assertTrue(isset($this->users[0]['id']));
$this->assertTrue($this->users[0]->contains('id')); $this->assertTrue($this->users[0]->contains('id'));
@ -51,7 +55,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertFalse($user->contains('id')); $this->assertFalse($user->contains('id'));
} }
public function testNotNullConstraint() { public function testNotNullConstraint()
{
$null = new NotNullTest(); $null = new NotNullTest();
$null->name = null; $null->name = null;
@ -67,7 +72,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
} }
public function testGzipType() { public function testGzipType()
{
$gzip = new GzipTest(); $gzip = new GzipTest();
$gzip->gzip = "compressed"; $gzip->gzip = "compressed";
@ -90,7 +96,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($gzip->gzip, "compressed 2"); $this->assertEqual($gzip->gzip, "compressed 2");
} }
public function testDefaultValues() { public function testDefaultValues()
{
$test = new FieldNameTest; $test = new FieldNameTest;
@ -102,7 +109,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
} }
public function testToArray() { public function testToArray()
{
$user = new User(); $user = new User();
$a = $user->toArray(); $a = $user->toArray();
@ -146,7 +154,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertTrue(is_numeric($a['id'])); $this->assertTrue(is_numeric($a['id']));
} }
public function testReferences2() { public function testReferences2()
{
$user = new User(); $user = new User();
$user->Phonenumber[0]->phonenumber = '123 123'; $user->Phonenumber[0]->phonenumber = '123 123';
$ref = $user->Phonenumber[0]->entity_id; $ref = $user->Phonenumber[0]->entity_id;
@ -154,7 +163,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($ref->getOid(), $user->getOid()); $this->assertEqual($ref->getOid(), $user->getOid());
} }
public function testUpdatingWithNullValue() { public function testUpdatingWithNullValue()
{
$user = $this->connection->getTable('User')->find(5); $user = $this->connection->getTable('User')->find(5);
$user->name = null; $user->name = null;
$this->assertEqual($user->name, null); $this->assertEqual($user->name, null);
@ -170,7 +180,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
} }
public function testSerialize() { public function testSerialize()
{
$user = $this->connection->getTable("User")->find(4); $user = $this->connection->getTable("User")->find(4);
$str = serialize($user); $str = serialize($user);
$user2 = unserialize($str); $user2 = unserialize($str);
@ -179,7 +190,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($user2->obtainIdentifier(), $user->obtainIdentifier()); $this->assertEqual($user2->obtainIdentifier(), $user->obtainIdentifier());
} }
public function testCallback() { public function testCallback()
{
$user = new User(); $user = new User();
$user->name = " zYne "; $user->name = " zYne ";
$user->call('trim', 'name'); $user->call('trim', 'name');
@ -255,7 +267,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($coll->count(), 1); $this->assertEqual($coll->count(), 1);
} }
public function testManyToManyTreeStructure() { public function testManyToManyTreeStructure()
{
$task = $this->connection->create("Task"); $task = $this->connection->create("Task");
@ -297,7 +310,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
} }
public function testOne2OneForeign() { public function testOne2OneForeign()
{
$user = new User(); $user = new User();
$user->name = "Richard Linklater"; $user->name = "Richard Linklater";
@ -351,7 +365,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
} }
public function testGet() { public function testGet()
{
$user = new User(); $user = new User();
$user->name = "Jack Daniels"; $user->name = "Jack Daniels";
$this->assertEqual($user->name, "Jack Daniels"); $this->assertEqual($user->name, "Jack Daniels");
@ -367,7 +382,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
} }
public function testNewOperator() { public function testNewOperator()
{
$table = $this->connection->getTable("User"); $table = $this->connection->getTable("User");
$this->assertEqual($this->connection->getTable("User")->getData(), array()); $this->assertEqual($this->connection->getTable("User")->getData(), array());
@ -382,7 +398,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertTrue($user->name,"John Locke"); $this->assertTrue($user->name,"John Locke");
} }
public function testTreeStructure() { public function testTreeStructure()
{
$e = new Element(); $e = new Element();
$fk = $e->getTable()->getRelation("Child"); $fk = $e->getTable()->getRelation("Child");
@ -433,7 +450,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
} }
public function testUniqueKeyComponent() { public function testUniqueKeyComponent()
{
$e = new Error(); $e = new Error();
$e->message = 'user error'; $e->message = 'user error';
$e->file_md5 = md5(0); $e->file_md5 = md5(0);
@ -509,7 +527,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($e->Description[1]->description, '2nd changed description'); $this->assertEqual($e->Description[1]->description, '2nd changed description');
} }
public function testInsert() { public function testInsert()
{
$user = new User(); $user = new User();
$user->name = "John Locke"; $user->name = "John Locke";
$user->save(); $user->save();
@ -523,7 +542,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN); $this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN);
} }
public function testUpdate() { public function testUpdate()
{
$user = $this->connection->getTable("User")->find(4); $user = $this->connection->getTable("User")->find(4);
$user->set("name","Jack Daniels",true); $user->set("name","Jack Daniels",true);
@ -535,7 +555,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($user->name, "Jack Daniels"); $this->assertEqual($user->name, "Jack Daniels");
} }
public function testCopy() { public function testCopy()
{
$user = $this->connection->getTable("User")->find(4); $user = $this->connection->getTable("User")->find(4);
$new = $user->copy(); $new = $user->copy();
@ -551,7 +572,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
$this->assertTrue(is_numeric($new->id) && $new->id > 0); $this->assertTrue(is_numeric($new->id) && $new->id > 0);
} }
public function testCopyAndModify() { public function testCopyAndModify()
{
$user = $this->connection->getTable("User")->find(4); $user = $this->connection->getTable("User")->find(4);
$new = $user->copy(); $new = $user->copy();
@ -694,7 +716,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
} }
public function testDeleteReference() { public function testDeleteReference()
{
$user = $this->objTable->find(5); $user = $this->objTable->find(5);
$int = $user->Phonenumber->delete(); $int = $user->Phonenumber->delete();
@ -702,7 +725,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase {
} }
public function testSaveAssociations() { public function testSaveAssociations()
{
$user = $this->objTable->find(5); $user = $this->objTable->find(5);
$gf = $this->connection->getTable("Group"); $gf = $this->connection->getTable("Group");