-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
[BUG] Unit tests not working when using :memory: driver sqlite database. #275
Comments
Do you have a 'create_cities_table' migration? |
I have similar issue (not same table of course), but I do have the VersionXXX files that when I run from the console create the tables I am looking for. (when I call the same methods myself not from phpunit they work) |
I don't see where you are running the migrations. We use in memory sqlite for our tests. We haven't had this issue. Have you tried adding the helper trait for refreshing the database during tests? It should be in the laravel doctrine migrations package. |
Cannot reproduce |
I have the same issue, I had to use a sqlite file instead of the in-memory version. I'm using Orchestra Testbench. |
I think this might be related to running the tests inside vm. |
I have same problem. |
You cannot use that trait as indeed we don't share the PDOConnection |
Any workaround available yet? I'm having this problem also. Can confirm this is a bug. More info:
This just confirms it again. Not sure whether it is |
This is my workaround so far. Provided you set up <?php
namespace Tests\Traits;
use Illuminate\Contracts\Console\Kernel;
trait RefreshDatabase
{
use \Illuminate\Foundation\Testing\RefreshDatabase;
/**
* Begin a database transaction on the testing database.
*
* @return void
*/
public function beginDatabaseTransaction()
{
$connection = $this->app->make('em')->getConnection();
$connection->beginTransaction();
$this->beforeApplicationDestroyed(function () use ($connection) {
$connection->rollBack();
});
}
/**
* Refresh the in-memory database.
*
* @return void
*/
protected function refreshInMemoryDatabase()
{
$this->artisan('doctrine:schema:create');
$this->app[Kernel::class]->setArtisan(null);
}
} It works without problems is several of my projects although for others I get If anyone has a better approach please let me know. |
Hi, any updates on this one? |
Package version, Laravel version
Laravel 5.5
Laravel doctrine 1.4
PHPUnit 6.0
Expected behaviour
Tests must pass success.
Actual behaviour
Entity manager can not access the tables in databases
Errors:
Steps to reproduce the behaviour
/config/database.php
/config/doctrine.php
phpunit.xml
ExampleTest.php
The text was updated successfully, but these errors were encountered: