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
67947934
Commit
67947934
authored
Jul 21, 2010
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DDC-697 - Added more tests for Type Conversion during execution
parent
53209d99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
1 deletion
+53
-1
DataAccessTest.php
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
+53
-1
No files found.
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
View file @
67947934
...
...
@@ -2,6 +2,9 @@
namespace
Doctrine\Tests\DBAL\Functional
;
use
Doctrine\DBAL\Types\Type
;
use
PDO
;
require_once
__DIR__
.
'/../../TestInit.php'
;
class
DataAccessTest
extends
\Doctrine\Tests\DbalFunctionalTestCase
...
...
@@ -15,11 +18,12 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table
=
new
\Doctrine\DBAL\Schema\Table
(
"fetch_table"
);
$table
->
addColumn
(
'test_int'
,
'integer'
);
$table
->
addColumn
(
'test_string'
,
'string'
);
$table
->
addColumn
(
'test_datetime'
,
'datetime'
,
array
(
'notnull'
=>
false
));
$sm
=
$this
->
_conn
->
getSchemaManager
();
$sm
->
createTable
(
$table
);
$this
->
_conn
->
insert
(
'fetch_table'
,
array
(
'test_int'
=>
1
,
'test_string'
=>
'foo'
));
$this
->
_conn
->
insert
(
'fetch_table'
,
array
(
'test_int'
=>
1
,
'test_string'
=>
'foo'
,
'test_datetime'
=>
'2010-01-01 10:10:10'
));
}
catch
(
\Exception
$e
)
{
}
...
...
@@ -167,4 +171,52 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
assertEquals
(
'foo'
,
$testString
);
}
/**
* @group DDC-697
*/
public
function
testExecuteQueryBindDateTimeType
()
{
$sql
=
'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'
;
$stmt
=
$this
->
_conn
->
executeQuery
(
$sql
,
array
(
1
=>
new
\DateTime
(
'2010-01-01 10:10:10'
)),
array
(
1
=>
Type
::
DATETIME
)
);
$this
->
assertEquals
(
1
,
$stmt
->
fetchColumn
());
}
/**
* @group DDC-697
*/
public
function
testExecuteUpdateBindDateTimeType
()
{
$datetime
=
new
\DateTime
(
'2010-02-02 20:20:20'
);
$sql
=
'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)'
;
$affectedRows
=
$this
->
_conn
->
executeUpdate
(
$sql
,
array
(
1
=>
1
,
2
=>
'foo'
,
3
=>
$datetime
),
array
(
1
=>
PDO
::
PARAM_INT
,
2
=>
PDO
::
PARAM_STR
,
3
=>
Type
::
DATETIME
)
);
$this
->
assertEquals
(
1
,
$affectedRows
);
$this
->
assertEquals
(
1
,
$this
->
_conn
->
executeQuery
(
'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'
,
array
(
1
=>
$datetime
),
array
(
1
=>
Type
::
DATETIME
)
)
->
fetchColumn
());
}
/**
* @group DDC-697
*/
public
function
testPrepareQueryBindValueDateTimeType
()
{
$sql
=
'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'
;
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$stmt
->
bindValue
(
1
,
new
\DateTime
(
'2010-01-01 10:10:10'
),
Type
::
DATETIME
);
$stmt
->
execute
();
$this
->
assertEquals
(
1
,
$stmt
->
fetchColumn
());
}
}
\ No newline at end of file
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