forked from FriendsOfSymfony1/doctrine1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: ensure models contain only one record per file
- Loading branch information
Showing
20 changed files
with
136 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,14 +30,14 @@ | |
* @since 1.0 | ||
* @version $Revision$ | ||
*/ | ||
class Doctrine_Relation_OneToOne_TestCase extends Doctrine_UnitTestCase | ||
class Doctrine_Relation_OneToOne_TestCase extends Doctrine_UnitTestCase | ||
{ | ||
public function prepareData() | ||
public function prepareData() | ||
{ } | ||
public function prepareTables() | ||
{ | ||
$this->tables = array('gnatUser','gnatEmail','Email','Entity','Record_City', 'Record_Country', 'SelfRefTest'); | ||
public function prepareTables() | ||
{ | ||
$this->tables = array('GnatUser','GnatEmail','Email','Entity','Record_City', 'Record_Country', 'SelfRefTest'); | ||
|
||
parent::prepareTables(); | ||
} | ||
|
||
|
@@ -46,27 +46,27 @@ public function testOneToOneAggregateRelationWithAliasesIsSupported() | |
$city = new Record_City(); | ||
$country = $city->Country; | ||
|
||
$this->assertTrue($country instanceof Record_Country); | ||
$this->assertTrue($country instanceof Record_Country); | ||
} | ||
|
||
public function testSelfReferentialOneToOneRelationsAreSupported() | ||
{ | ||
$ref = new SelfRefTest(); | ||
|
||
$rel = $ref->getTable()->getRelation('createdBy'); | ||
|
||
$this->assertEqual($rel->getForeign(), 'id'); | ||
$this->assertEqual($rel->getLocal(), 'created_by'); | ||
|
||
$ref->name = 'ref 1'; | ||
$ref->createdBy->name = 'ref 2'; | ||
|
||
$ref->save(); | ||
} | ||
public function testSelfReferentialOneToOneRelationsAreSupported2() | ||
{ | ||
$this->connection->clear(); | ||
|
||
$ref = $this->conn->queryOne("FROM SelfRefTest s WHERE s.name = 'ref 1'"); | ||
$this->assertEqual($ref->name, 'ref 1'); | ||
$this->assertEqual($ref->createdBy->name, 'ref 2'); | ||
|
@@ -88,14 +88,14 @@ public function testUnsetRelation() | |
|
||
public function testSavingRelatedObjects() | ||
{ | ||
$user = new gnatUser(); | ||
$user = new GnatUser(); | ||
$user->name = 'test'; | ||
$email = new gnatEmail(); | ||
$email = new GnatEmail(); | ||
$email->address = '[email protected]'; | ||
$user->Email = $email; | ||
$user->save(); | ||
$this->assertTrue($user->Email instanceOf gnatEmail); | ||
$this->assertTrue($user->Email instanceOf GnatEmail); | ||
$this->assertEqual($user->foreign_id, $user->Email->id); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
<?php | ||
class gnatEmail extends Doctrine_Record | ||
class GnatEmail extends Doctrine_Record | ||
{ | ||
public function setTableDefinition() | ||
{ | ||
$this->hasColumn('address', 'string', 150); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
<?php | ||
class gnatUserTable { } | ||
|
||
class gnatUser extends Doctrine_Record | ||
<?php | ||
class GnatUser extends Doctrine_Record | ||
{ | ||
public function setTableDefinition() | ||
public function setTableDefinition() | ||
{ | ||
$this->hasColumn('name', 'string', 150); | ||
$this->hasColumn('foreign_id', 'integer', 10, array ('unique' => true,)); | ||
} | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->hasOne('gnatEmail as Email', array('local'=> 'foreign_id', 'foreign'=>'id', 'onDelete'=>'CASCADE')); | ||
$this->hasOne('GnatEmail as Email', array('local'=> 'foreign_id', 'foreign'=>'id', 'onDelete'=>'CASCADE')); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
class GnatUserTable { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
// grouptable doesn't extend Doctrine_Table -> Doctrine_Connection | ||
// won't initialize grouptable when Doctrine_Connection->getTable('Group') is called | ||
class GroupTable { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
class MigrationPhonenumber extends Doctrine_Record | ||
{ | ||
public function setTableDefinition() | ||
{ | ||
$this->hasColumn('user_id', 'integer'); | ||
$this->hasColumn('phonenumber', 'string', 255); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
class MigrationProfile extends Doctrine_Record | ||
{ | ||
public function setTableDefinition() | ||
{ | ||
$this->hasColumn('name', 'string', 255); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
class MigrationUser extends Doctrine_Record | ||
{ | ||
public function setTableDefinition() | ||
{ | ||
$this->hasColumn('username', 'string', 255); | ||
$this->hasColumn('password', 'string', 255); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
require_once('RelationTest.php'); | ||
|
||
class RelationTestChild extends RelationTest | ||
{ | ||
public function setUp() | ||
{ | ||
$this->hasOne('RelationTest as Parent', array( | ||
'local' => 'parent_id', | ||
'foreign' => 'id', | ||
'onDelete' => 'CASCADE', | ||
)); | ||
$this->hasMany('RelationTestChild as Children', array( | ||
'local' => 'id', | ||
'foreign' => 'parent_id', | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
class TagTemplate extends Doctrine_Record | ||
{ | ||
public function setTableDefinition() | ||
{ | ||
$this->hasColumn('name', 'string', 100); | ||
$this->hasColumn('description', 'string'); | ||
} | ||
|
||
public function setUp() | ||
{ | ||
//$this->hasOne('[Component]', array('onDelete' => 'CASCADE')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
class Taggable extends Doctrine_Template | ||
{ | ||
public function setUp() | ||
{ | ||
//$this->hasMany('[Component]TagTemplate as Tag'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
// UserTable doesn't extend Doctrine_Table -> Doctrine_Connection | ||
// won't initialize grouptable when Doctrine_Connection->getTable('User') is called | ||
class UserTable extends Doctrine_Table { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
class VersioningTest2 extends Doctrine_Record | ||
{ | ||
public function setTableDefinition() | ||
{ | ||
$this->hasColumn('name', 'string'); | ||
$this->hasColumn('version', 'integer'); | ||
} | ||
public function setUp() | ||
{ | ||
$this->actAs('Versionable', array('auditLog' => false)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
class VersioningTest3 extends Doctrine_Record | ||
{ | ||
public function setTableDefinition() | ||
{ | ||
$this->hasColumn('name', 'string'); | ||
$this->hasColumn('version', 'integer'); | ||
} | ||
public function setUp() | ||
{ | ||
$this->actAs('Versionable', array( | ||
'tableName' => 'tbl_prefix_comments_version', | ||
'className' => 'VersioningTestClass' | ||
)); | ||
} | ||
} |