Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andergmartins/f9c61dd032fe49d2a1efdb46d3756422 to your computer and use it in GitHub Desktop.
Save andergmartins/f9c61dd032fe49d2a1efdb46d3756422 to your computer and use it in GitHub Desktop.
Get direct connection to Codeception Integration test DB
<?php
// This works inside a test class that extends \lucatume\WPBrowser\TestCase\WPTestCase.
$loaderConfig = $this->getModule('lucatume\WPBrowser\Module\WPLoader')->_getConfig();
$db = new \lucatume\WPBrowser\WordPress\Database\MysqlDatabase(
$loaderConfig['dbName'],
$loaderConfig['dbUser'],
$loaderConfig['dbPassword'],
$loaderConfig['dbHost'],
$loaderConfig['tablePrefix']
);
$pdo = $db->getPdo();
$statement = $pdo->prepare('SHOW TABLES');
$statement->execute();
$tables = $statement->fetchAll();
ray($tables);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment