protected function mockYiiApplication($config = []) { $this->initAppFileSystem(); // // create user's config file, as it will override apps config for database connection in bootstrap //TODO: remove duplicates $env_db = getenv('DB_TYPE'); $db = $GLOBALS['db'][$env_db]; /* @var $mycfg \app\components\Configuration faking class */ $mycfg = json_decode(file_get_contents(self::$baseTestDir . '/data/default_config.json')); $mycfg->system->version = '1.1'; //to avoid migration install $mycfg->database->dbname = @$db['dbname']; $mycfg->database->filename = @$db['filename']; $mycfg->database->format = $env_db; $mycfg->database->host = @$db['host']; $mycfg->database->login = @$db['username']; $mycfg->database->password = @$db['password']; file_put_contents($this->getConfigFilename(), json_encode($mycfg)); // //work cfg $cfg = (require dirname(self::$baseTestDir) . '/config/config.php'); // make work cfg testable unset($cfg['id'], $cfg['basePath'], $cfg['vendorPath'], $cfg['components']['db']); parent::mockYiiApplication(\yii\helpers\ArrayHelper::merge($cfg, $config)); //var_dump(\Yii::$app->mycfg); die; }
protected function setUp() { parent::setUp(); $this->mockYiiApplication(['components' => ['mailer' => ['class' => \yii\swiftmailer\Mailer::class, 'useFileTransport' => true, 'viewPath' => '@app/emails', 'fileTransportPath' => '@runtime/mail', 'htmlLayout' => false, 'textLayout' => false, 'transport' => ['class' => \Swift_SmtpTransport::class, 'host' => 'smtp.sample.com', 'username' => 'test', 'password' => 'test', 'port' => '465', 'encryption' => 'ssl']]]]); }
/** * (non-PHPdoc) * @see PHPUnit_Extensions_Database_TestCase::setUp() */ protected function setUp() { parent::setUp(); $this->mockYiiApplication(); }
protected function setUp() { $this->mockYiiApplication(); $this->books = $this->setupFixture('books'); parent::setUp(); }
protected function setUp() { parent::setUp(); $this->initAppFileSystem(); }
public function setUp() { parent::setUp(); $this->security = new Security(); }