I have a test which is failing due to a missing column in the database. The weird thing is the column is actually present.
Below is a little test I have run to prove that the column exists.
Controller
public function index()
{
if (Schema::hasColumn('occurrences', 'occurrenceable_type')) {
echo 'yes I have the bloody column';
} else {
echo 'no column for me!';
}
}
returns >> 'yes I have the bloody column';
Test
public function an_admin_can_create_a_new_occurrence()
{
if (Schema::hasColumn('occurrences', 'occurrenceable_type')) {
echo 'yes I have the bloody column';
} else {
echo 'no column for me!';
}
}
returns >> 'no column for me'
The differences between the test and controller are
Controller: database is a MySQL database connection
Testing: database is a MySQLite database running in memory.
the tests implement use RefreshDatabase;
and if a run a artisan migrate:refresh
on the MySQL database the column is present.
Why would there be differences between them? How can I solve it?
Aucun commentaire:
Enregistrer un commentaire