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
0835a57c
Commit
0835a57c
authored
Oct 25, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #192, added Doctrine_Record_State_TestCase
Ticket: 192
parent
e06f0be6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
131 additions
and
25 deletions
+131
-25
Record.php
lib/Doctrine/Record.php
+10
-2
Table.php
lib/Doctrine/Table.php
+15
-8
documentation.php
manual/documentation.php
+11
-5
ImportTestCase.php
tests/ImportTestCase.php
+2
-1
RecordStateTestCase.php
tests/RecordStateTestCase.php
+80
-0
RecordTestCase.php
tests/RecordTestCase.php
+1
-1
RelationTestCase.php
tests/RelationTestCase.php
+5
-4
run.php
tests/run.php
+7
-4
No files found.
lib/Doctrine/Record.php
View file @
0835a57c
...
...
@@ -512,9 +512,14 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
$state
==
null
)
{
return
$this
->
_state
;
}
$err
=
false
;
if
(
is_integer
(
$state
))
{
if
(
$state
>=
1
&&
$state
<=
6
)
$this
->
_state
=
$state
;
else
$err
=
true
;
}
elseif
(
is_string
(
$state
))
{
$upper
=
strtoupper
(
$state
);
switch
(
$upper
)
{
...
...
@@ -526,10 +531,13 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
case
'DELETED'
:
$this
->
_state
=
constant
(
'Doctrine_Record::STATE_'
.
$upper
);
break
;
default
:
$err
=
true
;
}
}
}
throw
new
Doctrine_Record_State_Exception
(
'Unknown record state '
.
$state
);
if
(
$err
)
throw
new
Doctrine_Record_State_Exception
(
'Unknown record state '
.
$state
);
}
/**
* refresh
...
...
lib/Doctrine/Table.php
View file @
0835a57c
...
...
@@ -177,7 +177,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$names
=
array_reverse
(
$names
);
// create database table
if
(
method_exists
(
$record
,
"setTableDefinition"
))
{
if
(
method_exists
(
$record
,
'setTableDefinition'
))
{
$record
->
setTableDefinition
();
$this
->
columnCount
=
count
(
$this
->
columns
);
...
...
@@ -185,7 +185,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
if
(
isset
(
$this
->
columns
))
{
// get the declaring class of setTableDefinition method
$method
=
new
ReflectionMethod
(
$this
->
options
[
'name'
],
"setTableDefinition"
);
$method
=
new
ReflectionMethod
(
$this
->
options
[
'name'
],
'setTableDefinition'
);
$class
=
$method
->
getDeclaringClass
();
if
(
!
isset
(
$this
->
options
[
'tableName'
]))
...
...
@@ -193,9 +193,17 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
switch
(
count
(
$this
->
primaryKeys
))
:
case
0
:
$this
->
columns
=
array_merge
(
array
(
"id"
=>
array
(
"integer"
,
20
,
array
(
"autoincrement"
=>
true
,
"primary"
=>
true
))),
$this
->
columns
);
$this
->
primaryKeys
[]
=
"id"
;
$this
->
identifier
=
"id"
;
$this
->
columns
=
array_merge
(
array
(
'id'
=>
array
(
'integer'
,
20
,
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
)
)
),
$this
->
columns
);
$this
->
primaryKeys
[]
=
'id'
;
$this
->
identifier
=
'id'
;
$this
->
identifierType
=
Doctrine_Identifier
::
AUTO_INCREMENT
;
$this
->
columnCount
++
;
break
;
...
...
@@ -964,9 +972,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
*/
final
public
function
enumValue
(
$field
,
$index
)
{
if
(
$index
instanceof
Doctrine_Null
)
{
return
$index
;
}
return
$index
;
return
isset
(
$this
->
options
[
'enumMap'
][
$field
][
$index
])
?
$this
->
options
[
'enumMap'
][
$field
][
$index
]
:
$index
;
}
/**
...
...
manual/documentation.php
View file @
0835a57c
...
...
@@ -343,10 +343,16 @@ $menu = array("Getting started" =>
"Transactions"
=>
array
(
"Introduction"
,
"Unit of work"
,
"Nesting"
,
"Savepoints"
,
"Locking strategies"
=>
array
(
"Pessimistic locking"
,
"Optimistic locking"
),
"Nesting"
"Lock modes"
,
"Isolation levels"
,
"Deadlocks"
,
),
/**
"Developer components" => array(
...
...
@@ -466,12 +472,12 @@ $menu = array("Getting started" =>
if
(
!
file_exists
(
"docs/
$title
-
$k
-
$v2
.php"
))
{
$missing
[
0
]
++
;
$str
.=
" [ <font color='red'>doc</font> ] "
;
touch
(
"docs/
$title
-
$k
-
$v2
.php"
);
//
touch("docs/$title - $k - $v2.php");
}
if
(
!
file_exists
(
"codes/
$title
-
$k
-
$v2
.php"
))
{
$missing
[
1
]
++
;
$str
.=
" [ <font color='red'>code</font> ] "
;
touch
(
"codes/
$title
-
$k
-
$v2
.php"
);
//
touch("codes/$title - $k - $v2.php");
}
...
...
@@ -486,12 +492,12 @@ $menu = array("Getting started" =>
if
(
!
file_exists
(
"docs/
$title
-
$t
.php"
))
{
$missing
[
0
]
++
;
$str
.=
" [ <font color='red'>doc</font> ] "
;
touch
(
"docs/
$title
-
$t
.php"
);
//
touch("docs/$title - $t.php");
}
if
(
!
file_exists
(
"codes/
$title
-
$t
.php"
))
{
$missing
[
1
]
++
;
$str
.=
" [ <font color='red'>code</font> ] "
;
touch
(
"codes/
$title
-
$t
.php"
);
//
touch("codes/$title - $t.php");
}
print
"<dt>"
.
$e
.
" <a href=
\"
"
.
$_SERVER
[
'PHP_SELF'
]
.
"?index=
$i
#
$e
\"
>"
.
$t
.
"</a>
$str
</dt>
\n
"
;
}
...
...
tests/ImportTestCase.php
View file @
0835a57c
...
...
@@ -90,6 +90,7 @@ class Doctrine_Import_TestCase extends Doctrine_UnitTestCase {
unlink
(
'tmp'
.
DIRECTORY_SEPARATOR
.
'ImportTest.php'
);
}
public
function
testForeignKeySupport
()
{
/**
$this->dbh->query('CREATE TABLE album (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
title VARCHAR(100),
...
...
@@ -109,7 +110,7 @@ class Doctrine_Import_TestCase extends Doctrine_UnitTestCase {
$sql = "PRAGMA table_info(track)";
$sql = "PRAGMA foreign_key_list(track)";
$result = $this->dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
*/
}
...
...
tests/RecordStateTestCase.php
0 → 100644
View file @
0835a57c
<?php
class
Doctrine_Record_State_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareTables
()
{
}
public
function
prepareData
()
{
}
public
function
testAssignUnknownState
()
{
$user
=
new
User
();
try
{
$user
->
state
(
123123
);
$this
->
fail
();
}
catch
(
Doctrine_Record_State_Exception
$e
)
{
$this
->
pass
();
}
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_TCLEAN
);
try
{
$user
->
state
(
'some unknown state'
);
$this
->
fail
();
}
catch
(
Doctrine_Record_State_Exception
$e
)
{
$this
->
pass
();
}
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_TCLEAN
);
}
public
function
testAssignDirtyState
()
{
$user
=
new
User
();
$user
->
state
(
Doctrine_Record
::
STATE_DIRTY
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_DIRTY
);
$user
->
state
(
'dirty'
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_DIRTY
);
}
public
function
testAssignCleanState
()
{
$user
=
new
User
();
$user
->
state
(
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_CLEAN
);
$user
->
state
(
'clean'
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_CLEAN
);
}
public
function
testAssignTransientCleanState
()
{
$user
=
new
User
();
$user
->
state
(
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_TCLEAN
);
$user
->
state
(
'tclean'
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_TCLEAN
);
}
public
function
testAssignTransientDirtyState
()
{
$user
=
new
User
();
$user
->
state
(
Doctrine_Record
::
STATE_TDIRTY
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_TDIRTY
);
$user
->
state
(
'tdirty'
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_TDIRTY
);
}
public
function
testAssignProxyState
()
{
$user
=
new
User
();
$user
->
state
(
Doctrine_Record
::
STATE_PROXY
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_PROXY
);
$user
->
state
(
'proxy'
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_PROXY
);
}
}
?>
tests/RecordTestCase.php
View file @
0835a57c
<?php
require_once
(
"UnitTestCase.php"
);
class
Doctrine_RecordTestCase
extends
Doctrine_UnitTestCase
{
class
Doctrine_Record
_
TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareTables
()
{
$this
->
tables
[]
=
"enumTest"
;
...
...
tests/RelationTestCase.php
View file @
0835a57c
...
...
@@ -3,11 +3,12 @@
class
RelationTest
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'name'
,
'string'
,
200
);
$this
->
hasColumn
(
"child_id"
,
"integer"
);
$this
->
hasColumn
(
'child_id'
,
'integer'
);
}
public
function
setUp
()
{
$this
->
ownsMany
(
'OwnsOneToManyWithAlias as AliasO2M'
,
'AliasO2M.component_id'
);
$this
->
hasMany
(
'HasManyToManyWithAlias as AliasM2M'
,
'JoinTable.c1_id'
);
$this
->
hasMany
(
'M2M as AliasM2M'
,
'JoinTable.c1_id'
);
// $this->hasMany('M2M as AliasM2M2', 'JoinTable.c1_id');
}
}
class
RelationTestChild
extends
RelationTest
{
...
...
@@ -41,7 +42,7 @@ class OwnsOneToManyWithAlias extends Doctrine_Record {
}
}
class
HasManyToManyWithAlias
extends
Doctrine_Record
{
class
M2M
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'name'
,
'string'
,
200
);
}
...
...
@@ -52,7 +53,7 @@ class HasManyToManyWithAlias extends Doctrine_Record {
class
Doctrine_Relation_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
$this
->
tables
=
array
(
'
HasManyToManyWithAlias
'
,
'RelationTest'
,
'JoinTable'
);
$this
->
tables
=
array
(
'
M2M
'
,
'RelationTest'
,
'JoinTable'
);
parent
::
prepareTables
();
}
...
...
tests/run.php
View file @
0835a57c
...
...
@@ -12,6 +12,7 @@ require_once("BatchIteratorTestCase.php");
require_once
(
"CacheFileTestCase.php"
);
require_once
(
"RecordTestCase.php"
);
require_once
(
"RecordStateTestCase.php"
);
require_once
(
"RecordFilterTestCase.php"
);
require_once
(
"AccessTestCase.php"
);
...
...
@@ -57,13 +58,15 @@ print "<pre>";
$test
=
new
GroupTest
(
"Doctrine Framework Unit Tests"
);
$test
->
addTestCase
(
new
Doctrine_
Import
_TestCase
());
$test
->
addTestCase
(
new
Doctrine_
Relation
_TestCase
());
$test
->
addTestCase
(
new
Doctrine_
Schema
TestCase
());
$test
->
addTestCase
(
new
Doctrine_
Record_
TestCase
());
$test
->
addTestCase
(
new
Doctrine_Re
lation
_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Re
cord_State
_TestCase
());
$test
->
addTestCase
(
new
Doctrine_RecordTestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_TestCase
());
$test
->
addTestCase
(
new
Doctrine_SchemaTestCase
());
$test
->
addTestCase
(
new
Doctrine_ValidatorTestCase
());
...
...
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