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
d1ad19fd
Commit
d1ad19fd
authored
Dec 27, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified the test structure
parent
a622f9ab
Changes
29
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
783 additions
and
695 deletions
+783
-695
AccessTestCase.php
tests/AccessTestCase.php
+58
-29
BatchIteratorTestCase.php
tests/BatchIteratorTestCase.php
+31
-2
BooleanTestCase.php
tests/BooleanTestCase.php
+32
-1
CollectionTestCase.php
tests/CollectionTestCase.php
+32
-1
ConfigurableTestCase.php
tests/ConfigurableTestCase.php
+5
-4
SqliteTestCase.php
tests/Connection/SqliteTestCase.php
+1
-1
ConnectionTestCase.php
tests/ConnectionTestCase.php
+69
-47
CustomPrimaryKeyTestCase.php
tests/CustomPrimaryKeyTestCase.php
+31
-2
CustomResultSetOrderTestCase.php
tests/CustomResultSetOrderTestCase.php
+33
-2
DriverTestCase.php
tests/DriverTestCase.php
+12
-3
EnumTestCase.php
tests/EnumTestCase.php
+32
-1
EventListenerChainTestCase.php
tests/EventListenerChainTestCase.php
+31
-1
EventListenerTestCase.php
tests/EventListenerTestCase.php
+32
-2
ExportReporterTestCase.php
tests/ExportReporterTestCase.php
+9
-2
ExportTestCase.php
tests/ExportTestCase.php
+3
-5
ManagerTestCase.php
tests/ManagerTestCase.php
+32
-2
PessimisticLockingTestCase.php
tests/PessimisticLockingTestCase.php
+32
-5
RecordStateTestCase.php
tests/RecordStateTestCase.php
+0
-80
TableTestCase.php
tests/TableTestCase.php
+32
-2
TransactionFirebirdTestCase.php
tests/TransactionFirebirdTestCase.php
+0
-75
TransactionMssqlTestCase.php
tests/TransactionMssqlTestCase.php
+0
-30
TransactionMysqlTestCase.php
tests/TransactionMysqlTestCase.php
+0
-40
TransactionOracleTestCase.php
tests/TransactionOracleTestCase.php
+0
-39
TransactionPgsqlTestCase.php
tests/TransactionPgsqlTestCase.php
+0
-35
TransactionSqliteTestCase.php
tests/TransactionSqliteTestCase.php
+0
-25
UnitTestCase.php
tests/UnitTestCase.php
+101
-68
ValidatorTestCase.php
tests/ValidatorTestCase.php
+30
-1
ViewTestCase.php
tests/ViewTestCase.php
+32
-1
run.php
tests/run.php
+113
-189
No files found.
tests/AccessTestCase.php
View file @
d1ad19fd
<?php
class
Doctrine_AccessTestCase
extends
Doctrine_UnitTestCase
{
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Access_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Access_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
$this
->
tables
=
array
(
"Entity"
,
"User"
);
$this
->
tables
=
array
(
'Entity'
,
'User'
);
parent
::
prepareTables
();
}
public
function
testUnset
()
{
public
function
testUnset
()
{
}
public
function
testIsset
()
{
...
...
@@ -32,54 +61,54 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
}
public
function
testOffsetMethods
()
{
$user
=
new
User
();
$this
->
assertEqual
(
$user
[
"name"
],
null
);
$this
->
assertEqual
(
$user
[
'name'
],
null
);
$user
[
"name"
]
=
"Jack"
;
$this
->
assertEqual
(
$user
[
"name"
],
"Jack"
);
$user
[
'name'
]
=
'Jack'
;
$this
->
assertEqual
(
$user
[
'name'
],
'Jack'
);
$user
->
save
();
$user
=
$this
->
connection
->
getTable
(
"User"
)
->
find
(
$user
->
obtainIdentifier
());
$this
->
assertEqual
(
$user
->
name
,
"Jack"
);
$user
=
$this
->
connection
->
getTable
(
'User'
)
->
find
(
$user
->
obtainIdentifier
());
$this
->
assertEqual
(
$user
->
name
,
'Jack'
);
$user
[
"name"
]
=
"Jack"
;
$this
->
assertEqual
(
$user
[
"name"
],
"Jack"
);
$user
[
"name"
]
=
"zYne"
;
$this
->
assertEqual
(
$user
[
"name"
],
"zYne"
);
$user
[
'name'
]
=
'Jack'
;
$this
->
assertEqual
(
$user
[
'name'
],
'Jack'
);
$user
[
'name'
]
=
'zYne'
;
$this
->
assertEqual
(
$user
[
'name'
],
'zYne'
);
}
public
function
testOverload
()
{
$user
=
new
User
();
$this
->
assertEqual
(
$user
->
name
,
null
);
$user
->
name
=
"Jack"
;
$user
->
name
=
'Jack'
;
$this
->
assertEqual
(
$user
->
name
,
"Jack"
);
$this
->
assertEqual
(
$user
->
name
,
'Jack'
);
$user
->
save
();
$user
=
$this
->
connection
->
getTable
(
"User"
)
->
find
(
$user
->
obtainIdentifier
());
$this
->
assertEqual
(
$user
->
name
,
"Jack"
);
$user
=
$this
->
connection
->
getTable
(
'User'
)
->
find
(
$user
->
obtainIdentifier
());
$this
->
assertEqual
(
$user
->
name
,
'Jack'
);
$user
->
name
=
"Jack"
;
$this
->
assertEqual
(
$user
->
name
,
"Jack"
);
$user
->
name
=
"zYne"
;
$this
->
assertEqual
(
$user
->
name
,
"zYne"
);
$user
->
name
=
'Jack'
;
$this
->
assertEqual
(
$user
->
name
,
'Jack'
);
$user
->
name
=
'zYne'
;
$this
->
assertEqual
(
$user
->
name
,
'zYne'
);
}
public
function
testSet
()
{
$user
=
new
User
();
$this
->
assertEqual
(
$user
->
get
(
"name"
),
null
);
$this
->
assertEqual
(
$user
->
get
(
'name'
),
null
);
$user
->
set
(
"name"
,
"Jack"
);
$this
->
assertEqual
(
$user
->
get
(
"name"
),
"Jack"
);
$user
->
set
(
'name'
,
'Jack'
);
$this
->
assertEqual
(
$user
->
get
(
'name'
),
'Jack'
);
$user
->
save
();
$user
=
$this
->
connection
->
getTable
(
"User"
)
->
find
(
$user
->
obtainIdentifier
());
$user
=
$this
->
connection
->
getTable
(
'User'
)
->
find
(
$user
->
obtainIdentifier
());
$this
->
assertEqual
(
$user
->
get
(
"name"
),
"Jack"
);
$this
->
assertEqual
(
$user
->
get
(
'name'
),
'Jack'
);
$user
->
set
(
"name"
,
"Jack"
);
$this
->
assertEqual
(
$user
->
get
(
"name"
),
"Jack"
);
$user
->
set
(
'name'
,
'Jack'
);
$this
->
assertEqual
(
$user
->
get
(
'name'
),
'Jack'
);
}
}
?>
tests/BatchIteratorTestCase.php
View file @
d1ad19fd
<?php
require_once
(
"UnitTestCase.php"
);
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
class
Doctrine_BatchIteratorTestCase
extends
Doctrine_UnitTestCase
{
/**
* Doctrine_BatchIterator_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_BatchIterator_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareTables
()
{
$this
->
tables
=
array
(
"Entity"
,
"User"
,
"Group"
,
"Address"
,
"Phonenumber"
);
...
...
tests/BooleanTestCase.php
View file @
d1ad19fd
<?php
class
Doctrine_BooleanTestCase
extends
Doctrine_UnitTestCase
{
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Boolean_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Boolean_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
$this
->
tables
=
array
(
"BooleanTest"
);
...
...
tests/CollectionTestCase.php
View file @
d1ad19fd
<?php
class
Doctrine_CollectionTestCase
extends
Doctrine_UnitTestCase
{
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Collection_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Collection_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testLoadRelatedForAssociation
()
{
$coll
=
$this
->
connection
->
query
(
"FROM User"
);
...
...
tests/ConfigurableTestCase.php
View file @
d1ad19fd
...
...
@@ -7,11 +7,11 @@ class Doctrine_Configurable_TestCase extends Doctrine_UnitTestCase {
public
function
testGetIndexNameFormatAttribute
()
{
// default index name format is %_idx
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_IDXNAME_FORMAT
),
'%_idx'
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_IDXNAME_FORMAT
),
'%
s
_idx'
);
}
public
function
testGetSequenceNameFormatAttribute
()
{
// default sequence name format is %_seq
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_SEQNAME_FORMAT
),
'%_seq'
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_SEQNAME_FORMAT
),
'%
s
_seq'
);
}
public
function
testSetIndexNameFormatAttribute
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_IDXNAME_FORMAT
,
'%_index'
);
...
...
@@ -25,7 +25,7 @@ class Doctrine_Configurable_TestCase extends Doctrine_UnitTestCase {
}
public
function
testExceptionIsThrownWhenSettingIndexNameFormatAttributeAtTableLevel
()
{
try
{
$this
->
connection
->
getTable
(
'Entity'
)
->
setAttribute
(
Doctrine
::
ATTR_IDXNAME_FORMAT
,
'%_idx'
);
$this
->
connection
->
getTable
(
'Entity'
)
->
setAttribute
(
Doctrine
::
ATTR_IDXNAME_FORMAT
,
'%
s
_idx'
);
$this
->
fail
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
pass
();
...
...
@@ -33,7 +33,7 @@ class Doctrine_Configurable_TestCase extends Doctrine_UnitTestCase {
}
public
function
testExceptionIsThrownWhenSettingSequenceNameFormatAttributeAtTableLevel
()
{
try
{
$this
->
connection
->
getTable
(
'Entity'
)
->
setAttribute
(
Doctrine
::
ATTR_SEQNAME_FORMAT
,
'%_seq'
);
$this
->
connection
->
getTable
(
'Entity'
)
->
setAttribute
(
Doctrine
::
ATTR_SEQNAME_FORMAT
,
'%
s
_seq'
);
$this
->
fail
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
pass
();
...
...
@@ -86,6 +86,7 @@ class Doctrine_Configurable_TestCase extends Doctrine_UnitTestCase {
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_QUOTE_IDENTIFIER
,
true
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_QUOTE_IDENTIFIER
),
true
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_QUOTE_IDENTIFIER
,
false
);
}
public
function
testDefaultSequenceColumnNameAttributeValueIsId
()
{
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_SEQCOL_NAME
),
'id'
);
...
...
tests/Connection/SqliteTestCase.php
View file @
d1ad19fd
<?php
class
Doctrine_Connection_Sqlite_TestCase
extends
Doctrine_
Driver_
UnitTestCase
{
class
Doctrine_Connection_Sqlite_TestCase
extends
Doctrine_UnitTestCase
{
public
function
__construct
()
{
parent
::
__construct
(
'sqlite'
);
}
...
...
tests/ConnectionTestCase.php
View file @
d1ad19fd
<?php
require_once
(
"UnitTestCase.php"
);
class
Doctrine_ConnectionTestCase
extends
Doctrine_UnitTestCase
{
public
function
testBulkInsert
()
{
$u1
=
new
User
();
$u1
->
name
=
"Jean Reno"
;
$u1
->
save
();
$id
=
$u1
->
obtainIdentifier
();
$u1
->
delete
();
}
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Connection_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Connection_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testUnknownModule
()
{
try
{
$this
->
connection
->
unknown
;
...
...
@@ -27,25 +49,25 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
}
public
function
testFlush
()
{
$user
=
$this
->
connection
->
getTable
(
"User"
)
->
find
(
4
);
$user
=
$this
->
connection
->
getTable
(
'User'
)
->
find
(
4
);
$this
->
assertTrue
(
is_numeric
(
$user
->
Phonenumber
[
0
]
->
entity_id
));
$user
=
$this
->
connection
->
create
(
"Email"
);
$user
=
$this
->
connection
->
create
(
"User"
);
$record
=
$this
->
connection
->
create
(
"Phonenumber"
);
$user
=
$this
->
connection
->
create
(
'Email'
);
$user
=
$this
->
connection
->
create
(
'User'
);
$record
=
$this
->
connection
->
create
(
'Phonenumber'
);
$user
->
Email
->
address
=
"example@drinkmore.info"
;
$user
->
Email
->
address
=
'example@drinkmore.info'
;
$this
->
assertTrue
(
$user
->
email_id
instanceof
Email
);
$user
->
name
=
"Example user"
;
$user
->
Group
[
0
]
->
name
=
"Example group 1"
;
$user
->
Group
[
1
]
->
name
=
"Example group 2"
;
$user
->
name
=
'Example user'
;
$user
->
Group
[
0
]
->
name
=
'Example group 1'
;
$user
->
Group
[
1
]
->
name
=
'Example group 2'
;
$user
->
Phonenumber
[
0
]
->
phonenumber
=
"123 123"
;
$user
->
Phonenumber
[
0
]
->
phonenumber
=
'123 123'
;
$user
->
Phonenumber
[
1
]
->
phonenumber
=
"321 2132"
;
$user
->
Phonenumber
[
2
]
->
phonenumber
=
"123 123"
;
$user
->
Phonenumber
[
3
]
->
phonenumber
=
"321 2132"
;
$user
->
Phonenumber
[
1
]
->
phonenumber
=
'321 2132'
;
$user
->
Phonenumber
[
2
]
->
phonenumber
=
'123 123'
;
$user
->
Phonenumber
[
3
]
->
phonenumber
=
'321 2132'
;
...
...
@@ -73,7 +95,7 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
$user
=
$this
->
objTable
->
find
(
5
);
$pf
=
$this
->
connection
->
getTable
(
"Phonenumber"
);
$pf
=
$this
->
connection
->
getTable
(
'Phonenumber'
);
$this
->
assertTrue
(
$user
->
Phonenumber
instanceof
Doctrine_Collection
);
$this
->
assertTrue
(
$user
->
Phonenumber
->
count
()
==
3
);
...
...
@@ -91,10 +113,10 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
// ADDING REFERENCES
$user
->
Phonenumber
[
0
]
->
phonenumber
=
"123 123"
;
$user
->
Phonenumber
[
0
]
->
phonenumber
=
'123 123'
;
$this
->
assertTrue
(
is_numeric
(
$user
->
Phonenumber
[
0
]
->
entity_id
));
$user
->
Phonenumber
[
1
]
->
phonenumber
=
"123 123"
;
$user
->
Phonenumber
[
1
]
->
phonenumber
=
'123 123'
;
$this
->
connection
->
flush
();
...
...
@@ -104,7 +126,7 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
$user
=
$this
->
objTable
->
find
(
5
);
$this
->
assertEqual
(
$user
->
Phonenumber
->
count
(),
2
);
$user
->
Phonenumber
[
3
]
->
phonenumber
=
"123 123"
;
$user
->
Phonenumber
[
3
]
->
phonenumber
=
'123 123'
;
$this
->
connection
->
flush
();
$this
->
assertEqual
(
$user
->
Phonenumber
->
count
(),
3
);
...
...
@@ -123,8 +145,8 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
// ADDING REFERENCES WITH STRING KEYS
$user
->
Phonenumber
[
"home"
]
->
phonenumber
=
"123 123"
;
$user
->
Phonenumber
[
"work"
]
->
phonenumber
=
"444 444"
;
$user
->
Phonenumber
[
'home'
]
->
phonenumber
=
'123 123'
;
$user
->
Phonenumber
[
'work'
]
->
phonenumber
=
'444 444'
;
$this
->
assertEqual
(
$user
->
Phonenumber
->
count
(),
2
);
$this
->
connection
->
flush
();
...
...
@@ -138,9 +160,9 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
unset
(
$coll
);
$coll
=
new
Doctrine_Collection
(
$pf
);
$coll
[
0
]
->
phonenumber
=
"123 123"
;
$coll
[
"home"
]
->
phonenumber
=
"444 444"
;
$coll
[
"work"
]
->
phonenumber
=
"444 444"
;
$coll
[
0
]
->
phonenumber
=
'123 123'
;
$coll
[
'home'
]
->
phonenumber
=
'444 444'
;
$coll
[
'work'
]
->
phonenumber
=
'444 444'
;
...
...
@@ -154,28 +176,28 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
// ONE-TO-ONE REFERENCES
$user
->
Email
->
address
=
"drinker@drinkmore.info"
;
$user
->
Email
->
address
=
'drinker@drinkmore.info'
;
$this
->
assertTrue
(
$user
->
Email
instanceof
Email
);
$this
->
connection
->
flush
();
$this
->
assertTrue
(
$user
->
Email
instanceof
Email
);
$user
=
$this
->
objTable
->
find
(
5
);
$this
->
assertEqual
(
$user
->
Email
->
address
,
"drinker@drinkmore.info"
);
$this
->
assertEqual
(
$user
->
Email
->
address
,
'drinker@drinkmore.info'
);
$id
=
$user
->
Email
->
id
;
// REPLACING ONE-TO-ONE REFERENCES
$email
=
$this
->
connection
->
create
(
"Email"
);
$email
->
address
=
"absolutist@nottodrink.com"
;
$email
=
$this
->
connection
->
create
(
'Email'
);
$email
->
address
=
'absolutist@nottodrink.com'
;
$user
->
Email
=
$email
;
$this
->
assertTrue
(
$user
->
Email
instanceof
Email
);
$this
->
assertEqual
(
$user
->
Email
->
address
,
"absolutist@nottodrink.com"
);
$this
->
assertEqual
(
$user
->
Email
->
address
,
'absolutist@nottodrink.com'
);
$this
->
connection
->
flush
();
unset
(
$user
);
$user
=
$this
->
objTable
->
find
(
5
);
$this
->
assertTrue
(
$user
->
Email
instanceof
Email
);
$this
->
assertEqual
(
$user
->
Email
->
address
,
"absolutist@nottodrink.com"
);
$this
->
assertEqual
(
$user
->
Email
->
address
,
'absolutist@nottodrink.com'
);
$emails
=
$this
->
connection
->
query
(
"FROM Email WHERE Email.id =
$id
"
);
//$this->assertEqual(count($emails),0);
...
...
@@ -187,31 +209,31 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$this
->
connection
->
getManager
(),
$this
->
manager
);
}
public
function
testQuery
()
{
$this
->
assertTrue
(
$this
->
connection
->
query
(
"FROM User"
)
instanceof
Doctrine_Collection
);
$this
->
assertTrue
(
$this
->
connection
->
query
(
'FROM User'
)
instanceof
Doctrine_Collection
);
}
public
function
testDelete
()
{
$user
=
$this
->
connection
->
create
(
"User"
);
$user
=
$this
->
connection
->
create
(
'User'
);
$this
->
connection
->
delete
(
$user
);
$this
->
assertEqual
(
$user
->
getState
(),
Doctrine_Record
::
STATE_TCLEAN
);
}
public
function
testGetTable
()
{
$table
=
$this
->
connection
->
getTable
(
"Group"
);
$table
=
$this
->
connection
->
getTable
(
'Group'
);
$this
->
assertTrue
(
$table
instanceof
Doctrine_Table
);
try
{
$table
=
$this
->
connection
->
getTable
(
"Unknown"
);
$table
=
$this
->
connection
->
getTable
(
'Unknown'
);
$f
=
false
;
}
catch
(
Doctrine_Exception
$e
)
{
$f
=
true
;
}
$this
->
assertTrue
(
$f
);
$table
=
$this
->
connection
->
getTable
(
"User"
);
$table
=
$this
->
connection
->
getTable
(
'User'
);
$this
->
assertTrue
(
$table
instanceof
UserTable
);
}
public
function
testCreate
()
{
$email
=
$this
->
connection
->
create
(
"Email"
);
$email
=
$this
->
connection
->
create
(
'Email'
);
$this
->
assertTrue
(
$email
instanceof
Email
);
}
public
function
testGetDbh
()
{
...
...
@@ -225,7 +247,7 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
}
public
function
testGetState
()
{
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Transaction
::
STATE_SLEEP
);
$this
->
assertEqual
(
Doctrine_Lib
::
getConnectionStateAsString
(
$this
->
connection
->
transaction
->
getState
()),
"open"
);
$this
->
assertEqual
(
Doctrine_Lib
::
getConnectionStateAsString
(
$this
->
connection
->
transaction
->
getState
()),
'open'
);
}
public
function
testGetTables
()
{
$this
->
assertTrue
(
is_array
(
$this
->
connection
->
getTables
()));
...
...
@@ -242,12 +264,12 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
$user
=
$this
->
objTable
->
find
(
6
);
$user
->
name
=
"Jack Daniels"
;
$user
->
name
=
'Jack Daniels'
;
$this
->
connection
->
flush
();
$this
->
connection
->
commit
();
$user
=
$this
->
objTable
->
find
(
6
);
$this
->
assertEqual
(
$user
->
name
,
"Jack Daniels"
);
$this
->
assertEqual
(
$user
->
name
,
'Jack Daniels'
);
}
...
...
tests/CustomPrimaryKeyTestCase.php
View file @
d1ad19fd
<?php
require_once
(
"UnitTestCase.php"
);
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
class
Doctrine_CustomPrimaryKeyTestCase
extends
Doctrine_UnitTestCase
{
/**
* Doctrine_CustomPrimaryKey_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_CustomPrimaryKey_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
...
...
tests/CustomResultSetOrderTestCase.php
View file @
d1ad19fd
<?
PHP
class
Doctrine_CustomResultSetOrderTestCase
extends
Doctrine_UnitTestCase
{
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_CustomResultSetOrder_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_CustomResultSetOrder_TestCase
extends
Doctrine_UnitTestCase
{
/**
* Prepares the data under test.
...
...
tests/DriverTestCase.php
View file @
d1ad19fd
...
...
@@ -15,7 +15,7 @@ class AdapterMock implements Doctrine_Adapter_Interface {
public
function
pop
()
{
return
array_pop
(
$this
->
queries
);
}
public
function
forceException
(
$name
,
$message
,
$code
)
{
public
function
forceException
(
$name
,
$message
=
''
,
$code
=
0
)
{
$this
->
exception
=
array
(
$name
,
$message
,
$code
);
}
public
function
prepare
(
$prepareString
){
...
...
@@ -69,7 +69,7 @@ class AdapterMock implements Doctrine_Adapter_Interface {
public
function
errorInfo
(){
}
public
function
getAttribute
(
$attribute
)
{
if
(
$attribute
==
PDO
::
ATTR_DRIVER_NAME
)
return
$this
->
name
;
return
strtolower
(
$this
->
name
)
;
}
public
function
setAttribute
(
$attribute
,
$value
)
{
...
...
@@ -82,6 +82,9 @@ class AdapterStatementMock {
public
function
fetchAll
(
$fetchMode
)
{
return
array
();
}
public
function
execute
()
{
return
true
;
}
}
class
Doctrine_Driver_UnitTestCase
extends
UnitTestCase
{
protected
$driverName
=
false
;
...
...
@@ -107,6 +110,9 @@ class Doctrine_Driver_UnitTestCase extends UnitTestCase {
public
function
getDeclaration
(
$type
)
{
return
$this
->
dataDict
->
getPortableDeclaration
(
array
(
'type'
=>
$type
,
'name'
=>
'colname'
,
'length'
=>
1
,
'fixed'
=>
true
));
}
public
function
setDriverName
(
$driverName
)
{
$this
->
driverName
=
$driverName
;
}
public
function
init
()
{
$this
->
adapter
=
new
AdapterMock
(
$this
->
driverName
);
$this
->
manager
=
Doctrine_Manager
::
getInstance
();
...
...
@@ -123,7 +129,10 @@ class Doctrine_Driver_UnitTestCase extends UnitTestCase {
$tx
=
'Doctrine_Transaction_'
.
ucwords
(
$name
);
$dataDict
=
'Doctrine_DataDict_'
.
ucwords
(
$name
);
$exc
=
'Doctrine_Connection_'
.
ucwords
(
$name
)
.
'_Exception'
;
$this
->
exc
=
new
$exc
();
if
(
class_exists
(
$tx
))
$this
->
transaction
=
new
$tx
(
$this
->
conn
);
if
(
class_exists
(
$dataDict
))
{
...
...
tests/EnumTestCase.php
View file @
d1ad19fd
<?php
class
Doctrine_EnumTestCase
extends
Doctrine_UnitTestCase
{
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Enum_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Enum_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
$this
->
tables
=
array
(
"EnumTest"
);
...
...
tests/EventListenerChainTestCase.php
View file @
d1ad19fd
<?php
require_once
(
"UnitTestCase.php"
);
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_EventListener_Chain_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
EventListenerChainTest
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
"name"
,
"string"
,
100
);
...
...
tests/EventListenerTestCase.php
View file @
d1ad19fd
<?php
require_once
(
"UnitTestCase.php"
);
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_EventListener_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
EventListenerTest
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
"name"
,
"string"
,
100
);
...
...
@@ -36,7 +66,7 @@ class Doctrine_EventListener_TestLogger implements Doctrine_Overloadable, Counta
}
}
class
Doctrine_EventListenerTestCase
extends
Doctrine_UnitTestCase
{
class
Doctrine_EventListener
_
TestCase
extends
Doctrine_UnitTestCase
{
private
$logger
;
...
...
tests/ExportReporterTestCase.php
View file @
d1ad19fd
...
...
@@ -11,9 +11,16 @@ class Doctrine_Export_Reporter_TestCase extends Doctrine_Driver_UnitTestCase {
}
public
function
testExportChecksClassNaming
()
{
$reporter
=
$this
->
export
->
export
(
'BadLyNamed__Class'
);
// Class name is not valid. Double underscores are not allowed
$this
->
assertEqual
(
$reporter
->
pop
(),
array
(
E_WARNING
,
'Badly named class.'
));
}
public
function
testExportReportsExceptions
()
{
$reporter
=
$this
->
export
->
export
(
'User'
);
// Class name is not valid. Double underscores are not allowed
$this
->
assertEqual
(
$reporter
->
pop
(),
array
(
E_WARNING
,
Doctrine
::
ERR_CLASS_NAME
));
}
}
}
tests/ExportTestCase.php
View file @
d1ad19fd
<?php
class
Doctrine_Export_TestCase
extends
Doctrine_Driver_UnitTestCase
{
class
Doctrine_Export_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testCreateTableThrowsExceptionWithoutValidTableName
()
{
try
{
$this
->
export
->
createTable
(
0
,
array
(),
array
());
...
...
@@ -22,13 +20,13 @@ class Doctrine_Export_TestCase extends Doctrine_Driver_UnitTestCase {
}
public
function
testDropConstraintExecutesSql
()
{
$this
->
export
->
dropConstraint
(
'sometable'
,
'relevancy'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'ALTER TABLE sometable DROP CONSTRAINT relevancy_idx'
);
}
public
function
testCreateIndexExecutesSql
()
{
$this
->
export
->
createIndex
(
'sometable'
,
'relevancy'
,
array
(
'fields'
=>
array
(
'title'
=>
array
(),
'content'
=>
array
())));
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'CREATE INDEX relevancy ON sometable (title, content)'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'CREATE INDEX relevancy
_idx
ON sometable (title, content)'
);
}
public
function
testDropIndexExecutesSql
()
{
...
...
tests/ManagerTestCase.php
View file @
d1ad19fd
<?php
require_once
(
"UnitTestCase.php"
);
class
Doctrine_ManagerTestCase
extends
Doctrine_UnitTestCase
{
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Manager_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Manager_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testGetInstance
()
{
$this
->
assertTrue
(
Doctrine_Manager
::
getInstance
()
instanceOf
Doctrine_Manager
);
}
...
...
tests/PessimisticLockingTestCase.php
View file @
d1ad19fd
<?
PHP
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
require_once
(
"UnitTestCase.php"
);
class
Doctrine_PessimisticLockingTestCase
extends
Doctrine_UnitTestCase
{
/**
* Doctrine_Boolean_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_PessimisticLocking_TestCase
extends
Doctrine_UnitTestCase
{
private
$lockingManager
;
/**
...
...
tests/RecordStateTestCase.php
deleted
100644 → 0
View file @
a622f9ab
<?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/TableTestCase.php
View file @
d1ad19fd
<?php
require_once
(
"UnitTestCase.php"
);
class
Doctrine_TableTestCase
extends
Doctrine_UnitTestCase
{
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Table_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Table_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareTables
()
{
$this
->
tables
[]
=
"FieldNameTest"
;
parent
::
prepareTables
();
...
...
tests/TransactionFirebirdTestCase.php
deleted
100644 → 0
View file @
a622f9ab
<?php
class
Doctrine_Transaction_Firebird_TestCase
extends
Doctrine_Driver_UnitTestCase
{
public
function
__construct
()
{
parent
::
__construct
(
'firebird'
);
}
public
function
testCreateSavePointExecutesSql
()
{
$this
->
transaction
->
beginTransaction
(
'mypoint'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SAVEPOINT mypoint'
);
}
public
function
testReleaseSavePointExecutesSql
()
{
$this
->
transaction
->
commit
(
'mypoint'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'RELEASE SAVEPOINT mypoint'
);
}
public
function
testRollbackSavePointExecutesSql
()
{
$this
->
transaction
->
beginTransaction
(
'mypoint'
);
$this
->
transaction
->
rollback
(
'mypoint'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'ROLLBACK TO SAVEPOINT mypoint'
);
}
public
function
testSetIsolationThrowsExceptionOnUnknownIsolationMode
()
{
try
{
$this
->
transaction
->
setIsolation
(
'unknown'
);
$this
->
fail
();
}
catch
(
Doctrine_Transaction_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testSetIsolationThrowsExceptionOnUnknownWaitMode
()
{
try
{
$this
->
transaction
->
setIsolation
(
'READ UNCOMMITTED'
,
array
(
'wait'
=>
'unknown'
));
$this
->
fail
();
}
catch
(
Doctrine_Transaction_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testSetIsolationThrowsExceptionOnUnknownReadWriteMode
()
{
try
{
$this
->
transaction
->
setIsolation
(
'READ UNCOMMITTED'
,
array
(
'rw'
=>
'unknown'
));
$this
->
fail
();
}
catch
(
Doctrine_Transaction_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testSetIsolationExecutesSql
()
{
$this
->
transaction
->
setIsolation
(
'READ UNCOMMITTED'
);
$this
->
transaction
->
setIsolation
(
'READ COMMITTED'
);
$this
->
transaction
->
setIsolation
(
'REPEATABLE READ'
);
$this
->
transaction
->
setIsolation
(
'SERIALIZABLE'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION ISOLATION LEVEL SNAPSHOT TABLE STABILITY'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION ISOLATION LEVEL SNAPSHOT'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION ISOLATION LEVEL READ COMMITTED NO RECORD_VERSION'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION ISOLATION LEVEL READ COMMITTED RECORD_VERSION'
);
}
public
function
testSetIsolationSupportsReadWriteOptions
()
{
$this
->
transaction
->
setIsolation
(
'SERIALIZABLE'
,
array
(
'rw'
=>
'READ ONLY'
));
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION READ ONLY ISOLATION LEVEL SNAPSHOT TABLE STABILITY'
);
$this
->
transaction
->
setIsolation
(
'SERIALIZABLE'
,
array
(
'rw'
=>
'READ WRITE'
));
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION READ WRITE ISOLATION LEVEL SNAPSHOT TABLE STABILITY'
);
}
public
function
testSetIsolationSupportsWaitOptions
()
{
$this
->
transaction
->
setIsolation
(
'SERIALIZABLE'
,
array
(
'wait'
=>
'NO WAIT'
));
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION NO WAIT ISOLATION LEVEL SNAPSHOT TABLE STABILITY'
);
$this
->
transaction
->
setIsolation
(
'SERIALIZABLE'
,
array
(
'wait'
=>
'WAIT'
));
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION WAIT ISOLATION LEVEL SNAPSHOT TABLE STABILITY'
);
}
}
tests/TransactionMssqlTestCase.php
deleted
100644 → 0
View file @
a622f9ab
<?php
class
Doctrine_Transaction_Mssql_TestCase
extends
Doctrine_Driver_UnitTestCase
{
public
function
__construct
()
{
parent
::
__construct
(
'mssql'
);
}
public
function
testSetIsolationThrowsExceptionOnUnknownIsolationMode
()
{
try
{
$this
->
transaction
->
setIsolation
(
'unknown'
);
$this
->
fail
();
}
catch
(
Doctrine_Transaction_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testSetIsolationExecutesSql
()
{
$this
->
transaction
->
setIsolation
(
'READ UNCOMMITTED'
);
$this
->
transaction
->
setIsolation
(
'READ COMMITTED'
);
$this
->
transaction
->
setIsolation
(
'REPEATABLE READ'
);
$this
->
transaction
->
setIsolation
(
'SERIALIZABLE'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION ISOLATION LEVEL READ COMMITTED'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'
);
}
public
function
testSetIsolationSupportsSnapshotMode
()
{
$this
->
transaction
->
setIsolation
(
'SNAPSHOT'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET TRANSACTION ISOLATION LEVEL SNAPSHOT'
);
}
}
tests/TransactionMysqlTestCase.php
deleted
100644 → 0
View file @
a622f9ab
<?php
class
Doctrine_Transaction_Mysql_TestCase
extends
Doctrine_Driver_UnitTestCase
{
public
function
__construct
()
{
parent
::
__construct
(
'mysql'
);
}
public
function
testCreateSavePointExecutesSql
()
{
$this
->
transaction
->
beginTransaction
(
'mypoint'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SAVEPOINT mypoint'
);
}
public
function
testReleaseSavePointExecutesSql
()
{
$this
->
transaction
->
commit
(
'mypoint'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'RELEASE SAVEPOINT mypoint'
);
}
public
function
testRollbackSavePointExecutesSql
()
{
$this
->
transaction
->
beginTransaction
(
'mypoint'
);
$this
->
transaction
->
rollback
(
'mypoint'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'ROLLBACK TO SAVEPOINT mypoint'
);
}
public
function
testGetIsolationExecutesSql
()
{
$this
->
transaction
->
getIsolation
();
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SELECT @@tx_isolation'
);
}
public
function
testSetIsolationThrowsExceptionOnUnknownIsolationMode
()
{
try
{
$this
->
transaction
->
setIsolation
(
'unknown'
);
$this
->
fail
();
}
catch
(
Doctrine_Transaction_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testSetIsolationExecutesSql
()
{
$this
->
transaction
->
setIsolation
(
'READ UNCOMMITTED'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'
);
}
}
tests/TransactionOracleTestCase.php
deleted
100644 → 0
View file @
a622f9ab
<?php
class
Doctrine_Transaction_Oracle_TestCase
extends
Doctrine_Driver_UnitTestCase
{
public
function
__construct
()
{
parent
::
__construct
(
'oci'
);
}
public
function
testCreateSavePointExecutesSql
()
{
$this
->
transaction
->
beginTransaction
(
'mypoint'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SAVEPOINT mypoint'
);
}
public
function
testReleaseSavePointAlwaysReturnsTrue
()
{
$this
->
assertEqual
(
$this
->
transaction
->
commit
(
'mypoint'
),
true
);
}
public
function
testRollbackSavePointExecutesSql
()
{
$this
->
transaction
->
beginTransaction
(
'mypoint'
);
$this
->
transaction
->
rollback
(
'mypoint'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'ROLLBACK TO SAVEPOINT mypoint'
);
}
public
function
testSetIsolationThrowsExceptionOnUnknownIsolationMode
()
{
try
{
$this
->
transaction
->
setIsolation
(
'unknown'
);
$this
->
fail
();
}
catch
(
Doctrine_Transaction_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testSetIsolationExecutesSql
()
{
$this
->
transaction
->
setIsolation
(
'READ UNCOMMITTED'
);
$this
->
transaction
->
setIsolation
(
'READ COMMITTED'
);
$this
->
transaction
->
setIsolation
(
'REPEATABLE READ'
);
$this
->
transaction
->
setIsolation
(
'SERIALIZABLE'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'ALTER SESSION ISOLATION LEVEL SERIALIZABLE'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'ALTER SESSION ISOLATION LEVEL SERIALIZABLE'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'ALTER SESSION ISOLATION LEVEL SERIALIZABLE'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'ALTER SESSION ISOLATION LEVEL READ COMMITTED'
);
}
}
tests/TransactionPgsqlTestCase.php
deleted
100644 → 0
View file @
a622f9ab
<?php
class
Doctrine_Transaction_Pgsql_TestCase
extends
Doctrine_Driver_UnitTestCase
{
public
function
__construct
()
{
parent
::
__construct
(
'pgsql'
);
}
public
function
testCreateSavePointExecutesSql
()
{
$this
->
transaction
->
beginTransaction
(
'mypoint'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SAVEPOINT mypoint'
);
}
public
function
testReleaseSavePointExecutesSql
()
{
$this
->
transaction
->
commit
(
'mypoint'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'RELEASE SAVEPOINT mypoint'
);
}
public
function
testRollbackSavePointExecutesSql
()
{
$this
->
transaction
->
beginTransaction
(
'mypoint'
);
$this
->
transaction
->
rollback
(
'mypoint'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'ROLLBACK TO SAVEPOINT mypoint'
);
}
public
function
testSetIsolationThrowsExceptionOnUnknownIsolationMode
()
{
try
{
$this
->
transaction
->
setIsolation
(
'unknown'
);
$this
->
fail
();
}
catch
(
Doctrine_Transaction_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testSetIsolationExecutesSql
()
{
$this
->
transaction
->
setIsolation
(
'READ UNCOMMITTED'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'
);
}
}
tests/TransactionSqliteTestCase.php
deleted
100644 → 0
View file @
a622f9ab
<?php
class
Doctrine_Transaction_Sqlite_TestCase
extends
Doctrine_Driver_UnitTestCase
{
public
function
__construct
()
{
parent
::
__construct
(
'sqlite'
);
}
public
function
testSetIsolationThrowsExceptionOnUnknownIsolationMode
()
{
try
{
$this
->
transaction
->
setIsolation
(
'unknown'
);
$this
->
fail
();
}
catch
(
Doctrine_Transaction_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testSetIsolationExecutesSql
()
{
$this
->
transaction
->
setIsolation
(
'READ UNCOMMITTED'
);
$this
->
transaction
->
setIsolation
(
'READ COMMITTED'
);
$this
->
transaction
->
setIsolation
(
'REPEATABLE READ'
);
$this
->
transaction
->
setIsolation
(
'SERIALIZABLE'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'PRAGMA read_uncommitted = 1'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'PRAGMA read_uncommitted = 1'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'PRAGMA read_uncommitted = 1'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'PRAGMA read_uncommitted = 0'
);
}
}
tests/UnitTestCase.php
View file @
d1ad19fd
<?php
require_once
dirname
(
__FILE__
)
.
'/../lib/Doctrine.php'
;
//Doctrine::compile();
//require_once("../Doctrine.compiled.php");
//Doctrine::loadAll();
//ini_set('include_path', $_SERVER['DOCUMENT_ROOT']);
function
__autoload
(
$class
)
{
Doctrine
::
autoload
(
$class
);
}
require_once
(
"classes.php"
);
require_once
(
"simpletest/unit_tester.php"
);
require_once
(
"simpletest/reporter.php"
);
class
Doctrine_UnitTestCase
extends
UnitTestCase
{
protected
$manager
;
protected
$connection
;
...
...
@@ -31,6 +12,14 @@ class Doctrine_UnitTestCase extends UnitTestCase {
protected
$valueHolder
;
protected
$tables
=
array
();
protected
$unitOfWork
;
protected
$driverName
=
false
;
protected
$generic
=
false
;
protected
$conn
;
protected
$adapter
;
protected
$export
;
protected
$dataDict
;
protected
$transaction
;
private
$init
=
false
;
...
...
@@ -62,24 +51,68 @@ class Doctrine_UnitTestCase extends UnitTestCase {
);
$class
=
get_class
(
$this
);
$e
=
explode
(
'_'
,
$class
);
$this
->
driverName
=
'main'
;
switch
(
$e
[
1
])
{
case
'Export'
:
case
'Import'
:
case
'Expression'
:
case
'Transaction'
:
case
'DataDict'
:
$this
->
driverName
=
'Sqlite'
;
break
;
}
if
(
count
(
$e
)
>
3
)
{
$driver
=
$e
[
2
];
switch
(
$e
[
2
])
{
case
'Firebird'
:
case
'Informix'
:
case
'Mysql'
:
case
'Mssql'
:
case
'Oracle'
:
case
'Pgsql'
:
case
'Sqlite'
:
$this
->
driverName
=
$e
[
2
];
break
;
}
}
try
{
$this
->
connection
=
$this
->
manager
->
getConnection
(
'main'
);
$this
->
connection
=
$this
->
manager
->
getConnection
(
$this
->
driverName
);
$this
->
connection
->
evictTables
();
$this
->
dbh
=
$this
->
connection
->
getDBH
();
$this
->
dbh
=
$this
->
adapter
=
$this
->
connection
->
getDbh
();
$this
->
listener
=
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_LISTENER
,
$this
->
listener
);
}
catch
(
Doctrine_Manager_Exception
$e
)
{
//$this->dbh = Doctrine_Db::getConnection();
$this
->
dbh
=
Doctrine_Db
::
getConnection
(
"sqlite::memory:"
);
//$this->dbh = new PDO("sqlite::memory:");
if
(
$this
->
driverName
==
'main'
)
{
$this
->
dbh
=
Doctrine_Db
::
getConnection
(
"sqlite::memory:"
);
}
else
{
$this
->
dbh
=
$this
->
adapter
=
new
AdapterMock
(
$this
->
driverName
);
}
$this
->
connection
=
$this
->
manager
->
openConnection
(
$this
->
dbh
,
'main'
);
$this
->
connection
=
$this
->
manager
->
openConnection
(
$this
->
dbh
,
$this
->
driverName
);
if
(
$this
->
driverName
!==
'main'
)
{
$exc
=
'Doctrine_Connection_'
.
ucwords
(
$this
->
driverName
)
.
'_Exception'
;
$this
->
exc
=
new
$exc
();
}
else
{
}
$this
->
listener
=
new
Doctrine_EventListener_Debugger
();
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_LISTENER
,
$this
->
listener
);
}
if
(
$this
->
driverName
!==
'main'
)
{
$this
->
export
=
$this
->
connection
->
export
;
$this
->
transaction
=
$this
->
connection
->
transaction
;
$this
->
dataDict
=
$this
->
connection
->
dataDict
;
}
$this
->
unitOfWork
=
$this
->
connection
->
unitOfWork
;
$this
->
connection
->
setListener
(
new
Doctrine_EventListener
());
$this
->
query
=
new
Doctrine_Query
(
$this
->
connection
);
...
...
@@ -91,7 +124,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
}
public
function
prepareTables
()
{
foreach
(
$this
->
tables
as
$name
)
{
$query
=
"DROP TABLE "
.
Doctrine
::
tableize
(
$name
);
$query
=
'DROP TABLE '
.
Doctrine
::
tableize
(
$name
);
try
{
$this
->
dbh
->
query
(
$query
);
}
catch
(
PDOException
$e
)
{
...
...
@@ -106,61 +139,61 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$table
->
clear
();
}
$this
->
objTable
=
$this
->
connection
->
getTable
(
"User"
);
$this
->
objTable
=
$this
->
connection
->
getTable
(
'User'
);
}
public
function
prepareData
()
{
$groups
=
new
Doctrine_Collection
(
$this
->
connection
->
getTable
(
"Group"
));
$groups
=
new
Doctrine_Collection
(
$this
->
connection
->
getTable
(
'Group'
));
$groups
[
0
]
->
name
=
"Drama Actors"
;
$groups
[
0
]
->
name
=
'Drama Actors'
;
$groups
[
1
]
->
name
=
"Quality Actors"
;
$groups
[
1
]
->
name
=
'Quality Actors'
;
$groups
[
2
]
->
name
=
"Action Actors"
;
$groups
[
2
][
"Phonenumber"
][
0
]
->
phonenumber
=
"123 123"
;
$groups
[
2
]
->
name
=
'Action Actors'
;
$groups
[
2
][
'Phonenumber'
][
0
]
->
phonenumber
=
'123 123'
;
$groups
->
save
();
$users
=
new
Doctrine_Collection
(
$this
->
connection
->
getTable
(
"User"
)
);
$users
=
new
Doctrine_Collection
(
'User'
);
$users
[
0
]
->
name
=
"zYne"
;
$users
[
0
][
"Email"
]
->
address
=
"zYne@example.com"
;
$users
[
0
][
"Phonenumber"
][
0
]
->
phonenumber
=
"123 123"
;
$users
[
0
]
->
name
=
'zYne'
;
$users
[
0
][
'Email'
]
->
address
=
'zYne@example.com'
;
$users
[
0
][
'Phonenumber'
][
0
]
->
phonenumber
=
'123 123'
;
$users
[
1
]
->
name
=
"Arnold Schwarzenegger"
;
$users
[
1
]
->
Email
->
address
=
"arnold@example.com"
;
$users
[
1
][
"Phonenumber"
][
0
]
->
phonenumber
=
"123 123"
;
$users
[
1
][
"Phonenumber"
][
1
]
->
phonenumber
=
"456 456"
;
$users
[
1
]
->
Phonenumber
[
2
]
->
phonenumber
=
"789 789"
;
$users
[
1
]
->
name
=
'Arnold Schwarzenegger'
;
$users
[
1
]
->
Email
->
address
=
'arnold@example.com'
;
$users
[
1
][
'Phonenumber'
][
0
]
->
phonenumber
=
'123 123'
;
$users
[
1
][
'Phonenumber'
][
1
]
->
phonenumber
=
'456 456'
;
$users
[
1
]
->
Phonenumber
[
2
]
->
phonenumber
=
'789 789'
;
$users
[
1
]
->
Group
[
0
]
=
$groups
[
2
];
$users
[
2
]
->
name
=
"Michael Caine"
;
$users
[
2
]
->
Email
->
address
=
"caine@example.com"
;
$users
[
2
]
->
Phonenumber
[
0
]
->
phonenumber
=
"123 123"
;
$users
[
3
]
->
name
=
"Takeshi Kitano"
;
$users
[
3
]
->
Email
->
address
=
"kitano@example.com"
;
$users
[
3
]
->
Phonenumber
[
0
]
->
phonenumber
=
"111 222 333"
;
$users
[
4
]
->
name
=
"Sylvester Stallone"
;
$users
[
4
]
->
Email
->
address
=
"stallone@example.com"
;
$users
[
4
]
->
Phonenumber
[
0
]
->
phonenumber
=
"111 555 333"
;
$users
[
4
][
"Phonenumber"
][
1
]
->
phonenumber
=
"123 213"
;
$users
[
4
][
"Phonenumber"
][
2
]
->
phonenumber
=
"444 555"
;
$users
[
5
]
->
name
=
"Kurt Russell"
;
$users
[
5
]
->
Email
->
address
=
"russell@example.com"
;
$users
[
5
]
->
Phonenumber
[
0
]
->
phonenumber
=
"111 222 333"
;
$users
[
6
]
->
name
=
"Jean Reno"
;
$users
[
6
]
->
Email
->
address
=
"reno@example.com"
;
$users
[
6
]
->
Phonenumber
[
0
]
->
phonenumber
=
"111 222 333"
;
$users
[
6
][
"Phonenumber"
][
1
]
->
phonenumber
=
"222 123"
;
$users
[
6
][
"Phonenumber"
][
2
]
->
phonenumber
=
"123 456"
;
$users
[
7
]
->
name
=
"Edward Furlong"
;
$users
[
7
]
->
Email
->
address
=
"furlong@example.com"
;
$users
[
7
]
->
Phonenumber
[
0
]
->
phonenumber
=
"111 567 333"
;
$users
[
2
]
->
name
=
'Michael Caine'
;
$users
[
2
]
->
Email
->
address
=
'caine@example.com'
;
$users
[
2
]
->
Phonenumber
[
0
]
->
phonenumber
=
'123 123'
;
$users
[
3
]
->
name
=
'Takeshi Kitano'
;
$users
[
3
]
->
Email
->
address
=
'kitano@example.com'
;
$users
[
3
]
->
Phonenumber
[
0
]
->
phonenumber
=
'111 222 333'
;
$users
[
4
]
->
name
=
'Sylvester Stallone'
;
$users
[
4
]
->
Email
->
address
=
'stallone@example.com'
;
$users
[
4
]
->
Phonenumber
[
0
]
->
phonenumber
=
'111 555 333'
;
$users
[
4
][
'Phonenumber'
][
1
]
->
phonenumber
=
'123 213'
;
$users
[
4
][
'Phonenumber'
][
2
]
->
phonenumber
=
'444 555'
;
$users
[
5
]
->
name
=
'Kurt Russell'
;
$users
[
5
]
->
Email
->
address
=
'russell@example.com'
;
$users
[
5
]
->
Phonenumber
[
0
]
->
phonenumber
=
'111 222 333'
;
$users
[
6
]
->
name
=
'Jean Reno'
;
$users
[
6
]
->
Email
->
address
=
'reno@example.com'
;
$users
[
6
]
->
Phonenumber
[
0
]
->
phonenumber
=
'111 222 333'
;
$users
[
6
][
'Phonenumber'
][
1
]
->
phonenumber
=
'222 123'
;
$users
[
6
][
'Phonenumber'
][
2
]
->
phonenumber
=
'123 456'
;
$users
[
7
]
->
name
=
'Edward Furlong'
;
$users
[
7
]
->
Email
->
address
=
'furlong@example.com'
;
$users
[
7
]
->
Phonenumber
[
0
]
->
phonenumber
=
'111 567 333'
;
$this
->
users
=
$users
;
$this
->
connection
->
flush
();
...
...
tests/ValidatorTestCase.php
View file @
d1ad19fd
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Validator_TestCase
* TestCase for Doctrine's validation component.
*
* @todo More tests to cover the full interface of Doctrine_Validator_ErrorStack.
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_ValidatorTestCase
extends
Doctrine_UnitTestCase
{
class
Doctrine_Validator
_
TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareTables
()
{
$this
->
tables
[]
=
"ValidatorTest"
;
parent
::
prepareTables
();
...
...
tests/ViewTestCase.php
View file @
d1ad19fd
<?php
class
Doctrine_ViewTestCase
extends
Doctrine_UnitTestCase
{
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_View_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_View_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testCreateView
()
{
$query
=
new
Doctrine_Query
(
$this
->
connection
);
$query
->
from
(
'User'
);
...
...
tests/run.php
View file @
d1ad19fd
This diff is collapsed.
Click to expand it.
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