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
7a262557
Commit
7a262557
authored
Sep 12, 2007
by
meus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addded tests for template. added optimization for __call and calling template functions in Record
parent
cebd4928
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
2 deletions
+27
-2
Record.php
lib/Doctrine/Record.php
+14
-1
TemplateTestCase.php
tests/TemplateTestCase.php
+12
-0
run.php
tests/run.php
+1
-1
No files found.
lib/Doctrine/Record.php
View file @
7a262557
...
@@ -119,6 +119,12 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -119,6 +119,12 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*/
*/
private
$_oid
;
private
$_oid
;
/**
* @var array $_methods array that contains methods that are already checked for
*/
protected
$_methods
;
/**
/**
* constructor
* constructor
* @param Doctrine_Table|null $table a Doctrine_Table object or null,
* @param Doctrine_Table|null $table a Doctrine_Table object or null,
...
@@ -213,7 +219,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -213,7 +219,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
{
}
{
}
/**
/**
* construct
* construct
* Empty temp
al
te method to provide concrete Record classes with the possibility
* Empty temp
la
te method to provide concrete Record classes with the possibility
* to hook into the constructor procedure
* to hook into the constructor procedure
*
*
* @return void
* @return void
...
@@ -1511,9 +1517,16 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
...
@@ -1511,9 +1517,16 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*/
*/
public
function
__call
(
$method
,
$args
)
public
function
__call
(
$method
,
$args
)
{
{
if
(
isset
(
$this
->
_methods
[
$method
]))
{
$methodArray
=
$this
->
_methods
[
$method
];
$template
=
$methodArray
[
"template"
];
$template
->
setInvoker
(
$this
);
return
call_user_func_array
(
array
(
$template
,
$method
),
$methodArray
[
"args"
]);
}
foreach
(
$this
->
_table
->
getTemplates
()
as
$template
)
{
foreach
(
$this
->
_table
->
getTemplates
()
as
$template
)
{
if
(
method_exists
(
$template
,
$method
))
{
if
(
method_exists
(
$template
,
$method
))
{
$template
->
setInvoker
(
$this
);
$template
->
setInvoker
(
$this
);
$this
->
_methods
[
$method
]
=
array
(
"template"
=>
$template
,
"args"
=>
$args
);
return
call_user_func_array
(
array
(
$template
,
$method
),
$args
);
return
call_user_func_array
(
array
(
$template
,
$method
),
$args
);
}
}
...
...
tests/TemplateTestCase.php
View file @
7a262557
...
@@ -69,6 +69,13 @@ class Doctrine_Template_TestCase extends Doctrine_UnitTestCase
...
@@ -69,6 +69,13 @@ class Doctrine_Template_TestCase extends Doctrine_UnitTestCase
$this
->
assertTrue
(
$user
->
Email
[
0
]
instanceof
ConcreteEmail
);
$this
->
assertTrue
(
$user
->
Email
[
0
]
instanceof
ConcreteEmail
);
}
}
public
function
testShouldCallMethodInTemplate
()
{
$user
=
new
ConcreteUser
();
$this
->
assertEqual
(
"foo"
,
$user
->
foo
());
}
}
}
// move these to ../templates?
// move these to ../templates?
...
@@ -87,6 +94,11 @@ class UserTemplate extends Doctrine_Template
...
@@ -87,6 +94,11 @@ class UserTemplate extends Doctrine_Template
$this
->
hasMany
(
'EmailTemplate as Email'
,
array
(
'local'
=>
'id'
,
$this
->
hasMany
(
'EmailTemplate as Email'
,
array
(
'local'
=>
'id'
,
'foreign'
=>
'user_id'
));
'foreign'
=>
'user_id'
));
}
}
public
function
foo
()
{
return
"foo"
;
}
}
}
class
EmailTemplate
extends
Doctrine_Template
class
EmailTemplate
extends
Doctrine_Template
{
{
...
...
tests/run.php
View file @
7a262557
...
@@ -310,7 +310,7 @@ $test->addTestCase(new Doctrine_Import_Schema_Xml_TestCase());
...
@@ -310,7 +310,7 @@ $test->addTestCase(new Doctrine_Import_Schema_Xml_TestCase());
$test
->
addTestCase
(
new
Doctrine_Export_Schema_Yml_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Export_Schema_Yml_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Export_Schema_Xml_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Export_Schema_Xml_TestCase
());
//
$test->addTestCase(new Doctrine_Template_TestCase());
$test
->
addTestCase
(
new
Doctrine_Template_TestCase
());
//$test->addTestCase(new Doctrine_Import_Builder_TestCase());
//$test->addTestCase(new Doctrine_Import_Builder_TestCase());
...
...
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