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
1f188109
Commit
1f188109
authored
May 05, 2012
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBAL-214] Add test for new functionality
parent
d3930dcd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
13 deletions
+69
-13
DataAccessTest.php
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
+69
-13
No files found.
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
View file @
1f188109
...
@@ -407,19 +407,8 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -407,19 +407,8 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
*/
*/
public
function
testFetchAllSupportFetchClass
()
public
function
testFetchAllSupportFetchClass
()
{
{
if
(
isset
(
$GLOBALS
[
'db_type'
])
&&
$GLOBALS
[
'db_type'
]
==
"oci8"
)
{
$this
->
skipOci8AndMysqli
();
$this
->
markTestSkipped
(
"Not supported by OCI8"
);
$this
->
setupFixture
();
}
if
(
'mysqli'
==
$this
->
_conn
->
getDriver
()
->
getName
())
{
$this
->
markTestSkipped
(
'Mysqli driver dont support this feature.'
);
}
$this
->
_conn
->
executeQuery
(
'DELETE FROM fetch_table'
)
->
execute
();
$this
->
_conn
->
insert
(
'fetch_table'
,
array
(
'test_int'
=>
1
,
'test_string'
=>
'foo'
,
'test_datetime'
=>
'2010-01-01 10:10:10'
));
$sql
=
"SELECT test_int, test_string, test_datetime FROM fetch_table"
;
$sql
=
"SELECT test_int, test_string, test_datetime FROM fetch_table"
;
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
...
@@ -454,6 +443,73 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -454,6 +443,73 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
assertEquals
(
array
(
1
,
10
),
$rows
);
$this
->
assertEquals
(
array
(
1
,
10
),
$rows
);
}
}
/**
* @group DBAL-214
*/
public
function
testSetFetchModeClassFetchAll
()
{
$this
->
skipOci8AndMysqli
();
$this
->
setupFixture
();
$sql
=
"SELECT * FROM fetch_table"
;
$stmt
=
$this
->
_conn
->
query
(
$sql
);
$stmt
->
setFetchMode
(
\PDO
::
FETCH_CLASS
,
__NAMESPACE__
.
'\\MyFetchClass'
,
array
());
$results
=
$stmt
->
fetchAll
();
$this
->
assertEquals
(
1
,
count
(
$results
));
$this
->
assertInstanceOf
(
__NAMESPACE__
.
'\\MyFetchClass'
,
$results
[
0
]);
$this
->
assertEquals
(
1
,
$results
[
0
]
->
test_int
);
$this
->
assertEquals
(
'foo'
,
$results
[
0
]
->
test_string
);
$this
->
assertStringStartsWith
(
'2010-01-01 10:10:10'
,
$results
[
0
]
->
test_datetime
);
}
/**
* @group DBAL-214
*/
public
function
testSetFetchModeClassFetch
()
{
$this
->
skipOci8AndMysqli
();
$this
->
setupFixture
();
$sql
=
"SELECT * FROM fetch_table"
;
$stmt
=
$this
->
_conn
->
query
(
$sql
);
$stmt
->
setFetchMode
(
\PDO
::
FETCH_CLASS
,
__NAMESPACE__
.
'\\MyFetchClass'
,
array
());
$results
=
array
();
while
(
$row
=
$stmt
->
fetch
())
{
$results
[]
=
$row
;
}
$this
->
assertEquals
(
1
,
count
(
$results
));
$this
->
assertInstanceOf
(
__NAMESPACE__
.
'\\MyFetchClass'
,
$results
[
0
]);
$this
->
assertEquals
(
1
,
$results
[
0
]
->
test_int
);
$this
->
assertEquals
(
'foo'
,
$results
[
0
]
->
test_string
);
$this
->
assertStringStartsWith
(
'2010-01-01 10:10:10'
,
$results
[
0
]
->
test_datetime
);
}
private
function
setupFixture
()
{
$this
->
_conn
->
executeQuery
(
'DELETE FROM fetch_table'
)
->
execute
();
$this
->
_conn
->
insert
(
'fetch_table'
,
array
(
'test_int'
=>
1
,
'test_string'
=>
'foo'
,
'test_datetime'
=>
'2010-01-01 10:10:10'
));
}
private
function
skipOci8AndMysqli
()
{
if
(
isset
(
$GLOBALS
[
'db_type'
])
&&
$GLOBALS
[
'db_type'
]
==
"oci8"
)
{
$this
->
markTestSkipped
(
"Not supported by OCI8"
);
}
if
(
'mysqli'
==
$this
->
_conn
->
getDriver
()
->
getName
())
{
$this
->
markTestSkipped
(
'Mysqli driver dont support this feature.'
);
}
}
}
}
class
MyFetchClass
class
MyFetchClass
...
...
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