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
59df6edf
Commit
59df6edf
authored
Jun 28, 2007
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addition to the validator tests.
Ticket: 354
parent
c02c83d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
9 deletions
+97
-9
ValidatorTestCase.php
tests/ValidatorTestCase.php
+34
-8
classes.php
tests/classes.php
+63
-1
No files found.
tests/ValidatorTestCase.php
View file @
59df6edf
...
...
@@ -40,6 +40,9 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$this
->
tables
[]
=
'ValidatorTest'
;
$this
->
tables
[]
=
'ValidatorTest_Person'
;
$this
->
tables
[]
=
'ValidatorTest_FootballPlayer'
;
$this
->
tables
[]
=
'ValidatorTest_ClientModel'
;
$this
->
tables
[]
=
'ValidatorTest_ClientToAddressModel'
;
$this
->
tables
[]
=
'ValidatorTest_AddressModel'
;
parent
::
prepareTables
();
}
...
...
@@ -229,16 +232,14 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$this
->
pass
();
$a
=
$e
->
getInvalidRecords
();
//var_dump($a[1]->getErrorStack());
$this
->
assertTrue
(
is_array
(
$a
));
//var_dump(array_search($user, $a));
$emailStack
=
$user
->
Email
->
errorStack
();
$userStack
=
$user
->
errorStack
();
$this
->
assertTrue
(
in_array
(
'email'
,
$emailStack
[
'address'
]));
$this
->
assertTrue
(
in_array
(
'length'
,
$userStack
[
'name'
]));
}
$this
->
assertTrue
(
is_array
(
$a
));
//var_dump(array_search($user, $a));
$emailStack
=
$user
->
Email
->
errorStack
();
$userStack
=
$user
->
errorStack
();
//var_dump($userStack);
$this
->
assertTrue
(
in_array
(
'email'
,
$emailStack
[
'address'
]));
$this
->
assertTrue
(
in_array
(
'length'
,
$userStack
[
'name'
]));
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
false
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_AUTO_LENGTH_VLD
,
false
);
}
...
...
@@ -384,5 +385,30 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
false
);
}
public
function
testValidationOnManyToManyRelations
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
true
);
try
{
$client
=
new
ValidatorTest_ClientModel
();
$client
->
short_name
=
'test'
;
$client
->
ValidatorTest_AddressModel
[
0
]
->
state
=
'az'
;
$client
->
save
();
$this
->
fail
();
}
catch
(
Doctrine_Validator_Exception
$dve
)
{
$this
->
assertEqual
(
1
,
count
(
$dve
->
getInvalidRecords
()));
$stack
=
$client
->
ValidatorTest_AddressModel
[
0
]
->
getErrorStack
();
$this
->
assertTrue
(
in_array
(
'notnull'
,
$stack
[
'address1'
]));
$this
->
assertTrue
(
in_array
(
'notblank'
,
$stack
[
'address1'
]));
$this
->
assertTrue
(
in_array
(
'notnull'
,
$stack
[
'address2'
]));
$this
->
assertTrue
(
in_array
(
'notnull'
,
$stack
[
'city'
]));
$this
->
assertTrue
(
in_array
(
'notblank'
,
$stack
[
'city'
]));
$this
->
assertTrue
(
in_array
(
'usstate'
,
$stack
[
'state'
]));
$this
->
assertTrue
(
in_array
(
'notnull'
,
$stack
[
'zip'
]));
$this
->
assertTrue
(
in_array
(
'notblank'
,
$stack
[
'zip'
]));
}
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
false
);
}
}
?>
tests/classes.php
View file @
59df6edf
...
...
@@ -791,6 +791,16 @@ class QueryTest_User extends Doctrine_Record
public
function
setUp
()
{
$this
->
hasOne
(
'QueryTest_Rank as visibleRank'
,
'QueryTest_User.visibleRankId'
);
$this
->
hasMany
(
'QueryTest_Rank as ranks'
,
'QueryTest_UserRank.rankId'
);
}
}
class
QueryTest_UserRank
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'rankId'
,
'integer'
,
4
,
array
(
'primary'
));
$this
->
hasColumn
(
'userId'
,
'integer'
,
4
,
array
(
'primary'
));
}
}
...
...
@@ -808,6 +818,58 @@ class QueryTest_Rank extends Doctrine_Record
$this
->
hasColumn
(
'icon as icon'
,
'string'
,
50
,
array
(
'notnull'
,
'default'
=>
' '
,
'regexp'
=>
'/^[a-zA-Z0-9_\-]+\.(jpg|gif|png)$/D'
));
}
public
function
setUp
()
{
$this
->
hasMany
(
'QueryTest_User as users'
,
'QueryTest_UserRank.userId'
);
}
}
class
ValidatorTest_ClientModel
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'id'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'primary'
=>
true
,
'autoincrement'
=>
true
,
'unsigned'
=>
true
));
$this
->
hasColumn
(
'short_name'
,
'string'
,
32
,
array
(
'notnull'
=>
true
,
'notblank'
,
'unique'
=>
true
));
}
public
function
setUp
()
{
$this
->
hasMany
(
"ValidatorTest_AddressModel"
,
array
(
'local'
=>
'client_id'
,
'foreign'
=>
'address_id'
,
'refClass'
=>
'ValidatorTest_ClientToAddressModel'
));
}
}
class
ValidatorTest_ClientToAddressModel
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
"client_id"
,
"integer"
,
11
,
array
(
'primary'
=>
true
));
$this
->
hasColumn
(
"address_id"
,
"integer"
,
11
,
array
(
'primary'
=>
true
));
}
public
function
construct
(){
}
public
function
setUp
()
{
}
}
class
ValidatorTest_AddressModel
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
"id"
,
"integer"
,
11
,
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
));
$this
->
hasColumn
(
'address1'
,
'string'
,
255
,
array
(
'notnull'
=>
true
,
'notblank'
));
$this
->
hasColumn
(
'address2'
,
'string'
,
255
,
array
(
'notnull'
=>
true
));
$this
->
hasColumn
(
'city'
,
'string'
,
255
,
array
(
'notnull'
=>
true
,
'notblank'
));
$this
->
hasColumn
(
'state'
,
'string'
,
10
,
array
(
'notnull'
=>
true
,
'notblank'
,
'usstate'
));
$this
->
hasColumn
(
'zip'
,
'string'
,
15
,
array
(
'notnull'
=>
true
,
'notblank'
,
'regexp'
=>
'/^[0-9-]*$/'
));
}
public
function
setUp
()
{
$this
->
hasMany
(
'ValidatorTest_ClientModel'
,
array
(
'local'
=>
'address_id'
,
'foreign'
=>
'client_id'
,
'refClass'
=>
'ValidatorTest_ClientToAddressModel'
));
}
}
?>
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