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
ccc51c72
Commit
ccc51c72
authored
Jun 28, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formatting fix
parent
5586bf92
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
55 deletions
+64
-55
ValidatorTestCase.php
tests/ValidatorTestCase.php
+64
-55
No files found.
tests/ValidatorTestCase.php
View file @
ccc51c72
...
@@ -33,8 +33,10 @@
...
@@ -33,8 +33,10 @@
* @since 1.0
* @since 1.0
* @version $Revision$
* @version $Revision$
*/
*/
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_Person'
;
$this
->
tables
[]
=
'ValidatorTest_FootballPlayer'
;
$this
->
tables
[]
=
'ValidatorTest_FootballPlayer'
;
...
@@ -44,75 +46,77 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
...
@@ -44,75 +46,77 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
/**
/**
* Tests correct type detection.
* Tests correct type detection.
*/
*/
public
function
testIsValidType
()
{
public
function
testIsValidType
()
$var
=
"123"
;
{
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"string"
));
$var
=
'123'
;
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"integer"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'string'
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"float"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'integer'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"array"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'float'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"object"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'array'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'object'
));
$var
=
123
;
$var
=
123
;
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"string"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'string'
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"integer"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'integer'
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"float"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'float'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"array"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'array'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"object"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'object'
));
$var
=
123.12
;
$var
=
123.12
;
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"string"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'string'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"integer"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'integer'
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"float"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'float'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"array"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'array'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"object"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'object'
));
$var
=
'123.12'
;
$var
=
'123.12'
;
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"string"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'string'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"integer"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'integer'
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"float"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'float'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"array"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'array'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"object"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'object'
));
$var
=
''
;
$var
=
''
;
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"string"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'string'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"integer"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'integer'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"float"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'float'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"array"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'array'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"object"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'object'
));
$var
=
null
;
$var
=
null
;
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"string"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'string'
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"integer"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'integer'
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"float"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'float'
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"array"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'array'
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"object"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'object'
));
$var
=
'str'
;
$var
=
'str'
;
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"string"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'string'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"integer"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'integer'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"float"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'float'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"array"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'array'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"object"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'object'
));
$var
=
array
();
$var
=
array
();
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"string"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'string'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"integer"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'integer'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"float"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'float'
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"array"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'array'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"object"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'object'
));
$var
=
new
Exception
();
$var
=
new
Exception
();
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"string"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'string'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"integer"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'integer'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"float"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'float'
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
"array"
));
$this
->
assertFalse
(
Doctrine_Validator
::
isValidType
(
$var
,
'array'
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
"object"
));
$this
->
assertTrue
(
Doctrine_Validator
::
isValidType
(
$var
,
'object'
));
}
}
/**
/**
* Tests Doctrine_Validator::validateRecord()
* Tests Doctrine_Validator::validateRecord()
*/
*/
public
function
testValidate2
()
{
public
function
testValidate2
()
{
$test
=
new
ValidatorTest
();
$test
=
new
ValidatorTest
();
$test
->
mymixed
=
"message"
;
$test
->
mymixed
=
"message"
;
$test
->
myrange
=
1
;
$test
->
myrange
=
1
;
...
@@ -138,7 +142,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
...
@@ -138,7 +142,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
/**
/**
* Tests Doctrine_Validator::validateRecord()
* Tests Doctrine_Validator::validateRecord()
*/
*/
public
function
testValidate
()
{
public
function
testValidate
()
{
$user
=
$this
->
connection
->
getTable
(
'User'
)
->
find
(
4
);
$user
=
$this
->
connection
->
getTable
(
'User'
)
->
find
(
4
);
$set
=
array
(
'password'
=>
'this is an example of too long password'
,
$set
=
array
(
'password'
=>
'this is an example of too long password'
,
...
@@ -176,7 +181,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
...
@@ -176,7 +181,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
/**
/**
* Tests the Email validator. (Doctrine_Validator_Email)
* Tests the Email validator. (Doctrine_Validator_Email)
*/
*/
public
function
testIsValidEmail
()
{
public
function
testIsValidEmail
()
{
$validator
=
new
Doctrine_Validator_Email
();
$validator
=
new
Doctrine_Validator_Email
();
...
@@ -197,7 +203,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
...
@@ -197,7 +203,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
/**
/**
* Tests saving records with invalid attributes.
* Tests saving records with invalid attributes.
*/
*/
public
function
testSave
()
{
public
function
testSave
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
true
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
true
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_AUTO_LENGTH_VLD
,
true
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_AUTO_LENGTH_VLD
,
true
);
$user
=
$this
->
connection
->
getTable
(
"User"
)
->
find
(
4
);
$user
=
$this
->
connection
->
getTable
(
"User"
)
->
find
(
4
);
...
@@ -240,7 +247,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
...
@@ -240,7 +247,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
* Tests whether the validate() callback works correctly
* Tests whether the validate() callback works correctly
* in descendants of Doctrine_Record.
* in descendants of Doctrine_Record.
*/
*/
public
function
testValidationHooks
()
{
public
function
testValidationHooks
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
true
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
true
);
// Tests validate() and validateOnInsert()
// Tests validate() and validateOnInsert()
...
@@ -286,7 +294,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
...
@@ -286,7 +294,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
* Tests whether the validateOnInsert() callback works correctly
* Tests whether the validateOnInsert() callback works correctly
* in descendants of Doctrine_Record.
* in descendants of Doctrine_Record.
*/
*/
public
function
testHookValidateOnInsert
()
{
public
function
testHookValidateOnInsert
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
true
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
true
);
$user
=
new
User
();
$user
=
new
User
();
...
...
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