New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to use different fixtures for same tables. #8

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
1 participant
@o0h
Contributor

o0h commented Dec 18, 2017

I wrote pull request #6 , for different connections.
To make over-head caused by loading fixture less, often we define small fixtures by separating their $records .

This pr satisfies the needs by generating $_tableHashes by get_class() not db_name & table_name .


ex)

// Fixture A
class UsersFixture extends TestFixture
{
    public $import = ['table' => 'users'];
    public $records = [
        [
          'id' => 1,
          'name' => 'Alfred',
          'role' => 1,
          'created' => '2007-03-18 10:39:23',
          'modified' => '2007-03-18 10:41:31'
        ];
}

// Fixture B
class UsersWithAdminRoleFixture extends TestFixture
{
    public $import = ['table' => 'users'];
    public $records = [
        [
          'id' => 1,
          'name' => 'Alfred',
          'role' => 5,
          'created' => '2007-03-18 10:39:23',
          'modified' => '2007-03-18 10:41:31'
        ];
}

class UsersTest extends TestCase
{
    public $fixtures = ['app.Users', 'app.UsersWithAdminRoleFixture'];
    public $autoFixtures = false;

    public function testMyFunction()
    {
        $this->loadFixtures('Users');
    }

    public function testMyAnotherFunction()
    {
        $this->loadFixtures('UsersWithAdminRoleFixture');
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment