Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

TDD multiple databases

$
0
0
I am trying to test a model with a fixture. Nothing special, but in this case I am using two databases.
The DB's are in both setup main.php and test.php config files. The first db is named 'db', the second 'routedb'. The second DB has a 'class' => 'CDbConnection' (it's working while non-testing).

The Model has a public function

public function getDbConnection() {
    return Yii::app()->routedb;
  }

so it should select the other db.

But while testing with fixtures, it says
CException: Table 'tbl_route' does not exist.

Of course, this table exists in 'routedb'.

I work around this with commenting out the original 'db' and renaming 'routedb' to 'db', but that not the way I like it...

Is it possible to unittest with multiple databases? How do I do this?

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>