theferrett's avatar

Cannot Use RefreshDatabase Trait On A Model With A Specified Connection?

So I've been trying to get our database testing to use transactions, and it hasn't been working - the changes we make in the testing methods leave data behind (changed values, inserted rows, etc) that persist over to the next test, causing them to fail.

Then, on a chance, I commented out the $connection string from the model we were testing, and lo! The RefreshDatabase worked as expected.

Is this a known bug? Is there something else we should be doing to get $connection to work with transactions inside tests?

class Game extends Model
{

    /**
     * The database connection name.
     *
     * @var string
     * 
     * Comment this out to get RefreshDatabase to work, yay
     */
    // protected $connection = 'specifiedConnection';
0 likes
1 reply

Please or to participate in this conversation.