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
dded5346
Unverified
Commit
dded5346
authored
May 13, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for fetch*() methods of Portability\Result
parent
48625f1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
ResultTest.php
tests/Portability/ResultTest.php
+80
-0
No files found.
tests/Portability/ResultTest.php
View file @
dded5346
...
...
@@ -11,6 +11,86 @@ use PHPUnit\Framework\TestCase;
class
ResultTest
extends
TestCase
{
/**
* @param mixed $return
*
* @dataProvider fetchProvider
*/
public
function
testFetch
(
string
$source
,
callable
$fetch
,
$return
)
:
void
{
$driverResult
=
$this
->
createMock
(
DriverResult
::
class
);
$driverResult
->
expects
(
self
::
once
())
->
method
(
$source
)
->
willReturn
(
$return
);
$result
=
$this
->
newResult
(
$driverResult
);
self
::
assertSame
(
$return
,
$fetch
(
$result
));
}
/**
* @return iterable<string,array<int,mixed>>
*/
public
static
function
fetchProvider
()
:
iterable
{
yield
'numeric'
=>
[
'fetchNumeric'
,
static
function
(
Result
$result
)
:
array
{
return
$result
->
fetchNumeric
();
},
[
'bar'
],
];
yield
'associative'
=>
[
'fetchAssociative'
,
static
function
(
Result
$result
)
:
array
{
return
$result
->
fetchAssociative
();
},
[
'foo'
=>
'bar'
],
];
yield
'one'
=>
[
'fetchOne'
,
static
function
(
Result
$result
)
{
return
$result
->
fetchOne
();
},
'bar'
,
];
yield
'all-numeric'
=>
[
'fetchAllNumeric'
,
static
function
(
Result
$result
)
:
array
{
return
$result
->
fetchAllNumeric
();
},
[
[
'bar'
],
[
'baz'
],
],
];
yield
'all-associative'
=>
[
'fetchAllAssociative'
,
static
function
(
Result
$result
)
:
array
{
return
$result
->
fetchAllAssociative
();
},
[
[
'foo'
=>
'bar'
],
[
'foo'
=>
'baz'
],
],
];
yield
'first-column'
=>
[
'fetchFirstColumn'
,
static
function
(
Result
$result
)
:
array
{
return
$result
->
fetchFirstColumn
();
},
[
'bar'
,
'baz'
,
],
];
}
public
function
testRowCount
()
:
void
{
$driverResult
=
$this
->
createMock
(
DriverResult
::
class
);
...
...
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