/var/www/vhosts/nabawater/vendor/yiisoft/yii2/test
Edit: /var/www/vhosts/nabawater/vendor/yiisoft/yii2/test/InitDbFixture.php (2804B)
* @since 2.0
*/
class InitDbFixture extends DbFixture
{
/**
* @var string the init script file that should be executed when loading this fixture.
* This should be either a file path or [path alias](guide:concept-aliases). Note that if the file does not exist,
* no error will be raised.
*/
public $initScript = '@app/tests/fixtures/initdb.php';
/**
* @var array list of database schemas that the test tables may reside in. Defaults to
* `['']`, meaning using the default schema (an empty string refers to the
* default schema). This property is mainly used when turning on and off integrity checks
* so that fixture data can be populated into the database without causing problem.
*/
public $schemas = [''];
/**
* {@inheritdoc}
*/
public function beforeLoad()
{
$this->checkIntegrity(false);
}
/**
* {@inheritdoc}
*/
public function afterLoad()
{
$this->checkIntegrity(true);
}
/**
* {@inheritdoc}
*/
public function load()
{
$file = Yii::getAlias($this->initScript);
if (is_file($file)) {
require $file;
}
}
/**
* {@inheritdoc}
*/
public function beforeUnload()
{
$this->checkIntegrity(false);
}
/**
* {@inheritdoc}
*/
public function afterUnload()
{
$this->checkIntegrity(true);
}
/**
* Toggles the DB integrity check.
* @param bool $check whether to turn on or off the integrity check.
*/
public function checkIntegrity($check)
{
if (!$this->db instanceof \yii\db\Connection) {
return;
}
foreach ($this->schemas as $schema) {
$this->db->createCommand()->checkIntegrity($check, $schema)->execute();
}
}
}