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
4652ae5c
Commit
4652ae5c
authored
Mar 28, 2007
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a validator test.
parent
0ff46eb7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
1 deletion
+73
-1
ValidatorTestCase.php
tests/ValidatorTestCase.php
+53
-1
classes.php
tests/classes.php
+20
-0
No files found.
tests/ValidatorTestCase.php
View file @
4652ae5c
...
@@ -35,7 +35,9 @@
...
@@ -35,7 +35,9 @@
*/
*/
class
Doctrine_Validator_TestCase
extends
Doctrine_UnitTestCase
{
class
Doctrine_Validator_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareTables
()
{
public
function
prepareTables
()
{
$this
->
tables
[]
=
"ValidatorTest"
;
$this
->
tables
[]
=
'ValidatorTest'
;
$this
->
tables
[]
=
'ValidatorTest_Person'
;
$this
->
tables
[]
=
'ValidatorTest_FootballPlayer'
;
parent
::
prepareTables
();
parent
::
prepareTables
();
}
}
...
@@ -300,5 +302,55 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
...
@@ -300,5 +302,55 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
false
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
false
);
}
}
/*
public function testIssue()
{
$this->manager->setAttribute(Doctrine::ATTR_VLD, true);
try {
$person = new ValidatorTest_Person();
$person->name = ''; // will raise a validation exception since name must be 'notblank'
$person->is_football_player = true;
$person->ValidatorTest_FootballPlayer->team_name = 'liverpool';
$person->ValidatorTest_FootballPlayer->goals_count = 2;
$person->save();
}
catch(Doctrine_Validator_Exception $e) {
$this->fail("test");
//var_dump($person->getErrorStack());
//var_dump($person->ValidatorTest_FootballPlayer->getErrorStack());
}
$this->manager->setAttribute(Doctrine::ATTR_VLD, false);
}
*/
/**
* Enter description here...
*
* @todo move to a separate test file (tests/Validator/UniqueTestCase) .
*/
public
function
testSetSameUniqueValueThrowsNoException
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
true
);
$r
=
new
ValidatorTest_Person
();
$r
->
name
=
'value'
;
$r
->
save
();
$r
=
$this
->
connection
->
getTable
(
'ValidatorTest_Person'
)
->
findAll
()
->
getFirst
();
$r
->
name
=
'value'
;
try
{
$r
->
save
();
}
catch
(
Doctrine_Validator_Exception
$e
)
{
$this
->
fail
(
"Validator exception raised without reason!"
);
}
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
false
);
}
}
}
?>
?>
tests/classes.php
View file @
4652ae5c
...
@@ -602,4 +602,24 @@ class NestReference extends Doctrine_Record
...
@@ -602,4 +602,24 @@ class NestReference extends Doctrine_Record
$this
->
hasColumn
(
'child_id'
,
'integer'
,
4
,
'primary'
);
$this
->
hasColumn
(
'child_id'
,
'integer'
,
4
,
'primary'
);
}
}
}
}
class
ValidatorTest_Person
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'name'
,
'string'
,
255
,
array
(
'notblank'
,
'unique'
));
$this
->
hasColumn
(
'is_football_player'
,
'boolean'
);
}
public
function
setUp
()
{
$this
->
ownsOne
(
'ValidatorTest_FootballPlayer'
,
'ValidatorTest_FootballPlayer.person_id'
);
}
}
class
ValidatorTest_FootballPlayer
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'person_id'
,
'string'
,
255
,
'primary'
);
$this
->
hasColumn
(
'team_name'
,
'string'
,
255
);
$this
->
hasColumn
(
'goals_count'
,
'integer'
,
4
);
}
}
?>
?>
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