Accessing fixtures in CEPT functional tests

Hi all,

I’m still playing with functional tests, and I was wondering if there was a way to access the fixture data as you can do within PHPUnit tests, where you can access a specific row using the key of the fixture data array.

Ideally something like:




$I->amHttpAuthenticated($user->username, $user->password);

$I->sendGET('users/'.$user->id);



while having in the fixture:




return [

    'user' => [

        'username' => 'admin',

        'password' => 'on3wkend2onkjn12;lk1'

    ]

];



This highlights the thing I like least about using fixtures. As soon as you need to use a value from the fixture in a test, you have to use an opaque reference to the DB record and hope that’s the one you meant. When different records in the fixture are supposed to have different test outcomes then it’s just not DRY and I found it usually leads to tears.

In the PHP-Unit environment you can keep everything nice and DRY with data providers. You have a nice PHP data structure right there in the test class that you can use both to initialize the DB (as often as needed) and you can access the data as the tests run. If you encode the test outcome into the data structure then this is clean and easy does not lead to tears. (In other words, we avoid tears by not using a fixture, or, from another perspective, by moving it into the test class.)

This is the capability I think you should be asking for in f-tests, not the capability to read fixtures from the f-test environment.