mini\Database\DatabaseInterface::withTables() Method

public abstract

Signature

public abstract function withTables(array $tables): mini\Database\DatabaseInterface

Parameters

Name Type Default Description
$tables array required Documentation missing

Returns

mini\Database\DatabaseInterface

Documentation

Create a VirtualDatabase with shadowed tables

Returns a VirtualDatabase where specified tables are replaced with mock data while all other tables remain accessible. Perfect for testing - shadow specific tables while keeping real data for others.

For PDODatabase: Creates VirtualDatabase with all real tables (as PartialQuery), then shadows with provided tables. Allows JOINs between mock and real data.

For VirtualDatabase: Inherits all existing tables, shadows with provided ones.

Example:

// Shadow users table with mock data, keep real orders
$testDb = $db->withTables(['users' => $mockUsers]);

// Can now JOIN mock users with real orders
$testDb->query('SELECT u.name, o.amount FROM users u JOIN orders o ON u.id = o.user_id');

Source

src/Database/DatabaseInterface.php:268