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
29892607
Commit
29892607
authored
Aug 03, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for the new templating model
parent
5490247c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
14 deletions
+125
-14
TemplateTestCase.php
tests/TemplateTestCase.php
+109
-8
TokenizerTestCase.php
tests/TokenizerTestCase.php
+16
-6
No files found.
tests/TemplateTestCase.php
View file @
29892607
...
...
@@ -32,18 +32,119 @@
*/
class
Doctrine_Template_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testTemplatesGenerateFiles
()
{
@
unlink
(
'../models/BlogTag.php'
);
public
function
prepareTables
()
{
}
public
function
prepareData
()
{
}
$blog
=
new
Blog
();
$this
->
assertTrue
(
file_exists
(
'../models/BlogTag.php'
));
public
function
testAccessingNonExistingImplementationThrowsException
()
{
try
{
$user
=
new
ConcreteUser
();
$user
->
Group
;
$this
->
fail
();
}
catch
(
Doctrine_Relation_Parser_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testTemplateRelationsSupportConcreteInheritance
()
public
function
testAccessingExistingImplementationSupportsAssociations
()
{
$tag
=
new
BlogTag
();
$this
->
manager
->
setImpl
(
'UserTemplate'
,
'ConcreteUser'
)
->
setImpl
(
'GroupUserTemplate'
,
'ConcreteGroupUser'
)
->
setImpl
(
'GroupTemplate'
,
'ConcreteGroup'
)
->
setImpl
(
'EmailTemplate'
,
'ConcreteEmail'
);
$user
=
new
ConcreteUser
();
$group
=
$user
->
Group
[
0
];
$this
->
assertTrue
(
$group
instanceof
ConcreteGroup
);
$this
->
assertTrue
(
$group
->
User
[
0
]
instanceof
ConcreteUser
);
}
public
function
testAccessingExistingImplementationSupportsForeignKeyRelations
()
{
$user
=
new
ConcreteUser
();
$this
->
assertTrue
(
$user
->
Email
[
0
]
instanceof
ConcreteEmail
);
}
}
class
ConcreteUser
extends
Doctrine_Record
{
public
function
setUp
()
{
$this
->
loadTemplate
(
'UserTemplate'
);
}
}
class
ConcreteGroup
extends
Doctrine_Record
{
public
function
setUp
()
{
$this
->
loadTemplate
(
'GroupTemplate'
);
}
}
class
ConcreteEmail
extends
Doctrine_Record
{
public
function
setUp
()
{
$this
->
loadTemplate
(
'EmailTemplate'
);
}
}
class
ConcreteGroupUser
extends
Doctrine_Record
{
public
function
setUp
()
{
$this
->
loadTemplate
(
'GroupUserTemplate'
);
}
}
class
UserTemplate
extends
Doctrine_Template
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'name'
,
'string'
);
$this
->
hasColumn
(
'password'
,
'string'
);
}
public
function
setUp
()
{
$this
->
hasMany
(
'GroupTemplate as Group'
,
array
(
'local'
=>
'user_id'
,
'foreign'
=>
'group_id'
,
'refClass'
=>
'GroupUserTemplate'
));
$this
->
hasMany
(
'EmailTemplate as Email'
,
array
(
'local'
=>
'id'
,
'foreign'
=>
'user_id'
));
}
}
class
EmailTemplate
extends
Doctrine_Template
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'address'
,
'string'
);
$this
->
hasColumn
(
'user_id'
,
'integer'
);
}
public
function
setUp
()
{
$this
->
hasOne
(
'UserTemplate as User'
,
array
(
'local'
=>
'user_id'
,
'foreign'
=>
'id'
));
}
}
class
GroupTemplate
extends
Doctrine_Template
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'name'
,
'string'
);
}
public
function
setUp
()
{
$this
->
hasMany
(
'UserTemplate as User'
,
array
(
'local'
=>
'user_id'
,
'foreign'
=>
'group_id'
,
'refClass'
=>
'GroupUserTemplate'
));
}
}
class
GroupUserTemplate
extends
Doctrine_Template
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'user_id'
,
'integer'
);
$this
->
hasColumn
(
'group_id'
,
'integer'
);
}
}
tests/TokenizerTestCase.php
View file @
29892607
...
...
@@ -31,22 +31,24 @@
* @version $Revision: 1181 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class
Doctrine_Tokenizer_TestCase
extends
Doctrine_UnitTestCase
class
Doctrine_Tokenizer_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareData
()
public
function
prepareData
()
{
}
public
function
prepareTables
()
public
function
prepareTables
()
{
}
public
function
testSqlExplode
()
{
$str
=
"word1 word2 word3"
;
$a
=
Doctrine_Tokenizer
::
sqlExplode
(
$str
);
$this
->
assertEqual
(
$a
,
array
(
"word1"
,
"word2"
,
"word3"
));
$str
=
"word1 (word2 word3)"
;
$a
=
Doctrine_Tokenizer
::
sqlExplode
(
$str
);
$this
->
assertEqual
(
$a
,
array
(
"word1"
,
"(word2 word3)"
));
$str
=
"word1 'word2 word3'"
;
$a
=
Doctrine_Tokenizer
::
sqlExplode
(
$str
);
$this
->
assertEqual
(
$a
,
array
(
"word1"
,
"'word2 word3'"
));
...
...
@@ -97,6 +99,14 @@ class Doctrine_Tokenizer_TestCase extends Doctrine_UnitTestCase
$str
=
"something (( ))"
;
$a
=
Doctrine_Tokenizer
::
sqlExplode
(
$str
);
$this
->
assertEqual
(
$a
,
array
(
"something"
,
"(( ))"
));
$this
->
assertEqual
(
$a
,
array
(
"something"
,
"(( ))"
));
}
public
function
testSqlExplode2
()
{
$str
=
'rdbms (dbal OR database)'
;
$a
=
Doctrine_Tokenizer
::
sqlExplode
(
$str
,
' OR '
);
$this
->
assertEqual
(
$a
,
array
(
'rdbms (dbal OR database)'
));
}
}
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