Files
piratepoet/tests/_support/Helper/Database.php
Rostislav Wolny 9473579766 Fix type issues in tests
[MAILPOET-3296]
2020-12-07 11:36:01 +01:00

30 lines
768 B
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Helper;
use MailPoet\Config\Env;
use MailPoetVendor\Idiorm\ORM;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Database extends \Codeception\Module {
/**
* Load a SQL file
*
* @param string $filename Filename without extension
*/
static public function loadSQL($filename) {
global $wpdb;
$db = ORM::getDb();
$fullFilename = Env::$path . '/tests/_data/' . $filename . '.sql';
$sql = file_get_contents($fullFilename);
$sql = preg_replace('/`wp_/', '`' . $wpdb->prefix, $sql); // Use the current database prefix
if (!is_string($sql)) {
throw new \RuntimeException('Empty or missing ' . $fullFilename);
}
$db->exec($sql);
}
}