Monday, May 26, 2014

Re: Database schema for tests in 3.0.0-dev3

This looks like a bug, can you please create a Ticket?

On Monday, May 26, 2014 9:41:04 AM UTC+2, Joerg Henning wrote:
Hi,

not sure where to put this since I don't know it it's a defect or I'm just getting it wrong: trying to set up a test case using the latest 3.0.0 version. How would I generate the schema for the test database? Since there's no Schema shell, I'm trying to import the schema from my default database, like here: http://book.cakephp.org/3.0/en/development/testing.html#importing-table-information:

class TransactionFixture extends TestFixture
{
    public $import = ['table' => 'transactions', 'connection' => 'default'];
}

class TransactionsTest extends \Cake\TestSuite\TestCase
{
    public $fixtures = ['app.transaction'];

    public function testGetTransactions()
    {
        $table = Cake\ORM\TableRegistry::get('transactions');
        // ...
    }
}

However, that does not seem to work - it fails with the following error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mydb_test.transactions' doesn't exist

It seems it's trying to import the table from the test database, not from the default database as it should. Digging deeper into the problem, I see the following code in FixtureManager:

ConnectionManager::alias('test', 'default');

So since 'test' is aliased with 'default' how is this even supposed to ever work in the first place? The fixture would try to import the schema from the 'default' DB but since that one is aliased to 'test' so we end up trying to import from 'test' into 'test', don't we? Or am I getting it all wrong?

Any help appreciated,

Joerg

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: