Last active
August 29, 2015 14:13
-
-
Save jkovacs618/31041c41a455374cddc8 to your computer and use it in GitHub Desktop.
Extension of Codeception\Lib\Connector\Yii2, used by CodeceptionYii2Module gist, for Multiple DBs and Shared Transactions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace tests\codeception\common\Lib\Connector; | |
use Yii; | |
/** | |
* Extended Codeception Yii2 Client: | |
* | |
* This custom class extends the original Codeception\Lib\Connector\Yii2 to | |
* support Multiple DBs and Shared Transactions. | |
* Used by tests\codeception\common\Module\Yii2. | |
*/ | |
class Yii2 extends \Codeception\Lib\Connector\Yii2 | |
{ | |
/** | |
* Array of DB Connection objects indexed by App DB component id string. | |
* Set by tests\codeception\common\Module\Yii2->_before($test) after creating DB Transactions. | |
* | |
* @var Array[string => \yii\db\Connection] | |
*/ | |
public $dbs = array(); | |
/** | |
* Create an Application object and set the DB Connection components to this->dbs objects. | |
* | |
* @return \yii\web\Application $app | |
*/ | |
public function startApp() | |
{ | |
$config = require($this->configFile); | |
if (!isset($config['class'])) { | |
$config['class'] = 'yii\web\Application'; | |
} | |
/** @var \yii\web\Application $app */ | |
$app = Yii::createObject($config); | |
if(sizeof($this->dbs) > 0) { | |
foreach($this->dbs as $db_id => $db) { | |
$app->set($db_id, $db); | |
} | |
} | |
return $app; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In yii2-advanced where i have to give the cleanup:false while accessing database