Skip to content

Commit f47a790

Browse files
committed
Tests: ensure models contain only one record per file
1 parent 5ef8287 commit f47a790

20 files changed

+136
-127
lines changed

tests/MigrationTestCase.php

-26
Original file line numberDiff line numberDiff line change
@@ -128,29 +128,3 @@ public function testMigrationClassNameInflected()
128128
}
129129
}
130130
}
131-
132-
class MigrationPhonenumber extends Doctrine_Record
133-
{
134-
public function setTableDefinition()
135-
{
136-
$this->hasColumn('user_id', 'integer');
137-
$this->hasColumn('phonenumber', 'string', 255);
138-
}
139-
}
140-
141-
class MigrationUser extends Doctrine_Record
142-
{
143-
public function setTableDefinition()
144-
{
145-
$this->hasColumn('username', 'string', 255);
146-
$this->hasColumn('password', 'string', 255);
147-
}
148-
}
149-
150-
class MigrationProfile extends Doctrine_Record
151-
{
152-
public function setTableDefinition()
153-
{
154-
$this->hasColumn('name', 'string', 255);
155-
}
156-
}

tests/Relation/OneToOneTestCase.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
* @since 1.0
3131
* @version $Revision$
3232
*/
33-
class Doctrine_Relation_OneToOne_TestCase extends Doctrine_UnitTestCase
33+
class Doctrine_Relation_OneToOne_TestCase extends Doctrine_UnitTestCase
3434
{
35-
public function prepareData()
35+
public function prepareData()
3636
{ }
37-
public function prepareTables()
38-
{
39-
$this->tables = array('gnatUser','gnatEmail','Email','Entity','Record_City', 'Record_Country', 'SelfRefTest');
40-
37+
public function prepareTables()
38+
{
39+
$this->tables = array('GnatUser','GnatEmail','Email','Entity','Record_City', 'Record_Country', 'SelfRefTest');
40+
4141
parent::prepareTables();
4242
}
4343

@@ -46,27 +46,27 @@ public function testOneToOneAggregateRelationWithAliasesIsSupported()
4646
$city = new Record_City();
4747
$country = $city->Country;
4848

49-
$this->assertTrue($country instanceof Record_Country);
49+
$this->assertTrue($country instanceof Record_Country);
5050
}
51-
51+
5252
public function testSelfReferentialOneToOneRelationsAreSupported()
5353
{
5454
$ref = new SelfRefTest();
55-
55+
5656
$rel = $ref->getTable()->getRelation('createdBy');
5757

5858
$this->assertEqual($rel->getForeign(), 'id');
5959
$this->assertEqual($rel->getLocal(), 'created_by');
60-
60+
6161
$ref->name = 'ref 1';
6262
$ref->createdBy->name = 'ref 2';
63-
63+
6464
$ref->save();
6565
}
6666
public function testSelfReferentialOneToOneRelationsAreSupported2()
6767
{
6868
$this->connection->clear();
69-
69+
7070
$ref = $this->conn->queryOne("FROM SelfRefTest s WHERE s.name = 'ref 1'");
7171
$this->assertEqual($ref->name, 'ref 1');
7272
$this->assertEqual($ref->createdBy->name, 'ref 2');
@@ -88,14 +88,14 @@ public function testUnsetRelation()
8888

8989
public function testSavingRelatedObjects()
9090
{
91-
$user = new gnatUser();
91+
$user = new GnatUser();
9292
$user->name = 'test';
93-
$email = new gnatEmail();
93+
$email = new GnatEmail();
9494
$email->address = '[email protected]';
9595
$user->Email = $email;
9696
$user->save();
97-
$this->assertTrue($user->Email instanceOf gnatEmail);
97+
$this->assertTrue($user->Email instanceOf GnatEmail);
9898
$this->assertEqual($user->foreign_id, $user->Email->id);
99-
99+
100100
}
101101
}

tests/models/Blog.php

-20
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,3 @@ public function setUp()
1010
$this->actAs('Taggable');
1111
}
1212
}
13-
class Taggable extends Doctrine_Template
14-
{
15-
public function setUp()
16-
{
17-
//$this->hasMany('[Component]TagTemplate as Tag');
18-
}
19-
}
20-
class TagTemplate extends Doctrine_Record
21-
{
22-
public function setTableDefinition()
23-
{
24-
$this->hasColumn('name', 'string', 100);
25-
$this->hasColumn('description', 'string');
26-
}
27-
28-
public function setUp()
29-
{
30-
//$this->hasOne('[Component]', array('onDelete' => 'CASCADE'));
31-
}
32-
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
2-
class gnatEmail extends Doctrine_Record
2+
class GnatEmail extends Doctrine_Record
33
{
44
public function setTableDefinition()
55
{
66
$this->hasColumn('address', 'string', 150);
77
}
8-
9-
108
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
<?php
2-
class gnatUserTable { }
3-
4-
class gnatUser extends Doctrine_Record
1+
<?php
2+
class GnatUser extends Doctrine_Record
53
{
6-
public function setTableDefinition()
4+
public function setTableDefinition()
75
{
86
$this->hasColumn('name', 'string', 150);
97
$this->hasColumn('foreign_id', 'integer', 10, array ('unique' => true,));
108
}
11-
9+
1210
public function setUp()
1311
{
1412
parent::setUp();
15-
$this->hasOne('gnatEmail as Email', array('local'=> 'foreign_id', 'foreign'=>'id', 'onDelete'=>'CASCADE'));
13+
$this->hasOne('GnatEmail as Email', array('local'=> 'foreign_id', 'foreign'=>'id', 'onDelete'=>'CASCADE'));
1614
}
17-
18-
}
1915

16+
}

tests/models/GnatUserTable.php

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
class GnatUserTable { }

tests/models/Group.php

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
require_once('Entity.php');
44

5-
// grouptable doesn't extend Doctrine_Table -> Doctrine_Connection
6-
// won't initialize grouptable when Doctrine_Connection->getTable('Group') is called
7-
class GroupTable { }
8-
95
class Group extends Entity
106
{
117
public function setUp()

tests/models/GroupTable.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
// grouptable doesn't extend Doctrine_Table -> Doctrine_Connection
4+
// won't initialize grouptable when Doctrine_Connection->getTable('Group') is called
5+
class GroupTable { }

tests/models/MigrationPhonenumber.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
class MigrationPhonenumber extends Doctrine_Record
4+
{
5+
public function setTableDefinition()
6+
{
7+
$this->hasColumn('user_id', 'integer');
8+
$this->hasColumn('phonenumber', 'string', 255);
9+
}
10+
}

tests/models/MigrationProfile.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
class MigrationProfile extends Doctrine_Record
4+
{
5+
public function setTableDefinition()
6+
{
7+
$this->hasColumn('name', 'string', 255);
8+
}
9+
}

tests/models/MigrationUser.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
class MigrationUser extends Doctrine_Record
4+
{
5+
public function setTableDefinition()
6+
{
7+
$this->hasColumn('username', 'string', 255);
8+
$this->hasColumn('password', 'string', 255);
9+
}
10+
}

tests/models/RelationTest.php

-16
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,3 @@ public function setTableDefinition()
77
$this->hasColumn('parent_id', 'integer');
88
}
99
}
10-
11-
class RelationTestChild extends RelationTest
12-
{
13-
public function setUp()
14-
{
15-
$this->hasOne('RelationTest as Parent', array(
16-
'local' => 'parent_id',
17-
'foreign' => 'id',
18-
'onDelete' => 'CASCADE',
19-
));
20-
$this->hasMany('RelationTestChild as Children', array(
21-
'local' => 'id',
22-
'foreign' => 'parent_id',
23-
));
24-
}
25-
}

