Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
199dbbc2
Commit
199dbbc2
authored
Nov 10, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more tests for the class table inheritance
parent
a8d9830d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
2 deletions
+62
-2
ClassTableInheritanceTestCase.php
tests/ClassTableInheritanceTestCase.php
+62
-2
No files found.
tests/ClassTableInheritanceTestCase.php
View file @
199dbbc2
...
@@ -48,7 +48,7 @@ class Doctrine_ClassTableInheritance_TestCase extends Doctrine_UnitTestCase
...
@@ -48,7 +48,7 @@ class Doctrine_ClassTableInheritance_TestCase extends Doctrine_UnitTestCase
public
function
testExportGeneratesAllInheritedTables
()
public
function
testExportGeneratesAllInheritedTables
()
{
{
$sql
=
$this
->
conn
->
export
->
exportClassesSql
(
array
(
'CTITest'
));
$sql
=
$this
->
conn
->
export
->
exportClassesSql
(
array
(
'CTITest'
,
'CTITestOneToManyRelated'
));
$this
->
assertEqual
(
$sql
[
0
],
'CREATE TABLE c_t_i_test_parent4 (id INTEGER, age INTEGER, PRIMARY KEY(id))'
);
$this
->
assertEqual
(
$sql
[
0
],
'CREATE TABLE c_t_i_test_parent4 (id INTEGER, age INTEGER, PRIMARY KEY(id))'
);
$this
->
assertEqual
(
$sql
[
1
],
'CREATE TABLE c_t_i_test_parent3 (id INTEGER, added INTEGER, PRIMARY KEY(id))'
);
$this
->
assertEqual
(
$sql
[
1
],
'CREATE TABLE c_t_i_test_parent3 (id INTEGER, added INTEGER, PRIMARY KEY(id))'
);
...
@@ -101,6 +101,7 @@ class Doctrine_ClassTableInheritance_TestCase extends Doctrine_UnitTestCase
...
@@ -101,6 +101,7 @@ class Doctrine_ClassTableInheritance_TestCase extends Doctrine_UnitTestCase
// pop the prepare event
// pop the prepare event
$profiler
->
pop
();
$profiler
->
pop
();
$this
->
assertEqual
(
$profiler
->
pop
()
->
getQuery
(),
'INSERT INTO c_t_i_test_parent2 (name, verified) VALUES (?, ?)'
);
$this
->
assertEqual
(
$profiler
->
pop
()
->
getQuery
(),
'INSERT INTO c_t_i_test_parent2 (name, verified) VALUES (?, ?)'
);
$this
->
conn
->
addListener
(
new
Doctrine_EventListener
());
}
}
public
function
testParentalJoinsAreAddedAutomaticallyWithDql
()
public
function
testParentalJoinsAreAddedAutomaticallyWithDql
()
...
@@ -121,10 +122,69 @@ class Doctrine_ClassTableInheritance_TestCase extends Doctrine_UnitTestCase
...
@@ -121,10 +122,69 @@ class Doctrine_ClassTableInheritance_TestCase extends Doctrine_UnitTestCase
public
function
testFetchingCtiRecordsSupportsLimitSubqueryAlgorithm
()
public
function
testFetchingCtiRecordsSupportsLimitSubqueryAlgorithm
()
{
{
$record
=
new
CTITestOneToManyRelated
;
$record
->
name
=
'Someone'
;
$record
->
cti_id
=
1
;
$record
->
save
();
$this
->
conn
->
clear
();
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
();
$q
->
from
(
'CTITestOneToManyRelated c'
)
->
leftJoin
(
'c.CTITest c2'
)
->
where
(
'c.id = 1'
)
->
limit
(
1
);
$q
->
from
(
'CTITestOneToManyRelated c'
)
->
leftJoin
(
'c.CTITest c2'
)
->
where
(
'c.id = 1'
)
->
limit
(
1
);
print
$q
->
getSql
();
$record
=
$q
->
fetchOne
();
$this
->
assertEqual
(
$record
->
name
,
'Someone'
);
$this
->
assertEqual
(
$record
->
cti_id
,
1
);
$cti
=
$record
->
CTITest
[
0
];
$this
->
assertEqual
(
$cti
->
id
,
1
);
$this
->
assertEqual
(
$cti
->
name
,
'Jack Daniels'
);
$this
->
assertEqual
(
$cti
->
verified
,
true
);
$this
->
assertTrue
(
isset
(
$cti
->
added
));
$this
->
assertEqual
(
$cti
->
age
,
13
);
}
public
function
testUpdatingCtiRecordsUpdatesAllParentTables
()
{
$this
->
conn
->
clear
();
$profiler
=
new
Doctrine_Connection_Profiler
();
$this
->
conn
->
addListener
(
$profiler
);
$record
=
$this
->
conn
->
getTable
(
'CTITest'
)
->
find
(
1
);
$record
->
age
=
11
;
$record
->
name
=
'Jack'
;
$record
->
verified
=
false
;
$record
->
added
=
0
;
$record
->
save
();
// pop the commit event
$profiler
->
pop
();
$this
->
assertEqual
(
$profiler
->
pop
()
->
getQuery
(),
'UPDATE c_t_i_test_parent4 SET age = ? WHERE id = ?'
);
// pop the prepare event
$profiler
->
pop
();
$this
->
assertEqual
(
$profiler
->
pop
()
->
getQuery
(),
'UPDATE c_t_i_test_parent3 SET added = ? WHERE id = ?'
);
// pop the prepare event
$profiler
->
pop
();
$this
->
assertEqual
(
$profiler
->
pop
()
->
getQuery
(),
'UPDATE c_t_i_test_parent2 SET name = ?, verified = ? WHERE id = ?'
);
$this
->
conn
->
addListener
(
new
Doctrine_EventListener
());
}
public
function
testUpdateOperationIsPersistent
()
{
$this
->
conn
->
clear
();
$record
=
$this
->
conn
->
getTable
(
'CTITest'
)
->
find
(
1
);
$this
->
assertEqual
(
$record
->
id
,
1
);
$this
->
assertEqual
(
$record
->
name
,
'Jack'
);
$this
->
assertEqual
(
$record
->
verified
,
false
);
$this
->
assertEqual
(
$record
->
added
,
0
);
$this
->
assertEqual
(
$record
->
age
,
11
);
}
}
}
}
class
CTITestParent1
extends
Doctrine_Record
class
CTITestParent1
extends
Doctrine_Record
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment