Skip to content

Commit

Permalink
[feature] Test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelaon committed Mar 30, 2021
1 parent 1a13134 commit 93827c2
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/Medoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Medoo
*
* @var string
*/
protected $type;
public $type;

/**
* Table prefix
Expand Down Expand Up @@ -106,6 +106,20 @@ class Medoo
*/
protected $logging = false;

/**
* Determine is in test mode.
*
* @var bool
*/
protected $testMode = false;

/**
* The query string last generated in test mode.
*
* @var string
*/
public $queryString;

/**
* Determine is in debug mode.
*
Expand Down Expand Up @@ -189,6 +203,11 @@ public function __construct(array $options)
$this->prefix = $options['prefix'];
}

if (isset($options['testMode']) && $options['testMode'] == true) {
$this->testMode = true;
return;
}

if (isset($options['logging']) && is_bool($options['logging'])) {
$this->logging = $options['logging'];
}
Expand Down Expand Up @@ -471,6 +490,11 @@ public function exec(string $statement, array $map = []) : ?PDOStatement
$this->errorInfo = null;
$this->error = null;

if ($this->testMode) {
$this->queryString = $this->generate($statement, $map);
return null;
}

if ($this->debugMode) {

if ($this->debugLogging) {
Expand Down

0 comments on commit 93827c2

Please sign in to comment.