tests/models/RelationTestChild.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
require_once('RelationTest.php');
4+
5+
class RelationTestChild extends RelationTest
6+
{
7+
public function setUp()
8+
{
9+
$this->hasOne('RelationTest as Parent', array(
10+
'local' => 'parent_id',
11+
'foreign' => 'id',
12+
'onDelete' => 'CASCADE',
13+
));
14+
$this->hasMany('RelationTestChild as Children', array(
15+
'local' => 'id',
16+
'foreign' => 'parent_id',
17+
));
18+
}
19+
}

tests/models/TagTemplate.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
class TagTemplate extends Doctrine_Record
3+
{
4+
public function setTableDefinition()
5+
{
6+
$this->hasColumn('name', 'string', 100);
7+
$this->hasColumn('description', 'string');
8+
}
9+
10+
public function setUp()
11+
{
12+
//$this->hasOne('[Component]', array('onDelete' => 'CASCADE'));
13+
}
14+
}

tests/models/Taggable.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
class Taggable extends Doctrine_Template
3+
{
4+
public function setUp()
5+
{
6+
//$this->hasMany('[Component]TagTemplate as Tag');
7+
}
8+
}

tests/models/User.php

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
require_once('Entity.php');
44

5-
// UserTable doesn't extend Doctrine_Table -> Doctrine_Connection
6-
// won't initialize grouptable when Doctrine_Connection->getTable('User') is called
7-
class UserTable extends Doctrine_Table { }
8-
95
class User extends Entity
106
{
117
public function setUp()

tests/models/UserTable.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
// UserTable doesn't extend Doctrine_Table -> Doctrine_Connection
4+
// won't initialize grouptable when Doctrine_Connection->getTable('User') is called
5+
class UserTable extends Doctrine_Table { }

tests/models/VersioningTest.php

-29
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,3 @@ public function setUp()
1111
$this->actAs('Versionable');
1212
}
1313
}
14-
15-
class VersioningTest2 extends Doctrine_Record
16-
{
17-
public function setTableDefinition()
18-
{
19-
$this->hasColumn('name', 'string');
20-
$this->hasColumn('version', 'integer');
21-
}
22-
public function setUp()
23-
{
24-
$this->actAs('Versionable', array('auditLog' => false));
25-
}
26-
}
27-
28-
class VersioningTest3 extends Doctrine_Record
29-
{
30-
public function setTableDefinition()
31-
{
32-
$this->hasColumn('name', 'string');
33-
$this->hasColumn('version', 'integer');
34-
}
35-
public function setUp()
36-
{
37-
38-
$this->actAs('Versionable', array('tableName' => 'tbl_prefix_comments_version',
39-
'className' => 'VersioningTestClass'));
40-
41-
}
42-
}

tests/models/VersioningTest2.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
class VersioningTest2 extends Doctrine_Record
3+
{
4+
public function setTableDefinition()
5+
{
6+
$this->hasColumn('name', 'string');
7+
$this->hasColumn('version', 'integer');
8+
}
9+
public function setUp()
10+
{
11+
$this->actAs('Versionable', array('auditLog' => false));
12+
}
13+
}

tests/models/VersioningTest3.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
class VersioningTest3 extends Doctrine_Record
4+
{
5+
public function setTableDefinition()
6+
{
7+
$this->hasColumn('name', 'string');
8+
$this->hasColumn('version', 'integer');
9+
}
10+
public function setUp()
11+
{
12+
$this->actAs('Versionable', array(
13+
'tableName' => 'tbl_prefix_comments_version',
14+
'className' => 'VersioningTestClass'
15+
));
16+
}
17+
}

0 commit comments

Comments
 (0)