Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4792661
MockDatabaseEngine.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
816 B
Referenced Files
None
Subscribers
None
MockDatabaseEngine.php
View Options
<?php
namespace
Keruald\Database\Engines
;
use
Keruald\Database\DatabaseEngine
;
use
Keruald\Database\Result\DatabaseResult
;
use
Keruald\Database\Result\MockDatabaseResult
;
use
RuntimeException
;
class
MockDatabaseEngine
extends
BlackholeEngine
{
private
array
$query_results
=
[];
public
function
withQueries
(
array
$query_results
)
:
self
{
$this
->
query_results
=
$query_results
;
return
$this
;
}
public
function
query
(
string
$query
)
:
DatabaseResult
|
bool
{
if
(!
array_key_exists
(
$query
,
$this
->
query_results
))
{
throw
new
RuntimeException
(
"Unexpected query: "
.
$query
);
}
return
new
MockDatabaseResult
(
$this
->
query_results
[
$query
]);
}
public
static
function
load
(
array
$config
)
:
DatabaseEngine
{
return
new
self
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Feb 28, 20:14 (9 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2440621
Default Alt Text
MockDatabaseEngine.php (816 B)
Attached To
Mode
rKDB Keruald Database
Attached
Detach File
Event Timeline
Log In to Comment