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
378ed91a
Commit
378ed91a
authored
Jul 05, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
615dcdb8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
25 deletions
+60
-25
ConnectionTestCase.php
tests/ConnectionTestCase.php
+60
-25
No files found.
tests/ConnectionTestCase.php
View file @
378ed91a
...
@@ -30,9 +30,11 @@
...
@@ -30,9 +30,11 @@
* @since 1.0
* @since 1.0
* @version $Revision$
* @version $Revision$
*/
*/
class
Doctrine_Connection_TestCase
extends
Doctrine_UnitTestCase
{
class
Doctrine_Connection_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testUnknownModule
()
{
public
function
testUnknownModule
()
{
try
{
try
{
$this
->
connection
->
unknown
;
$this
->
connection
->
unknown
;
$this
->
fail
();
$this
->
fail
();
...
@@ -40,14 +42,18 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
...
@@ -40,14 +42,18 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
$this
->
pass
();
$this
->
pass
();
}
}
}
}
public
function
testGetModule
()
{
public
function
testGetModule
()
{
$this
->
assertTrue
(
$this
->
connection
->
unitOfWork
instanceof
Doctrine_Connection_UnitOfWork
);
$this
->
assertTrue
(
$this
->
connection
->
unitOfWork
instanceof
Doctrine_Connection_UnitOfWork
);
//$this->assertTrue($this->connection->dataDict instanceof Doctrine_DataDict);
//$this->assertTrue($this->connection->dataDict instanceof Doctrine_DataDict);
$this
->
assertTrue
(
$this
->
connection
->
expression
instanceof
Doctrine_Expression
);
$this
->
assertTrue
(
$this
->
connection
->
expression
instanceof
Doctrine_Expression
_Driver
);
$this
->
assertTrue
(
$this
->
connection
->
transaction
instanceof
Doctrine_Transaction
);
$this
->
assertTrue
(
$this
->
connection
->
transaction
instanceof
Doctrine_Transaction
);
$this
->
assertTrue
(
$this
->
connection
->
export
instanceof
Doctrine_Export
);
$this
->
assertTrue
(
$this
->
connection
->
export
instanceof
Doctrine_Export
);
}
}
public
function
testFetchAll
()
{
public
function
testFetchAll
()
{
$this
->
conn
->
exec
(
'DROP TABLE entity'
);
$this
->
conn
->
exec
(
'DROP TABLE entity'
);
$this
->
conn
->
exec
(
'CREATE TABLE entity (id INT, name TEXT)'
);
$this
->
conn
->
exec
(
'CREATE TABLE entity (id INT, name TEXT)'
);
...
@@ -70,7 +76,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
...
@@ -70,7 +76,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
),
),
));
));
}
}
public
function
testFetchOne
()
{
public
function
testFetchOne
()
{
$c
=
$this
->
conn
->
fetchOne
(
'SELECT COUNT(1) FROM entity'
);
$c
=
$this
->
conn
->
fetchOne
(
'SELECT COUNT(1) FROM entity'
);
$this
->
assertEqual
(
$c
,
2
);
$this
->
assertEqual
(
$c
,
2
);
...
@@ -80,10 +88,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
...
@@ -80,10 +88,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$c
,
1
);
$this
->
assertEqual
(
$c
,
1
);
}
}
public
function
testFetchAssoc
()
{
}
public
function
testFetchColumn
()
public
function
testFetchColumn
()
{
{
$a
=
$this
->
conn
->
fetchColumn
(
'SELECT * FROM entity'
);
$a
=
$this
->
conn
->
fetchColumn
(
'SELECT * FROM entity'
);
$this
->
assertEqual
(
$a
,
array
(
$this
->
assertEqual
(
$a
,
array
(
...
@@ -97,7 +104,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
...
@@ -97,7 +104,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
0
=>
'1'
,
0
=>
'1'
,
));
));
}
}
public
function
testFetchArray
()
{
public
function
testFetchArray
()
{
$a
=
$this
->
conn
->
fetchArray
(
'SELECT * FROM entity'
);
$a
=
$this
->
conn
->
fetchArray
(
'SELECT * FROM entity'
);
$this
->
assertEqual
(
$a
,
array
(
$this
->
assertEqual
(
$a
,
array
(
...
@@ -112,14 +121,16 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
...
@@ -112,14 +121,16 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
1
=>
'zYne'
,
1
=>
'zYne'
,
));
));
}
}
public
function
testFetchRow
()
{
public
function
testFetchRow
()
{
$c
=
$this
->
conn
->
fetchRow
(
'SELECT * FROM entity'
);
$c
=
$this
->
conn
->
fetchRow
(
'SELECT * FROM entity'
);
$this
->
assertEqual
(
$c
,
array
(
$this
->
assertEqual
(
$c
,
array
(
'id'
=>
'1'
,
'id'
=>
'1'
,
'name'
=>
'zYne'
,
'name'
=>
'zYne'
,
));
));
$c
=
$this
->
conn
->
fetchRow
(
'SELECT * FROM entity WHERE id = ?'
,
array
(
1
));
$c
=
$this
->
conn
->
fetchRow
(
'SELECT * FROM entity WHERE id = ?'
,
array
(
1
));
$this
->
assertEqual
(
$c
,
array
(
$this
->
assertEqual
(
$c
,
array
(
...
@@ -127,18 +138,26 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
...
@@ -127,18 +138,26 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
'name'
=>
'zYne'
,
'name'
=>
'zYne'
,
));
));
}
}
public
function
testFetchPairs
()
{
public
function
testFetchPairs
()
{
$this
->
conn
->
exec
(
'DROP TABLE entity'
);
$this
->
conn
->
exec
(
'DROP TABLE entity'
);
}
}
public
function
testGetManager
()
{
public
function
testGetManager
()
{
$this
->
assertTrue
(
$this
->
connection
->
getManager
()
===
$this
->
manager
);
$this
->
assertTrue
(
$this
->
connection
->
getManager
()
===
$this
->
manager
);
}
}
public
function
testDelete
()
{
public
function
testDelete
()
{
$user
=
$this
->
connection
->
create
(
'User'
);
$user
=
$this
->
connection
->
create
(
'User'
);
$this
->
connection
->
unitOfWork
->
delete
(
$user
);
$this
->
connection
->
unitOfWork
->
delete
(
$user
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$user
->
state
(),
Doctrine_Record
::
STATE_TCLEAN
);
}
}
public
function
testGetTable
()
{
public
function
testGetTable
()
{
$table
=
$this
->
connection
->
getTable
(
'Group'
);
$table
=
$this
->
connection
->
getTable
(
'Group'
);
$this
->
assertTrue
(
$table
instanceof
Doctrine_Table
);
$this
->
assertTrue
(
$table
instanceof
Doctrine_Table
);
try
{
try
{
...
@@ -153,27 +172,41 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
...
@@ -153,27 +172,41 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
$this
->
assertTrue
(
$table
instanceof
UserTable
);
$this
->
assertTrue
(
$table
instanceof
UserTable
);
}
}
public
function
testCreate
()
{
public
function
testCreate
()
{
$email
=
$this
->
connection
->
create
(
'Email'
);
$email
=
$this
->
connection
->
create
(
'Email'
);
$this
->
assertTrue
(
$email
instanceof
Email
);
$this
->
assertTrue
(
$email
instanceof
Email
);
}
}
public
function
testGetDbh
()
{
$this
->
assertTrue
(
$this
->
connection
->
getDBH
()
instanceof
Doctrine_Db
);
public
function
testGetDbh
()
{
$this
->
assertTrue
(
$this
->
connection
->
getDbh
()
instanceof
PDO
);
}
}
public
function
testCount
()
{
public
function
testCount
()
{
$this
->
assertTrue
(
is_integer
(
count
(
$this
->
connection
)));
$this
->
assertTrue
(
is_integer
(
count
(
$this
->
connection
)));
}
}
public
function
testGetIterator
()
{
public
function
testGetIterator
()
{
$this
->
assertTrue
(
$this
->
connection
->
getIterator
()
instanceof
ArrayIterator
);
$this
->
assertTrue
(
$this
->
connection
->
getIterator
()
instanceof
ArrayIterator
);
}
}
public
function
testGetState
()
{
public
function
testGetState
()
{
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Transaction
::
STATE_SLEEP
);
$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
()
{
public
function
testGetTables
()
{
$this
->
assertTrue
(
is_array
(
$this
->
connection
->
getTables
()));
$this
->
assertTrue
(
is_array
(
$this
->
connection
->
getTables
()));
}
}
public
function
testRollback
()
{
public
function
testRollback
()
{
$this
->
connection
->
beginTransaction
();
$this
->
connection
->
beginTransaction
();
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Transaction
::
STATE_ACTIVE
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Transaction
::
STATE_ACTIVE
);
...
@@ -181,7 +214,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
...
@@ -181,7 +214,9 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Transaction
::
STATE_SLEEP
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Transaction
::
STATE_SLEEP
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
0
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
0
);
}
}
public
function
testNestedTransactions
()
{
public
function
testNestedTransactions
()
{
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
0
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
0
);
$this
->
connection
->
beginTransaction
();
$this
->
connection
->
beginTransaction
();
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
1
);
...
...
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