Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4793818
MySQLiDatabaseResultTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
MySQLiDatabaseResultTest.php
View Options
<?php
namespace
Keruald\Database\Tests\Result
;
use
Keruald\Database\Engines\MySQLiEngine
;
use
Keruald\Database\Result\MySQLiDatabaseResult
;
use
PHPUnit\Framework\TestCase
;
class
MySQLiDatabaseResultTest
extends
TestCase
{
private
MySQLiDatabaseResult
$result
;
protected
function
setUp
()
:
void
{
$db
=
new
MySQLiEngine
(
'localhost'
,
''
,
''
,
'test_keruald_db'
);
$db
->
setFetchMode
(
MYSQLI_BOTH
);
$sql
=
"SELECT id, name, category FROM ships"
;
$this
->
result
=
$db
->
query
(
$sql
);
}
public
function
provideExpectedData
()
:
array
{
$data
=
[
// MYSQLI_NUM data
[
"1"
,
"So Much For Subtlety"
,
"GSV"
],
[
"2"
,
"Unfortunate Conflict Of Evidence"
,
"GSV"
],
[
"3"
,
"Just Read The Instructions"
,
"GCU"
],
[
"4"
,
"Just Another Victim Of The Ambient Morality"
,
"GCU"
],
];
return
array_map
(
function
(
$row
)
{
// MYSQLI_ASSOC data
return
$row
+
[
"id"
=>
$row
[
0
],
"name"
=>
$row
[
1
],
"category"
=>
$row
[
2
],
];
},
$data
);
}
public
function
testGetIterator
()
{
$actual
=
iterator_to_array
(
$this
->
result
->
getIterator
());
$this
->
assertEquals
(
$this
->
provideExpectedData
(),
$actual
);
}
public
function
testFetchRow
()
{
$expected
=
$this
->
provideExpectedData
()[
0
];
$this
->
assertEquals
(
$expected
,
$this
->
result
->
fetchRow
());
}
public
function
testNumRows
()
{
$this
->
assertEquals
(
4
,
$this
->
result
->
numRows
());
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Feb 28, 22:47 (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2437515
Default Alt Text
MySQLiDatabaseResultTest.php (1 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment