-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
TypeError when runnig test with RefreshDatabase trait #2622
Comments
I've developed a new trait called My trait example <?php
namespace Tests;
use Illuminate\Foundation\Testing\RefreshDatabase as BaseRefreshDatabase;
trait RefreshDatabase
{
use BaseRefreshDatabase {
BaseRefreshDatabase::beginDatabaseTransaction as parentBeginDatabaseTransaction;
}
public function beginDatabaseTransaction()
{
return;
}
}
|
@medeiroz what purpose does that extra trait serve? Since the original trait itself is opt-in, wouldn't the better solution just be to not include the trait in the first place? |
Run my tests without errors |
@medeiroz Isn't the |
Question; if you replace your trait with the I see this issue more as a feature request than a bug report. The docs clearly state that this trait is not supported. So the failing tests are not something that this package is responsable for. @alcaeus yes you have to add this trait manually. |
@Treggats thanks for confirming. @medeiroz since the trait is opt-in, you shouldn't have to create a separate trait to undo the While I get the idea of making tests "faster" by using an uncommitted database transaction, this isn't compatible with MongoDB. For one, MongoDB does not support nested transactions, so using this trait would prevent you from using transactions in your application. Second, transactions are not tied to the connection but rather to a session, so it is theoretically possible to start a transaction, run a command within the transaction, then run a command outside of the transaction (e.g. with a different read preference). While I'm not entirely sure what use cases might prompt someone to do something like that, it's not something we want to prevent for the sake of testing. |
20221209.37+debian111.gbp3b38f2Description:
Eror when running test with RefreshDatabase trait
Steps to reproduce
Expected behaviour
Continue without errors
Actual behaviour
Logs:
The text was updated successfully, but these errors were encountered: