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
c1c3f489
Commit
c1c3f489
authored
Feb 23, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
validator refactorings and others
parent
514e17ea
Changes
22
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
417 additions
and
348 deletions
+417
-348
ClassMetadata.php
lib/Doctrine/ClassMetadata.php
+120
-54
Connection.php
lib/Doctrine/Connection.php
+2
-2
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+48
-2
Manager.php
lib/Doctrine/Manager.php
+15
-0
Mapper.php
lib/Doctrine/Mapper.php
+11
-0
Record.php
lib/Doctrine/Record.php
+88
-60
Validator.php
lib/Doctrine/Validator.php
+34
-162
AccessTest.php
tests/Orm/Component/AccessTest.php
+10
-0
Doctrine_OrmTestCase.php
tests/lib/Doctrine_OrmTestCase.php
+0
-20
ForumUser.php
tests/models/forum/ForumUser.php
+7
-1
Doctrine_UnitTestCase.php
tests_old/DoctrineTest/Doctrine_UnitTestCase.php
+9
-0
UnitTestCase.php
tests_old/DoctrineTest/UnitTestCase.php
+5
-1
SingleTableTestCase.php
tests_old/Inheritance/SingleTableTestCase.php
+8
-8
FactoryTestCase.php
tests_old/Metadata/FactoryTestCase.php
+19
-19
381TestCase.php
tests_old/Ticket/381TestCase.php
+1
-0
ValidatorTestCase.php
tests_old/ValidatorTestCase.php
+4
-2
Email.php
tests_old/models/Email.php
+2
-1
Entity.php
tests_old/models/Entity.php
+1
-1
ValidatorTest.php
tests_old/models/ValidatorTest.php
+15
-6
ValidatorTest_AddressModel.php
tests_old/models/ValidatorTest_AddressModel.php
+10
-5
ValidatorTest_DateModel.php
tests_old/models/ValidatorTest_DateModel.php
+4
-2
ValidatorTest_Person.php
tests_old/models/ValidatorTest_Person.php
+4
-2
No files found.
lib/Doctrine/ClassMetadata.php
View file @
c1c3f489
This diff is collapsed.
Click to expand it.
lib/Doctrine/Connection.php
View file @
c1c3f489
...
@@ -1047,9 +1047,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
...
@@ -1047,9 +1047,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONN_ERROR
);
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
CONN_ERROR
);
$this
->
getListener
()
->
preError
(
$event
);
$this
->
getListener
()
->
preError
(
$event
);
/*if (strstr($e->getMessage(), 'no such column
')) {
if
(
strstr
(
$e
->
getMessage
(),
'may not be NULL
'
))
{
echo
$e
->
getMessage
()
.
"<br />"
.
$e
->
getTraceAsString
()
.
"<br />"
;
echo
$e
->
getMessage
()
.
"<br />"
.
$e
->
getTraceAsString
()
.
"<br />"
;
}
*/
}
$name
=
'Doctrine_Connection_'
.
$this
->
driverName
.
'_Exception'
;
$name
=
'Doctrine_Connection_'
.
$this
->
driverName
.
'_Exception'
;
...
...
lib/Doctrine/Connection/UnitOfWork.php
View file @
c1c3f489
...
@@ -29,15 +29,61 @@ Doctrine::autoload('Doctrine_Connection_Module');
...
@@ -29,15 +29,61 @@ Doctrine::autoload('Doctrine_Connection_Module');
* @since 1.0
* @since 1.0
* @version $Revision$
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @todo package:orm. Figure out a useful implementation.
* @todo package:orm. Figure out a useful implementation.
*/
*/
class
Doctrine_Connection_UnitOfWork
extends
Doctrine_Connection_Module
class
Doctrine_Connection_UnitOfWork
extends
Doctrine_Connection_Module
{
{
/**
* A map of all currently managed entities.
*
* @var array
*/
protected
$_managedEntities
=
array
();
/**
* The identity map that holds references to all managed entities that have
* an identity.
*/
protected
$_identityMap
=
array
();
/**
* Boolean flag that indicates whether the unit of work immediately executes any
* database operations or whether these operations are postponed until the
* unit of work is flushed/committed.
*
* @var boolean
*/
protected
$_autoflush
=
true
;
protected
$_autoflush
=
true
;
/**
* A list of all postponed inserts.
*/
protected
$_inserts
=
array
();
protected
$_inserts
=
array
();
/**
* A list of all postponed updates.
*/
protected
$_updates
=
array
();
protected
$_updates
=
array
();
/**
* A list of all postponed deletes.
*/
protected
$_deletes
=
array
();
protected
$_deletes
=
array
();
/**
* The dbal connection used by the unit of work.
*
* @var Doctrine_Connection
* @todo Allow multiple connections for transparent master-slave replication.
*/
protected
$_conn
;
/**
* Flushes the unit of work, executing all operations that have been postponed
* up to this point.
*
*/
public
function
flush
()
public
function
flush
()
{
{
// get the flush tree
// get the flush tree
...
@@ -47,7 +93,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -47,7 +93,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
foreach
(
$tree
as
$name
)
{
foreach
(
$tree
as
$name
)
{
$mapper
=
$this
->
conn
->
getMapper
(
$name
);
$mapper
=
$this
->
conn
->
getMapper
(
$name
);
foreach
(
$mapper
->
getRepository
()
as
$record
)
{
foreach
(
$mapper
->
getRepository
()
as
$record
)
{
//echo $record->getOid() . "<br />";
$mapper
->
saveSingleRecord
(
$record
);
$mapper
->
saveSingleRecord
(
$record
);
}
}
}
}
...
@@ -172,6 +217,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
...
@@ -172,6 +217,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
}
}
}
}
}
}
return
array_values
(
$tree
);
return
array_values
(
$tree
);
}
}
...
...
lib/Doctrine/Manager.php
View file @
c1c3f489
...
@@ -497,6 +497,21 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
...
@@ -497,6 +497,21 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
return
$query
;
return
$query
;
}
}
/**
* Creates a new native query (instance of Doctrine_RawSql).
*
* @return Doctrine_RawSql
*/
public
function
createNativeQuery
(
$sql
=
""
)
{
$nativeQuery
=
new
Doctrine_RawSql
(
$this
->
getCurrentConnection
());
if
(
!
empty
(
$sql
))
{
$nativeQuery
->
parseQuery
(
$sql
);
}
return
$nativeQuery
;
}
/**
/**
* Creates a query object out of a registered, named query.
* Creates a query object out of a registered, named query.
*
*
...
...
lib/Doctrine/Mapper.php
View file @
c1c3f489
...
@@ -318,6 +318,17 @@ class Doctrine_Mapper extends Doctrine_Configurable implements Countable
...
@@ -318,6 +318,17 @@ class Doctrine_Mapper extends Doctrine_Configurable implements Countable
return
true
;
return
true
;
}
}
/**
* Tells the mapper to manage the entity if it's not already managed.
*
* @return boolean TRUE if the entity was previously not managed and is now managed,
* FALSE otherwise (the entity is already managed).
*/
public
function
manage
(
Doctrine_Record
$record
)
{
return
$this
->
getRepository
()
->
add
(
$record
);
}
/**
/**
* removeRecord
* removeRecord
* removes a record from the identity map, returning true if the record
* removes a record from the identity map, returning true if the record
...
...
lib/Doctrine/Record.php
View file @
c1c3f489
This diff is collapsed.
Click to expand it.
lib/Doctrine/Validator.php
View file @
c1c3f489
...
@@ -67,6 +67,7 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
...
@@ -67,6 +67,7 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
*/
*/
public
function
validateRecord
(
Doctrine_Record
$record
)
public
function
validateRecord
(
Doctrine_Record
$record
)
{
{
$classMetadata
=
$record
->
getTable
();
$columns
=
$record
->
getTable
()
->
getColumns
();
$columns
=
$record
->
getTable
()
->
getColumns
();
$component
=
$record
->
getTable
()
->
getComponentName
();
$component
=
$record
->
getTable
()
->
getComponentName
();
...
@@ -74,90 +75,49 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
...
@@ -74,90 +75,49 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
// if record is transient all fields will be validated
// if record is transient all fields will be validated
// if record is persistent only the modified fields will be validated
// if record is persistent only the modified fields will be validated
$data
=
(
$record
->
exists
())
?
$record
->
getModified
()
:
$record
->
getData
();
$fields
=
(
$record
->
exists
())
?
$record
->
getModified
()
:
$record
->
getData
();
$err
=
array
();
$err
=
array
();
foreach
(
$
data
as
$key
=>
$value
)
{
foreach
(
$
fields
as
$fieldName
=>
$value
)
{
if
(
$value
===
self
::
$_null
)
{
if
(
$value
===
self
::
$_null
)
{
$value
=
null
;
$value
=
null
;
}
else
if
(
$value
instanceof
Doctrine_Record
)
{
}
else
if
(
$value
instanceof
Doctrine_Record
)
{
$value
=
$value
->
getIncremented
();
$value
=
$value
->
getIncremented
();
}
}
$column
=
$columns
[
$record
->
getTable
()
->
getColumnName
(
$key
)];
$dataType
=
$classMetadata
->
getTypeOf
(
$fieldName
);
if
(
$column
[
'type'
]
==
'enum'
)
{
$value
=
$record
->
getTable
()
->
enumIndex
(
$key
,
$value
);
if
(
$value
===
false
)
{
// Validate field type, if type validation is enabled
$errorStack
->
add
(
$key
,
'enum'
);
if
(
$classMetadata
->
getAttribute
(
Doctrine
::
ATTR_VALIDATE
)
&
Doctrine
::
VALIDATE_TYPES
)
{
continue
;
if
(
!
self
::
isValidType
(
$value
,
$dataType
))
{
$errorStack
->
add
(
$fieldName
,
'type'
);
}
}
if
(
$dataType
==
'enum'
)
{
$enumIndex
=
$classMetadata
->
enumIndex
(
$fieldName
,
$value
);
if
(
$enumIndex
===
false
)
{
$errorStack
->
add
(
$fieldName
,
'enum'
);
}
}
if
(
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_VALIDATE
)
&
Doctrine
::
VALIDATE_LENGTHS
)
{
if
(
!
$this
->
validateLength
(
$column
,
$key
,
$value
))
{
$errorStack
->
add
(
$key
,
'length'
);
continue
;
}
}
}
}
foreach
(
$column
as
$name
=>
$args
)
{
// Validate field length, if length validation is enabled
if
(
empty
(
$name
)
if
(
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_VALIDATE
)
&
Doctrine
::
VALIDATE_LENGTHS
)
{
||
$name
==
'primary'
if
(
!
$this
->
validateLength
(
$value
,
$dataType
,
$classMetadata
->
getFieldLength
(
$fieldName
)))
{
||
$name
==
'protected'
$errorStack
->
add
(
$fieldName
,
'length'
);
||
$name
==
'autoincrement'
||
$name
==
'default'
||
$name
==
'values'
||
$name
==
'sequence'
||
$name
==
'zerofill'
||
$name
==
'scale'
||
$name
==
'inherited'
)
{
continue
;
}
if
(
strtolower
(
$name
)
===
'notnull'
&&
isset
(
$column
[
'autoincrement'
]))
{
continue
;
}
if
(
strtolower
(
$name
)
==
'length'
)
{
if
(
!
(
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_VALIDATE
)
&
Doctrine
::
VALIDATE_LENGTHS
))
{
if
(
!
$this
->
validateLength
(
$column
,
$key
,
$value
))
{
$errorStack
->
add
(
$key
,
'length'
);
}
}
}
continue
;
}
}
if
(
strtolower
(
$name
)
==
'type'
)
{
// Run all custom validators
if
(
!
(
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_VALIDATE
)
&
Doctrine
::
VALIDATE_TYPES
)
)
{
foreach
(
$classMetadata
->
getFieldValidators
(
$fieldName
)
as
$validatorName
=>
$args
)
{
if
(
!
self
::
isValidType
(
$value
,
$column
[
'type'
]
))
{
if
(
!
is_string
(
$validatorName
))
{
$errorStack
->
add
(
$key
,
'type'
)
;
$validatorName
=
$args
;
}
$args
=
array
();
}
}
continue
;
$validator
=
self
::
getValidator
(
$validatorName
);
}
$validator
=
self
::
getValidator
(
$name
);
$validator
->
invoker
=
$record
;
$validator
->
invoker
=
$record
;
$validator
->
field
=
$key
;
$validator
->
field
=
$fieldName
;
$validator
->
args
=
$args
;
$validator
->
args
=
$args
;
if
(
!
$validator
->
validate
(
$value
))
{
if
(
!
$validator
->
validate
(
$value
))
{
$errorStack
->
add
(
$key
,
$name
);
$errorStack
->
add
(
$fieldName
,
$validatorName
);
//$err[$key] = 'not valid';
// errors found quit validation looping for this column
//break;
}
}
if
(
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_VALIDATE
)
&
Doctrine
::
VALIDATE_TYPES
)
{
if
(
!
self
::
isValidType
(
$value
,
$column
[
'type'
]))
{
$errorStack
->
add
(
$key
,
'type'
);
continue
;
}
}
}
}
}
}
...
@@ -166,18 +126,16 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
...
@@ -166,18 +126,16 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
/**
/**
* Validates the length of a field.
* Validates the length of a field.
*/
*/
private
function
validateLength
(
$
column
,
$key
,
$value
)
private
function
validateLength
(
$
value
,
$type
,
$maximumLength
)
{
{
if
(
$column
[
'type'
]
==
'timestamp'
||
$column
[
'type'
]
==
'integer'
||
if
(
$type
==
'timestamp'
||
$type
==
'integer'
||
$type
==
'enum'
)
{
$column
[
'type'
]
==
'enum'
)
{
return
true
;
return
true
;
}
else
if
(
$
column
[
'type'
]
==
'array'
||
$column
[
'type'
]
==
'object'
)
{
}
else
if
(
$
type
==
'array'
||
$type
==
'object'
)
{
$length
=
strlen
(
serialize
(
$value
));
$length
=
strlen
(
serialize
(
$value
));
}
else
{
}
else
{
$length
=
strlen
(
$value
);
$length
=
strlen
(
$value
);
}
}
if
(
$length
>
$maximumLength
)
{
if
(
$length
>
$column
[
'length'
])
{
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -193,67 +151,6 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
...
@@ -193,67 +151,6 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
return
(
count
(
$this
->
stack
)
>
0
);
return
(
count
(
$this
->
stack
)
>
0
);
}
}
/**
* phpType
* converts a doctrine type to native php type
*
* @param $portableType portable doctrine type
* @return string
*/
/*
public static function phpType($portableType)
{
switch ($portableType) {
case 'enum':
return 'integer';
case 'blob':
case 'clob':
case 'mbstring':
case 'timestamp':
case 'date':
case 'gzip':
return 'string';
break;
default:
return $portableType;
}
}*/
/**
* returns whether or not the given variable is
* valid type
*
* @param mixed $var
* @param string $type
* @return boolean
*/
/*
public static function isValidType($var, $type)
{
if ($type == 'boolean') {
return true;
}
$looseType = self::gettype($var);
$type = self::phpType($type);
switch ($looseType) {
case 'float':
case 'double':
case 'integer':
if ($type == 'string' || $type == 'float') {
return true;
}
case 'string':
case 'array':
case 'object':
return ($type === $looseType);
break;
case 'NULL':
return true;
break;
}
}*/
/**
/**
* returns whether or not the given variable is
* returns whether or not the given variable is
* valid type
* valid type
...
@@ -300,29 +197,4 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
...
@@ -300,29 +197,4 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
return
false
;
return
false
;
}
}
}
}
/**
* returns the type of loosely typed variable
*
* @param mixed $var
* @return string
*/
/*
public static function gettype($var)
{
$type = gettype($var);
switch ($type) {
case 'string':
if (preg_match("/^[0-9]+$/",$var)) {
return 'integer';
} elseif (is_numeric($var)) {
return 'float';
} else {
return $type;
}
break;
default:
return $type;
}
}*/
}
}
tests/Orm/Component/AccessTest.php
View file @
c1c3f489
...
@@ -44,6 +44,16 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase
...
@@ -44,6 +44,16 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase
$this
->
user
=
new
ForumUser
();
$this
->
user
=
new
ForumUser
();
}
}
public
function
testAccessorOverridePerformance
()
{
$this
->
user
->
username
;
$start
=
microtime
(
true
);
for
(
$i
=
0
;
$i
<
1
;
$i
++
)
{
$this
->
user
->
username
;
}
$end
=
microtime
(
true
);
echo
(
$end
-
$start
)
.
" seconds"
.
PHP_EOL
;
}
/**
/**
* @test
* @test
*/
*/
...
...
tests/lib/Doctrine_OrmTestCase.php
View file @
c1c3f489
...
@@ -119,24 +119,4 @@ class Doctrine_OrmTestCase extends Doctrine_TestCase
...
@@ -119,24 +119,4 @@ class Doctrine_OrmTestCase extends Doctrine_TestCase
$conn
->
exec
(
"DELETE FROM "
.
$conn
->
getClassMetadata
(
$model
)
->
getTableName
());
$conn
->
exec
(
"DELETE FROM "
.
$conn
->
getClassMetadata
(
$model
)
->
getTableName
());
}
}
}
}
/*
public function loadFixturesPackage($package, $models = array())
{
$packagePath = 'fixtures' . DIRECTORY_SEPARATOR . $package;
if ( ! file_exists($packagePath)) {
throw new Exception("Could not find fixtures package: $package.");
}
$modelsPath = $packagePath . DIRECTORY_SEPARATOR . 'models';
$dataPath = $packagePath . DIRECTORY_SEPARATOR . 'data';
Doctrine::loadModels($modelsPath);
Doctrine::createTablesFromModels($modelsPath);
$data = new Doctrine_Data();
$data->importData($dataPath, 'yml', $models);
}
*/
}
}
\ No newline at end of file
tests/models/forum/ForumUser.php
View file @
c1c3f489
...
@@ -16,11 +16,17 @@ class ForumUser extends Doctrine_Record
...
@@ -16,11 +16,17 @@ class ForumUser extends Doctrine_Record
// the discriminator column
// the discriminator column
$class
->
mapColumn
(
'dtype'
,
'string'
,
50
);
$class
->
mapColumn
(
'dtype'
,
'string'
,
50
);
//
property
mapping
//
column
mapping
$class
->
mapColumn
(
'id'
,
'integer'
,
4
,
array
(
$class
->
mapColumn
(
'id'
,
'integer'
,
4
,
array
(
'primary'
=>
true
,
'primary'
=>
true
,
'autoincrement'
=>
true
));
'autoincrement'
=>
true
));
$class
->
mapColumn
(
'username'
,
'string'
,
50
);
$class
->
mapColumn
(
'username'
,
'string'
,
50
);
}
}
/*
public function getUsername()
{
return $this->rawGet('username') . "!";
}
*/
}
}
\ No newline at end of file
tests_old/DoctrineTest/Doctrine_UnitTestCase.php
View file @
c1c3f489
...
@@ -300,4 +300,13 @@ class Doctrine_UnitTestCase extends UnitTestCase
...
@@ -300,4 +300,13 @@ class Doctrine_UnitTestCase extends UnitTestCase
$this
->
init
=
true
;
$this
->
init
=
true
;
}
}
public
function
tearDown
()
{
/*foreach ($this->tables as $table) {
foreach ($this->conn->getMapper($table)->getRepository() as $obj) {
$obj->free();
}
}*/
}
}
}
tests_old/DoctrineTest/UnitTestCase.php
View file @
c1c3f489
...
@@ -116,11 +116,15 @@ class UnitTestCase
...
@@ -116,11 +116,15 @@ class UnitTestCase
foreach
(
get_class_methods
(
$this
)
as
$method
)
{
foreach
(
get_class_methods
(
$this
)
as
$method
)
{
if
(
substr
(
$method
,
0
,
4
)
===
'test'
)
{
if
(
substr
(
$method
,
0
,
4
)
===
'test'
)
{
$this
->
setUp
();
$this
->
setUp
();
$this
->
$method
();
$this
->
$method
();
$this
->
tearDown
();
}
}
}
}
}
}
public
function
setUp
()
{}
public
function
tearDown
()
{}
public
function
getMessages
()
public
function
getMessages
()
{
{
return
$this
->
_messages
;
return
$this
->
_messages
;
...
...
tests_old/Inheritance/SingleTableTestCase.php
View file @
c1c3f489
...
@@ -17,20 +17,20 @@ class Doctrine_Inheritance_SingleTable_TestCase extends Doctrine_UnitTestCase
...
@@ -17,20 +17,20 @@ class Doctrine_Inheritance_SingleTable_TestCase extends Doctrine_UnitTestCase
public
function
testMetadataSetup
()
public
function
testMetadataSetup
()
{
{
$user
Table
=
$this
->
conn
->
get
Metadata
(
'STI_User'
);
$user
Class
=
$this
->
conn
->
getClass
Metadata
(
'STI_User'
);
$superManager
Table
=
$this
->
conn
->
get
Metadata
(
'STI_SuperManager'
);
$superManager
Class
=
$this
->
conn
->
getClass
Metadata
(
'STI_SuperManager'
);
$manager
Table
=
$this
->
conn
->
get
Metadata
(
'STI_Manager'
);
$manager
Class
=
$this
->
conn
->
getClass
Metadata
(
'STI_Manager'
);
$customer
Table
=
$this
->
conn
->
get
Metadata
(
'STI_Customer'
);
$customer
Class
=
$this
->
conn
->
getClass
Metadata
(
'STI_Customer'
);
$this
->
assertEqual
(
4
,
count
(
$user
Table
->
getField
s
()));
$this
->
assertEqual
(
4
,
count
(
$user
Class
->
getMappedColumn
s
()));
$this
->
assertEqual
(
'sti_entity'
,
$user
Table
->
getTableName
());
$this
->
assertEqual
(
'sti_entity'
,
$user
Class
->
getTableName
());
$this
->
assertEqual
(
'sti_entity'
,
$manager
Table
->
getTableName
());
$this
->
assertEqual
(
'sti_entity'
,
$manager
Class
->
getTableName
());
// check inheritance map
// check inheritance map
$this
->
assertEqual
(
array
(
1
=>
'STI_User'
,
$this
->
assertEqual
(
array
(
1
=>
'STI_User'
,
2
=>
'STI_Manager'
,
2
=>
'STI_Manager'
,
3
=>
'STI_Customer'
,
3
=>
'STI_Customer'
,
4
=>
'STI_SuperManager'
),
$user
Table
->
getInheritanceOption
(
'discriminatorMap'
));
4
=>
'STI_SuperManager'
),
$user
Class
->
getInheritanceOption
(
'discriminatorMap'
));
//var_dump($superManagerTable->getComponentName());
//var_dump($superManagerTable->getComponentName());
}
}
...
...
tests_old/Metadata/FactoryTestCase.php
View file @
c1c3f489
...
@@ -25,8 +25,8 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
...
@@ -25,8 +25,8 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
$userClass
=
$this
->
conn
->
getClassMetadata
(
'Metadata_User'
);
$userClass
=
$this
->
conn
->
getClassMetadata
(
'Metadata_User'
);
$this
->
assertTrue
(
$userClass
instanceof
Doctrine_ClassMetadata
);
$this
->
assertTrue
(
$userClass
instanceof
Doctrine_ClassMetadata
);
$this
->
assertEqual
(
'cti_user'
,
$userClass
->
getTableName
());
$this
->
assertEqual
(
'cti_user'
,
$userClass
->
getTableName
());
$this
->
assertEqual
(
4
,
count
(
$userClass
->
get
Field
s
()));
$this
->
assertEqual
(
4
,
count
(
$userClass
->
get
MappedColumn
s
()));
$this
->
assertIdentical
(
array
(),
$userClass
->
get
Option
(
'parents'
));
$this
->
assertIdentical
(
array
(),
$userClass
->
get
ParentClasses
(
));
$this
->
assertEqual
(
'type'
,
$userClass
->
getInheritanceOption
(
'discriminatorColumn'
));
$this
->
assertEqual
(
'type'
,
$userClass
->
getInheritanceOption
(
'discriminatorColumn'
));
$this
->
assertIdentical
(
array
(
$this
->
assertIdentical
(
array
(
1
=>
'CTI_User'
,
1
=>
'CTI_User'
,
...
@@ -37,9 +37,9 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
...
@@ -37,9 +37,9 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
$managerClass
=
$this
->
conn
->
getMetadata
(
'Metadata_Manager'
);
$managerClass
=
$this
->
conn
->
getMetadata
(
'Metadata_Manager'
);
$this
->
assertTrue
(
$managerClass
instanceof
Doctrine_ClassMetadata
);
$this
->
assertTrue
(
$managerClass
instanceof
Doctrine_ClassMetadata
);
$this
->
assertIdentical
(
array
(
'Metadata_User'
),
$managerClass
->
get
Option
(
'parents'
));
$this
->
assertIdentical
(
array
(
'Metadata_User'
),
$managerClass
->
get
ParentClasses
(
));
$this
->
assertEqual
(
'cti_manager'
,
$managerClass
->
getTableName
());
$this
->
assertEqual
(
'cti_manager'
,
$managerClass
->
getTableName
());
$this
->
assertEqual
(
5
,
count
(
$managerClass
->
get
Field
s
()));
$this
->
assertEqual
(
5
,
count
(
$managerClass
->
get
MappedColumn
s
()));
$this
->
assertEqual
(
'type'
,
$managerClass
->
getInheritanceOption
(
'discriminatorColumn'
));
$this
->
assertEqual
(
'type'
,
$managerClass
->
getInheritanceOption
(
'discriminatorColumn'
));
$this
->
assertIdentical
(
array
(
$this
->
assertIdentical
(
array
(
1
=>
'CTI_User'
,
1
=>
'CTI_User'
,
...
@@ -50,9 +50,9 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
...
@@ -50,9 +50,9 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
$suManagerClass
=
$this
->
conn
->
getMetadata
(
'Metadata_SuperManager'
);
$suManagerClass
=
$this
->
conn
->
getMetadata
(
'Metadata_SuperManager'
);
$this
->
assertTrue
(
$suManagerClass
instanceof
Doctrine_ClassMetadata
);
$this
->
assertTrue
(
$suManagerClass
instanceof
Doctrine_ClassMetadata
);
$this
->
assertIdentical
(
array
(
'Metadata_Manager'
,
'Metadata_User'
),
$suManagerClass
->
get
Option
(
'parents'
));
$this
->
assertIdentical
(
array
(
'Metadata_Manager'
,
'Metadata_User'
),
$suManagerClass
->
get
ParentClasses
(
));
$this
->
assertEqual
(
'cti_supermanager'
,
$suManagerClass
->
getTableName
());
$this
->
assertEqual
(
'cti_supermanager'
,
$suManagerClass
->
getTableName
());
$this
->
assertEqual
(
6
,
count
(
$suManagerClass
->
get
Field
s
()));
$this
->
assertEqual
(
6
,
count
(
$suManagerClass
->
get
MappedColumn
s
()));
$this
->
assertEqual
(
'type'
,
$suManagerClass
->
getInheritanceOption
(
'discriminatorColumn'
));
$this
->
assertEqual
(
'type'
,
$suManagerClass
->
getInheritanceOption
(
'discriminatorColumn'
));
$this
->
assertIdentical
(
array
(
$this
->
assertIdentical
(
array
(
1
=>
'CTI_User'
,
1
=>
'CTI_User'
,
...
@@ -65,7 +65,7 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
...
@@ -65,7 +65,7 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
public
function
testExportableFormatOfClassInClassTableInheritanceHierarchy
()
public
function
testExportableFormatOfClassInClassTableInheritanceHierarchy
()
{
{
$userClass
=
$this
->
conn
->
getMetadata
(
'Metadata_User'
);
$userClass
=
$this
->
conn
->
get
Class
Metadata
(
'Metadata_User'
);
$userClassExportableFormat
=
$userClass
->
getExportableFormat
();
$userClassExportableFormat
=
$userClass
->
getExportableFormat
();
$this
->
assertEqual
(
4
,
count
(
$userClassExportableFormat
[
'columns'
]));
$this
->
assertEqual
(
4
,
count
(
$userClassExportableFormat
[
'columns'
]));
$this
->
assertTrue
(
isset
(
$userClassExportableFormat
[
'columns'
][
'cti_id'
]));
$this
->
assertTrue
(
isset
(
$userClassExportableFormat
[
'columns'
][
'cti_id'
]));
...
@@ -75,21 +75,21 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
...
@@ -75,21 +75,21 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
$this
->
assertTrue
(
isset
(
$userClassExportableFormat
[
'columns'
][
'cti_name'
]));
$this
->
assertTrue
(
isset
(
$userClassExportableFormat
[
'columns'
][
'cti_name'
]));
$this
->
assertTrue
(
isset
(
$userClassExportableFormat
[
'columns'
][
'type'
]));
$this
->
assertTrue
(
isset
(
$userClassExportableFormat
[
'columns'
][
'type'
]));
$managerClass
=
$this
->
conn
->
getMetadata
(
'Metadata_Manager'
);
$managerClass
=
$this
->
conn
->
get
Class
Metadata
(
'Metadata_Manager'
);
$managerClassExportableFormat
=
$managerClass
->
getExportableFormat
();
$managerClassExportableFormat
=
$managerClass
->
getExportableFormat
();
$this
->
assertEqual
(
2
,
count
(
$managerClassExportableFormat
[
'columns'
]));
$this
->
assertEqual
(
2
,
count
(
$managerClassExportableFormat
[
'columns'
]));
$this
->
assertTrue
(
isset
(
$managerClassExportableFormat
[
'columns'
][
'cti_id'
]));
$this
->
assertTrue
(
isset
(
$managerClassExportableFormat
[
'columns'
][
'cti_id'
]));
$this
->
assertTrue
(
isset
(
$managerClassExportableFormat
[
'columns'
][
'cti_id'
][
'primary'
]));
$this
->
assertTrue
(
isset
(
$managerClassExportableFormat
[
'columns'
][
'cti_id'
][
'primary'
]));
$this
->
assertFalse
(
isset
(
$managerClassExportableFormat
[
'columns'
][
'cti_id'
][
'autoincrement'
]));
$this
->
assertFalse
(
isset
(
$managerClassExportableFormat
[
'columns'
][
'cti_id'
][
'autoincrement'
]));
$customerClass
=
$this
->
conn
->
getMetadata
(
'Metadata_Customer'
);
$customerClass
=
$this
->
conn
->
get
Class
Metadata
(
'Metadata_Customer'
);
$customerClassExportableFormat
=
$customerClass
->
getExportableFormat
();
$customerClassExportableFormat
=
$customerClass
->
getExportableFormat
();
$this
->
assertEqual
(
2
,
count
(
$customerClassExportableFormat
[
'columns'
]));
$this
->
assertEqual
(
2
,
count
(
$customerClassExportableFormat
[
'columns'
]));
$this
->
assertTrue
(
isset
(
$customerClassExportableFormat
[
'columns'
][
'cti_id'
]));
$this
->
assertTrue
(
isset
(
$customerClassExportableFormat
[
'columns'
][
'cti_id'
]));
$this
->
assertTrue
(
isset
(
$customerClassExportableFormat
[
'columns'
][
'cti_id'
][
'primary'
]));
$this
->
assertTrue
(
isset
(
$customerClassExportableFormat
[
'columns'
][
'cti_id'
][
'primary'
]));
$this
->
assertFalse
(
isset
(
$customerClassExportableFormat
[
'columns'
][
'cti_id'
][
'autoincrement'
]));
$this
->
assertFalse
(
isset
(
$customerClassExportableFormat
[
'columns'
][
'cti_id'
][
'autoincrement'
]));
$superManagerClass
=
$this
->
conn
->
getMetadata
(
'Metadata_SuperManager'
);
$superManagerClass
=
$this
->
conn
->
get
Class
Metadata
(
'Metadata_SuperManager'
);
$superManagerClassExportableFormat
=
$superManagerClass
->
getExportableFormat
();
$superManagerClassExportableFormat
=
$superManagerClass
->
getExportableFormat
();
$this
->
assertEqual
(
2
,
count
(
$superManagerClassExportableFormat
[
'columns'
]));
$this
->
assertEqual
(
2
,
count
(
$superManagerClassExportableFormat
[
'columns'
]));
$this
->
assertTrue
(
isset
(
$superManagerClassExportableFormat
[
'columns'
][
'cti_id'
]));
$this
->
assertTrue
(
isset
(
$superManagerClassExportableFormat
[
'columns'
][
'cti_id'
]));
...
@@ -99,11 +99,11 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
...
@@ -99,11 +99,11 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
public
function
testMetadataSetupOnSingleTableInheritanceHierarchy
()
public
function
testMetadataSetupOnSingleTableInheritanceHierarchy
()
{
{
$userClass
=
$this
->
conn
->
getMetadata
(
'Metadata_STI_User'
);
$userClass
=
$this
->
conn
->
get
Class
Metadata
(
'Metadata_STI_User'
);
$this
->
assertTrue
(
$userClass
instanceof
Doctrine_ClassMetadata
);
$this
->
assertTrue
(
$userClass
instanceof
Doctrine_ClassMetadata
);
$this
->
assertEqual
(
'cti_user'
,
$userClass
->
getTableName
());
$this
->
assertEqual
(
'cti_user'
,
$userClass
->
getTableName
());
$this
->
assertEqual
(
4
,
count
(
$userClass
->
get
Field
s
()));
$this
->
assertEqual
(
4
,
count
(
$userClass
->
get
MappedColumn
s
()));
$this
->
assertIdentical
(
array
(),
$userClass
->
get
Option
(
'parents'
));
$this
->
assertIdentical
(
array
(),
$userClass
->
get
ParentClasses
(
));
$this
->
assertEqual
(
'type'
,
$userClass
->
getInheritanceOption
(
'discriminatorColumn'
));
$this
->
assertEqual
(
'type'
,
$userClass
->
getInheritanceOption
(
'discriminatorColumn'
));
$this
->
assertIdentical
(
array
(
$this
->
assertIdentical
(
array
(
1
=>
'CTI_User'
,
1
=>
'CTI_User'
,
...
@@ -111,11 +111,11 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
...
@@ -111,11 +111,11 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
3
=>
'CTI_Customer'
,
3
=>
'CTI_Customer'
,
4
=>
'CTI_SuperManager'
),
$userClass
->
getInheritanceOption
(
'discriminatorMap'
));
4
=>
'CTI_SuperManager'
),
$userClass
->
getInheritanceOption
(
'discriminatorMap'
));
$managerClass
=
$this
->
conn
->
getMetadata
(
'Metadata_STI_Manager'
);
$managerClass
=
$this
->
conn
->
get
Class
Metadata
(
'Metadata_STI_Manager'
);
$this
->
assertTrue
(
$managerClass
instanceof
Doctrine_ClassMetadata
);
$this
->
assertTrue
(
$managerClass
instanceof
Doctrine_ClassMetadata
);
$this
->
assertIdentical
(
array
(
'Metadata_STI_User'
),
$managerClass
->
get
Option
(
'parents'
));
$this
->
assertIdentical
(
array
(
'Metadata_STI_User'
),
$managerClass
->
get
ParentClasses
(
));
$this
->
assertEqual
(
'cti_user'
,
$managerClass
->
getTableName
());
$this
->
assertEqual
(
'cti_user'
,
$managerClass
->
getTableName
());
$this
->
assertEqual
(
5
,
count
(
$managerClass
->
get
Field
s
()));
$this
->
assertEqual
(
5
,
count
(
$managerClass
->
get
MappedColumn
s
()));
$this
->
assertEqual
(
'type'
,
$managerClass
->
getInheritanceOption
(
'discriminatorColumn'
));
$this
->
assertEqual
(
'type'
,
$managerClass
->
getInheritanceOption
(
'discriminatorColumn'
));
$this
->
assertIdentical
(
array
(
$this
->
assertIdentical
(
array
(
1
=>
'CTI_User'
,
1
=>
'CTI_User'
,
...
@@ -124,11 +124,11 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
...
@@ -124,11 +124,11 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
4
=>
'CTI_SuperManager'
),
$managerClass
->
getInheritanceOption
(
'discriminatorMap'
));
4
=>
'CTI_SuperManager'
),
$managerClass
->
getInheritanceOption
(
'discriminatorMap'
));
$suManagerClass
=
$this
->
conn
->
getMetadata
(
'Metadata_STI_SuperManager'
);
$suManagerClass
=
$this
->
conn
->
get
Class
Metadata
(
'Metadata_STI_SuperManager'
);
$this
->
assertTrue
(
$suManagerClass
instanceof
Doctrine_ClassMetadata
);
$this
->
assertTrue
(
$suManagerClass
instanceof
Doctrine_ClassMetadata
);
$this
->
assertIdentical
(
array
(
'Metadata_STI_Manager'
,
'Metadata_STI_User'
),
$suManagerClass
->
get
Option
(
'parents'
));
$this
->
assertIdentical
(
array
(
'Metadata_STI_Manager'
,
'Metadata_STI_User'
),
$suManagerClass
->
get
ParentClasses
(
));
$this
->
assertEqual
(
'cti_user'
,
$suManagerClass
->
getTableName
());
$this
->
assertEqual
(
'cti_user'
,
$suManagerClass
->
getTableName
());
$this
->
assertEqual
(
6
,
count
(
$suManagerClass
->
get
Field
s
()));
$this
->
assertEqual
(
6
,
count
(
$suManagerClass
->
get
MappedColumn
s
()));
$this
->
assertEqual
(
'type'
,
$suManagerClass
->
getInheritanceOption
(
'discriminatorColumn'
));
$this
->
assertEqual
(
'type'
,
$suManagerClass
->
getInheritanceOption
(
'discriminatorColumn'
));
$this
->
assertIdentical
(
array
(
$this
->
assertIdentical
(
array
(
1
=>
'CTI_User'
,
1
=>
'CTI_User'
,
...
...
tests_old/Ticket/381TestCase.php
View file @
c1c3f489
...
@@ -56,4 +56,5 @@ class Doctrine_Ticket_381_TestCase extends Doctrine_UnitTestCase {
...
@@ -56,4 +56,5 @@ class Doctrine_Ticket_381_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$obj
->
get
(
'name'
),
'yes2'
);
$this
->
assertEqual
(
$obj
->
get
(
'name'
),
'yes2'
);
$obj
->
save
();
$obj
->
save
();
}
}
}
}
tests_old/ValidatorTestCase.php
View file @
c1c3f489
...
@@ -139,6 +139,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
...
@@ -139,6 +139,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
public
function
testValidate
()
public
function
testValidate
()
{
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VALIDATE
,
Doctrine
::
VALIDATE_ALL
);
$user
=
$this
->
connection
->
getMapper
(
'User'
)
->
find
(
4
);
$user
=
$this
->
connection
->
getMapper
(
'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'
,
...
@@ -152,8 +153,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
...
@@ -152,8 +153,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$this
->
assertTrue
(
$user
->
getModified
()
==
$set
);
$this
->
assertTrue
(
$user
->
getModified
()
==
$set
);
$validator
=
new
Doctrine_Validator
();
$validator
=
new
Doctrine_Validator
();
$validator
->
validateRecord
(
$user
);
$validator
->
validateRecord
(
$user
);
$stack
=
$user
->
errorStack
();
$stack
=
$user
->
errorStack
();
...
@@ -171,6 +172,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
...
@@ -171,6 +172,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
$stack
=
$email
->
errorStack
();
$stack
=
$email
->
errorStack
();
$this
->
assertTrue
(
in_array
(
'unique'
,
$stack
[
'address'
]));
$this
->
assertTrue
(
in_array
(
'unique'
,
$stack
[
'address'
]));
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VALIDATE
,
Doctrine
::
VALIDATE_NONE
);
}
}
/**
/**
...
...
tests_old/models/Email.php
View file @
c1c3f489
...
@@ -3,7 +3,8 @@ class Email extends Doctrine_Record
...
@@ -3,7 +3,8 @@ class Email extends Doctrine_Record
{
{
public
static
function
initMetadata
(
$class
)
public
static
function
initMetadata
(
$class
)
{
{
$class
->
setColumn
(
'address'
,
'string'
,
150
,
array
(
'email'
,
'unique'
=>
true
));
$class
->
setColumn
(
'address'
,
'string'
,
150
,
array
(
'email'
,
'unique'
=>
true
,
'validators'
=>
array
(
'email'
,
'unique'
)));
}
}
...
...
tests_old/models/Entity.php
View file @
c1c3f489
...
@@ -5,7 +5,7 @@ class Entity extends Doctrine_Record
...
@@ -5,7 +5,7 @@ class Entity extends Doctrine_Record
{
{
$class
->
setColumn
(
'id'
,
'integer'
,
20
,
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
));
$class
->
setColumn
(
'id'
,
'integer'
,
20
,
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
));
$class
->
setColumn
(
'name'
,
'string'
,
50
);
$class
->
setColumn
(
'name'
,
'string'
,
50
);
$class
->
setColumn
(
'loginname'
,
'string'
,
20
,
array
(
'unique'
=>
true
));
$class
->
setColumn
(
'loginname'
,
'string'
,
20
,
array
(
'unique'
=>
true
,
'validators'
=>
array
(
'unique'
)
));
$class
->
setColumn
(
'password'
,
'string'
,
16
);
$class
->
setColumn
(
'password'
,
'string'
,
16
);
$class
->
setColumn
(
'type'
,
'integer'
);
$class
->
setColumn
(
'type'
,
'integer'
);
$class
->
setColumn
(
'created'
,
'integer'
,
11
);
$class
->
setColumn
(
'created'
,
'integer'
,
11
);
...
...
tests_old/models/ValidatorTest.php
View file @
c1c3f489
...
@@ -2,14 +2,23 @@
...
@@ -2,14 +2,23 @@
class
ValidatorTest
extends
Doctrine_Record
{
class
ValidatorTest
extends
Doctrine_Record
{
public
static
function
initMetadata
(
$class
)
{
public
static
function
initMetadata
(
$class
)
{
$class
->
setColumn
(
'mymixed'
,
'string'
,
100
);
$class
->
setColumn
(
'mymixed'
,
'string'
,
100
);
$class
->
setColumn
(
'mystring'
,
'string'
,
100
,
array
(
'notnull'
,
'unique'
));
$class
->
setColumn
(
'mystring'
,
'string'
,
100
,
array
(
'validators'
=>
array
(
'notnull'
,
'unique'
))
);
$class
->
setColumn
(
'myarray'
,
'array'
,
1000
);
$class
->
setColumn
(
'myarray'
,
'array'
,
1000
);
$class
->
setColumn
(
'myobject'
,
'object'
,
1000
);
$class
->
setColumn
(
'myobject'
,
'object'
,
1000
);
$class
->
setColumn
(
'myinteger'
,
'integer'
,
11
);
$class
->
setColumn
(
'myinteger'
,
'integer'
,
11
);
$class
->
setColumn
(
'myrange'
,
'integer'
,
11
,
array
(
'range'
=>
array
(
4
,
123
)));
$class
->
setColumn
(
'myrange'
,
'integer'
,
11
,
$class
->
setColumn
(
'myregexp'
,
'string'
,
5
,
array
(
'regexp'
=>
'/^[0-9]+$/'
));
array
(
'validators'
=>
array
(
'range'
=>
array
(
4
,
123
)))
);
$class
->
setColumn
(
'myemail'
,
'string'
,
100
,
array
(
'email'
));
$class
->
setColumn
(
'myregexp'
,
'string'
,
5
,
$class
->
setColumn
(
'myemail2'
,
'string'
,
100
,
array
(
'email'
,
'notblank'
));
array
(
'validators'
=>
array
(
'regexp'
=>
'/^[0-9]+$/'
))
);
$class
->
setColumn
(
'myemail'
,
'string'
,
100
,
array
(
'validators'
=>
array
(
'email'
))
);
$class
->
setColumn
(
'myemail2'
,
'string'
,
100
,
array
(
'validators'
=>
array
(
'email'
,
'notblank'
))
);
}
}
}
}
tests_old/models/ValidatorTest_AddressModel.php
View file @
c1c3f489
...
@@ -4,11 +4,16 @@ class ValidatorTest_AddressModel extends Doctrine_Record {
...
@@ -4,11 +4,16 @@ class ValidatorTest_AddressModel extends Doctrine_Record {
$class
->
setColumn
(
"id"
,
"integer"
,
11
,
array
(
'autoincrement'
=>
true
,
$class
->
setColumn
(
"id"
,
"integer"
,
11
,
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
'primary'
=>
true
));
));
$class
->
setColumn
(
'address1'
,
'string'
,
255
,
array
(
'notnull'
=>
true
,
'notblank'
));
$class
->
setColumn
(
'address1'
,
'string'
,
255
,
array
(
'notnull'
=>
true
,
$class
->
setColumn
(
'address2'
,
'string'
,
255
,
array
(
'notnull'
=>
true
));
'validators'
=>
array
(
'notnull'
,
'notblank'
)));
$class
->
setColumn
(
'city'
,
'string'
,
255
,
array
(
'notnull'
=>
true
,
'notblank'
));
$class
->
setColumn
(
'address2'
,
'string'
,
255
,
array
(
'notnull'
=>
true
,
$class
->
setColumn
(
'state'
,
'string'
,
10
,
array
(
'notnull'
=>
true
,
'notblank'
,
'usstate'
));
'validators'
=>
array
(
'notnull'
)));
$class
->
setColumn
(
'zip'
,
'string'
,
15
,
array
(
'notnull'
=>
true
,
'notblank'
,
'regexp'
=>
'/^[0-9-]*$/'
));
$class
->
setColumn
(
'city'
,
'string'
,
255
,
array
(
'notnull'
=>
true
,
'validators'
=>
array
(
'notnull'
,
'notblank'
)));
$class
->
setColumn
(
'state'
,
'string'
,
10
,
array
(
'notnull'
=>
true
,
'validators'
=>
array
(
'notnull'
,
'notblank'
,
'usstate'
)));
$class
->
setColumn
(
'zip'
,
'string'
,
15
,
array
(
'notnull'
=>
true
,
'validators'
=>
array
(
'notnull'
,
'notblank'
,
'regexp'
=>
'/^[0-9-]*$/'
)));
$class
->
hasMany
(
'ValidatorTest_ClientModel'
,
array
(
'local'
=>
'address_id'
,
'foreign'
=>
'client_id'
,
'refClass'
=>
'ValidatorTest_ClientToAddressModel'
));
$class
->
hasMany
(
'ValidatorTest_ClientModel'
,
array
(
'local'
=>
'address_id'
,
'foreign'
=>
'client_id'
,
'refClass'
=>
'ValidatorTest_ClientToAddressModel'
));
}
}
}
}
tests_old/models/ValidatorTest_DateModel.php
View file @
c1c3f489
<?php
<?php
class
ValidatorTest_DateModel
extends
Doctrine_Record
{
class
ValidatorTest_DateModel
extends
Doctrine_Record
{
public
static
function
initMetadata
(
$class
)
{
public
static
function
initMetadata
(
$class
)
{
$class
->
setColumn
(
'birthday'
,
'date'
,
null
,
array
(
'past'
));
$class
->
setColumn
(
'birthday'
,
'date'
,
null
,
$class
->
setColumn
(
'death'
,
'date'
,
null
,
array
(
'future'
));
array
(
'validators'
=>
array
(
'past'
)));
$class
->
setColumn
(
'death'
,
'date'
,
null
,
array
(
'validators'
=>
array
(
'future'
)));
}
}
}
}
tests_old/models/ValidatorTest_Person.php
View file @
c1c3f489
<?php
<?php
class
ValidatorTest_Person
extends
Doctrine_Record
{
class
ValidatorTest_Person
extends
Doctrine_Record
{
public
static
function
initMetadata
(
$class
)
{
public
static
function
initMetadata
(
$class
)
{
$class
->
setColumn
(
'identifier'
,
'integer'
,
4
,
array
(
'notblank'
,
'unique'
));
$class
->
setColumn
(
'identifier'
,
'integer'
,
4
,
array
(
'validators'
=>
array
(
'notblank'
,
'unique'
)));
$class
->
setColumn
(
'is_football_player'
,
'boolean'
);
$class
->
setColumn
(
'is_football_player'
,
'boolean'
);
$class
->
hasOne
(
'ValidatorTest_FootballPlayer'
,
array
(
'local'
=>
'id'
,
'foreign'
=>
'person_id'
));
$class
->
hasOne
(
'ValidatorTest_FootballPlayer'
,
array
(
'local'
=>
'id'
,
'foreign'
=>
'person_id'
));
}
}
}
}
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